<HTML>
<HEAD>
<TITLE>Re: [Insight-users] Can a Vertex find its Lines?</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>Hi paul,<BR>
<BR>
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. <BR>
<BR>
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.<BR>
Indeed a lot of filter implementations recode a local array to stock this information (simplex mesh, spherical wavelet, ...). Alas.<BR>
<BR>
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.<BR>
<BR>
Alex.<BR>
<BR>
On 7/26/07 3:16 PM, "Paul Dennis" <aaeamdar@gmail.com> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>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.<BR>
<BR>
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: <BR>
<BR>
pointerToMyVertexCell->GetLinesAssociatedWithMe(dimension);<BR>
<BR>
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): <BR>
<BR>
<BR>
void printCells(MeshType::Pointer pMesh)<BR>
{<BR>
CellIterator cellIterator = pMesh->GetCells()->Begin();<BR>
CellIterator cellEnd = pMesh->GetCells()->End();<BR>
<BR>
CellType::CellAutoPointer tempCellPointer; <BR>
<BR>
while( cellIterator != cellEnd )<BR>
{<BR>
CellType * pCell = cellIterator.Value();<BR>
cout << pCell->GetNameOfClass() << endl;<BR>
<BR>
int type = pCell->GetType(); <BR>
int a = pCell->GetNumberOfBoundaryFeatures(VERTEX_DIMENSION);<BR>
int b = pCell->GetNumberOfBoundaryFeatures(LINE_DIMENSION);<BR>
<BR>
switch (type)<BR>
{<BR>
case CellType::VERTEX_CELL: <BR>
cout << "\tpointId = " << ((VertexType*)pCell)->GetPointId() << endl;<BR>
cout << "numBoundfeats = " << ((VertexType*)pCell)->GetNumberOfBoundaryFeatures(LINE_DIMENSION) << endl; <BR>
break;<BR>
<BR>
case CellType::LINE_CELL:<BR>
for (int i = 0; i < a; i++)<BR>
{<BR>
pCell->GetBoundaryFeature(VERTEX_DIMENSION, i, tempCellPointer); <BR>
cout << "\t" << tempCellPointer->GetNameOfClass() << endl;<BR>
VertexType * pVertex = dynamic_cast< VertexType* >(tempCellPointer.GetPointer ());<BR>
assert (pVertex != NULL);<BR>
cout << "\t\tpointId = " << pVertex->GetPointId() << endl;<BR>
}<BR>
break; <BR>
<BR>
case CellType::TRIANGLE_CELL:<BR>
for (int i = 0; i < b; i++)<BR>
{<BR>
pCell->GetBoundaryFeature(LINE_DIMENSION, i, tempCellPointer); <BR>
cout << "\t" << tempCellPointer->GetNameOfClass() << endl;<BR>
int c = tempCellPointer->GetNumberOfBoundaryFeatures(VERTEX_DIMENSION);<BR>
VertexType::CellAutoPointer tempVertexPointer;<BR>
for (int j = 0; j < c; j++)<BR>
{<BR>
tempCellPointer->GetBoundaryFeature(VERTEX_DIMENSION, j, tempVertexPointer); <BR>
cout << "\t\t" << tempVertexPointer->GetNameOfClass() << endl;<BR>
VertexType * pVertex = dynamic_cast< VertexType* >(tempVertexPointer.GetPointer ());<BR>
assert (pVertex != NULL);<BR>
cout << "\t\t\t pointId = " << pVertex->GetPointId() << endl;<BR>
}<BR>
} <BR>
break;<BR>
<BR>
default:<BR>
cout << "Unrecognized format." << endl;<BR>
break;<BR>
}<BR>
++cellIterator; <BR>
}<BR>
}<BR>
<BR>
Which generates output like this:<BR>
<BR>
TriangleCell<BR>
LineCell<BR>
VertexCell<BR>
pointId = 4223<BR>
VertexCell<BR>
pointId = 3958<BR>
etc etc...<BR>
<BR>
However, so far I have only been able to iterate downwards in the dimension tree (i.e. Triangle->Line->Vertex) and not up.<BR>
<BR>
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. <BR>
<BR>
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? <BR>
<BR>
Thanks,<BR>
Paul Dennis<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
</SPAN></FONT>
</BODY>
</HTML>