]> Creatis software - creaContours.git/blobdiff - lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx
no message
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / OutlineModelManager.cxx
index 6b2e68b25495332d6d6e275389abe33c2432d2aa..9dbb1dbf9d80a13bd8f35373c1f829dbd666ff0b 100644 (file)
                outlinesEnvironment                     = contourEnv;
 
                workSpace                                       = new ContourWorkspace(this);//implies a shared workSpace
-               keyGenerator                            = * new PrefixMaxKeyGenerator();        
+               keyGenerator                            = * new PrefixMaxKeyGenerator();
                counterIdKey                            = 0;
 
                actualInstantWrapping           = new InstantMembersNameList();
-               changeSourceImage                       = true; 
+               changeSourceImage                       = true;
 
                bool allOK      = keyGenerator.addKeyThing("Axes", "Axe");
                allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
                clean();
                delete actualInstant;
                delete workSpace;
-               delete actualInstantWrapping;           
+               delete actualInstantWrapping;
        }
 
 //------------------------------------------------------------------------------------------------------------
-// Methods 
+// Methods
 //------------------------------------------------------------------------------------------------------------
 
 
@@ -65,7 +65,7 @@
 
        /*
        * Sets the workSpace object
-       * @param  aWorkSpace The workSpace to set 
+       * @param  aWorkSpace The workSpace to set
        */
        void OutlineModelManager :: setWorkSpace( ContourWorkspace * aWorkSpace )
        {
        {
                bool executedComs = executionQueue.size()>0 ? true : false;
                while( executionQueue.size()>0 )
-               {                       
+               {
                        CommandObject * aCmmand = executionQueue.front();
                        executedComs &= executeCommand(aCmmand, fromRegistration);
                        executionQueue.pop_front();
                return executedComs;
        }
 
-       
+
        /*
-       * Sets the concepts of the environments and includes the concepts managed by the program 
+       * Sets the concepts of the environments and includes the concepts managed by the program
        * @conceptsScript Is the script for with the concepts descrition
        * @return Returns true if successful insert of the given concepts, false otherwise
        */
                int endSub;
                std::string::size_type equalIndex = conceptsScript.find("=", 0);
                std::string::size_type nextIndex = 0;
-               while( equalIndex != std::string::npos && allOK) 
-               {       
+               while( equalIndex != std::string::npos && allOK)
+               {
             endSub = equalIndex;
-                       std::string concept = conceptsScript.substr( 0, endSub ); 
-                       conceptsScript.erase( 0, endSub+1 ); 
-                       std::cout << "C: " << concept <<std::endl;                      
+                       std::string concept = conceptsScript.substr( 0, endSub );
+                       conceptsScript.erase( 0, endSub+1 );
+                       std::cout << "C: " << concept <<std::endl;
                        nextIndex = conceptsScript.find(";", 0);
                        std::string cSize;
                        if(nextIndex != std::string::npos)
                        {
                                endSub = nextIndex;
-                               cSize = conceptsScript.substr( 0, endSub ); 
-                               conceptsScript.erase( 0, endSub+1 ); 
+                               cSize = conceptsScript.substr( 0, endSub );
+                               conceptsScript.erase( 0, endSub+1 );
                        }
                        else
                        {
-                               endSub = conceptsScript.size();         
-                               cSize = conceptsScript.substr( 0, endSub ); 
-                               conceptsScript.erase( 0, endSub ); 
-                       }                       
-                       int intReturn = atoi(cSize.c_str());                    
-                       std::cout << "SZ: "<<intReturn <<std::endl;     
-                       equalIndex = conceptsScript.find("=", 0);       
+                               endSub = conceptsScript.size();
+                               cSize = conceptsScript.substr( 0, endSub );
+                               conceptsScript.erase( 0, endSub );
+                       }
+                       int intReturn = atoi(cSize.c_str());
+                       std::cout << "SZ: "<<intReturn <<std::endl;
+                       equalIndex = conceptsScript.find("=", 0);
                        if( intReturn>0 )
                                allOK &= addUserConcept(concept, intReturn);
                        else
                                allOK = false;
-               }               
+               }
                return allOK;
        }
 
        /*
-       * Add a concept to all the environments 
+       * Add a concept to all the environments
        * @param theConceptName Is the name of the new concept
-       * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances 
+       * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances
        * @return Returns true if successful insert of concept, false otherwise
-       */              
+       */
        bool OutlineModelManager :: addUserConcept(std::string theConceptName, int conceptSize)
-       {       
+       {
                bool allOK = axesEnvironment->addConcept(theConceptName, conceptSize);
                allOK &= imagesSectionEnvironment->addConcept(theConceptName, conceptSize);
                allOK &= imageSourceEnvironment->addConcept(theConceptName, conceptSize);
                        this->outlinesEnvironment->removeThingFromInstant(keyName, instant);
                } else {
                        ContourThing **contourthing  = staticContourLst[ispartofstaticlist];
-                       this->outlinesEnvironment->addInstantToThing    ( keyName , instant );                  
+                       this->outlinesEnvironment->addInstantToThing    ( keyName , instant );
                        staticContourLst.erase( staticContourLst.begin()+ispartofstaticlist );
                }
        }
                std::vector<std::string> kNamesVector;
                std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
                std::vector<Instant *> lstInstants = getOutlineInstants();
-               int i,sizeLstInstants = lstInstants.size(); 
+               int i,sizeLstInstants = lstInstants.size();
                Instant *instant;
                for ( i=0 ; i<sizeLstInstants ; i++ )
                {
        * Gets the outlines at a specific form the outline's environment
        * @param aGroupName The name of the group containing the outlines names to get
        * @return The vector to the outlines at the given group
-       */ 
+       */
        std::vector<ContourThing*> OutlineModelManager :: getOutlinesFromGroup(std::string aGroupName)
        {
                std::vector<ContourThing *> outlinesVector;
                std::map< std::string,OutlineGroup * >::iterator iterP = outlineGroups.find(aGroupName);
                if ( iterP != outlineGroups.end() )
-               {       
-                       std::vector<std::string> kNamesVector = iterP->second->getGroupOutlinesNames(); 
+               {
+                       std::vector<std::string> kNamesVector = iterP->second->getGroupOutlinesNames();
                        for(int i=0; i<kNamesVector.size();i++)
                        {
                                ContourThing * outlineI = getOutlineByKeyName(kNamesVector[i]);
                                outlinesVector.push_back(outlineI);
-                       }                       
+                       }
                }
                return outlinesVector;
        }
        * Gets the outlines at a specific form the outline's environment
        * @param aGroupName The name of the group containing the outlines names to get
        * @return The vector to the outlineGroups at the given group
-       */ 
+       */
        bool OutlineModelManager :: addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup )
        {
-        outlineGroups.insert(std::pair <std::string, OutlineGroup *> ( theOutlineName, theGroup ));                            
+        outlineGroups.insert(std::pair <std::string, OutlineGroup *> ( theOutlineName, theGroup ));
 //             std::map<std::string, OutlineGroup *> :: iterator iter = NULL;
                std::map<std::string, OutlineGroup *> :: iterator iter;
                iter = outlineGroups.find( theOutlineName );
        std::string  OutlineModelManager :: createOutline(manualBaseModel * model, std::vector<int> theInstantData, std::string aName)
        {
                ContourThing * theOutline = new ContourThing ( model );
-               theOutline->setName(aName);             
-               return addOutline( theOutline, new Instant( &theInstantData ) );                                
+               theOutline->setName(aName);
+               return addOutline( theOutline, new Instant( &theInstantData ) );
        }
 
        /*
        bool  OutlineModelManager :: createAxe(std::string aDescription, Instant * theInstantData)
        {
                AxeThing * theAxe = new AxeThing ();
-               theAxe->setDescription(aDescription);                 
-               return addAxe(theAxe, theInstantData);          
+               theAxe->setDescription(aDescription);
+               return addAxe(theAxe, theInstantData);
        }
 
        /*
        //bool OutlineModelManager :: createImageSource(std::string aSource, ImageSourceThing * &imageSource)
        bool OutlineModelManager :: createImageSource(std::string aSource, Instant * theInstantData)
        {
-//             imageSource = new ImageSourceThing(aSource);                
-               //return addImageSource(new ImageSourceThing(aSource), theInstantData);         
+//             imageSource = new ImageSourceThing(aSource);
+               //return addImageSource(new ImageSourceThing(aSource), theInstantData);
                return NULL;//***********************************************************************************************
        }
 
        //bool OutlineModelManager :: createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection)
        bool OutlineModelManager :: createImageSection(std::string aSecImageData, Instant * theInstantData)
        {
-               //imageSection = new ImageSectionThing(aSecImageData);               
-//             return addImageSection(new ImageSectionThing(aSecImageData), theInstantData);   
+               //imageSection = new ImageSectionThing(aSecImageData);
+//             return addImageSection(new ImageSectionThing(aSecImageData), theInstantData);
                return NULL;
        }
 
        /*
-       * Adds an outlineThing 
+       * Adds an outlineThing
        * @param theOutline The outline/contour (thing)
        * @param theInstantData Is the instant for the outline to add
        * @return Returns true if the addition of the outline was successful
        */
        std::string OutlineModelManager :: addOutline( ContourThing * theOutline, Instant * theInstantData)
-       {               
+       {
                std::string kName;
 
-// EED 
+// EED
 //             bool added  = keyGenerator.generateKeyOf("Outlines", outlinesEnvironment->getNumberOfThings(),kName);
 
                counterIdKey++;
                if( added )
                        return kName;
                else
-                       return "";              
+                       return "";
        }
 
 
 
 
        /*
-       * Remove an outlineThing 
+       * Remove an outlineThing
        * @param theOutline The outline/contour (thing)
        */
        void OutlineModelManager :: removeOutline( std::string ss )
-       {               
+       {
                        outlinesEnvironment->removeThing( ss );
        }
 
                std::vector< ContourThing **>  thingsVector;
                outlinesEnvironment->getThingsOfEnvironment( &thingsVector );
                int i,sizeThingVector = thingsVector.size();
-               for(i=0;i<sizeThingVector;i++) 
+               for(i=0;i<sizeThingVector;i++)
                {
                        ContourThing ** contourthing =  thingsVector[i];
                    removeOutline(  (*contourthing)->getName()   );
 
 
        /*
-       * Adds an axeThing 
+       * Adds an axeThing
        * @param thaAxe The axe (thing)
        * @param theInstantData Is the instant for the axe to add
        * @return Returns true if the addition of the axe was successful
        bool OutlineModelManager :: addAxe( AxeThing * theAxe , Instant * theInstantData)
        {
                std::string kName;
-               bool added  = keyGenerator.generateKeyOf("Axes", axesEnvironment->getNumberOfThings(),kName);           
+               bool added  = keyGenerator.generateKeyOf("Axes", axesEnvironment->getNumberOfThings(),kName);
                added &= axesEnvironment->addThingWithInstant(kName,theAxe, theInstantData);
                return added;
        }
 
        /*
-       * Adds an imageSourceThing 
+       * Adds an imageSourceThing
        * @param imgageSource The image source (thing)
        * @param theInstantData Is the instant for the source to add
        * @return Returns true if the addition of the imageSource was successful
        * @return Returns true if the addition of the imageSection was successful
        */
        bool OutlineModelManager :: addImageSection(ImageSectionThing * imageSection, Instant * theInstantData)
-       {               
+       {
                std::string kName;
                bool added  = keyGenerator.generateKeyOf("Image Sections", imagesSectionEnvironment->getNumberOfThings(),kName);
                added &= imagesSectionEnvironment->addThingWithInstant(kName, imageSection, theInstantData);
                        actualInstantWrapping -> addOutlineName( kNamesVector[i], anOutline->getName() );
                }
        }
-       
+
        /*
        * Annotates the actual outline keyName-real name wrapping at the actual instant
        * @param actualKeyOutline The key name to annotate
        void OutlineModelManager :: annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
        {
                actualInstantWrapping -> setActualSectionImageNamesWrapp(actualKeyImage, theRealName);
-       } 
+       }
 
        /*
        * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
        * @param actualKeyImage The key name to annotate
-       * @param theRealName The real name asigned to the annotateActualSource 
+       * @param theRealName The real name asigned to the annotateActualSource
        */
        void OutlineModelManager :: annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
        {
                actualInstantWrapping -> setActualSourceImageNamesWrapp(actualKeyImage, theRealName);
-       } 
+       }
 
 
        /*
        /*
        * Gets the instants of a specific outline
        * @param thekName Is the name of the outline
-       * @return The instants set 
+       * @return The instants set
        */
        std::vector<Instant *> OutlineModelManager :: getOutlineInstantsByName(std::string thekName)
-       {               
-               return *outlinesEnvironment->getInstantsOfThing(thekName);              
+       {
+               return *outlinesEnvironment->getInstantsOfThing(thekName);
        }
 
        /*
        * Gets all instants outlines
-       * @return The instants set 
+       * @return The instants set
        */
        std::vector<Instant *> OutlineModelManager :: getOutlineInstants()
-       {               
-               return *outlinesEnvironment->getExistingInstants();             
+       {
+               return *outlinesEnvironment->getExistingInstants();
        }
 
 
        {
                return imageSourceEnvironment->addInstantToThing( imaKName,anInstantData );
        }
-       
+
        /*
        *       Method that retorns the name of each concept and the size of it.
        *       @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
                {
                        //if (outlinesEnvironment->getNumberOfThings()>0)
                                outlinesEnvironment->getConceptsInformation(conceptNameVect, conceptSizeVect);
-               }       
+               }
        }
 
 
        /*
-       * Gets the contourWorspace 
+       * Gets the contourWorspace
        * @return Returns the workspace
        */
        ContourWorkspace * OutlineModelManager :: getContourWorkspace()
        * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
        */
        void OutlineModelManager :: updateToActualInstant()
-       {               
+       {
                Instant * longInstant = actualInstant;
                /*Instant * mediumInstant = new Instant();
-               Instant * shortInstant = new Instant();         
+               Instant * shortInstant = new Instant();
                std::vector<int>* theInstant = longInstant->getInstant();
                for(int i=1; i<theInstant->size(); i++)
                {
                                shortInstant->addConcept( (*theInstant)[i] );
                        mediumInstant->addConcept( (*theInstant)[i] );
                }
-               
+
                //getting the sourceAtInstant
                std::vector<std::string> kSourceVector;
                std::vector<ImageSourceThing **> imSourceVector;
                imageSourceEnvironment->getThings(kSourceVector, imSourceVector, shortInstant);
                annotateActualSourceImageWrap(kSourceVector[0], (**imSourceVector[0]).getSourceImage());
 
-        //getting the aAxeAtInstant 
+        //getting the aAxeAtInstant
                std::vector<std::string> kAxeVector;
                std::vector<AxeThing **> axesVector;
                axesEnvironment->getThings(kAxeVector, axesVector, mediumInstant);
                imagesSectionEnvironment->getThings(kSectionVector, imSectionVector, longInstant); if ( !kSectionVector.empty() )
            //annotateActualSectionImageWrap(kSectionVector[0], (**imSectionVector[0]).getImageData());
                */
-               
-               //getting the outlines          
+
+               //getting the outlines
 
                std::vector<ContourThing ** > vect = getOutlinesAtInstant( longInstant );
 
        }
-       
+
        /*
-       * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.   
+       * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.
        * @return Returns true if successful insert of the automatic concepts, false otherwise
        */
        bool OutlineModelManager :: setAutomaticConcepts()
                bool allOK = axesEnvironment->addConcept(axeConcept, axeC_size);
                allOK &= imagesSectionEnvironment->addConcept(axeConcept, axeC_size);
                allOK &= outlinesEnvironment->addConcept(axeConcept, axeC_size);
-               
+
                allOK &= imagesSectionEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
                allOK &= outlinesEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
 /*
        void OutlineModelManager::SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing )
        {
                std::vector< Instant * > *lstInstants;
-printf("EED OutlineModelManager::SaveThingName %s\n",nameThing.c_str() );
                lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing );
-printf("EED OutlineModelManager::SaveThingName %d\n", (*lstInstants).size() );
                Instant *instant = (*lstInstants)[0];
                std::vector<int> *vecInst =instant->getInstant();
                int i,sizeVecInst = vecInst->size();