]> Creatis software - creaContours.git/blobdiff - lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx
#onLoad without interface
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / KernelManagerContour.cxx
index 8e9f1d8e3663b3c498ae5d7327eb2c4635c13e7d..4a96eae2505cb2f510c1575b14bb4a5e088d9a76 100644 (file)
@@ -91,6 +91,23 @@ std::vector<vtkImageData*> KernelManagerContour::getVectImages()
        return vectimages;
 }
 
+void KernelManagerContour::changeImage(int id, vtkImageData *img)
+{
+    if ( id<vectimages.size() )
+    {
+        vectimages[id]=img;
+    }
+    double spc[3];
+    std::vector<double> vectspc;
+    img->GetSpacing(spc);
+    vectspc.push_back(spc[0]);
+    vectspc.push_back(spc[1]);
+    vectspc.push_back(spc[2]);
+    vectimagesSpacing[id]=vectspc;
+    std::string         imgstring           = "Source Image "+intToString(id+1);
+    ImageSourceThing    *imagesourcething   = modelManager->getImageSourceThingByKeyName( imgstring );
+    imagesourcething->setSourceImage( img );
+}
 
 void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg)
 {
@@ -98,8 +115,8 @@ void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg)
        std::vector<double> vectspc;
        for(int i = 0; i < (int)(vectimg.size()); i++)
        {
-               vtkImageData* img = vectimg[i];
-               vtkImageChangeInformationchange = vtkImageChangeInformation::New();
+               vtkImageData                *img    = vectimg[i];
+               vtkImageChangeInformation   *change = vtkImageChangeInformation::New();
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
                change->SetInformationInput(img);
@@ -131,23 +148,23 @@ void KernelManagerContour::GetSpacing(double *vecspc, int iImage)
 
 void KernelManagerContour::initializeEnvironment(std::string datadir)
 {
-       _datadir                                                    = datadir;
-       std::string conceptsFN                                              = datadir+"holaConceptsFile.cf";
-       std::string imageSourcesFN                                          = datadir+"holaImagesInstantsFile.of";
-       std::string imageSectionsFN                                         = "";
-       std::string axeThingsFN                                             = "";
-       std::map<std::string, ImageSourceThing *> * sourcesMap      = new std::map<std::string, ImageSourceThing *>();
-       std::map<std::string, ImageSectionThing *>* sectionsMap     = new std::map<std::string, ImageSectionThing *>();
-       std::map<std::string, AxeThing *>* axesMap                                  = new std::map<std::string, AxeThing *>();
-       std::map<std::string, ContourThing *>* outlinesMap                  = new std::map<std::string, ContourThing *>();
+                                                _datadir            = datadir;
+       std::string                                 conceptsFN                  = datadir+"holaConceptsFile.cf";
+       std::string                                 imageSourcesFN              = datadir+"holaImagesInstantsFile.of";
+       std::string                                 imageSectionsFN             = "";
+       std::string                                 axeThingsFN                 = "";
+       std::map<std::string, ImageSourceThing *>   *sourcesMap         = new std::map<std::string, ImageSourceThing *>();
+       std::map<std::string, ImageSectionThing *>  *sectionsMap            = new std::map<std::string, ImageSectionThing *>();
+       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 < (int)(vectimages.size()); i++)
        {
-               vtkImageData* selectedimage = vectimages[i];
-               ImageSourceThing * thing                                                                = new ImageSourceThing(selectedimage);
-               std::string imgstring = "Source Image "+intToString(i+1);
+               vtkImageData        *selectedimage      = vectimages[i];
+               ImageSourceThing    *thing              = new ImageSourceThing(selectedimage);
+               std::string         imgstring           = "Source Image "+intToString(i+1);
                sourcesMap->insert(std::pair<std::string, ImageSourceThing *>( imgstring, thing));
        } // for
-       OutlineModelBuilder * _builder                                                          = new OutlineModelBuilder( conceptsFN ,datadir);
+       OutlineModelBuilder     *_builder = new OutlineModelBuilder( conceptsFN ,datadir);
        _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap );
        _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap );
        _builder->buildAxe_Envornment(axeThingsFN, axesMap );
@@ -489,49 +506,43 @@ void KernelManagerContour::getConceptsInformation(std::vector<std::string>& conc
        modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
 }
 
-
-vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> inst){
+vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> inst)
+{
        int index = inst[5]-1;
-
-       if(index < (int)(vectimages.size())&&index!=_currentIndex){
-               _currentIndex=index;
+       if(index < (int)(vectimages.size())&&index!=_currentIndex)
+    {
+               _currentIndex = index;
                return vectimages[index];
        }
        return NULL;
 }
 
-std::string KernelManagerContour::getCurrentFileName(){
+std::string KernelManagerContour::getCurrentFileName()
+{
        return filename;
 }
 
-void KernelManagerContour::setCurrentFileName(std::string filenam){
+void KernelManagerContour::setCurrentFileName(std::string filenam)
+{
        this->filename = filenam;
 }
 
-std::string KernelManagerContour::parseOsirixFile(std::string filename){
-
-
+std::string KernelManagerContour::parseOsirixFile(std::string filename)
+{
 #ifdef ParserOsirix_BUILD
        vtkImageData* sourceimage;
        std::string xsdfile;
-
        xsdfile = _datadir;
-
        xsdfile.append("\\XML\\osirixschema.xsd");
-
        sourceimage = getSourceImage();
        OsirixParser p(xsdfile.c_str(), sourceimage->GetSpacing(), sourceimage->GetExtent());
-
-       if(p.ParseFile(filename.c_str())!= 0){
-
+       if(p.ParseFile(filename.c_str())!= 0)
+    {
        }
-
        return p.getContoursFileName();
 #else
        return "";
 #endif
-
-
 }