]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkMeasureLength.cxx
4dfc3d73d51b06e1b3485fe900ced5ccb4e15be1
[bbtk.git] / packages / vtk / src / bbvtkMeasureLength.cxx
1 //===== 
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)
3 //===== 
4 #include "bbvtkMeasureLength.h"
5 #include "bbvtkPackage.h"
6 namespace bbvtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MeasureLength)
10 BBTK_BLACK_BOX_IMPLEMENTATION(MeasureLength,bbtk::AtomicBlackBox);
11 //===== 
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)
13 //===== 
14 void MeasureLength::Process()
15 {
16         std::cout << "RaC MeasureLength::Process START"<< std::endl;
17
18         _points = bbGetInputPoints();
19         _image = bbGetInputImageData();
20
21         double sumLength =0;
22         if(_image != NULL && _points->GetNumberOfPoints()>1)
23         {
24
25                 double spc[3];
26                 double origin[3];
27
28                 _image->GetSpacing(spc);
29                 _image->GetOrigin(origin);
30
31                 double* first;
32                 first = _points->GetPoint(0);
33
34                 double firstWorld[3];
35                 firstWorld[0] = first[0]*spc[0] + origin[0];
36                 firstWorld[1] = first[1]*spc[1] + origin[1];
37                 firstWorld[2] = first[2]*spc[2] + origin[2];
38
39
40
41                 for(int i = 1; i<_points->GetNumberOfPoints();i++)
42                 {
43                         double* second;
44                         second = _points->GetPoint(i);
45                         double secondWorld[3];
46                         secondWorld[0] = second[0]*spc[0] + origin[0];
47                         secondWorld[1] = second[1]*spc[1] + origin[1];
48                         secondWorld[2] = second[2]*spc[2] + origin[2];
49
50                         double XFactor = secondWorld[0]-firstWorld[0];
51                         double YFactor = secondWorld[1]-firstWorld[1];
52                         double ZFactor = secondWorld[2]-firstWorld[2];
53                         sumLength += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
54
55                         firstWorld[0] = secondWorld[0];
56                         firstWorld[1] = secondWorld[1];
57                         firstWorld[2] = secondWorld[2];
58
59                 }
60         }
61
62         bbSetOutputLength(sumLength);
63
64         std::cout << "RaC MeasureLength::Process END"<< std::endl;
65 }
66 //===== 
67 // 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)
68 //===== 
69 void MeasureLength::bbUserSetDefaultValues()
70 {
71         bbSetOutputLength(0);
72 }
73 //===== 
74 // 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)
75 //===== 
76 void MeasureLength::bbUserInitializeProcessing()
77 {
78
79
80
81   
82 }
83 //===== 
84 // 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)
85 //===== 
86 void MeasureLength::bbUserFinalizeProcessing()
87 {
88
89
90   
91 }
92 }
93 // EO namespace bbvtk
94
95