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 std::cout << "RaC MeasureLength::Process START"<< std::endl;
18 _points = bbGetInputPoints();
19 _image = bbGetInputImageData();
21 double sumLength = 0 ;
22 double sumLengthVoxels = 0 ;
23 if(_image != NULL && _points->GetNumberOfPoints()>1)
33 _image->GetSpacing(spc);
34 _image->GetOrigin(origin);
41 first = _points->GetPoint(0);
42 firstWorld[0] = first[0]*spc[0] + origin[0];
43 firstWorld[1] = first[1]*spc[1] + origin[1];
44 firstWorld[2] = first[2]*spc[2] + origin[2];
45 for(i = 1; i<_points->GetNumberOfPoints();i++)
48 second = _points->GetPoint(i);
49 double secondWorld[3];
50 secondWorld[0] = second[0]*spc[0] + origin[0];
51 secondWorld[1] = second[1]*spc[1] + origin[1];
52 secondWorld[2] = second[2]*spc[2] + origin[2];
54 XFactor = secondWorld[0]-firstWorld[0];
55 YFactor = secondWorld[1]-firstWorld[1];
56 ZFactor = secondWorld[2]-firstWorld[2];
57 sumLength += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
59 firstWorld[0] = secondWorld[0];
60 firstWorld[1] = secondWorld[1];
61 firstWorld[2] = secondWorld[2];
65 first = _points->GetPoint(0);
66 firstWorld[0] = first[0];
67 firstWorld[1] = first[1];
68 firstWorld[2] = first[2];
69 for(i = 1; i<_points->GetNumberOfPoints();i++)
72 second = _points->GetPoint(i);
73 double secondWorld[3];
74 secondWorld[0] = second[0];
75 secondWorld[1] = second[1];
76 secondWorld[2] = second[2];
78 XFactor = secondWorld[0]-firstWorld[0];
79 YFactor = secondWorld[1]-firstWorld[1];
80 ZFactor = secondWorld[2]-firstWorld[2];
81 sumLengthVoxels += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
83 firstWorld[0] = secondWorld[0];
84 firstWorld[1] = secondWorld[1];
85 firstWorld[2] = secondWorld[2];
90 bbSetOutputLength( sqrt(sumLength) );
91 bbSetOutputLengthVoxels( sqrt(sumLengthVoxels) );
93 std::cout << "RaC MeasureLength::Process END"<< std::endl;
96 // 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)
98 void MeasureLength::bbUserSetDefaultValues()
100 bbSetOutputLength(0);
103 // 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)
105 void MeasureLength::bbUserInitializeProcessing()
113 // 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)
115 void MeasureLength::bbUserFinalizeProcessing()
122 // EO namespace bbvtk