From c4879112fd85619dc824d3ae163d65fd0b59ecf9 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 7 Jul 2021 17:15:25 +0200 Subject: [PATCH] #3466 ApplyTransformToPoint3D box --- .../src/bbcreaVtkApplyTransformToPoint3D.cxx | 111 ++++++++++++++++++ .../src/bbcreaVtkApplyTransformToPoint3D.h | 56 +++++++++ bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx | 7 +- bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx | 33 +++--- 4 files changed, 187 insertions(+), 20 deletions(-) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx new file mode 100644 index 0000000..ae04772 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx @@ -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 = " <TransformPoint( point,newPoint ); + std::vector 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 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 point; + point.push_back(0); + point.push_back(0); + point.push_back(0); + bbSetInputPoint( point ); + std::vector 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 index 0000000..fb5b70b --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.h @@ -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); + BBTK_DECLARE_INPUT(DirectionInPoint,std::vector); + BBTK_DECLARE_INPUT(Transform,vtkLinearTransform*); + BBTK_DECLARE_OUTPUT(Out,std::vector); + BBTK_DECLARE_OUTPUT(OutDirection,std::vector); + 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,""); + BBTK_INPUT(ApplyTransformToPoint3D,DirectionInPoint,"(default [0,0,1]) Direction from point [x,y,z]",std::vector,""); + BBTK_INPUT(ApplyTransformToPoint3D,Transform,"vtkLinearTransform",vtkLinearTransform*,""); + + BBTK_OUTPUT(ApplyTransformToPoint3D,Out,"Point 3D [x,y,z] after Transform ",std::vector,""); + BBTK_OUTPUT(ApplyTransformToPoint3D,OutDirection,"Direction 3D [x,y,z] after Transform",std::vector,""); + +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__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx index 53fabde..cc7fd5f 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlane.cxx @@ -31,17 +31,18 @@ void Plane::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <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 "); } //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx index 14fbab9..91f5a49 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx @@ -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() ); -- 2.45.1