ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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;
65 using InputMeshConstPointer = typename InputMeshType::ConstPointer;
66 using InputPointType = typename InputMeshType::PointType;
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:
103
107 virtual ~SimplexCellVisitor() = default;
108
112 void
114 {
115 using PointIdIterator = typename SimplexPolygonType::PointIdIterator;
116 PointIdIterator it = poly->PointIdsBegin();
117 InputPointType center{};
118
119 InputPointType p{};
120
121 while (it != poly->PointIdsEnd())
122 {
123 this->m_Mesh->GetPoint(*it, &p);
124 center += p.GetVectorFromOrigin();
125 ++it;
126 }
127
128 center[0] /= poly->GetNumberOfPoints();
129 center[1] /= poly->GetNumberOfPoints();
130 center[2] /= poly->GetNumberOfPoints();
131
132 m_CenterMap->InsertElement(cellId, center);
133 }
134
137 {
138 return m_CenterMap;
139 }
140
141 void
142 SetMesh(const InputMeshType * mesh)
143 {
144 this->m_Mesh = mesh;
145 }
146
147 protected:
150 };
151
153 CellInterfaceVisitorImplementation<InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor>;
154
155 using SimplexVisitorInterfacePointer = typename SimplexVisitorInterfaceType::Pointer;
156 using CellMultiVisitorType = typename SimplexCellType::MultiVisitor;
157 using CellMultiVisitorPointer = typename CellMultiVisitorType::Pointer;
158
159protected:
162
163 void
164 PrintSelf(std::ostream & os, Indent indent) const override;
165
166 void
167 GenerateData() override;
168
169 void
171
173 void
175
179
182};
183} // namespace itk
184
185#ifndef ITK_MANUAL_INSTANTIATION
186# include "itkSimplexMeshToTriangleMeshFilter.hxx"
187#endif
188
189#endif //__SimplexMeshToTriangleMeshFilter_h
Convenience class for generating meshes.
Control indentation during Print() invocation.
Definition itkIndent.h:50
A wrapper of the STL "map" container.
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
typename InputMeshType::NeighborListType::iterator InputNeighborsIterator
itk::PolygonCell< SimplexCellType > SimplexPolygonType
typename InputPointsContainer::Pointer InputPointsContainerPointer
typename InputMeshType::NeighborListType InputNeighbors
itk::AutomaticTopologyMeshSource< TOutputMesh > AutoMeshSourceType
typename InputPointsContainer::Iterator InputPointsContainerIterator
itk:: CellInterfaceVisitorImplementation< InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor > SimplexVisitorInterfaceType
itk::MapContainer< PointIdentifier, InputPointType > PointMapType
~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
MeshToMeshFilter< TInputMesh, TOutputMesh > Superclass
typename InputMeshType::CellIdentifier CellIdentifier
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....