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