]> Creatis software - creaBruker.git/blobdiff - lib/src1/brukerobjectvaryingproperties.cpp
- use creaBruker_EXPORT
[creaBruker.git] / lib / src1 / brukerobjectvaryingproperties.cpp
index 2d6f733f2ceeeed6f2f1f4a7c48cd99991a6dac8..1222eae8387f757e7d43a448bd55ed2f4b0a02c0 100644 (file)
@@ -10,7 +10,7 @@
 //
 //
 #include "brukerobjectvaryingproperties.h"
-//#include "brukerexception.h"
+#include "brukerexception.h"
 
 
 BrukerObjectVaryingProperties::BrukerObjectVaryingProperties()
@@ -43,7 +43,8 @@ void BrukerObjectVaryingProperties::computeTE(std::map<std::string, BrukerFieldD
 
 double BrukerObjectVaryingProperties::getTE(unsigned int theValue) const{
    if (theValue < TE.size() ) {return TE[theValue];}
-   else throw 0;
+   //else throw 0;
+   else throw BrukerSizeException("TE", theValue, TE.size() ); 
 }
 
 /*void BrukerObjectVaryingProperties::computeTE(const std::vector< double >& theValue)
@@ -53,7 +54,8 @@ double BrukerObjectVaryingProperties::getTE(unsigned int theValue) const{
 
 double  BrukerObjectVaryingProperties::getPositionP(unsigned int theValue) const{
    if (theValue < PositionP.size() ) return PositionP[theValue];
-   else throw 1;
+//   else throw 1;
+   else throw BrukerSizeException("PositionP", theValue, PositionP.size() );    
 }
   
 /*void BrukerObjectVaryingProperties::computePositionP(const std::vector< double >& theValue)
@@ -63,7 +65,8 @@ double  BrukerObjectVaryingProperties::getPositionP(unsigned int theValue) const
 
 double  BrukerObjectVaryingProperties::getPositionR(unsigned int theValue) const{
    if (theValue < PositionR.size() ) return PositionR[theValue];
-   else throw 2;
+//   else throw 2;
+   else throw BrukerSizeException("PositionR", theValue, PositionR.size() );
 }
 
 /*void BrukerObjectVaryingProperties::computePositionR(const std::vector< double >& theValue)
@@ -73,7 +76,8 @@ double  BrukerObjectVaryingProperties::getPositionR(unsigned int theValue) const
 
 double  BrukerObjectVaryingProperties::getPositionS(unsigned int theValue) const{
    if (theValue < PositionS.size() )  return PositionS[theValue];
-   else throw 3;
+//   else throw 3;
+   else throw BrukerSizeException("PositionS", theValue, PositionS.size() );
 }
 
 /*void BrukerObjectVaryingProperties::computePositionS(const std::vector< double >& theValue)
@@ -83,7 +87,8 @@ double  BrukerObjectVaryingProperties::getPositionS(unsigned int theValue) const
 
 int  BrukerObjectVaryingProperties::getAcquisitionOrder(unsigned int theValue) const{
    if (theValue <AcquisitionOrder.size())  return AcquisitionOrder[theValue];
-   else throw 4;
+   //else throw 4;
+   else throw BrukerSizeException("AcquisitionOrder", theValue, AcquisitionOrder.size() );
 }
 
 /*void BrukerObjectVaryingProperties::computeAcquisitionOrder(const std::vector< int >& theValue1, const std::vector< int >& theValue2)
@@ -95,17 +100,23 @@ int  BrukerObjectVaryingProperties::getAcquisitionOrder(unsigned int theValue) c
 }*/
 
 void BrukerObjectVaryingProperties::computeAcquisitionOrder(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
-   std::vector<int> AcqOrder;
-  if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) throw 7;
+  std::vector<int> AcqOrder;
+  
+  if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) {
+     std::cout << "BrukerHM[(std::string) 'ACQ_obj_order'].GetIntValue().size() " << BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() 
+               << " LoopStruct[3] : " << LoopStruct[3] << " * LoopStruct[1] : " << LoopStruct[1] << " = " << LoopStruct[3]*LoopStruct[1] << std::endl;  
+     throw 7;
+  }
   if (LoopStruct.size() < 4 ) throw 8;
   for (int i =0 ;i<LoopStruct[3];i++)
      AcqOrder.push_back((int) BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue()[i*LoopStruct[1]]/LoopStruct[1]);
   AcquisitionOrder=AcqOrder;
 };
 
-std :: vector < std :: vector < double > >  BrukerObjectVaryingProperties::getOrientation(unsigned int theValue) const{
+std :: vector < std :: vector < double > >  BrukerObjectVaryingProperties::getOrientation(unsigned int theValue) const {
    if (theValue < Orientation.size())return Orientation[theValue];
-   else throw 9;
+   //else throw 9;
+   else throw BrukerSizeException("Orientation", theValue, Orientation.size() );
 }
 
 /*void BrukerObjectVaryingProperties::computeOrientation( std :: vector < double > & theValue1,const std::vector< int >& theValue2)
@@ -125,8 +136,10 @@ std :: vector < std :: vector < double > >  BrukerObjectVaryingProperties::getOr
 
 void BrukerObjectVaryingProperties::computeOrientation(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
    if (BrukerHM[(std::string) "ACQ_grad_matrix"].GetDoubleValue().size() != LoopStruct[3]*9) throw 12;
-   if (LoopStruct.size() < 4 ) throw 13;
-
+   if (LoopStruct.size() < 4 ) 
+   //throw 13;
+      throw BrukerSizeException("LoopStruct", 4, LoopStruct.size() );
+      
    std::vector<double> Temp1D(3,0.0);
    std::vector<std::vector<double> > Temp2D;
    std::vector<std::vector<std::vector<double> > > Temp3D;
@@ -197,7 +210,7 @@ void BrukerObjectVaryingProperties::computePositionTimePerNR(std::map<std::strin
 /*!
     \fn BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> BrukerHM,std::vector<int> LoopStruct)
  */
-bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct)
+bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> &BrukerHM, std::vector<int> &LoopStruct)
 {
    try {
       computeAcquisitionOrder (BrukerHM, LoopStruct);
@@ -208,7 +221,13 @@ bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData>
       computePositionTimePerNR(BrukerHM, LoopStruct);
       computeTE               (BrukerHM);
    }
-   
+   catch (int i)
+   {
+      std::cout << "Failure during BrukerObjectVaryingProperties::init err code : " << i << std::endl;
+      if (i==7)
+         std::cout << "Probabely non standard acquisition (extra loop not yet dealt with)" << std::endl;
+      return false;   
+   }   
    catch (...)
    {
       std::cout << "Failure during BrukerObjectVaryingProperties::init " << std::endl;