From: Eduardo DAVILA Date: Wed, 13 Jun 2018 12:24:41 +0000 (+0200) Subject: 3195 creaVtk Feature New Normal - new Boxes ImageCutByAxis LightKit MeshCutByAxis X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d4d007ec0086a1145c20e922e87e0fee1b2f12d8;p=creaVtk.git 3195 creaVtk Feature New Normal - new Boxes ImageCutByAxis LightKit MeshCutByAxis --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.cxx new file mode 100644 index 0000000..2860baa --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.cxx @@ -0,0 +1,163 @@ +//===== +// 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 "bbcreaVtkImageCutByAxis.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageCutByAxis) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageCutByAxis,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 ImageCutByAxis::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 = " <DeepCopy( bbGetInputIn() ); + + int ext[6]; + bbGetInputIn()->GetWholeExtent(ext); + double dimX=ext[1]-ext[0]+1; + double dimY=ext[3]-ext[2]+1; + double dimZ=ext[5]-ext[4]+1; + + int x=bbGetInputPoint()[0]; + int y=bbGetInputPoint()[1]; + int z=bbGetInputPoint()[2]; + + int i,j; + bool c1=false; + bool c2=false; + bool c3=false; + bool c4=false; + + if ( bbGetInputType()=="x-y-z+" ) + { + if (bbGetInputTypeOrientation()==0) { c1=false; c2=true; c3=true; c4=true; } + if (bbGetInputTypeOrientation()==1) { c1=true; c2=false; c3=true; c4=true; } + if (bbGetInputTypeOrientation()==2) { c1=true; c2=false; c3=true; c4=true; } + } + + if (bbGetInputInsideVol()==true) + { + c1=!c1; + c2=!c2; + c3=!c3; + c4=!c4; + } // IndideVol + + + int xmin,xmax,ymin,ymax; + +// void *imgPtr; +// imgPtr=bbGetInputIn()->GetScalarPointer(x,y,z,0); +// memset( bbGetInputIn()->GetScalarPointer() ); + + if (c1==true) + { + if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=0; ymax=y; } + if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY; } + if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY; } + for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i + } // for j + } // c1 + + if (c2==true) + { + if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=y; ymax=dimY; } + if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=0; ymax=dimY-z; } + if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=0; ymax=dimY-z; } + for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i + } // for j + } //c2 + + if (c3==true) + { + if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=0; ymax=y; } + if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=dimY-z; ymax=dimY; } + if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=dimY-z; ymax=dimY; } + for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i + } // for j + } //c3 + + if (c4==true) + { + if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=y; ymax=dimY; } + if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=0; ymax=dimY-z; } + if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=0; ymax=dimY-z; } + for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i + } // for j + + } //c4 + + bbSetOutputOut( newData ); + +} +//===== +// 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 ImageCutByAxis::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + bbSetInputType("x+y+z+"); + bbSetInputInsideVol(true); + std::vector point; + point.push_back(0); + point.push_back(0); + point.push_back(0); + bbSetInputPoint(point); +} +//===== +// 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 ImageCutByAxis::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 ImageCutByAxis::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/bbcreaVtkImageCutByAxis.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.h new file mode 100644 index 0000000..1cf7640 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageCutByAxis.h @@ -0,0 +1,54 @@ +//===== +// 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 __bbcreaVtkImageCutByAxis_h_INCLUDED__ +#define __bbcreaVtkImageCutByAxis_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageCutByAxis + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageCutByAxis,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(In,vtkImageData*); + BBTK_DECLARE_INPUT(InsideVol,bool); + BBTK_DECLARE_INPUT(Point,std::vector); + BBTK_DECLARE_INPUT(Type,std::string); + BBTK_DECLARE_INPUT(TypeOrientation,int); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + 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(ImageCutByAxis,bbtk::AtomicBlackBox); + BBTK_NAME("ImageCutByAxis"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ImageCutByAxis,In,"Input image",vtkImageData*,""); + BBTK_INPUT(ImageCutByAxis,Type,"x y z x+y+ x-y+ x+y- x-y- y+z+ y+z- y-z+ y-z- x+z+ x+z- x-z+ x-z- x+y+z+ x-y+z+ x+y-z+ x+y+z- x-y-z+ x-y+z- x+y-z- x-y-z-",std::string,""); + BBTK_INPUT(ImageCutByAxis,InsideVol,"Inside volume",bool,""); + BBTK_INPUT(ImageCutByAxis,Point,"First input",std::vector,""); + BBTK_INPUT(ImageCutByAxis,TypeOrientation,"TypeOrientation (default 0) 0=XY 1=XZ 2=YZ",int,""); + BBTK_OUTPUT(ImageCutByAxis,Out,"Output image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageCutByAxis); +//===== +// 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 // __bbcreaVtkImageCutByAxis_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkLightKit.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkLightKit.cxx new file mode 100644 index 0000000..e4d1ea5 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkLightKit.cxx @@ -0,0 +1,94 @@ +//===== +// 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 "bbcreaVtkLightKit.h" +#include "bbcreaVtkPackage.h" + +//#include +#include +#include + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,LightKit) +BBTK_BLACK_BOX_IMPLEMENTATION(LightKit,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 LightKit::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 = " <GetLights(); + std::cout << "Now there are " << originalLights->GetNumberOfItems() << " lights." << std::endl; + + if (firsttime==true) + { + firsttime=false; + bbGetInputRenderer()->RemoveAllLights(); + vtkLightKit *lightKit=vtkLightKit::New(); + //bbGetInputRenderer()->SetTwoSidedLighting(0); + lightKit->SetKeyLightWarmth( bbGetInputKeyLightWarmth() ); + lightKit->SetFillLightWarmth( bbSetInputFillLightWarmth() ); + lightKit->SetBackLightWarmth( bbSetInputBackLightWarmth() ); + lightKit->AddLightsToRenderer( bbGetInputRenderer() ); + } + +} +//===== +// 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 LightKit::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputRenderer(NULL); + bbSetInputKeyLightWarmth(0.8); + bbSetInputFillLightWarmth(5.0); + bbSetInputBackLightWarmth(0.5); +} +//===== +// 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 LightKit::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 LightKit::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/bbcreaVtkLightKit.h b/bbtk_creaVtk_PKG/src/bbcreaVtkLightKit.h new file mode 100644 index 0000000..145f260 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkLightKit.h @@ -0,0 +1,53 @@ +//===== +// 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 __bbcreaVtkLightKit_h_INCLUDED__ +#define __bbcreaVtkLightKit_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT LightKit + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(LightKit,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(KeyLightWarmth,double); + BBTK_DECLARE_INPUT(FillLightWarmth,double); + BBTK_DECLARE_INPUT(BackLightWarmth,double); + BBTK_DECLARE_INPUT(Renderer,vtkRenderer *); +( +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + bool firsttime; + +//===== +// 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(LightKit,bbtk::AtomicBlackBox); + BBTK_NAME("LightKit"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(LightKit,Renderer,"3D scene in which to insert the surface",vtkRenderer*,""); +// BBTK_OUTPUT(LightKit,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(LightKit); +//===== +// 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 // __bbcreaVtkLightKit_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.cxx new file mode 100644 index 0000000..111efb5 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.cxx @@ -0,0 +1,143 @@ +//===== +// 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 "bbcreaVtkMeshCutByAxis.h" +#include "bbcreaVtkPackage.h" + +#include +#include +#include + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MeshCutByAxis) +BBTK_BLACK_BOX_IMPLEMENTATION(MeshCutByAxis,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 MeshCutByAxis::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 = " < SetInput( bbGetInputIn() ); + clipper->SetInsideOut( bbGetInputInsideVol() ); + + int a; // correction border + if (bbGetInputInsideVol()==false) + { + a=1; + } else { + a=0; + } + + int px=bbGetInputPoint()[0]; + int py=bbGetInputPoint()[1]; + int pz=bbGetInputPoint()[2]; + + if ( bbGetInputType()=="x" ) { clipPlane->SetNormal(1, 0, 0); ok=1; } else + if ( bbGetInputType()=="y" ) { clipPlane->SetNormal(0, 1, 0); ok=1; } else + if ( bbGetInputType()=="z" ) { clipPlane->SetNormal(0, 0, 1); ok=1; } else + + if ( bbGetInputType()=="x+y+" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz-sb ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x-y+" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz-sb ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x+y-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz-sb ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x-y-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz-sb ,pz+sb ); ok=2; } else + + if ( bbGetInputType()=="y+z+" ) { clipBox->SetBounds(px-sb,px+sb ,py ,py+sb ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="y-z+" ) { clipBox->SetBounds(px-sb,px+sb ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="y+z-" ) { clipBox->SetBounds(px-sb,px+sb ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else + if ( bbGetInputType()=="y-z-" ) { clipBox->SetBounds(px-sb,px+sb ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; } else + + if ( bbGetInputType()=="x+z+" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+sb ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x-z+" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+sb ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x+z-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+sb ,pz-sb ,pz+a ); ok=2; } else + if ( bbGetInputType()=="x-z-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+sb ,pz-sb ,pz+a ); ok=2; } else + + + if ( bbGetInputType()=="x+y+z+" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x-y+z+" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x+y-z+" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x+y+z-" ) { clipBox->SetBounds(px ,px+sb ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else + if ( bbGetInputType()=="x-y-z+" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz ,pz+sb ); ok=2; } else + if ( bbGetInputType()=="x+y-z-" ) { clipBox->SetBounds(px ,px+sb ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; } else + if ( bbGetInputType()=="x-y+z-" ) { clipBox->SetBounds(px-sb,px+a ,py ,py+sb ,pz-sb ,pz+a ); ok=2; } else + if ( bbGetInputType()=="x-y-z-" ) { clipBox->SetBounds(px-sb,px+a ,py-sb ,py+a ,pz-sb ,pz+a ); ok=2; } + + if (ok==1) { + clipPlane -> SetOrigin(px,py,pz); + clipper -> SetClipFunction(clipPlane); + bbSetOutputOut( clipper->GetOutput() ); + } else if (ok==2) { + + clipper -> SetClipFunction(clipBox); + bbSetOutputOut( clipper->GetOutput() ); + } else { + bbSetOutputOut( bbGetInputIn() ); + } // ok +} +//===== +// 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 MeshCutByAxis::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + bbSetInputType("x+y+z+"); + bbSetInputInsideVol(true); + std::vector point; + point.push_back(0); + point.push_back(0); + point.push_back(0); + bbSetInputPoint(point); +} +//===== +// 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 MeshCutByAxis::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 MeshCutByAxis::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/bbcreaVtkMeshCutByAxis.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.h new file mode 100644 index 0000000..23cf4cb --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshCutByAxis.h @@ -0,0 +1,52 @@ +//===== +// 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 __bbcreaVtkMeshCutByAxis_h_INCLUDED__ +#define __bbcreaVtkMeshCutByAxis_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT MeshCutByAxis + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(MeshCutByAxis,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(In,vtkPolyData*); + BBTK_DECLARE_INPUT(Type,std::string); + BBTK_DECLARE_INPUT(InsideVol,bool); + BBTK_DECLARE_INPUT(Point,std::vector); + BBTK_DECLARE_OUTPUT(Out,vtkPolyData*); + 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(MeshCutByAxis,bbtk::AtomicBlackBox); + BBTK_NAME("MeshCutByAxis"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("MeshCutByAxis"); + BBTK_CATEGORY("empty"); + BBTK_INPUT(MeshCutByAxis,In,"Mesh to be cut",vtkPolyData*,""); + BBTK_INPUT(MeshCutByAxis,Type,"x y z x+y+ x-y+ x+y- x-y- y+z+ y+z- y-z+ y-z- x+z+ x+z- x-z+ x-z- x+y+z+ x-y+z+ x+y-z+ x+y+z- x-y-z+ x-y+z- x+y-z- x-y-z-",std::string,""); + BBTK_INPUT(MeshCutByAxis,InsideVol,"Inside volume",bool,""); + BBTK_INPUT(MeshCutByAxis,Point,"First input",std::vector,""); + BBTK_OUTPUT(MeshCutByAxis,Out,"First output",vtkPolyData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(MeshCutByAxis); +//===== +// 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 // __bbcreaVtkMeshCutByAxis_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx index ff09f5d..2f8b50d 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx @@ -24,18 +24,18 @@ void PlaneSource::Process() p0[2]=0; double p1[3]; p1[0]=0; - p1[1]=0; + p1[1]=1; p1[2]=0; double p2[3]; p2[0]=0; p2[1]=0; - p2[2]=0; + p2[2]=1; double c[3]; c[0]=bbGetInputCenter()[0]; c[1]=bbGetInputCenter()[1]; c[2]=bbGetInputCenter()[2]; - plane->SetResolution( 100, 100); + plane->SetResolution( bbGetInputXResolution(), bbGetInputYResolution() ); plane->SetOrigin( p0 ); plane->SetPoint1( p1 ); plane->SetPoint2( p2 ); @@ -45,15 +45,26 @@ void PlaneSource::Process() plane->SetCenter( c ); plane->Update( ); bbSetOutputPlane( (vtkDataSet*)plane ); - std::cout << "CFT End of Process() CFT" << std::endl; - + bbSetOutputPolyData( plane->GetOutput() ); + } //===== // 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 PlaneSource::bbUserSetDefaultValues() { - + std::vector c; + std::vector n; + c.push_back(0); + c.push_back(0); + c.push_back(0); + n.push_back(1); + n.push_back(0); + n.push_back(0); + bbSetInputCenter(c); + bbSetInputNormal(n); + bbSetInputXResolution(100); + bbSetInputYResolution(100); } //===== // 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h index 1461d07..2646c9b 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h @@ -8,6 +8,7 @@ #include "iostream" #include "vtkPlaneSource.h" #include "vtkDataSet.h" +#include "vtkPolyData.h" namespace bbcreaVtk { @@ -21,8 +22,11 @@ class bbcreaVtk_EXPORT PlaneSource // 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(Center,std::vector); - BBTK_DECLARE_INPUT(Normal,std::vector); + BBTK_DECLARE_INPUT(Normal,std::vector); + BBTK_DECLARE_INPUT(XResolution,int); + BBTK_DECLARE_INPUT(YResolution,int); BBTK_DECLARE_OUTPUT(Plane,vtkDataSet*); + BBTK_DECLARE_OUTPUT(PolyData,vtkPolyData*); BBTK_PROCESS(Process); void Process(); //===== @@ -31,13 +35,16 @@ class bbcreaVtk_EXPORT PlaneSource }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneSource,bbtk::AtomicBlackBox); -BBTK_NAME("PlaneSource"); -BBTK_AUTHOR("carlos torres"); -BBTK_DESCRIPTION("No Description."); -BBTK_CATEGORY("empty"); -BBTK_INPUT(PlaneSource,Center,"Center",std::vector,""); -BBTK_INPUT(PlaneSource,Normal,"Normal",std::vector,""); -BBTK_OUTPUT(PlaneSource,Plane,"Plane",vtkDataSet*,""); + BBTK_NAME("PlaneSource"); + BBTK_AUTHOR("carlos torres"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(PlaneSource,Center,"Center (default[0,0,0]) ",std::vector,""); + BBTK_INPUT(PlaneSource,Normal,"Normal (default[1,0,0]) ",std::vector,""); + BBTK_INPUT(PlaneSource,XResolution,"XResolution (default 100)",int,""); + BBTK_INPUT(PlaneSource,YResolution,"YResolution (default 100)",int,""); + BBTK_OUTPUT(PlaneSource,Plane,"Plane",vtkDataSet*,""); + BBTK_OUTPUT(PlaneSource,PolyData,"vtkPolyData",vtkPolyData*,""); BBTK_END_DESCRIBE_BLACK_BOX(PlaneSource); //===== // 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx index e4524c6..91569f7 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx @@ -30,45 +30,99 @@ void ScalarsToColors::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <Build(); - double rgba1[4]; - double rgba2[4]; - for (int iLookTable = 0; iLookTable<128; iLookTable++) - { + if (bbGetInputRange().size()==2) + { + _colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]); +// _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); + } else { + _colorLookupTable->SetRange(0,255); + } + _colorLookupTable->SetNumberOfTableValues(1000); + _colorLookupTable->Build(); + double rgba1[4]; + double rgba2[4]; + int iLookTable; + for (iLookTable = 0; iLookTable<500; iLookTable++) + { _colorLookupTable->GetTableValue( iLookTable, rgba1); - _colorLookupTable->GetTableValue(256-1-iLookTable, rgba2); - - _colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]); + _colorLookupTable->GetTableValue(1000-1-iLookTable, rgba2); + _colorLookupTable->SetTableValue(1000-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]); _colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]); } // for iLookTable - } // if - } // firsttime - - if (bbGetInputRange().size()==2) - { - _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); - } else { - _colorLookupTable->SetTableRange( 0,1 ); - } - - double rgb[3]; - _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb ); - std::vectorcolorRGB; - colorRGB.push_back( rgb[0] ); - colorRGB.push_back( rgb[1] ); - colorRGB.push_back( rgb[2] ); - - bbSetOutputColor( colorRGB ); - bbSetOutputLookupTable(_colorLookupTable); - + double rgba[4]; + _colorLookupTable->GetTableValue(0,rgba); + rgba[3]=0; + _colorLookupTable->SetTableValue(0,rgba); + + int i,iMax=200; + for (i=0;iGetTableValue(500+100+i, rgba); + rgba[3]=(double)i/(double)iMax; + _colorLookupTable->SetTableValue(500+100+i,rgba); + _colorLookupTable->GetTableValue(500-100-i, rgba); + rgba[3]=(double)i/(double)iMax; + _colorLookupTable->SetTableValue(500-100-i,rgba); + } // for + + iMax=100; + for (i=0;iGetTableValue(500+i, rgba); + rgba[3]=0; + _colorLookupTable->SetTableValue(500+i,rgba); + _colorLookupTable->GetTableValue(500-i, rgba); + rgba[3]=0; + _colorLookupTable->SetTableValue(500-i,rgba); + } // for + + } // if Type 0 + +//EED 2018-06-8 ***********************ARDS Projet*********************************************** + if (bbGetInputType()==1) + { + _colorLookupTable = vtkLookupTable::New(); + if (bbGetInputRange().size()==2) + { + _colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]); +// _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); + } else { + _colorLookupTable->SetRange(0,255); + } + _colorLookupTable->SetValueRange(0.0, 1.0); // from black to white + _colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation + _colorLookupTable->SetRampToLinear(); + _colorLookupTable->Build(); + double rgba[4]; + _colorLookupTable->GetTableValue(0,rgba); + rgba[3]=0; + _colorLookupTable->SetTableValue(0,rgba); + } // IF + + + + + } // firsttime + + double rgb[3]; + std::vectorcolorRGB; + _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb ); + colorRGB.push_back( rgb[0] ); + colorRGB.push_back( rgb[1] ); + colorRGB.push_back( rgb[2] ); + bbSetOutputColor( colorRGB ); + bbSetOutputLookupTable(_colorLookupTable); + +printf("EED ScalarsToColors::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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h index c3c2bd8..340ab86 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h @@ -9,6 +9,8 @@ #include #include +#include + namespace bbcreaVtk { @@ -29,8 +31,9 @@ class bbcreaVtk_EXPORT ScalarsToColors BBTK_PROCESS(Process); void Process(); - bool firsttime; - vtkLookupTable *_colorLookupTable; + bool firsttime; + vtkLookupTable *_colorLookupTable; + vtkColorTransferFunction *_volumeColor; //===== @@ -43,8 +46,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ScalarsToColors,bbtk::AtomicBlackBox); BBTK_AUTHOR("Info-Dev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(ScalarsToColors,Type,"Type of color table",int,""); - BBTK_INPUT(ScalarsToColors,ScalarValue,"Scalar value",double,""); + BBTK_INPUT(ScalarsToColors,Type,"0 (default) Type of color table",int,""); + BBTK_INPUT(ScalarsToColors,ScalarValue,"Scalar value -> Color OUT",double,""); BBTK_INPUT(ScalarsToColors,Range,"Min Max range",std::vector,""); BBTK_OUTPUT(ScalarsToColors,Color,"Color",std::vector,""); BBTK_OUTPUT(ScalarsToColors,LookupTable,"LookupTable",vtkScalarsToColors*,"");