X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkMeasureLength.cxx;h=11326b71782d94761eedbf00dafaa786d40c418e;hb=6b2916fb6359ead51e50b3ee9b473dc1c3c057d4;hp=4dfc3d73d51b06e1b3485fe900ced5ccb4e15be1;hpb=947acfe6b7e7f37d3523f9d5eabfeb9277292aad;p=bbtk.git 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; }