ITK  5.0.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 ITK_TEMPLATE_EXPORT SimplexMeshToTriangleMeshFilter:public MeshToMeshFilter< TInputMesh, TOutputMesh >
44 {
45 public:
46  ITK_DISALLOW_COPY_AND_ASSIGN(SimplexMeshToTriangleMeshFilter);
47 
50 
53 
57 
59  itkNewMacro(Self);
60 
63 
64  using InputMeshType = TInputMesh;
65  using InputMeshConstPointer = typename InputMeshType::ConstPointer;
67  using InputPixelType = typename InputMeshType::PixelType;
68  using InputCellTraitsType = typename InputMeshType::MeshTraits::CellTraits;
69  using PointIdentifier = typename InputMeshType::PointIdentifier;
70  using CellIdentifier = typename InputMeshType::CellIdentifier;
71 
72  using InputPointsContainer = typename InputMeshType::PointsContainer;
73  using InputPointsContainerPointer = typename InputPointsContainer::Pointer;
74  using InputPointsContainerIterator = typename InputPointsContainer::Iterator;
75 
76  using InputNeighbors = typename InputMeshType::NeighborListType;
77  using InputNeighborsIterator = typename InputMeshType::NeighborListType::iterator;
78 
80 
81  using SimplexCellType = typename InputMeshType::CellType;
83 
84  // stores the center for each simplex mesh cell, key is the point id
87 
95  {
96 public:
97 
102  {
103  m_CenterMap = PointMapType::New();
104  }
105 
109  virtual ~SimplexCellVisitor() = default;
110 
115  {
116  using PointIdIterator = typename SimplexPolygonType::PointIdIterator;
117  PointIdIterator it = poly->PointIdsBegin();
118  InputPointType center;
119  center.Fill(0);
121 
122  InputPointType p;
123  p.Fill(0);
124 
125  while ( it != poly->PointIdsEnd() )
126  {
127  this->m_Mesh->GetPoint(*it, &p);
128  center += p.GetVectorFromOrigin();
129  it++;
130  }
131 
132  center[0] /= poly->GetNumberOfPoints();
133  center[1] /= poly->GetNumberOfPoints();
134  center[2] /= poly->GetNumberOfPoints();
135 
136  m_CenterMap->InsertElement(cellId, center);
137  }
138 
140  {
141  return m_CenterMap;
142  }
143 
144  void SetMesh(const InputMeshType *mesh)
145  {
146  this->m_Mesh = mesh;
147  }
148 
149 protected:
152  };
153 
159 
161  using CellMultiVisitorType = typename SimplexCellType::MultiVisitor;
162  using CellMultiVisitorPointer = typename CellMultiVisitorType::Pointer;
163 
164 protected:
165 
167  ~SimplexMeshToTriangleMeshFilter() override = default;
168 
169  void PrintSelf(std::ostream & os, Indent indent) const override;
170 
171  void GenerateData() override;
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
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.
typename InputPointsContainer::Pointer InputPointsContainerPointer
typename InputMeshType::PointsContainer InputPointsContainer
PointIdIterator PointIdsBegin() override
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
typename SimplexVisitorInterfaceType::Pointer SimplexVisitorInterfacePointer
typename InputPointsContainer::Iterator InputPointsContainerIterator
typename InputMeshType::NeighborListType::iterator InputNeighborsIterator
void SetMesh(const InputMeshType *mesh)
visits all polygon cells and compute the cell centers
typename InputMeshType::ConstPointer InputMeshConstPointer
typename SimplexCellType::MultiVisitor CellMultiVisitorType
PointMapPointer m_CenterMap
visits all polygon cells and compute the cell centers
InputMeshConstPointer m_Mesh
visits all polygon cells and compute the cell centers
Represents a polygon in a Mesh.
This filter converts a 2-simplex mesh into a triangle mesh.
typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType
typename InputMeshType::NeighborListType InputNeighbors
typename InputMeshType::CellIdentifier CellIdentifier
Control indentation during Print() invocation.
Definition: itkIndent.h:49
PointMapPointer GetCenterMap()
visits all polygon cells and compute the cell centers
unsigned int GetNumberOfPoints() const override
typename InputMeshType::PointIdentifier PointIdentifier
PointIdIterator PointIdsEnd() override
void Visit(CellIdentifier cellId, SimplexPolygonType *poly)
visits all polygon cells and compute the cell centers
typename CellMultiVisitorType::Pointer CellMultiVisitorPointer