ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkFEMLoadLandmark.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 
00019 #ifndef __itkFEMLoadLandmark_h
00020 #define __itkFEMLoadLandmark_h
00021 
00022 #include "itkFEMLoadElementBase.h"
00023 
00024 #include "vnl/vnl_vector.h"
00025 
00026 namespace itk
00027 {
00028 namespace fem
00029 {
00038 class LoadLandmark : public LoadElement
00039 {
00040 public:
00041 
00043   typedef LoadLandmark             Self;
00044   typedef LoadElement              Superclass;
00045   typedef SmartPointer<Self>       Pointer;
00046   typedef SmartPointer<const Self> ConstPointer;
00047 
00049   itkSimpleNewMacro(Self);
00050 
00052   itkTypeMacro(LoadLandmark, LoadElement);
00053 
00056   virtual::itk::LightObject::Pointer CreateAnother(void) const;
00057 
00061   void SetSolution(Solution::ConstPointer ptr)
00062   {
00063     m_Solution = ptr;
00064   }
00065   Solution::ConstPointer GetSolution()
00066   {
00067     return m_Solution;
00068   }
00069   Float GetSolution(unsigned int i, unsigned int v = 0)
00070   {
00071     return m_Solution->GetSolutionValue(i, v);
00072   }
00074 
00078   Element::VectorType & GetPoint()
00079   {
00080     return m_Point;
00081   }
00082 
00086   void SetPoint(const vnl_vector<Float> & pt)
00087   {
00088     m_Point = pt;
00089   }
00090 
00094   Element::VectorType & GetSource()
00095   {
00096     return m_Source;
00097   }
00098 
00099   const Element::VectorType & GetSource() const
00100   {
00101     return m_Source;
00102   }
00103 
00107   Element::VectorType & GetForce()
00108   {
00109     return m_Force;
00110   }
00111 
00112   const Element::VectorType & GetForce() const
00113   {
00114     return m_Force;
00115   }
00116 
00120   void SetForce(const vnl_vector<Float> & force)
00121   {
00122     if( m_Force.size() != force.size() )
00123       {
00124       m_Force.set_size( force.size() );
00125       }
00126     for( unsigned int i = 0; i < force.size(); i++ )
00127       {
00128       m_Force[i] = force[i];
00129       }
00130   }
00132 
00136   void SetSource(const vnl_vector<Float> & source)
00137   {
00138     if( m_Source.size() != source.size() )
00139       {
00140       m_Source.set_size( source.size() );
00141       }
00142     for( unsigned int i = 0; i < source.size(); i++ )
00143       {
00144       m_Source[i] = source[i];
00145       }
00146   }
00148 
00152   Element::VectorType & GetTarget()
00153   {
00154     return m_Target;
00155   }
00156   const Element::VectorType & GetTarget() const
00157   {
00158     return m_Target;
00159   }
00161 
00165   void SetTarget(const vnl_vector<Float> & target)
00166   {
00167     if( m_Target.size() != target.size() )
00168       {
00169       m_Target.set_size( target.size() );
00170       }
00171     for( unsigned int i = 0; i < target.size(); i++ )
00172       {
00173       m_Target[i] = target[i];
00174       }
00175   }
00177 
00178   void ScalePointAndForce(double *spacing, double fwt)
00179   {
00180     for( unsigned int i = 0; i < m_Target.size(); i++ )
00181       {
00182       m_Target[i] /= spacing[i];
00183       m_Source[i] /= spacing[i];
00184       this->m_Eta *= fwt;
00185       }
00186   }
00187 
00191   void SetContainedElement(Element::Pointer e)
00192   {
00193       this->m_Element[0] = e;
00194   }
00195 
00199   Element::Pointer GetContainedElement()
00200   {
00201       return const_cast<Element*>(this->m_Element[0]);
00202   }
00203 
00207   virtual bool AssignToElement(Element::ArrayType::Pointer elements);
00208 
00209   virtual bool AssignToElement(Element::ArrayType1::Pointer elements);
00210 
00211   virtual Element::ConstPointer GetAssignedElement(Element::ArrayType1::Pointer elements);
00212 
00216   LoadLandmark():
00217     m_Eta(0),
00218     m_Target(0),
00219     m_Source(0),
00220     m_Force(0),
00221     m_Solution(0)
00222   {
00223   }
00224 
00226   void SetEta(double e);
00227 
00228   double GetEta() const;
00229 
00231   virtual void ApplyLoad(Element::ConstPointer element, Element::VectorType & Fe);
00232 
00233 protected:
00234 
00235   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00236 
00240   double m_Eta;
00241 
00245   vnl_vector<Float> m_Point;
00246 
00250   vnl_vector<Float> m_Target;
00251 
00252   vnl_vector<Float> m_Source;
00253 
00254   vnl_vector<Float> m_Force;
00255 
00260   // Element::ConstPointer m_element;
00261 
00265   Solution::ConstPointer m_Solution;
00266 };
00267 
00268 }
00269 }  // end namespace itk::fem
00270 
00271 #endif // #ifndef __itkFEMLoadLandmark_h
00272