00001 #ifndef _DEF_UniformScale_TXX
00002 #define _DEF_UniformScale_TXX
00003
00004 #include "Def_UniformScale.h"
00005
00006 namespace mial
00007 {
00008
00009 template<class DataType,int nDims,class MType, class VType>
00010 Def_UniformScale<DataType, nDims,MType,VType>
00011 ::Def_UniformScale()
00012 {
00013 this->name = "Def_UniformScale";
00014 }
00015
00016 template<class DataType,int nDims,class MType, class VType>
00017 bool Def_UniformScale<DataType, nDims,MType,VType>
00018 ::run(typename Deformation<DataType,nDims>::deformationIn* i,typename Deformation<DataType,nDims>::DefArgSet* org, std::stringstream *s)
00019 {
00020 DefArgSet* orgUp = reinterpret_cast<DefArgSet *>(org);
00021 typename deformationIn::Pointer in;
00022 if(i !=NULL && s != NULL)
00023 {
00024 Error e;
00025 e.msg = "Only one of struct or stream input may be provided.";
00026 e.name = "Def_UniformScale";
00027 throw e;
00028 }
00029 else if(i !=NULL)
00030 in = reinterpret_cast<deformationIn *>(i);
00031 else if( s!= NULL)
00032 {
00033 in = deformationIn::New();
00034 in->fillFromStream(*s);
00035 }
00036 else
00037 {
00038 Error e;
00039 e.msg = "Either struct or stream input must be provided.";
00040 e.name = "Def_UniformScale";
00041 throw e;
00042 }
00043 int numSprings = orgUp->springsRest->size();
00044
00045 for( unsigned int i=0; i<numSprings; i++ )
00046 {
00047 orgUp->springsRest->put(i,orgUp->springsRest->get(i)*in->scaleAmount);
00048 }
00049
00050 return false;
00051 }
00052
00053 }
00054
00055 #endif