ITK  6.0.0
Insight Toolkit
itkDeformableSimplexMesh3DGradientConstraintForceFilter.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 itkDeformableSimplexMesh3DGradientConstraintForceFilter_h
19#define itkDeformableSimplexMesh3DGradientConstraintForceFilter_h
20
22#include "itkMesh.h"
24#include "itkCovariantVector.h"
25
26#include <set>
27#include <vector>
28#include "ITKDeformableMeshExport.h"
29
30namespace itk
31{
33{
34public:
35 // voxel coordinates
36 unsigned int m_Vpos[3];
37 // subvoxel coordinates (in cartesian space)
38 double m_Spos[3];
39 // voxel value converted to a double
40 double m_Value;
41 // distance from line origin
42 double m_Distance;
43 // index
44 unsigned int m_Index;
45
46 ImageVoxel() = default;
47 ImageVoxel(const int * pos, const double * subpos, double val, double dist, unsigned int ind)
48 {
49 this->m_Vpos[0] = pos[0];
50 this->m_Vpos[1] = pos[1];
51 this->m_Vpos[2] = pos[2];
52 this->m_Spos[0] = subpos[0];
53 this->m_Spos[1] = subpos[1];
54 this->m_Spos[2] = subpos[2];
55 this->m_Value = val;
56 this->m_Distance = dist;
57 this->m_Index = ind;
58 }
59
61 unsigned int
62 GetX() const
63 {
64 return m_Vpos[0];
65 }
67 unsigned int
68 GetY() const
69 {
70 return m_Vpos[1];
71 }
73 unsigned int
74 GetZ() const
75 {
76 return m_Vpos[2];
77 }
79 double
81 {
82 return m_Distance;
83 }
85 double
86 GetValue() const
87 {
88 return m_Value;
89 }
91
93 void
94 SetValue(const double val)
95 {
96 m_Value = val;
97 }
98
99 inline friend std::ostream &
100 operator<<(std::ostream & os, const ImageVoxel & val)
101 {
102 os << "Vpos: " << val.m_Vpos << std::endl;
103 os << "Spos: " << val.m_Spos << std::endl;
104 os << "Value: " << val.m_Value << std::endl;
105 os << "Distance: " << val.m_Distance << std::endl;
106 os << "Index: " << val.m_Index << std::endl;
107
108 return os;
109 }
110};
116{
117public:
122 enum class SIDE : uint8_t
123 {
124 // half segment in direction
125 NORMAL,
126 // half segment in -direction
127 INVERSE,
128 // complete segment
129 BOTH
130 };
131};
132// Define how to print enumeration
133extern ITKDeformableMesh_EXPORT std::ostream &
135
148template <typename TInputMesh, typename TOutputMesh>
150 : public DeformableSimplexMesh3DFilter<TInputMesh, TOutputMesh>
151{
152public:
155
158
162
164 itkNewMacro(Self);
165
168
170 using InputMeshType = TInputMesh;
171 using OutputMeshType = TOutputMesh;
172
173 using typename Superclass::PointType;
174 using typename Superclass::GradientIndexType;
175 using typename Superclass::GradientIndexValueType;
176 using typename Superclass::GradientType;
177 using typename Superclass::GradientImageType;
178
179 /* Mesh pointer definition. */
182
183 using PixelType = typename InputMeshType::PixelType;
184
187
192
194 itkSetMacro(Range, int);
195 itkGetConstMacro(Range, int);
199#if !defined(ITK_LEGACY_REMOVE)
201 static constexpr SIDEEnum NORMAL = SIDEEnum::NORMAL;
202 static constexpr SIDEEnum INVERSE = SIDEEnum::INVERSE;
203 static constexpr SIDEEnum BOTH = SIDEEnum::BOTH;
204#endif
205
209 itkSetConstObjectMacro(Image, OriginalImageType);
210
211protected:
215 void
217 {}
218 void
219 PrintSelf(std::ostream & os, Indent indent) const override;
220
224 void
225 ComputeExternalForce(SimplexMeshGeometry * data, const GradientImageType * gradientImage) override;
226
230 int m_Range{};
231
232private:
233 double
234 NextVoxel(const double * pp, int * ic, double * x, double * y, double * z);
235
236 int
237 Signi(double a);
238
239 void
241
242 // line starting voxel
243 ImageVoxel * m_StartVoxel{};
244 // line voxels in direction
245 std::vector<ImageVoxel *> m_Positive{};
246 // line voxels in -direction
247 std::vector<ImageVoxel *> m_Negative{};
248
250}; // end of class
251} // namespace itk
252
253#ifndef ITK_MANUAL_INSTANTIATION
254# include "itkDeformableSimplexMesh3DGradientConstraintForceFilter.hxx"
255#endif
256
257#endif /* __DeformableSimplexMesh3DGradientConstraintForceFilter_h */
Three-dimensional deformable model for image segmentation.
Contains all enum classes used by the DeformableSimplexMesh3DGradientConstraintForceFilter class.
Additional to its superclass this class reimplements the external forces methods in which the scan li...
void ComputeExternalForce(SimplexMeshGeometry *data, const GradientImageType *gradientImage) override
void PrintSelf(std::ostream &os, Indent indent) const override
double NextVoxel(const double *pp, int *ic, double *x, double *y, double *z)
unsigned int GetY() const
returns voxel Y coordinate (voxel row)
unsigned int GetZ() const
returns voxel Z coordinate (voxel plane)
friend std::ostream & operator<<(std::ostream &os, const ImageVoxel &val)
ImageVoxel(const int *pos, const double *subpos, double val, double dist, unsigned int ind)
double GetDistance() const
returns voxel distance to origin
ImageVoxel()=default
unsigned int GetX() const
returns voxel X coordinate (voxel column)
void SetValue(const double val)
returns voxel position
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkMeshSource.h:69
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
typename InputMeshType::Pointer InputMeshPointer
handle geometric properties for vertices of a simplex mesh
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating so it cannot multithread for data other than in Anisotropic Diffusion of Multivalued Images *with Application to Color IEEE Transactions on Image No pp
long IndexValueType
Definition: itkIntTypes.h:93
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216