ITK  4.3.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();
184 
188  virtual void RunSolver(void);
189 
193  void Initialization();
194 
202 
207  void InitializeLandmarks();
208 
214 
219  virtual void AssembleElementMatrixWithID(const Element::Pointer & e, unsigned int matrixIndex);
220 
226 
231 
235  void AssembleF();
236 
242 
248 
252  void SolveSystem();
253 
260 
265  void ComputeLandmarkTensor();
266 
270  float GetLandmarkTensorPonderation() const;
271 
277  void NthElementWRTDisplacementError(unsigned int numberOfRejectedBlocksPerStep);
278 
285  void UnselectLandmarks(unsigned int numberOfRejectedBlocksPerStep);
286 
292 
297  void DeleteFromLandmarkBeginning(unsigned int numberOfRejectedLandmarksPerStep);
298 
303 
311  void RescaleLandmarkStiffnessMatrix(double oldPointTensorPonderation);
312 
318 
324 
325 private:
326 
327  RobustSolver(const Self &); //purposely not implemented
328  void operator=(const Self &); //purposely not implemented
329 
335 
339  unsigned int m_ApproximationSteps;
340 
341 
345  typedef unsigned int FEMIndexType;
346 
354 
356 
360 
368 
370 };
371 
379  public std::binary_function<const Load::Pointer &, const Load::Pointer &, bool>
380 {
381 public:
382  bool operator()(const Load::Pointer & L1 , const Load::Pointer & L2)
383  {
384  LoadNoisyLandmark * l1 = dynamic_cast<LoadNoisyLandmark*>(L1.GetPointer());
385  LoadNoisyLandmark * l2 = dynamic_cast<LoadNoisyLandmark*>(L2.GetPointer());
387 
388  return l1->GetErrorNorm() > l2->GetErrorNorm();
389  }
390 };
391 
392 }
393 
394 } // end namespace itk::fem
395 
396 #ifndef ITK_MANUAL_INSTANTIATION
397 #include "itkFEMRobustSolver.hxx"
398 #endif
399 
400 #endif
401