X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fkernel_ManagerContour_NDimensions%2FOutlineModelManager.cxx;h=b1c4f4b67c5bdfb4b8bcc51993d38fb344bf2cf4;hb=6c905248260709012e018c112dab06da8deecede;hp=44d91fa5f592521c68c2fb1dc8d76f5aed628ece;hpb=6e3c929c883c405e0075fa8df10b12a935979367;p=creaContours.git diff --git a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx index 44d91fa..b1c4f4b 100644 --- a/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx +++ b/lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx @@ -1,3 +1,28 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + //---------------------------------------------------------------------------------------------------------------- // Class definition include @@ -24,11 +49,11 @@ 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"); @@ -45,11 +70,11 @@ clean(); delete actualInstant; delete workSpace; - delete actualInstantWrapping; + delete actualInstantWrapping; } //------------------------------------------------------------------------------------------------------------ -// Methods +// Methods //------------------------------------------------------------------------------------------------------------ @@ -65,7 +90,7 @@ /* * Sets the workSpace object - * @param aWorkSpace The workSpace to set + * @param aWorkSpace The workSpace to set */ void OutlineModelManager :: setWorkSpace( ContourWorkspace * aWorkSpace ) { @@ -78,6 +103,7 @@ * @param theCommand Is the command to execute * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false. */ + bool OutlineModelManager :: executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration) { ContourThing * theOutline = *outlinesEnvironment->getThingByName( outKName ); @@ -116,7 +142,7 @@ { bool executedComs = executionQueue.size()>0 ? true : false; while( executionQueue.size()>0 ) - { + { CommandObject * aCmmand = executionQueue.front(); executedComs &= executeCommand(aCmmand, fromRegistration); executionQueue.pop_front(); @@ -124,9 +150,9 @@ 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 */ @@ -136,45 +162,45 @@ 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 <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); @@ -203,7 +229,7 @@ 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 ); } } @@ -255,7 +281,7 @@ std::vector kNamesVector; std::vector outlinesVector; //= new std::vector(); std::vector lstInstants = getOutlineInstants(); - int i,sizeLstInstants = lstInstants.size(); + int i,sizeLstInstants = lstInstants.size(); Instant *instant; for ( i=0 ; i OutlineModelManager :: getOutlinesFromGroup(std::string aGroupName) { std::vector outlinesVector; std::map< std::string,OutlineGroup * >::iterator iterP = outlineGroups.find(aGroupName); if ( iterP != outlineGroups.end() ) - { - std::vector kNamesVector = iterP->second->getGroupOutlinesNames(); + { + std::vector kNamesVector = iterP->second->getGroupOutlinesNames(); for(int i=0; i ( theOutlineName, theGroup )); + outlineGroups.insert(std::pair ( theOutlineName, theGroup )); // std::map :: iterator iter = NULL; std::map :: iterator iter; iter = outlineGroups.find( theOutlineName ); @@ -337,11 +363,11 @@ * @return Returns the key name of the created outline, or ""if it wasn't created */ // bool OutlineModelManager :: createOutline(std::string aName, ContourThing * &theOutline) - std::string OutlineModelManager :: createOutline(manualContourModel * model, std::vector theInstantData, std::string aName) + std::string OutlineModelManager :: createOutline(manualBaseModel * model, std::vector 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 ) ); } /* @@ -353,8 +379,8 @@ 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); } /* @@ -365,8 +391,8 @@ //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;//*********************************************************************************************** } @@ -378,22 +404,22 @@ //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++; @@ -407,7 +433,7 @@ if( added ) return kName; else - return ""; + return ""; } @@ -428,11 +454,11 @@ /* - * Remove an outlineThing + * Remove an outlineThing * @param theOutline The outline/contour (thing) */ void OutlineModelManager :: removeOutline( std::string ss ) - { + { outlinesEnvironment->removeThing( ss ); } @@ -446,7 +472,7 @@ std::vector< ContourThing **> thingsVector; outlinesEnvironment->getThingsOfEnvironment( &thingsVector ); int i,sizeThingVector = thingsVector.size(); - for(i=0;igetName() ); @@ -455,7 +481,7 @@ /* - * 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 @@ -463,13 +489,13 @@ 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 @@ -489,7 +515,7 @@ * @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); @@ -520,7 +546,7 @@ 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 @@ -549,17 +575,17 @@ 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); - } + } /* @@ -590,20 +616,20 @@ /* * 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 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 OutlineModelManager :: getOutlineInstants() - { - return *outlinesEnvironment->getExistingInstants(); + { + return *outlinesEnvironment->getExistingInstants(); } @@ -651,7 +677,7 @@ { 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 @@ -663,12 +689,12 @@ { //if (outlinesEnvironment->getNumberOfThings()>0) outlinesEnvironment->getConceptsInformation(conceptNameVect, conceptSizeVect); - } + } } /* - * Gets the contourWorspace + * Gets the contourWorspace * @return Returns the workspace */ ContourWorkspace * OutlineModelManager :: getContourWorkspace() @@ -696,10 +722,10 @@ * 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* theInstant = longInstant->getInstant(); for(int i=1; isize(); i++) { @@ -707,14 +733,14 @@ shortInstant->addConcept( (*theInstant)[i] ); mediumInstant->addConcept( (*theInstant)[i] ); } - + //getting the sourceAtInstant std::vector kSourceVector; std::vector imSourceVector; imageSourceEnvironment->getThings(kSourceVector, imSourceVector, shortInstant); annotateActualSourceImageWrap(kSourceVector[0], (**imSourceVector[0]).getSourceImage()); - //getting the aAxeAtInstant + //getting the aAxeAtInstant std::vector kAxeVector; std::vector axesVector; axesEnvironment->getThings(kAxeVector, axesVector, mediumInstant); @@ -727,15 +753,15 @@ imagesSectionEnvironment->getThings(kSectionVector, imSectionVector, longInstant); if ( !kSectionVector.empty() ) //annotateActualSectionImageWrap(kSectionVector[0], (**imSectionVector[0]).getImageData()); */ - - //getting the outlines + + //getting the outlines std::vector 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() @@ -748,7 +774,7 @@ 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); /* @@ -763,11 +789,11 @@ std::string OutlineModelManager :: createCopyContourOf( std::string anExistingKName, std::vector &instantNoTouchData ) { - manualContourModel * manModelContour = getOutlineByKeyName( anExistingKName )->getModel()->Clone(); + manualBaseModel * manModelContour = getOutlineByKeyName( anExistingKName )->getModel()->Clone(); return createOutline( manModelContour, instantNoTouchData ); } - void OutlineModelManager::SaveThingName( FILE *pFile, std::string nameThing ) + void OutlineModelManager::SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing ) { std::vector< Instant * > *lstInstants; lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing ); @@ -782,5 +808,6 @@ fprintf(pFile,"\n"); ContourThing *contourthing = *outlinesEnvironment->getThingByName(nameThing); contourthing->getModel()->Save(pFile); + contourthing->getModel()->SaveData(pFileData); }