Orfeo Toolbox  3.16
itkFEMElementStd.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFEMElementStd.txx,v $
5  Language: C++
6  Date: $Date: 2009-01-29 21:28:16 $
7  Version: $Revision: 1.14 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkFEMElementStd_txx
19 #define __itkFEMElementStd_txx
20 
21 #include "itkFEMElementStd.h"
22 
23 namespace itk {
24 namespace fem {
25 
26 template<unsigned int VNumberOfPoints, unsigned int VNumberOfSpatialDimensions, class TBaseClass>
29 {
30  // Set all node ids to 0 (undefined).
31  for(int i=0; i<NumberOfNodes; i++)
32  {
33  this->m_node[i]=0;
34  }
35 }
36 
37 
38 template<unsigned int VNumberOfPoints, unsigned int VNumberOfSpatialDimensions, class TBaseClass>
39 void
41 ::Read( std::istream& f, void* info )
42 {
43  int n;
44  // Convert the info pointer to a usable object
45  ReadInfoType::NodeArrayPointer nodes=static_cast<ReadInfoType*>(info)->m_node;
46 
47  // First call the parent's read function
48  Superclass::Read(f,info);
49 
50  try
51  {
52  // Read and set each of the expected global node numbers
53  for(unsigned int p=0; p<NumberOfNodes; p++)
54  {
55  this->SkipWhiteSpace(f); f>>n; if(!f) goto out;
56  m_node[p]=dynamic_cast<const Element::Node*>( &*nodes->Find(n));
57  }
58 
59  }
60  catch ( FEMExceptionObjectNotFound e )
61  {
62  throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"ElementStd::Read()",e.m_baseClassName,e.m_GN);
63  }
64 
65 
66 out:
67 
68  if( !f )
69  {
70  throw FEMExceptionIO(__FILE__,__LINE__,"ElementStd::Read()","Error reading FEM element!");
71  }
72 
73 }
74 
75 
76 template<unsigned int VNumberOfPoints, unsigned int VNumberOfSpatialDimensions, class TBaseClass>
77 void
79 ::Write( std::ostream& f ) const
80 {
81  // First call the parent's write function
82  Superclass::Write(f);
83 
84  // ... then write the actual data (node ids)
85  // We also add some comments in the output file
86  for(unsigned int p=0; p<NumberOfNodes; p++)
87  {
88  f<<"\t"<<m_node[p]->GN<<"\t% Node #"<<(p+1)<<" ID\n";
89  }
90 
91  // check for errors
92  if (!f)
93  {
94  throw FEMExceptionIO(__FILE__,__LINE__,"ElementStd::Write()","Error writing FEM element!");
95  }
96 
97 }
98 
99 #ifdef _MSC_VER
100 // Declare a static dummy function to prevent a MSVC 6.0 SP5 from crashing.
101 // I have no idea why things don't work when this is not declared, but it
102 // looks like this declaration makes compiler forget about some of the
103 // troubles it has with templates.
104 static void Dummy( void );
105 #endif // #ifdef _MSC_VER
106 
107 }} // end namespace itk::fem
108 
109 #endif // #ifndef __itkFEMElementStd_txx

Generated at Sat Feb 2 2013 23:36:43 for Orfeo Toolbox with doxygen 1.8.1.1