From 7ab8fb10baaab07081bfa89ce347b4dfb99fcb0c Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 1 Oct 2024 13:27:31 +0200 Subject: [PATCH 01/16] #3528 NIFTIImageWritger box --- .../src/bbcreaVtkNIFTIimageWriter.cxx | 82 +++++++++++++++++++ .../src/bbcreaVtkNIFTIimageWriter.h | 50 +++++++++++ 2 files changed, 132 insertions(+) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.cxx new file mode 100644 index 0000000..b271e53 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.cxx @@ -0,0 +1,82 @@ +//===== +// 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 "bbcreaVtkNIFTIimageWriter.h" +#include "bbcreaVtkPackage.h" + +#include "vtkNIFTIImageWriter.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,NIFTIimageWriter) +BBTK_BLACK_BOX_IMPLEMENTATION(NIFTIimageWriter,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 NIFTIimageWriter::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() ); + writer->SetFileName( bbGetInputFileName().c_str() ); +// writer->SetNIFTIHeader(reader1->GetNIFTIHeader()); +// writer->SetSFormMatrix(reader1->GetSFormMatrix()); + writer->SetNIFTIVersion(2); + writer->Update(); + } // if In + +} + +//===== +// 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 NIFTIimageWriter::bbUserSetDefaultValues() +{ + // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + // Here we initialize the input 'In' to 0 + bbSetInputIn(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 NIFTIimageWriter::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 NIFTIimageWriter::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/bbcreaVtkNIFTIimageWriter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.h new file mode 100644 index 0000000..dfd5fbd --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIimageWriter.h @@ -0,0 +1,50 @@ +//===== +// 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 __bbcreaVtkNIFTIimageWriter_h_INCLUDED__ +#define __bbcreaVtkNIFTIimageWriter_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT NIFTIimageWriter + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(NIFTIimageWriter,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(FileName, std::string); +// BBTK_DECLARE_OUTPUT(Out,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(NIFTIimageWriter,bbtk::AtomicBlackBox); + BBTK_NAME("NIFTIimageWriter"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(NIFTIimageWriter,In,"Input image",vtkImageData*,""); + BBTK_INPUT(NIFTIimageWriter,FileName,"File name",std::string,""); +// BBTK_OUTPUT(NIFTIimageWriter,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(NIFTIimageWriter); +//===== +// 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 // __bbcreaVtkNIFTIimageWriter_h_INCLUDED__ + -- 2.50.0 From 5057f0fc6ca255d5d09489c346cb199c34870eda Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 14 Oct 2024 12:29:00 +0200 Subject: [PATCH 02/16] #3529 clean VTKTurnImage box --- bbtk_creaVtk_PKG/.DS_Store | Bin 8196 -> 8196 bytes bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx | 265 +++++++++++--------- 2 files changed, 150 insertions(+), 115 deletions(-) diff --git a/bbtk_creaVtk_PKG/.DS_Store b/bbtk_creaVtk_PKG/.DS_Store index 8fd3482ce295b13412c4a47a718c628794e1ca1a..afa815535c7de6d6e2d9472d3384e822300392fe 100644 GIT binary patch delta 14 VcmZp1XmQx^U67Gs^AABDJ^(9B1sDJT delta 14 VcmZp1XmQx^U67G+^AABDJ^(9H1sMPU diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx index d64a3c7..581df50 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx @@ -6,141 +6,176 @@ #include "creaVtk_MACROS.h" +#include +#include + namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,TurnImage) BBTK_BLACK_BOX_IMPLEMENTATION(TurnImage,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 TurnImage::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 = " <GetExtent(ext); - dim[0] = ext[1]-ext[0]+1; - dim[1] = ext[3]-ext[2]+1; - dim[2] = ext[5]-ext[4]+1; - double spc[3]; - bbGetInputIn()->GetSpacing(spc); - - vtkImageData *newImage = vtkImageData::New(); - newImage->Initialize(); - if (bbGetInputDir()==1) - { - newImage->SetSpacing( spc[1],spc[2],spc[0] ); - newImage->SetDimensions( dim[1],dim[2], dim[0] ); - } else if (bbGetInputDir()==2) - { - newImage->SetSpacing( spc[0],spc[2],spc[1] ); - newImage->SetDimensions( dim[0],dim[2], dim[1] ); - } else { - newImage->SetSpacing( spc[0],spc[1],spc[2] ); - newImage->SetDimensions( dim[0],dim[1], dim[2] ); - }// if Dir - -//EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - newImage->SetScalarType( bbGetInputIn()->GetScalarType() ); - newImage->SetNumberOfScalarComponents(1); - newImage->AllocateScalars(); -#endif -#if (VTK_MAJOR_VERSION >= 6) - newImage->AllocateScalars( bbGetInputIn()->GetScalarType(),1 ); -#endif - - DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn()) - DEF_POINTER_IMAGE_VTK_CREA(vNI,ssNI,pNI,stNI,newImage) - - long int index=0; - int i,j,k; - double value; - for (k=0;kGetScalarComponentAsDouble (i,j,k,0); - if (bbGetInputDir()==1) - { - SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] ) -// newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value); - } else if (bbGetInputDir()==2) - { - SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] ) -// newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value); - } else { - SETVALUE2_VTK_CREA(vIn,pNI,stNI,index) -// newImage->SetScalarComponentFromDouble(i,j,k,0,value); - }// if Dir - index++; - } // for i - } // for j - } // for k - bbSetOutputOut(newImage); - } else { - bbSetOutputOut(NULL); - }// if In!=NULL + + // 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 = " <GetExtent(ext); + dim[0] = ext[1]-ext[0]+1; + dim[1] = ext[3]-ext[2]+1; + dim[2] = ext[5]-ext[4]+1; + double spc[3]; + bbGetInputIn()->GetSpacing(spc); + + vtkImageData *newImage = vtkImageData::New(); + newImage->Initialize(); + if (bbGetInputDir()==1) + { + newImage->SetSpacing( spc[1],spc[2],spc[0] ); + newImage->SetDimensions( dim[1],dim[2], dim[0] ); + } else if (bbGetInputDir()==2) + { + newImage->SetSpacing( spc[0],spc[2],spc[1] ); + newImage->SetDimensions( dim[0],dim[2], dim[1] ); + } else { + newImage->SetSpacing( spc[0],spc[1],spc[2] ); + newImage->SetDimensions( dim[0],dim[1], dim[2] ); + }// if Dir + + //EED 2017-01-01 Migration VTK7 + #if (VTK_MAJOR_VERSION <= 5) + newImage->SetScalarType( bbGetInputIn()->GetScalarType() ); + newImage->SetNumberOfScalarComponents(1); + newImage->AllocateScalars(); + #endif + #if (VTK_MAJOR_VERSION >= 6) + newImage->AllocateScalars( bbGetInputIn()->GetScalarType(),1 ); + #endif + + DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn()) + DEF_POINTER_IMAGE_VTK_CREA(vNI,ssNI,pNI,stNI,newImage) + + + long int index=0; + int i,j,k; + double value; + for (k=0;kGetScalarComponentAsDouble (i,j,k,0); + if (bbGetInputDir()==1) + { + SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] ) + //old newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value); + } else if (bbGetInputDir()==2) + { + SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] ) + //old newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value); + } else { + SETVALUE2_VTK_CREA(vIn,pNI,stNI,index) + //old newImage->SetScalarComponentFromDouble(i,j,k,0,value); + }// if Dir + // index++; + } // for i + + } // for j + } // for k + bbSetOutputOut(newImage); + */ + + /* + vtkImagePermute *permute = vtkImagePermute::New(); + permute->SetInputData( bbGetInputIn() ); + permute->SetFilteredAxes (0,2,1); + permute->Update(); + bbSetOutputOut( permute->GetOutput() ); + */ + + // Rotate about the center + // vtkTransform *transform; + // transform->Translate(center[0], center[1], center[2]); + // transform->RotateWXYZ(angle, 0, 0, 1); + // transform->Translate(-center[0], -center[1], -center[2]); + + // Reslice does all of the work. + vtkImageReslice *reslice = vtkImageReslice::New(); + static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + // reslice->SetOutputOrigin(0,0,0); + reslice->SetInputData( bbGetInputIn() ); + reslice->SetResliceAxesOrigin( 0,0,0 ); + reslice->SetInterpolationModeToNearestNeighbor(); + reslice->Update(); + + vtkImageChangeInformation *mchange = vtkImageChangeInformation::New(); + mchange->SetInputData( reslice->GetOutput() ); + mchange->SetOutputOrigin( 0,0,0 ); + mchange->Update(); + bbSetOutputOut( mchange->GetOutput() ); + } else { + bbSetOutputOut(NULL); + }// if In!=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 TurnImage::bbUserSetDefaultValues() { - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 - bbSetInputIn(NULL); - bbSetInputDir(0); - + // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + // Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + bbSetInputDir(0); } -//===== + +//===== // 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 TurnImage::bbUserInitializeProcessing() { - -// THE INITIALIZATION METHOD BODY : -// Here does nothing -// but this is where you should allocate the internal/output pointers -// if any - - + // 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 TurnImage::bbUserFinalizeProcessing() { - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - -} + // THE FINALIZATION METHOD BODY : + // Here does nothing + // but this is where you should desallocate the internal/output pointers + // if any } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk -- 2.50.0 From 321f4a5d59a4664326da8d5a7e3fbd5352784637 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Thu, 17 Oct 2024 15:57:42 +0200 Subject: [PATCH 03/16] #3530 bbcreaVtkTurnImage optimisation --- bbtk_creaVtk_PKG/.DS_Store | Bin 8196 -> 8196 bytes bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx | 104 ++++++++++---------- 2 files changed, 50 insertions(+), 54 deletions(-) diff --git a/bbtk_creaVtk_PKG/.DS_Store b/bbtk_creaVtk_PKG/.DS_Store index afa815535c7de6d6e2d9472d3384e822300392fe..8fd3482ce295b13412c4a47a718c628794e1ca1a 100644 GIT binary patch delta 14 VcmZp1XmQx^U67G+^AABDJ^(9H1sMPU delta 14 VcmZp1XmQx^U67Gs^AABDJ^(9B1sDJT diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx index 581df50..7afd2e9 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx @@ -75,69 +75,65 @@ void TurnImage::Process() DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn()) DEF_POINTER_IMAGE_VTK_CREA(vNI,ssNI,pNI,stNI,newImage) - long int index=0; int i,j,k; double value; for (k=0;kGetScalarComponentAsDouble (i,j,k,0); - if (bbGetInputDir()==1) - { - SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] ) - //old newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value); - } else if (bbGetInputDir()==2) - { - SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] ) - //old newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value); - } else { - SETVALUE2_VTK_CREA(vIn,pNI,stNI,index) - //old newImage->SetScalarComponentFromDouble(i,j,k,0,value); - }// if Dir - // index++; - } // for i + for (i=0;iGetScalarComponentAsDouble (i,j,k,0); + if (bbGetInputDir()==1) + { + SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] ) + //old newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value); + } else if (bbGetInputDir()==2) + { + SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] ) + //old newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value); + } else { + SETVALUE2_VTK_CREA(vIn,pNI,stNI,index) + //old newImage->SetScalarComponentFromDouble(i,j,k,0,value); + }// if Dir + index++; + } // for i - } // for j + } // for j } // for k bbSetOutputOut(newImage); - */ - - /* - vtkImagePermute *permute = vtkImagePermute::New(); - permute->SetInputData( bbGetInputIn() ); - permute->SetFilteredAxes (0,2,1); - permute->Update(); - bbSetOutputOut( permute->GetOutput() ); - */ - - // Rotate about the center - // vtkTransform *transform; - // transform->Translate(center[0], center[1], center[2]); - // transform->RotateWXYZ(angle, 0, 0, 1); - // transform->Translate(-center[0], -center[1], -center[2]); - - // Reslice does all of the work. - vtkImageReslice *reslice = vtkImageReslice::New(); - static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }; - reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); - // reslice->SetOutputOrigin(0,0,0); - reslice->SetInputData( bbGetInputIn() ); - reslice->SetResliceAxesOrigin( 0,0,0 ); - reslice->SetInterpolationModeToNearestNeighbor(); - reslice->Update(); - - vtkImageChangeInformation *mchange = vtkImageChangeInformation::New(); - mchange->SetInputData( reslice->GetOutput() ); - mchange->SetOutputOrigin( 0,0,0 ); - mchange->Update(); - bbSetOutputOut( mchange->GetOutput() ); + */ + if ( (bbGetInputDir()==1) || (bbGetInputDir()==2) ) + { + vtkImageReslice *reslice = vtkImageReslice::New(); + vtkImageChangeInformation *mchange = vtkImageChangeInformation::New(); + // Reslice does all of the work. + if ( bbGetInputDir()==1 ) + { + static double axes[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 1, 0, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 1 + if ( bbGetInputDir()==2 ) + { + static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 2 + // reslice->SetOutputOrigin(0,0,0); + reslice->SetInputData( bbGetInputIn() ); + reslice->SetResliceAxesOrigin( 0,0,0 ); + reslice->SetInterpolationModeToNearestNeighbor(); + reslice->Update(); + mchange->SetInputData( reslice->GetOutput() ); + mchange->SetOutputOrigin( 0,0,0 ); + mchange->Update(); + bbSetOutputOut( mchange->GetOutput() ); + } else { + bbSetOutputOut( bbGetInputIn() ); + }// if Dir 1 or 2 + } else { bbSetOutputOut(NULL); }// if In!=NULL -- 2.50.0 From dd307a21a05b9b949e673cafe58a26697d8d86a6 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 21 Oct 2024 11:34:45 +0200 Subject: [PATCH 04/16] #3562 Active option in GaussianSmooth ImageThreshold box --- .../src/bbcreaVtkImageGaussianSmooth2.cxx | 26 ++++++++----------- .../src/bbcreaVtkImageGaussianSmooth2.h | 2 ++ .../src/bbcreaVtkImageThreshold.cxx | 16 ++++++------ .../src/bbcreaVtkImageThreshold.h | 4 ++- .../src/bbcreaVtkPolyDataToImageData.cxx | 15 ++++++----- lib/creaVtk/CMakeLists.txt | 3 +++ 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx index 4998bf9..8608c61 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageGaussianSmooth2.cxx @@ -28,7 +28,7 @@ void ImageGaussianSmooth2::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " < Date: Mon, 4 Nov 2024 13:27:22 +0100 Subject: [PATCH 05/16] #3531 ImageMaskDice box --- .../src/bbcreaVtkImageMaskDice.cxx | 107 +++++++++++++----- bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.h | 8 +- 2 files changed, 85 insertions(+), 30 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx index 23b4330..5272ac3 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx @@ -3,77 +3,130 @@ //===== #include "bbcreaVtkImageMaskDice.h" #include "bbcreaVtkPackage.h" + +#include "creaVtk_MACROS.h" + namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageMaskDice) BBTK_BLACK_BOX_IMPLEMENTATION(ImageMaskDice,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) -//===== + + +#define ACUMULATE(VMA,VMM,TP,FP,FN) \ + if ( (VMA>0) || (VMM>0) ) \ + { \ + if ((VMA>0)&&(VMM>0)) \ + { \ + TP++; \ + } else if ((VMA>0)&&(VMM==0)) { \ + FP++; \ + } else if ((VMA==0)&&(VMM>0)) { \ + FN++; \ + } \ + } + +#define INSERTINVECTOR(TP,FP,FN) \ + LstTitles.push_back( "tp"); LstValues.push_back( std::to_string(TP) ); \ + LstTitles.push_back( "fp"); LstValues.push_back( std::to_string(FP) ); \ + LstTitles.push_back( "fn"); LstValues.push_back( std::to_string(FN) ); \ + LstTitles.push_back( "vol1"); LstValues.push_back( std::to_string(TP+FP) ); \ + LstTitles.push_back( "vol2"); LstValues.push_back( std::to_string(TP+FN) ); \ + if ((TP==0) && (FP==0) && (FN==0)) { \ + LstTitles.push_back( "_dice"); LstValues.push_back( "---" ); \ + }else { \ + tmp = 2 * (double)TP / (2 * (double)TP + (double)FP + (double)FN ); \ + LstTitles.push_back( "dice"); LstValues.push_back( std::to_string(tmp) ); \ + } + void ImageMaskDice::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 +// 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') - - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - printf("EED ImageMaskDice::Process Error, this method is not implemented \n"); - - bbSetOutputOut( -1 ); + if ( (bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) ) + { + int ext[6]; + int dimX1,dimY1,dimZ1; + bbGetInputIn1()->GetExtent(ext); + dimX1 = ext[1]-ext[0]+1; + dimY1 = ext[3]-ext[2]+1; + dimZ1 = ext[5]-ext[4]+1; + int dimX2,dimY2,dimZ2; + bbGetInputIn2()->GetExtent(ext); + dimX2 = ext[1]-ext[0]+1; + dimY2 = ext[3]-ext[2]+1; + dimZ2 = ext[5]-ext[4]+1; + if ( (dimX1==dimX2) && + (dimY1==dimY2) && + (dimZ1==dimZ2) ) + { + long int tpAll=0 ,fpAll=0 ,fnAll=0 ; + DEF_POINTER_IMAGE_VTK_CREA(vMA,ssMA,pMA,stMA,bbGetInputIn1()) + DEF_POINTER_IMAGE_VTK_CREA(vMM,ssMM,pMM,stMM,bbGetInputIn2()) + long int i,size=dimX1*dimY1*dimZ1; + for (i=0;i LstTitles; + std::vector LstValues; + INSERTINVECTOR(tpAll,fpAll,fnAll) + bbSetOutputLstTitles(LstTitles); + bbSetOutputLstValues(LstValues); + } else { + printf ("EED Warning... creaSDRAVisu VolumeMassDice::Process Size of images are not the same. \n"); + } // if dimXYZ I MA MM + } else { + printf ("EED Warning... VolumeMassDice::Process Missing input files...\n"); + }// if } -//===== + +//===== // 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 ImageMaskDice::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn1(NULL); bbSetInputIn2(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 ImageMaskDice::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// 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 ImageMaskDice::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - -} } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.h index 5caeea7..316e4bd 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.h @@ -23,7 +23,8 @@ class bbcreaVtk_EXPORT ImageMaskDice //===== BBTK_DECLARE_INPUT(In1,vtkImageData*); BBTK_DECLARE_INPUT(In2,vtkImageData*); - BBTK_DECLARE_OUTPUT(Out,double); + BBTK_DECLARE_OUTPUT(LstTitles, std::vector ); + BBTK_DECLARE_OUTPUT(LstValues, std::vector ); BBTK_PROCESS(Process); void Process(); //===== @@ -34,11 +35,12 @@ class bbcreaVtk_EXPORT ImageMaskDice BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageMaskDice,bbtk::AtomicBlackBox); BBTK_NAME("ImageMaskDice"); BBTK_AUTHOR("InfoDev"); - BBTK_DESCRIPTION("(C++?????,Python)"); + BBTK_DESCRIPTION("(C++,Python)"); BBTK_CATEGORY("empty"); BBTK_INPUT(ImageMaskDice,In1,"Image 1",vtkImageData*,""); BBTK_INPUT(ImageMaskDice,In2,"Image 2",vtkImageData*,""); - BBTK_OUTPUT(ImageMaskDice,Out,"Dice",double,""); + BBTK_OUTPUT(ImageMaskDice,LstTitles,"List of titles", std::vector ,""); + BBTK_OUTPUT(ImageMaskDice,LstValues,"List of values", std::vector ,""); BBTK_END_DESCRIBE_BLACK_BOX(ImageMaskDice); //===== // 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) -- 2.50.0 From 202e2e9d3c4aab17725fcb53737f73f844094b9d Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Wed, 6 Nov 2024 08:58:50 +0100 Subject: [PATCH 06/16] Clean code --- bbtk_creaVtk_PKG/src/bbcreaVtkActor.h | 72 +++++++++---------- .../src/bbcreaVtkImageMaskDice.cxx | 4 ++ 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkActor.h b/bbtk_creaVtk_PKG/src/bbcreaVtkActor.h index 5fed993..e2ae8e5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkActor.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkActor.h @@ -15,51 +15,51 @@ namespace bbcreaVtk { class bbcreaVtk_EXPORT Actor - : - public bbtk::AtomicBlackBox +: +public bbtk::AtomicBlackBox { - BBTK_BLACK_BOX_INTERFACE(Actor,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,vtkProp3D*); - BBTK_DECLARE_INPUT(Opacity,double); - BBTK_DECLARE_INPUT(Color,std::vector); - BBTK_DECLARE_INPUT(LineWidth,double); - BBTK_DECLARE_INPUT(Transform,vtkTransform*); - BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); -// BBTK_DECLARE_OUTPUT(Out,double); - BBTK_PROCESS(Process); - void Process(); - - bool backActive; -//===== -// 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_BLACK_BOX_INTERFACE(Actor,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,vtkProp3D*); + BBTK_DECLARE_INPUT(Opacity,double); + BBTK_DECLARE_INPUT(Color,std::vector); + BBTK_DECLARE_INPUT(LineWidth,double); + BBTK_DECLARE_INPUT(Transform,vtkTransform*); + BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); + // BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + bool backActive; + //===== + // 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(Actor,bbtk::AtomicBlackBox); - BBTK_NAME("Actor"); - BBTK_AUTHOR("Info-Dev"); - BBTK_DESCRIPTION("No Description."); - BBTK_CATEGORY("empty"); +BBTK_NAME("Actor"); +BBTK_AUTHOR("Info-Dev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); - BBTK_INPUT(Actor,Active,"Active true/false (default false)",bool,""); - BBTK_INPUT(Actor,In,"First input",vtkProp3D*,""); - BBTK_INPUT(Actor,Opacity,"Opacity 0..1 (default 1)",double,""); - BBTK_INPUT(Actor,Color,"(default [1 0 0]red ) RGB color vector [0..1, 0..1, 0..1] )", std::vector,""); - BBTK_INPUT(Actor,LineWidth,"(default 0.5 ) With ligne )",double,""); - BBTK_INPUT(Actor,Transform,"Transform",vtkTransform*,""); - BBTK_INPUT(Actor,Renderer,"Renderer",vtkRenderer*,""); +BBTK_INPUT(Actor,Active,"Active true/false (default false)",bool,""); +BBTK_INPUT(Actor,In,"First input",vtkProp3D*,""); +BBTK_INPUT(Actor,Opacity,"Opacity 0..1 (default 1)",double,""); +BBTK_INPUT(Actor,Color,"(default [1 0 0]red ) RGB color vector [0..1, 0..1, 0..1] )", std::vector,""); +BBTK_INPUT(Actor,LineWidth,"(default 0.5 ) With ligne )",double,""); +BBTK_INPUT(Actor,Transform,"Transform",vtkTransform*,""); +BBTK_INPUT(Actor,Renderer,"Renderer",vtkRenderer*,""); // BBTK_OUTPUT(Actor,Out,"First output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(Actor); -//===== +//===== // 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 +//===== + +}// EO namespace bbcreaVtk #endif // __bbcreaVtkActor_h_INCLUDED__ diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx index 5272ac3..2cc87fc 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx @@ -53,6 +53,8 @@ void ImageMaskDice::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') + printf("EED ImageMaskDice::Process Start .. \n"); + if ( (bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) ) { int ext[6]; @@ -92,6 +94,8 @@ void ImageMaskDice::Process() } else { printf ("EED Warning... VolumeMassDice::Process Missing input files...\n"); }// if + printf("EED ImageMaskDice::Process .. End \n"); + } //===== -- 2.50.0 From 0ebd55a20524d5ebfd8668696f392ac72fd6d9f6 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 12 Nov 2024 17:53:48 +0100 Subject: [PATCH 07/16] Clean code --- bbtk_creaVtk_PKG/src/bbcreaVtkImageAppendComponents.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageAppendComponents.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageAppendComponents.cxx index bcdc510..442bd37 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageAppendComponents.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageAppendComponents.cxx @@ -54,7 +54,8 @@ void ImageAppendComponents::bbUserSetDefaultValues() bbSetInputIn2(NULL); bbSetInputIn3(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 ImageAppendComponents::bbUserInitializeProcessing() @@ -64,7 +65,8 @@ void ImageAppendComponents::bbUserInitializeProcessing() // 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 ImageAppendComponents::bbUserFinalizeProcessing() -- 2.50.0 From 7974fa8edc4d5d963f0b0a559ea5b414dba786b4 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 19 Nov 2024 23:58:38 +0100 Subject: [PATCH 08/16] Clean code --- .../src/bbcreaVtkImageMaskDice.cxx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx index 2cc87fc..8d90757 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageMaskDice.cxx @@ -33,8 +33,9 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageMaskDice,bbtk::AtomicBlackBox); LstTitles.push_back( "vol1"); LstValues.push_back( std::to_string(TP+FP) ); \ LstTitles.push_back( "vol2"); LstValues.push_back( std::to_string(TP+FN) ); \ if ((TP==0) && (FP==0) && (FN==0)) { \ - LstTitles.push_back( "_dice"); LstValues.push_back( "---" ); \ + LstTitles.push_back( "_dice"); LstValues.push_back( "-1" ); \ }else { \ + double tmp; \ tmp = 2 * (double)TP / (2 * (double)TP + (double)FP + (double)FN ); \ LstTitles.push_back( "dice"); LstValues.push_back( std::to_string(tmp) ); \ } @@ -54,7 +55,8 @@ void ImageMaskDice::Process() // (the one provided in the attribute 'type' of the tag 'input') printf("EED ImageMaskDice::Process Start .. \n"); - + long int tpAll=0 ,fpAll=0 ,fnAll=0 ; + if ( (bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) ) { int ext[6]; @@ -72,7 +74,6 @@ void ImageMaskDice::Process() (dimY1==dimY2) && (dimZ1==dimZ2) ) { - long int tpAll=0 ,fpAll=0 ,fnAll=0 ; DEF_POINTER_IMAGE_VTK_CREA(vMA,ssMA,pMA,stMA,bbGetInputIn1()) DEF_POINTER_IMAGE_VTK_CREA(vMM,ssMM,pMM,stMM,bbGetInputIn2()) long int i,size=dimX1*dimY1*dimZ1; @@ -82,12 +83,9 @@ void ImageMaskDice::Process() GETVALUE2_VTK_CREA(vMM,pMM,stMM,i) ACUMULATE(vMA, vMM, tpAll, fpAll, fnAll) } // for - double tmp; - std::vector LstTitles; - std::vector LstValues; - INSERTINVECTOR(tpAll,fpAll,fnAll) - bbSetOutputLstTitles(LstTitles); - bbSetOutputLstValues(LstValues); +// INSERTINVECTOR(tpAll,fpAll,fnAll) +// bbSetOutputLstTitles(LstTitles); +// bbSetOutputLstValues(LstValues); } else { printf ("EED Warning... creaSDRAVisu VolumeMassDice::Process Size of images are not the same. \n"); } // if dimXYZ I MA MM @@ -96,6 +94,13 @@ void ImageMaskDice::Process() }// if printf("EED ImageMaskDice::Process .. End \n"); + std::vector LstTitles; + std::vector LstValues; + INSERTINVECTOR(tpAll,fpAll,fnAll) + bbSetOutputLstTitles(LstTitles); + bbSetOutputLstValues(LstValues); + + } //===== -- 2.50.0 From 34578bee77758fa081dc8a02dbc2e196c65dc893 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 25 Nov 2024 16:29:04 +0100 Subject: [PATCH 09/16] Clean code --- .../src/bbcreaVtkImageDataStructuredPoints.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx index 9f0ccec..b9b7c98 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx @@ -34,21 +34,20 @@ void ImageDataStructuredPoints::bbUserSetDefaultValues() bbSetInputData5(NULL); bbSetInputData6(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 ImageDataStructuredPoints::bbUserInitializeProcessing() { - } //===== // 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 ImageDataStructuredPoints::bbUserFinalizeProcessing() { - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk -- 2.50.0 From e482692f228bf0b28d3429cb55bb7ef09d1f8e4b Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 3 Dec 2024 15:13:37 +0100 Subject: [PATCH 10/16] #3552 Plane xy xz yz Vectors visu --- bbtk_creaVtk_PKG/.DS_Store | Bin 8196 -> 8196 bytes .../bbs/boxes/PlaneTensorVisu_Widget.bbg | 2 +- .../bbs/boxes/PlaneTensorVisu_Widget.bbs | 2 +- .../bbs/boxes/PlaneVectorVisu_Interface.bbg | 215 ++++++--- .../bbs/boxes/PlaneVectorVisu_Interface.bbs | 52 +- .../bbs/boxes/PlaneVectorVisu_Widget.bbg | 448 ++++++++++++++++-- .../bbs/boxes/PlaneVectorVisu_Widget.bbs | 141 +++++- .../bbs/boxes/VectorsTensors_Widget.bbg | 107 +++-- .../bbs/boxes/VectorsTensors_Widget.bbs | 12 +- bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx | 38 +- bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx | 28 +- lib/creaVtk/vtkVectorsVisu.cpp | 5 +- 12 files changed, 881 insertions(+), 169 deletions(-) diff --git a/bbtk_creaVtk_PKG/.DS_Store b/bbtk_creaVtk_PKG/.DS_Store index 8fd3482ce295b13412c4a47a718c628794e1ca1a..9e9655d8fd9a5157af96d9e6d516da62ad3f1647 100644 GIT binary patch delta 26 icmZp1XmOYj$H=%bem_4W<7Rn*8;pz$n|}!M@BsjGga_*Y delta 26 icmZp1XmOYj$H=fTem_4W!)AGb8;p#Mn|}!M@BsjGY6t27 diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbg b/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbg index 47294a7..db08201 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbg @@ -62,7 +62,7 @@ ISEXEC:FALSE -23.855784:52.258658:-900.000000 FIN_BOX BOX -creaVtk:PlaneVectorViso_Interface:Box06 +creaVtk:PlaneVectorVisu_Interface:Box06 ISEXEC:FALSE 54.274543:36.839315:-900.000000 125.449543:26.839315:-900.000000 diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbs b/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbs index b8a99f5..798da78 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneTensorVisu_Widget.bbs @@ -27,7 +27,7 @@ new vtkImageDataPointerRelay Box04 new MagicBox Box05 -new PlaneVectorViso_Interface Box06 +new PlaneVectorVisu_Interface Box06 set Box06.typeFormsStr "Cube Sphere Superquadric" new TensorsVisu Box07 diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg index 63b92d4..c1a6005 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg @@ -1,59 +1,72 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /tmpEED/creaTools/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg +# - BBTKGEditor v 1.6 BBG BlackBox Diagram file +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbg # ---------------------------------- APP_START CATEGORY: DESCRIPTION:Description ?? AUTHOR:Author ?? +EXPORTFORMAT:0 COMPLEXBOX:TRUE -COMPLEXBOXNAME:PlaneVectorViso_Interface +COMPLEXBOXNAME:PlaneVectorVisu_Interface PACKAGENAME:creaVtk -COMPLEXOUTPUTS:8 +COMPLEXOUTPUTS:11 COMPLEX_PORT boxChange --55.620936:-52.838253:-900.000000 +-38.934655:-15.851476:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT widget -5.487815:-55.801788:-900.000000 +3.841470:-16.740536:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT ActivePlaneControl --22.349772:-52.654549:-900.000000 +-15.644840:-15.796365:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT AcitiveVector -80.231895:-54.018263:-900.000000 +56.162326:-16.205479:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT Opacity -136.144207:-52.806072:-900.000000 +95.300945:-15.841822:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT ScaleFactor -170.388604:-54.927407:-900.000000 +119.272023:-16.478222:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT Ratio -68.944467:-60.974247:-900.000000 +48.261127:-18.292274:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT typeForm -102.276330:-54.205701:-900.000000 +71.593431:-16.261710:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +active_xy +-69.649214:-16.573658:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +avtive_xz +-64.107295:-16.761520:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +active_yz +-58.471446:-16.479727:-900.000000 FIN_COMPLEX_PORT COMPLEXINPUTS:1 COMPLEX_PORT typeFormsStr -107.913964:117.907952:-900.000000 +82.718534:85.458673:-900.000000 FIN_COMPLEX_PORT -BOXES:14 +BOXES:20 BOX wx:Slider:Box00 ISEXEC:FALSE -31.999641:48.109206:-900.000000 -83.399641:38.109206:-900.000000 +25.012707:20.758872:-900.000000 +54.812707:18.258872:-900.000000 PORT In:"30" PORT @@ -70,44 +83,44 @@ FIN_BOX BOX wx:CheckBox:Box01 ISEXEC:FALSE --29.436005:97.853036:-900.000000 -16.138995:87.853036:-900.000000 +-8.448071:48.911842:-900.000000 +13.181929:46.411842:-900.000000 PORT In:"false" PORT ReactiveOnKeystroke:"true" PORT -Title:"Plane control" +Title:"control" FIN_BOX BOX wx:LayoutLine:Box03 ISEXEC:FALSE -20.799855:-14.759536:-900.000000 -78.359855:-24.759536:-900.000000 +14.559898:-4.427861:-900.000000 +47.879898:-6.927861:-900.000000 PORT WinTitle:"Plane flield" FIN_BOX BOX wx:LayoutTab:Box04 ISEXEC:FALSE -10.485060:-37.613537:-900.000000 -68.045060:-47.613537:-900.000000 +7.339542:-11.284061:-900.000000 +40.659542:-13.784061:-900.000000 FIN_BOX BOX wx:CheckBox:Box05 ISEXEC:FALSE -27.771749:97.805412:-900.000000 -73.346749:87.805412:-900.000000 +4.711390:44.359258:-900.000000 +26.341390:41.859258:-900.000000 PORT ReactiveOnKeystroke:"true" PORT -Title:"Active Vectors" +Title:"Free" FIN_BOX BOX wx:Slider:Box06 ISEXEC:FALSE -96.421419:49.928393:-900.000000 -147.821419:39.928393:-900.000000 +66.807373:29.968648:-900.000000 +96.607373:27.468648:-900.000000 PORT In:"100" PORT @@ -124,16 +137,16 @@ FIN_BOX BOX std:Div:Box07 ISEXEC:FALSE -124.614860:-26.900311:-900.000000 -157.389860:-36.900311:-900.000000 +87.230402:-8.070093:-900.000000 +108.155402:-10.570093:-900.000000 PORT In2:"100.0" FIN_BOX BOX wx:Slider:Box08 ISEXEC:FALSE -191.649098:61.508736:-900.000000 -243.049098:51.508736:-900.000000 +133.466748:33.442751:-900.000000 +163.266748:30.942751:-900.000000 PORT ChangeResolution:"true" PORT @@ -152,32 +165,32 @@ FIN_BOX BOX std:Div:Box09 ISEXEC:FALSE -170.827909:-26.212517:-900.000000 -203.602909:-36.212517:-900.000000 +119.579536:-7.863755:-900.000000 +140.504536:-10.363755:-900.000000 PORT In2:"100.0" FIN_BOX BOX wx:LayoutLine:Box10 ISEXEC:FALSE -8.365236:62.514618:-900.000000 -65.925236:52.514618:-900.000000 +3.792803:28.243550:-900.000000 +37.112803:25.743550:-900.000000 PORT -Orientation:"H" +Orientation:"V" FIN_BOX BOX wx:LayoutLine:Box11 ISEXEC:FALSE -47.351525:19.503081:-900.000000 -104.911525:9.503081:-900.000000 +31.495778:7.913786:-900.000000 +64.815778:5.413786:-900.000000 PORT Orientation:"H" FIN_BOX BOX wx:ComboBox:Box12 ISEXEC:FALSE -113.883224:81.760768:-900.000000 -159.458224:71.760768:-900.000000 +79.030636:39.518360:-900.000000 +105.310636:37.018360:-900.000000 PORT In:"A B C" PORT @@ -186,18 +199,74 @@ FIN_BOX BOX wx:LayoutLine:Box13 ISEXEC:FALSE -124.445059:13.148288:-900.000000 -170.020059:3.148288:-900.000000 +87.111541:3.944486:-900.000000 +120.431541:1.444486:-900.000000 PORT Orientation:"H" FIN_BOX BOX std:SharedMemory:Box15 ISEXEC:FALSE --76.284843:36.368355:-900.000000 --30.709843:26.368355:-900.000000 +-43.218130:9.877267:-900.000000 +-20.458130:7.377267:-900.000000 +FIN_BOX +BOX +wx:LayoutLine:Box16 +ISEXEC:FALSE +-85.271364:42.217201:-900.000000 +-51.951364:39.717201:-900.000000 +PORT +Orientation:"H" +FIN_BOX +BOX +wx:CheckBox:Box17 +ISEXEC:FALSE +-85.405279:58.765018:-900.000000 +-63.775279:56.265018:-900.000000 +PORT +In:"false" +PORT +ReactiveOnKeystroke:"true" +PORT +Title:"XY" +FIN_BOX +BOX +wx:CheckBox:Box18 +ISEXEC:FALSE +-76.281134:53.888110:-900.000000 +-54.651134:51.388110:-900.000000 +PORT +In:"false" +PORT +ReactiveOnKeystroke:"true" +PORT +Title:"XZ" +FIN_BOX +BOX +wx:CheckBox:Box19 +ISEXEC:FALSE +-70.157516:49.511289:-900.000000 +-48.527516:47.011289:-900.000000 +PORT +In:"false" +PORT +ReactiveOnKeystroke:"true" +PORT +Title:"YZ" +FIN_BOX +BOX +wx:OutputText:Box20 +ISEXEC:FALSE +19.192871:38.142357:-900.000000 +40.862871:35.642357:-900.000000 FIN_BOX -CONNECTIONS:28 +BOX +std:MultipleInputs:Box21 +ISEXEC:FALSE +-54.970140:33.506544:-900.000000 +-33.000140:31.006544:-900.000000 +FIN_BOX +CONNECTIONS:40 CONNECTION Box03:Widget:Box04:Widget1 NumberOfControlPoints:0 @@ -238,21 +307,12 @@ CONNECTION Box06:Widget:Box11:Widget2 NumberOfControlPoints:0 CONNECTION -Box10:Widget:Box03:Widget1 -NumberOfControlPoints:0 -CONNECTION -Box11:Widget:Box03:Widget2 -NumberOfControlPoints:0 -CONNECTION Box08:Widget:Box13:Widget1 NumberOfControlPoints:0 CONNECTION Box12:Widget:Box13:Widget2 NumberOfControlPoints:0 CONNECTION -Box13:Widget:Box03:Widget3 -NumberOfControlPoints:0 -CONNECTION Box12:Out:typeForm:typeForm NumberOfControlPoints:0 CONNECTION @@ -282,4 +342,49 @@ NumberOfControlPoints:0 CONNECTION Box15:BoxChange:Box04:BoxExecute NumberOfControlPoints:0 +CONNECTION +Box11:Widget:Box03:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box13:Widget:Box03:Widget6 +NumberOfControlPoints:0 +CONNECTION +Box17:Widget:Box16:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box18:Widget:Box16:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box19:Widget:Box16:Widget6 +NumberOfControlPoints:0 +CONNECTION +Box16:Widget:Box03:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box10:Widget:Box16:Widget8 +NumberOfControlPoints:0 +CONNECTION +Box20:Widget:Box10:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box17:BoxChange:Box21:In1 +NumberOfControlPoints:0 +CONNECTION +Box18:BoxChange:Box21:In2 +NumberOfControlPoints:0 +CONNECTION +Box19:BoxChange:Box21:In3 +NumberOfControlPoints:0 +CONNECTION +Box21:BoxChange:Box15:In6 +NumberOfControlPoints:0 +CONNECTION +Box17:Out:active_xy:active_xy +NumberOfControlPoints:0 +CONNECTION +Box18:Out:avtive_xz:avtive_xz +NumberOfControlPoints:0 +CONNECTION +Box19:Out:active_yz:active_yz +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs index 23766a1..d853c91 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs @@ -1,6 +1,6 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /tmpEED/creaTools/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs +# - BBTKGEditor v 1.6 BBS BlackBox Script (Complex Box) +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Interface.bbs # ---------------------------------- include std @@ -8,7 +8,7 @@ include itkvtk include wx include std -define PlaneVectorViso_Interface creaVtk +define PlaneVectorVisu_Interface creaVtk author "Author ??" description "Description ??" @@ -26,7 +26,7 @@ new wx:Slider Box00 new wx:CheckBox Box01 set Box01.In "false" set Box01.ReactiveOnKeystroke "true" - set Box01.Title "Plane control" + set Box01.Title "control" new wx:LayoutLine Box03 set Box03.WinTitle "Plane flield" @@ -35,7 +35,7 @@ new wx:LayoutTab Box04 new wx:CheckBox Box05 set Box05.ReactiveOnKeystroke "true" - set Box05.Title "Active Vectors" + set Box05.Title "Free" new wx:Slider Box06 set Box06.In "100" @@ -61,7 +61,7 @@ new std:Div Box09 set Box09.In2 "100.0" new wx:LayoutLine Box10 - set Box10.Orientation "H" + set Box10.Orientation "V" new wx:LayoutLine Box11 set Box11.Orientation "H" @@ -75,6 +75,28 @@ new wx:LayoutLine Box13 new std:SharedMemory Box15 +new wx:LayoutLine Box16 + set Box16.Orientation "H" + +new wx:CheckBox Box17 + set Box17.In "false" + set Box17.ReactiveOnKeystroke "true" + set Box17.Title "XY" + +new wx:CheckBox Box18 + set Box18.In "false" + set Box18.ReactiveOnKeystroke "true" + set Box18.Title "XZ" + +new wx:CheckBox Box19 + set Box19.In "false" + set Box19.ReactiveOnKeystroke "true" + set Box19.Title "YZ" + +new wx:OutputText Box20 + +new std:MultipleInputs Box21 + connect Box03.Widget Box04.Widget1 connect Box06.Out Box07.In1 @@ -83,11 +105,8 @@ connect Box01.Widget Box10.Widget1 connect Box05.Widget Box10.Widget2 connect Box00.Widget Box11.Widget1 connect Box06.Widget Box11.Widget2 -connect Box10.Widget Box03.Widget1 -connect Box11.Widget Box03.Widget2 connect Box08.Widget Box13.Widget1 connect Box12.Widget Box13.Widget2 -connect Box13.Widget Box03.Widget3 connect Box00.BoxChange Box15.In connect Box01.BoxChange Box15.In1 connect Box05.BoxChange Box15.In2 @@ -95,6 +114,18 @@ connect Box06.BoxChange Box15.In3 connect Box08.BoxChange Box15.In4 connect Box12.BoxChange Box15.In5 connect Box15.BoxChange Box04.BoxExecute +connect Box11.Widget Box03.Widget4 +connect Box13.Widget Box03.Widget6 +connect Box17.Widget Box16.Widget2 +connect Box18.Widget Box16.Widget4 +connect Box19.Widget Box16.Widget6 +connect Box16.Widget Box03.Widget2 +connect Box10.Widget Box16.Widget8 +connect Box20.Widget Box10.Widget4 +connect Box17.BoxChange Box21.In1 +connect Box18.BoxChange Box21.In2 +connect Box19.BoxChange Box21.In3 +connect Box21.BoxChange Box15.In6 # Complex input ports input typeFormsStr Box12.In " " @@ -108,6 +139,9 @@ output ScaleFactor Box09.Out " " output Ratio Box00.Out " " output typeForm Box12.Out " " output boxChange Box15.BoxChange " " +output active_xy Box17.Out " " +output avtive_xz Box18.Out " " +output active_yz Box19.Out " " endefine diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg index aff184d..c5e1036 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg @@ -1,81 +1,86 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg +# - BBTKGEditor v 1.6 BBG BlackBox Diagram file +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg # ---------------------------------- APP_START CATEGORY: DESCRIPTION:Description ?? AUTHOR:Author ?? +EXPORTFORMAT:0 COMPLEXBOX:TRUE COMPLEXBOXNAME:PlaneVectorVisu_Widget PACKAGENAME:creaVtk COMPLEXOUTPUTS:2 COMPLEX_PORT Widget -86.258910:-108.178434:-900.000000 +57.919555:-90.419950:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT boxchange --75.932205:-101.708611:-900.000000 +-46.276337:-89.923007:-900.000000 FIN_COMPLEX_PORT -COMPLEXINPUTS:3 +COMPLEXINPUTS:4 COMPLEX_PORT vtkImageData -38.028121:89.676762:-900.000000 +34.045988:67.335122:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT renderer --52.117833:88.203991:-900.000000 +-37.376390:69.162439:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT boxexecute --104.232070:88.823851:-900.000000 +-65.536146:67.079249:-900.000000 FIN_COMPLEX_PORT -BOXES:9 +COMPLEX_PORT +_point +-100.903572:70.586075:-900.000000 +FIN_COMPLEX_PORT +BOXES:35 BOX creaVtk:VectorsVisu:Box00 ISEXEC:FALSE --4.465574:-69.418679:-900.000000 -33.159426:-79.418679:-900.000000 +-6.756539:-48.963041:-900.000000 +15.013461:-51.463041:-900.000000 FIN_BOX BOX creaVtk:PlaneWidget:Box01 ISEXEC:FALSE --66.409855:2.022991:-900.000000 --27.884855:-7.977009:-900.000000 +-19.408397:-19.512883:-900.000000 +2.436603:-22.012883:-900.000000 FIN_BOX BOX vtk:ProbeFilter:Box03 ISEXEC:FALSE --29.657798:-23.712064:-900.000000 -6.742202:-33.712064:-900.000000 +-10.171101:-27.687229:-900.000000 +11.468899:-30.187229:-900.000000 FIN_BOX BOX vtk:vtkImageDataPointerRelay:Box04 ISEXEC:FALSE -31.994878:59.395975:-900.000000 -84.169878:49.395975:-900.000000 +29.822718:58.250886:-900.000000 +53.032718:55.750886:-900.000000 FIN_BOX BOX std:MagicBox:Box05 ISEXEC:FALSE --63.018802:49.434694:-900.000000 --26.943802:39.434694:-900.000000 +-36.686858:55.262502:-900.000000 +-15.086858:52.762502:-900.000000 FIN_BOX BOX -creaVtk:PlaneVectorViso_Interface:Box06 +creaVtk:PlaneVectorVisu_Interface:Box06 ISEXEC:FALSE -53.843860:42.438188:-900.000000 -105.768860:32.438188:-900.000000 +-45.951472:29.990734:-900.000000 +-22.756472:27.490734:-900.000000 PORT typeFormsStr:"Line Arrow" FIN_BOX BOX vtk:UpdateRender:Box13 ISEXEC:FALSE --129.325679:-71.617843:-900.000000 --89.000679:-81.617843:-900.000000 +-18.754133:-69.343749:-900.000000 +3.270867:-71.843749:-900.000000 PORT Active:"true" PORT @@ -84,16 +89,212 @@ FIN_BOX BOX std:SharedMemory:Box15 ISEXEC:FALSE --79.072661:-36.761184:-900.000000 --37.897661:-46.761184:-900.000000 +-29.331298:-35.383878:-900.000000 +-6.571298:-37.883878:-900.000000 FIN_BOX BOX std:MagicBox:Box11 ISEXEC:FALSE --116.304953:49.494646:-900.000000 --80.229953:39.494646:-900.000000 +-73.987164:55.280487:-900.000000 +-52.387164:52.780487:-900.000000 +FIN_BOX +BOX +vtk:ImageVtkProperties:Box10 +ISEXEC:FALSE +-160.286184:40.103245:-900.000000 +-137.751184:37.603245:-900.000000 +FIN_BOX +BOX +std:MagicBox:Box12 +ISEXEC:FALSE +-122.136747:39.285446:-900.000000 +-100.536747:36.785446:-900.000000 +FIN_BOX +BOX +std:GetVectorIntElement:Box14 +ISEXEC:FALSE +-125.320317:31.887685:-900.000000 +-102.660317:29.387685:-900.000000 +PORT +I:"0" +FIN_BOX +BOX +std:GetVectorIntElement:Box16 +ISEXEC:FALSE +-116.596868:28.048158:-900.000000 +-93.936868:25.548158:-900.000000 +PORT +I:"1" +FIN_BOX +BOX +std:GetVectorIntElement:Box17 +ISEXEC:FALSE +-101.756321:23.766568:-900.000000 +-79.096321:21.266568:-900.000000 +PORT +I:"2" +FIN_BOX +BOX +std:MathOperationVector:Box18 +ISEXEC:FALSE +-162.886078:32.173145:-900.000000 +-138.366078:29.673145:-900.000000 +PORT +In1:"2 2 2" +PORT +Type:"3" +FIN_BOX +BOX +std:GetVectorDoubleElement:Box19 +ISEXEC:FALSE +-172.137701:24.046719:-900.000000 +-149.012701:21.546719:-900.000000 +PORT +I:"0" FIN_BOX -CONNECTIONS:23 +BOX +std:GetVectorDoubleElement:Box20 +ISEXEC:FALSE +-164.263776:18.544701:-900.000000 +-141.138776:16.044701:-900.000000 +PORT +I:"0" +FIN_BOX +BOX +std:GetVectorDoubleElement:Box21 +ISEXEC:FALSE +-152.139105:12.292551:-900.000000 +-129.014105:9.792551:-900.000000 +PORT +I:"0" +FIN_BOX +BOX +std:ConcatStrings:Box22 +ISEXEC:FALSE +-202.656805:-24.280510:-900.000000 +-179.896805:-26.780510:-900.000000 +PORT +In2:" " +PORT +In4:" " +FIN_BOX +BOX +std:MathOperationVector:Box23 +ISEXEC:FALSE +-204.084512:-32.495504:-900.000000 +-179.564512:-34.995504:-900.000000 +PORT +Type:"2" +FIN_BOX +BOX +creaVtk:PlaneSource:Box24 +ISEXEC:FALSE +-204.507130:-42.671237:-900.000000 +-182.662130:-45.171237:-900.000000 +PORT +Normal:"0 0 1" +FIN_BOX +BOX +std:MagicBox:Box25 +ISEXEC:FALSE +-132.380726:1.542771:-900.000000 +-110.780726:-0.957229:-900.000000 +FIN_BOX +BOX +vtk:ProbeFilter:Box26 +ISEXEC:FALSE +-201.956683:-50.060033:-900.000000 +-180.316683:-52.560033:-900.000000 +FIN_BOX +BOX +creaVtk:VectorsVisu:Box27 +ISEXEC:FALSE +-206.186175:-58.076439:-900.000000 +-184.416175:-60.576439:-900.000000 +FIN_BOX +BOX +std:MultipleInputs:Box28 +ISEXEC:FALSE +-104.850896:2.020354:-900.000000 +-82.880896:-0.479646:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box29 +ISEXEC:FALSE +-147.262043:-24.249057:-900.000000 +-124.502043:-26.749057:-900.000000 +PORT +In2:" " +PORT +In4:" " +FIN_BOX +BOX +std:MathOperationVector:Box30 +ISEXEC:FALSE +-148.139653:-31.501382:-900.000000 +-123.619653:-34.001382:-900.000000 +PORT +Type:"2" +FIN_BOX +BOX +creaVtk:PlaneSource:Box31 +ISEXEC:FALSE +-149.222387:-41.897153:-900.000000 +-127.377387:-44.397153:-900.000000 +PORT +Normal:"0 1 0" +FIN_BOX +BOX +vtk:ProbeFilter:Box32 +ISEXEC:FALSE +-146.011824:-49.753532:-900.000000 +-124.371824:-52.253532:-900.000000 +FIN_BOX +BOX +creaVtk:VectorsVisu:Box33 +ISEXEC:FALSE +-149.182380:-58.897636:-900.000000 +-127.412380:-61.397636:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box34 +ISEXEC:FALSE +-100.283757:-19.307993:-900.000000 +-77.523757:-21.807993:-900.000000 +PORT +In2:" " +PORT +In4:" " +FIN_BOX +BOX +std:MathOperationVector:Box35 +ISEXEC:FALSE +-101.161367:-26.560318:-900.000000 +-76.641367:-29.060318:-900.000000 +PORT +Type:"2" +FIN_BOX +BOX +creaVtk:PlaneSource:Box36 +ISEXEC:FALSE +-101.033889:-37.561195:-900.000000 +-79.188889:-40.061195:-900.000000 +PORT +Normal:"1 0 0" +FIN_BOX +BOX +vtk:ProbeFilter:Box37 +ISEXEC:FALSE +-99.941197:-44.358638:-900.000000 +-78.301197:-46.858638:-900.000000 +FIN_BOX +BOX +creaVtk:VectorsVisu:Box38 +ISEXEC:FALSE +-102.506647:-58.646145:-900.000000 +-80.736647:-61.146145:-900.000000 +FIN_BOX +CONNECTIONS:86 CONNECTION Box03:Out:Box00:In NumberOfControlPoints:0 @@ -163,4 +364,193 @@ NumberOfControlPoints:0 CONNECTION Box01:BoxChange:Box15:In3 NumberOfControlPoints:0 +CONNECTION +Box04:Out:Box10:In +NumberOfControlPoints:0 +CONNECTION +_point:_point:Box12:In +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box14:In +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box16:In +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box17:In +NumberOfControlPoints:0 +CONNECTION +Box10:Size:Box18:In0 +NumberOfControlPoints:0 +CONNECTION +Box18:Out:Box19:In +NumberOfControlPoints:0 +CONNECTION +Box18:Out:Box20:In +NumberOfControlPoints:0 +CONNECTION +Box18:Out:Box21:In +NumberOfControlPoints:0 +CONNECTION +Box22:Out:Box23:In0 +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box24:Center +NumberOfControlPoints:0 +CONNECTION +Box10:Spacing:Box23:In1 +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box24:XResolution +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box24:YResolution +NumberOfControlPoints:0 +CONNECTION +Box06:Ratio:Box25:In +NumberOfControlPoints:0 +CONNECTION +Box24:PolyData:Box26:Input +NumberOfControlPoints:0 +CONNECTION +Box04:Out:Box26:Source +NumberOfControlPoints:0 +CONNECTION +Box26:Out:Box27:In +NumberOfControlPoints:0 +CONNECTION +Box06:active_xy:Box27:Active +NumberOfControlPoints:0 +CONNECTION +Box19:Out:Box22:In1 +NumberOfControlPoints:0 +CONNECTION +Box20:Out:Box22:In3 +NumberOfControlPoints:0 +CONNECTION +Box17:Out:Box22:In5 +NumberOfControlPoints:0 +CONNECTION +Box11:Out:Box28:In1 +NumberOfControlPoints:0 +CONNECTION +Box28:BoxChange:Box27:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box06:boxChange:Box28:In2 +NumberOfControlPoints:0 +CONNECTION +Box06:Opacity:Box27:Opacity +NumberOfControlPoints:0 +CONNECTION +Box05:Out:Box27:Renderer +NumberOfControlPoints:0 +CONNECTION +Box06:ScaleFactor:Box27:ScaleFactor +NumberOfControlPoints:0 +CONNECTION +Box06:typeForm:Box27:TypeForm +NumberOfControlPoints:0 +CONNECTION +Box29:Out:Box30:In0 +NumberOfControlPoints:0 +CONNECTION +Box30:Out:Box31:Center +NumberOfControlPoints:0 +CONNECTION +Box31:PolyData:Box32:Input +NumberOfControlPoints:0 +CONNECTION +Box32:Out:Box33:In +NumberOfControlPoints:0 +CONNECTION +Box19:Out:Box29:In1 +NumberOfControlPoints:0 +CONNECTION +Box21:Out:Box29:In5 +NumberOfControlPoints:0 +CONNECTION +Box16:Out:Box29:In3 +NumberOfControlPoints:0 +CONNECTION +Box10:Spacing:Box30:In1 +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box31:XResolution +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box31:YResolution +NumberOfControlPoints:0 +CONNECTION +Box04:Out:Box32:Source +NumberOfControlPoints:0 +CONNECTION +Box28:BoxChange:Box33:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box06:Opacity:Box33:Opacity +NumberOfControlPoints:0 +CONNECTION +Box05:Out:Box33:Renderer +NumberOfControlPoints:0 +CONNECTION +Box06:ScaleFactor:Box33:ScaleFactor +NumberOfControlPoints:0 +CONNECTION +Box06:typeForm:Box33:TypeForm +NumberOfControlPoints:0 +CONNECTION +Box34:Out:Box35:In0 +NumberOfControlPoints:0 +CONNECTION +Box35:Out:Box36:Center +NumberOfControlPoints:0 +CONNECTION +Box36:PolyData:Box37:Input +NumberOfControlPoints:0 +CONNECTION +Box37:Out:Box38:In +NumberOfControlPoints:0 +CONNECTION +Box20:Out:Box34:In3 +NumberOfControlPoints:0 +CONNECTION +Box21:Out:Box34:In5 +NumberOfControlPoints:0 +CONNECTION +Box14:Out:Box34:In1 +NumberOfControlPoints:0 +CONNECTION +Box10:Spacing:Box35:In1 +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box36:XResolution +NumberOfControlPoints:0 +CONNECTION +Box25:Out:Box36:YResolution +NumberOfControlPoints:0 +CONNECTION +Box04:Out:Box37:Source +NumberOfControlPoints:0 +CONNECTION +Box28:BoxChange:Box38:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box06:Opacity:Box38:Opacity +NumberOfControlPoints:0 +CONNECTION +Box06:ScaleFactor:Box38:ScaleFactor +NumberOfControlPoints:0 +CONNECTION +Box06:typeForm:Box38:TypeForm +NumberOfControlPoints:0 +CONNECTION +Box05:Out:Box38:Renderer +NumberOfControlPoints:0 +CONNECTION +Box06:avtive_xz:Box33:Active +NumberOfControlPoints:0 +CONNECTION +Box06:active_yz:Box38:Active +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs index 443ca11..e8e6876 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs @@ -1,6 +1,6 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs +# - BBTKGEditor v 1.6 BBS BlackBox Script (Complex Box) +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs # ---------------------------------- include std @@ -26,7 +26,7 @@ new vtk:vtkImageDataPointerRelay Box04 new std:MagicBox Box05 -new creaVtk:PlaneVectorViso_Interface Box06 +new creaVtk:PlaneVectorVisu_Interface Box06 set Box06.typeFormsStr "Line Arrow" new vtk:UpdateRender Box13 @@ -37,6 +37,78 @@ new std:SharedMemory Box15 new std:MagicBox Box11 +new vtk:ImageVtkProperties Box10 + +new std:MagicBox Box12 + +new std:GetVectorIntElement Box14 + set Box14.I "0" + +new std:GetVectorIntElement Box16 + set Box16.I "1" + +new std:GetVectorIntElement Box17 + set Box17.I "2" + +new std:MathOperationVector Box18 + set Box18.In1 "2 2 2" + set Box18.Type "3" + +new std:GetVectorDoubleElement Box19 + set Box19.I "0" + +new std:GetVectorDoubleElement Box20 + set Box20.I "0" + +new std:GetVectorDoubleElement Box21 + set Box21.I "0" + +new std:ConcatStrings Box22 + set Box22.In2 " " + set Box22.In4 " " + +new std:MathOperationVector Box23 + set Box23.Type "2" + +new creaVtk:PlaneSource Box24 + set Box24.Normal "0 0 1" + +new std:MagicBox Box25 + +new vtk:ProbeFilter Box26 + +new creaVtk:VectorsVisu Box27 + +new std:MultipleInputs Box28 + +new std:ConcatStrings Box29 + set Box29.In2 " " + set Box29.In4 " " + +new std:MathOperationVector Box30 + set Box30.Type "2" + +new creaVtk:PlaneSource Box31 + set Box31.Normal "0 1 0" + +new vtk:ProbeFilter Box32 + +new creaVtk:VectorsVisu Box33 + +new std:ConcatStrings Box34 + set Box34.In2 " " + set Box34.In4 " " + +new std:MathOperationVector Box35 + set Box35.Type "2" + +new creaVtk:PlaneSource Box36 + set Box36.Normal "1 0 0" + +new vtk:ProbeFilter Box37 + +new creaVtk:VectorsVisu Box38 + connect Box03.Out Box00.In connect Box01.Out Box03.Input @@ -56,11 +128,74 @@ connect Box06.boxChange Box15.In1 connect Box15.Out Box13.BoxExecute connect Box11.Out Box15.In2 connect Box01.BoxChange Box15.In3 +connect Box04.Out Box10.In +connect Box12.Out Box14.In +connect Box12.Out Box16.In +connect Box12.Out Box17.In +connect Box10.Size Box18.In0 +connect Box18.Out Box19.In +connect Box18.Out Box20.In +connect Box18.Out Box21.In +connect Box22.Out Box23.In0 +connect Box23.Out Box24.Center +connect Box10.Spacing Box23.In1 +connect Box25.Out Box24.XResolution +connect Box25.Out Box24.YResolution +connect Box06.Ratio Box25.In +connect Box24.PolyData Box26.Input +connect Box04.Out Box26.Source +connect Box26.Out Box27.In +connect Box06.active_xy Box27.Active +connect Box19.Out Box22.In1 +connect Box20.Out Box22.In3 +connect Box17.Out Box22.In5 +connect Box11.Out Box28.In1 +connect Box28.BoxChange Box27.BoxExecute +connect Box06.boxChange Box28.In2 +connect Box06.Opacity Box27.Opacity +connect Box05.Out Box27.Renderer +connect Box06.ScaleFactor Box27.ScaleFactor +connect Box06.typeForm Box27.TypeForm +connect Box29.Out Box30.In0 +connect Box30.Out Box31.Center +connect Box31.PolyData Box32.Input +connect Box32.Out Box33.In +connect Box19.Out Box29.In1 +connect Box21.Out Box29.In5 +connect Box16.Out Box29.In3 +connect Box10.Spacing Box30.In1 +connect Box25.Out Box31.XResolution +connect Box25.Out Box31.YResolution +connect Box04.Out Box32.Source +connect Box28.BoxChange Box33.BoxExecute +connect Box06.Opacity Box33.Opacity +connect Box05.Out Box33.Renderer +connect Box06.ScaleFactor Box33.ScaleFactor +connect Box06.typeForm Box33.TypeForm +connect Box34.Out Box35.In0 +connect Box35.Out Box36.Center +connect Box36.PolyData Box37.Input +connect Box37.Out Box38.In +connect Box20.Out Box34.In3 +connect Box21.Out Box34.In5 +connect Box14.Out Box34.In1 +connect Box10.Spacing Box35.In1 +connect Box25.Out Box36.XResolution +connect Box25.Out Box36.YResolution +connect Box04.Out Box37.Source +connect Box28.BoxChange Box38.BoxExecute +connect Box06.Opacity Box38.Opacity +connect Box06.ScaleFactor Box38.ScaleFactor +connect Box06.typeForm Box38.TypeForm +connect Box05.Out Box38.Renderer +connect Box06.avtive_xz Box33.Active +connect Box06.active_yz Box38.Active # Complex input ports input vtkImageData Box04.In " " input renderer Box05.In " " input boxexecute Box11.BoxExecute " " +input _point Box12.In " " # Complex output ports output Widget Box06.widget " " diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg b/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg index f1a04f4..cee937b 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg @@ -1,131 +1,152 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg +# - BBTKGEditor v 1.6 BBG BlackBox Diagram file +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbg # ---------------------------------- APP_START CATEGORY: DESCRIPTION:Description ?? AUTHOR:Author ?? +EXPORTFORMAT:0 COMPLEXBOX:TRUE COMPLEXBOXNAME:VectorsTensors_Widget PACKAGENAME:creaVtk COMPLEXOUTPUTS:1 COMPLEX_PORT widget --133.205566:-215.108938:-900.000000 +-93.243896:-64.532681:-900.000000 FIN_COMPLEX_PORT -COMPLEXINPUTS:3 +COMPLEXINPUTS:5 COMPLEX_PORT vtkImageData_vectors --202.201495:171.786415:-900.000000 +-141.541046:51.535925:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT vtkImageData_tensors --84.383009:173.600108:-900.000000 +-59.068106:52.080032:-900.000000 FIN_COMPLEX_PORT COMPLEX_PORT vtkRenderer -128.828216:174.474869:-900.000000 +90.179751:52.342461:-900.000000 FIN_COMPLEX_PORT -BOXES:14 +COMPLEX_PORT +_viewerExecute +-181.613941:51.790685:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +_pointViewer +-209.411741:54.697096:-900.000000 +FIN_COMPLEX_PORT +BOXES:16 BOX vtk:UpdateRender:Box22 ISEXEC:FALSE -91.911565:-119.753930:-900.000000 -132.236565:-129.753930:-900.000000 +64.338095:-35.926179:-900.000000 +86.363095:-38.426179:-900.000000 PORT Active:"true" FIN_BOX BOX wx:LayoutTab:Box17 ISEXEC:FALSE --148.219985:-138.795108:-900.000000 --90.659985:-148.795108:-900.000000 +-103.753990:-41.638532:-900.000000 +-70.433990:-44.138532:-900.000000 PORT WinTitle:"VectorsTensors Analysis" FIN_BOX BOX std:MultipleInputs:Box23 ISEXEC:FALSE -32.484087:-86.883484:-900.000000 -72.184087:-96.883484:-900.000000 +22.738861:-26.065045:-900.000000 +44.708861:-28.565045:-900.000000 PORT BoxProcessMode:"Reactive" FIN_BOX BOX creaVtk:PlaneVectorVisu_Widget:Box41 ISEXEC:FALSE --290.289955:71.849699:-900.000000 --240.339955:61.849699:-900.000000 +-203.202968:21.554910:-900.000000 +-180.202968:19.054910:-900.000000 FIN_BOX BOX wx:LayoutLine:Box14 ISEXEC:FALSE --249.537648:23.883192:-900.000000 --191.977648:13.883192:-900.000000 +-174.676354:7.164958:-900.000000 +-141.356354:4.664958:-900.000000 PORT WinTitle:"Field" FIN_BOX BOX creaVtk:VolumeVectorVisu_Widget:Box18 ISEXEC:FALSE --214.258652:71.383715:-900.000000 --162.208652:61.383715:-900.000000 +-149.981056:21.415114:-900.000000 +-126.761056:18.915114:-900.000000 FIN_BOX BOX wx:LayoutLine:Box16 ISEXEC:FALSE --107.142871:-103.536135:-900.000000 --49.582871:-113.536135:-900.000000 +-75.000010:-31.060840:-900.000000 +-41.680010:-33.560840:-900.000000 PORT WinTitle:"Tensors" FIN_BOX BOX creaVtk:VolumeTensorVisu_Widget:Box19 ISEXEC:FALSE -60.863865:72.033730:-900.000000 -112.563865:62.033730:-900.000000 +42.604705:21.610119:-900.000000 +65.789705:19.110119:-900.000000 FIN_BOX BOX creaVtk:PlaneTensorVisu_Widget:Box21 ISEXEC:FALSE --17.702072:72.444185:-900.000000 -31.897928:62.444185:-900.000000 +-12.391450:21.733256:-900.000000 +10.573550:19.233256:-900.000000 FIN_BOX BOX creaVtk:PlaneWidget_StreamLineVisu_Widget:Box30 ISEXEC:FALSE --156.561665:28.789589:-900.000000 --94.686665:18.789589:-900.000000 +-109.593165:8.636877:-900.000000 +-85.398165:6.136877:-900.000000 FIN_BOX BOX vtk:vtkImageDataPointerRelay:Box26 ISEXEC:FALSE --208.540015:141.393307:-900.000000 --154.090517:131.393307:-900.000000 +-145.978011:42.417992:-900.000000 +-122.768011:39.917992:-900.000000 FIN_BOX BOX vtk:vtkImageDataPointerRelay:Box27 ISEXEC:FALSE --89.314298:137.998626:-900.000000 --37.139298:127.998626:-900.000000 +-62.520009:41.399588:-900.000000 +-39.310009:38.899588:-900.000000 FIN_BOX BOX std:MagicBox:Box28 ISEXEC:FALSE -123.517825:137.982960:-900.000000 -159.592825:127.982960:-900.000000 +86.462477:41.394888:-900.000000 +108.062477:38.894888:-900.000000 FIN_BOX BOX wx:LayoutTab:Box29 ISEXEC:FALSE --175.679382:-102.651254:-900.000000 --118.119382:-112.651254:-900.000000 +-122.975567:-30.795376:-900.000000 +-89.655567:-33.295376:-900.000000 PORT WinTitle:"Vectors" FIN_BOX -CONNECTIONS:31 +BOX +std:MagicBox:Box15 +ISEXEC:FALSE +-193.706938:37.145989:-900.000000 +-172.106938:34.645989:-900.000000 +FIN_BOX +BOX +std:MagicBox:Box20 +ISEXEC:FALSE +-219.964001:37.144937:-900.000000 +-198.364001:34.644937:-900.000000 +FIN_BOX +CONNECTIONS:35 CONNECTION Box23:BoxChange:Box22:BoxExecute NumberOfControlPoints:0 @@ -219,4 +240,16 @@ NumberOfControlPoints:0 CONNECTION Box18:boxchange:Box29:BoxExecute NumberOfControlPoints:0 +CONNECTION +_viewerExecute:_viewerExecute:Box15:In +NumberOfControlPoints:0 +CONNECTION +Box15:BoxChange:Box41:boxexecute +NumberOfControlPoints:0 +CONNECTION +_pointViewer:_pointViewer:Box20:In +NumberOfControlPoints:0 +CONNECTION +Box20:Out:Box41:_point +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs b/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs index 8117a50..b4e28b4 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs @@ -1,6 +1,6 @@ # ---------------------------------- -# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs +# - BBTKGEditor v 1.6 BBS BlackBox Script (Complex Box) +# - /Users/davila/Creatis/C23/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/VectorsTensors_Widget.bbs # ---------------------------------- include std @@ -51,6 +51,10 @@ new std:MagicBox Box28 new wx:LayoutTab Box29 set Box29.WinTitle "Vectors" +new std:MagicBox Box15 + +new std:MagicBox Box20 + connect Box23.BoxChange Box22.BoxExecute connect Box41.boxchange Box23.In1 @@ -79,11 +83,15 @@ connect Box29.Widget Box17.Widget1 connect Box16.Widget Box17.Widget2 connect Box41.boxchange Box14.BoxExecute connect Box18.boxchange Box29.BoxExecute +connect Box15.BoxChange Box41.boxexecute +connect Box20.Out Box41._point # Complex input ports input vtkImageData_vectors Box26.In " " input vtkImageData_tensors Box27.In " " input vtkRenderer Box28.In " " +input _viewerExecute Box15.In " " +input _pointViewer Box20.In " " # Complex output ports output widget Box17.Widget " " diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx index 91f5a49..2521476 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx @@ -21,17 +21,17 @@ void PlaneSource::Process() double p1[3]; double p2[3]; vtkPlaneSource *plane; - plane = vtkPlaneSource::New(); - c[0] = bbGetInputCenter()[0]; - c[1] = bbGetInputCenter()[1]; - c[2] = bbGetInputCenter()[2]; - p0[0] = 0; - p0[1] = 0; - p0[2] = 0; + plane = vtkPlaneSource::New(); + c[0] = bbGetInputCenter()[0]; + c[1] = bbGetInputCenter()[1]; + c[2] = bbGetInputCenter()[2]; + p0[0] = 0; + p0[1] = 0; + p0[2] = 0; - bool byNormal=true; - double size=350; + bool byNormal = true; + double size = 350; // xy if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==1) ) @@ -69,6 +69,20 @@ void PlaneSource::Process() p2[2] = size; } +/* + p0[0] = c[0]; + p0[1] = c[1]; + p0[2] = c[2]; + + p1[0] = c[0]+0; + p1[1] = c[1]+size; + p1[2] = c[2]+0; + + p2[0] = c[0]+0; + p2[1] = c[1]+0; + p2[2] = c[2]+size; +*/ + plane->SetResolution( bbGetInputXResolution(), bbGetInputYResolution() ); if (byNormal==false) { @@ -79,14 +93,14 @@ void PlaneSource::Process() 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->SetCenter( c ); plane->Update( ); bbSetOutputPlane( (vtkDataSet*)plane ); 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() diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx index d15268b..d04e569 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsVisu.cxx @@ -3,17 +3,17 @@ //===== #include "bbcreaVtkVectorsVisu.h" #include "bbcreaVtkPackage.h" + namespace bbcreaVtk { - BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VectorsVisu) BBTK_BLACK_BOX_IMPLEMENTATION(VectorsVisu,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 VectorsVisu::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -25,7 +25,6 @@ void VectorsVisu::Process() // (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') - vectorsvisu.SetActive( bbGetInputActive() ); vectorsvisu.SetDataObject( bbGetInputIn() ); vectorsvisu.SetScaleFactor( bbGetInputScaleFactor() ); @@ -35,9 +34,10 @@ void VectorsVisu::Process() vectorsvisu.SetOrientation( bbGetInputOrientation() ); vectorsvisu.SetExternalLut( bbGetInputExternalLut() ); vectorsvisu.Process(); - bbSetOutputOut( vectorsvisu.GetProp3D() ); + bbSetOutputOut( vectorsvisu.GetProp3D() ); } -//===== + +//===== // 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 VectorsVisu::bbUserSetDefaultValues() @@ -45,7 +45,6 @@ void VectorsVisu::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputActive(false); bbSetInputIn(NULL); bbSetInputRenderer(NULL); @@ -55,32 +54,29 @@ void VectorsVisu::bbUserSetDefaultValues() bbSetInputOrientation(-1); bbSetInputExternalLut(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 VectorsVisu::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// 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 VectorsVisu::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk diff --git a/lib/creaVtk/vtkVectorsVisu.cpp b/lib/creaVtk/vtkVectorsVisu.cpp index 51392f7..543ab17 100644 --- a/lib/creaVtk/vtkVectorsVisu.cpp +++ b/lib/creaVtk/vtkVectorsVisu.cpp @@ -115,10 +115,8 @@ void vtkVectorsVisu::Process() } // _orientation } // _vtkglyph NULL - if(_active==true) { - if (GetDataObject()!=NULL) { #if VTK_MAJOR_VERSION <= 5 @@ -143,7 +141,6 @@ void vtkVectorsVisu::Process() } _vtkglyph->SetScaleModeToScaleByVector(); - if (_externalLut==NULL) { _vtkglyph->SetColorModeToColorByVector(); @@ -261,7 +258,7 @@ void vtkVectorsVisu::Process() _actor->SetMapper( _pdm ); _actor->GetProperty()->SetOpacity( GetOpacity() ); } else { - printf("EED Warnning! vtkVectorsVisu::Process GetDataObject() is EMPTY\n"); + printf("EED Warnning! vtkVectorsVisu::Process GetDataObject() is EMPTY \n" ); }// if GetDataObject()!=NULL _pdm->ScalarVisibilityOn(); -- 2.50.0 From 6c65d1fa924cb5c729a2c6e27fc229203b0378fb Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Fri, 6 Dec 2024 11:30:04 +0100 Subject: [PATCH 11/16] Clean code --- bbtk_creaVtk_PKG/.DS_Store | Bin 8196 -> 8196 bytes bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx | 45 ++++++++++-------- bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h | 10 ++-- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/bbtk_creaVtk_PKG/.DS_Store b/bbtk_creaVtk_PKG/.DS_Store index 9e9655d8fd9a5157af96d9e6d516da62ad3f1647..8fd3482ce295b13412c4a47a718c628794e1ca1a 100644 GIT binary patch delta 26 icmZp1XmOYj$H=fTem_4W!)AGb8;p#Mn|}!M@BsjGY6t27 delta 26 icmZp1XmOYj$H=%bem_4W<7Rn*8;pz$n|}!M@BsjGga_*Y diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx index 2521476..a7ed64b 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx @@ -32,12 +32,13 @@ void PlaneSource::Process() bool byNormal = true; double size = 350; - +// bbGetInputVolumeSize ????????? + // xy if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==1) ) { byNormal= false; - p1[0] = size; + p1[0] = size; p1[1] = 0; p1[2] = 0; p2[0] = 0; @@ -93,8 +94,7 @@ void PlaneSource::Process() 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->SetCenter( c ); plane->Update( ); bbSetOutputPlane( (vtkDataSet*)plane ); bbSetOutputPolyData( plane->GetOutput() ); @@ -105,36 +105,39 @@ void PlaneSource::Process() //===== void PlaneSource::bbUserSetDefaultValues() { - std::vector c; - std::vector n; + std::vector c; 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); + bbSetInputCenter( c ); + std::vector n; + n.push_back(1); + n.push_back(0); + n.push_back(0); + bbSetInputNormal( n ); + std::vector volSize; + volSize.push_back(350); + volSize.push_back(350); + volSize.push_back(350); + bbSetInputVolumeSize( volSize ); + 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) //===== void PlaneSource::bbUserInitializeProcessing() { - - } -//===== + +//===== // 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::bbUserFinalizeProcessing() { - - -} } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h index 2646c9b..0f54e0c 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.h @@ -25,6 +25,7 @@ class bbcreaVtk_EXPORT PlaneSource BBTK_DECLARE_INPUT(Normal,std::vector); BBTK_DECLARE_INPUT(XResolution,int); BBTK_DECLARE_INPUT(YResolution,int); + BBTK_DECLARE_INPUT(VolumeSize,std::vector); BBTK_DECLARE_OUTPUT(Plane,vtkDataSet*); BBTK_DECLARE_OUTPUT(PolyData,vtkPolyData*); BBTK_PROCESS(Process); @@ -39,10 +40,11 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneSource,bbtk::AtomicBlackBox); 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_INPUT(PlaneSource,Center,"( default [0,0,0] ) Center ",std::vector,""); + BBTK_INPUT(PlaneSource,Normal,"( default [1,0,0] ) Normal ",std::vector,""); + BBTK_INPUT(PlaneSource,XResolution,"(default 100) XResolution ",int,""); + BBTK_INPUT(PlaneSource,YResolution,"(default 100) YResolution ",int,""); + BBTK_INPUT(PlaneSource,VolumeSize,"(default [350 350 350]) VolumeSize [sizeX sizeY sizeZ] ",std::vector,""); BBTK_OUTPUT(PlaneSource,Plane,"Plane",vtkDataSet*,""); BBTK_OUTPUT(PlaneSource,PolyData,"vtkPolyData",vtkPolyData*,""); BBTK_END_DESCRIBE_BLACK_BOX(PlaneSource); -- 2.50.0 From d1eb905ef3be6516b50e3b80353879df7c156d26 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 9 Dec 2024 18:11:54 +0100 Subject: [PATCH 12/16] #3532 Plane xy xz yz Vectors visu --- .../bbs/boxes/PlaneVectorVisu_Widget.bbg | 83 ++++++++++++------- .../bbs/boxes/PlaneVectorVisu_Widget.bbs | 12 ++- bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx | 39 +++++---- 3 files changed, 88 insertions(+), 46 deletions(-) diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg index c5e1036..09439d2 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbg @@ -37,7 +37,7 @@ COMPLEX_PORT _point -100.903572:70.586075:-900.000000 FIN_COMPLEX_PORT -BOXES:35 +BOXES:36 BOX creaVtk:VectorsVisu:Box00 ISEXEC:FALSE @@ -155,24 +155,24 @@ FIN_BOX BOX std:GetVectorDoubleElement:Box20 ISEXEC:FALSE --164.263776:18.544701:-900.000000 --141.138776:16.044701:-900.000000 +-162.475962:17.994604:-900.000000 +-139.350962:15.494604:-900.000000 PORT -I:"0" +I:"1" FIN_BOX BOX std:GetVectorDoubleElement:Box21 ISEXEC:FALSE --152.139105:12.292551:-900.000000 --129.014105:9.792551:-900.000000 +-152.826726:13.255220:-900.000000 +-129.701726:10.755220:-900.000000 PORT -I:"0" +I:"2" FIN_BOX BOX std:ConcatStrings:Box22 ISEXEC:FALSE --202.656805:-24.280510:-900.000000 --179.896805:-26.780510:-900.000000 +-201.969184:-23.042793:-900.000000 +-179.209184:-25.542793:-900.000000 PORT In2:" " PORT @@ -197,8 +197,8 @@ FIN_BOX BOX std:MagicBox:Box25 ISEXEC:FALSE --132.380726:1.542771:-900.000000 --110.780726:-0.957229:-900.000000 +-129.630243:-1.345236:-900.000000 +-108.030243:-3.845236:-900.000000 FIN_BOX BOX vtk:ProbeFilter:Box26 @@ -209,8 +209,8 @@ FIN_BOX BOX creaVtk:VectorsVisu:Box27 ISEXEC:FALSE --206.186175:-58.076439:-900.000000 --184.416175:-60.576439:-900.000000 +-206.598747:-60.964446:-900.000000 +-184.828747:-63.464446:-900.000000 FIN_BOX BOX std:MultipleInputs:Box28 @@ -221,8 +221,8 @@ FIN_BOX BOX std:ConcatStrings:Box29 ISEXEC:FALSE --147.262043:-24.249057:-900.000000 --124.502043:-26.749057:-900.000000 +-147.262043:-18.473044:-900.000000 +-124.502043:-20.973044:-900.000000 PORT In2:" " PORT @@ -231,36 +231,36 @@ FIN_BOX BOX std:MathOperationVector:Box30 ISEXEC:FALSE --148.139653:-31.501382:-900.000000 --123.619653:-34.001382:-900.000000 +-148.277177:-33.014147:-900.000000 +-123.757177:-35.514147:-900.000000 PORT Type:"2" FIN_BOX BOX creaVtk:PlaneSource:Box31 ISEXEC:FALSE --149.222387:-41.897153:-900.000000 --127.377387:-44.397153:-900.000000 +-151.147725:-41.759629:-900.000000 +-129.302725:-44.259629:-900.000000 PORT Normal:"0 1 0" FIN_BOX BOX vtk:ProbeFilter:Box32 ISEXEC:FALSE --146.011824:-49.753532:-900.000000 --124.371824:-52.253532:-900.000000 +-150.962693:-49.616008:-900.000000 +-129.322693:-52.116008:-900.000000 FIN_BOX BOX creaVtk:VectorsVisu:Box33 ISEXEC:FALSE --149.182380:-58.897636:-900.000000 --127.412380:-61.397636:-900.000000 +-152.070387:-60.135353:-900.000000 +-130.300387:-62.635353:-900.000000 FIN_BOX BOX std:ConcatStrings:Box34 ISEXEC:FALSE --100.283757:-19.307993:-900.000000 --77.523757:-21.807993:-900.000000 +-100.283757:-13.807028:-900.000000 +-77.523757:-16.307028:-900.000000 PORT In2:" " PORT @@ -269,16 +269,16 @@ FIN_BOX BOX std:MathOperationVector:Box35 ISEXEC:FALSE --101.161367:-26.560318:-900.000000 --76.641367:-29.060318:-900.000000 +-100.886319:-28.210608:-900.000000 +-76.366319:-30.710608:-900.000000 PORT Type:"2" FIN_BOX BOX creaVtk:PlaneSource:Box36 ISEXEC:FALSE --101.033889:-37.561195:-900.000000 --79.188889:-40.061195:-900.000000 +-101.446461:-38.111292:-900.000000 +-79.601461:-40.611292:-900.000000 PORT Normal:"1 0 0" FIN_BOX @@ -294,7 +294,15 @@ ISEXEC:FALSE -102.506647:-58.646145:-900.000000 -80.736647:-61.146145:-900.000000 FIN_BOX -CONNECTIONS:86 +BOX +std:MathOperationVector:Box41 +ISEXEC:FALSE +-168.025554:-1.857037:-900.000000 +-143.505554:-4.357037:-900.000000 +PORT +Type:"2" +FIN_BOX +CONNECTIONS:91 CONNECTION Box03:Out:Box00:In NumberOfControlPoints:0 @@ -553,4 +561,19 @@ NumberOfControlPoints:0 CONNECTION Box06:active_yz:Box38:Active NumberOfControlPoints:0 +CONNECTION +Box10:Size:Box41:In0 +NumberOfControlPoints:0 +CONNECTION +Box10:Spacing:Box41:In1 +NumberOfControlPoints:0 +CONNECTION +Box41:Out:Box31:VolumeSize +NumberOfControlPoints:0 +CONNECTION +Box41:Out:Box36:VolumeSize +NumberOfControlPoints:0 +CONNECTION +Box41:Out:Box24:VolumeSize +NumberOfControlPoints:0 APP_END diff --git a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs index e8e6876..49f336f 100644 --- a/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs +++ b/bbtk_creaVtk_PKG/bbs/boxes/PlaneVectorVisu_Widget.bbs @@ -58,10 +58,10 @@ new std:GetVectorDoubleElement Box19 set Box19.I "0" new std:GetVectorDoubleElement Box20 - set Box20.I "0" + set Box20.I "1" new std:GetVectorDoubleElement Box21 - set Box21.I "0" + set Box21.I "2" new std:ConcatStrings Box22 set Box22.In2 " " @@ -109,6 +109,9 @@ new vtk:ProbeFilter Box37 new creaVtk:VectorsVisu Box38 +new std:MathOperationVector Box41 + set Box41.Type "2" + connect Box03.Out Box00.In connect Box01.Out Box03.Input @@ -190,6 +193,11 @@ connect Box06.typeForm Box38.TypeForm connect Box05.Out Box38.Renderer connect Box06.avtive_xz Box33.Active connect Box06.active_yz Box38.Active +connect Box10.Size Box41.In0 +connect Box10.Spacing Box41.In1 +connect Box41.Out Box31.VolumeSize +connect Box41.Out Box36.VolumeSize +connect Box41.Out Box24.VolumeSize # Complex input ports input vtkImageData Box04.In " " diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx index a7ed64b..3c29a25 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx @@ -16,7 +16,10 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PlaneSource,bbtk::AtomicBlackBox); //===== void PlaneSource::Process() { - double c[3]; + double sizeX; + double sizeY; + double sizeZ; + double c[3]; double p0[3]; double p1[3]; double p2[3]; @@ -29,20 +32,28 @@ void PlaneSource::Process() p0[1] = 0; p0[2] = 0; - bool byNormal = true; - double size = 350; -// bbGetInputVolumeSize ????????? + + if (bbGetInputVolumeSize().size()==3) + { + sizeX = bbGetInputVolumeSize()[0]-10; + sizeY = bbGetInputVolumeSize()[1]-10; + sizeZ = bbGetInputVolumeSize()[2]-10; + } else { + sizeX = 40; + sizeY = 40; + sizeZ = 40; + } // xy if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==1) ) { byNormal= false; - p1[0] = size; + p1[0] = sizeX; p1[1] = 0; p1[2] = 0; p2[0] = 0; - p2[1] = size; + p2[1] = sizeY; p2[2] = 0; } @@ -50,12 +61,12 @@ void PlaneSource::Process() if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==1) && (bbGetInputNormal()[2]==0) ) { byNormal= false; - p1[0] = size; + p1[0] = sizeZ; p1[1] = 0; p1[2] = 0; p2[0] = 0; p2[1] = 0; - p2[2] = size; + p2[2] = sizeX; } // yz @@ -63,11 +74,11 @@ void PlaneSource::Process() { byNormal= false; p1[0] = 0; - p1[1] = size; - p1[2] = 0; + p1[1] = sizeY; + p1[2] = 0; p2[0] = 0; p2[1] = 0; - p2[2] = size; + p2[2] = sizeZ; } /* @@ -116,9 +127,9 @@ void PlaneSource::bbUserSetDefaultValues() n.push_back(0); bbSetInputNormal( n ); std::vector volSize; - volSize.push_back(350); - volSize.push_back(350); - volSize.push_back(350); + volSize.push_back(40); + volSize.push_back(40); + volSize.push_back(40); bbSetInputVolumeSize( volSize ); bbSetInputXResolution(100); bbSetInputYResolution(100); -- 2.50.0 From d8fad3bea98887b8309bf67ce694eb8eff7d8fae Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 28 Jan 2025 15:19:21 +0100 Subject: [PATCH 13/16] Clean code --- appli/template_wx_appli/winApp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appli/template_wx_appli/winApp.cpp b/appli/template_wx_appli/winApp.cpp index 17670cb..606275b 100644 --- a/appli/template_wx_appli/winApp.cpp +++ b/appli/template_wx_appli/winApp.cpp @@ -41,7 +41,7 @@ class myApp : public wxApp { public: - bool OnInit( ); + bool OnInit(); int OnExit() { return true; } }; @@ -55,7 +55,6 @@ bool myApp::OnInit( ) setlocale(LC_NUMERIC, "C"); #endif - wxFrame *frame = new wxFrame(NULL , -1 ,_T("My window..")); SetTopWindow(frame); frame->Show(true); -- 2.50.0 From bf4535fc2c69a9014cb59295f6315a1bbc5a0d16 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 14 Apr 2025 10:30:05 +0200 Subject: [PATCH 14/16] box TurnImage manual matrix type -1 --- bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx | 40 ++++++++++++++++++--- bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h | 6 ++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx index 7afd2e9..2c3a8ec 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx @@ -5,9 +5,8 @@ #include "bbcreaVtkPackage.h" #include "creaVtk_MACROS.h" - -#include #include +#include namespace bbcreaVtk { @@ -106,11 +105,26 @@ void TurnImage::Process() } // for k bbSetOutputOut(newImage); */ - if ( (bbGetInputDir()==1) || (bbGetInputDir()==2) ) + if ( (bbGetInputDir()>=-1) && (bbGetInputDir()<=5) ) { vtkImageReslice *reslice = vtkImageReslice::New(); vtkImageChangeInformation *mchange = vtkImageChangeInformation::New(); // Reslice does all of the work. + if ( bbGetInputDir()==-1 ) // manual matrix + { + + if (bbGetInputAxesDirectionCosines().size()==9) + { + std::vector v =bbGetInputAxesDirectionCosines(); + double axes[3][3] = { { v[0], v[1], v[2] }, { v[3], v[4], v[5] }, { v[6], v[7], v[8] } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } + } // dir -1 + if ( bbGetInputDir()==0 ) // nothing + { + static double axes[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 0 if ( bbGetInputDir()==1 ) { static double axes[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 1, 0, 0 } }; @@ -121,10 +135,27 @@ void TurnImage::Process() static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } }; reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); } // dir 2 + if ( bbGetInputDir()==3 ) + { + static double axes[3][3] = { { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, 1 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 3 + if ( bbGetInputDir()==4 ) // RY90 + { + static double axes[3][3] = { { 0, 0, 1 }, { 0, 1, 0 }, { -1, 0, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 4 + if ( bbGetInputDir()==5 ) // RY-90 + { + static double axes[3][3] = { { 0, 0, -1 }, { 0, 1, 0 }, { 1, 0, 0 } }; + reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]); + } // dir 5 // reslice->SetOutputOrigin(0,0,0); + bbGetInputIn()->Modified(); reslice->SetInputData( bbGetInputIn() ); reslice->SetResliceAxesOrigin( 0,0,0 ); reslice->SetInterpolationModeToNearestNeighbor(); + reslice->Modified(); reslice->Update(); mchange->SetInputData( reslice->GetOutput() ); mchange->SetOutputOrigin( 0,0,0 ); @@ -132,8 +163,7 @@ void TurnImage::Process() bbSetOutputOut( mchange->GetOutput() ); } else { bbSetOutputOut( bbGetInputIn() ); - }// if Dir 1 or 2 - + }// if Dir -1..5 } else { bbSetOutputOut(NULL); }// if In!=NULL diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h index 1f6d0f4..98eb49c 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h @@ -24,10 +24,11 @@ class bbcreaVtk_EXPORT TurnImage //===== BBTK_DECLARE_INPUT(In,vtkImageData*); BBTK_DECLARE_INPUT(Dir,int); + BBTK_DECLARE_INPUT(AxesDirectionCosines,std::vector); 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) //===== }; @@ -39,7 +40,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TurnImage,bbtk::AtomicBlackBox); BBTK_CATEGORY("empty"); BBTK_INPUT(TurnImage,In,"Input Image",vtkImageData*,""); - BBTK_INPUT(TurnImage,Dir,"(default 0) 0:XY(original) 1:YZ 2:XZ",int,""); + BBTK_INPUT(TurnImage,Dir,"(default 0) -1:Manual matrix 0:XY(original) 1:YZ 2:XZ 3:R180Z 4:RY90 5:RY-90",int,""); + BBTK_INPUT(TurnImage,AxesDirectionCosines,"AxesDirectionCosines 9 elements of a matrix3x3", std::vector ,""); BBTK_OUTPUT(TurnImage,Out,"Output image",vtkImageData*,""); -- 2.50.0 From 139e93037040ff790696668c2da7ca57afdf83d5 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Fri, 18 Apr 2025 10:30:34 +0200 Subject: [PATCH 15/16] Clean code --- bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h index 05cda29..2dda2f5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h @@ -42,7 +42,7 @@ class bbcreaVtk_EXPORT ImageThreshold BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageThreshold,bbtk::AtomicBlackBox); BBTK_NAME("ImageThreshold"); BBTK_AUTHOR("InfoDev"); - BBTK_DESCRIPTION("No Description."); + BBTK_DESCRIPTION("(C++,JavaScript) No Description."); BBTK_CATEGORY("empty"); BBTK_INPUT(ImageThreshold,Active,"(default true) true/false",bool,""); BBTK_INPUT(ImageThreshold,In,"Input image",vtkImageData*,""); -- 2.50.0 From f1a45b868dcdee1834250cbbede3d62d452ddac9 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 17 Jun 2025 15:19:34 +0200 Subject: [PATCH 16/16] #3534 MeshFromPoints MeshToImageData --- bbtk_creaVtk_PKG/.DS_Store | Bin 8196 -> 8196 bytes .../src/bbcreaVtkCreateMeshFromPoints.cxx | 856 +++++++++--------- .../src/bbcreaVtkCreateMeshFromPoints.h | 1 - .../src/bbcreaVtkMarchingCubes2.h | 4 +- .../src/bbcreaVtkPolyDataToImageData.h | 3 +- .../src/bbcreaVtkScalarsToColors.cxx | 2 + lib/creaVtk/MeshFromPoints.cpp | 456 ++++++++++ lib/creaVtk/MeshFromPoints.h | 67 ++ lib/creaVtk/MeshToImageData.cpp | 85 ++ lib/creaVtk/MeshToImageData.h | 52 ++ 10 files changed, 1092 insertions(+), 434 deletions(-) create mode 100644 lib/creaVtk/MeshFromPoints.cpp create mode 100644 lib/creaVtk/MeshFromPoints.h create mode 100644 lib/creaVtk/MeshToImageData.cpp create mode 100644 lib/creaVtk/MeshToImageData.h diff --git a/bbtk_creaVtk_PKG/.DS_Store b/bbtk_creaVtk_PKG/.DS_Store index 8fd3482ce295b13412c4a47a718c628794e1ca1a..afa815535c7de6d6e2d9472d3384e822300392fe 100644 GIT binary patch delta 14 VcmZp1XmQx^U67Gs^AABDJ^(9B1sDJT delta 14 VcmZp1XmQx^U67G+^AABDJ^(9H1sMPU diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index 2a4dd44..0009dd1 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -13,475 +13,473 @@ namespace bbcreaVtk BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,CreateMeshFromPoints) BBTK_BLACK_BOX_IMPLEMENTATION(CreateMeshFromPoints,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 CreateMeshFromPoints::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 = " < lstX = bbGetInputLstX(); - std::vector lstY = bbGetInputLstY(); - std::vector lstZ = bbGetInputLstZ(); - std::vector lstIndexs = bbGetInputLstIndexs(); - double pointsCentroid[3]; - if ( (lstIndexs.size()<1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) ) - { - printf("Warning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n"); - bbSetOutputOut(NULL); - } else { - int ii,sizeSegment1,sizeSegment2; - int endSegment; -// vtkSmartPointer points = vtkSmartPointer::New(); - if (points!=NULL) points->Delete(); - points = vtkPoints::New(); - int i,sizeLstX = lstX.size(); - for (i=0;iInsertNextPoint(lstX[i],lstY[i],lstZ[i]); - pointsCentroid[0] += lstX[i]; - pointsCentroid[1] += lstY[i]; - pointsCentroid[2] += lstZ[i]; - } // for i - pointsCentroid[0] /= sizeLstX; - pointsCentroid[1] /= sizeLstX; - pointsCentroid[2] /= sizeLstX; - - if ((bbGetInputCloseSurface()==true) && (lstIndexs.size()>=2) ) - { - //check if initial and end points are the same in all splines (splines are in line shape and not U shape) - //to not apply changes because clean polydata will take care of it. - int count = 0; - bool differentPoints = false; - for(i=0; i < lstIndexs.size() && !differentPoints;i++){ - bool sameStart = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; - bool sameEnd = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; - if(!(sameStart && sameEnd)) differentPoints = true; - count += lstIndexs[i]; - } - //Correct surface normals if needed - if(differentPoints) - { - double pointSurf1[3], pointSurf2[3], pointSurf3[3]; - double vect1[3], vect2[3]; - double surfNormal[3], vectorCenter[3]; - double dotNormalSurf = 0; - for(int pIndex = 0; pIndex < lstIndexs[0]-1; pIndex++) - { - pointSurf1[0] = lstX[pIndex]; - pointSurf1[1] = lstY[pIndex]; - pointSurf1[2] = lstZ[pIndex]; - vtkMath::Subtract(pointsCentroid, pointSurf1, vectorCenter); - pointSurf2[0] = lstX[pIndex+lstIndexs[1]]; - pointSurf2[1] = lstY[pIndex+lstIndexs[1]]; - pointSurf2[2] = lstZ[pIndex+lstIndexs[1]]; - pointSurf3[0] = lstX[pIndex+1]; - pointSurf3[1] = lstY[pIndex+1]; - pointSurf3[2] = lstZ[pIndex+1]; - vtkMath::Subtract(pointSurf2, pointSurf1, vect1); - vtkMath::Subtract(pointSurf3, pointSurf1, vect2); - vtkMath::Cross(vect1, vect2, surfNormal); - dotNormalSurf += vtkMath::Dot(surfNormal, vectorCenter); - } // for pIndex - - if(dotNormalSurf > 0){ - points->Delete(); - points = vtkPoints::New(); - for(int splineI = 0; splineI < lstIndexs.size(); splineI++){ - for (i=lstIndexs[splineI]-1; i >= 0;i--) - { - points->InsertNextPoint(lstX[splineI*lstIndexs[0]+i],lstY[splineI*lstIndexs[0]+i],lstZ[splineI*lstIndexs[0]+i]); - } // for i - } // for splineI - } // if dotNormalSurf - }// if differentPoints - } - // - -// vtkSmartPointer cells = vtkSmartPointer::New(); - if (cells!=NULL) cells->Delete(); - cells = vtkCellArray::New(); - int maxElements; - int maxSegment1,maxSegment2; - int iSeg1,iSeg2; - int iGeneral = 0; - int sizeLstIdexes=lstIndexs.size(); - for (i=0; i triangleStrip = vtkSmartPointer::New(); - triangleStrip->GetPointIds()->SetNumberOfIds(sizeSegment1+sizeSegment2); - maxElements=sizeSegment1; - if (maxElementsGetPointIds()->SetId(ii*2 ,iSeg1); - triangleStrip->GetPointIds()->SetId(ii*2+1,iSeg2); - iSeg1++; - iSeg2++; - if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; } - if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; } - } // for ii - iGeneral=iGeneral+sizeSegment1; - cells->InsertNextCell(triangleStrip); - } //for LstIndexs - - - if(bbGetInputCloseSurface()) - { - int lastId1 = lstIndexs[0]-1; - int lastId2 = sizeLstX - 1; - int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1]; - bool face1open = std::fabs(lstX[0] - lstX[lastId1]) > 0.0001 || std::fabs(lstY[0] - lstY[lastId1]) > 0.0001 || std::fabs(lstZ[0] - lstZ[lastId1]) > 0.0001; - bool face2open = std::fabs(lstX[firstId2] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[firstId2] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[firstId2] - lstZ[lastId2]) > 0.0001; - - bool altFace1open = std::fabs(lstX[0] - lstX[firstId2]) > 0.0001 || std::fabs(lstY[0] - lstY[firstId2]) > 0.0001 || std::fabs(lstZ[0] - lstZ[firstId2]) > 0.0001; - bool altFace2open = std::fabs(lstX[lastId1] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[lastId1] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[lastId1] - lstZ[lastId2]) > 0.0001; - - //false = Open Contour - //true = Closed Contour - if(!face1open && !face2open) - { -// isClosedCont = true; - CloseContourSides(lstIndexs, true, true); - } - else if(!altFace1open && !altFace2open) - { -// isClosedCont = true; - CloseContourSides(lstIndexs, false, true); - } - else{ - CloseOpenContourSurface(lstIndexs); - } - } - -// vtkPolyData *polydata = vtkPolyData::New(); - if (polydata!=NULL) polydata->Delete(); - polydata = vtkPolyData::New(); - polydata->SetPoints(points); - polydata->SetStrips(cells); -// vtkCleanPolyData *clean=vtkCleanPolyData::New(); - if (clean!=NULL) clean->Delete(); - clean = vtkCleanPolyData::New(); - clean->SetInputData(polydata); - clean->Update(); -// vtkTriangleFilter *triangle = vtkTriangleFilter::New(); - if (triangle!=NULL) triangle->Delete(); - triangle = vtkTriangleFilter::New(); - triangle->SetInputData( clean->GetOutput() ); - triangle->Update(); - bbSetOutputOut( triangle->GetOutput() ); - // bbSetOutputOut( clean->GetOutput() ); - }// if listXYZ size - //printf("PG CreateMeshFromPoints::Process: End\n"); + + // 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 = " < lstX = bbGetInputLstX(); + std::vector lstY = bbGetInputLstY(); + std::vector lstZ = bbGetInputLstZ(); + std::vector lstIndexs = bbGetInputLstIndexs(); + double pointsCentroid[3]; + if ( (lstIndexs.size()<1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) ) + { + printf("Warning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n"); + bbSetOutputOut(NULL); + } else { + int ii,sizeSegment1,sizeSegment2; + int endSegment; + // vtkSmartPointer points = vtkSmartPointer::New(); + if (points!=NULL) points->Delete(); + points = vtkPoints::New(); + int i,sizeLstX = lstX.size(); + for (i=0;iInsertNextPoint(lstX[i],lstY[i],lstZ[i]); + pointsCentroid[0] += lstX[i]; + pointsCentroid[1] += lstY[i]; + pointsCentroid[2] += lstZ[i]; + } // for i + pointsCentroid[0] /= sizeLstX; + pointsCentroid[1] /= sizeLstX; + pointsCentroid[2] /= sizeLstX; + + if ((bbGetInputCloseSurface()==true) && (lstIndexs.size()>=2) ) + { + //check if initial and end points are the same in all splines (splines are in line shape and not U shape) + //to not apply changes because clean polydata will take care of it. + int count = 0; + bool differentPoints = false; + for(i=0; i < lstIndexs.size() && !differentPoints;i++){ + bool sameStart = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; + bool sameEnd = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; + if(!(sameStart && sameEnd)) differentPoints = true; + count += lstIndexs[i]; + } + //Correct surface normals if needed + if(differentPoints) + { + double pointSurf1[3], pointSurf2[3], pointSurf3[3]; + double vect1[3], vect2[3]; + double surfNormal[3], vectorCenter[3]; + double dotNormalSurf = 0; + for(int pIndex = 0; pIndex < lstIndexs[0]-1; pIndex++) + { + pointSurf1[0] = lstX[pIndex]; + pointSurf1[1] = lstY[pIndex]; + pointSurf1[2] = lstZ[pIndex]; + vtkMath::Subtract(pointsCentroid, pointSurf1, vectorCenter); + pointSurf2[0] = lstX[pIndex+lstIndexs[1]]; + pointSurf2[1] = lstY[pIndex+lstIndexs[1]]; + pointSurf2[2] = lstZ[pIndex+lstIndexs[1]]; + pointSurf3[0] = lstX[pIndex+1]; + pointSurf3[1] = lstY[pIndex+1]; + pointSurf3[2] = lstZ[pIndex+1]; + vtkMath::Subtract(pointSurf2, pointSurf1, vect1); + vtkMath::Subtract(pointSurf3, pointSurf1, vect2); + vtkMath::Cross(vect1, vect2, surfNormal); + dotNormalSurf += vtkMath::Dot(surfNormal, vectorCenter); + } // for pIndex + + if(dotNormalSurf > 0){ + points->Delete(); + points = vtkPoints::New(); + for(int splineI = 0; splineI < lstIndexs.size(); splineI++){ + for (i=lstIndexs[splineI]-1; i >= 0;i--) + { + points->InsertNextPoint(lstX[splineI*lstIndexs[0]+i],lstY[splineI*lstIndexs[0]+i],lstZ[splineI*lstIndexs[0]+i]); + } // for i + } // for splineI + } // if dotNormalSurf + }// if differentPoints + } + // + + // vtkSmartPointer cells = vtkSmartPointer::New(); + if (cells!=NULL) cells->Delete(); + cells = vtkCellArray::New(); + int maxElements; + int maxSegment1,maxSegment2; + int iSeg1,iSeg2; + int iGeneral = 0; + int sizeLstIdexes=lstIndexs.size(); + for (i=0; i triangleStrip = vtkSmartPointer::New(); + triangleStrip->GetPointIds()->SetNumberOfIds(sizeSegment1+sizeSegment2); + maxElements=sizeSegment1; + if (maxElementsGetPointIds()->SetId(ii*2 ,iSeg1); + triangleStrip->GetPointIds()->SetId(ii*2+1,iSeg2); + iSeg1++; + iSeg2++; + if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; } + if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; } + } // for ii + iGeneral=iGeneral+sizeSegment1; + cells->InsertNextCell(triangleStrip); + } //for LstIndexs + + + if(bbGetInputCloseSurface()) + { + int lastId1 = lstIndexs[0]-1; + int lastId2 = sizeLstX - 1; + int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1]; + bool face1open = std::fabs(lstX[0] - lstX[lastId1]) > 0.0001 || std::fabs(lstY[0] - lstY[lastId1]) > 0.0001 || std::fabs(lstZ[0] - lstZ[lastId1]) > 0.0001; + bool face2open = std::fabs(lstX[firstId2] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[firstId2] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[firstId2] - lstZ[lastId2]) > 0.0001; + + bool altFace1open = std::fabs(lstX[0] - lstX[firstId2]) > 0.0001 || std::fabs(lstY[0] - lstY[firstId2]) > 0.0001 || std::fabs(lstZ[0] - lstZ[firstId2]) > 0.0001; + bool altFace2open = std::fabs(lstX[lastId1] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[lastId1] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[lastId1] - lstZ[lastId2]) > 0.0001; + + //false = Open Contour + //true = Closed Contour + if(!face1open && !face2open) + { + // isClosedCont = true; + CloseContourSides(lstIndexs, true, true); + } + else if(!altFace1open && !altFace2open) + { + // isClosedCont = true; + CloseContourSides(lstIndexs, false, true); + } + else{ + CloseOpenContourSurface(lstIndexs); + } + } + + // vtkPolyData *polydata = vtkPolyData::New(); + if (polydata!=NULL) polydata->Delete(); + polydata = vtkPolyData::New(); + polydata->SetPoints(points); + polydata->SetStrips(cells); + // vtkCleanPolyData *clean=vtkCleanPolyData::New(); + if (clean!=NULL) clean->Delete(); + clean = vtkCleanPolyData::New(); + clean->SetInputData(polydata); + clean->Update(); + // vtkTriangleFilter *triangle = vtkTriangleFilter::New(); + if (triangle!=NULL) triangle->Delete(); + triangle = vtkTriangleFilter::New(); + triangle->SetInputData( clean->GetOutput() ); + triangle->Update(); + bbSetOutputOut( triangle->GetOutput() ); + // bbSetOutputOut( clean->GetOutput() ); + }// if listXYZ size + //printf("PG CreateMeshFromPoints::Process: End\n"); } /** -* Closes the sides of the contour -* iterates in one way or the other, depending on the order of the points and calculated vectors. -* uPointOrder: Points are order in a U shape -* lstIndexs: number of points on each spline -*/ + * Closes the sides of the contour + * iterates in one way or the other, depending on the order of the points and calculated vectors. + * uPointOrder: Points are order in a U shape + * lstIndexs: number of points on each spline + */ void CreateMeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uPointOrder, bool isClosedCont){ - int sizeLstIdexes = lstIndexs.size(); - int sizePoints = bbGetInputLstX().size(); - - int firstIndex, end, centroidId, numPointsFace, contraryId; - int increment = uPointOrder?1:sizeLstIdexes; - double centroid[3]; - int numProcessFaces = sizeLstIdexes > 1?2:1; - for(int facesIdx = 0; facesIdx < numProcessFaces; facesIdx++){ - std::fill(std::begin(centroid), std::end(centroid), 0); - if(facesIdx == 0) - { - firstIndex = 0; - numPointsFace = uPointOrder?lstIndexs[0]: sizeLstIdexes; - end = uPointOrder?firstIndex + numPointsFace:sizePoints - lstIndexs[sizeLstIdexes - 1] + 1; - contraryId = sizePoints-1; - }else{ - firstIndex = uPointOrder?sizePoints - lstIndexs[sizeLstIdexes-1]:lstIndexs[0]-1; - numPointsFace = uPointOrder?lstIndexs[sizeLstIdexes-1]:sizeLstIdexes; - end = uPointOrder?firstIndex + numPointsFace:sizePoints; - contraryId = 0; - } - if(numPointsFace > 1) - { - bool validCentroid = CalcValidCentroid(centroid, firstIndex, end, increment, numPointsFace); - if(validCentroid) - { - bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId); - centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]); - //vtkSmartPointer triangleStrip = vtkSmartPointer::New(); - //triangleStrip->GetPointIds()->SetNumberOfIds(numPointsFace*2 + (!isClosedCont?2:0)); - //int triangleIndex = 0; - if( normalOrder ) + int sizeLstIdexes = lstIndexs.size(); + int sizePoints = bbGetInputLstX().size(); + + int firstIndex, end, centroidId, numPointsFace, contraryId; + int increment = uPointOrder?1:sizeLstIdexes; + double centroid[3]; + int numProcessFaces = sizeLstIdexes > 1?2:1; + for(int facesIdx = 0; facesIdx < numProcessFaces; facesIdx++){ + std::fill(std::begin(centroid), std::end(centroid), 0); + if(facesIdx == 0) + { + firstIndex = 0; + numPointsFace = uPointOrder?lstIndexs[0]: sizeLstIdexes; + end = uPointOrder?firstIndex + numPointsFace:sizePoints - lstIndexs[sizeLstIdexes - 1] + 1; + contraryId = sizePoints-1; + }else{ + firstIndex = uPointOrder?sizePoints - lstIndexs[sizeLstIdexes-1]:lstIndexs[0]-1; + numPointsFace = uPointOrder?lstIndexs[sizeLstIdexes-1]:sizeLstIdexes; + end = uPointOrder?firstIndex + numPointsFace:sizePoints; + contraryId = 0; + } + if(numPointsFace > 1) + { + bool validCentroid = CalcValidCentroid(centroid, firstIndex, end, increment, numPointsFace); + if(validCentroid) + { + bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId); + centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]); + //vtkSmartPointer triangleStrip = vtkSmartPointer::New(); + //triangleStrip->GetPointIds()->SetNumberOfIds(numPointsFace*2 + (!isClosedCont?2:0)); + //int triangleIndex = 0; + if( normalOrder ) { - int initial = firstIndex; - for(int index = initial; index < end; index+=increment){ - if(index+increment >= end && !isClosedCont){ - vtkNew triangle; - triangle->GetPointIds()->SetId(0, index); - triangle->GetPointIds()->SetId(1, initial); - triangle->GetPointIds()->SetId(2, centroidId); - cells->InsertNextCell(triangle); - }else if(index+increment < end){ - vtkNew triangle; - triangle->GetPointIds()->SetId(0, index); - triangle->GetPointIds()->SetId(1, index+increment); - triangle->GetPointIds()->SetId(2, centroidId); - cells->InsertNextCell(triangle); - } - /* - triangleStrip->GetPointIds()->SetId(triangleIndex,index); - triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);//1 - if(index+increment >= end && !isClosedCont){ - triangleStrip->GetPointIds()->SetId(triangleIndex+2,initial);//2 - triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);//3 - } - triangleIndex+=2; - */ - } - //cells->InsertNextCell(triangleStrip); - } else { - int initial = firstIndex-1; - int triangleStripStart = end-1; - for(int index = triangleStripStart; index > initial; index-=increment){ - if(index-increment <= initial && !isClosedCont){ - vtkNew triangle; - triangle->GetPointIds()->SetId(0, index); - triangle->GetPointIds()->SetId(1, triangleStripStart); - triangle->GetPointIds()->SetId(2, centroidId); - cells->InsertNextCell(triangle); - }else if(index-increment > initial){ - vtkNew triangle; - triangle->GetPointIds()->SetId(0, index); - triangle->GetPointIds()->SetId(1, index-increment); - triangle->GetPointIds()->SetId(2, centroidId); - cells->InsertNextCell(triangle); - } - } - }//if normalOrder - }//if validCentroid - }//if numPointsFace - }//for facesIdx - + int initial = firstIndex; + for(int index = initial; index < end; index+=increment){ + if(index+increment >= end && !isClosedCont){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, initial); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + }else if(index+increment < end){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, index+increment); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + } + /* + triangleStrip->GetPointIds()->SetId(triangleIndex,index); + triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);//1 + if(index+increment >= end && !isClosedCont){ + triangleStrip->GetPointIds()->SetId(triangleIndex+2,initial);//2 + triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);//3 + } + triangleIndex+=2; + */ + } + //cells->InsertNextCell(triangleStrip); + } else { + int initial = firstIndex-1; + int triangleStripStart = end-1; + for(int index = triangleStripStart; index > initial; index-=increment){ + if(index-increment <= initial && !isClosedCont){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, triangleStripStart); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + }else if(index-increment > initial){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, index-increment); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + } + } + }//if normalOrder + }//if validCentroid + }//if numPointsFace + }//for facesIdx + } /** -* Checks if the normal from firstPointId, secPointId and centroid points away -* from the vector centroid to contrPointId. -* Used to check that the order used to create the new polygons is correct. -*/ + * Checks if the normal from firstPointId, secPointId and centroid points away + * from the vector centroid to contrPointId. + * Used to check that the order used to create the new polygons is correct. + */ bool CreateMeshFromPoints::isPointingCorrectly( int firstPointId, int secPointId, double(¢roid)[3], int contrPointId) { - - double firstPoint[3], secPoint[3], contrPoint[3]; - points->GetPoint(firstPointId, firstPoint); - points->GetPoint(secPointId, secPoint); - - double firstVect[3], secVect[3], normal[3], contrVect[3]; - - vtkMath::Subtract(firstPoint, centroid, firstVect); - vtkMath::Subtract(secPoint, centroid, secVect); - - points->GetPoint(contrPointId, contrPoint); - vtkMath::Subtract(contrPoint, centroid, contrVect); - - vtkMath::Cross(firstVect, secVect, normal); - double dotCalc; - dotCalc = vtkMath::Dot(normal, contrVect); - - return dotCalc<0; + + double firstPoint[3], secPoint[3], contrPoint[3]; + points->GetPoint(firstPointId, firstPoint); + points->GetPoint(secPointId, secPoint); + + double firstVect[3], secVect[3], normal[3], contrVect[3]; + + vtkMath::Subtract(firstPoint, centroid, firstVect); + vtkMath::Subtract(secPoint, centroid, secVect); + + points->GetPoint(contrPointId, contrPoint); + vtkMath::Subtract(contrPoint, centroid, contrVect); + + vtkMath::Cross(firstVect, secVect, normal); + double dotCalc; + dotCalc = vtkMath::Dot(normal, contrVect); + + return dotCalc<0; } /** -* Checks if the order of the points represent a curved spline (U shape) or the points resemble a straight spline. -* Now it checks the angle between each point and the vector that goes from the last point to the first. -* -* Previous version checked the curvature between 3 points in the spline, but this created problems when the straight lines -* had curves in the middle, increasing the curvature although they are not in the U shape. -*/ + * Checks if the order of the points represent a curved spline (U shape) or the points resemble a straight spline. + * Now it checks the angle between each point and the vector that goes from the last point to the first. + * + * Previous version checked the curvature between 3 points in the spline, but this created problems when the straight lines + * had curves in the middle, increasing the curvature although they are not in the U shape. + */ bool CreateMeshFromPoints::CheckLinePointOrder(){ - int sizePoints = bbGetInputLstX().size(); - std::vector lstIndexs = bbGetInputLstIndexs(); - double point1[3], point2[3], point3[3]; - double center[3]; - double firstAngleSum = 0; - double secondAngleSum = 0; - - points->GetPoint(0, point1); - points->GetPoint((lstIndexs[0]-1), point3); - double firstVect[3]; - double secVect[3]; - vtkMath::Subtract(point3, point1, firstVect); - for(int i = 0; i < lstIndexs[0]; i++){ - points->GetPoint(i, point2); - vtkMath::Subtract(point2, point1, secVect); - firstAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); - } - points->GetPoint((sizePoints-lstIndexs[0]), point3); - vtkMath::Subtract(point3, point1, firstVect); - for(int i = 0; i < sizePoints; i+=lstIndexs.size()){ - points->GetPoint(i, point2); - vtkMath::Subtract(point2, point1, secVect); - secondAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); - } - - return firstAngleSum < secondAngleSum; + int sizePoints = bbGetInputLstX().size(); + std::vector lstIndexs = bbGetInputLstIndexs(); + double point1[3], point2[3], point3[3]; + double center[3]; + double firstAngleSum = 0; + double secondAngleSum = 0; + + points->GetPoint(0, point1); + points->GetPoint((lstIndexs[0]-1), point3); + double firstVect[3]; + double secVect[3]; + vtkMath::Subtract(point3, point1, firstVect); + for(int i = 0; i < lstIndexs[0]; i++){ + points->GetPoint(i, point2); + vtkMath::Subtract(point2, point1, secVect); + firstAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); + } + points->GetPoint((sizePoints-lstIndexs[0]), point3); + vtkMath::Subtract(point3, point1, firstVect); + for(int i = 0; i < sizePoints; i+=lstIndexs.size()){ + points->GetPoint(i, point2); + vtkMath::Subtract(point2, point1, secVect); + secondAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); + } + + return firstAngleSum < secondAngleSum; } /** -* Closes an open contour -* lstIndexs: number of points on each spline -*/ + * Closes an open contour + * lstIndexs: number of points on each spline + */ void CreateMeshFromPoints::CloseOpenContourSurface(std::vector lstIndexs){ - bool linePointOrder = CheckLinePointOrder(); - CloseContourSides(lstIndexs, !linePointOrder, false); - CloseContourBottom(!linePointOrder); + bool linePointOrder = CheckLinePointOrder(); + CloseContourSides(lstIndexs, !linePointOrder, false); + CloseContourBottom(!linePointOrder); } /** -* Calculates centroid and checks if points are collinear. -* centroid: array to store calculation -* start: start index of points to use -* end: end index of points to use -* increment: increment to be used in point iteration -* numPoints: number of points used to calculate the centroid. -* Returns a bool indicating the validity of the centroid calculated. -* False = invalid centroid = all points are the same. -*/ + * Calculates centroid and checks if points are collinear. + * centroid: array to store calculation + * start: start index of points to use + * end: end index of points to use + * increment: increment to be used in point iteration + * numPoints: number of points used to calculate the centroid. + * Returns a bool indicating the validity of the centroid calculated. + * False = invalid centroid = all points are the same. + */ bool CreateMeshFromPoints::CalcValidCentroid(double(¢roid)[3], int start, int end, int increment, int numPoints){ - double currPoint[3] = {}, prevPoint[3] = {}, middlePoint[3] = {}, firstPoint[3] = {}; - double vector1[3], vector2[3]; - bool samePoint = true; - int splineMidPoint = numPoints/2; - bool collinear = true; - - points->GetPoint(start, firstPoint); - points->GetPoint(splineMidPoint, middlePoint); - vtkMath::Subtract(middlePoint, firstPoint, vector1); - - for(int i = start; i < end; i+=increment){ - points->GetPoint(i, currPoint); - if(samePoint && i > start && (currPoint[0] != prevPoint[0] || currPoint[1] != prevPoint[1] || currPoint[2] != prevPoint[2])){ - samePoint = false; - } - - vtkMath::Subtract(currPoint, firstPoint, vector2); - double angle = vtkMath::AngleBetweenVectors(vector1, vector2); - if(angle > 0.0001 && collinear){ - collinear = false; - } - - centroid[0] += currPoint[0]; - centroid[1] += currPoint[1]; - centroid[2] += currPoint[2]; - std::copy(std::begin(currPoint), std::end(currPoint), prevPoint); - } - - centroid[0] /= numPoints; - centroid[1] /= numPoints; - centroid[2] /= numPoints; - - return !samePoint && !collinear; + double currPoint[3] = {}, prevPoint[3] = {}, middlePoint[3] = {}, firstPoint[3] = {}; + double vector1[3], vector2[3]; + bool samePoint = true; + int splineMidPoint = numPoints/2; + bool collinear = true; + + points->GetPoint(start, firstPoint); + points->GetPoint(splineMidPoint, middlePoint); + vtkMath::Subtract(middlePoint, firstPoint, vector1); + + for(int i = start; i < end; i+=increment){ + points->GetPoint(i, currPoint); + if(samePoint && i > start && (currPoint[0] != prevPoint[0] || currPoint[1] != prevPoint[1] || currPoint[2] != prevPoint[2])){ + samePoint = false; + } + + vtkMath::Subtract(currPoint, firstPoint, vector2); + double angle = vtkMath::AngleBetweenVectors(vector1, vector2); + if(angle > 0.0001 && collinear){ + collinear = false; + } + + centroid[0] += currPoint[0]; + centroid[1] += currPoint[1]; + centroid[2] += currPoint[2]; + std::copy(std::begin(currPoint), std::end(currPoint), prevPoint); + } + + centroid[0] /= numPoints; + centroid[1] /= numPoints; + centroid[2] /= numPoints; + + return !samePoint && !collinear; } /** -* Closes the bottom of the given countour. -* Should only be used when its an open contour. -* uPointOrder: points are ordered in U shape -*/ + * Closes the bottom of the given countour. + * Should only be used when its an open contour. + * uPointOrder: points are ordered in U shape + */ void CreateMeshFromPoints::CloseContourBottom(bool uPointOrder){ - std::vector lstIndexs = bbGetInputLstIndexs(); - int sizeLstIdexes = lstIndexs.size(); - int sizeLstX = bbGetInputLstX().size(); - - vtkSmartPointer triangleStripBottom = vtkSmartPointer::New(); - triangleStripBottom->GetPointIds()->SetNumberOfIds(sizeLstIdexes*2); - - double originPoint[3]; - points->GetPoint(0, originPoint); - int middleMeshPoint = uPointOrder?lstIndexs[0]/2:lstIndexs[0]*sizeLstIdexes/2; - - bool normalOrder = isPointingCorrectly(uPointOrder?lstIndexs[0]-1:sizeLstX-lstIndexs[0], uPointOrder?lstIndexs[0]:1, originPoint, middleMeshPoint); - - int triangleIndex = 0, currentId = 0, nextId = 0; - for(int splineIndex = 0; splineIndex < sizeLstIdexes;splineIndex++){ - nextId = uPointOrder?currentId + lstIndexs[splineIndex] - 1:sizeLstX - sizeLstIdexes + splineIndex; - if(normalOrder) - { - triangleStripBottom->GetPointIds()->SetId(triangleIndex, currentId); - triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, nextId); - } - else{ - triangleStripBottom->GetPointIds()->SetId(triangleIndex, nextId); - triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, currentId); - } - currentId = uPointOrder?nextId + 1: splineIndex+1; - triangleIndex+=2; - } - cells->InsertNextCell(triangleStripBottom); + std::vector lstIndexs = bbGetInputLstIndexs(); + int sizeLstIdexes = lstIndexs.size(); + int sizeLstX = bbGetInputLstX().size(); + + vtkSmartPointer triangleStripBottom = vtkSmartPointer::New(); + triangleStripBottom->GetPointIds()->SetNumberOfIds(sizeLstIdexes*2); + + double originPoint[3]; + points->GetPoint(0, originPoint); + int middleMeshPoint = uPointOrder?lstIndexs[0]/2:lstIndexs[0]*sizeLstIdexes/2; + + bool normalOrder = isPointingCorrectly(uPointOrder?lstIndexs[0]-1:sizeLstX-lstIndexs[0], uPointOrder?lstIndexs[0]:1, originPoint, middleMeshPoint); + + int triangleIndex = 0, currentId = 0, nextId = 0; + for(int splineIndex = 0; splineIndex < sizeLstIdexes;splineIndex++){ + nextId = uPointOrder?currentId + lstIndexs[splineIndex] - 1:sizeLstX - sizeLstIdexes + splineIndex; + if(normalOrder) + { + triangleStripBottom->GetPointIds()->SetId(triangleIndex, currentId); + triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, nextId); + } + else{ + triangleStripBottom->GetPointIds()->SetId(triangleIndex, nextId); + triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, currentId); + } + currentId = uPointOrder?nextId + 1: splineIndex+1; + triangleIndex+=2; + } + cells->InsertNextCell(triangleStripBottom); } -//===== +//===== // 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 CreateMeshFromPoints::bbUserSetDefaultValues() { - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 -// bbSetInputIn(0); - bbSetInputCloseSurface(false); - points = NULL; - cells = NULL; - polydata = NULL; - clean = NULL; - triangle = NULL; + + // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + // Here we initialize the input 'In' to 0 + // bbSetInputIn(0); + bbSetInputCloseSurface(false); + points = NULL; + cells = NULL; + polydata = NULL; + clean = NULL; + triangle = 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 CreateMeshFromPoints::bbUserInitializeProcessing() { - -// THE INITIALIZATION METHOD BODY : -// Here does nothing -// but this is where you should allocate the internal/output pointers -// if any - - + // 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 CreateMeshFromPoints::bbUserFinalizeProcessing() { - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - -} + + // THE FINALIZATION METHOD BODY : + // Here does nothing + // but this is where you should desallocate the internal/output pointers + // if any } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.h b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.h index f92f342..5a34600 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.h @@ -14,7 +14,6 @@ #include "vtkCleanPolyData.h" #include "vtkTriangleFilter.h" - namespace bbcreaVtk { diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h index 21fcca2..e1f049a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.h @@ -40,12 +40,12 @@ class bbcreaVtk_EXPORT MarchingCubes2 BBTK_BEGIN_DESCRIBE_BLACK_BOX(MarchingCubes2,bbtk::AtomicBlackBox); BBTK_NAME("MarchingCubes2"); BBTK_AUTHOR("InfoDev"); - BBTK_DESCRIPTION("No Description. (JavaScript)"); + BBTK_DESCRIPTION("(C++,JavaScript) 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,Value,"(default 400) 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,""); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataToImageData.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataToImageData.h index b5fd4b3..b5dc35a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataToImageData.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataToImageData.h @@ -30,7 +30,6 @@ class bbcreaVtk_EXPORT PolyDataToImageData //===== BBTK_DECLARE_INPUT(InImage,vtkImageData*); BBTK_DECLARE_INPUT(BackgroundValue,double); - BBTK_DECLARE_INPUT(InPolyData,vtkPolyData*); BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); @@ -49,7 +48,7 @@ class bbcreaVtk_EXPORT PolyDataToImageData BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataToImageData,bbtk::AtomicBlackBox); BBTK_NAME("PolyDataToImageData"); BBTK_AUTHOR("InfoDev"); - BBTK_DESCRIPTION("No Description."); + BBTK_DESCRIPTION("(C++, JavaScript) No Description."); BBTK_CATEGORY("empty"); BBTK_INPUT(PolyDataToImageData,InImage,"Image to put Result",vtkImageData*,""); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx index 4aceca3..549ce49 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx @@ -313,7 +313,9 @@ void ScalarsToColors::Process() double w = bbGetInputWindowColorLevel()[0] / 2; double c = bbGetInputWindowColorLevel()[1]; colorLookupTable->SetRange( c-w , c+w ); + printf("EED ScalarsToColors::Process A %f - %f\n",w, c); }else { + printf("EED ScalarsToColors::Process B\n"); colorLookupTable->SetRange(0,255); } diff --git a/lib/creaVtk/MeshFromPoints.cpp b/lib/creaVtk/MeshFromPoints.cpp new file mode 100644 index 0000000..1eaf784 --- /dev/null +++ b/lib/creaVtk/MeshFromPoints.cpp @@ -0,0 +1,456 @@ +#include "MeshFromPoints.h" + +#include "vtkTriangleStrip.h" +#include "vtkTriangle.h" +#include + +MeshFromPoints::MeshFromPoints() +{ + SetDefaultValues(); +} + +//Set Inputs +void MeshFromPoints::SetInputLstX(std::vector lst) { LstX = lst; } +void MeshFromPoints::SetInputLstY(std::vector lst) { LstY = lst; } +void MeshFromPoints::SetInputLstZ(std::vector lst) { LstZ = lst; } +void MeshFromPoints::SetInputLstIndexs(std::vector lst) { LstIndexs = lst; } +void MeshFromPoints::SetInputCloseSurface(bool value) { CloseSurface = value; } +//Get Inputs +std::vector MeshFromPoints::GetInputLstX() { return LstX; } +std::vector MeshFromPoints::GetInputLstY() { return LstY; } +std::vector MeshFromPoints::GetInputLstZ() { return LstZ; } +std::vector MeshFromPoints::GetInputLstIndexs() { return LstIndexs; } +bool MeshFromPoints::GetInputCloseSurface() { return CloseSurface; } +//Set Outputs +void MeshFromPoints::SetOutputOut(vtkPolyData* polydata) { Out = polydata; } +//Get Outputs +vtkPolyData* MeshFromPoints::GetOutputOut() { return Out; } + +void MeshFromPoints::Process() +{ + + std::vector lstX = GetInputLstX(); + std::vector lstY = GetInputLstY(); + std::vector lstZ = GetInputLstZ(); + std::vector lstIndexs = GetInputLstIndexs(); + double pointsCentroid[3]; + if ( (lstIndexs.size()<1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) ) + { + printf("Warning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n"); + SetOutputOut(NULL); + } else { + int ii,sizeSegment1,sizeSegment2; + int endSegment; + // vtkSmartPointer points = vtkSmartPointer::New(); + if (points!=NULL) points->Delete(); + points = vtkPoints::New(); + int i,sizeLstX = lstX.size(); + for (i=0;iInsertNextPoint(lstX[i],lstY[i],lstZ[i]); + pointsCentroid[0] += lstX[i]; + pointsCentroid[1] += lstY[i]; + pointsCentroid[2] += lstZ[i]; + } // for i + pointsCentroid[0] /= sizeLstX; + pointsCentroid[1] /= sizeLstX; + pointsCentroid[2] /= sizeLstX; + + if ((GetInputCloseSurface()==true) && (lstIndexs.size()>=2) ) + { + //check if initial and end points are the same in all splines (splines are in line shape and not U shape) + //to not apply changes because clean polydata will take care of it. + int count = 0; + bool differentPoints = false; + for(i=0; i < lstIndexs.size() && !differentPoints;i++){ + bool sameStart = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; + bool sameEnd = lstX[count] != lstX[count+lstIndexs[i]-1] && lstY[count] != lstY[count+lstIndexs[i]-1] && lstZ[count] != lstZ[count+lstIndexs[i]-1]; + if(!(sameStart && sameEnd)) differentPoints = true; + count += lstIndexs[i]; + } + //Correct surface normals if needed + if(differentPoints) + { + double pointSurf1[3], pointSurf2[3], pointSurf3[3]; + double vect1[3], vect2[3]; + double surfNormal[3], vectorCenter[3]; + double dotNormalSurf = 0; + for(int pIndex = 0; pIndex < lstIndexs[0]-1; pIndex++) + { + pointSurf1[0] = lstX[pIndex]; + pointSurf1[1] = lstY[pIndex]; + pointSurf1[2] = lstZ[pIndex]; + vtkMath::Subtract(pointsCentroid, pointSurf1, vectorCenter); + pointSurf2[0] = lstX[pIndex+lstIndexs[1]]; + pointSurf2[1] = lstY[pIndex+lstIndexs[1]]; + pointSurf2[2] = lstZ[pIndex+lstIndexs[1]]; + pointSurf3[0] = lstX[pIndex+1]; + pointSurf3[1] = lstY[pIndex+1]; + pointSurf3[2] = lstZ[pIndex+1]; + vtkMath::Subtract(pointSurf2, pointSurf1, vect1); + vtkMath::Subtract(pointSurf3, pointSurf1, vect2); + vtkMath::Cross(vect1, vect2, surfNormal); + dotNormalSurf += vtkMath::Dot(surfNormal, vectorCenter); + } // for pIndex + + if(dotNormalSurf > 0){ + points->Delete(); + points = vtkPoints::New(); + for(int splineI = 0; splineI < lstIndexs.size(); splineI++){ + for (i=lstIndexs[splineI]-1; i >= 0;i--) + { + points->InsertNextPoint(lstX[splineI*lstIndexs[0]+i],lstY[splineI*lstIndexs[0]+i],lstZ[splineI*lstIndexs[0]+i]); + } // for i + } // for splineI + } // if dotNormalSurf + }// if differentPoints + } + // + + // vtkSmartPointer cells = vtkSmartPointer::New(); + if (cells!=NULL) cells->Delete(); + cells = vtkCellArray::New(); + int maxElements; + int maxSegment1,maxSegment2; + int iSeg1,iSeg2; + int iGeneral = 0; + int sizeLstIdexes=lstIndexs.size(); + for (i=0; i triangleStrip = vtkSmartPointer::New(); + triangleStrip->GetPointIds()->SetNumberOfIds(sizeSegment1+sizeSegment2); + maxElements=sizeSegment1; + if (maxElementsGetPointIds()->SetId(ii*2 ,iSeg1); + triangleStrip->GetPointIds()->SetId(ii*2+1,iSeg2); + iSeg1++; + iSeg2++; + if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; } + if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; } + } // for ii + iGeneral=iGeneral+sizeSegment1; + cells->InsertNextCell(triangleStrip); + } //for LstIndexs + + + if(GetInputCloseSurface()) + { + int lastId1 = lstIndexs[0]-1; + int lastId2 = sizeLstX - 1; + int firstId2 = sizeLstX - lstIndexs[sizeLstIdexes - 1]; + bool face1open = std::fabs(lstX[0] - lstX[lastId1]) > 0.0001 || std::fabs(lstY[0] - lstY[lastId1]) > 0.0001 || std::fabs(lstZ[0] - lstZ[lastId1]) > 0.0001; + bool face2open = std::fabs(lstX[firstId2] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[firstId2] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[firstId2] - lstZ[lastId2]) > 0.0001; + + bool altFace1open = std::fabs(lstX[0] - lstX[firstId2]) > 0.0001 || std::fabs(lstY[0] - lstY[firstId2]) > 0.0001 || std::fabs(lstZ[0] - lstZ[firstId2]) > 0.0001; + bool altFace2open = std::fabs(lstX[lastId1] - lstX[lastId2]) > 0.0001 || std::fabs(lstY[lastId1] - lstY[lastId2]) > 0.0001 || std::fabs(lstZ[lastId1] - lstZ[lastId2]) > 0.0001; + + //false = Open Contour + //true = Closed Contour + if(!face1open && !face2open) + { + // isClosedCont = true; + CloseContourSides(lstIndexs, true, true); + } + else if(!altFace1open && !altFace2open) + { + // isClosedCont = true; + CloseContourSides(lstIndexs, false, true); + } + else{ + CloseOpenContourSurface(lstIndexs); + } + } + + // vtkPolyData *polydata = vtkPolyData::New(); + if (polydata!=NULL) polydata->Delete(); + polydata = vtkPolyData::New(); + polydata->SetPoints(points); + polydata->SetStrips(cells); + // vtkCleanPolyData *clean=vtkCleanPolyData::New(); + if (clean!=NULL) clean->Delete(); + clean = vtkCleanPolyData::New(); + clean->SetInputData(polydata); + clean->Update(); + // vtkTriangleFilter *triangle = vtkTriangleFilter::New(); + if (triangle!=NULL) triangle->Delete(); + triangle = vtkTriangleFilter::New(); + triangle->SetInputData( clean->GetOutput() ); + triangle->Update(); + SetOutputOut( triangle->GetOutput() ); + // SetOutputOut( clean->GetOutput() ); + }// if listXYZ size + //printf("PG CreateMeshFromPoints::Process: End\n"); +} + +/** + * Closes the sides of the contour + * iterates in one way or the other, depending on the order of the points and calculated vectors. + * uPointOrder: Points are order in a U shape + * lstIndexs: number of points on each spline + */ +void MeshFromPoints::CloseContourSides(std::vector lstIndexs, bool uPointOrder, bool isClosedCont){ + int sizeLstIdexes = lstIndexs.size(); + int sizePoints = GetInputLstX().size(); + + int firstIndex, end, centroidId, numPointsFace, contraryId; + int increment = uPointOrder?1:sizeLstIdexes; + double centroid[3]; + int numProcessFaces = sizeLstIdexes > 1?2:1; + for(int facesIdx = 0; facesIdx < numProcessFaces; facesIdx++){ + std::fill(std::begin(centroid), std::end(centroid), 0); + if(facesIdx == 0) + { + firstIndex = 0; + numPointsFace = uPointOrder?lstIndexs[0]: sizeLstIdexes; + end = uPointOrder?firstIndex + numPointsFace:sizePoints - lstIndexs[sizeLstIdexes - 1] + 1; + contraryId = sizePoints-1; + }else{ + firstIndex = uPointOrder?sizePoints - lstIndexs[sizeLstIdexes-1]:lstIndexs[0]-1; + numPointsFace = uPointOrder?lstIndexs[sizeLstIdexes-1]:sizeLstIdexes; + end = uPointOrder?firstIndex + numPointsFace:sizePoints; + contraryId = 0; + } + if(numPointsFace > 1) + { + bool validCentroid = CalcValidCentroid(centroid, firstIndex, end, increment, numPointsFace); + if(validCentroid) + { + bool normalOrder = isPointingCorrectly(firstIndex, firstIndex+increment, centroid, contraryId); + centroidId = points->InsertNextPoint(centroid[0], centroid[1], centroid[2]); + //vtkSmartPointer triangleStrip = vtkSmartPointer::New(); + //triangleStrip->GetPointIds()->SetNumberOfIds(numPointsFace*2 + (!isClosedCont?2:0)); + //int triangleIndex = 0; + if( normalOrder ) + { + int initial = firstIndex; + for(int index = initial; index < end; index+=increment){ + if(index+increment >= end && !isClosedCont){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, initial); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + }else if(index+increment < end){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, index+increment); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + } + /* + triangleStrip->GetPointIds()->SetId(triangleIndex,index); + triangleStrip->GetPointIds()->SetId(triangleIndex+1,centroidId);//1 + if(index+increment >= end && !isClosedCont){ + triangleStrip->GetPointIds()->SetId(triangleIndex+2,initial);//2 + triangleStrip->GetPointIds()->SetId(triangleIndex+3,centroidId);//3 + } + triangleIndex+=2; + */ + } + //cells->InsertNextCell(triangleStrip); + } else { + int initial = firstIndex-1; + int triangleStripStart = end-1; + for(int index = triangleStripStart; index > initial; index-=increment){ + if(index-increment <= initial && !isClosedCont){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, triangleStripStart); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + }else if(index-increment > initial){ + vtkNew triangle; + triangle->GetPointIds()->SetId(0, index); + triangle->GetPointIds()->SetId(1, index-increment); + triangle->GetPointIds()->SetId(2, centroidId); + cells->InsertNextCell(triangle); + } + } + }//if normalOrder + }//if validCentroid + }//if numPointsFace + }//for facesIdx + +} + +/** + * Checks if the normal from firstPointId, secPointId and centroid points away + * from the vector centroid to contrPointId. + * Used to check that the order used to create the new polygons is correct. + */ +bool MeshFromPoints::isPointingCorrectly( int firstPointId, int secPointId, double(¢roid)[3], int contrPointId) { + + double firstPoint[3], secPoint[3], contrPoint[3]; + points->GetPoint(firstPointId, firstPoint); + points->GetPoint(secPointId, secPoint); + + double firstVect[3], secVect[3], normal[3], contrVect[3]; + + vtkMath::Subtract(firstPoint, centroid, firstVect); + vtkMath::Subtract(secPoint, centroid, secVect); + + points->GetPoint(contrPointId, contrPoint); + vtkMath::Subtract(contrPoint, centroid, contrVect); + + vtkMath::Cross(firstVect, secVect, normal); + double dotCalc; + dotCalc = vtkMath::Dot(normal, contrVect); + + return dotCalc<0; +} + +/** + * Checks if the order of the points represent a curved spline (U shape) or the points resemble a straight spline. + * Now it checks the angle between each point and the vector that goes from the last point to the first. + * + * Previous version checked the curvature between 3 points in the spline, but this created problems when the straight lines + * had curves in the middle, increasing the curvature although they are not in the U shape. + */ +bool MeshFromPoints::CheckLinePointOrder(){ + int sizePoints = GetInputLstX().size(); + std::vector lstIndexs = GetInputLstIndexs(); + double point1[3], point2[3], point3[3]; + double center[3]; + double firstAngleSum = 0; + double secondAngleSum = 0; + + points->GetPoint(0, point1); + points->GetPoint((lstIndexs[0]-1), point3); + double firstVect[3]; + double secVect[3]; + vtkMath::Subtract(point3, point1, firstVect); + for(int i = 0; i < lstIndexs[0]; i++){ + points->GetPoint(i, point2); + vtkMath::Subtract(point2, point1, secVect); + firstAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); + } + points->GetPoint((sizePoints-lstIndexs[0]), point3); + vtkMath::Subtract(point3, point1, firstVect); + for(int i = 0; i < sizePoints; i+=lstIndexs.size()){ + points->GetPoint(i, point2); + vtkMath::Subtract(point2, point1, secVect); + secondAngleSum += vtkMath::SignedAngleBetweenVectors(firstVect, secVect, firstVect); + } + + return firstAngleSum < secondAngleSum; +} + +/** + * Closes an open contour + * lstIndexs: number of points on each spline + */ +void MeshFromPoints::CloseOpenContourSurface(std::vector lstIndexs){ + bool linePointOrder = CheckLinePointOrder(); + CloseContourSides(lstIndexs, !linePointOrder, false); + CloseContourBottom(!linePointOrder); +} + +/** + * Calculates centroid and checks if points are collinear. + * centroid: array to store calculation + * start: start index of points to use + * end: end index of points to use + * increment: increment to be used in point iteration + * numPoints: number of points used to calculate the centroid. + * Returns a bool indicating the validity of the centroid calculated. + * False = invalid centroid = all points are the same. + */ +bool MeshFromPoints::CalcValidCentroid(double(¢roid)[3], int start, int end, int increment, int numPoints){ + double currPoint[3] = {}, prevPoint[3] = {}, middlePoint[3] = {}, firstPoint[3] = {}; + double vector1[3], vector2[3]; + bool samePoint = true; + int splineMidPoint = numPoints/2; + bool collinear = true; + + points->GetPoint(start, firstPoint); + points->GetPoint(splineMidPoint, middlePoint); + vtkMath::Subtract(middlePoint, firstPoint, vector1); + + for(int i = start; i < end; i+=increment){ + points->GetPoint(i, currPoint); + if(samePoint && i > start && (currPoint[0] != prevPoint[0] || currPoint[1] != prevPoint[1] || currPoint[2] != prevPoint[2])){ + samePoint = false; + } + + vtkMath::Subtract(currPoint, firstPoint, vector2); + double angle = vtkMath::AngleBetweenVectors(vector1, vector2); + if(angle > 0.0001 && collinear){ + collinear = false; + } + + centroid[0] += currPoint[0]; + centroid[1] += currPoint[1]; + centroid[2] += currPoint[2]; + std::copy(std::begin(currPoint), std::end(currPoint), prevPoint); + } + + centroid[0] /= numPoints; + centroid[1] /= numPoints; + centroid[2] /= numPoints; + + return !samePoint && !collinear; +} + +/** + * Closes the bottom of the given countour. + * Should only be used when its an open contour. + * uPointOrder: points are ordered in U shape + */ +void MeshFromPoints::CloseContourBottom(bool uPointOrder){ + std::vector lstIndexs = GetInputLstIndexs(); + int sizeLstIdexes = lstIndexs.size(); + int sizeLstX = GetInputLstX().size(); + + vtkSmartPointer triangleStripBottom = vtkSmartPointer::New(); + triangleStripBottom->GetPointIds()->SetNumberOfIds(sizeLstIdexes*2); + + double originPoint[3]; + points->GetPoint(0, originPoint); + int middleMeshPoint = uPointOrder?lstIndexs[0]/2:lstIndexs[0]*sizeLstIdexes/2; + + bool normalOrder = isPointingCorrectly(uPointOrder?lstIndexs[0]-1:sizeLstX-lstIndexs[0], uPointOrder?lstIndexs[0]:1, originPoint, middleMeshPoint); + + int triangleIndex = 0, currentId = 0, nextId = 0; + for(int splineIndex = 0; splineIndex < sizeLstIdexes;splineIndex++){ + nextId = uPointOrder?currentId + lstIndexs[splineIndex] - 1:sizeLstX - sizeLstIdexes + splineIndex; + if(normalOrder) + { + triangleStripBottom->GetPointIds()->SetId(triangleIndex, currentId); + triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, nextId); + } + else{ + triangleStripBottom->GetPointIds()->SetId(triangleIndex, nextId); + triangleStripBottom->GetPointIds()->SetId(triangleIndex+1, currentId); + } + currentId = uPointOrder?nextId + 1: splineIndex+1; + triangleIndex+=2; + } + cells->InsertNextCell(triangleStripBottom); +} + +//===== +// 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 MeshFromPoints::SetDefaultValues() +{ + + // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX + // Here we initialize the input 'In' to 0 + // SetInputIn(0); + SetInputCloseSurface(false); + points = NULL; + cells = NULL; + polydata = NULL; + clean = NULL; + triangle = NULL; +} + + diff --git a/lib/creaVtk/MeshFromPoints.h b/lib/creaVtk/MeshFromPoints.h new file mode 100644 index 0000000..0377195 --- /dev/null +++ b/lib/creaVtk/MeshFromPoints.h @@ -0,0 +1,67 @@ + +#ifndef MeshFromPoints_h +#define MeshFromPoints_h + +//#include "creaVTK_EXPORT.h" +#include +#include +#include "vtkPoints.h" +#include "vtkCellArray.h" +#include "vtkCleanPolyData.h" +#include "vtkTriangleFilter.h" + + +class /*creaVTK_EXPORT*/ MeshFromPoints +{ +public: + MeshFromPoints(); + + //Inputs + std::vector LstX; + std::vector LstY; + std::vector LstZ; + std::vector LstIndexs; + bool CloseSurface; + //Outputs + vtkPolyData* Out; + + // Get Inputs + std::vector GetInputLstX(); + std::vector GetInputLstY(); + std::vector GetInputLstZ(); + std::vector GetInputLstIndexs(); + bool GetInputCloseSurface(); + // Set Inputs + void SetInputLstX( std::vector lst); + void SetInputLstY( std::vector lst); + void SetInputLstZ( std::vector lst); + void SetInputLstIndexs( std::vector lst); + void SetInputCloseSurface( bool value); + // Set Outputs + void SetOutputOut(vtkPolyData* polydata); + // Get Outputs + vtkPolyData* GetOutputOut(); + + // Atributes + vtkPoints *points; + vtkCellArray *cells; + vtkPolyData *polydata; + vtkCleanPolyData *clean; + vtkTriangleFilter *triangle; + + void Process(); + void SetDefaultValues(); + + // Methods + bool CalcValidCentroid(double(¢roid)[3], int start, int end, int increment, int numPoints); + bool CheckLinePointOrder(); + bool isPointingCorrectly( int firstPointId, int secPointId, double(¢roid)[3], int contrPointId); + void CloseContourBottom(bool uPointOrder); + void CloseContourSides(std::vector lstIndexs, bool uPointOrder, bool isClosedCont); + void CloseOpenContourSurface(std::vector lstIndexs); + +}; + + +#endif // _h_INCLUDED__ + diff --git a/lib/creaVtk/MeshToImageData.cpp b/lib/creaVtk/MeshToImageData.cpp new file mode 100644 index 0000000..f144a98 --- /dev/null +++ b/lib/creaVtk/MeshToImageData.cpp @@ -0,0 +1,85 @@ +#include "MeshToImageData.h" +#include + + +MeshToImageData::MeshToImageData() +{ + SetInputInPolyData(NULL); + SetInputInImage(NULL); + SetInputBackgroundValue(255); + + clean1 = NULL; + dataToStencil = NULL; + extract = NULL; + stencil = NULL; + +} + +//Set Inputs +void MeshToImageData::SetInputInImage(vtkImageData *image) { InImage = image; } +void MeshToImageData::SetInputBackgroundValue(double value) { BackgroundValue = value; } +void MeshToImageData::SetInputInPolyData(vtkPolyData *polydata) { InPolyData = polydata; } +//Get Inputs +vtkImageData *MeshToImageData::GetInputInImage() { return InImage; } +double MeshToImageData::GetInputBackgroundValue() { return BackgroundValue; } +vtkPolyData *MeshToImageData::GetInputInPolyData() { return InPolyData; } + +//Set Outputs +void MeshToImageData::SetOutputOut(vtkImageData* image) { Out = image; } +//Get Outputs +vtkImageData* MeshToImageData::GetOutputOut() { return Out; } + +void MeshToImageData::Process() +{ + if ((GetInputInPolyData()!=NULL) && (GetInputInImage()!=NULL) ) + { +printf("EED Warnning!! MeshToImageData::Process Clean this code .................\n "); + int ext[6]; + double spc[3]; + double org[3]; + GetInputInImage()->GetExtent( ext ); + GetInputInImage()->GetSpacing( spc ); + GetInputInImage()->GetOrigin( org ); + +// vtkCleanPolyData *clean1 = vtkCleanPolyData::New(); + if (clean1!=NULL) clean1->Delete(); + clean1 = vtkCleanPolyData::New(); + clean1->SetInputData( GetInputInPolyData() ); + clean1->Update(); + vtkTriangleFilter *triangle1 = vtkTriangleFilter::New(); + triangle1->SetInputData( clean1->GetOutput() ); + triangle1->Update(); +// vtkPolyDataToImageStencil *dataToStencil = vtkPolyDataToImageStencil::New(); + if (dataToStencil!=NULL) dataToStencil->Delete(); + dataToStencil = vtkPolyDataToImageStencil::New(); + dataToStencil->SetInputData( triangle1->GetOutput() ); + dataToStencil->SetOutputOrigin( org ); + dataToStencil->SetOutputSpacing( spc ); + dataToStencil->SetOutputWholeExtent( ext ); + dataToStencil->Update(); +// vtkExtractVOI *extract = vtkExtractVOI::New(); + if (extract!=NULL) extract->Delete(); + extract = vtkExtractVOI::New(); + extract->SetVOI( ext ); + extract->SetSampleRate(1, 1, 1); + extract->SetInputData( GetInputInImage() ); + extract->ReleaseDataFlagOff(); + extract->Update(); +// vtkImageStencil *stencil = vtkImageStencil::New(); + if (stencil!=NULL) stencil->Delete(); + stencil = vtkImageStencil::New(); + stencil->SetInputData( extract->GetOutput() ); + stencil->Update(); + stencil->SetStencilData( dataToStencil->GetOutput() ); + stencil->ReverseStencilOn(); + stencil->SetBackgroundValue( GetInputBackgroundValue() ); + stencil->Update(); + SetOutputOut( stencil->GetOutput() ); + } else { + printf("EED Warnning! PolyDataToImageData::Process > Missing Image or PolyData inputs\n"); + SetOutputOut( NULL); + }// if In NULL + +} + + diff --git a/lib/creaVtk/MeshToImageData.h b/lib/creaVtk/MeshToImageData.h new file mode 100644 index 0000000..b8336af --- /dev/null +++ b/lib/creaVtk/MeshToImageData.h @@ -0,0 +1,52 @@ + +#ifndef MeshToImageData_h +#define MeshToImageData_h + +//#include "creaVTK_EXPORT.h" + +#include +#include +#include +#include +#include +#include + +class /*creaVTK_EXPORT*/ MeshToImageData +{ +public: + MeshToImageData(); + //Inputs + vtkImageData *InImage; + double BackgroundValue; + vtkPolyData *InPolyData; + //Outputs + vtkImageData* Out; + + // Get Inputs + vtkImageData *GetInputInImage(); + double GetInputBackgroundValue(); + vtkPolyData *GetInputInPolyData(); + + // Set Inputs + void SetInputInImage( vtkImageData *image); + void SetInputBackgroundValue( double value ); + void SetInputInPolyData( vtkPolyData *polydata); + + // Set Outputs + void SetOutputOut(vtkImageData *image); + // Get Outputs + vtkImageData* GetOutputOut(); + + // Atributes + vtkCleanPolyData *clean1; + vtkPolyDataToImageStencil *dataToStencil; + vtkExtractVOI *extract; + vtkImageStencil *stencil; + + void Process(); + +}; + + +#endif // _h_INCLUDED__ + -- 2.50.0