]> Creatis software - creaVtk.git/commitdiff
#3466 ApplyTransformToPoint3D box
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 7 Jul 2021 15:15:25 +0000 (17:15 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 7 Jul 2021 15:15:25 +0000 (17:15 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.h [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.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
+
+
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.h b/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.h
new file mode 100644 (file)
index 0000000..fb5b70b
--- /dev/null
@@ -0,0 +1,56 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbcreaVtkApplyTransformToPoint3D_h_INCLUDED__
+#define __bbcreaVtkApplyTransformToPoint3D_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+#include "vtkLinearTransform.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT ApplyTransformToPoint3D
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(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)
+//===== 
+  BBTK_DECLARE_INPUT(Point,std::vector<double>);
+  BBTK_DECLARE_INPUT(DirectionInPoint,std::vector<double>);
+  BBTK_DECLARE_INPUT(Transform,vtkLinearTransform*);
+  BBTK_DECLARE_OUTPUT(Out,std::vector<double>);
+  BBTK_DECLARE_OUTPUT(OutDirection,std::vector<double>);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// 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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ApplyTransformToPoint3D,bbtk::AtomicBlackBox);
+  BBTK_NAME("ApplyTransformToPoint3D");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+  
+  BBTK_INPUT(ApplyTransformToPoint3D,Point,"(default [0,0,0]) Point 3D [x,y,z]",std::vector<double>,"");
+  BBTK_INPUT(ApplyTransformToPoint3D,DirectionInPoint,"(default [0,0,1]) Direction from point [x,y,z]",std::vector<double>,"");
+  BBTK_INPUT(ApplyTransformToPoint3D,Transform,"vtkLinearTransform",vtkLinearTransform*,"");
+  
+  BBTK_OUTPUT(ApplyTransformToPoint3D,Out,"Point 3D [x,y,z] after Transform ",std::vector<double>,"");
+  BBTK_OUTPUT(ApplyTransformToPoint3D,OutDirection,"Direction 3D [x,y,z] after Transform",std::vector<double>,"");
+  
+BBTK_END_DESCRIBE_BLACK_BOX(ApplyTransformToPoint3D);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbcreaVtk
+
+#endif // __bbcreaVtkApplyTransformToPoint3D_h_INCLUDED__
+
index 53fabde34efcf3809e5d98fec255e9b45368432d..cc7fd5ff4cd7920c6ba9be069daf763c8e0110b0 100644 (file)
@@ -31,17 +31,18 @@ void Plane::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
 
+       printf("EED Plane::Process Start\n ");
        vtkPlane        *plane = NULL;
-  
     if ( (bbGetInputOrigin().size()==3) && (bbGetInputNormal().size()==3) ) 
     {
                plane  = vtkPlane::New();
                plane->SetOrigin( bbGetInputOrigin()[0],bbGetInputOrigin()[1],bbGetInputOrigin()[2] );
                plane->SetNormal( bbGetInputNormal()[0], bbGetInputNormal()[1], bbGetInputNormal()[2] );
+               printf("EED Plane::Process Origin = %f  %f  %f\n",bbGetInputOrigin()[0],bbGetInputOrigin()[1],bbGetInputOrigin()[2]  );
+               printf("EED Plane::Process Normal = %f  %f  %f\n",bbGetInputNormal()[0],bbGetInputNormal()[1],bbGetInputNormal()[2]  );
     } 
-    
        bbSetOutputOut( plane );        
-  
+       printf("EED Plane::Process End\n ");
 }
 
 //===== 
index 14fbab9bfda5af9bd247658e82eeb9713deebc54..91f5a49d2d890a7937fac69906accbf316c72f21 100644 (file)
@@ -29,11 +29,14 @@ void PlaneSource::Process()
        p0[1]   =       0;
        p0[2]   =       0;
 
+
+       bool byNormal=true;     
        double size=350;
 
        // xy
        if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==1)  ) 
        {
+               byNormal=       false;
                p1[0]   =       size;   
                p1[1]   =       0;
                p1[2]   =       0;    
@@ -45,6 +48,7 @@ void PlaneSource::Process()
        // xz
        if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==1) && (bbGetInputNormal()[2]==0)  ) 
        {
+               byNormal=       false;
                p1[0]   =       size;   
                p1[1]   =       0;
                p1[2]   =       0;    
@@ -56,6 +60,7 @@ void PlaneSource::Process()
        // yz
        if ((bbGetInputNormal()[0]==1) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==0)  ) 
        {
+               byNormal=       false;
                p1[0]   =       0;      
                p1[1]   =       size;
                p1[2]   =       0;    
@@ -64,24 +69,18 @@ void PlaneSource::Process()
                p2[2]   =       size;
        }
 
-
-
-/*
-               p1[0]   =       100;    
-               p1[1]   =       0;
-               p1[2]   =       0;    
-               p2[0]   =       0;
-               p2[1]   =       100;
-               p2[2]   =       0;
-*/
                plane->SetResolution( bbGetInputXResolution(), bbGetInputYResolution() );
-               plane->SetOrigin( p0 );
-               plane->SetPoint1( p1 );
-               plane->SetPoint2( p2 );
-//             plane->Update( );
-               plane->SetNormal( bbGetInputNormal()[0], bbGetInputNormal()[1], bbGetInputNormal()[2] );
-//             plane->Update( );
-               plane->SetCenter( c );
+               if (byNormal==false)
+               {
+                       plane->SetOrigin( p0 );         
+                       plane->SetPoint1( p1 );
+                       plane->SetPoint2( p2 );
+               } else {
+                       plane->SetNormal( bbGetInputNormal()[0], bbGetInputNormal()[1], bbGetInputNormal()[2] );
+                       printf("EED PlaneSource. Missing mechanism to define the size of the plane\n");
+               }
+                       plane->SetCenter( c );
+
                plane->Update( );
     bbSetOutputPlane( (vtkDataSet*)plane );
     bbSetOutputPolyData( plane->GetOutput() );