ITK  6.0.0
Insight Toolkit
itkSimplexMeshToTriangleMeshFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
28namespace itk
29{
42template <typename TInputMesh, typename TOutputMesh>
43class ITK_TEMPLATE_EXPORT SimplexMeshToTriangleMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
44{
45public:
46 ITK_DISALLOW_COPY_AND_MOVE(SimplexMeshToTriangleMeshFilter);
47
50
53
57
59 itkNewMacro(Self);
60
62 itkOverrideGetNameOfClassMacro(SimplexMeshToTriangleMeshFilter);
63
64 using InputMeshType = TInputMesh;
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;
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:
101
105 virtual ~SimplexCellVisitor() = default;
106
110 void
112 {
113 using PointIdIterator = typename SimplexPolygonType::PointIdIterator;
114 PointIdIterator it = poly->PointIdsBegin();
115 InputPointType center{};
118 InputPointType p{};
119
120 while (it != poly->PointIdsEnd())
121 {
122 this->m_Mesh->GetPoint(*it, &p);
123 center += p.GetVectorFromOrigin();
124 ++it;
125 }
126
127 center[0] /= poly->GetNumberOfPoints();
128 center[1] /= poly->GetNumberOfPoints();
129 center[2] /= poly->GetNumberOfPoints();
130
131 m_CenterMap->InsertElement(cellId, center);
132 }
133
136 {
137 return m_CenterMap;
138 }
139
140 void
141 SetMesh(const InputMeshType * mesh)
142 {
143 this->m_Mesh = mesh;
144 }
145
146 protected:
149 };
150
152 CellInterfaceVisitorImplementation<InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor>;
153
155 using CellMultiVisitorType = typename SimplexCellType::MultiVisitor;
157
158protected:
161
162 void
163 PrintSelf(std::ostream & os, Indent indent) const override;
164
165 void
166 GenerateData() override;
167
168 void
170
172 void
174
178
180 PointMapPointer m_Centers{};
181};
182} // namespace itk
183
184#ifndef ITK_MANUAL_INSTANTIATION
185# include "itkSimplexMeshToTriangleMeshFilter.hxx"
186#endif
187
188#endif //__SimplexMeshToTriangleMeshFilter_h
Convenience class for generating meshes.
A template class used to implement a visitor object.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
A wrapper of the STL "map" container.
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
Represents a polygon in a Mesh.
unsigned int GetNumberOfPoints() const override
PointIdIterator PointIdsEnd() override
PointIdIterator PointIdsBegin() override
void Visit(CellIdentifier cellId, SimplexPolygonType *poly)
visits all polygon cells and compute the cell centers
This filter converts a 2-simplex mesh into a triangle mesh.
typename InputMeshType::NeighborListType::iterator InputNeighborsIterator
typename InputPointsContainer::Pointer InputPointsContainerPointer
typename InputMeshType::NeighborListType InputNeighbors
typename InputPointsContainer::Iterator InputPointsContainerIterator
~SimplexMeshToTriangleMeshFilter() override=default
typename CellMultiVisitorType::Pointer CellMultiVisitorPointer
typename InputMeshType::PointIdentifier PointIdentifier
typename SimplexCellType::MultiVisitor CellMultiVisitorType
typename InputMeshType::ConstPointer InputMeshConstPointer
CellIdentifier FindCellId(CellIdentifier id1, CellIdentifier id2, CellIdentifier id3)
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType
typename SimplexVisitorInterfaceType::Pointer SimplexVisitorInterfacePointer
typename InputMeshType::PointsContainer InputPointsContainer
typename InputMeshType::CellIdentifier CellIdentifier
SmartPointer< const Self > ConstPointer
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....