ITK  5.4.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;
116 center.Fill(0);
120 p.Fill(0);
121
122 while (it != poly->PointIdsEnd())
123 {
124 this->m_Mesh->GetPoint(*it, &p);
125 center += p.GetVectorFromOrigin();
126 ++it;
127 }
128
129 center[0] /= poly->GetNumberOfPoints();
130 center[1] /= poly->GetNumberOfPoints();
131 center[2] /= poly->GetNumberOfPoints();
132
133 m_CenterMap->InsertElement(cellId, center);
134 }
135
138 {
139 return m_CenterMap;
140 }
141
142 void
143 SetMesh(const InputMeshType * mesh)
144 {
145 this->m_Mesh = mesh;
146 }
147
148 protected:
151 };
152
154 CellInterfaceVisitorImplementation<InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor>;
155
157 using CellMultiVisitorType = typename SimplexCellType::MultiVisitor;
159
160protected:
163
164 void
165 PrintSelf(std::ostream & os, Indent indent) const override;
166
167 void
168 GenerateData() override;
169
170 void
172
174 void
176
180
182 PointMapPointer m_Centers{};
183};
184} // namespace itk
185
186#ifndef ITK_MANUAL_INSTANTIATION
187# include "itkSimplexMeshToTriangleMeshFilter.hxx"
188#endif
189
190#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....