[Insight-users] Can a Vertex find its Lines?

Alexandre GOUAILLARD hanfei at caltech.edu
Thu Jul 26 18:32:20 EDT 2007


Hi paul,

At the cell level, the cell interface API (boundaryfeatures functions) gives
you only informations about their boundaries i.e. All the cells of
(topological) dimension equal or inferior to itself¹s.

At the itk::Mesh level, you have an interface to get what you want, even
though it has not been directly exported into a nice GetPointCells function.
The structure is there though. You need to call BuildLinks first and then to
access directly the CellLinksContainer. You can take a look at the
implementation of getCellNeighbors to see how it works.
Indeed a lot of filter implementations recode a local array to stock this
information (simplex mesh, spherical wavelet, ...). Alas.

If you use the cvs version of ITK, compiled with the advanced USE_REVIEW
option on, and if you mesh is a surface mesh, you can use an
itk::QuadEdgeMesh which will give you a direct iterator to the 1-ring of a
point (Point->GetEdge( )->BeginGeomOnext( )). This iterator is consistant
with the orientation and allows you to access the points (GetDestination( ))
as well of the faces (GetLeft( )) of the one ring.

Alex.

On 7/26/07 3:16 PM, "Paul Dennis" <aaeamdar at gmail.com> wrote:

> First of all, I apologize in advance if this is a stupid question that gets
> asked every month. I'm relatively new to programming and even more new to ITK,
> so I am unsure if this is a reasonable query or not.
> 
> Here's the problem: using the "Mesh" structure of ITK (an itk::Mesh), is it
> possible for a VertexCell to have information about the higher-dimension cells
> that it's associated with? In other words, is there an equivalent to:
> 
> pointerToMyVertexCell->GetLinesAssociatedWithMe(dimension);
> 
> My initial findings seem to indicate that no, there is no built in way to do
> this in ITK. I am using a K-complex from the itk::AutomaticTopologyMeshSource
> template. I have quite a few triangles, each of which has 3 lines and 3 points
> attached to it. I'm using the following code segment to iterate through all
> the cells and print out information (sorry this is dense and without
> commenting): 
> 
> 
> void printCells(MeshType::Pointer pMesh)
>     {
>         CellIterator cellIterator    = pMesh->GetCells()->Begin();
>         CellIterator cellEnd        = pMesh->GetCells()->End();
> 
>         CellType::CellAutoPointer tempCellPointer;
> 
>         while( cellIterator != cellEnd )
>         {
>             CellType * pCell = cellIterator.Value();
>             cout << pCell->GetNameOfClass() << endl;
> 
>             int type = pCell->GetType();
>             int a = pCell->GetNumberOfBoundaryFeatures(VERTEX_DIMENSION);
>             int b = pCell->GetNumberOfBoundaryFeatures(LINE_DIMENSION);
> 
>             switch (type)
>             {
>                 case CellType::VERTEX_CELL:
>                     cout << "\tpointId = " <<
> ((VertexType*)pCell)->GetPointId() << endl;
>                     cout << "numBoundfeats = " <<
> ((VertexType*)pCell)->GetNumberOfBoundaryFeatures(LINE_DIMENSION) << endl;
>                     break;
> 
>                 case CellType::LINE_CELL:
>                     for (int i = 0; i < a; i++)
>                     {
>                         pCell->GetBoundaryFeature(VERTEX_DIMENSION, i,
> tempCellPointer);
>                         cout << "\t" << tempCellPointer->GetNameOfClass() <<
> endl;
>                         VertexType * pVertex = dynamic_cast< VertexType*
> >(tempCellPointer.GetPointer ());
>                         assert (pVertex != NULL);
>                         cout << "\t\tpointId = " << pVertex->GetPointId() <<
> endl;
>                     }
>                     break;
>                  
>                 case CellType::TRIANGLE_CELL:
>                     for (int i = 0; i < b; i++)
>                     {
>                         pCell->GetBoundaryFeature(LINE_DIMENSION, i,
> tempCellPointer);
>                         cout << "\t" << tempCellPointer->GetNameOfClass() <<
> endl;
>                         int c =
> tempCellPointer->GetNumberOfBoundaryFeatures(VERTEX_DIMENSION);
>                         VertexType::CellAutoPointer tempVertexPointer;
>                         for (int j = 0; j < c; j++)
>                         {
>                  
> tempCellPointer->GetBoundaryFeature(VERTEX_DIMENSION, j, tempVertexPointer);
>                             cout << "\t\t" <<
> tempVertexPointer->GetNameOfClass() << endl;
>                             VertexType * pVertex = dynamic_cast< VertexType*
> >(tempVertexPointer.GetPointer ());
>                             assert (pVertex != NULL);
>                             cout << "\t\t\t pointId = " <<
> pVertex->GetPointId() << endl;
>                         }
>                     }
>                     break;
> 
>                 default:
>                     cout << "Unrecognized format." << endl;
>                     break;
>             }
>             ++cellIterator;
>         }
>     }
> 
> Which generates output like this:
> 
> TriangleCell
>     LineCell
>         VertexCell
>             pointId = 4223
>         VertexCell
>             pointId = 3958
> etc etc...
> 
> However, so far I have only been able to iterate downwards in the dimension
> tree (i.e. Triangle->Line->Vertex) and not up.
> 
> Alternatively, if it's not possible to find higher-dimension cells from
> lower-dimension ones, is there a good way to find the neighboring VertexCells
> of a given VertexCell? One approach would be to go through all  of the cells
> and call their euclideanDistanceTo(Point) methods, but this would be
> a)time-consuming and b) unreliable.
> 
> At the moment, I'm thinking of creating a separate array and filling it when I
> call the addTriangle(Point, Point, Point) method so that I have independent
> information about which triangles a given point is a member of. Is there a
> better way? 
> 
> Thanks,
> Paul Dennis


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070726/1db34ffb/attachment.html


More information about the Insight-users mailing list