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
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkFEMLoadNode.cxx,v $
Language: C++
Date: $Date: 2009-01-30 21:10:18 $
Version: $Revision: 1.14 $
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 "itkFEMLoadNode.h"
namespace itk {
namespace fem {
/**
* Read the LoadNode object from input stream
*/
void LoadNode::Read( std::istream& f, void* info )
{
int n;
/**
* Convert the info pointer to a usable objects
*/
ReadInfoType::ElementArrayPointer elements=static_cast<ReadInfoType*>(info)->m_el;
/** first call the parent's read function */
Superclass::Read(f,info);
/** read and set pointer to node that we're applying the load to */
this->SkipWhiteSpace(f); f>>n; if(!f) goto out;
try
{
this->m_element=dynamic_cast<const Element*>( &*elements->Find(n));
}
catch ( FEMExceptionObjectNotFound e )
{
throw FEMExceptionObjectNotFound(__FILE__,__LINE__,"LoadNode::Read()",e.m_baseClassName,e.m_GN);
}
/* read and set the point number */
this->SkipWhiteSpace(f); f>>this->m_pt; if(!f) goto out;
/** read and set the number of elements inside a force vector */
this->SkipWhiteSpace(f); f>>n; if(!f) goto out;
this->F.set_size(n);
/** read the force vector itself */
this->SkipWhiteSpace(f); f>>this->F; if(!f) goto out;
out:
if( !f )
{
throw FEMExceptionIO(__FILE__,__LINE__,"LoadNode::Read()","Error reading FEM load!");
}
}
/**
* Write the LoadNode to the output stream
*/
void LoadNode::Write( std::ostream& f ) const {
/** first call the parent's write function */
Superclass::Write(f);
/** write the actual Load data */
f<<"\t"<<this->m_element->GN<<"\t% GN of element on which the load acts"<<"\n";
f<<"\t"<<this->m_pt<<" "<<"\t% Point number within the element\n";
f<<"\t"<<this->F.size()<<" "<<this->F<<"\t% Force vector (first number is the size of a vector)\n";
/** check for errors */
if (!f)
{
throw FEMExceptionIO(__FILE__,__LINE__,"LoadNode::Write()","Error writing FEM load!");
}
}
FEM_CLASS_REGISTER(LoadNode)
}} // end namespace itk::fem
|