Esempio n. 1
0
    def drawGL(self,mode='wireframe',color=None,colormap=None,alpha=None):
        """Draw the surface."""

        if mode.endswith('wire'):
            self.drawGL(mode='wireframe',color=asarray(black),colormap=None)
            self.drawGL(mode=mode[:-4],color=color,colormap=colormap,alpha=alpha)
            return

        if alpha is None:
            alpha = self.alpha           

        if color is None:  
            color,colormap = self.color,self.colormap
        else:
            color,colormap = saneColorSet(color,colormap,self.nelems())
        
        if color is None:  # no color
            pass
        
        elif color.dtype.kind == 'f' and color.ndim == 1:  # single color
            GL.glColor(append(color,alpha))
            color = None

        elif color.dtype.kind == 'i': # color index
            color = colormap[color]

        else: # a full color array : use as is
            pass

        if self.linewidth is not None:
            GL.glLineWidth(self.linewidth)

        t = timer.Timer()
        if mode=='wireframe' :
            rev = reverseIndex(self.faces)
            if color is not None:
                color = color[rev[:,-1]]
            drawLineElems(self.coords,self.edges,color)
        else:
            self.refresh()
            drawPolygonElems(self.coords,self.elems,mode,color,alpha)
        GD.debug("Drawing time: %s seconds" % t.seconds())
def removeTriangles(elems):
    """Remove the triangles from the centerline.
    
    This is a clean-up function for the centerline.
    Triangles appearing in the centerline are removed by this function.
    Both input and output are the connectivity of the centerline.
    """
    rev = connectivity.reverseIndex(elems)
    if rev.shape[1] > 2:
        w =  where(rev[:,-3] != -1)[0]
        for i in w:
            el = rev[i].compress(rev[i] != -1)
            u = unique(elems[el].reshape(-1))
            NB = u.compress(u != i)
            int = intersect1d(w,NB)
            if int.shape[0] == 2:
                tri = append(int,i)
                w1 = where(tri != tri.min())[0]
                t = (elems[:,0] == tri[w1[0]])*(elems[:,1] == tri[w1[1]])
                elems[t] = -1
    w2 = where(elems[:,0] != -1)[0]
    return elems[w2]
Esempio n. 3
0
def Finalize():
    DB.nid = connectivity.reverseIndex(DB.nodid.reshape((-1,1))).ravel()
    for k,v in DB.elems.iteritems():
        DB.elems[k] = array(v) - 1
    DB.modeldone = True