00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __TriangleMeshToSimplexMeshFilter_h
00018 #define __TriangleMeshToSimplexMeshFilter_h
00019
00020 #include <itkMesh.h>
00021 #include <itkLineCell.h>
00022 #include <itkVertexCell.h>
00023 #include <itkMapContainer.h>
00024 #include "itkSimplexMesh.h"
00025 #include "itkSimplexMeshGeometry.h"
00026 #include "itkMeshToMeshFilter.h"
00027 #include "itkVectorContainer.h"
00028 #include "itkNumericTraits.h"
00029
00030 #include <itkPolygonCell.h>
00031 namespace itk
00032 {
00047 template <class TInputMesh, class TOutputMesh>
00048 class TriangleMeshToSimplexMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00049 {
00050 public:
00051
00053 typedef TriangleMeshToSimplexMeshFilter Self;
00054
00056 typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00057
00059 typedef SmartPointer<Self> Pointer;
00060 typedef SmartPointer<const Self> ConstPointer;
00061
00063 itkNewMacro(Self);
00064
00066 itkTypeMacro(TriangleMeshToSimplexMeshFilter,MeshToMeshFilter);
00067
00068 typedef TInputMesh InputMeshType;
00069 typedef typename TInputMesh::Pointer InputMeshPointer;
00070 typedef typename TInputMesh::PointType InputPointType;
00071 typedef typename TInputMesh::BoundaryAssignmentsContainerPointer InputBoundaryAssignmentsContainerPointer;
00072 typedef typename TInputMesh::PointsContainer InputPointsContainer;
00073 typedef typename InputPointsContainer::Pointer InputPointsContainerPointer;
00074 typedef typename InputPointsContainer::Iterator InputPointsContainerIterator;
00075
00076 typedef typename TOutputMesh::Pointer OutputMeshPointer;
00077 typedef typename TOutputMesh::PointType OutputPointType;
00078 typedef typename TOutputMesh::PixelType OutputPixelType;
00079 typedef typename TOutputMesh::PointsContainer OutputPointsContainer;
00080 typedef typename OutputPointsContainer::Pointer OutputPointsContainerPointer;
00081 typedef typename TOutputMesh::PointsContainer::Iterator OutputPointsContainerIterator;
00082
00083 typedef typename TInputMesh::BoundaryAssignmentIdentifier InputBoundnaryAssignmentIdentifier;
00084
00085 typedef typename TInputMesh::CellType InputCellType;
00086 typedef typename InputCellType::CellAutoPointer InputCellAutoPointer;
00087 typedef typename TInputMesh::CellAutoPointer CellAutoPointer;
00088 typedef itk::LineCell<InputCellType> LineType;
00089 typedef itk::PolygonCell<InputCellType> PolygonType;
00090 typedef itk::TriangleCell<InputCellType> TriangleType;
00091 typedef itk::VertexCell<InputCellType> VertexType;
00092
00093 typedef std::pair<unsigned long,unsigned long> EdgeIdentifierType;
00094 typedef std::set<unsigned long> IndexSetType;
00095 typedef itk::MapContainer<unsigned long, EdgeIdentifierType> EdgeNeighborListType;
00096 typedef itk::MapContainer<EdgeIdentifierType, unsigned long> LineCellIndexType;
00097
00098 typedef itk::MapContainer<unsigned long, IndexSetType> VertexNeighborListType;
00099 typedef itk::MapContainer<EdgeIdentifierType,unsigned long> EdgeMapType;
00100 typedef typename EdgeMapType::Pointer EdgeMapPointer;
00101
00102 typedef itk::VectorContainer<unsigned long,unsigned long> IdVectorType;
00103 typedef typename IdVectorType::Pointer IdVectorPointer;
00104
00105 typedef typename TOutputMesh::CellType OutputCellType;
00106 typedef typename TOutputMesh::CellAutoPointer OutputCellAutoPointer;
00107 typedef itk::LineCell<OutputCellType> OutputLineType;
00108 typedef itk::PolygonCell<OutputCellType> OutputPolygonType;
00109
00110 protected:
00111
00112 TriangleMeshToSimplexMeshFilter();
00113
00114 ~TriangleMeshToSimplexMeshFilter();
00115
00116 TriangleMeshToSimplexMeshFilter(const Self&) {}
00117
00118 void operator=(const Self&)
00119 {
00120 }
00121
00122 void PrintSelf(std::ostream& os, Indent indent) const;
00123
00127 virtual void GenerateData();
00128
00132 void Initialize();
00133
00137 void CreateSimplexPoints();
00138
00144 void CreateEdgeForTrianglePair( unsigned long pointIndex, unsigned long boundaryId);
00145
00150 void CreateSimplexNeighbors();
00151
00155 void CreateCells();
00156
00157
00161 void CreateNewEdge(unsigned long currentCellId, unsigned int featureId,
00162 unsigned long startPointId, unsigned long endPointId);
00163
00167 InputPointType ComputeFaceCenter(unsigned long faceId);
00168
00169
00173 IndexSetType* m_FaceSet;
00174
00181 EdgeMapPointer m_Edges;
00182
00186 EdgeNeighborListType::Pointer m_EdgeNeighborList;
00187
00191 VertexNeighborListType::Pointer m_VertexNeighborList;
00192
00196 LineCellIndexType::Pointer m_LineCellIndices;
00197
00198
00202 unsigned long m_CellIdxOffset;
00203
00207 unsigned long m_IdOffset;
00208
00209
00213 unsigned long m_EdgeCellId;
00214
00218 IdVectorPointer m_HandledEdgeIds;
00219
00223 InputCellAutoPointer NewInputMeshCellPointer;
00224
00228 OutputCellAutoPointer NewSimplexCellPointer;
00229
00230
00231
00232 };
00233
00234 }
00235
00236 #ifndef ITK_MANUAL_INSTANTIATION
00237 #include "itkTriangleMeshToSimplexMeshFilter.txx"
00238 #endif
00239
00240 #endif //_TRIANGLE_MESH_TO_SIMPLEX_MESH_FILTER_H
00241