2 // 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)
4 #include "bbvtkMeasureLength.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MeasureLength)
10 BBTK_BLACK_BOX_IMPLEMENTATION(MeasureLength,bbtk::AtomicBlackBox);
12 // 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)
14 void MeasureLength::Process()
16 _points = bbGetInputPoints();
17 _image = bbGetInputImageData();
18 double sumLength = 0 ;
19 double sumLengthVoxels = 0 ;
20 if(_image != NULL && _points->GetNumberOfPoints()>1)
30 _image->GetSpacing(spc);
31 _image->GetOrigin(origin);
38 first = _points->GetPoint(0);
39 firstWorld[0] = first[0]*spc[0] + origin[0];
40 firstWorld[1] = first[1]*spc[1] + origin[1];
41 firstWorld[2] = first[2]*spc[2] + origin[2];
42 for(i = 1; i<_points->GetNumberOfPoints();i++)
45 second = _points->GetPoint(i);
46 double secondWorld[3];
47 secondWorld[0] = second[0]*spc[0] + origin[0];
48 secondWorld[1] = second[1]*spc[1] + origin[1];
49 secondWorld[2] = second[2]*spc[2] + origin[2];
51 XFactor = secondWorld[0]-firstWorld[0];
52 YFactor = secondWorld[1]-firstWorld[1];
53 ZFactor = secondWorld[2]-firstWorld[2];
54 sumLength += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
56 firstWorld[0] = secondWorld[0];
57 firstWorld[1] = secondWorld[1];
58 firstWorld[2] = secondWorld[2];
62 first = _points->GetPoint(0);
63 firstWorld[0] = first[0];
64 firstWorld[1] = first[1];
65 firstWorld[2] = first[2];
66 for(i = 1; i<_points->GetNumberOfPoints();i++)
69 second = _points->GetPoint(i);
70 double secondWorld[3];
71 secondWorld[0] = second[0];
72 secondWorld[1] = second[1];
73 secondWorld[2] = second[2];
75 XFactor = secondWorld[0]-firstWorld[0];
76 YFactor = secondWorld[1]-firstWorld[1];
77 ZFactor = secondWorld[2]-firstWorld[2];
78 sumLengthVoxels += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
80 firstWorld[0] = secondWorld[0];
81 firstWorld[1] = secondWorld[1];
82 firstWorld[2] = secondWorld[2];
86 bbSetOutputLength( sqrt(sumLength) );
87 bbSetOutputLengthVoxels( sqrt(sumLengthVoxels) );
90 // 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)
92 void MeasureLength::bbUserSetDefaultValues()
97 // 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)
99 void MeasureLength::bbUserInitializeProcessing()
107 // 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)
109 void MeasureLength::bbUserFinalizeProcessing()
116 // EO namespace bbvtk