ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkSimplexMeshToTriangleMeshFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkSimplexMeshToTriangleMeshFilter_h
19 #define __itkSimplexMeshToTriangleMeshFilter_h
20 
21 #include "itkPolygonCell.h"
22 
23 #include "itkSimplexMesh.h"
24 #include "itkMeshToMeshFilter.h"
25 #include "itkVectorContainer.h"
27 
28 namespace itk
29 {
42 template< typename TInputMesh, typename TOutputMesh >
43 class SimplexMeshToTriangleMeshFilter:public MeshToMeshFilter< TInputMesh, TOutputMesh >
44 {
45 public:
48 
51 
55 
57  itkNewMacro(Self);
58 
61 
62  typedef TInputMesh InputMeshType;
63  typedef typename InputMeshType::ConstPointer InputMeshConstPointer;
64  typedef typename InputMeshType::PointType InputPointType;
65  typedef typename InputMeshType::PixelType InputPixelType;
66  typedef typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType;
67  typedef typename InputMeshType::PointIdentifier PointIdentifier;
68  typedef typename InputMeshType::CellIdentifier CellIdentifier;
69 
70  typedef typename InputMeshType::PointsContainer InputPointsContainer;
71  typedef typename InputPointsContainer::Pointer InputPointsContainerPointer;
72  typedef typename InputPointsContainer::Iterator InputPointsContainerIterator;
73 
74  typedef typename InputMeshType::NeighborListType InputNeighbors;
75  typedef typename InputMeshType::NeighborListType::iterator InputNeighborsIterator;
76 
78 
79  typedef typename InputMeshType::CellType SimplexCellType;
81 
82  // stores the center for each simplex mesh cell, key is the point id
85 
93  {
94 public:
95 
100  {
102  }
103 
107  virtual ~SimplexCellVisitor() {}
108 
113  {
114  typedef typename SimplexPolygonType::PointIdIterator PointIdIterator;
115  PointIdIterator it = poly->PointIdsBegin();
116  InputPointType center;
117  center.Fill(0);
119 
120  InputPointType p;
121  p.Fill(0);
122 
123  while ( it != poly->PointIdsEnd() )
124  {
125  this->m_Mesh->GetPoint(*it, &p);
126  center += p.GetVectorFromOrigin();
127  it++;
128  }
129 
130  center[0] /= poly->GetNumberOfPoints();
131  center[1] /= poly->GetNumberOfPoints();
132  center[2] /= poly->GetNumberOfPoints();
133 
134  m_CenterMap->InsertElement(cellId, center);
135  }
136 
138  {
139  return m_CenterMap;
140  }
141 
142  void SetMesh(const InputMeshType *mesh)
143  {
144  this->m_Mesh = mesh;
145  }
146 
147 protected:
150  };
151 
157 
159  typedef typename SimplexCellType::MultiVisitor CellMultiVisitorType;
160  typedef typename CellMultiVisitorType::Pointer CellMultiVisitorPointer;
161 
162 protected:
163 
167  void operator=(const Self &) {}
168 
169  void PrintSelf(std::ostream & os, Indent indent) const;
170 
171  virtual void GenerateData();
172 
173  void Initialize();
174 
176  void CreateTriangles();
177 
180 
183 };
184 } //end of namespace
185 
186 #ifndef ITK_MANUAL_INSTANTIATION
187 #include "itkSimplexMeshToTriangleMeshFilter.hxx"
188 #endif
189 
190 #endif //__SimplexMeshToTriangleMeshFilter_h
SimplexVisitorInterfaceType::Pointer SimplexVisitorInterfacePointer
Light weight base class for most itk classes.
A template class used to implement a visitor object.
A wrapper of the STL &quot;map&quot; container.
Convenience class for generating meshes.
CellIdentifier FindCellId(CellIdentifier id1, CellIdentifier id2, CellIdentifier id3)
virtual PointIdIterator PointIdsBegin(void)
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
static Pointer New()
virtual PointIdIterator PointIdsEnd(void)
InputMeshType::MeshTraits::CellTraits InputCellTraitsType
itk::AutomaticTopologyMeshSource< TOutputMesh > AutoMeshSourceType
InputPointsContainer::Iterator InputPointsContainerIterator
void PrintSelf(std::ostream &os, Indent indent) const
void SetMesh(const InputMeshType *mesh)
visits all polygon cells and compute the cell centers
MeshToMeshFilter< TInputMesh, TOutputMesh > Superclass
itk::MapContainer< PointIdentifier, InputPointType > PointMapType
PointMapPointer m_CenterMap
visits all polygon cells and compute the cell centers
InputMeshConstPointer m_Mesh
visits all polygon cells and compute the cell centers
InputMeshType::NeighborListType::iterator InputNeighborsIterator
Represents a polygon in a Mesh.
itk::CellInterfaceVisitorImplementation< InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor > SimplexVisitorInterfaceType
This filter converts a 2-simplex mesh into a triangle mesh.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
PointMapPointer GetCenterMap()
visits all polygon cells and compute the cell centers
itk::PolygonCell< SimplexCellType > SimplexPolygonType
virtual unsigned int GetNumberOfPoints(void) const
void Visit(CellIdentifier cellId, SimplexPolygonType *poly)
visits all polygon cells and compute the cell centers