From f65c6059e8f78f82537349d6467441c8993ef596 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 2 Jan 2023 17:28:09 +0100 Subject: [PATCH] #3499 boxes ImageGaussianSmooth2 MarchingCubes2 --- .../bbs/appli/exampleMarchingCubes2.bbg | 122 ++++++++++++++++++ .../bbs/appli/exampleMarchingCubes2.bbs | 77 +++++++++++ .../src/bbcreaVtkImageGaussianSmooth2.cxx | 87 +++++++++++++ .../src/bbcreaVtkImageGaussianSmooth2.h | 60 +++++++++ .../src/bbcreaVtkMarchingCubes2.cxx | 104 +++++++++++++++ .../src/bbcreaVtkMarchingCubes2.h | 62 +++++++++ 6 files changed, 512 insertions(+) create mode 100644 bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbg create mode 100644 bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbs create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.h create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h diff --git a/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbg b/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbg new file mode 100644 index 0000000..67be478 --- /dev/null +++ b/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbg @@ -0,0 +1,122 @@ +# ---------------------------------- +# - BBTKGEditor v 1.5 BBG BlackBox Diagram file +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbg +# ---------------------------------- + +APP_START +CATEGORY: +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:FALSE +COMPLEXINPUTS:0 +BOXES:9 +BOX +vtk:LoadHola:Box00 +ISEXEC:FALSE +-27.599389:38.890732:-900.000000 +-6.049389:36.390732:-900.000000 +FIN_BOX +BOX +creaMaracasVisu:ViewerNV:Box01 +ISEXEC:FALSE +-16.608374:10.422259:-900.000000 +21.991626:7.922259:-900.000000 +FIN_BOX +BOX +creaMaracasVisu:PolyDataToActor_Widget:Box02 +ISEXEC:FALSE +-49.493516:-11.332302:-900.000000 +-26.473516:-13.832302:-900.000000 +FIN_BOX +BOX +creaVtk:MarchingCubes2:Box03 +ISEXEC:FALSE +-47.378096:1.297573:-900.000000 +-25.093096:-1.202427:-900.000000 +FIN_BOX +BOX +wx:LayoutSplit:Box04 +ISEXEC:TRUE +-38.663218:-23.332412:-900.000000 +-15.903218:-25.832412:-900.000000 +PORT +Orientation:"H" +FIN_BOX +BOX +wx:LayoutLine:Box05 +ISEXEC:FALSE +-58.418249:-18.320351:-900.000000 +-25.098249:-20.820351:-900.000000 +FIN_BOX +BOX +wx:CheckBox:Box06 +ISEXEC:FALSE +-62.808374:12.443259:-900.000000 +-41.178374:9.943259:-900.000000 +FIN_BOX +BOX +std:MultipleInputs:Box07 +ISEXEC:FALSE +-64.135009:-4.271200:-900.000000 +-42.165009:-6.771200:-900.000000 +FIN_BOX +BOX +wx:Slider:Box10 +ISEXEC:FALSE +-96.096271:11.950144:-900.000000 +-66.296271:9.450144:-900.000000 +PORT +In:"1200" +PORT +Label:"true" +PORT +Max:"2000" +PORT +ReactiveOnTrack:"true" +PORT +Title:"Isovalue" +FIN_BOX +CONNECTIONS:14 +CONNECTION +Box00:Out:Box01:In +NumberOfControlPoints:0 +CONNECTION +Box00:Out:Box03:In +NumberOfControlPoints:0 +CONNECTION +Box01:Widget:Box04:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box03:Out:Box02:polydata +NumberOfControlPoints:0 +CONNECTION +Box01:Renderer1:Box02:render +NumberOfControlPoints:0 +CONNECTION +Box02:widget:Box05:Widget3 +NumberOfControlPoints:0 +CONNECTION +Box05:Widget:Box04:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box06:Widget:Box05:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box06:Out:Box03:Active +NumberOfControlPoints:0 +CONNECTION +Box06:BoxChange:Box07:In1 +NumberOfControlPoints:0 +CONNECTION +Box01:BoxChange:Box07:In2 +NumberOfControlPoints:0 +CONNECTION +Box07:BoxChange:Box02:boxexecute +NumberOfControlPoints:0 +CONNECTION +Box10:Out:Box03:Value +NumberOfControlPoints:0 +CONNECTION +Box10:Widget:Box05:Widget2 +NumberOfControlPoints:0 +APP_END diff --git a/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbs b/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbs new file mode 100644 index 0000000..71d3aa5 --- /dev/null +++ b/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbs @@ -0,0 +1,77 @@ +# ---------------------------------- +# - BBTKGEditor v 1.5 BBS BlackBox Script +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleMarchingCubes2.bbs +# ---------------------------------- + +# BBTK GEditor Script +# ---------------------- + +include std +include itkvtk +include vtk +include creaMaracasVisu +include creaVtk +include wx +include std + +author "Author ??" +description "Description ??" +category "" + +new vtk:LoadHola Box00 + +new creaMaracasVisu:ViewerNV Box01 + +new creaMaracasVisu:PolyDataToActor_Widget Box02 + +new creaVtk:MarchingCubes2 Box03 + +new wx:LayoutSplit Box04 + set Box04.Orientation "H" + +new wx:LayoutLine Box05 + +new wx:CheckBox Box06 + +new std:MultipleInputs Box07 + +new wx:Slider Box10 + set Box10.In "1200" + set Box10.Label "true" + set Box10.Max "2000" + set Box10.ReactiveOnTrack "true" + set Box10.Title "Isovalue" + + +connect Box00.Out Box01.In + +connect Box00.Out Box03.In + +connect Box01.Widget Box04.Widget2 + +connect Box03.Out Box02.polydata + +connect Box01.Renderer1 Box02.render + +connect Box02.widget Box05.Widget3 + +connect Box05.Widget Box04.Widget1 + +connect Box06.Widget Box05.Widget1 + +connect Box06.Out Box03.Active + +connect Box06.BoxChange Box07.In1 + +connect Box01.BoxChange Box07.In2 + +connect Box07.BoxChange Box02.boxexecute + +connect Box10.Out Box03.Value + +connect Box10.Widget Box05.Widget2 + + + +# Complex input ports +exec Box04 diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx new file mode 100644 index 0000000..0d9040b --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx @@ -0,0 +1,87 @@ +//===== +// 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 "bbcreaVtkImageGaussianSmooth2.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageGaussianSmooth2) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageGaussianSmooth2,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 ImageGaussianSmooth2::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 = " <SetInputData( bbGetInputIn() ); + gaussiansmooth->SetStandardDeviation( bbGetInputStdDevX() , bbGetInputStdDevY() , bbGetInputStdDevZ() ); + gaussiansmooth->Modified(); + gaussiansmooth->Update(); + bbSetOutputOut( gaussiansmooth->GetOutput() ); + } else { + bbSetOutputOut(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 ImageGaussianSmooth2::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + gaussiansmooth=NULL; + bbSetInputIn(NULL); + bbSetInputStdDevX(2); + bbSetInputStdDevY(2); + bbSetInputStdDevZ(2); + +} +//===== +// 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 ImageGaussianSmooth2::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 ImageGaussianSmooth2::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/bbcreaVtkImageGaussianSmooth2.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.h new file mode 100644 index 0000000..39503df --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.h @@ -0,0 +1,60 @@ +//===== +// 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 __bbcreaVtkImageGaussianSmooth2_h_INCLUDED__ +#define __bbcreaVtkImageGaussianSmooth2_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" +#include "vtkImageGaussianSmooth.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageGaussianSmooth2 + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageGaussianSmooth2,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(StdDevX,double); + BBTK_DECLARE_INPUT(StdDevY,double); + BBTK_DECLARE_INPUT(StdDevZ,double); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); + vtkImageGaussianSmooth *gaussiansmooth; + +//===== +// 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(ImageGaussianSmooth2,bbtk::AtomicBlackBox); + BBTK_NAME("ImageGaussianSmooth2"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + + BBTK_INPUT(ImageGaussianSmooth2,In,"First input",vtkImageData*,""); + BBTK_INPUT(ImageGaussianSmooth2,StdDevX,"(default 2) Standard deviation in direction X",double,""); + BBTK_INPUT(ImageGaussianSmooth2,StdDevY,"(default 2) Standard deviation in direction Y",double,""); + BBTK_INPUT(ImageGaussianSmooth2,StdDevZ,"(default 2) Standard deviation in direction Z",double,""); + + BBTK_OUTPUT(ImageGaussianSmooth2,Out,"First output",vtkImageData*,""); + +BBTK_END_DESCRIBE_BLACK_BOX(ImageGaussianSmooth2); +//===== +// 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 // __bbcreaVtkImageGaussianSmooth2_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx new file mode 100644 index 0000000..e2d3b8e --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx @@ -0,0 +1,104 @@ +//===== +// 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 "bbcreaVtkMarchingCubes2.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MarchingCubes2) +BBTK_BLACK_BOX_IMPLEMENTATION(MarchingCubes2,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 MarchingCubes2::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 = " <SetInputData( bbGetInputIn() ); + marchingcubes->SetValue(0, bbGetInputValue() ); + + if(bbGetInputComputeNormalsOn()) + { + marchingcubes->ComputeNormalsOn(); + }else { + marchingcubes->ComputeNormalsOff(); + }// if Normals + + if(bbGetInputComputeScalarsOn()) + { + marchingcubes->ComputeScalarsOn(); + }else{ + marchingcubes->ComputeScalarsOff(); + }// if Scalars + + marchingcubes->Update(); + bbSetOutputOut( marchingcubes->GetOutput() ); + } else { + bbSetOutputOut(NULL); + } // Active + + + +} +//===== +// 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 MarchingCubes2::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + marchingcubes=NULL; + bbSetInputActive(true); + bbSetInputIn(NULL); + bbSetInputValue( 400 ); + bbSetInputComputeNormalsOn(true); + bbSetInputComputeScalarsOn(true); + bbSetOutputOut(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 MarchingCubes2::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 MarchingCubes2::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/bbcreaVtkMarchingCubes2.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h new file mode 100644 index 0000000..b4d44c4 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h @@ -0,0 +1,62 @@ +//===== +// 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 __bbcreaVtkMarchingCubes2_h_INCLUDED__ +#define __bbcreaVtkMarchingCubes2_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT MarchingCubes2 + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(MarchingCubes2,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(Active,bool); + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_INPUT(Value,double); + BBTK_DECLARE_INPUT(ComputeNormalsOn,bool); + BBTK_DECLARE_INPUT(ComputeScalarsOn,bool); + BBTK_DECLARE_OUTPUT(Out,vtkPolyData*); + BBTK_PROCESS(Process); + void Process(); + vtkMarchingCubes *marchingcubes; +//===== +// 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(MarchingCubes2,bbtk::AtomicBlackBox); + BBTK_NAME("MarchingCubes2"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + + BBTK_INPUT(MarchingCubes2,Active,"(default true) Active",bool,""); + BBTK_INPUT(MarchingCubes2,In,"Input image",vtkImageData*,""); + BBTK_INPUT(MarchingCubes2,Value,"Value of the iso-surface",double,""); + BBTK_INPUT(MarchingCubes2,ComputeNormalsOn,"Set the computation of normals",bool,""); + BBTK_INPUT(MarchingCubes2,ComputeScalarsOn,"Set the computation of scalars",bool,""); + + BBTK_OUTPUT(MarchingCubes2,Out,"Output polydata (iso-surface)",vtkPolyData*,""); + +BBTK_END_DESCRIBE_BLACK_BOX(MarchingCubes2); +//===== +// 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 // __bbcreaVtkMarchingCubes2_h_INCLUDED__ + -- 2.45.1