ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkTriangleMeshToBinaryImageFilter.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 itkTriangleMeshToBinaryImageFilter_h
19#define itkTriangleMeshToBinaryImageFilter_h
20
21#include "itkImageSource.h"
22
23#include "itkPolygonCell.h"
24#include "itkMapContainer.h"
25#include "itkVectorContainer.h"
27#include "itkPointSet.h"
28
29#include <vector>
30
31namespace itk
32{
34{
35public:
36 double m_X;
37 int m_Sign;
38
39 Point1D() = default;
40 Point1D(const double p, const int s)
41 : m_X(p)
42 , m_Sign(s)
43 {}
44
45 Point1D(const Point1D & point) = default;
46
47 Point1D &
48 operator=(const Point1D &) = default;
49
50 [[nodiscard]] double
51 getX() const
52 {
53 return m_X;
54 }
55
56 [[nodiscard]] int
57 getSign() const
58 {
59 return m_Sign;
60 }
61};
62
70template <typename TInputMesh, typename TOutputImage>
71class ITK_TEMPLATE_EXPORT TriangleMeshToBinaryImageFilter : public ImageSource<TOutputImage>
72{
73public:
74 ITK_DISALLOW_COPY_AND_MOVE(TriangleMeshToBinaryImageFilter);
75
81
82 using IndexType = typename TOutputImage::IndexType;
83 using SizeType = typename TOutputImage::SizeType;
84 using OutputImageType = TOutputImage;
85 using OutputImagePointer = typename OutputImageType::Pointer;
86 using ValueType = typename OutputImageType::ValueType;
87 using SpacingType = typename OutputImageType::SpacingType;
88 using DirectionType = typename OutputImageType::DirectionType;
89
91 itkNewMacro(Self);
92
94 itkOverrideGetNameOfClassMacro(TriangleMeshToBinaryImageFilter);
95
98
100 using InputMeshType = TInputMesh;
101 using InputMeshPointer = typename InputMeshType::Pointer;
102 using InputPointType = typename InputMeshType::PointType;
103 using InputPixelType = typename InputMeshType::PixelType;
104 using InputCellTraitsType = typename InputMeshType::MeshTraits::CellTraits;
105 using CellType = typename InputMeshType::CellType;
106 using CellsContainerPointer = typename InputMeshType::CellsContainerPointer;
107 using CellsContainerIterator = typename InputMeshType::CellsContainerIterator;
108
109 using InputPointsContainer = typename InputMeshType::PointsContainer;
110 using InputPointsContainerPointer = typename InputPointsContainer::Pointer;
111 using InputPointsContainerIterator = typename InputPointsContainer::Iterator;
112
115
118
120
121 using Point1DVector = std::vector<Point1D>;
122 using Point1DArray = std::vector<std::vector<Point1D>>;
123
124 using Point2DVector = std::vector<Point2DType>;
125 using Point2DArray = std::vector<std::vector<Point2DType>>;
126
127 using PointVector = std::vector<PointType>;
128 using PointArray = std::vector<std::vector<PointType>>;
129
135 itkSetMacro(Spacing, SpacingType);
136 virtual void
137 SetSpacing(const double spacing[3]);
139 virtual void
140 SetSpacing(const float spacing[3]);
141
142 itkGetConstReferenceMacro(Spacing, SpacingType);
143
148 itkSetMacro(Direction, DirectionType);
149 itkGetConstMacro(Direction, DirectionType);
157 itkSetMacro(InsideValue, ValueType);
158 itkGetConstMacro(InsideValue, ValueType);
166 itkSetMacro(OutsideValue, ValueType);
167 itkGetConstMacro(OutsideValue, ValueType);
174 itkSetMacro(Origin, PointType);
175 virtual void
176 SetOrigin(const double origin[3]);
178 virtual void
179 SetOrigin(const float origin[3]);
180
181 itkGetConstReferenceMacro(Origin, PointType);
182
185 itkSetMacro(Index, IndexType);
186 itkGetConstMacro(Index, IndexType);
190 itkSetMacro(Size, SizeType);
191 itkGetConstMacro(Size, SizeType);
195 void
197
198 void
200 {
201 if (InfoImage != m_InfoImage)
202 {
203 this->Modified();
204 m_InfoImage = InfoImage;
205 }
206 }
207
209 InputMeshType *
211
213 GetInput(unsigned int idx);
214
215 /* Set the tolerance for doing spatial searches of the polydata. */
216 itkSetMacro(Tolerance, double);
217 itkGetConstMacro(Tolerance, double);
218
219protected:
222
223 void
225 {} // do nothing
226 void
227 GenerateData() override;
228
229 virtual void
231
233 static int
234 PolygonToImageRaster(PointVector coords, Point1DArray & zymatrix, int extent[6]);
235
237
239
241
243
244 PointType m_Origin{}; // start value
245
246 double m_Tolerance{};
247
250
252
253 void
254 PrintSelf(std::ostream & os, Indent indent) const override;
255
256private:
257 static bool
259
260 static bool
262};
263} // end namespace itk
264
265#ifndef ITK_MANUAL_INSTANTIATION
266# include "itkTriangleMeshToBinaryImageFilter.hxx"
267#endif
268
269#endif
Array class with size defined at construction time.
Definition itkArray.h:48
typename OutputImageType::RegionType OutputImageRegionType
Control indentation during Print() invocation.
Definition itkIndent.h:51
virtual void Modified() const
Point1D & operator=(const Point1D &)=default
Point1D(const double p, const int s)
Point1D()=default
Point1D(const Point1D &point)=default
TPointsContainer PointsContainer
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition itkPointSet.h:82
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
Implements transparent reference counting.
typename InputPointsContainer::Iterator InputPointsContainerIterator
std::vector< std::vector< Point2DType > > Point2DArray
typename InputMeshType::PointsContainer InputPointsContainer
typename OutputImageType::DirectionType DirectionType
typename OutputImageType::SpacingType SpacingType
virtual void SetOrigin(const double origin[3])
InputMeshType * GetInput(unsigned int idx)
virtual void SetSpacing(const float spacing[3])
void PrintSelf(std::ostream &os, Indent indent) const override
typename InputMeshType::CellsContainerPointer CellsContainerPointer
typename InputPointsContainer::Pointer InputPointsContainerPointer
static bool ComparePoints2D(Point2DType a, Point2DType b)
virtual void SetOrigin(const float origin[3])
~TriangleMeshToBinaryImageFilter() override=default
typename InputMeshType::MeshTraits::CellTraits InputCellTraitsType
static int PolygonToImageRaster(PointVector coords, Point1DArray &zymatrix, int extent[6])
typename InputMeshType::CellsContainerIterator CellsContainerIterator
virtual void SetSpacing(const double spacing[3])
static bool ComparePoints1D(Point1D a, Point1D b)
std::vector< std::vector< Point1D > > Point1DArray
std::vector< std::vector< PointType > > PointArray
void SetInput(InputMeshType *input)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Represent a n-dimensional index in a n-dimensional image.
Definition itkIndex.h:69
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition itkSize.h:70