ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkFEMLoadLandmark.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 itkFEMLoadLandmark_h
20 #define itkFEMLoadLandmark_h
21 
22 #include "itkFEMLoadElementBase.h"
23 #include "ITKFEMExport.h"
24 
25 #include "vnl/vnl_vector.h"
26 
27 namespace itk
28 {
29 namespace fem
30 {
39 class ITKFEM_EXPORT LoadLandmark : public LoadElement
40 {
41 public:
42 
44  typedef LoadLandmark Self;
48 
50  itkSimpleNewMacro(Self);
51 
53  itkTypeMacro(LoadLandmark, LoadElement);
54 
57  virtual::itk::LightObject::Pointer CreateAnother(void) const ITK_OVERRIDE;
58 
62  virtual void SetSolution(Solution::ConstPointer ptr) ITK_OVERRIDE
63  {
64  m_Solution = ptr;
65  }
66  virtual Solution::ConstPointer GetSolution() ITK_OVERRIDE
67  {
68  return m_Solution;
69  }
70  Float GetSolution(unsigned int i, unsigned int v = 0)
71  {
72  return m_Solution->GetSolutionValue(i, v);
73  }
75 
80  {
81  return m_Point;
82  }
83 
87  void SetPoint(const vnl_vector<Float> & pt)
88  {
89  m_Point = pt;
90  }
91 
96  {
97  return m_Source;
98  }
99 
101  {
102  return m_Source;
103  }
104 
109  {
110  return m_Force;
111  }
112 
114  {
115  return m_Force;
116  }
117 
121  void SetForce(const vnl_vector<Float> & force)
122  {
123  if( m_Force.size() != force.size() )
124  {
125  m_Force.set_size( force.size() );
126  }
127  for( unsigned int i = 0; i < force.size(); i++ )
128  {
129  m_Force[i] = force[i];
130  }
131  }
133 
137  void SetSource(const vnl_vector<Float> & source)
138  {
139  if( m_Source.size() != source.size() )
140  {
141  m_Source.set_size( source.size() );
142  }
143  for( unsigned int i = 0; i < source.size(); i++ )
144  {
145  m_Source[i] = source[i];
146  }
147  }
149 
154  {
155  return m_Target;
156  }
158  {
159  return m_Target;
160  }
162 
166  void SetTarget(const vnl_vector<Float> & target)
167  {
168  if( m_Target.size() != target.size() )
169  {
170  m_Target.set_size( target.size() );
171  }
172  for( unsigned int i = 0; i < target.size(); i++ )
173  {
174  m_Target[i] = target[i];
175  }
176  }
178 
179  void ScalePointAndForce(double *spacing, double fwt)
180  {
181  for( unsigned int i = 0; i < m_Target.size(); i++ )
182  {
183  m_Target[i] /= spacing[i];
184  m_Source[i] /= spacing[i];
185  this->m_Eta *= fwt;
186  }
187  }
188 
193  {
194  this->m_Element[0] = e;
195  }
196 
200  const Element * GetContainedElement() const
201  {
202  return this->m_Element[0];
203  }
204 
208  virtual bool AssignToElement(Element::ArrayType::Pointer elements);
209 
210  virtual bool AssignToElement(Element::ArrayType1::Pointer elements);
211 
212  virtual Element::ConstPointer GetAssignedElement(Element::ArrayType1::Pointer elements);
213 
218  m_Eta(0),
219  m_Target(0),
220  m_Source(0),
221  m_Force(0),
222  m_Solution(ITK_NULLPTR)
223  {
224  }
225 
227  void SetEta(double e);
228 
229  double GetEta() const;
230 
232  virtual void ApplyLoad(Element::ConstPointer element, Element::VectorType & Fe) ITK_OVERRIDE;
233 
234 protected:
235 
236  virtual void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
237 
241  double m_Eta;
242 
246  vnl_vector<Float> m_Point;
247 
251  vnl_vector<Float> m_Target;
252 
253  vnl_vector<Float> m_Source;
254 
255  vnl_vector<Float> m_Force;
256 
261  // Element::ConstPointer m_element;
262 
267 };
268 
269 }
270 } // end namespace itk::fem
271 
272 #endif // #ifndef itkFEMLoadLandmark_h
Light weight base class for most itk classes.
Element::VectorType & GetTarget()
virtual Solution::ConstPointer GetSolution() override
vnl_vector< Float > m_Point
void SetSource(const vnl_vector< Float > &source)
void ScalePointAndForce(double *spacing, double fwt)
vnl_vector< Float > m_Force
Element::VectorType & GetPoint()
Provides functions to access the values of the solution vector.
This load is derived from the motion of a specific landmark.
Float GetSolution(unsigned int i, unsigned int v=0)
Solution::ConstPointer m_Solution
vnl_vector< Float > VectorType
Virtual element load base class.
void SetTarget(const vnl_vector< Float > &target)
void SetContainedElement(const Element *e)
void SetPoint(const vnl_vector< Float > &pt)
const Element::VectorType & GetTarget() const
Array for FEMP objects.
Definition: itkFEMPArray.h:40
Abstract base element class.
void SetForce(const vnl_vector< Float > &force)
vnl_vector< Float > m_Source
SmartPointer< Self > Pointer
Element::VectorType & GetSource()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
const Element * GetContainedElement() const
SmartPointer< const Self > ConstPointer
vnl_vector< Float > m_Target
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:56
const Element::VectorType & GetSource() const
const Element::VectorType & GetForce() const
Element::VectorType & GetForce()