1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkFEMLoadEdge.cxx,v $
Language: C++
Date: $Date: 2009-01-30 21:10:18 $
Version: $Revision: 1.13 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// disable debug warnings in MS compiler
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include "itkFEMLoadEdge.h"
namespace itk {
namespace fem {
/**
* Read the Load object from input stream
*/
void LoadEdge::Read( std::istream& f, void* info )
{
int n,m;
/** first call the parent's read function */
Superclass::Read(f,info);
/** ... edge number */
this->SkipWhiteSpace(f); f>>n; if(!f) goto out;
m_Edge=n;
/** ... # of rows */
this->SkipWhiteSpace(f); f>>n; if(!f) goto out;
/** ... # of cols */
this->SkipWhiteSpace(f); f>>m; if(!f) goto out;
m_Force.set_size(n,m);
for(int i=0; i<n; i++)
{
this->SkipWhiteSpace(f);
for(int j=0; j<m; j++)
{
f>>m_Force[i][j];
}
this->SkipWhiteSpace(f);
}
out:
if( !f )
{
throw FEMExceptionIO(__FILE__,__LINE__,"LoadEdge::Read()","Error reading FEM load!");
}
}
/**
* Write the Load object to the output stream
*/
void LoadEdge::Write( std::ostream& f ) const
{
/** first call the parent's write function */
Superclass::Write(f);
/** Write the actual Load data */
/** ... edge number */
f<<"\t"<<m_Edge<<"\t% Edge number"<<"\n";
/** ... force matrix */
f<<"\t"<<m_Force.rows()<<"\t% # rows in force matrix"<<"\n";
f<<"\t"<<m_Force.cols()<<"\t% # cols in force matrix"<<"\n";
f<<"\t% force matrix\n";
for(int i=0; i<(int)m_Force.rows(); i++)
{
f<<"\t";
for(int j=0; j<(int)m_Force.cols(); j++)
{
f<<m_Force[i][j]<<" ";
}
f<<"\n";
}
/** check for errors */
if (!f)
{
throw FEMExceptionIO(__FILE__,__LINE__,"LoadBCMFC::Write()","Error writing FEM load!");
}
}
FEM_CLASS_REGISTER(LoadEdge)
}} // end namespace itk::fem
|