[vtkusers] having a hard time using vtkConvexPointSet

jelle jelleferinga at gmail.com
Thu Jul 12 13:20:09 EDT 2007


Hi,

I'm having trouble using vtkConvexPointSet from python.
I wrote the following methods to construct a vtkUnstructeredGrid that'll 
contain the convex point sets, where self.ugrid refers to the 
vtkUnstructeredGrid instance, and self.pts to the vtkPoints instance.

My questions are:

a) in a vtkConvexPointSet, are the resulting individual cells convex?
since vtkConvexPointSet doesn't use the GetOutput idiom, I've got a hard time 
figuring out exactly where in the pipeline to plug it.

b) the .tcl example of vtkConvexPointSet is interesting, but differs from what 
I'm doing, since I need to generate a series of convex cells. So, my data is a 
list of list, which are the points that make up a voronoi site, which is 
inherently convex. in constructUgridA traverses through this lists, and makes 
a new vtkIdList for every single voronoi site. so i'm worried that this will 
make a convex hull of all cells, rather than individual cells. when i update 
the vtkUnstructuredGrid instance, all seems ok, the right number of cells are 
generated. but when launching the program, it hangs (i've checked that this is 
due the ugrid instance).

c) constructGridB tries to acomplish the same thing, however, here single 
instance of vtkConvexPointSet are used. the result is pretty similar: the 
object looks proper, it returns an list of cell types for instance (all 41), 
but crashes for instance when I use the BuildLinks method...

d) i'm very curious to know _if_ these two different methods are really 
different actually! am i just calling the same methods via a different route?

What am I doing wrong here? It should be fairly straightforward to do this, 
though I'm surprised that VTK is crashing pretty seriously. Probably I've 
misunderstood the InsertNextCell method... 

Many thanks,

-jelle


    def constructUgridA(self):
        '''
        '''
        assert self.__build == 1, 'voronoi cells not yet build'
        self.ugrid.allocate(12*self.pts.shape[0],12*self.pts.shape[0])
        self.ugrid.points = self.pts
        
        # nessecary?
        # construct topology
        idList = self.convex._vtk_obj.GetPointIds()
        self.cellIDs = {}
        
        vertexIndex = 0
        
        for n_cell, cell in enumerate(self.voronoiCells):
            for vert in cell:
                idList.InsertId(vertexIndex, vertexIndex)
                vertexIndex+=1
            self.cellIDs[n_cell]=idList
            idList = idList.NewInstance()
        
        for v in self.cellIDs.itervalues():
            self.ugrid.insert_next_cell(self.convex._get_cell_type(), v)
        
        self.ugrid.update()
    def constructUgridB(self):
        '''
        '''
        assert self.__build == 1, 'voronoi cells not yet build'
        self.ugrid.allocate(12*self.pts.shape[0],12*self.pts.shape[0])
        self.ugrid.points = self.pts
        
        # nessecary?
        # construct topology
        
        cnvxPtSet = tvtk.ConvexPointSet()
        self.cnvxPtSets = {}
        
        vertexIndex = 0
        
        for n_cell, cell in enumerate(self.voronoiCells):
            for vert in cell:
                cnvxPtSet._vtk_obj.GetPointIds().InsertId(vertexIndex, 
vertexIndex)
                vertexIndex+=1
            self.cnvxPtSets[n_cell]=cnvxPtSet
            cnvxPtSet = cnvxPtSet.new_instance()
        
        for v in self.cnvxPtSets.itervalues():
            self.ugrid.insert_next_cell(v.cell_type, v._get_point_ids())
        
        self.ugrid.update()




More information about the vtkusers mailing list