]> Creatis software - creaContours.git/blobdiff - lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx
no message
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / KernelManagerContour.cxx
index 57f9228ee6499549b0e365b5c5903e11b158e520..d189cbd4ce9b691424878f295e7f71fa49714859 100644 (file)
@@ -12,7 +12,7 @@ KernelManagerContour::KernelManagerContour(){
 **
 **/
        inredo = 0;
-       inundo = 0;     
+       inundo = 0;
 
        time_t seconds;
        seconds = time (NULL);
@@ -42,7 +42,7 @@ KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images,std
 **
 **/
        inredo = 0;
-       inundo = 0;     
+       inundo = 0;
 
        time_t seconds;
        seconds = time (NULL);
@@ -51,7 +51,7 @@ KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images,std
 
        stundoredo = tmpdir+"/temp"+intToString(time);
        _currentIndex = 0;
-       
+
        _contourPropagation = NULL;
 #if(WIN32)
        mkdir(tmpdir.c_str());
@@ -69,7 +69,7 @@ KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images,std
 
 }
 KernelManagerContour::~KernelManagerContour(){
-}      
+}
 
 std::vector<vtkImageData*> KernelManagerContour::getVectImages(){
        return vectimages;
@@ -83,7 +83,7 @@ void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg){
                change->SetInputConnection(img->GetProducerPort());
 
                change->SetOutputSpacing(1,1,1);
-               
+
                change->Update();
 
                vectimg[i] = change->GetOutput();
@@ -102,7 +102,7 @@ void KernelManagerContour::initializeEnvironment(std::string datadir){
        std::map<std::string, ImageSourceThing *> * sourcesMap          = new std::map<std::string, ImageSourceThing *>();
        std::map<std::string, ImageSectionThing *>* sectionsMap         = new std::map<std::string, ImageSectionThing *>();
        std::map<std::string, AxeThing *>* axesMap                                      = new std::map<std::string, AxeThing *>();
-       std::map<std::string, ContourThing *>* outlinesMap                      = new std::map<std::string, ContourThing *>();  
+       std::map<std::string, ContourThing *>* outlinesMap                      = new std::map<std::string, ContourThing *>();
 
        for(int i = 0; i < (int)(vectimages.size()); i++){
                vtkImageData* selectedimage = vectimages[i];
@@ -110,11 +110,11 @@ void KernelManagerContour::initializeEnvironment(std::string datadir){
                std::string imgstring = "Source Image "+intToString(i+1);
                sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( imgstring, thing));
        }
-       
+
 
        OutlineModelBuilder * _builder                                                          = new OutlineModelBuilder( conceptsFN ,datadir);
        _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
-       _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );         
+       _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
        _builder->buildAxe_Envornment(axeThingsFN, axesMap );
        _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap );
 
@@ -144,7 +144,7 @@ std::string KernelManagerContour::intToString(int num){
                while (k > 0){
                        char temp = k % 10 + 48;
                        k = k / 10;
-                       result = temp + result; 
+                       result = temp + result;
                }
        }
        return result;
@@ -208,7 +208,9 @@ std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKN
 {
        return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData);
 }
-manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){
+
+manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName)
+{
        return modelManager->getOutlineByKeyName (cloneName )->getModel();
 }
 
