Ejemplo n.º 1
0
def drawFaces(x,e,faces,mode,color=None,alpha=1.0):
    """Draw the faces of a geometry.

    This function draws the faces of a geometry collection, usually of a higher
    dimensionality (i.c. a volume).
    The faces are identified by a constant indices into all element vertices.

    The geometry is specified by x or (x,e)
    The faces are specified by a list of lists. Each list defines a single
    face of the solid, in local vertex numbers (0..nplex-1). The faces are
    sorted and collected according to their plexitude before drawing them. 
    """
    GD.debug("drawFaces")
    # We may have faces with different plexitudes!
    for fac in olist.collectOnLength(faces).itervalues():
        fa = asarray(fac)
        nplex = fa.shape[1]
        if e is None:
            coords = x[:,fa,:]
            elems = None
        else:
            coords = x
            elems = e[:,fa]
        GD.debug("COORDS SHAPE: %s" % str(coords.shape))
        if elems is not None:
            GD.debug("ELEMS SHAPE: %s" % str(elems.shape))
        if color is not None and color.ndim==3:
            GD.debug("COLOR SHAPE BEFORE EXTRACTING: %s" % str(color.shape))
            # select the colors of the matching points
            color = color[:,fa,:]
            color = color.reshape((-1,)+color.shape[-2:])
            GD.debug("COLOR SHAPE AFTER EXTRACTING: %s" % str(color.shape))
        draw_parts(coords,elems,mode,color,alpha)
Ejemplo n.º 2
0
def drawFaceElems(x,faces,mode,color=None,alpha=1.0):
    """Draw a collection of faces.

    This function is like drawFaces, but the coordinates of the faces are
    specified by:
    x (nel,nplex) : the coordinates of solid elements
    faces (nfaces,fplex): the definition of nfaces faces of the solid,
      each with plexitude fplex. Each line of faces defines a single
      face of the solid, in local vertex numbers (0..nplex-1)
    """
    # We may have faces with different plexitudes!
    for fac in olist.collectOnLength(faces).itervalues():
        fa = asarray(fac)
        drawFaces(x[:,fa.ravel(),:],fa.shape[1],mode,color,alpha)
Ejemplo n.º 3
0
def drawEdges(x,e,edges,eltype,color=None):
    """Draw the edges of a geometry.

    This function draws the edges of a geometry collection, usually of a higher
    dimensionality (i.c. a surface or a volume).
    The edges are identified by constant indices into all element vertices.

    The geometry is specified by x or (x,e)
    The edges are specified by a list of lists. Each list defines a single
    edge of the solid, in local vertex numbers (0..nplex-1).

    If eltype is None, the edges are drawn as polygons. Other allowed values
    are: 'line3'
    """
    pf.debug("drawEdges",pf.DEBUG.DRAW)
    if not type(eltype) == str:
        eltype = eltype.name()
    # We may have edges with different plexitudes!
    # We collect them according to plexitude.
    # But first convert to a list, so that we can call this function
    # with an array too (in case of a single plexitude)
    edges = list(edges)
    for edg in olist.collectOnLength(edges).itervalues():
        fa = asarray(edg)
        nplex = fa.shape[1]
        if e is None:
            coords = x[:,fa,:]
            elems = None
        else:
            coords = x
            elems = e[:,fa]
        pf.debug("COORDS SHAPE: %s" % str(coords.shape),pf.DEBUG.DRAW)
        if elems is not None:
            pf.debug("ELEMS SHAPE: %s" % str(elems.shape),pf.DEBUG.DRAW)
        if color is not None and color.ndim==3:
            pf.debug("COLOR SHAPE BEFORE EXTRACTING: %s" % str(color.shape),pf.DEBUG.DRAW)
            # select the colors of the matching points
            color = color[:,fa,:]
            pf.debug("COLOR SHAPE AFTER EXTRACTING: %s" % str(color.shape),pf.DEBUG.DRAW)

        if eltype == 'line3':
            if 'line3' in pf.cfg['draw/quadline']:
                drawQuadraticCurves(coords,elems,color)
            else:
                draw_faces(coords,elems,color,1.0,objtype=GL.GL_LINE_STRIP)
        else:
            draw_faces(coords,elems,color,1.0)
Ejemplo n.º 4
0
def drawFaces(x,e,faces,eltype,color=None,alpha=1.0,texture=None,texc=None,normals=None,lighting=False,avgnormals=False):
    """Draw the faces of a geometry.

    This function draws the faces of a geometry collection, usually of a higher
    dimensionality (i.c. a volume).
    The faces are identified by a constant indices into all element vertices.

    The geometry is specified by x or (x,e)
    The faces are specified by a list of lists. Each list defines a single
    face of the solid, in local vertex numbers (0..nplex-1). The faces are
    sorted and collected according to their plexitude before drawing them.
    """
    pf.debug("drawFaces",pf.DEBUG.DRAW)
    # We may have faces with different plexitudes!
    # We collect them according to plexitude.
    # But first convert to a list, so that we can call this function
    # with an array too (in case of a single plexitude)
    faces = list(faces)
    for fac in olist.collectOnLength(faces).itervalues():
        fa = asarray(fac)
        nplex = fa.shape[1]
        if e is None:
            coords = x[:,fa,:]
            elems = None
        else:
            coords = x
            elems = e[:,fa]
        pf.debug("COORDS SHAPE: %s" % str(coords.shape),pf.DEBUG.DRAW)
        if elems is not None:
            pf.debug("ELEMS SHAPE: %s" % str(elems.shape),pf.DEBUG.DRAW)
        if color is not None:
            pf.debug("COLOR SHAPE: %s" % str(color.shape),pf.DEBUG.DRAW)
            # select the colors of the matching points
            if color.ndim==3:
                color = color[:,fa,:]
                pf.debug("COLOR SHAPE AFTER EXTRACTING: %s" % str(color.shape),pf.DEBUG.DRAW)
        if eltype in pf.cfg['draw/quadsurf'] and eltype in _nurbs_elements:
            #print "USING QUADSURF"
            drawQuadraticSurfaces(coords,elems,color)
        else:
            #print "USING POLYGON"
            draw_faces(coords,elems,color,alpha,texture,texc,normals,lighting,avgnormals)
Ejemplo n.º 5
0
 def getFaces():
     return olist.collectOnLength(self.faces)
Ejemplo n.º 6
0
 def getFaces(self):
     return collectOnLength(self.faces)