[vtkusers] Dependencies between vtkPolyData::BuildCells and ::BuildLinks

Hentschel, Bernd hentschel at rz.rwth-aachen.de
Fri Jan 14 10:52:38 EST 2005


Hi all,

I'm currently doing some mesh editing with vtkPolyData. Since this
involves some "topologically complex queries", I make use of
vtkPolyData::BuildCells and ::BuildLinks. The following snippet is meant
to illustrate the problem: 

vtkPolyData *pTarget = pReader->GetOutput();
std::set<vtkIdType> setIds;
pTarget->BuildLinks();
ComputeVertexNeighbors(0, pTarget , setIds);

Where ComputeVertex is (...well, if anyone came up with a more efficient
way of computing the 1-ring neighborhood, I would surely appreciate
that):

void ComputeVertexNeighbors(vtkIdType iVertexId, vtkPolyData* pMesh,
set<vtkIdType>& setNeighbors)
{
    vtkIdType* pIncidentCells;
    unsigned short iNumCells;
    
    pMesh->GetPointCells(iVertexId, iNumCells, pIncidentCells);
    
    int i=0;
    int j;
    vtkIdType* pIncidentPoints;
    vtkIdType iNumPoints;

    for(; i<iNumCells; ++iNumCells)
    {
        pMesh->GetCellPoints(pIncidentCells[i], iNumPoints,
pIncidentPoints);
        for(j=0; j<iNumPoints; ++j)
            if(j!=iVertexId)
                setNeighbors.insert(j);
    }
}

Later in my code I want to use vtkPolyData::GetCellPoints which needs
::BuildCells to be called beforehand. So I did the call and ended up
with ::GetPointCells(...) crashing in subsequent calls. Inserting
::BuildCells just before ComputeVertexNeighbors in the above snippet
will just do the same. So it seems to me, that ::BuildCells interferes
with ::BuildLinks, since mixing the two always ends with a crash at some
point in my final program. Moreover, as the ::Build* routines are rather
expensive, I want to call them as little as possible. So, could anyone
explain me the key dependencies and how to use this stuff "correctly"?
Thanx in advance!

Cheers,
	Bernd
    





More information about the vtkusers mailing list