[vtkusers] Polydata cell connectivity list

Wesley Brooks wesbrooks at gmail.com
Mon Feb 7 10:53:25 EST 2005


Thanks for your help. The program doesn't stall any more it just
doesn't find any cells which share points with each other...

This is the code as it stands now:


    def SupportCheck(self):

        print self.polydata



        print self.polydata

        for cellid in self.nobad:

            supcell = self.polydata.GetCell(cellid)

            pntid1 = supcell.GetPointId(0)
            pntid2 = supcell.GetPointId(1)

            coord1 = self.polydata.GetPoint(pntid1)
            coord2 = self.polydata.GetPoint(pntid2)

            if coord1[2] == coord2[2]:
                flag1 = self.SelectPoint(coord1[2], pntid1, cellid)
                flag2 = self.SelectPoint(coord2[2], pntid2, cellid)

            if coord1[2] > coord2[2]:
                flag = self.SelectPoint(coord2, pntid2, cellid)

            if coord1[2] < coord2[2]:
                flag = self.SelectPoint(coord1, pntid1, cellid)

        return self.supportlist

    def SelectPoint(self, z, pntid, cellid):
        cells = vtk.vtkIdList()

        ncells = 0

        self.polydata.GetPointCells(pntid, cells)

        numofcells = cells.GetNumberOfIds()

        for linkedcell in range(numofcells):
            idcell = cells.GetId(linkedcell)

            if idcell != self.nobad:

                chkcell = self.polydata.GetCell(idcell)

                chkpntid1 = chkcell.GetPointId(0)

                if chkpntid1 != pntid:
                    flag = self.CheckPnt(chkpntid1, z)
                elif chkpntid1 == pntid:
                    chkpntid2 = chkcell.GetPointId(1)
                    flag = self.CheckPnt(chkpntid2, z)

        if flag == 1:
            if pntid not in self.supportlist:

    def CheckPnt(self, pntid, z):
        flag = 1
        chkcoord = self.polydata.GetPoint(pntid)

        if chkcoord[2] < z:
            flag = 0

        return flag


I think my problem is something to do with the BuildLinks(0) call.

Briefly the code is supposed to save the ids of points of cells (each
cell is a line) which are in the list self.nobad and are connected to
no cells which have a point lower than it's lowest point.

However there's not much reason for you to look past the numofcells =
line as this is always seems to equal 1 now which it should not. The
polydata file is fine, I can view it before this opperation.

I've also viewed the polydata before and after the BuildLinks() and
seen no difference between them.

Thanks again for your help.


More information about the vtkusers mailing list