]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkPlanes_ImplicitFunction.cxx
#3525 Python descrition
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkPlanes_ImplicitFunction.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 "bbcreaVtkPlanes_ImplicitFunction.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include <vtkPlane.h>
8
9 namespace bbcreaVtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Planes_ImplicitFunction)
13 BBTK_BLACK_BOX_IMPLEMENTATION(Planes_ImplicitFunction,bbtk::AtomicBlackBox);
14 //===== 
15 // 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)
16 //===== 
17 void Planes_ImplicitFunction::Process()
18 {
19
20 // THE MAIN PROCESSING METHOD BODY
21 //   Here we simply set the input 'In' value to the output 'Out'
22 //   And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 //    void bbSet{Input|Output}NAME(const TYPE&)
25 //    const TYPE& bbGet{Input|Output}NAME() const 
26 //    Where :
27 //    * NAME is the name of the input/output
28 //      (the one provided in the attribute 'name' of the tag 'input')
29 //    * TYPE is the C++ type of the input/output
30 //      (the one provided in the attribute 'type' of the tag 'input')
31 //    bbSetOutputOut( bbGetInputType() );
32 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
33     printf("EED Planes_ImplicitFunction::Process Start \n");
34
35     if (bbGetInputPlanes()!=NULL)
36     {
37         printf("EED Planes_ImplicitFunction::Process Flag 01 \n");
38         int i,size;
39         vtkPlane* p;
40         double tmpDouble[3];
41         std::vector<double> lstPoints;
42         std::vector<double> lstNormals;
43         size = bbGetInputPlanes()->GetNumberOfPlanes();
44
45         
46         if (bbGetInputType()==1)
47         {
48             std::vector<double> points = bbGetInputPointsIn();
49             std::vector<double> normals = bbGetInputNormalsIn();
50             printf("EED Planes_ImplicitFunction::Process size %d     size %d \n",points.size() , normals.size() );
51             if ((points.size() % 3==0) && (normals.size() % 3==0))
52             {
53                 for (i=0;i<size;i++)
54                 {
55                     p = bbGetInputPlanes()->GetPlane(i);
56                     tmpDouble[0] = points[i*3+0] ;
57                     tmpDouble[1] = points[i*3+1] ;
58                     tmpDouble[2] = points[i*3+2] ;
59                     p->SetOrigin(tmpDouble);
60                     tmpDouble[0] = normals[i*3+0] ;
61                     tmpDouble[1] = normals[i*3+1] ;
62                     tmpDouble[2] = normals[i*3+2] ;
63                     p->SetNormal(tmpDouble);
64                     p->Modified();
65                     printf("EED Planes_ImplicitFunction::Process normals %f %f %f \n", tmpDouble[0], tmpDouble[1], tmpDouble[2]);
66                 } // for i
67             }
68         } // Type ==1
69         
70         if (bbGetInputType()==2)
71         {
72             for (i=0;i<size;i++)
73             {
74                 p = bbGetInputPlanes()->GetPlane(i);
75                 lstPoints.push_back( p->GetOrigin()[0] );
76                 lstPoints.push_back( p->GetOrigin()[1] );
77                 lstPoints.push_back( p->GetOrigin()[2] );
78                 lstNormals.push_back( p->GetNormal()[0] );
79                 lstNormals.push_back( p->GetNormal()[1] );
80                 lstNormals.push_back( p->GetNormal()[2] );
81             } // for i
82             bbSetOutputPointsOut(lstPoints);
83             bbSetOutputNormalsOut(lstNormals);
84         } // Type ==2
85     }// Planes
86     printf("EED Planes_ImplicitFunction::Process End \n");
87
88 }
89 //===== 
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)
91 //===== 
92 void Planes_ImplicitFunction::bbUserSetDefaultValues()
93 {
94
95 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
96 //    Here we initialize the input 'In' to 0
97     bbSetInputType(0);
98     bbSetInputPlanes(NULL);
99
100 }
101 //===== 
102 // 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)
103 //===== 
104 void Planes_ImplicitFunction::bbUserInitializeProcessing()
105 {
106
107 //  THE INITIALIZATION METHOD BODY :
108 //    Here does nothing 
109 //    but this is where you should allocate the internal/output pointers 
110 //    if any 
111
112   
113 }
114 //===== 
115 // 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)
116 //===== 
117 void Planes_ImplicitFunction::bbUserFinalizeProcessing()
118 {
119
120 //  THE FINALIZATION METHOD BODY :
121 //    Here does nothing 
122 //    but this is where you should desallocate the internal/output pointers 
123 //    if any
124   
125 }
126 }
127 // EO namespace bbcreaVtk
128
129