]> Creatis software - creaContours.git/blob - lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx
89d0b6da6df88b33a53f905c56a10cce3ac0759b
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / OutlineModelManager.cxx
1
2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "OutlineModelManager.h"
6
7 //----------------------------------------------------------------------------------------------------------------
8 // Class implementation
9 //----------------------------------------------------------------------------------------------------------------
10 /** @file OutlineModelManager.cxx */
11
12 //------------------------------------------------------------------------------------------------------------
13 // Constructors & Destructors
14 //------------------------------------------------------------------------------------------------------------
15 /*
16         * Creates the outline manager
17         */
18         OutlineModelManager :: OutlineModelManager( SomeEnvironment<ImageSourceThing *> *imSourceEnv, SomeEnvironment<ImageSectionThing *> *imSectionEnv, SomeEnvironment<AxeThing *> *axesEnv, SomeEnvironment<ContourThing *> *contourEnv )
19         {
20                 actualInstant                           = NULL;
21                 imageSourceEnvironment          = imSourceEnv;
22                 imagesSectionEnvironment        = imSectionEnv;
23                 axesEnvironment                         = axesEnv;
24                 outlinesEnvironment                     = contourEnv;
25
26                 workSpace                                       = new ContourWorkspace(this);//implies a shared workSpace
27                 keyGenerator                            = * new PrefixMaxKeyGenerator();        
28                 counterIdKey                            = 0;
29
30                 actualInstantWrapping           = new InstantMembersNameList();
31                 changeSourceImage                       = true; 
32
33                 bool allOK      = keyGenerator.addKeyThing("Axes", "Axe");
34                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
35                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
36                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");
37                 //setAutomaticConcepts();
38         }
39
40         /*
41         * Destroys the outline manager
42         */
43         OutlineModelManager :: ~OutlineModelManager()
44         {
45                 clean();
46                 delete actualInstant;
47                 delete workSpace;
48                 delete actualInstantWrapping;           
49         }
50
51 //------------------------------------------------------------------------------------------------------------
52 // Methods 
53 //------------------------------------------------------------------------------------------------------------
54
55
56         /*
57         * Creates and sets a workSpace object
58         * @return Retourns the created workSpace
59         */
60         ContourWorkspace * OutlineModelManager :: createWorkSpace()
61         {
62                 workSpace = new ContourWorkspace(this);
63                 return workSpace;
64         }
65
66         /*
67         * Sets the workSpace object
68         * @param  aWorkSpace The workSpace to set 
69         */
70         void OutlineModelManager :: setWorkSpace( ContourWorkspace * aWorkSpace )
71         {
72                 workSpace = aWorkSpace;
73         }
74
75         /*
76         * Executes a command over an outline object
77         * @param imaKName Is the key name of the outline
78         * @param theCommand Is the command to execute
79         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
80         */
81
82         bool OutlineModelManager :: executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration)
83         {
84                 ContourThing * theOutline = *outlinesEnvironment->getThingByName( outKName );
85                 if(!fromRegistration)
86                 {
87                         CommandObject * undoCommand = theOutline->getUndoCommandOf( theCommand );
88                         workSpace->callRegisterCommand(theCommand, undoCommand);
89                 }
90                 return theOutline->executeCommand( theCommand );
91         }
92
93         /*
94         * Executes a command identifying which actions have to realize before executing it.
95         * @param theCommand Is the command to execute
96         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
97         */
98         bool OutlineModelManager :: executeCommand(CommandObject * theCommand, bool fromRegistration)
99         {
100                 bool executedCom = true;
101                 //TODO**********************************************************************************************************************************************
102                 //Interpreting who is the one that executes the command
103
104                 //Modifiying the command in necessary for detaching interpreted information
105
106                 //If is an outline, sending the command to execute the specific command
107
108                 return executedCom;
109         }
110
111         /*
112         * Executes a command queue identifying which actions have to realize before executing it, using FIFO for each.
113         * @param executionQueue Is the command queue to execute
114         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
115         */
116         bool OutlineModelManager ::  executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration)
117         {
118                 bool executedComs = executionQueue.size()>0 ? true : false;
119                 while( executionQueue.size()>0 )
120                 {                       
121                         CommandObject * aCmmand = executionQueue.front();
122                         executedComs &= executeCommand(aCmmand, fromRegistration);
123                         executionQueue.pop_front();
124                 }
125                 return executedComs;
126         }
127
128         
129         /*
130         * Sets the concepts of the environments and includes the concepts managed by the program 
131         * @conceptsScript Is the script for with the concepts descrition
132         * @return Returns true if successful insert of the given concepts, false otherwise
133         */
134         bool OutlineModelManager :: setUserConcepts(std::string conceptsScript)
135         {
136                 bool allOK = true;
137                 int endSub;
138                 std::string::size_type equalIndex = conceptsScript.find("=", 0);
139                 std::string::size_type nextIndex = 0;
140                 while( equalIndex != std::string::npos && allOK) 
141                 {       
142             endSub = equalIndex;
143                         std::string concept = conceptsScript.substr( 0, endSub ); 
144                         conceptsScript.erase( 0, endSub+1 ); 
145                         std::cout << "C: " << concept <<std::endl;                      
146                         nextIndex = conceptsScript.find(";", 0);
147                         std::string cSize;
148                         if(nextIndex != std::string::npos)
149                         {
150                                 endSub = nextIndex;
151                                 cSize = conceptsScript.substr( 0, endSub ); 
152                                 conceptsScript.erase( 0, endSub+1 ); 
153                         }
154                         else
155                         {
156                                 endSub = conceptsScript.size();         
157                                 cSize = conceptsScript.substr( 0, endSub ); 
158                                 conceptsScript.erase( 0, endSub ); 
159                         }                       
160                         int intReturn = atoi(cSize.c_str());                    
161                         std::cout << "SZ: "<<intReturn <<std::endl;     
162                         equalIndex = conceptsScript.find("=", 0);       
163                         if( intReturn>0 )
164                                 allOK &= addUserConcept(concept, intReturn);
165                         else
166                                 allOK = false;
167                 }               
168                 return allOK;
169         }
170
171         /*
172         * Add a concept to all the environments 
173         * @param theConceptName Is the name of the new concept
174         * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances 
175         * @return Returns true if successful insert of concept, false otherwise
176         */              
177         bool OutlineModelManager :: addUserConcept(std::string theConceptName, int conceptSize)
178         {       
179                 bool allOK = axesEnvironment->addConcept(theConceptName, conceptSize);
180                 allOK &= imagesSectionEnvironment->addConcept(theConceptName, conceptSize);
181                 allOK &= imageSourceEnvironment->addConcept(theConceptName, conceptSize);
182                 allOK &= outlinesEnvironment->addConcept(theConceptName, conceptSize);
183                 return allOK;
184         }
185
186         /**
187         * Gets the outlines at an instant form the outline's environment
188         * @param anInstant The instant wondered to get outlines at
189         * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
190         * @return The vector to the outlines at the given instance
191         */
192         std::vector<NameWrapper *> OutlineModelManager :: getActualInstantOutlines ()
193         {
194                 return actualInstantWrapping->getOutlinesNamesVector();
195         }
196
197 //EED01
198         void OutlineModelManager :: ChangeContourOfList(std::string keyName, Instant *instant)
199         {
200                 int ispartofstaticlist = IsPartOfStaticList(keyName);
201                 if (ispartofstaticlist==-1)
202                 {
203                         staticContourLst.push_back(  this->outlinesEnvironment->getThingByName(keyName)  );
204                         this->outlinesEnvironment->removeThingFromInstant(keyName, instant);
205                 } else {
206                         ContourThing **contourthing  = staticContourLst[ispartofstaticlist];
207                         this->outlinesEnvironment->addInstantToThing    ( keyName , instant );                  
208                         staticContourLst.erase( staticContourLst.begin()+ispartofstaticlist );
209                 }
210         }
211
212
213         /**
214         * Gets the outlines at an instant form the outline's environment
215         * @param anInstant The instant wondered to get outlines at
216         * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
217         * @return The vector to the outlines at the given instance
218         */
219         std::vector<ContourThing**>  OutlineModelManager :: getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate)
220         {
221                 std::vector<std::string> kNamesVector;
222                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
223                 outlinesEnvironment->getThings( kNamesVector, outlinesVector, anInstant);
224
225 //EED01
226                 int i,sizeStaticContourLst =  staticContourLst.size();
227                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
228                 {
229                         ContourThing **contourthing  = staticContourLst[i];
230                         outlinesVector.push_back( contourthing );
231                         kNamesVector.push_back( (*contourthing)->getName() );
232                 }// for i
233
234                 if (ifAnnotate)
235                 {
236                         annotateOutlinesWrap(kNamesVector, outlinesVector);
237                 }
238                 return outlinesVector;
239         }
240
241 //EED01
242         std::vector<std::string> OutlineModelManager :: GetLstNameThingsStatic()
243         {
244                 std::vector<std::string> result;
245                 int i,sizeStaticContourLst =  staticContourLst.size();
246                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
247                 {
248                         ContourThing **contourthing  = staticContourLst[i];
249                         result.push_back( (*contourthing)->getName() );
250                 }// for i
251                 return result;
252         }
253
254         std::vector<std::string> OutlineModelManager :: GetLstNameThings()
255         {
256                 std::vector<std::string> kNamesVector;
257                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
258                 std::vector<Instant *> lstInstants = getOutlineInstants();
259                 int i,sizeLstInstants = lstInstants.size(); 
260                 Instant *instant;
261                 for ( i=0 ; i<sizeLstInstants ; i++ )
262                 {
263                         instant = lstInstants[i];
264                         outlinesEnvironment->getThings( kNamesVector, outlinesVector, instant);
265                 } // for i
266                 return kNamesVector;
267         }
268
269
270         /**
271         * Gets the outlines at a specific form the outline's environment
272         * @param aGroupName The name of the group containing the outlines names to get
273         * @return The vector to the outlines at the given group
274         */ 
275         std::vector<ContourThing*> OutlineModelManager :: getOutlinesFromGroup(std::string aGroupName)
276         {
277                 std::vector<ContourThing *> outlinesVector;
278                 std::map< std::string,OutlineGroup * >::iterator iterP = outlineGroups.find(aGroupName);
279                 if ( iterP != outlineGroups.end() )
280                 {       
281                         std::vector<std::string> kNamesVector = iterP->second->getGroupOutlinesNames(); 
282                         for(int i=0; i<kNamesVector.size();i++)
283                         {
284                                 ContourThing * outlineI = getOutlineByKeyName(kNamesVector[i]);
285                                 outlinesVector.push_back(outlineI);
286                         }                       
287                 }
288                 return outlinesVector;
289         }
290
291         /**
292         * Gets the outlines at a specific form the outline's environment
293         * @param aGroupName The name of the group containing the outlines names to get
294         * @return The vector to the outlineGroups at the given group
295         */ 
296         bool OutlineModelManager :: addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup )
297         {
298         outlineGroups.insert(std::pair <std::string, OutlineGroup *> ( theOutlineName, theGroup ));                             
299 //              std::map<std::string, OutlineGroup *> :: iterator iter = NULL;
300                 std::map<std::string, OutlineGroup *> :: iterator iter;
301                 iter = outlineGroups.find( theOutlineName );
302                 bool ifAdded = iter->first.compare( theOutlineName ) == 0;
303                 return ifAdded;
304         }
305         /*
306         * Gets the an outline given the keyName used to be indexed in the outlines's environment
307         * @param outKName Is the outline keyName to search
308         * @return  The corresponding unique outline with the given key name
309         */
310         ContourThing* OutlineModelManager :: getOutlineByKeyName(std::string outKName)
311         {
312                 return *(outlinesEnvironment->getThingByName(outKName));
313         }
314
315         /*
316         * Gets the an imageSourceThing given the keyName used to be indexed in the ImageSourceThing's environment
317         * @param outKName Is the imageSourceThing keyName to search
318         * @return  The corresponding unique outline with the given key name
319         */
320         ImageSourceThing* OutlineModelManager ::getImageSourceThingByKeyName(std::string iSeourceKName)
321         {
322                 return *(imageSourceEnvironment->getThingByName(iSeourceKName));
323         }
324
325         /*
326         * Gets the an imageSectionThing given the keyName used to be indexed in the ImageSectionThing's environment
327         * @param outISectionName Is the imageSectionThing keyName to search
328         * @return  The corresponding unique outline with the given key name
329         */
330         ImageSectionThing* OutlineModelManager ::getImageSectionThingByKeyName(std::string iSectionName)
331         {
332                 return *(imagesSectionEnvironment->getThingByName(iSectionName));
333         }
334
335         /*
336         * Creates an outlineThing with a given name, if no name is given it would have an automatic
337         * @param aName The name for the outlineThing
338                 * @return Returns the key name of the created outline, or ""if it wasn't created
339         */
340 //      bool OutlineModelManager :: createOutline(std::string aName, ContourThing * &theOutline)
341         std::string  OutlineModelManager :: createOutline(manualContourModel * model, std::vector<int> theInstantData, std::string aName)
342         {
343                 ContourThing * theOutline = new ContourThing ( model );
344                 theOutline->setName(aName);             
345                 return addOutline( theOutline, new Instant( &theInstantData ) );                                
346         }
347
348         /*
349         * Creates an axeThing with a given name
350         * @param aDescription The description for the axeThing
351         * @return Returns true if the creation of the axe was successful
352         */
353         //bool OutlineModelManager :: createAxe(std::string aDescription, AxeThing * &theAxe)
354         bool  OutlineModelManager :: createAxe(std::string aDescription, Instant * theInstantData)
355         {
356                 AxeThing * theAxe = new AxeThing ();
357                 theAxe->setDescription(aDescription);                 
358                 return addAxe(theAxe, theInstantData);          
359         }
360
361         /*
362         * Creates an imageSourceThing with a given name
363         * @param aSource The name for the imageSourceThing
364         * @return Returns true if the creation of the imageSource was successful
365         */
366         //bool OutlineModelManager :: createImageSource(std::string aSource, ImageSourceThing * &imageSource)
367         bool OutlineModelManager :: createImageSource(std::string aSource, Instant * theInstantData)
368         {
369 //              imageSource = new ImageSourceThing(aSource);                
370                 //return addImageSource(new ImageSourceThing(aSource), theInstantData);         
371                 return NULL;//***********************************************************************************************
372         }
373
374         /*
375         * Creates an imageSectionThing with a given name
376         * @param aSecImageData The name for the imageSectionThing
377         * @return Returns true if the creation of the imageSection was successful
378         */
379         //bool OutlineModelManager :: createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection)
380         bool OutlineModelManager :: createImageSection(std::string aSecImageData, Instant * theInstantData)
381         {
382                 //imageSection = new ImageSectionThing(aSecImageData);               
383 //              return addImageSection(new ImageSectionThing(aSecImageData), theInstantData);   
384                 return NULL;
385         }
386
387         /*
388         * Adds an outlineThing 
389         * @param theOutline The outline/contour (thing)
390         * @param theInstantData Is the instant for the outline to add
391         * @return Returns true if the addition of the outline was successful
392         */
393         std::string OutlineModelManager :: addOutline( ContourThing * theOutline, Instant * theInstantData)
394         {               
395                 std::string kName;
396
397 // EED 
398 //              bool added  = keyGenerator.generateKeyOf("Outlines", outlinesEnvironment->getNumberOfThings(),kName);
399
400                 counterIdKey++;
401                 bool added = keyGenerator.generateKeyOf( "Outlines", counterIdKey , kName );
402
403                 if( theOutline->getName().compare("")==0 )
404                 {
405                         theOutline->setName(kName);
406                 }
407                 added &= outlinesEnvironment->addThingWithInstant(kName,theOutline, theInstantData);
408                 if( added )
409                         return kName;
410                 else
411                         return "";              
412         }
413
414
415         int OutlineModelManager::IsPartOfStaticList(std::string ss)
416         {
417                 int iBack=-1;
418                 int i, size = staticContourLst.size();
419                 for( i=0 ; i<size ; i++ )
420                 {
421                         ContourThing **contourthing  = staticContourLst[i];
422                         if ((*contourthing)->getName() == ss)
423                         {
424                                 iBack=i;
425                         } // getName() == ss
426                 }
427                 return iBack;
428         }
429
430
431         /*
432         * Remove an outlineThing 
433         * @param theOutline The outline/contour (thing)
434         */
435         void OutlineModelManager :: removeOutline( std::string ss )
436         {               
437                         outlinesEnvironment->removeThing( ss );
438         }
439
440 //EED01
441         void OutlineModelManager :: removeAllOutlines()
442         {
443                 //
444                 staticContourLst.clear();
445
446                 //
447                 std::vector< ContourThing **>  thingsVector;
448                 outlinesEnvironment->getThingsOfEnvironment( &thingsVector );
449                 int i,sizeThingVector = thingsVector.size();
450                 for(i=0;i<sizeThingVector;i++) 
451                 {
452                         ContourThing ** contourthing =  thingsVector[i];
453                     removeOutline(  (*contourthing)->getName()   );
454                 }
455         }
456
457
458         /*
459         * Adds an axeThing 
460         * @param thaAxe The axe (thing)
461         * @param theInstantData Is the instant for the axe to add
462         * @return Returns true if the addition of the axe was successful
463         */
464         bool OutlineModelManager :: addAxe( AxeThing * theAxe , Instant * theInstantData)
465         {
466                 std::string kName;
467                 bool added  = keyGenerator.generateKeyOf("Axes", axesEnvironment->getNumberOfThings(),kName);           
468                 added &= axesEnvironment->addThingWithInstant(kName,theAxe, theInstantData);
469                 return added;
470         }
471
472         /*
473         * Adds an imageSourceThing 
474         * @param imgageSource The image source (thing)
475         * @param theInstantData Is the instant for the source to add
476         * @return Returns true if the addition of the imageSource was successful
477         */
478         bool OutlineModelManager :: addImageSource(ImageSourceThing * imageSource, Instant * theInstantData)
479         {
480                 std::string kName;
481                 bool added  = keyGenerator.generateKeyOf("Image Sources", imageSourceEnvironment->getNumberOfThings(),kName);
482                 added &= imageSourceEnvironment->addThingWithInstant(kName,imageSource, theInstantData );
483                 return added;
484         }
485
486         /*
487         * Adds an imageSectionThing with a given name, if no name is given it would have an automatic
488         * @param aName The imageSection (thing)
489         * @param theInstantData Is the instant for the imageSection to add
490         * @return Returns true if the addition of the imageSection was successful
491         */
492         bool OutlineModelManager :: addImageSection(ImageSectionThing * imageSection, Instant * theInstantData)
493         {               
494                 std::string kName;
495                 bool added  = keyGenerator.generateKeyOf("Image Sections", imagesSectionEnvironment->getNumberOfThings(),kName);
496                 added &= imagesSectionEnvironment->addThingWithInstant(kName, imageSection, theInstantData);
497                 return added;
498         }
499
500         /*
501         * Annotates an outline keyname at the actual instant
502         * @param kOutlineName The key name to annotate
503         * @param theRealName The real name asigned to the outline
504         */
505         void OutlineModelManager :: annotateOutlineWrap(std::string kOutlineName, std::string theRealName)
506         {
507                 actualInstantWrapping -> addOutlineName(kOutlineName, theRealName);
508         }
509
510         /*
511         * Annotates a set of outline keynames-real names wrapping at the actual instant
512         * @param kNamesVector The key names vector to annotate
513         * @param theOutlinesVector The outlines pointers vector to get the real names from
514         */
515         void OutlineModelManager :: annotateOutlinesWrap(std::vector<std::string> kNamesVector, std::vector<ContourThing **> theOutlinesVector)
516         {
517                 actualInstantWrapping ->clean();
518                 for(int i=0; i<kNamesVector.size(); i++)
519                 {
520                         ContourThing * anOutline = *theOutlinesVector[i];
521                         actualInstantWrapping -> addOutlineName( kNamesVector[i], anOutline->getName() );
522                 }
523         }
524         
525         /*
526         * Annotates the actual outline keyName-real name wrapping at the actual instant
527         * @param actualKeyOutline The key name to annotate
528         * @param theRealName The real name asigned to the actual outline
529         */
530         void OutlineModelManager :: annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName)
531         {
532                 actualInstantWrapping -> setActualOutline(actualKeyOutline, theRealName);
533         }
534
535         /*
536         * Annotate the actual axe keyName-real name wrapping at the actual instant
537         * @param actualKeyAxe The key name to annotate
538         * @param theRealName The real name asigned to the actual axe
539         */
540         void OutlineModelManager :: annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName)
541         {
542                 actualInstantWrapping -> setActualAxeWrap(actualKeyAxe, theRealName);
543         }
544
545         /*
546         * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant
547         * @param actualKeyImage The key name to annotate
548         * @param theRealName The real name asigned to the annotateActualSection
549         */
550         void OutlineModelManager :: annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
551         {
552                 actualInstantWrapping -> setActualSectionImageNamesWrapp(actualKeyImage, theRealName);
553         } 
554
555         /*
556         * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
557         * @param actualKeyImage The key name to annotate
558         * @param theRealName The real name asigned to the annotateActualSource 
559         */
560         void OutlineModelManager :: annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
561         {
562                 actualInstantWrapping -> setActualSourceImageNamesWrapp(actualKeyImage, theRealName);
563         } 
564
565
566         /*
567         * Sets the actual instant and manage the search of the corresponding elements with the specified instant in all the enviornments
568         * @param newActualInstantData Is the instant data
569         */
570         void OutlineModelManager :: setInstant(Instant * newActualInstantData)
571         {
572                 actualInstant = newActualInstantData;
573                 updateToActualInstant();
574         }
575
576         Instant* OutlineModelManager :: getInstant()
577         {
578                 return actualInstant;
579         }
580
581         /*
582         * Gets the an axe with a given keyName
583         * @axeKName The axe keyName for searching in the axes environment
584         * @return The corresponding axe
585         */
586         AxeThing * OutlineModelManager :: getAxeByKeyName(std::string axeKName)
587         {
588                 return *axesEnvironment->getThingByName(axeKName);
589         }
590
591         /*
592         * Gets the instants of a specific outline
593         * @param thekName Is the name of the outline
594         * @return The instants set 
595         */
596         std::vector<Instant *> OutlineModelManager :: getOutlineInstantsByName(std::string thekName)
597         {               
598                 return *outlinesEnvironment->getInstantsOfThing(thekName);              
599         }
600
601         /*
602         * Gets all instants outlines
603         * @return The instants set 
604         */
605         std::vector<Instant *> OutlineModelManager :: getOutlineInstants()
606         {               
607                 return *outlinesEnvironment->getExistingInstants();             
608         }
609
610
611
612         /*
613         * Includes an instant to the specified axe
614         * @param outKName Is outline key name
615         * @param anInstantData Is the instant data
616         * @return Returns if the insertion was successful or not
617         */
618         bool OutlineModelManager :: includeOutlineInstant(std::string outKName,Instant * anInstantData)
619         {
620                 return outlinesEnvironment->addInstantToThing(outKName,anInstantData);
621         }
622
623         /*
624         * Includes an instant to the specified axe
625         * @param axeKName Is axe key name
626         * @param anInstantData Is the instant data
627         * @return Returns if the insertion was successful or not
628         */
629         bool OutlineModelManager :: includeAxeInstant(std::string axeKName,Instant * anInstantData)
630         {
631                 return axesEnvironment->addInstantToThing( axeKName,anInstantData );
632         }
633
634         /*
635         * Includes an instant to the specified image section
636         * @param imaKName Is the image section key name
637         * @param anInstantData Is the instant data
638         * @return Returns if the insertion was successful or not
639         */
640         bool OutlineModelManager :: includeImageSectionInstant(std::string imaKName,Instant * anInstantData)
641         {
642                 return imagesSectionEnvironment->addInstantToThing( imaKName,anInstantData );
643         }
644
645         /*
646         * Includes an instant to the specified image source
647         * @param imaKName Is the image section key name
648         * @param anInstantData Is the instant data
649         * @return Returns if the insertion was successful or not
650         */
651         bool OutlineModelManager :: includeImageSourceInstant(std::string imaKName,Instant * anInstantData)
652         {
653                 return imageSourceEnvironment->addInstantToThing( imaKName,anInstantData );
654         }
655         
656         /*
657         *       Method that retorns the name of each concept and the size of it.
658         *       @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
659         *       @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
660         */
661         void OutlineModelManager :: getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect)
662         {
663                 if( outlinesEnvironment != NULL )
664                 {
665                         //if (outlinesEnvironment->getNumberOfThings()>0)
666                                 outlinesEnvironment->getConceptsInformation(conceptNameVect, conceptSizeVect);
667                 }       
668         }
669
670
671         /*
672         * Gets the contourWorspace 
673         * @return Returns the workspace
674         */
675         ContourWorkspace * OutlineModelManager :: getContourWorkspace()
676         {
677                 return workSpace;
678         }
679
680
681         /*
682         * Cleans the outline model manager and its dependencies
683         */
684         void OutlineModelManager :: clean()
685         {
686                 /*axesEnvironment->clean();
687                 imagesSectionEnvironment->clean();
688                 imageSourceEnvironment->clean();
689                 outlinesEnvironment->clean();*/
690                 outlineGroups.clear();
691                 actualInstantWrapping->clean();
692                 keyGenerator.clear();
693                 //workSpace->clear();
694         }
695
696         /*
697         * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
698         */
699         void OutlineModelManager :: updateToActualInstant()
700         {               
701                 Instant * longInstant = actualInstant;
702                 /*Instant * mediumInstant = new Instant();
703                 Instant * shortInstant = new Instant();         
704                 std::vector<int>* theInstant = longInstant->getInstant();
705                 for(int i=1; i<theInstant->size(); i++)
706                 {
707                         if (i>=2)
708                                 shortInstant->addConcept( (*theInstant)[i] );
709                         mediumInstant->addConcept( (*theInstant)[i] );
710                 }
711                 
712                 //getting the sourceAtInstant
713                 std::vector<std::string> kSourceVector;
714                 std::vector<ImageSourceThing **> imSourceVector;
715                 imageSourceEnvironment->getThings(kSourceVector, imSourceVector, shortInstant);
716                 annotateActualSourceImageWrap(kSourceVector[0], (**imSourceVector[0]).getSourceImage());
717
718         //getting the aAxeAtInstant 
719                 std::vector<std::string> kAxeVector;
720                 std::vector<AxeThing **> axesVector;
721                 axesEnvironment->getThings(kAxeVector, axesVector, mediumInstant);
722                 if ( !kAxeVector.empty() )
723                         annotateActualAxeWrap(kAxeVector[0], (**axesVector[0]).getDescription());
724
725                 //getting the sectionAtInstant
726                 std::vector<std::string> kSectionVector;
727                 std::vector<ImageSectionThing **> imSectionVector;
728                 imagesSectionEnvironment->getThings(kSectionVector, imSectionVector, longInstant); if ( !kSectionVector.empty() )
729             //annotateActualSectionImageWrap(kSectionVector[0], (**imSectionVector[0]).getImageData());
730                 */
731                 
732                 //getting the outlines          
733
734                 std::vector<ContourThing ** > vect = getOutlinesAtInstant( longInstant );
735
736         }
737         
738         /*
739         * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.   
740         * @return Returns true if successful insert of the automatic concepts, false otherwise
741         */
742         bool OutlineModelManager :: setAutomaticConcepts()
743         {
744                 axeConcept = "Axe";
745                 axeDepthConcept = "Axe Depth";
746                 int axeC_size = 10;
747                 int axeDepthC_size = INT_MAX;
748
749                 bool allOK = axesEnvironment->addConcept(axeConcept, axeC_size);
750                 allOK &= imagesSectionEnvironment->addConcept(axeConcept, axeC_size);
751                 allOK &= outlinesEnvironment->addConcept(axeConcept, axeC_size);
752                 
753                 allOK &= imagesSectionEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
754                 allOK &= outlinesEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
755 /*
756                 allOK &= keyGenerator.addKeyThing("Axes", "Axe");
757                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
758                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
759                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");*/
760
761                 return allOK;
762         }
763
764
765         std::string OutlineModelManager :: createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData )
766         {
767                 manualContourModel * manModelContour  = getOutlineByKeyName( anExistingKName )->getModel()->Clone();
768                 return createOutline( manModelContour, instantNoTouchData );
769         }
770
771         void OutlineModelManager::SaveThingName( FILE *pFile, std::string nameThing )
772         {
773                 std::vector< Instant * > *lstInstants;
774                 lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing );
775                 Instant *instant = (*lstInstants)[0];
776                 std::vector<int> *vecInst =instant->getInstant();
777                 int i,sizeVecInst = vecInst->size();
778                 fprintf(pFile,"Instant ");
779                 for ( i=0 ; i<sizeVecInst ; i++ )
780                 {
781                         fprintf(pFile,"%d ",(*vecInst)[i]);
782                 }
783                 fprintf(pFile,"\n");
784                 ContourThing *contourthing = *outlinesEnvironment->getThingByName(nameThing);
785                 contourthing->getModel()->Save(pFile);
786         }
787