From: Eduardo DAVILA Date: Tue, 30 Aug 2022 15:06:00 +0000 (+0200) Subject: #3493 MeshManager X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1b751726e6e277dc63258520d3c243f705d1b929;p=creaVtk.git #3493 MeshManager --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx index 3daea34..c1d7192 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx @@ -6,11 +6,11 @@ // #include "vtkBooleanOperationPolyDataFilter.h" #include "vtkPolyDataBooleanFilter.h" +#include "vtkPoints.h" #include "vtkCleanPolyData.h" #include "vtkTriangleFilter.h" - namespace bbcreaVtk { @@ -36,9 +36,19 @@ void BooleanOperationPolyDataFilter::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <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"); printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n"); @@ -95,11 +105,20 @@ printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at t } */ - booleanOperation->Update(); - bbSetOutputOut( booleanOperation->GetOutput() ); + booleanOperation->Update(); + vtkPoints *points = booleanOperation->GetOutput()->GetPoints(); + if (points!=NULL) + { + 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/bbcreaVtkCreateMeshFromPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx index 3d6227f..4c444dd 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCreateMeshFromPoints.cxx @@ -35,6 +35,12 @@ void CreateMeshFromPoints::Process() std::vector lstY = bbGetInputLstY(); std::vector lstZ = bbGetInputLstZ(); std::vector lstIndexs = bbGetInputLstIndexs(); + + printf("CreateMeshFromPoints::Process: sizeX %d \n", lstX.size() ); + printf("CreateMeshFromPoints::Process: sizeY %d \n", lstY.size() ); + printf("CreateMeshFromPoints::Process: sizeZ %d \n", lstZ.size() ); + printf("CreateMeshFromPoints::Process: lstIndexs %d \n", lstIndexs.size() ); + if ( (lstIndexs.size()<=1) || (lstX.size()==0) || (lstX.size()!=lstY.size()) || (lstY.size()!=lstZ.size()) ) { printf("Warnning! CreateMeshFromPoints::Process: List of points X Y Z and LstIndexes is not correct\n"); @@ -58,7 +64,7 @@ void CreateMeshFromPoints::Process() int iSeg1,iSeg2; int iGeneral = 0; int sizeLstIdexes=lstIndexs.size(); - for (i=0; iGetPointIds()->SetId(ii*2+1,iSeg2); iSeg1++; iSeg2++; - if (iSeg1>=maxSegment1) iSeg1=maxSegment1-1; - if (iSeg2>=maxSegment2) iSeg2=maxSegment2-1; + if (iSeg1>=maxSegment1) { iSeg1=maxSegment1-1; } + if (iSeg2>=maxSegment2) { iSeg2=maxSegment2-1; } } // for ii iGeneral=iGeneral+sizeSegment1; cells->InsertNextCell(triangleStrip); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx index 82651c6..826d759 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx @@ -33,7 +33,8 @@ void Cutter::Process() // See example in: // https://kitware.github.io/vtk-examples/site/Cxx/VisualizationAlgorithms/Cutter/ - if (bbGetInputIn()!=NULL) + printf("EED Cutter::Process start this=%p ImFu=%p \n ", this, bbGetInputImplicitFunction() ); + if ( (bbGetInputActive()==true) && (bbGetInputIn()!=NULL) ) { vtkCutter *cutter; cutter = vtkCutter::New(); @@ -44,6 +45,8 @@ void Cutter::Process() } else { bbSetOutputOut( NULL ); } + + printf("EED Cutter::Process end\n "); } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) @@ -53,6 +56,7 @@ void Cutter::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 // bbSetInputIn(NULL); + bbSetInputActive( true ); bbSetOutputOut( NULL ); } //===== diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.h index 35614e0..9878972 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCutter.h @@ -21,6 +21,7 @@ class bbcreaVtk_EXPORT Cutter //===== // 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,vtkPolyData*); BBTK_DECLARE_INPUT(ImplicitFunction,vtkImplicitFunction*); BBTK_DECLARE_OUTPUT(Out,vtkPolyData*); @@ -37,6 +38,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(Cutter,bbtk::AtomicBlackBox); BBTK_DESCRIPTION("vtkCutter"); BBTK_CATEGORY("empty"); + BBTK_INPUT(Cutter,Active,"(default true) Active true/false)",bool,""); BBTK_INPUT(Cutter,In,"vtkPolyData input",vtkPolyData*,""); BBTK_INPUT(Cutter,ImplicitFunction,"vtkImpliciteFunction ex.: vtkBox, vtkCone, vtkCylender, vtkPlane, vtkSphere(s), vtkQuadric, ETC.",vtkImplicitFunction*,""); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.cxx index cb4cca8..25be322 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.cxx @@ -6,6 +6,23 @@ namespace bbcreaVtk { +MeshManagerModel_Box::MeshManagerModel_Box( MeshManager *box ) +{ + mBox=box; +} + +MeshManagerModel_Box::~MeshManagerModel_Box( ) +{ +} + +void MeshManagerModel_Box::RefreshOutputs( ) +{ + mBox->bbSetOutputMeshBase( GetMeshBase() ); + mBox->bbSetOutputMeshTemp( GetMeshTemp() ); + mBox->bbSignalOutputModification(); +} + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MeshManager) BBTK_BLACK_BOX_IMPLEMENTATION(MeshManager,bbtk::AtomicBlackBox); //===== @@ -26,14 +43,14 @@ void MeshManager::Process() // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <SetMeshBase( bbGetInputMesh() ); - bbSetOutputMeshBase( meshManagerModel->GetMeshBase() ); - bbSetOutputMeshTemp( meshManagerModel->GetMeshTemp() ); - bbSetOutputMeshManagerModel( meshManagerModel ); - } + meshManagerModel_Box = new MeshManagerModel_Box(this); + meshManagerModel_Box->SetMeshBase( bbGetInputMesh() ); + meshManagerModel_Box->RefreshOutputs(); + bbSetOutputMeshManagerModel( meshManagerModel_Box ); + } // if meshManagerModel_Box } //===== @@ -44,7 +61,7 @@ void MeshManager::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 // bbSetInputIn(0); - meshManagerModel = NULL; + meshManagerModel_Box = NULL; bbSetInputMesh(NULL); } diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.h index 315ee5d..e4e389a 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager.h @@ -13,6 +13,8 @@ namespace bbcreaVtk { +class MeshManagerModel_Box; + class bbcreaVtk_EXPORT MeshManager : public bbtk::AtomicBlackBox @@ -28,12 +30,25 @@ class bbcreaVtk_EXPORT MeshManager BBTK_PROCESS(Process); void Process(); - MeshManagerModel *meshManagerModel; + MeshManagerModel_Box *meshManagerModel_Box; //===== // 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) //===== }; +class MeshManagerModel_Box : public MeshManagerModel +{ +public : + MeshManagerModel_Box(MeshManager *box); + ~MeshManagerModel_Box(); + virtual void RefreshOutputs(); +protected: +private: + MeshManager *mBox; +}; + + + BBTK_BEGIN_DESCRIBE_BLACK_BOX(MeshManager,bbtk::AtomicBlackBox); BBTK_NAME("MeshManager"); BBTK_AUTHOR("InfoDev"); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx index cb12791..bda31e1 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx @@ -27,25 +27,37 @@ void MeshManager_tool::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <SetMeshBase( bbGetInputMesh() ); - } + if (bbGetInputTool()==30) // Set + { + printf("EED MeshManager_tool::Process Set\n"); + if (bbGetInputMesh()!=NULL){ + vtkPoints *points = bbGetInputMesh()->GetPoints(); + if (points!=NULL) + { + bbGetInputMeshManagerModel()->SetMeshBase( bbGetInputMesh() ); + } // if points!=NULL + } // Mesh!=NULL + } // if Tool 30 Set - if (bbGetInputTool()==4) // Reset - { - printf("EED Warning! MeshManager_tool Reset Not implemented.\n"); - } + if (bbGetInputTool()==40) // Reset + { + printf("EED Warning! MeshManager_tool Reset Not implemented.\n"); + } // if Tool 40 Reset + } else { + printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n"); + }// if MeshManagerModel != NULL } //===== @@ -59,32 +71,28 @@ void MeshManager_tool::bbUserSetDefaultValues() bbSetInputMesh(NULL); bbSetInputMeshManagerModel(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 MeshManager_tool::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 MeshManager_tool::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/bbcreaVtkMeshManager_tool.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.h index f4ce72e..43a960d 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.h @@ -38,7 +38,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(MeshManager_tool,bbtk::AtomicBlackBox); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(MeshManager_tool,Tool,"(default 0) 0:Nothing 1:Undo 2:ReDo 3:Set 4:Reset",int,""); + BBTK_INPUT(MeshManager_tool,Tool,"(default 0) 0:Nothing 10:Undo 20:ReDo 30:Set 40:Reset",int,""); BBTK_INPUT(MeshManager_tool,Mesh,"Mesh",vtkPolyData*,""); BBTK_INPUT(MeshManager_tool,MeshManagerModel,"Mesh Manager Model",MeshManagerModel*,""); diff --git a/lib/creaVtk/MeshManagerModel.cpp b/lib/creaVtk/MeshManagerModel.cpp index bcf8c1a..01f3398 100644 --- a/lib/creaVtk/MeshManagerModel.cpp +++ b/lib/creaVtk/MeshManagerModel.cpp @@ -39,13 +39,17 @@ MeshManagerModel::~MeshManagerModel() void MeshManagerModel::SetMeshBase(vtkPolyData* mesh) { - _meshBase = mesh; - if (_meshTemp!=NULL) + if (mesh!=NULL) { - _meshTemp->Delete(); - } // if - _meshTemp = vtkPolyData::New(); - _meshTemp->DeepCopy(_meshBase); + _meshBase = mesh; + if (_meshTemp!=NULL) + { + _meshTemp->Delete(); + } // if + _meshTemp = vtkPolyData::New(); + _meshTemp->DeepCopy(_meshBase); + RefreshOutputs(); + } // if mesh } vtkPolyData* MeshManagerModel::GetMeshBase() @@ -57,3 +61,7 @@ vtkPolyData* MeshManagerModel::GetMeshTemp() { return _meshTemp; } + +void MeshManagerModel::RefreshOutputs() // virtula +{ +} diff --git a/lib/creaVtk/MeshManagerModel.h b/lib/creaVtk/MeshManagerModel.h index 70f33f8..7677cc7 100644 --- a/lib/creaVtk/MeshManagerModel.h +++ b/lib/creaVtk/MeshManagerModel.h @@ -48,6 +48,7 @@ public : void SetMeshBase(vtkPolyData* mesh); vtkPolyData* GetMeshBase(); vtkPolyData* GetMeshTemp(); + virtual void RefreshOutputs(); //--Method template---------------------------- // void FunctionName(int& parameterA);