From c01e9ed63b999c29ceaef14a478d4a877abf0a8e Mon Sep 17 00:00:00 2001 From: marioalexis Date: Tue, 3 Dec 2024 11:44:56 -0300 Subject: [PATCH 1/2] Fem: Fix FemPostPipeline base class --- src/Mod/Fem/App/FemPostPipeline.cpp | 106 ++++++---------------------- src/Mod/Fem/App/FemPostPipeline.h | 3 +- src/Mod/Fem/Gui/Command.cpp | 1 + src/Mod/Fem/Gui/TaskPostBoxes.cpp | 1 + 4 files changed, 26 insertions(+), 85 deletions(-) diff --git a/src/Mod/Fem/App/FemPostPipeline.cpp b/src/Mod/Fem/App/FemPostPipeline.cpp index 53ac2721ae..5fa1d45291 100644 --- a/src/Mod/Fem/App/FemPostPipeline.cpp +++ b/src/Mod/Fem/App/FemPostPipeline.cpp @@ -42,6 +42,7 @@ #include "FemMesh.h" #include "FemMeshObject.h" +#include "FemPostFilter.h" #include "FemPostPipeline.h" #include "FemPostPipelinePy.h" #include "FemVTKTools.h" @@ -84,41 +85,11 @@ short FemPostPipeline::mustExecute() const return 1; } - return FemPostFilter::mustExecute(); + return FemPostObject::mustExecute(); } DocumentObjectExecReturn* FemPostPipeline::execute() { - - // if we are the toplevel pipeline our data object is not created by filters, - // we are the main source - if (!Input.getValue()) { - return StdReturn; - } - - // now if we are a filter than our data object is created by the filter we hold - - // if we are in serial mode we just copy over the data of the last filter, - // but if we are in parallel we need to combine all filter results - if (Mode.getValue() == 0) { - // serial - Data.setValue(getLastPostObject()->Data.getValue()); - } - else if (Mode.getValue() == 1) { - // parallel, go through all filters and append the result - const std::vector& filters = Filter.getValues(); - std::vector::const_iterator it = filters.begin(); - - vtkSmartPointer append = vtkSmartPointer::New(); - for (; it != filters.end(); ++it) { - - append->AddInputDataObject(static_cast(*it)->Data.getValue()); - } - - append->Update(); - Data.setValue(append->GetOutputDataObject(0)); - } - return Fem::FemPostObject::execute(); } @@ -189,61 +160,30 @@ void FemPostPipeline::onChanged(const Property* prop) std::vector::iterator it = objs.begin(); FemPostFilter* filter = static_cast(*it); - // If we have a Input we need to ensure our filters are connected correctly - if (Input.getValue()) { + // the first filter must always grab the data + if (filter->Input.getValue()) { + filter->Input.setValue(nullptr); + } - // the first filter is always connected to the input - if (filter->Input.getValue() != Input.getValue()) { - filter->Input.setValue(Input.getValue()); + // all the others need to be connected to the previous filter or grab the data, + // dependent on mode + ++it; + for (; it != objs.end(); ++it) { + FemPostFilter* nextFilter = static_cast(*it); + + if (Mode.getValue() == 0) { // serial mode + if (nextFilter->Input.getValue() != filter) { + nextFilter->Input.setValue(filter); + } + } + else { // Parallel mode + if (nextFilter->Input.getValue()) { + nextFilter->Input.setValue(nullptr); + } } - // all the others need to be connected to the previous filter or the source, - // dependent on the mode - ++it; - for (; it != objs.end(); ++it) { - FemPostFilter* nextFilter = static_cast(*it); - - if (Mode.getValue() == 0) { // serial mode - if (nextFilter->Input.getValue() != filter) { - nextFilter->Input.setValue(filter); - } - } - else { // Parallel mode - if (nextFilter->Input.getValue() != Input.getValue()) { - nextFilter->Input.setValue(Input.getValue()); - } - } - - filter = nextFilter; - }; - } - // if we have no input the filters are responsible of grabbing the pipeline data themself - else { - // the first filter must always grab the data - if (filter->Input.getValue()) { - filter->Input.setValue(nullptr); - } - - // all the others need to be connected to the previous filter or grab the data, - // dependent on mode - ++it; - for (; it != objs.end(); ++it) { - FemPostFilter* nextFilter = static_cast(*it); - - if (Mode.getValue() == 0) { // serial mode - if (nextFilter->Input.getValue() != filter) { - nextFilter->Input.setValue(filter); - } - } - else { // Parallel mode - if (nextFilter->Input.getValue()) { - nextFilter->Input.setValue(nullptr); - } - } - - filter = nextFilter; - }; - } + filter = nextFilter; + }; } App::GeoFeature::onChanged(prop); diff --git a/src/Mod/Fem/App/FemPostPipeline.h b/src/Mod/Fem/App/FemPostPipeline.h index 475b0e6f99..2f5cb260da 100644 --- a/src/Mod/Fem/App/FemPostPipeline.h +++ b/src/Mod/Fem/App/FemPostPipeline.h @@ -23,7 +23,6 @@ #ifndef Fem_FemPostPipeline_H #define Fem_FemPostPipeline_H -#include "FemPostFilter.h" #include "FemPostFunction.h" #include "FemPostObject.h" #include "FemResultObject.h" @@ -34,7 +33,7 @@ namespace Fem { -class FemExport FemPostPipeline: public Fem::FemPostFilter +class FemExport FemPostPipeline: public Fem::FemPostObject { PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostPipeline); diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 3e7f493170..2ef4a338f1 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -59,6 +59,7 @@ #include "FemSettings.h" #ifdef FC_USE_VTK +#include #include #include #endif diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index fd46038991..a8647b8bc7 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include "ui_TaskPostClip.h" From 7bd413066f1b3de3d11e4f7b2be29e011ccb2da4 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 6 Dec 2024 11:29:37 -0600 Subject: [PATCH 2/2] Update src/Mod/Fem/App/FemPostPipeline.cpp --- src/Mod/Fem/App/FemPostPipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Fem/App/FemPostPipeline.cpp b/src/Mod/Fem/App/FemPostPipeline.cpp index 5fa1d45291..ecc57dc190 100644 --- a/src/Mod/Fem/App/FemPostPipeline.cpp +++ b/src/Mod/Fem/App/FemPostPipeline.cpp @@ -169,7 +169,7 @@ void FemPostPipeline::onChanged(const Property* prop) // dependent on mode ++it; for (; it != objs.end(); ++it) { - FemPostFilter* nextFilter = static_cast(*it); + auto* nextFilter = static_cast(*it); if (Mode.getValue() == 0) { // serial mode if (nextFilter->Input.getValue() != filter) {