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 "bbcreaVtkPointPickerNearest.h"
5 #include "bbcreaVtkPackage.h"
8 #include <vtkPointData.h>
9 #include <vtkDataArray.h>
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PointPickerNearest)
15 BBTK_BLACK_BOX_IMPLEMENTATION(PointPickerNearest,bbtk::AtomicBlackBox);
17 // 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)
19 void PointPickerNearest::Process()
22 // THE MAIN PROCESSING METHOD BODY
23 // Here we simply set the input 'In' value to the output 'Out'
24 // And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 // void bbSet{Input|Output}NAME(const TYPE&)
27 // const TYPE& bbGet{Input|Output}NAME() const
29 // * NAME is the name of the input/output
30 // (the one provided in the attribute 'name' of the tag 'input')
31 // * TYPE is the C++ type of the input/output
32 // (the one provided in the attribute 'type' of the tag 'input')
34 printf ("EED PointPickerNearest::Process Start\n");
36 std::vector<double> lstNormal;
37 std::vector<double> refPoint = bbGetInputPoint();
39 printf ("EED PointPickerNearest::Process 1\n");
41 if ((bbGetInputActive()==true) && ( bbGetInputMesh()!=NULL) && (refPoint.size()==3) )
45 double minBack=100000000;
48 vtkPoints *points = bbGetInputMesh()->GetPoints();
49 long size = points->GetNumberOfPoints();
50 double border = bbGetInputBorder() * bbGetInputBorder();
51 printf ("EED PointPickerNearest::Process 2\n");
52 for ( i=0 ; i<size ; i++)
54 points->GetPoint(i,p);
55 dx = p[0]-refPoint[0];
56 dy = p[1]-refPoint[1];
57 dz = p[2]-refPoint[2];
58 min = dx*dx + dy*dy + dz*dz;
68 printf ("EED PointPickerNearest::Process 3\n");
71 vtkPointData *pointdata = bbGetInputMesh()->GetPointData();
72 vtkDataArray *dataarray;
75 int i,size=pointdata->GetNumberOfArrays();
78 dataarray=pointdata->GetArray(i);
79 printf("EED creaVtkCallbackPointPicker::Execute dataarray=%s n=%ld p=%ld\n", dataarray->GetName(),dataarray->GetNumberOfValues() ,polydata->GetNumberOfPoints() );
82 printf ("EED PointPickerNearest::Process 4\n");
83 dataarray = pointdata->GetNormals();
86 pValue = dataarray->GetTuple3( iBack );
87 printf ("EED PointPickerNearest::Process 5\n");
88 lstNormal.push_back(pValue[0]);
89 lstNormal.push_back(pValue[1]);
90 lstNormal.push_back(pValue[2]);
93 bbSetOutputPointId( iBack );
94 bbSetOutputNormal( lstNormal );
95 printf ("EED PointPickerNearest::Process 6 %ld\n", iBack);
96 std::vector<double> lstPointOut;
98 points->GetPoint(iBack,p);
99 lstPointOut.push_back(p[0]);
100 lstPointOut.push_back(p[1]);
101 lstPointOut.push_back(p[2]);
102 printf ("EED PointPickerNearest::Process 7 pointOut=%f %f %f\n", lstPointOut[0],lstPointOut[1],lstPointOut[2]);
104 bbSetOutputPointOut( lstPointOut );
106 bbSetOutputPointId( -1 );
107 lstNormal.push_back(0);
108 lstNormal.push_back(1);
109 lstNormal.push_back(2);
110 bbSetOutputNormal( lstNormal );
111 bbSetOutputPointOut( bbGetInputPoint() );
114 printf ("EED PointPickerNearest::Process END\n");
118 // 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)
120 void PointPickerNearest::bbUserSetDefaultValues()
123 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
124 // Here we initialize the input 'In' to 0
125 bbSetInputActive(false);
126 bbSetInputMesh(NULL);
130 // 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)
132 void PointPickerNearest::bbUserInitializeProcessing()
135 // THE INITIALIZATION METHOD BODY :
137 // but this is where you should allocate the internal/output pointers
143 // 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)
145 void PointPickerNearest::bbUserFinalizeProcessing()
148 // THE FINALIZATION METHOD BODY :
150 // but this is where you should desallocate the internal/output pointers
155 // EO namespace bbcreaVtk