]> Creatis software - creaContours.git/blobdiff - lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx
RaC Changes that includes a Polygon contour in creaMaracasVisu and creaContours
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / KernelManagerContour.cxx
index 10a3c4cb22a0f32ab8466ddbfe26566b7d0b0acd..ec6251f994dd2b3e51319a3f7f3a4fab92902ed3 100644 (file)
@@ -13,7 +13,13 @@ KernelManagerContour::KernelManagerContour(){
 **/
        inredo = 0;
        inundo = 0;     
-       stundoredo = "data/temp";
+
+       time_t seconds;
+       seconds = time (NULL);
+       int time = seconds;
+
+
+       stundoredo = "data/temp"+intToString(time);
        _currentIndex = 0;
 
        _contourPropagation = NULL;
@@ -28,7 +34,8 @@ KernelManagerContour::KernelManagerContour(){
 **/
 
 }
-KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images){
+KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images,std::string datadir,std::string tmpdir)
+{
 
 
 /**THIS ALL SHOULD BE IN AN OTHER LIB CALLED PERSISTANCE
@@ -36,38 +43,46 @@ KernelManagerContour::KernelManagerContour(std::vector<vtkImageData*> images){
 **/
        inredo = 0;
        inundo = 0;     
-       stundoredo = "data/temp";
-       _currentIndex = 0;
 
+       time_t seconds;
+       seconds = time (NULL);
+       int time = seconds;
+
+
+       stundoredo = tmpdir+"/temp"+intToString(time);
+       _currentIndex = 0;
+       
        _contourPropagation = NULL;
 #if(WIN32)
-               mkdir(stundoredo.c_str());
+       mkdir(tmpdir.c_str());
+       mkdir(stundoredo.c_str());
 #else
-               mkdir(stundoredo.c_str(),755);
+       mkdir(tmpdir.c_str(),755);
+       mkdir(stundoredo.c_str(),755);
 #endif
        stundoredo += "/cont";
 /**
 **  FINISH PERSISTANCE
 **/
        setVectImages(images);
-       initializeEnvironment();
+       initializeEnvironment(datadir);
 
 }
 KernelManagerContour::~KernelManagerContour(){
-}
+}      
 
 std::vector<vtkImageData*> KernelManagerContour::getVectImages(){
        return vectimages;
 }
 void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg){
 
-       for(int i = 0; i < vectimg.size(); i++){
+       for(int i = 0; i < (int)(vectimg.size()); i++){
                vtkImageData* img = vectimg[i];
                vtkImageChangeInformation* change = vtkImageChangeInformation::New();
                change->SetInformationInput(img);
                change->SetInputConnection(img->GetProducerPort());
 
-               change->SetOutputSpacing(0.6,0.6,0.6);
+               change->SetOutputSpacing(1,1,1);
                
                change->Update();
 
@@ -77,9 +92,9 @@ void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg){
        vectimages = vectimg;
 }
 
-void KernelManagerContour::initializeEnvironment(){
-       std::string conceptsFN                  =  "data/holaConceptsFile.cf";
-       std::string imageSourcesFN              = "data/holaImagesInstantsFile.of";
+void KernelManagerContour::initializeEnvironment(std::string datadir){
+       std::string conceptsFN                  =  datadir+"holaConceptsFile.cf";
+       std::string imageSourcesFN              =  datadir+"holaImagesInstantsFile.of";
        std::string imageSectionsFN             = "";
        std::string axeThingsFN                 = "";
 
@@ -88,7 +103,7 @@ void KernelManagerContour::initializeEnvironment(){
        std::map<std::string, AxeThing *>* axesMap                                      = new std::map<std::string, AxeThing *>();
        std::map<std::string, ContourThing *>* outlinesMap                      = new std::map<std::string, ContourThing *>();  
 
-       for(int i = 0; i < vectimages.size(); i++){
+       for(int i = 0; i < (int)(vectimages.size()); i++){
                vtkImageData* selectedimage = vectimages[i];
                ImageSourceThing * thing                                                                        = new ImageSourceThing(selectedimage);
                std::string imgstring = "Source Image "+intToString(i+1);
@@ -96,7 +111,7 @@ void KernelManagerContour::initializeEnvironment(){
        }
        
 
-       OutlineModelBuilder * _builder                                                          = new OutlineModelBuilder( conceptsFN );
+       OutlineModelBuilder * _builder                                                          = new OutlineModelBuilder( conceptsFN ,datadir);
        _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
        _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );         
        _builder->buildAxe_Envornment(axeThingsFN, axesMap );
@@ -115,7 +130,7 @@ OutlineModelManager* KernelManagerContour::getOutlineModelManager(){
        return modelManager;
 }
 
-std::string KernelManagerContour::createOutline(manualContourModel * manModelContour,std::vector<int> instantVector){
+std::string KernelManagerContour::createOutline(manualBaseModel * manModelContour,std::vector<int> instantVector){
        return modelManager->createOutline( manModelContour, instantVector );
 }
 
@@ -138,8 +153,8 @@ std::vector<std::string> KernelManagerContour::GetLstNameThingsStatic(){
        return modelManager->GetLstNameThingsStatic();
 }
 
-void KernelManagerContour::SaveThingName(FILE* pFile, std::string name ){
-       modelManager->SaveThingName(pFile, name);
+void KernelManagerContour::SaveThingName(FILE* pFile, FILE *pFileData, std::string name ){
+       modelManager->SaveThingName(pFile, pFileData, name);
 }
 std::vector<std::string> KernelManagerContour::GetLstNameThings(){
        return modelManager->GetLstNameThings();
@@ -153,7 +168,7 @@ bool KernelManagerContour::IsPartOfStaticList(std::string theKeyName){
 }
 
 void KernelManagerContour::deleteCModel(std::string theKeyName){
-       manualContourModel* cModel              = modelManager->getOutlineByKeyName(theKeyName)->getModel();
+       manualBaseModel* cModel         = modelManager->getOutlineByKeyName(theKeyName)->getModel();
        modelManager->removeOutline( theKeyName );
 
        delete cModel;
@@ -188,10 +203,11 @@ void KernelManagerContour::setInstant(std::vector<int> vectInstant){
        modelManager->setInstant(act);
 }
 
-std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData){
+std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData)
+{
        return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData);
 }
-manualContourModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){
+manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){
        return modelManager->getOutlineByKeyName (cloneName )->getModel();
 }
 
@@ -298,11 +314,11 @@ void KernelManagerContour::CalculeSplinePropagation(){
        _contourPropagation->CalculeSplinePropagation();
 }
 
-manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector){
+manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector){
     
        
        bool addedModel = false;
-       manualContourModel* manModelContour=NULL;
+       manualBaseModel* manModelContour=NULL;
 
        if (_contourPropagation->ifSliceKeyContourExist(z)==false){
 
@@ -327,7 +343,7 @@ manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector<
                for (int j=0 ; j<sizeCtrPt ; j++)
                {
 //JSTG_16-07-08_----------------------------------------------------------------
-                       manModelContour->AddPoint( (*vecCtrlPointX)[j] , (*vecCtrlPointY)[j] , -900  );
+                       manModelContour->AddPoint( (*vecCtrlPointX)[j] , (*vecCtrlPointY)[j] , 900  );
 //--------------------------------------------------------------------
                } // for j
 
@@ -340,12 +356,14 @@ manualContourModel* KernelManagerContour::GetPoints(int z,int type, std::vector<
                
        }// ifSliceKeyContourExist
        return manModelContour;
-
 }
 
-manualContourModel * KernelManagerContour::factoryManualContourModel(int typeContour)
+manualBaseModel * KernelManagerContour::factoryManualContourModel(int typeContour)
 {      
-       manualContourModel *manModelContour=NULL;
+       manualBaseModel *manModelContour=NULL;
+
+       // Creating the model
+       // NOTE: The view and the controler are created in the wxVtkBaseView_SceneManager class, configureViewControlTo method
 
        // spline
        if (typeContour==0)
@@ -371,6 +389,24 @@ manualContourModel * KernelManagerContour::factoryManualContourModel(int typeCon
                manModelContour = new manualContourModelCircle();
        }
 
+       // line
+       if (typeContour==6)
+       {
+               manModelContour = new manualContourModelLine();
+       }
+       
+       // points
+       if (typeContour==7)
+       {
+               manModelContour = new manualBaseModel();
+       }
+
+       // polygon
+       if (typeContour==10)
+       {
+               manModelContour = new manualContourModelPolygon();
+       }
+
        return manModelContour;
 }
 
@@ -378,7 +414,7 @@ std::vector<std::string> KernelManagerContour::getOutlinesNameAtInstant(std::vec
        Instant instant(&tempvector);
        std::vector<ContourThing**> vectcont = modelManager->getOutlinesAtInstant( &instant );
        std::vector<std::string> vectname;
-       for(int i = 0; i < vectcont.size(); i++){
+       for(int i = 0; i < (int)(vectcont.size()); i++){
                ContourThing **contourthing = vectcont[i];
                vectname.push_back((*contourthing)->getName());
        }
@@ -389,9 +425,9 @@ std::vector<ContourThing**> KernelManagerContour::getOutlinesAtInstant(Instant*
        return modelManager->getOutlinesAtInstant(instant);
 }
 
-std::vector<manualContourModel*> KernelManagerContour::ExploseEachModel( std::vector<manualContourModel*> lstManConMod ){
-       std::vector<manualContourModel*> lstTmp;
-       std::vector<manualContourModel*> lstResult;
+std::vector<manualBaseModel*> KernelManagerContour::ExploseEachModel( std::vector<manualBaseModel*> lstManConMod ){
+       std::vector<manualBaseModel*> lstTmp;
+       std::vector<manualBaseModel*> lstResult;
        int j,jSize;
        int i,iSize=lstManConMod.size();
        for (i=0;i<iSize;i++)
@@ -414,9 +450,19 @@ void KernelManagerContour::getConceptsInformation(std::vector<std::string>& conc
 vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> inst){
        int index = inst[5]-1;
 
-       if(index < vectimages.size()&&index!=_currentIndex){
+       if(index < (int)(vectimages.size())&&index!=_currentIndex){
                _currentIndex=index;
                return vectimages[index];
        }
        return NULL;
-}
\ No newline at end of file
+}
+
+std::string KernelManagerContour::getCurrentFileName(){
+       return filename;
+}
+
+void KernelManagerContour::setCurrentFileName(std::string filenam){
+       this->filename = filenam;
+}
+
+