]> Creatis software - bbtk.git/commitdiff
#2969 BBTK Bug New Normal - MesureLength box in vtk package
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 6 Jun 2016 19:28:10 +0000 (21:28 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 6 Jun 2016 19:28:10 +0000 (21:28 +0200)
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx
packages/std/src/bbstdGetSubVector.h
packages/vtk/src/bbvtkExtractVtkImageFilter.cxx
packages/vtk/src/bbvtkMeasureLength.cxx
packages/vtk/src/bbvtkMeasureLength.h
packages/vtk/src/bbvtkUnaryOperations.h

index 550148b057ad8affa7f220bfa146ec2aa8611d42..197ed037997da829b0de5672b6af03575e0bc767 100644 (file)
@@ -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
index ec6e861adfb20eedbefecf72675ad21a6ac5bc07..a2cf2e876c27d6a307a1c5944008c9b82f5d887f 100644 (file)
@@ -79,19 +79,19 @@ namespace bbstd
   void GetSubVector<T>::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<T> tmpVectResult;
-       if  (bbGetInputSize()>=1) 
+       if  ( (ok==true) && (bbGetInputSize()>=1) )
        {       
-               for ( i=iStart ; i<iEnd ; i++)
+               for ( i=iStart ; i<=iEnd ; i++)
                {
                        if ( i<(int)bbGetInputIn().size() ) 
                        {
index 7f6f7b305e5119f6da5717e28fd42d33f540e529..efbbe227e7eb91a17ed86c540eda84e5d8d409dc 100644 (file)
@@ -40,7 +40,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ExtractVtkImageFilter,bbtk::AtomicBlackBox);
 //===== 
 void ExtractVtkImageFilter::Process()
 {
-printf("EED ExtractVtkImageFilter::Process Start\n");
        int voi[6];
 
        voi[0] = bbGetInputIndex()[0];
@@ -56,7 +55,6 @@ printf("EED ExtractVtkImageFilter::Process Start\n");
        _extract->Modified();
        _extract->Update();
        bbSetOutputOut(_extract->GetOutput());
-printf("EED ExtractVtkImageFilter::Process End\n");
 }
        
 //===== 
index 4dfc3d73d51b06e1b3485fe900ced5ccb4e15be1..11326b71782d94761eedbf00dafaa786d40c418e 100644 (file)
@@ -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;
 }
index d7110e96693ed06f85877ae7f23b16427a69aa17..4c42f852815a853ce9c039e650176a537c3e7287 100644 (file)
@@ -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)
index 9ef8725c95a69884896610e0d4823952c0bb7f18..c2fb858275fc3a47baf287d9709e90a036c1ad19 100644 (file)
@@ -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);
 }