@@ -216,16 +218,16 @@ bool KernelManagerContour::onRedo(std::string& filename){
        if(inredo > 0){
                inredo--;
                inundo++;
-               std::string str = intToString(inundo);        
-               filename = stundoredo + str + ".roi";   
-               //loadState(temp);              
+               std::string str = intToString(inundo);
+               filename = stundoredo + str + ".roi";
+               //loadState(temp);
                return true;
        }
        return false;
 }
 
 bool KernelManagerContour::onUndo(std::string& filename){
-       if(inundo>0){           
+       if(inundo>0){
                inredo++;
                inundo--;
 
@@ -233,9 +235,9 @@ bool KernelManagerContour::onUndo(std::string& filename){
                //itoa(inundo, str, 10);
                std::string str = intToString(inundo);
 
-        
+
                filename = stundoredo + str + ".roi";
-       
+
                return true;//loadState(temp);
        }
        return false;
@@ -259,7 +261,7 @@ bool KernelManagerContour::onUndoSaveFile(std::string& filename){
 
                        filename = stundoredo + str + ".roi";
                        return true;
-                       //saveFileWithContours(temp);                           
+                       //saveFileWithContours(temp);
 
                }
        }
@@ -271,53 +273,55 @@ void KernelManagerContour :: changeContourOfManager(std::string keyName, Instant
        modelManager->ChangeContourOfList(keyName, instant);
 }
 
-void KernelManagerContour ::resetAppend(){
-       if(isInitContourPropagation()){
+void KernelManagerContour ::resetAppend()
+{
+    if (_contourPropagation!=NULL)
+       {
                _contourPropagation->resetAppend();
-       }       
-}
-
-bool KernelManagerContour::isInitContourPropagation(){
-       if(_contourPropagation == NULL){
-               _contourPropagation = new ContourPropagation();
-       }else{
-               return true;
        }
-       return false;
-
 }
 
-std::string KernelManagerContour::onSpreadAdd( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants){
-       if(isInitContourPropagation()){
-               if (vecX->size()!=0){
-                       
-                       int i,size=vecZ->size();
-                       int actualSlice = instants[1];
-                       for ( i=0 ; i<size ; i++ )
-                       {
-                               (*vecZ)[i] = actualSlice;
-                       } // for
 
-                       _contourPropagation->appendContour(vecX , vecY , vecZ);
-                       return intToString(actualSlice);                
-               }
-       }
+std::string KernelManagerContour::onSpreadAdd( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants)
+{
+    if (_contourPropagation==NULL)
+    {
+               _contourPropagation = new ContourPropagation();
+    }
+
+    if (vecX->size()!=0){
+
+        int i,size=vecZ->size();
+        int actualSlice = instants[1];
+        for ( i=0 ; i<size ; i++ )
+        {
+            (*vecZ)[i] = actualSlice;
+        } // for
+
+        _contourPropagation->appendContour(vecX , vecY , vecZ);
+        return intToString(actualSlice);
+    }
        return "";
 }
 
-void KernelManagerContour::getMaxMinZ(double *minZ,double *maxZ){
-       if(isInitContourPropagation()){
+
+void KernelManagerContour::getMaxMinZ(double *minZ,double *maxZ)
+{
+    if (_contourPropagation!=NULL)
+       {
                _contourPropagation->getMaxMinZ(minZ, maxZ);
        }
 }
-void KernelManagerContour::CalculeSplinePropagation(){
+
+
+void KernelManagerContour::CalculeSplinePropagation()
+{
        _contourPropagation->setInterpolationNumber(100);
        _contourPropagation->CalculeSplinePropagation();
 }
 
-manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector){
-    
-       
+manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector)
+{
        bool addedModel = false;
        manualBaseModel* manModelContour=NULL;
 
@@ -328,9 +332,9 @@ manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector<dou
                int idTmp = _contourPropagation->FindIdWithZ(z);
 
                if (type==0) // Initial Points
-               {   
+               {
                        _contourPropagation->GetInitialControlPoints( idTmp , vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ);
-               } 
+               }
                if (type==1)  // Automatique Method
                {
                        _contourPropagation->GetControlPoints( idTmp  ,vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ);
@@ -354,13 +358,13 @@ manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector<dou
                if(!addedModel){
                        manModelContour = NULL;
                }
-               
+
        }// ifSliceKeyContourExist
        return manModelContour;
 }
 
 manualBaseModel * KernelManagerContour::factoryManualContourModel(int typeContour)
-{      
+{
        manualBaseModel *manModelContour=NULL;
 
        // Creating the model
@@ -395,7 +399,7 @@ manualBaseModel * KernelManagerContour::factoryManualContourModel(int typeContou
        {
                manModelContour = new manualContourModelLine();
        }
-       
+
        // points
        if (typeContour==7)
        {
@@ -419,7 +423,7 @@ std::vector<std::string> KernelManagerContour::getOutlinesNameAtInstant(std::vec
                ContourThing **contourthing = vectcont[i];
                vectname.push_back((*contourthing)->getName());
        }
-    return vectname;   
+    return vectname;
 }
 
 std::vector<ContourThing**> KernelManagerContour::getOutlinesAtInstant(Instant* instant ){
@@ -467,7 +471,7 @@ void KernelManagerContour::setCurrentFileName(std::string filenam){
 }
 
 std::string KernelManagerContour::parseOsirixFile(std::string filename){
-       
+
 
 #ifdef ParserOsirix_BUILD
        vtkImageData* sourceimage;
@@ -487,7 +491,7 @@ std::string KernelManagerContour::parseOsirixFile(std::string filename){
        return p.getContoursFileName();
 #else
        return "";
-#endif 
+#endif
 
 
 }