]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx
#3466 ApplyTransformToPoint3D box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkApplyTransformToPoint3D.cxx
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx
new file mode 100644 (file)
index 0000000..ae04772
--- /dev/null
@@ -0,0 +1,111 @@
+//===== 
+// 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 "bbcreaVtkApplyTransformToPoint3D.h"
+#include "bbcreaVtkPackage.h"
+#include "vtkTransform.h"
+
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyTransformToPoint3D)
+BBTK_BLACK_BOX_IMPLEMENTATION(ApplyTransformToPoint3D,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 ApplyTransformToPoint3D::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( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+
+       printf("EED ApplyTransformToPoint3D::Process Start\n ");
+
+       if ((bbGetInputPoint().size()==3) && (bbGetInputDirectionInPoint().size()==3) )
+       {
+               double point[3] , newPoint[3];
+               point[0] = bbGetInputPoint()[0];
+               point[1] = bbGetInputPoint()[1];
+               point[2] = bbGetInputPoint()[2];
+               bbGetInputTransform()->TransformPoint( point,newPoint );
+               std::vector<double> out;
+               out.push_back( newPoint[0] );
+               out.push_back( newPoint[1] );
+               out.push_back( newPoint[2] );
+               bbSetOutputOut( out );
+               
+               double pointDir[3] , newPointDir[3];
+               pointDir[0] = bbGetInputPoint()[0]+bbGetInputDirectionInPoint()[0];
+               pointDir[1] = bbGetInputPoint()[1]+bbGetInputDirectionInPoint()[1];
+               pointDir[2] = bbGetInputPoint()[2]+bbGetInputDirectionInPoint()[2];
+               bbGetInputTransform()->TransformPoint( pointDir,newPointDir );
+               std::vector<double> outDir;
+               outDir.push_back( newPointDir[0]-newPoint[0] );
+               outDir.push_back( newPointDir[1]-newPoint[1] );
+               outDir.push_back( newPointDir[2]-newPoint[2] );
+               bbSetOutputOutDirection( outDir );
+       } else {
+               printf("EED Warning!  ApplyTransformToPoint3D::Process  Incoherent sizes  Point(3)=%d  DirectionInPoint(3)=%d\n", bbGetInputPoint().size(),bbGetInputDirectionInPoint().size() );
+       }// if Point size
+       printf("EED ApplyTransformToPoint3D::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 ApplyTransformToPoint3D::bbUserSetDefaultValues()
+{
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+
+   std::vector<double> point;
+   point.push_back(0);
+   point.push_back(0);
+   point.push_back(0);
+   bbSetInputPoint( point ); 
+   std::vector<double> dir;
+   dir.push_back(0);
+   dir.push_back(0);
+   dir.push_back(1);
+   bbSetInputDirectionInPoint( dir ); 
+   bbSetInputTransform(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 ApplyTransformToPoint3D::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 ApplyTransformToPoint3D::bbUserFinalizeProcessing()
+{
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any 
+}
+
+} // EO namespace bbcreaVtk
+
+