X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fkernel_ManagerContour_NDimensions%2FKernelManagerContour.cxx;h=e7f99c8d89b8e6607bbf8152a5d2286ce7891a77;hb=ec11a783e7b5477f1d93886a6336255cd7cbecf3;hp=ec6251f994dd2b3e51319a3f7f3a4fab92902ed3;hpb=40033c782c0c68ecc676bb59de5c7fe9eb3cac44;p=creaContours.git diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index ec6251f..e7f99c8 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -12,7 +12,7 @@ KernelManagerContour::KernelManagerContour(){ ** **/ inredo = 0; - inundo = 0; + inundo = 0; time_t seconds; seconds = time (NULL); @@ -42,7 +42,7 @@ KernelManagerContour::KernelManagerContour(std::vector images,std ** **/ inredo = 0; - inundo = 0; + inundo = 0; time_t seconds; seconds = time (NULL); @@ -51,7 +51,7 @@ KernelManagerContour::KernelManagerContour(std::vector images,std stundoredo = tmpdir+"/temp"+intToString(time); _currentIndex = 0; - + _contourPropagation = NULL; #if(WIN32) mkdir(tmpdir.c_str()); @@ -64,35 +64,58 @@ KernelManagerContour::KernelManagerContour(std::vector images,std /** ** FINISH PERSISTANCE **/ - setVectImages(images); + setVectImages(images); initializeEnvironment(datadir); } -KernelManagerContour::~KernelManagerContour(){ -} -std::vector KernelManagerContour::getVectImages(){ +KernelManagerContour::~KernelManagerContour() +{ +} + +std::vector KernelManagerContour::getVectImages() +{ return vectimages; } -void KernelManagerContour::setVectImages(std::vector vectimg){ + +void KernelManagerContour::setVectImages(std::vector vectimg) +{ + double spc[3]; + std::vector vectspc; + for(int i = 0; i < (int)(vectimg.size()); i++){ vtkImageData* img = vectimg[i]; vtkImageChangeInformation* change = vtkImageChangeInformation::New(); change->SetInformationInput(img); change->SetInputConnection(img->GetProducerPort()); + img->GetSpacing(spc); change->SetOutputSpacing(1,1,1); - change->Update(); + vectspc.clear(); + vectspc.push_back(spc[0]); + vectspc.push_back(spc[1]); + vectspc.push_back(spc[2]); + vectimagesSpacing.push_back(vectspc); vectimg[i] = change->GetOutput(); } vectimages = vectimg; } + +void KernelManagerContour::GetSpacing(double *vecspc, int iImage) +{ + vecspc[0]=vectimagesSpacing[iImage][0]; + vecspc[1]=vectimagesSpacing[iImage][1]; + vecspc[2]=vectimagesSpacing[iImage][2]; +} + + void KernelManagerContour::initializeEnvironment(std::string datadir){ + _datadir = datadir; std::string conceptsFN = datadir+"holaConceptsFile.cf"; std::string imageSourcesFN = datadir+"holaImagesInstantsFile.of"; std::string imageSectionsFN = ""; @@ -101,7 +124,7 @@ void KernelManagerContour::initializeEnvironment(std::string datadir){ std::map * sourcesMap = new std::map(); std::map* sectionsMap = new std::map(); std::map* axesMap = new std::map(); - std::map* outlinesMap = new std::map(); + std::map* outlinesMap = new std::map(); for(int i = 0; i < (int)(vectimages.size()); i++){ vtkImageData* selectedimage = vectimages[i]; @@ -109,11 +132,11 @@ void KernelManagerContour::initializeEnvironment(std::string datadir){ std::string imgstring = "Source Image "+intToString(i+1); sourcesMap->insert(std::pair( imgstring, thing)); } - + OutlineModelBuilder * _builder = new OutlineModelBuilder( conceptsFN ,datadir); _builder->buildImageSource_Envornment( imageSourcesFN, sourcesMap ); - _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap ); + _builder->buildImageSection_Envornment( imageSectionsFN, sectionsMap ); _builder->buildAxe_Envornment(axeThingsFN, axesMap ); _builder->buildCountour_Envornment( imageSectionsFN, outlinesMap ); @@ -143,7 +166,7 @@ std::string KernelManagerContour::intToString(int num){ while (k > 0){ char temp = k % 10 + 48; k = k / 10; - result = temp + result; + result = temp + result; } } return result; @@ -207,7 +230,9 @@ std::string KernelManagerContour::createCopyContourOf ( std::string anExistingKN { return modelManager->createCopyContourOf(anExistingKName, instantNoTouchData); } -manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName){ + +manualBaseModel* KernelManagerContour::getOutlineByKeyName(std::string cloneName) +{ return modelManager->getOutlineByKeyName (cloneName )->getModel(); } @@ -215,16 +240,16 @@ bool KernelManagerContour::onRedo(std::string& filename){ if(inredo > 0){ inredo--; inundo++; - std::string str = intToString(inundo); - filename = stundoredo + str + ".roi"; - //loadState(temp); + std::string str = intToString(inundo); + filename = stundoredo + str + ".roi"; + //loadState(temp); return true; } return false; } bool KernelManagerContour::onUndo(std::string& filename){ - if(inundo>0){ + if(inundo>0){ inredo++; inundo--; @@ -232,9 +257,9 @@ bool KernelManagerContour::onUndo(std::string& filename){ //itoa(inundo, str, 10); std::string str = intToString(inundo); - + filename = stundoredo + str + ".roi"; - + return true;//loadState(temp); } return false; @@ -258,7 +283,7 @@ bool KernelManagerContour::onUndoSaveFile(std::string& filename){ filename = stundoredo + str + ".roi"; return true; - //saveFileWithContours(temp); + //saveFileWithContours(temp); } } @@ -270,53 +295,55 @@ void KernelManagerContour :: changeContourOfManager(std::string keyName, Instant modelManager->ChangeContourOfList(keyName, instant); } -void KernelManagerContour ::resetAppend(){ - if(isInitContourPropagation()){ +void KernelManagerContour ::resetAppend() +{ + if (_contourPropagation!=NULL) + { _contourPropagation->resetAppend(); - } -} - -bool KernelManagerContour::isInitContourPropagation(){ - if(_contourPropagation == NULL){ - _contourPropagation = new ContourPropagation(); - }else{ - return true; } - return false; - } -std::string KernelManagerContour::onSpreadAdd( std::vector *vecX, std::vector *vecY, std::vector *vecZ, std::vector instants){ - if(isInitContourPropagation()){ - if (vecX->size()!=0){ - - int i,size=vecZ->size(); - int actualSlice = instants[1]; - for ( i=0 ; iappendContour(vecX , vecY , vecZ); - return intToString(actualSlice); - } - } +std::string KernelManagerContour::onSpreadAdd( std::vector *vecX, std::vector *vecY, std::vector *vecZ, std::vector instants) +{ + if (_contourPropagation==NULL) + { + _contourPropagation = new ContourPropagation(); + } + + if (vecX->size()!=0){ + + int i,size=vecZ->size(); + int actualSlice = instants[1]; + for ( i=0 ; iappendContour(vecX , vecY , vecZ); + return intToString(actualSlice); + } return ""; } -void KernelManagerContour::getMaxMinZ(double *minZ,double *maxZ){ - if(isInitContourPropagation()){ + +void KernelManagerContour::getMaxMinZ(double *minZ,double *maxZ) +{ + if (_contourPropagation!=NULL) + { _contourPropagation->getMaxMinZ(minZ, maxZ); } } -void KernelManagerContour::CalculeSplinePropagation(){ + + +void KernelManagerContour::CalculeSplinePropagation() +{ _contourPropagation->setInterpolationNumber(100); _contourPropagation->CalculeSplinePropagation(); } -manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector){ - - +manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector) +{ bool addedModel = false; manualBaseModel* manModelContour=NULL; @@ -327,9 +354,9 @@ manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vectorFindIdWithZ(z); if (type==0) // Initial Points - { + { _contourPropagation->GetInitialControlPoints( idTmp , vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ); - } + } if (type==1) // Automatique Method { _contourPropagation->GetControlPoints( idTmp ,vecCtrlPointX,vecCtrlPointY,vecCtrlPointZ); @@ -343,7 +370,7 @@ manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vectorAddPoint( (*vecCtrlPointX)[j] , (*vecCtrlPointY)[j] , 900 ); + manModelContour->AddPoint( (*vecCtrlPointX)[j] , (*vecCtrlPointY)[j] , -900 ); //-------------------------------------------------------------------- } // for j @@ -353,13 +380,13 @@ manualBaseModel* KernelManagerContour::GetPoints(int z,int type, std::vector KernelManagerContour::getOutlinesNameAtInstant(std::vec ContourThing **contourthing = vectcont[i]; vectname.push_back((*contourthing)->getName()); } - return vectname; + return vectname; } std::vector KernelManagerContour::getOutlinesAtInstant(Instant* instant ){ @@ -465,4 +492,30 @@ void KernelManagerContour::setCurrentFileName(std::string filenam){ this->filename = filenam; } +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){ + + } + + return p.getContoursFileName(); +#else + return ""; +#endif + + +} +