ITK  4.10.0
Insight Segmentation and Registration Toolkit
itkFEMRobustSolver.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 
19 #ifndef itkFEMRobustSolver_h
20 #define itkFEMRobustSolver_h
21 
22 #include "itkFEMSolver.h"
23 #include "itkFEMElementBase.h"
24 #include "itkFEMMaterialBase.h"
25 #include "itkFEMLoadBase.h"
29 
30 #include <cmath>
31 
32 namespace itk
33 {
34 namespace fem
35 {
82 
83 template <unsigned int VDimension = 3>
84 class RobustSolver : public Solver<VDimension>
85 {
86 public:
88  typedef RobustSolver Self;
92 
94  itkNewMacro(Self);
95 
97  itkTypeMacro(RobustSolver, Solver);
98 
100  typedef typename Superclass::VectorType VectorType;
101  typedef typename Superclass::Float Float;
109  typedef typename InterpolationGridType::DirectionType InterpolationGridDirectionType;
110 
111  itkStaticConstMacro(FEMDimension, unsigned int, VDimension);
112 
114 
116  typedef typename Element::MatrixType MatrixType;
117  typedef typename FEMObjectType::LoadContainerType LoadContainerType;
118  typedef typename FEMObjectType::NodeContainerType NodeContainerType;
119  typedef typename FEMObjectType::LoadContainerIterator LoadContainerIterator;
120 
124  itkSetMacro(ApproximationSteps, unsigned int);
125  itkGetMacro(ApproximationSteps, unsigned int);
127 
131  itkSetMacro(OutlierRejectionSteps, unsigned int);
132  itkGetMacro(OutlierRejectionSteps, unsigned int);
134 
140  itkSetMacro(ToleranceToLargestDisplacement, double);
141  itkGetMacro(ToleranceToLargestDisplacement, double);
143 
150  itkSetMacro(TradeOffImageMeshEnergy, double);
151  itkGetMacro(TradeOffImageMeshEnergy, double);
153 
158  itkSetMacro(FractionErrorRejected, double);
159  itkGetMacro(FractionErrorRejected, double);
161 
167  itkSetMacro(UseInterpolationGrid, bool);
168  itkGetMacro(UseInterpolationGrid, bool);
170 
171 protected:
172 
177  RobustSolver();
178  ~RobustSolver();
180 
183  virtual void GenerateData() ITK_OVERRIDE;
184 
186  virtual void RunSolver(void) ITK_OVERRIDE;
187 
189  void Initialization();
190 
198 
203  void InitializeLandmarks();
204 
210 
215  virtual void AssembleElementMatrixWithID(const Element::Pointer & e, unsigned int matrixIndex);
216 
222 
225 
227  void AssembleF();
228 
234 
240 
242  void SolveSystem();
243 
250 
255  void ComputeLandmarkTensor();
256 
258  float GetLandmarkTensorPonderation() const;
259 
265  void NthElementWRTDisplacementError(unsigned int numberOfRejectedBlocksPerStep);
266 
273  void UnselectLandmarks(unsigned int numberOfRejectedBlocksPerStep);
274 
280 
285  void DeleteFromLandmarkBeginning(unsigned int numberOfRejectedLandmarksPerStep);
286 
289 
297  void RescaleLandmarkStiffnessMatrix(double oldPointTensorPonderation);
298 
304 
310 
311 private:
312 
313  RobustSolver(const Self &) ITK_DELETE_FUNCTION;
314  void operator=(const Self &) ITK_DELETE_FUNCTION;
315 
321 
325  unsigned int m_ApproximationSteps;
326 
327 
329  typedef unsigned int FEMIndexType;
330 
331  FEMIndexType m_ForceIndex;
332  FEMIndexType m_LandmarkForceIndex;
333  FEMIndexType m_ExternalForceIndex;
334  FEMIndexType m_SolutionIndex;
338 
340 
344 
352 
354 };
355 
363  public std::binary_function<const Load::Pointer &, const Load::Pointer &, bool>
364 {
365 public:
366  bool operator()(const Load::Pointer & L1 , const Load::Pointer & L2)
367  {
368  LoadNoisyLandmark * l1 = dynamic_cast<LoadNoisyLandmark*>(L1.GetPointer());
369  LoadNoisyLandmark * l2 = dynamic_cast<LoadNoisyLandmark*>(L2.GetPointer());
371 
372  return l1->GetErrorNorm() > l2->GetErrorNorm();
373  }
374 };
375 
376 } // end namespace fem
377 } // end namespace itk
378 
379 #ifndef ITK_MANUAL_INSTANTIATION
380 #include "itkFEMRobustSolver.hxx"
381 #endif
382 
383 #endif
unsigned int m_OutlierRejectionSteps
void DeleteFromLandmarkBeginning(unsigned int numberOfRejectedLandmarksPerStep)
InterpolationGridType::PointType InterpolationGridPointType
Definition: itkFEMSolver.h:112
virtual void AssembleElementMatrixWithID(const Element::Pointer &e, unsigned int matrixIndex)
void RescaleLandmarkStiffnessMatrix(double oldPointTensorPonderation)
Superclass::FEMObjectType FEMObjectType
InterpolationGridType::SpacingType InterpolationGridSpacingType
Definition: itkFEMSolver.h:113
Element::VectorType VectorType
Definition: itkFEMSolver.h:99
STL namespace.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes...
Definition: itkArray.h:30
void IncrementalSolverWithOutlierRejection()
void AssembleGlobalMatrixFromLandmarksAndMeshMatrices()
Superclass::InterpolationGridSpacingType InterpolationGridSpacingType
itk::Image< Element::ConstPointer, VDimension > InterpolationGridType
Definition: itkFEMSolver.h:108
Superclass::InterpolationGridIndexType InterpolationGridIndexType
ObjectType * GetPointer() const
FEMObjectType::LoadContainerIterator LoadContainerIterator
FEMObjectType::LoadContainerType LoadContainerType
FEMIndexType m_MeshStiffnessMatrixIndex
vnl_matrix< Float > MatrixType
itk::fem::FEMObject< VDimension > FEMObjectType
Definition: itkFEMSolver.h:92
float GetLandmarkTensorPonderation() const
InterpolationGridType::RegionType InterpolationGridRegionType
Definition: itkFEMSolver.h:111
void InitializeInterpolationGrid()
static ITK_CONSTEXPR double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:58
SmartPointer< Self > Pointer
InterpolationGridType::IndexType InterpolationGridIndexType
Definition: itkFEMSolver.h:114
Superclass::VectorType VectorType
LinearSystemWrapperItpack m_Itpack
void AssembleLandmarkStiffnessMatrix()
InterpolationGridType::Pointer InterpolationGridPointerType
Definition: itkFEMSolver.h:109
Superclass::InterpolationGridPointerType InterpolationGridPointerType
FEM solver used to generate a solution for a FE formulation.
Definition: itkFEMSolver.h:73
void AddExternalForcesToSetMeshZeroEnergy()
FEMIndexType m_StiffnessMatrixIndex
Abstract base element class.
InterpolationGridType::SizeType InterpolationGridSizeType
Definition: itkFEMSolver.h:110
bool operator()(const Load::Pointer &L1, const Load::Pointer &L2)
void AssembleMeshStiffnessMatrix()
void RemoveUnselectedLandmarkContributionInPointStiffnessMatrix()
Element::MatrixType MatrixType
void NthElementWRTDisplacementError(unsigned int numberOfRejectedBlocksPerStep)
General abstract load base class.
void IncrementalSolverWithoutOutlierRejection()
InterpolationGridType::DirectionType InterpolationGridDirectionType
LinearSystemWrapper class that uses Itpack numeric library functions to define and solve a sparse lin...
void ComputeLandmarkSimulatedDisplacementAndWeightedError()
void UnselectLandmarks(unsigned int numberOfRejectedBlocksPerStep)
FEMIndexType m_LandmarkStiffnessMatrixIndex
Element::Float Float
Definition: itkFEMSolver.h:98
Superclass::InterpolationGridSizeType InterpolationGridSizeType
virtual void GenerateData() override
Superclass::InterpolationGridType InterpolationGridType
FEMObjectType::NodeContainerType NodeContainerType
static const unsigned int FEMDimension
Superclass::InterpolationGridRegionType InterpolationGridRegionType
Superclass::InterpolationGridPointType InterpolationGridPointType
SmartPointer< const Self > ConstPointer
Solver< VDimension > Superclass
virtual void RunSolver(void) override