From: Eduardo DAVILA Date: Mon, 6 Jun 2016 19:28:10 +0000 (+0200) Subject: #2969 BBTK Bug New Normal - MesureLength box in vtk package X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6b2916fb6359ead51e50b3ee9b473dc1c3c057d4;p=bbtk.git #2969 BBTK Bug New Normal - MesureLength box in vtk package --- diff --git a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx index 550148b..197ed03 100644 --- a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx +++ b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx @@ -80,9 +80,17 @@ vtkImageData* GetXCoherentInfoGdcmReader::CreateDefaultImage() #if defined USE_GDCM void GetXCoherentInfoGdcmReader::Process() { + // Read the *first* image file (a SET of file names is given as input) f = GDCM_NAME_SPACE::File::New(); - f->SetFileName( bbGetInputIn()[0] ); + + if ( bbGetInputIn().size()!=0 ) + { + f->SetFileName( bbGetInputIn()[0] ); + } else { + f->SetFileName( "" ); + } + bool res = f->Load(); if ( !res ) { @@ -120,6 +128,7 @@ void GetXCoherentInfoGdcmReader::Process() sh->AddFileName(*it); } + GDCM_NAME_SPACE::FileList::const_iterator it; GDCM_NAME_SPACE::FileList *l; @@ -154,8 +163,6 @@ void GetXCoherentInfoGdcmReader::Process() //reader->SetFileName( bbGetInputIn().c_str() ); reader->SetCoherentFileList(l); reader->Update(); - reader->GetOutput(); - bbSetOutputOut( reader->GetOutput() ); } #endif diff --git a/packages/std/src/bbstdGetSubVector.h b/packages/std/src/bbstdGetSubVector.h index ec6e861..a2cf2e8 100644 --- a/packages/std/src/bbstdGetSubVector.h +++ b/packages/std/src/bbstdGetSubVector.h @@ -79,19 +79,19 @@ namespace bbstd void GetSubVector::DoIt() { int i,iStart,iEnd; + bool ok = true; iStart = bbGetInputI(); iEnd = bbGetInputI() + bbGetInputSize() - 1; - if (iStart<0) { iStart = 0; } - if (iEnd<0) { iEnd = 0; } - if (iStart>bbGetInputIn().size() ) { iStart = bbGetInputIn().size(); } - if (iEnd>bbGetInputIn().size() ) { iEnd = bbGetInputIn().size(); } + if ((iStart<0) || (iEnd<0)) { ok=false; } + if (iStart>(int)bbGetInputIn().size() ) { ok=false; } + if (iEnd>=(int)bbGetInputIn().size() ) { ok=false; } std::vector tmpVectResult; - if (bbGetInputSize()>=1) + if ( (ok==true) && (bbGetInputSize()>=1) ) { - for ( i=iStart ; iModified(); _extract->Update(); bbSetOutputOut(_extract->GetOutput()); -printf("EED ExtractVtkImageFilter::Process End\n"); } //===== diff --git a/packages/vtk/src/bbvtkMeasureLength.cxx b/packages/vtk/src/bbvtkMeasureLength.cxx index 4dfc3d7..11326b7 100644 --- a/packages/vtk/src/bbvtkMeasureLength.cxx +++ b/packages/vtk/src/bbvtkMeasureLength.cxx @@ -16,29 +16,33 @@ void MeasureLength::Process() std::cout << "RaC MeasureLength::Process START"<< std::endl; _points = bbGetInputPoints(); - _image = bbGetInputImageData(); + _image = bbGetInputImageData(); - double sumLength =0; + double sumLength = 0 ; + double sumLengthVoxels = 0 ; if(_image != NULL && _points->GetNumberOfPoints()>1) { double spc[3]; double origin[3]; + double XFactor; + double YFactor; + double ZFactor; + _image->GetSpacing(spc); _image->GetOrigin(origin); double* first; - first = _points->GetPoint(0); - double firstWorld[3]; + int i; + +//--Length + first = _points->GetPoint(0); firstWorld[0] = first[0]*spc[0] + origin[0]; firstWorld[1] = first[1]*spc[1] + origin[1]; firstWorld[2] = first[2]*spc[2] + origin[2]; - - - - for(int i = 1; i<_points->GetNumberOfPoints();i++) + for(i = 1; i<_points->GetNumberOfPoints();i++) { double* second; second = _points->GetPoint(i); @@ -47,19 +51,44 @@ void MeasureLength::Process() secondWorld[1] = second[1]*spc[1] + origin[1]; secondWorld[2] = second[2]*spc[2] + origin[2]; - double XFactor = secondWorld[0]-firstWorld[0]; - double YFactor = secondWorld[1]-firstWorld[1]; - double ZFactor = secondWorld[2]-firstWorld[2]; + XFactor = secondWorld[0]-firstWorld[0]; + YFactor = secondWorld[1]-firstWorld[1]; + ZFactor = secondWorld[2]-firstWorld[2]; sumLength += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor; firstWorld[0] = secondWorld[0]; firstWorld[1] = secondWorld[1]; firstWorld[2] = secondWorld[2]; + } // for + +//--Length Voxels + first = _points->GetPoint(0); + firstWorld[0] = first[0]; + firstWorld[1] = first[1]; + firstWorld[2] = first[2]; + for(i = 1; i<_points->GetNumberOfPoints();i++) + { + double* second; + second = _points->GetPoint(i); + double secondWorld[3]; + secondWorld[0] = second[0]; + secondWorld[1] = second[1]; + secondWorld[2] = second[2]; + + XFactor = secondWorld[0]-firstWorld[0]; + YFactor = secondWorld[1]-firstWorld[1]; + ZFactor = secondWorld[2]-firstWorld[2]; + sumLengthVoxels += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor; + + firstWorld[0] = secondWorld[0]; + firstWorld[1] = secondWorld[1]; + firstWorld[2] = secondWorld[2]; + } // for - } - } + } // if - bbSetOutputLength(sumLength); + bbSetOutputLength( sqrt(sumLength) ); + bbSetOutputLengthVoxels( sqrt(sumLengthVoxels) ); std::cout << "RaC MeasureLength::Process END"<< std::endl; } diff --git a/packages/vtk/src/bbvtkMeasureLength.h b/packages/vtk/src/bbvtkMeasureLength.h index d7110e9..4c42f85 100644 --- a/packages/vtk/src/bbvtkMeasureLength.h +++ b/packages/vtk/src/bbvtkMeasureLength.h @@ -28,6 +28,7 @@ class bbvtk_EXPORT MeasureLength BBTK_DECLARE_INPUT(Points,vtkPoints*); BBTK_DECLARE_INPUT(ImageData,vtkImageData*); BBTK_DECLARE_OUTPUT(Length,double); + BBTK_DECLARE_OUTPUT(LengthVoxels,double); BBTK_PROCESS(Process); void Process(); private: @@ -46,6 +47,7 @@ BBTK_CATEGORY(""); BBTK_INPUT(MeasureLength,Points,"List of points",vtkPoints*,""); BBTK_INPUT(MeasureLength,ImageData,"Set an image if you want real lentgh (usually in mm)",vtkImageData*,""); BBTK_OUTPUT(MeasureLength,Length,"Sum of the Euclidean distances among the points",double,""); +BBTK_OUTPUT(MeasureLength,LengthVoxels,"Sum of the Euclidean distances among the points (Voxels)",double,""); BBTK_END_DESCRIBE_BLACK_BOX(MeasureLength); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) diff --git a/packages/vtk/src/bbvtkUnaryOperations.h b/packages/vtk/src/bbvtkUnaryOperations.h index 9ef8725..c2fb858 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.h +++ b/packages/vtk/src/bbvtkUnaryOperations.h @@ -76,7 +76,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(UnaryOperations,bbtk::AtomicBlackBox); BBTK_INPUT(UnaryOperations,In1,"Image to be operated",vtkImageData*,""); BBTK_INPUT(UnaryOperations,InConstant,"Constant that will be used in the operations.",double,"0 default"); BBTK_INPUT(UnaryOperations,NewValue,"InConstant replace by NewValue",double,"0 default"); - BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot, 11:ReplaceByContant",int,"Addition default"); + BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot, 11:ReplaceByConstant",int,"Addition default"); BBTK_OUTPUT(UnaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(UnaryOperations); }