ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkSimplexMeshVolumeCalculator.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 itkSimplexMeshVolumeCalculator_h
19#define itkSimplexMeshVolumeCalculator_h
20
21#include "itkIntTypes.h"
22#include "itkPolygonCell.h"
23#include "itkVector.h"
24#include "itkSimplexMesh.h"
25#include "itkVectorContainer.h"
26
27namespace itk
28{
50
51template <typename TInputMesh>
52class ITK_TEMPLATE_EXPORT SimplexMeshVolumeCalculator : public Object
53{
54public:
55 ITK_DISALLOW_COPY_AND_MOVE(SimplexMeshVolumeCalculator);
56
59
62
66
68 itkNewMacro(Self);
69
71 itkOverrideGetNameOfClassMacro(SimplexMeshVolumeCalculator);
72
73 using InputMeshType = TInputMesh;
74 using InputMeshPointer = typename InputMeshType::Pointer;
75 using InputMeshConstPointer = typename InputMeshType::ConstPointer;
76
77 using InputPointType = typename InputMeshType::PointType;
78 using InputPixelType = typename InputMeshType::PixelType;
79 using InputCellTraitsType = typename InputMeshType::MeshTraits::CellTraits;
80
81 using InputPointsContainer = typename InputMeshType::PointsContainer;
82 using InputPointsContainerPointer = typename InputPointsContainer::ConstPointer;
83 using InputPointsContainerIterator = typename InputPointsContainer::ConstIterator;
84
85 using InputNeighbors = typename InputMeshType::NeighborListType;
86 using InputNeighborsIterator = typename InputMeshType::NeighborListType::iterator;
87
88 using SimplexCellType = typename InputMeshType::CellType;
90
91 // stores the center for each simplex mesh cell, key is the point id
94
95 using VectorType = typename InputPointType::VectorType;
97
106 {
107 public:
108
113 virtual ~SimplexCellVisitor() = default;
115
119 void
121 {
122 using PointIdIterator = typename SimplexPolygonType::PointIdIterator;
123 PointIdIterator it = poly->PointIdsBegin();
124 InputPointType center{};
125 InputPointType p{};
127
128 while (it != poly->PointIdsEnd())
129 {
130 m_Mesh->GetPoint(*it, &p);
131 center += p.GetVectorFromOrigin();
132 ++it;
133 }
134
135 center[0] /= poly->GetNumberOfPoints();
136 center[1] /= poly->GetNumberOfPoints();
137 center[2] /= poly->GetNumberOfPoints();
138
139 m_CenterMap->InsertElement(cellId, center);
140 }
141
144 {
145 return m_CenterMap;
146 }
147
148 void
150 {
151 m_Mesh = mesh;
152 }
153
154 protected:
157 };
158
160 CellInterfaceVisitorImplementation<InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor>;
161
162 using SimplexVisitorInterfacePointer = typename SimplexVisitorInterfaceType::Pointer;
163 using CellMultiVisitorType = typename SimplexCellType::MultiVisitor;
164 using CellMultiVisitorPointer = typename CellMultiVisitorType::Pointer;
165
167 itkSetObjectMacro(SimplexMesh, InputMeshType);
168
170 void
172
174 itkGetConstMacro(Volume, double);
175
177 itkGetConstMacro(Area, double);
178
179protected:
181 ~SimplexMeshVolumeCalculator() override = default;
182 void
183 PrintSelf(std::ostream & os, Indent indent) const override;
184
185private:
186 void
188
189 void
191
193 void
195
197 void
199
203
206
208
209 double m_Volume{ 0.0 };
210 double m_VolumeX{ 0.0 };
211 double m_VolumeY{ 0.0 };
212 double m_VolumeZ{ 0.0 };
213 double m_Area{ 0.0 };
214 double m_Kx{ 0.0 };
215 double m_Ky{ 0.0 };
216 double m_Kz{ 0.0 };
217 double m_Wxyz{ 0.0 };
218 double m_Wxy{ 0.0 };
219 double m_Wxz{ 0.0 };
220 double m_Wyz{ 0.0 };
221
225
227};
228} // namespace itk
229
230#ifndef ITK_MANUAL_INSTANTIATION
231# include "itkSimplexMeshVolumeCalculator.hxx"
232#endif
233
234#endif /* __SimplexMeshVolumeCalculator_h */
A templated class holding a n-Dimensional covariant vector.
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(IdentifierType cellId, SimplexPolygonType *poly)
visits all polygon cells and compute the cell centers
typename CellMultiVisitorType::Pointer CellMultiVisitorPointer
CovariantVector< typename VectorType::ValueType, 3 > CovariantVectorType
typename InputMeshType::PointType InputPointType
typename InputMeshType::ConstPointer InputMeshConstPointer
itk::MapContainer< IdentifierType, InputPointType > PointMapType
typename SimplexCellType::MultiVisitor CellMultiVisitorType
itk::PolygonCell< SimplexCellType > SimplexPolygonType
typename SimplexVisitorInterfaceType::Pointer SimplexVisitorInterfacePointer
typename InputMeshType::NeighborListType::iterator InputNeighborsIterator
typename InputMeshType::Pointer InputMeshPointer
typename PointMapType::Pointer PointMapPointer
IdentifierType FindCellId(IdentifierType id1, IdentifierType id2, IdentifierType id3)
typename InputPointsContainer::ConstIterator InputPointsContainerIterator
typename InputPointType::VectorType VectorType
typename InputPointsContainer::ConstPointer InputPointsContainerPointer
itk:: CellInterfaceVisitorImplementation< InputPixelType, InputCellTraitsType, SimplexPolygonType, SimplexCellVisitor > SimplexVisitorInterfaceType
~SimplexMeshVolumeCalculator() override=default
typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType
typename InputMeshType::PixelType InputPixelType
void CalculateTriangleVolume(InputPointType p1, InputPointType p2, InputPointType p3)
typename InputMeshType::NeighborListType InputNeighbors
typename InputMeshType::PointsContainer InputPointsContainer
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputMeshType::CellType SimplexCellType
The class represents a 2-simplex mesh.
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition itkIntTypes.h:90
unsigned long SizeValueType
Definition itkIntTypes.h:86
long IndexValueType
Definition itkIntTypes.h:93