ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkFEMElementStd.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 __itkFEMElementStd_h
00020 #define __itkFEMElementStd_h
00021 
00022 #include "itkFEMElementBase.h"
00023 
00024 namespace itk
00025 {
00026 namespace fem
00027 {
00055 template <unsigned int VNumberOfNodes, unsigned int VNumberOfSpatialDimensions, class TBaseClass = Element>
00056 class ElementStd : public TBaseClass
00057 {
00058 public:
00059 
00061   typedef ElementStd               Self;
00062   typedef TBaseClass               Superclass;
00063   typedef SmartPointer<Self>       Pointer;
00064   typedef SmartPointer<const Self> ConstPointer;
00065 
00067   itkTypeMacro(ElementStd, TBaseClass);
00068 
00069 // FIXME: Add concept cheking for TBaseClass, and TPointClass
00070 
00071   // Repeat typedefs and enums from parent class
00072 
00073   typedef typename Superclass::Float                 Float;
00074   typedef typename Superclass::MatrixType            MatrixType;
00075   typedef typename Superclass::VectorType            VectorType;
00076   typedef typename Superclass::LoadType              LoadType;
00077   typedef typename Superclass::LoadPointer           LoadPointer;
00078   typedef typename Superclass::NodeIDType            NodeIDType;
00079   typedef typename Superclass::DegreeOfFreedomIDType DegreeOfFreedomIDType;
00080   typedef typename Superclass::Node                  Node;
00081   enum { InvalidDegreeOfFreedomID = Superclass::InvalidDegreeOfFreedomID };
00082 
00086   enum { NumberOfNodes = VNumberOfNodes };
00087 
00091   enum { NumberOfSpatialDimensions = VNumberOfSpatialDimensions };
00092 
00096   ElementStd();
00097 
00098   // ////////////////////////////////////////////////////////////////////////
00102   virtual unsigned int GetNumberOfNodes(void) const
00103   {
00104     return NumberOfNodes;
00105   }
00106 
00111   virtual NodeIDType GetNode(unsigned int n) const
00112   {
00113     if( n >= NumberOfNodes )
00114       {
00115       return 0;
00116       }
00117     return this->m_node[n];
00118   }
00119 
00120   virtual void SetNode(unsigned int n, NodeIDType node)
00121   {
00122     this->SetNodeInternal(n,node);
00123   }
00124   virtual void SetNode(unsigned int n, typename Superclass::Node::Pointer node)
00125   {
00126     this->SetNodeInternal(n,node);
00127   }
00128 
00130   virtual const VectorType & GetNodeCoordinates(unsigned int n) const
00131   {
00132     return m_node[n]->GetCoordinates();
00133   }
00134 
00136   virtual unsigned int GetNumberOfSpatialDimensions() const
00137   {
00138     return NumberOfSpatialDimensions;
00139   }
00140 
00141   // ////////////////////////////////////////////////////////////////////////
00142 protected:
00143 
00144   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00145 
00146   virtual void SetNodeInternal(unsigned int n, const Node *node)
00147   {
00148     if( n >= NumberOfNodes )
00149       {
00150       return;
00151       }
00152     this->m_node[n] = node;
00153   }
00157   const Node *m_node[NumberOfNodes];
00158 };
00159 
00160 }
00161 }  // end namespace itk::fem
00162 
00163 #ifndef ITK_MANUAL_INSTANTIATION
00164 #include "itkFEMElementStd.hxx"
00165 #endif
00166 
00167 #endif // #ifndef __itkFEMElementStd_h
00168