From 797e2ddbfbbf4794b08653db4e8ba0b63e077b33 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 7 Sep 2022 15:23:27 +0200 Subject: [PATCH] #3493 MeshManager --- ...bcreaVtkBooleanOperationPolyDataFilter.cxx | 30 ++++++---- bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx | 1 - .../src/bbcreaVtkLinearExtrusionFilter.cxx | 56 +++++++++---------- .../src/bbcreaVtkLinearExtrusionFilter.h | 6 +- .../bbcreaVtkMeshReduction_DecimatePro.cxx | 19 +++++-- ...creaVtkMeshReduction_QuadricDecimation.cxx | 14 +++-- .../src/bbcreaVtkPolyDataNormals.cxx | 38 ++++++++++--- .../src/bbcreaVtkTrimmedExtrusionFilter.cxx | 31 ++-------- .../src/bbcreaVtkTrimmedExtrusionFilter.h | 11 +--- 9 files changed, 111 insertions(+), 95 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx index c1d7192..564f379 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx @@ -10,6 +10,8 @@ #include "vtkCleanPolyData.h" #include "vtkTriangleFilter.h" +#include "vtkFillHolesFilter.h" + namespace bbcreaVtk { @@ -42,12 +44,6 @@ void BooleanOperationPolyDataFilter::Process() if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) ) { - - vtkPoints *points1 = bbGetInputIn1()->GetPoints(); - vtkPoints *points2 = bbGetInputIn2()->GetPoints(); - printf("EED BooleanOperationPolyDataFilter::Process Number of points 1 %ld\n", points1->GetNumberOfPoints() ); - printf("EED BooleanOperationPolyDataFilter::Process Number of points 2 %ld\n", points2->GetNumberOfPoints() ); - 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"); @@ -57,7 +53,8 @@ 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 *clean1 = vtkCleanPolyData::New(); vtkCleanPolyData *clean2 = vtkCleanPolyData::New(); clean1->SetInputData( bbGetInputIn1() ); clean2->SetInputData( bbGetInputIn2() ); @@ -70,9 +67,17 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t triangle1->Update(); triangle2->Update(); +// 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, bbGetInputIn1() ); +// booleanOperation->SetInputData(1, bbGetInputIn2() ); + if (bbGetInputOperation()==0 ) { booleanOperation->SetOperModeToUnion(); @@ -106,19 +111,24 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t */ booleanOperation->Update(); + vtkPoints *points = booleanOperation->GetOutput()->GetPoints(); if (points!=NULL) { - bbSetOutputOut( booleanOperation->GetOutput() ); + vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New(); + fillHolesFilter->SetInputData( booleanOperation->GetOutput() ); + fillHolesFilter->SetHoleSize(100000.0); + fillHolesFilter->Update(); + bbSetOutputOut( fillHolesFilter->GetOutput() ); +// bbSetOutputOut( booleanOperation->GetOutput() ); } else { bbSetOutputOut( NULL ); } // if points!=NULL + } else { bbSetOutputOut( NULL ); printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n"); } // if In1 In2 != NULL - - printf("EED BooleanOperationPolyDataFilter::Process End \n" ); } //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx index 742a700..0e4f85a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx @@ -33,7 +33,6 @@ void Cutter::Process() // See example in: // https://kitware.github.io/vtk-examples/site/Cxx/VisualizationAlgorithms/Cutter/ - printf("EED Cutter::Process start this=%p ImFu=%p In=%p\n", this, bbGetInputImplicitFunction() , bbGetInputIn() ); if ( (bbGetInputActive()==true) && (bbGetInputIn()!=NULL) ) { vtkCutter *cutter; diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.cxx index 5d0ea97..2b39efe 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.cxx @@ -3,7 +3,7 @@ //===== #include "bbcreaVtkLinearExtrusionFilter.h" #include "bbcreaVtkPackage.h" - +#include namespace bbcreaVtk { @@ -15,7 +15,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(LinearExtrusionFilter,bbtk::AtomicBlackBox); //===== void LinearExtrusionFilter::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -29,23 +28,27 @@ void LinearExtrusionFilter::Process() // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <Delete(); - } - if (triangleFilter!=NULL) - { - triangleFilter->Delete(); - } + extrude->Delete(); + extrude=NULL; + } + if (triangleFilter!=NULL) + { + triangleFilter->Delete(); + triangleFilter=NULL; + } - extrude = vtkLinearExtrusionFilter::New(); - triangleFilter = vtkTriangleFilter::New(); + if (bbGetInputIn()!=NULL) + { + std::vector dir = bbGetInputDirection(); + extrude = vtkLinearExtrusionFilter::New(); + triangleFilter = vtkTriangleFilter::New(); extrude->SetInputData( bbGetInputIn() ); extrude->SetExtrusionTypeToNormalExtrusion(); - std::vector dir = bbGetInputDirection(); if (dir.size()==3) { extrude->SetVector( dir[0],dir[1],dir[2] ); @@ -57,55 +60,52 @@ void LinearExtrusionFilter::Process() triangleFilter->SetInputData( extrude->GetOutput() ); triangleFilter->Update( ); bbSetOutputOut( triangleFilter->GetOutput() ); - } // if bbGetInputIn + } else { + bbSetOutputOut( NULL ); + }// if bbGetInputIn } + //===== // 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 LinearExtrusionFilter::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - extrude = NULL; triangleFilter = NULL; bbSetInputIn(NULL); - std::vector dir; dir.push_back(1); dir.push_back(0); dir.push_back(0); bbSetInputDirection( dir ); bbSetInputScalarFactor(0); - + 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 LinearExtrusionFilter::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 LinearExtrusionFilter::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/bbcreaVtkLinearExtrusionFilter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.h index e68ba66..01547a5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.h @@ -50,9 +50,9 @@ BBTK_CATEGORY("empty"); BBTK_END_DESCRIBE_BLACK_BOX(LinearExtrusionFilter); //===== // 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 // __bbcreaVtkLinearExtrusionFilter_h_INCLUDED__ diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_DecimatePro.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_DecimatePro.cxx index 6848c8a..8a019ff 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_DecimatePro.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_DecimatePro.cxx @@ -28,17 +28,25 @@ void MeshReduction_DecimatePro::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') + printf("EED MeshReduction_DecimatePro::Process In=%p \n",bbGetInputIn() ); + if (firsttime==true) { firsttime = false; decimatepro = vtkDecimatePro::New(); } - decimatepro->SetInputData( bbGetInputIn() ); - decimatepro->SetTargetReduction( bbGetInputTargetReduction() ); - decimatepro->PreserveTopologyOn(); - decimatepro->Update(); - bbSetOutputOut(decimatepro->GetOutput() ); + + if (bbGetInputIn()!=NULL) + { + decimatepro->SetInputData( bbGetInputIn() ); + decimatepro->SetTargetReduction( bbGetInputTargetReduction() ); + decimatepro->PreserveTopologyOn(); + decimatepro->Update(); + bbSetOutputOut(decimatepro->GetOutput() ); + } else { + bbSetOutputOut( NULL ); + } // 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) @@ -52,6 +60,7 @@ void MeshReduction_DecimatePro::bbUserSetDefaultValues() decimatepro = NULL; bbSetInputIn(NULL); bbSetInputTargetReduction(0.5); + 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_QuadricDecimation.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_QuadricDecimation.cxx index 38fd833..bf723e1 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_QuadricDecimation.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshReduction_QuadricDecimation.cxx @@ -32,12 +32,16 @@ void MeshReduction_QuadricDecimation::Process() firsttime =false; quadricdecimation = vtkQuadricDecimation::New(); } - quadricdecimation->SetInputData( bbGetInputIn() ); + if (bbGetInputIn()!=NULL) + { + quadricdecimation->SetInputData( bbGetInputIn() ); + quadricdecimation->SetTargetReduction( bbGetInputTargetReduction() ); + quadricdecimation->Update(); + bbSetOutputOut(quadricdecimation->GetOutput() ); + } else { + bbSetOutputOut( NULL ); + } // if In - quadricdecimation->SetTargetReduction( bbGetInputTargetReduction() ); - - quadricdecimation->Update(); - bbSetOutputOut(quadricdecimation->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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx index f9676e5..e369989 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataNormals.cxx @@ -5,6 +5,7 @@ #include "bbcreaVtkPackage.h" #include +//#include #include #include @@ -34,8 +35,12 @@ void PolyDataNormals::Process() // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <SetInputData( bbGetInputIn() ); if (bbGetInputComputeType()==0) @@ -44,8 +49,14 @@ void PolyDataNormals::Process() } else { normal->ComputePointNormalsOn(); } - // normal->SetFeatureAngle(60.0); + normal->SetFeatureAngle(360); + normal->Update(); + + /* + vtkTriangleMeshPointNormals* normal = vtkTriangleMeshPointNormals::New(); + normal->SetInputData( bbGetInputIn() ); normal->Update(); + */ // >>>>>>>>>>>>>>>>>>>> Calculate the MeanNormal vtkPolyData *polydata = normal->GetOutput(); @@ -62,12 +73,11 @@ void PolyDataNormals::Process() */ dataarray = pointdata->GetNormals(); std::vector meanNormal; - meanNormal.push_back(1); + meanNormal.push_back(0); meanNormal.push_back(0); meanNormal.push_back(0); if (dataarray!=NULL) { - meanNormal[0]=0; int i , size=dataarray->GetNumberOfTuples(); for (i=0; iGetNumberOfTuples(); for (i=0; iGetTuple3( i ); ang = vtkMath::AngleBetweenVectors( pValue, meanN ); - vtkMath::Cross(meanN,pValue,crossResult); wxyz[0] = ang * bbGetInputParam(); wxyz[1] = crossResult[0]; wxyz[2] = crossResult[1]; wxyz[3] = crossResult[2]; vtkMath::RotateVectorByWXYZ(meanN, wxyz ,meanNormalresult); + magnitude = sqrt( meanNormalresult[0]*meanNormalresult[0] + meanNormalresult[1]*meanNormalresult[1] + meanNormalresult[2]* meanNormalresult[2] ); + meanNormalresult[0] = meanNormalresult[0] / magnitude; + meanNormalresult[1] = meanNormalresult[1] / magnitude; + meanNormalresult[2] = meanNormalresult[2] / magnitude; dataarray->SetTuple3( i , meanNormalresult[0], meanNormalresult[1], meanNormalresult[2] ); } // for - } // if Type==1 && dataarray bbSetOutputMeanNormal( meanNormal ); bbSetOutputOut( normal->GetOutput() ); - } // if In + } else { + bbSetOutputOut( NULL ); + }// if In } //===== @@ -128,7 +147,8 @@ void PolyDataNormals::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputIn(NULL); + bbSetInputIn(NULL); + 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.cxx index ee6fc3e..84226bd 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.cxx @@ -33,19 +33,6 @@ void TrimmedExtrusionFilter::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " < dir; dir.push_back(1); dir.push_back(0); dir.push_back(0); bbSetInputDirection( dir ); - } + //===== // 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 TrimmedExtrusionFilter::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 TrimmedExtrusionFilter::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/bbcreaVtkTrimmedExtrusionFilter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.h index b975111..30ddfdc 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkTrimmedExtrusionFilter.h @@ -9,10 +9,7 @@ #include "iostream" #include - -// ------ Not exist in windows old VTK version --------- -//#include - +#include namespace bbcreaVtk { @@ -34,8 +31,7 @@ class bbcreaVtk_EXPORT TrimmedExtrusionFilter BBTK_PROCESS(Process); void Process(); -// ------ Not exist in windows old VTK version --------- -// vtkTrimmedExtrusionFilter *extrusion; + vtkTrimmedExtrusionFilter *extrusion; //===== @@ -61,8 +57,7 @@ BBTK_END_DESCRIBE_BLACK_BOX(TrimmedExtrusionFilter); //===== // 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 // __bbcreaVtkTrimmedExtrusionFilter_h_INCLUDED__ -- 2.45.1