]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkPlanes_ImplicitFunction.cxx
#3524 BoxWidget_tool Box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkPlanes_ImplicitFunction.cxx
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlanes_ImplicitFunction.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlanes_ImplicitFunction.cxx
new file mode 100644 (file)
index 0000000..e4b71bb
--- /dev/null
@@ -0,0 +1,129 @@
+//===== 
+// 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)
+//===== 
+#include "bbcreaVtkPlanes_ImplicitFunction.h"
+#include "bbcreaVtkPackage.h"
+
+#include <vtkPlane.h>
+
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Planes_ImplicitFunction)
+BBTK_BLACK_BOX_IMPLEMENTATION(Planes_ImplicitFunction,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+void Planes_ImplicitFunction::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+//    bbSetOutputOut( bbGetInputType() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+    printf("EED Planes_ImplicitFunction::Process Start \n");
+
+    if (bbGetInputPlanes()!=NULL)
+    {
+        printf("EED Planes_ImplicitFunction::Process Flag 01 \n");
+        int i,size;
+        vtkPlane* p;
+        double tmpDouble[3];
+        std::vector<double> lstPoints;
+        std::vector<double> lstNormals;
+        size = bbGetInputPlanes()->GetNumberOfPlanes();
+
+        
+        if (bbGetInputType()==1)
+        {
+            std::vector<double> points = bbGetInputPointsIn();
+            std::vector<double> normals = bbGetInputNormalsIn();
+            printf("EED Planes_ImplicitFunction::Process size %d     size %d \n",points.size() , normals.size() );
+            if ((points.size() % 3==0) && (normals.size() % 3==0))
+            {
+                for (i=0;i<size;i++)
+                {
+                    p = bbGetInputPlanes()->GetPlane(i);
+                    tmpDouble[0] = points[i*3+0] ;
+                    tmpDouble[1] = points[i*3+1] ;
+                    tmpDouble[2] = points[i*3+2] ;
+                    p->SetOrigin(tmpDouble);
+                    tmpDouble[0] = normals[i*3+0] ;
+                    tmpDouble[1] = normals[i*3+1] ;
+                    tmpDouble[2] = normals[i*3+2] ;
+                    p->SetNormal(tmpDouble);
+                    p->Modified();
+                    printf("EED Planes_ImplicitFunction::Process normals %f %f %f \n", tmpDouble[0], tmpDouble[1], tmpDouble[2]);
+                } // for i
+            }
+        } // Type ==1
+        
+        if (bbGetInputType()==2)
+        {
+            for (i=0;i<size;i++)
+            {
+                p = bbGetInputPlanes()->GetPlane(i);
+                lstPoints.push_back( p->GetOrigin()[0] );
+                lstPoints.push_back( p->GetOrigin()[1] );
+                lstPoints.push_back( p->GetOrigin()[2] );
+                lstNormals.push_back( p->GetNormal()[0] );
+                lstNormals.push_back( p->GetNormal()[1] );
+                lstNormals.push_back( p->GetNormal()[2] );
+            } // for i
+            bbSetOutputPointsOut(lstPoints);
+            bbSetOutputNormalsOut(lstNormals);
+        } // Type ==2
+    }// Planes
+    printf("EED Planes_ImplicitFunction::Process End \n");
+
+}
+//===== 
+// 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)
+//===== 
+void Planes_ImplicitFunction::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+    bbSetInputType(0);
+    bbSetInputPlanes(NULL);
+
+}
+//===== 
+// 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)
+//===== 
+void Planes_ImplicitFunction::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// 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)
+//===== 
+void Planes_ImplicitFunction::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaVtk
+
+