ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLaplacianDeformationQuadEdgeMeshFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
24 #include "itkConceptChecking.h"
25 
26 #include "itksys/hash_map.hxx"
27 
28 namespace itk {
92 template< class TInputMesh, class TOutputMesh, class TSolverTraits >
93 class ITK_TEMPLATE_EXPORT LaplacianDeformationQuadEdgeMeshFilter:
94  public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
95 {
96 public:
97  ITK_DISALLOW_COPY_AND_ASSIGN(LaplacianDeformationQuadEdgeMeshFilter);
98 
104 
106 
107 
108  using InputMeshType = TInputMesh;
110 
111  static constexpr unsigned int InputPointDimension = InputMeshType::PointDimension;
112 
114  using OutputMeshType = TOutputMesh;
121 
122  static constexpr unsigned int OutputPointDimension = OutputMeshType::PointDimension;
123 
124  using SolverTraits = TSolverTraits;
125  using ValueType = typename SolverTraits::ValueType;
126  using MatrixType = typename SolverTraits::MatrixType;
127  using VectorType = typename SolverTraits::VectorType;
128 
130 
132  void SetCoefficientsMethod(CoefficientsComputationType *iMethod)
133  {
134  this->m_CoefficientsMethod = iMethod;
135  this->Modified();
136  }
138 
140 
142  void SetConstrainedNode(OutputPointIdentifier vId, const OutputPointType & iP);
143 
145  void SetDisplacement(OutputPointIdentifier vId, const OutputVectorType &iV);
146 
150  bool GetDisplacement( OutputPointIdentifier vId, OutputVectorType& oV ) const;
151 
153  void ClearConstraints();
154 
156  itkSetMacro(Order, unsigned int);
157  itkGetMacro(Order, unsigned int);
159 
160  enum AreaType
161  {
163  NONE = 0,
164 
166  MIXEDAREA
167  };
168 
170  itkSetMacro(AreaComputationType, AreaType );
171  itkGetMacro(AreaComputationType, AreaType );
173 
174 #ifdef ITK_USE_CONCEPT_CHECKING
175  itkConceptMacro( SameDimensionCheck1,
177  itkConceptMacro( SameDimensionCheck2,
179 #endif
180 
181 protected:
182 
185  ~LaplacianDeformationQuadEdgeMeshFilter() override = default;
187 
188  using OutputMapPointIdentifier = itksys::hash_map< OutputPointIdentifier, OutputPointIdentifier >;
189  using OutputMapPointIdentifierIterator = typename OutputMapPointIdentifier::iterator;
190  using OutputMapPointIdentifierConstIterator = typename OutputMapPointIdentifier::const_iterator;
191 
192  using ConstraintMapType = itksys::hash_map< OutputPointIdentifier, OutputVectorType >;
193  using ConstraintMapConstIterator = typename ConstraintMapType::const_iterator;
194 
196  {
197  size_t operator() ( OutputQEPrimal* qe ) const
198  {
199  return reinterpret_cast< size_t >( qe );
200  }
201  };
202 
203  using CoefficientMapType = itksys::hash_map< OutputQEPrimal*, OutputCoordRepType, HashOutputQEPrimal >;
204  using CoefficientMapConstIterator = typename CoefficientMapType::const_iterator;
205 
206  using AreaMapType = itksys::hash_map< OutputPointIdentifier, OutputCoordRepType >;
207  using AreaMapConstIterator = typename AreaMapType::const_iterator;
208 
209  using RowType = itksys::hash_map< OutputPointIdentifier, OutputCoordRepType >;
210  using RowIterator = typename RowType::iterator;
211  using RowConstIterator = typename RowType::const_iterator;
212 
217 
219 
220  unsigned int m_Order{1};
222 
223  void PrintSelf(std::ostream & os, Indent indent) const override;
224 
225  OutputCoordRepType ComputeMixedAreaForGivenVertex(OutputPointIdentifier vId);
226  OutputCoordRepType ComputeMixedArea(OutputQEPrimal *iQE1, OutputQEPrimal *iQE2);
227 
228  virtual void ComputeVertexIdMapping();
229 
230  void ComputeLaplacianMatrix( MatrixType &ioL );
231 
232  void
233  FillMatrixRow(OutputPointIdentifier iId,
234  unsigned int iDegree,
235  OutputCoordRepType iWeight,
236  RowType & ioRow);
237 
242  void FillMatrix(MatrixType & iM, VectorType & iBx, VectorType & iBy, VectorType & iBz);
243 
256  void SolveLinearSystems(const MatrixType & iM,
257  const VectorType & iBx,
258  const VectorType & iBy,
259  const VectorType & iBz,
260  VectorType & oX,
261  VectorType & oY,
262  VectorType & oZ);
263 
264 
265 private:
266  struct Triple
267  {
268  Triple() = default;
269  Triple(OutputPointIdentifier iV, OutputCoordRepType iWeight, unsigned int iDegree):
270  m_Id(iV), m_Weight(iWeight), m_Degree(iDegree) {}
271 
274  unsigned int m_Degree;
275  };
276 };
277 } // end namespace itk
278 
279 #include "itkLaplacianDeformationQuadEdgeMeshFilter.hxx"
280 
281 #endif
Light weight base class for most itk classes.
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
Triple(OutputPointIdentifier iV, OutputCoordRepType iWeight, unsigned int iDegree)
itksys::hash_map< OutputPointIdentifier, OutputCoordRepType > AreaMapType
typename OutputMeshType::PointIdentifier OutputPointIdentifier
itksys::hash_map< OutputPointIdentifier, OutputCoordRepType > RowType
typename ConstraintMapType::const_iterator ConstraintMapConstIterator
typename OutputMeshType::CoordRepType OutputCoordRepType
A convenience class for computation of various triangle elements in 2D or 3D.
itksys::hash_map< OutputPointIdentifier, OutputPointIdentifier > OutputMapPointIdentifier
typename CoefficientMapType::const_iterator CoefficientMapConstIterator
typename OutputMapPointIdentifier::const_iterator OutputMapPointIdentifierConstIterator
typename OutputMapPointIdentifier::iterator OutputMapPointIdentifierIterator
itksys::hash_map< OutputQEPrimal *, OutputCoordRepType, HashOutputQEPrimal > CoefficientMapType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename OutputMeshType::VectorType OutputVectorType
itksys::hash_map< OutputPointIdentifier, OutputVectorType > ConstraintMapType
#define itkConceptMacro(name, concept)
(abstract) base class for laplacian surface mesh deformation.
typename OutputQEPrimal::IteratorGeom OutputQEIterator
Superclass for all the matrix coefficients computation classes.