From d59326dc256aa89dd33ca55cfa4b0a37fcae095c Mon Sep 17 00:00:00 2001 From: Pablo Garzon Date: Thu, 11 May 2023 14:39:55 +0200 Subject: [PATCH] #3503 Clean BooleanOperationPolyDataFilter --- ...bcreaVtkBooleanOperationPolyDataFilter.cxx | 33 ++++++-- .../src/bbcreaVtkCleanPolyData.cxx | 79 +++++++++++++++++++ bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.h | 51 ++++++++++++ .../src/bbcreaVtkTriangleFilter.cxx | 78 ++++++++++++++++++ .../src/bbcreaVtkTriangleFilter.h | 51 ++++++++++++ 5 files changed, 286 insertions(+), 6 deletions(-) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.h create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx index 7a2d956..79a92c2 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx @@ -40,7 +40,7 @@ void BooleanOperationPolyDataFilter::Process() if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) ) { - +/* printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); @@ -49,7 +49,9 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); - +*/ + +/* vtkCleanPolyData *clean1 = vtkCleanPolyData::New(); vtkCleanPolyData *clean2 = vtkCleanPolyData::New(); clean1->SetInputData( bbGetInputIn1() ); @@ -62,17 +64,20 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t triangle2->SetInputData( clean2->GetOutput() ); triangle1->Update(); triangle2->Update(); +*/ + //TRIANGLE FILTER NOT NEEDED, this can handle non triangle meshes. + // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter ) // https://github.com/zippy84/vtkbool // vtkPolyDataBooleanFilter is a local code creaVtk lib vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New(); - booleanOperation->SetInputData(0, triangle1->GetOutput() ); - booleanOperation->SetInputData(1, triangle2->GetOutput() ); +// booleanOperation->SetInputData(0, triangle1->GetOutput() ); +// booleanOperation->SetInputData(1, triangle2->GetOutput() ); -// booleanOperation->SetInputData(0, bbGetInputIn1() ); -// booleanOperation->SetInputData(1, bbGetInputIn2() ); + booleanOperation->SetInputData(0, bbGetInputIn1() ); + booleanOperation->SetInputData(1, bbGetInputIn2() ); if (bbGetInputOperation()==0 ) { @@ -116,6 +121,22 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t // fillHolesFilter->SetHoleSize(100000.0); // fillHolesFilter->Update(); // bbSetOutputOut( fillHolesFilter->GetOutput() ); + + /* + * + *Added boxes(triangleFilter and CleanPolyData) to handle this outside the box + * + + //vtkTriangleFilter *triangleEnd = vtkTriangleFilter::New(); + //triangleEnd->SetInputData( booleanOperation->GetOutput() ); + //triangleEnd->Update(); + + vtkCleanPolyData *cleanEnd = vtkCleanPolyData::New(); + cleanEnd->SetInputData( booleanOperation->GetOutput() ); + cleanEnd->Update(); + bbSetOutputOut( cleanEnd->GetOutput() ); + */ + bbSetOutputOut( booleanOperation->GetOutput() ); } else { bbSetOutputOut( NULL ); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.cxx new file mode 100644 index 0000000..8e79bed --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.cxx @@ -0,0 +1,79 @@ +//===== +// 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 "bbcreaVtkCleanPolyData.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,CleanPolyData) +BBTK_BLACK_BOX_IMPLEMENTATION(CleanPolyData,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 CleanPolyData::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') + if( bbGetInputIn() != NULL ) + { + cleanPolyData->SetInputData( bbGetInputIn() ); + cleanPolyData->Update(); + bbSetOutputOut( cleanPolyData->GetOutput() ); + }else{ + bbSetOutputOut(NULL); + } + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void CleanPolyData::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + cleanPolyData = 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 CleanPolyData::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + cleanPolyData = vtkCleanPolyData::New(); + +} +//===== +// 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 CleanPolyData::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + cleanPolyData->Delete(); + cleanPolyData = NULL; +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.h b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.h new file mode 100644 index 0000000..f5f0d01 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanPolyData.h @@ -0,0 +1,51 @@ +//===== +// 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 __bbcreaVtkCleanPolyData_h_INCLUDED__ +#define __bbcreaVtkCleanPolyData_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkCleanPolyData.h" +#include "vtkPolyData.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT CleanPolyData + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(CleanPolyData,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(In,vtkPolyData*); + BBTK_DECLARE_OUTPUT(Out,vtkPolyData*); + BBTK_PROCESS(Process); + void Process(); + + vtkCleanPolyData *cleanPolyData; +//===== +// 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(CleanPolyData,bbtk::AtomicBlackBox); +BBTK_NAME("CleanPolyData"); +BBTK_AUTHOR("InfoDev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); +BBTK_INPUT(CleanPolyData,In,"Input PolyData",vtkPolyData*,""); +BBTK_OUTPUT(CleanPolyData,Out,"Output PolyData",vtkPolyData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(CleanPolyData); +//===== +// 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 // __bbcreaVtkCleanPolyData_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.cxx new file mode 100644 index 0000000..b54f51a --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.cxx @@ -0,0 +1,78 @@ +//===== +// 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 "bbcreaVtkTriangleFilter.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,TriangleFilter) +BBTK_BLACK_BOX_IMPLEMENTATION(TriangleFilter,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 TriangleFilter::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') + if( bbGetInputIn() != NULL ) + { + triangleFilter->SetInputData( bbGetInputIn() ); + triangleFilter->Update(); + bbSetOutputOut( triangleFilter->GetOutput() ); + }else{ + bbSetOutputOut(NULL); + } + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TriangleFilter::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + triangleFilter = 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 TriangleFilter::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + triangleFilter = vtkTriangleFilter::New(); + +} +//===== +// 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 TriangleFilter::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + triangleFilter->Delete(); + triangleFilter = NULL; +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.h new file mode 100644 index 0000000..c210b45 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTriangleFilter.h @@ -0,0 +1,51 @@ +//===== +// 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 __bbcreaVtkTriangleFilter_h_INCLUDED__ +#define __bbcreaVtkTriangleFilter_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkPolyData.h" +#include "vtkTriangleFilter.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT TriangleFilter + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(TriangleFilter,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(In,vtkPolyData*); + BBTK_DECLARE_OUTPUT(Out,vtkPolyData*); + BBTK_PROCESS(Process); + void Process(); + + vtkTriangleFilter *triangleFilter; +//===== +// 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(TriangleFilter,bbtk::AtomicBlackBox); +BBTK_NAME("TriangleFilter"); +BBTK_AUTHOR("InfoDev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); +BBTK_INPUT(TriangleFilter,In,"Input PolyData", vtkPolyData*,""); +BBTK_OUTPUT(TriangleFilter,Out,"Output PolyData", vtkPolyData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(TriangleFilter); +//===== +// 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 // __bbcreaVtkTriangleFilter_h_INCLUDED__ + -- 2.45.1