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
<span style="font-style: italic;">all</span> 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 clear="all">
<br>-- <br>-Deal in puns!