ITK  5.4.0
Insight Toolkit
itkLaplacianDeformationQuadEdgeMeshFilter.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 itkLaplacianDeformationQuadEdgeMeshFilter_h
19 #define itkLaplacianDeformationQuadEdgeMeshFilter_h
20 
23 #include "ITKQuadEdgeMeshFilteringExport.h"
24 
25 #include "itkConceptChecking.h"
26 
27 #include <unordered_map>
28 
29 namespace itk
30 {
36 {
37 public:
41  enum class Area : uint8_t
42  {
44  NONE = 0,
45 
47  MIXEDAREA
48  };
49 };
50 // Define how to print enumeration
51 extern ITKQuadEdgeMeshFiltering_EXPORT std::ostream &
52  operator<<(std::ostream & out, const LaplacianDeformationQuadEdgeMeshFilterEnums::Area value);
53 
115 template <class TInputMesh, class TOutputMesh, class TSolverTraits>
116 class ITK_TEMPLATE_EXPORT LaplacianDeformationQuadEdgeMeshFilter
117  : public QuadEdgeMeshToQuadEdgeMeshFilter<TInputMesh, TOutputMesh>
118 {
119 public:
120  ITK_DISALLOW_COPY_AND_MOVE(LaplacianDeformationQuadEdgeMeshFilter);
121 
127 
128  itkOverrideGetNameOfClassMacro(LaplacianDeformationQuadEdgeMeshFilter);
129 
131  using InputMeshType = TInputMesh;
132  using typename Superclass::InputPointType;
133 
134  static constexpr unsigned int InputPointDimension = InputMeshType::PointDimension;
135 
137  using OutputMeshType = TOutputMesh;
138  using typename Superclass::OutputCoordRepType;
139  using typename Superclass::OutputPointType;
140  using typename Superclass::OutputPointIdentifier;
141  using typename Superclass::OutputQEPrimal;
142  using typename Superclass::OutputVectorType;
143  using typename Superclass::OutputQEIterator;
144 
145  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
146 
147  using SolverTraits = TSolverTraits;
148  using ValueType = typename SolverTraits::ValueType;
149  using MatrixType = typename SolverTraits::MatrixType;
151 
153 
155  void
157  {
158  this->m_CoefficientsMethod = iMethod;
159  this->Modified();
160  }
164 
166  void
167  SetConstrainedNode(OutputPointIdentifier vId, const OutputPointType & iP);
168 
170  void
171  SetDisplacement(OutputPointIdentifier vId, const OutputVectorType & iV);
172 
176  bool
177  GetDisplacement(OutputPointIdentifier vId, OutputVectorType & oV) const;
178 
180  void
181  ClearConstraints();
182 
184  itkSetMacro(Order, unsigned int);
185  itkGetMacro(Order, unsigned int);
189 #if !defined(ITK_LEGACY_REMOVE)
190 
191  static constexpr AreaEnum NONE = AreaEnum::NONE;
192  static constexpr AreaEnum MIXEDAREA = AreaEnum::MIXEDAREA;
193 #endif
194 
196  itkSetEnumMacro(AreaComputationType, AreaEnum);
197  itkGetMacro(AreaComputationType, AreaEnum);
200 #ifdef ITK_USE_CONCEPT_CHECKING
203 #endif
204 
205 protected:
208  ~LaplacianDeformationQuadEdgeMeshFilter() override = default;
211  using OutputMapPointIdentifier = std::unordered_map<OutputPointIdentifier, OutputPointIdentifier>;
212  using OutputMapPointIdentifierIterator = typename OutputMapPointIdentifier::iterator;
213  using OutputMapPointIdentifierConstIterator = typename OutputMapPointIdentifier::const_iterator;
214 
215  using ConstraintMapType = std::unordered_map<OutputPointIdentifier, OutputVectorType>;
216  using ConstraintMapConstIterator = typename ConstraintMapType::const_iterator;
217 
219  {
220  size_t
222  {
223  return reinterpret_cast<size_t>(qe);
224  }
225  };
226 
227  using CoefficientMapType = std::unordered_map<OutputQEPrimal *, OutputCoordRepType, HashOutputQEPrimal>;
228  using CoefficientMapConstIterator = typename CoefficientMapType::const_iterator;
229 
230  using AreaMapType = std::unordered_map<OutputPointIdentifier, OutputCoordRepType>;
231  using AreaMapConstIterator = typename AreaMapType::const_iterator;
232 
233  using RowType = std::unordered_map<OutputPointIdentifier, OutputCoordRepType>;
234  using RowIterator = typename RowType::iterator;
235  using RowConstIterator = typename RowType::const_iterator;
236 
237  OutputMapPointIdentifier m_InternalMap{};
238  ConstraintMapType m_Constraints{};
239  CoefficientMapType m_CoefficientMap{};
240  AreaMapType m_MixedAreaMap{};
241 
242  CoefficientsComputationType * m_CoefficientsMethod{};
243 
244  unsigned int m_Order{ 1 };
245  AreaEnum m_AreaComputationType{ AreaEnum::NONE };
246 
247  void
248  PrintSelf(std::ostream & os, Indent indent) const override;
249 
250  OutputCoordRepType
251  ComputeMixedAreaForGivenVertex(OutputPointIdentifier iId);
252  OutputCoordRepType
253  ComputeMixedArea(OutputQEPrimal * iQE1, OutputQEPrimal * iQE2);
254 
255  virtual void
256  ComputeVertexIdMapping();
257 
258  void
259  ComputeLaplacianMatrix(MatrixType & ioL);
260 
261  void
262  FillMatrixRow(OutputPointIdentifier iId, unsigned int iDegree, OutputCoordRepType iWeight, RowType & ioRow);
263 
268  void
269  FillMatrix(MatrixType & iM, VectorType & iBx, VectorType & iBy, VectorType & iBz);
270 
283  void
284  SolveLinearSystems(const MatrixType & iM,
285  const VectorType & iBx,
286  const VectorType & iBy,
287  const VectorType & iBz,
288  VectorType & oX,
289  VectorType & oY,
290  VectorType & oZ);
291 
292 
293 private:
294  struct Triple
295  {
296  Triple() = default;
297  Triple(OutputPointIdentifier iV, OutputCoordRepType iWeight, unsigned int iDegree)
298  : m_Id(iV)
299  , m_Weight(iWeight)
300  , m_Degree(iDegree)
301  {}
302 
303  OutputPointIdentifier m_Id;
305  unsigned int m_Degree;
306  };
307 };
308 } // end namespace itk
309 
310 #include "itkLaplacianDeformationQuadEdgeMeshFilter.hxx"
311 
312 #endif
itk::LaplacianDeformationQuadEdgeMeshFilter::AreaMapType
std::unordered_map< OutputPointIdentifier, OutputCoordRepType > AreaMapType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:230
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputQEPrimal
typename OutputMeshType::QEPrimal OutputQEPrimal
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:82
itk::LaplacianDeformationQuadEdgeMeshFilter::OutputMapPointIdentifierConstIterator
typename OutputMapPointIdentifier::const_iterator OutputMapPointIdentifierConstIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:213
itk::LaplacianDeformationQuadEdgeMeshFilter::HashOutputQEPrimal::operator()
vcl_size_t operator()(OutputQEPrimal *qe) const
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:221
itk::LaplacianDeformationQuadEdgeMeshFilter::SolverTraits
TSolverTraits SolverTraits
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:147
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:216
itk::LaplacianDeformationQuadEdgeMeshFilter::VectorType
typename SolverTraits::VectorType VectorType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:150
itk::LaplacianDeformationQuadEdgeMeshFilter::ConstraintMapType
std::unordered_map< OutputPointIdentifier, OutputVectorType > ConstraintMapType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:215
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::LaplacianDeformationQuadEdgeMeshFilterEnums::Area::MIXEDAREA
itk::LaplacianDeformationQuadEdgeMeshFilter::SetCoefficientsMethod
void SetCoefficientsMethod(CoefficientsComputationType *iMethod)
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:156
itkConceptChecking.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LaplacianDeformationQuadEdgeMeshFilter::OutputMapPointIdentifierIterator
typename OutputMapPointIdentifier::iterator OutputMapPointIdentifierIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:212
itk::TriangleHelper
A convenience class for computation of various triangle elements in 2D or 3D.
Definition: itkTriangleHelper.h:31
itk::LaplacianDeformationQuadEdgeMeshFilterEnums::Area::NONE
itk::LaplacianDeformationQuadEdgeMeshFilter::Triple::m_Degree
unsigned int m_Degree
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:305
itk::LaplacianDeformationQuadEdgeMeshFilter::HashOutputQEPrimal
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:218
itkQuadEdgeMeshToQuadEdgeMeshFilter.h
itk::MeshToMeshFilter::InputMeshType
TInputMesh InputMeshType
Definition: itkMeshToMeshFilter.h:65
itk::LaplacianDeformationQuadEdgeMeshFilter::CoefficientMapConstIterator
typename CoefficientMapType::const_iterator CoefficientMapConstIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:228
itk::LaplacianDeformationQuadEdgeMeshFilter::RowType
std::unordered_map< OutputPointIdentifier, OutputCoordRepType > RowType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:233
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::LaplacianDeformationQuadEdgeMeshFilter::AreaMapConstIterator
typename AreaMapType::const_iterator AreaMapConstIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:231
itk::LaplacianDeformationQuadEdgeMeshFilter::Triple::m_Id
OutputPointIdentifier m_Id
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:303
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LaplacianDeformationQuadEdgeMeshFilter::OutputMapPointIdentifier
std::unordered_map< OutputPointIdentifier, OutputPointIdentifier > OutputMapPointIdentifier
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:211
itk::LaplacianDeformationQuadEdgeMeshFilter::Triple::m_Weight
OutputCoordRepType m_Weight
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:304
itk::LaplacianDeformationQuadEdgeMeshFilter::ConstraintMapConstIterator
typename ConstraintMapType::const_iterator ConstraintMapConstIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:216
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputVectorType
typename OutputMeshType::VectorType OutputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:83
itk::LaplacianDeformationQuadEdgeMeshFilter::Triple
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:294
itk::QuadEdgeMeshToQuadEdgeMeshFilter
Duplicates the content of a Mesh.
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:37
itkQuadEdgeMeshParamMatrixCoefficients.h
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputCoordRepType
typename OutputMeshType::CoordRepType OutputCoordRepType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:79
itk::LaplacianDeformationQuadEdgeMeshFilter::ValueType
typename SolverTraits::ValueType ValueType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:148
itk::LaplacianDeformationQuadEdgeMeshFilter::MatrixType
typename SolverTraits::MatrixType MatrixType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:149
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk::LaplacianDeformationQuadEdgeMeshFilterEnums::Area
Area
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:41
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LaplacianDeformationQuadEdgeMeshFilter::CoefficientMapType
std::unordered_map< OutputQEPrimal *, OutputCoordRepType, HashOutputQEPrimal > CoefficientMapType
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:227
itk::LaplacianDeformationQuadEdgeMeshFilter
(abstract) base class for laplacian surface mesh deformation.
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:116
itk::MatrixCoefficients
Superclass for all the matrix coefficients computation classes.
Definition: itkQuadEdgeMeshParamMatrixCoefficients.h:33
Area
itk::LaplacianDeformationQuadEdgeMeshFilterEnums
Contains all enum classes used by LaplacianDeformationQuadEdgeMeshFilter class.
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:35
itk::MeshSource::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
itk::LaplacianDeformationQuadEdgeMeshFilter::Triple::Triple
Triple(OutputPointIdentifier iV, OutputCoordRepType iWeight, unsigned int iDegree)
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:297
itk::LaplacianDeformationQuadEdgeMeshFilter::RowConstIterator
typename RowType::const_iterator RowConstIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:235
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:81
itk::QuadEdgeMeshToQuadEdgeMeshFilter::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:80
itk::LaplacianDeformationQuadEdgeMeshFilter::RowIterator
typename RowType::iterator RowIterator
Definition: itkLaplacianDeformationQuadEdgeMeshFilter.h:234