ITK  4.6.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 
24 #include "vnl/vnl_vector.h"
25 
26 namespace itk
27 {
28 namespace fem
29 {
38 class LoadLandmark : public LoadElement
39 {
40 public:
41 
43  typedef LoadLandmark Self;
47 
49  itkSimpleNewMacro(Self);
50 
52  itkTypeMacro(LoadLandmark, LoadElement);
53 
56  virtual::itk::LightObject::Pointer CreateAnother(void) const ITK_OVERRIDE;
57 
61  virtual void SetSolution(Solution::ConstPointer ptr) ITK_OVERRIDE
62  {
63  m_Solution = ptr;
64  }
65  virtual Solution::ConstPointer GetSolution() ITK_OVERRIDE
66  {
67  return m_Solution;
68  }
69  Float GetSolution(unsigned int i, unsigned int v = 0)
70  {
71  return m_Solution->GetSolutionValue(i, v);
72  }
74 
79  {
80  return m_Point;
81  }
82 
86  void SetPoint(const vnl_vector<Float> & pt)
87  {
88  m_Point = pt;
89  }
90 
95  {
96  return m_Source;
97  }
98 
100  {
101  return m_Source;
102  }
103 
108  {
109  return m_Force;
110  }
111 
113  {
114  return m_Force;
115  }
116 
120  void SetForce(const vnl_vector<Float> & force)
121  {
122  if( m_Force.size() != force.size() )
123  {
124  m_Force.set_size( force.size() );
125  }
126  for( unsigned int i = 0; i < force.size(); i++ )
127  {
128  m_Force[i] = force[i];
129  }
130  }
132 
136  void SetSource(const vnl_vector<Float> & source)
137  {
138  if( m_Source.size() != source.size() )
139  {
140  m_Source.set_size( source.size() );
141  }
142  for( unsigned int i = 0; i < source.size(); i++ )
143  {
144  m_Source[i] = source[i];
145  }
146  }
148 
153  {
154  return m_Target;
155  }
157  {
158  return m_Target;
159  }
161 
165  void SetTarget(const vnl_vector<Float> & target)
166  {
167  if( m_Target.size() != target.size() )
168  {
169  m_Target.set_size( target.size() );
170  }
171  for( unsigned int i = 0; i < target.size(); i++ )
172  {
173  m_Target[i] = target[i];
174  }
175  }
177 
178  void ScalePointAndForce(double *spacing, double fwt)
179  {
180  for( unsigned int i = 0; i < m_Target.size(); i++ )
181  {
182  m_Target[i] /= spacing[i];
183  m_Source[i] /= spacing[i];
184  this->m_Eta *= fwt;
185  }
186  }
187 
192  {
193  this->m_Element[0] = e;
194  }
195 
199  const Element * GetContainedElement() const
200  {
201  return this->m_Element[0];
202  }
203 
207  virtual bool AssignToElement(Element::ArrayType::Pointer elements);
208 
209  virtual bool AssignToElement(Element::ArrayType1::Pointer elements);
210 
212 
217  m_Eta(0),
218  m_Target(0),
219  m_Source(0),
220  m_Force(0),
221  m_Solution(ITK_NULLPTR)
222  {
223  }
224 
226  void SetEta(double e);
227 
228  double GetEta() const;
229 
231  virtual void ApplyLoad(Element::ConstPointer element, Element::VectorType & Fe) ITK_OVERRIDE;
232 
233 protected:
234 
235  virtual void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
236 
240  double m_Eta;
241 
245  vnl_vector<Float> m_Point;
246 
250  vnl_vector<Float> m_Target;
251 
252  vnl_vector<Float> m_Source;
253 
254  vnl_vector<Float> m_Force;
255 
260  // Element::ConstPointer m_element;
261 
266 };
267 
268 }
269 } // end namespace itk::fem
270 
271 #endif // #ifndef __itkFEMLoadLandmark_h
virtual Element::ConstPointer GetAssignedElement(Element::ArrayType1::Pointer elements)
Light weight base class for most itk classes.
Element::VectorType & GetTarget()
vnl_vector< Float > m_Point
void SetSource(const vnl_vector< Float > &source)
Element::ConstPointer m_Element
void ScalePointAndForce(double *spacing, double fwt)
virtual Solution::ConstPointer GetSolution() ITK_OVERRIDE
static const double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:45
virtual void ApplyLoad(Element::ConstPointer element, Element::VectorType &Fe) ITK_OVERRIDE
vnl_vector< Float > m_Force
Element::VectorType & GetPoint()
virtual ::itk::LightObject::Pointer CreateAnother(void) const ITK_OVERRIDE
Provides functions to access the values of the solution vector.
This load is derived from the motion of a specific landmark.
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
Float GetSolution(unsigned int i, unsigned int v=0)
Solution::ConstPointer m_Solution
vnl_vector< Float > VectorType
Virtual element load base class.
virtual bool AssignToElement(Element::ArrayType::Pointer elements)
void SetTarget(const vnl_vector< Float > &target)
double GetEta() const
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
const Element::VectorType & GetSource() const
virtual Float GetSolutionValue(unsigned int i, unsigned int solutionIndex=0) const =0
void SetEta(double e)
const Element::VectorType & GetForce() const
virtual void SetSolution(Solution::ConstPointer ptr) ITK_OVERRIDE
Element::VectorType & GetForce()