#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 )
{
sh->AddFileName(*it);
}
+
GDCM_NAME_SPACE::FileList::const_iterator it;
GDCM_NAME_SPACE::FileList *l;
//reader->SetFileName( bbGetInputIn().c_str() );
reader->SetCoherentFileList(l);
reader->Update();
- reader->GetOutput();
-
bbSetOutputOut( reader->GetOutput() );
}
#endif
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() )
{
//=====
void ExtractVtkImageFilter::Process()
{
-printf("EED ExtractVtkImageFilter::Process Start\n");
int voi[6];
voi[0] = bbGetInputIndex()[0];
_extract->Modified();
_extract->Update();
bbSetOutputOut(_extract->GetOutput());
-printf("EED ExtractVtkImageFilter::Process End\n");
}
//=====
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);
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;
}
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:
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)
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);
}