ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkFEMObject.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 #ifndef __itkFEMObject_h
00019 #define __itkFEMObject_h
00020 
00021 #include "itkDataObject.h"
00022 
00023 #include "itkFEMElementBase.h"
00024 #include "itkFEMLinearSystemWrapper.h"
00025 #include "itkFEMLinearSystemWrapperVNL.h"
00026 #include "itkFEMLoadBase.h"
00027 #include "itkFEMLoadNode.h"
00028 #include "itkFEMLoadBC.h"
00029 #include "itkFEMLoadBCMFC.h"
00030 #include "itkFEMLoadEdge.h"
00031 #include "itkFEMLoadGrav.h"
00032 #include "itkFEMLoadLandmark.h"
00033 #include "itkFEMMaterialBase.h"
00034 #include "itkFEMMaterialLinearElasticity.h"
00035 #include "itkVectorContainer.h"
00036 
00037 namespace itk
00038 {
00039 namespace fem
00040 {
00073 template <unsigned int VDimension = 3>
00074 class ITK_EXPORT FEMObject : public DataObject
00075 {
00076 public:
00078   typedef FEMObject                Self;
00079   typedef DataObject               Superclass;
00080   typedef SmartPointer<Self>       Pointer;
00081   typedef SmartPointer<const Self> ConstPointer;
00082 
00084   itkNewMacro(Self);
00085 
00087   itkTypeMacro(FEMObject, DataObject);
00088 
00089   itkStaticConstMacro(FEMDimension, unsigned int, VDimension);
00090   itkStaticConstMacro(MaxDimensions, unsigned int, 3);
00091 
00092   typedef unsigned long ElementIdentifier;
00093   typedef unsigned long NodeIdentifier;
00094   typedef unsigned long LoadIdentifier;
00095   typedef unsigned long MaterialIdentifier;
00096 
00098   typedef VectorContainer<LoadIdentifier, Load::Pointer>          LoadContainerType;
00099   typedef VectorContainer<MaterialIdentifier, Material::Pointer>  MaterialContainerType;
00100   typedef VectorContainer<ElementIdentifier, Element::Pointer>    ElementContainerType;
00101   typedef VectorContainer<NodeIdentifier, Element::Node::Pointer> NodeContainerType;
00102 
00104   typedef typename ElementContainerType::Pointer       ElementContainerPointer;
00105   typedef typename ElementContainerType::ConstPointer  ElementContainerConstPointer;
00106   typedef typename NodeContainerType::Pointer          NodeContainerPointer;
00107   typedef typename NodeContainerType::ConstPointer     NodeContainerConstPointer;
00108   typedef typename LoadContainerType::Pointer          LoadContainerPointer;
00109   typedef typename LoadContainerType::ConstPointer     LoadContainerConstPointer;
00110   typedef typename MaterialContainerType::Pointer      MaterialContainerPointer;
00111   typedef typename MaterialContainerType::ConstPointer MaterialContainerConstPointer;
00112 
00114   typedef typename
00115   ElementContainerType::ConstIterator         ElementContainerConstIterator;
00116   typedef typename
00117   ElementContainerType::Iterator              ElementContainerIterator;
00118   typedef typename
00119   NodeContainerType::ConstIterator            NodeContainerConstIterator;
00120   typedef typename
00121   NodeContainerType::Iterator                 NodeContainerIterator;
00122   typedef typename
00123   LoadContainerType::ConstIterator            LoadContainerConstIterator;
00124   typedef typename
00125   LoadContainerType::Iterator                 LoadContainerIterator;
00126   typedef typename
00127   MaterialContainerType::ConstIterator        MaterialContainerConstIterator;
00128   typedef typename
00129   MaterialContainerType::Iterator             MaterialContainerIterator;
00130 
00131   // Copy the contents
00132   void DeepCopy(FEMObject *Copy);
00133 
00134   // Get methods to get the entire VectorContainers for Elements, Nodes, Loads, and Materials
00135   itkGetObjectMacro(ElementContainer, ElementContainerType);
00136   itkGetObjectMacro(NodeContainer, NodeContainerType);
00137   itkGetObjectMacro(LoadContainer, LoadContainerType);
00138   itkGetObjectMacro(MaterialContainer, MaterialContainerType);
00139 
00141   unsigned int GetNumberOfDegreesOfFreedom(void) const
00142   {
00143     return m_NGFN;
00144   }
00145 
00147   unsigned int GetNumberOfMultiFreedomConstraints(void) const
00148   {
00149     return m_NMFC;
00150   }
00151 
00153   unsigned int GetNumberOfNodes(void) const
00154   {
00155     return m_NodeContainer->Size();
00156   }
00157 
00159   unsigned int GetNumberOfElements(void) const
00160   {
00161     return m_ElementContainer->Size();
00162   }
00163 
00165   unsigned int GetNumberOfLoads(void) const
00166   {
00167     return m_LoadContainer->Size();
00168   }
00169 
00171   unsigned int GetNumberOfMaterials(void) const
00172   {
00173     return m_MaterialContainer->Size();
00174   }
00175 
00179   void AddNextElement(Element::Pointer e);
00180 
00184   void InsertElement(Element::Pointer e, ElementIdentifier index);
00185 
00189   void AddNextNode(Element::Node::Pointer e);
00190 
00194   void InsertNode(Element::Node::Pointer e, NodeIdentifier index);
00195 
00199   void AddNextMaterial(Material::Pointer mat)
00200   {
00201     this->AddNextMaterialInternal(mat.GetPointer());
00202   }
00203   void AddNextMaterial(MaterialLinearElasticity::Pointer mat)
00204   {
00205     this->AddNextMaterialInternal(mat.GetPointer());
00206   }
00207 
00211   void InsertMaterial(Material::Pointer e, MaterialIdentifier index);
00212 
00216   void AddNextLoad(Load::Pointer ld)
00217   { this->AddNextLoadInternal(ld.GetPointer()); }
00218   void AddNextLoad(LoadNode::Pointer ld)
00219   { this->AddNextLoadInternal(ld.GetPointer()); }
00220   void AddNextLoad(LoadBCMFC::Pointer ld)
00221   { this->AddNextLoadInternal(ld.GetPointer()); }
00222   void AddNextLoad(LoadBC::Pointer ld)
00223   { this->AddNextLoadInternal(ld.GetPointer()); }
00224   void AddNextLoad(LoadEdge::Pointer ld)
00225   { this->AddNextLoadInternal(ld.GetPointer()); }
00226   void AddNextLoad(LoadGravConst::Pointer ld)
00227   { this->AddNextLoadInternal(ld.GetPointer()); }
00228   void AddNextLoad(LoadLandmark::Pointer ld)
00229   { this->AddNextLoadInternal(ld.GetPointer()); }
00230 
00234   void InsertLoad(Load::Pointer ld, LoadIdentifier index);
00235 
00239   Element::ConstPointer GetElement(ElementIdentifier index) const;
00240   Element::Pointer GetElement(ElementIdentifier index);
00242 
00246   Element::ConstPointer GetElementWithGlobalNumber(int globalNumber) const;
00247   Element::Pointer GetElementWithGlobalNumber(int globalNumber);
00249 
00253   Element::Node::Pointer GetNode(NodeIdentifier index);
00254   Element::Node::ConstPointer GetNode(NodeIdentifier index) const;
00256 
00260   Element::Node::Pointer GetNodeWithGlobalNumber(int globalNumber);
00261 
00265   Material::ConstPointer GetMaterial(MaterialIdentifier index) const;
00266   Material::Pointer GetMaterial(MaterialIdentifier index);
00268 
00272   Material::ConstPointer GetMaterialWithGlobalNumber(int globalNumber) const;
00273   Material::Pointer GetMaterialWithGlobalNumber(int globalNumber);
00275 
00279   Load::ConstPointer GetLoad(LoadIdentifier index) const;
00280   Load::Pointer GetLoad(LoadIdentifier index);
00282 
00286   Load::Pointer GetLoadWithGlobalNumber(int globalNumber);
00287 
00291   void Clear();
00292 
00297   void RenumberNodeContainer();
00298 
00305   void FinalizeMesh();
00306 
00307 protected:
00309   FEMObject();
00310   ~FEMObject();
00311   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00313 
00319   void GenerateGFN(void);
00320 
00326   void GenerateMFC(void);
00327 
00328   void AddNextMaterialInternal(Material *mat);
00332   unsigned int m_NGFN;
00333 
00338   unsigned int m_NMFC;
00339 
00340   ElementContainerPointer  m_ElementContainer;
00341   NodeContainerPointer     m_NodeContainer;
00342   LoadContainerPointer     m_LoadContainer;
00343   MaterialContainerPointer m_MaterialContainer;
00344 private:
00345   FEMObject(const Self &);      // purposely not implemented
00346   void operator=(const Self &); // purposely not implemented
00347 
00348   void AddNextLoadInternal(Load *l);
00349 };  // End Class: FEMObject
00350 
00351 }
00352 }
00353 
00354 #ifndef ITK_MANUAL_INSTANTIATION
00355 #include "itkFEMObject.hxx"
00356 #endif
00357 
00358 #endif // #ifndef __itkFEMObject_h
00359