diff --git a/src/Mod/Fem/App/FemPostBranchFilter.cpp b/src/Mod/Fem/App/FemPostBranchFilter.cpp index 36eef44d85..9d997cedea 100644 --- a/src/Mod/Fem/App/FemPostBranchFilter.cpp +++ b/src/Mod/Fem/App/FemPostBranchFilter.cpp @@ -24,27 +24,10 @@ #ifndef _PreComp_ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #endif -#include - -#include "FemMesh.h" -#include "FemMeshObject.h" #include "FemPostBranchFilter.h" #include "FemPostBranchFilterPy.h" -#include "FemVTKTools.h" - using namespace Fem; using namespace App; @@ -120,15 +103,14 @@ void FemPostBranchFilter::setupPipeline() m_append->RemoveAllInputConnections(0); FemPostFilter* filter = NULL; - std::vector::iterator it = objs.begin(); - for (; it != objs.end(); ++it) { + for (auto& obj : objs) { // prepare the filter: make all connections new - FemPostFilter* nextFilter = static_cast(*it); + FemPostFilter* nextFilter = static_cast(obj); nextFilter->getFilterInput()->RemoveAllInputConnections(0); // handle input modes - if (Mode.getValue() == 0) { + if (Mode.getValue() == Fem::PostGroupMode::Serial) { // serial: the next filter gets the previous output, the first one gets our input if (filter == NULL) { nextFilter->getFilterInput()->SetInputConnection(m_passthrough->GetOutputPort()); @@ -137,7 +119,7 @@ void FemPostBranchFilter::setupPipeline() } } - else if (Mode.getValue() == 1) { + else if (Mode.getValue() == Fem::PostGroupMode::Parallel) { // parallel: all filters get out input nextFilter->getFilterInput()->SetInputConnection(m_passthrough->GetOutputPort()); } @@ -162,7 +144,7 @@ void FemPostBranchFilter::onChanged(const Property* prop) if (prop == &Frame) { //Update all children with the new step for (const auto& obj : Group.getValues()) { - if (obj->isDerivedFrom(FemPostFilter::getClassTypeId())) { + if (obj->isDerivedFrom()) { static_cast(obj)->Frame.setValue(Frame.getValue()); } } @@ -193,7 +175,7 @@ void FemPostBranchFilter::filterChanged(FemPostFilter* filter) { //we only need to update the following children if we are in serial mode - if (Mode.getValue() == 0) { + if (Mode.getValue() == Fem::PostGroupMode::Serial) { std::vector objs = Group.getValues(); @@ -201,14 +183,13 @@ void FemPostBranchFilter::filterChanged(FemPostFilter* filter) return; } bool started = false; - std::vector::iterator it = objs.begin(); - for (; it != objs.end(); ++it) { + for (auto& obj : objs) { if (started) { - (*it)->touch(); + obj->touch(); } - if (*it == filter) { + if (obj == filter) { started = true; } } diff --git a/src/Mod/Fem/App/FemPostBranchFilter.h b/src/Mod/Fem/App/FemPostBranchFilter.h index 60ccf05836..be03b58b73 100644 --- a/src/Mod/Fem/App/FemPostBranchFilter.h +++ b/src/Mod/Fem/App/FemPostBranchFilter.h @@ -50,7 +50,7 @@ public: short mustExecute() const override; PyObject* getPyObject() override; - const char* getViewProviderName() const override + constexpr const char* getViewProviderName() const override { return "FemGui::ViewProviderFemPostBranchFilter"; } diff --git a/src/Mod/Fem/App/FemPostBranchFilterPyImp.cpp b/src/Mod/Fem/App/FemPostBranchFilterPyImp.cpp index 583844f7a1..c76d9c0db7 100644 --- a/src/Mod/Fem/App/FemPostBranchFilterPyImp.cpp +++ b/src/Mod/Fem/App/FemPostBranchFilterPyImp.cpp @@ -25,8 +25,6 @@ #include #endif -#include - // clang-format off #include "FemPostBranchFilter.h" #include "FemPostBranchFilterPy.h" diff --git a/src/Mod/Fem/App/FemPostFilter.h b/src/Mod/Fem/App/FemPostFilter.h index b0db05d949..03300c9d93 100644 --- a/src/Mod/Fem/App/FemPostFilter.h +++ b/src/Mod/Fem/App/FemPostFilter.h @@ -45,7 +45,11 @@ namespace Fem { -enum TransformLocation { input, output }; +enum class TransformLocation : size_t +{ + input, + output +}; class FemExport FemPostFilter: public Fem::FemPostObject { diff --git a/src/Mod/Fem/App/FemPostFunction.cpp b/src/Mod/Fem/App/FemPostFunction.cpp index 6c1833e9ac..c87f7b9be7 100644 --- a/src/Mod/Fem/App/FemPostFunction.cpp +++ b/src/Mod/Fem/App/FemPostFunction.cpp @@ -41,7 +41,7 @@ FemPostFunctionProvider::~FemPostFunctionProvider() = default; bool FemPostFunctionProvider::allowObject(App::DocumentObject* obj) { - return obj->isDerivedFrom(FemPostFunction::getClassTypeId()); + return obj->isDerivedFrom(); } void FemPostFunctionProvider::unsetupObject() @@ -60,11 +60,8 @@ void FemPostFunctionProvider::handleChangedPropertyName(Base::XMLReader& reader, if (strcmp(propName, "Functions") == 0 && Base::Type::fromName(typeName) == App::PropertyLinkList::getClassTypeId()) { - // add the formerly Functions values to the group - App::PropertyLinkList functions; - functions.setContainer(this); - functions.Restore(reader); - Group.setValues(functions.getValues()); + // restore the property into Group, instead of the old Functions property + Group.Restore(reader); } else { App::DocumentObject::handleChangedPropertyName(reader, typeName, propName); diff --git a/src/Mod/Fem/App/FemPostGroupExtension.cpp b/src/Mod/Fem/App/FemPostGroupExtension.cpp index 97fec2cb0f..28850ae16a 100644 --- a/src/Mod/Fem/App/FemPostGroupExtension.cpp +++ b/src/Mod/Fem/App/FemPostGroupExtension.cpp @@ -53,7 +53,7 @@ FemPostGroupExtension::~FemPostGroupExtension() { void FemPostGroupExtension::initExtension(App::ExtensionContainer* obj) { - if (!obj->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (!obj->isDerivedFrom()) { throw Base::RuntimeError("FemPostGroupExtension can only be applied to FemPostObject"); } @@ -68,8 +68,8 @@ void FemPostGroupExtension::extensionOnChanged(const App::Property* p) auto objs = Group.getValues(); std::sort( objs.begin( ), objs.end( ), [ ]( const App::DocumentObject* lhs, const App::DocumentObject* rhs ){ - int l = lhs->isDerivedFrom(FemPostFilter::getClassTypeId()) ? 0 : 1; - int r = rhs->isDerivedFrom(FemPostFilter::getClassTypeId()) ? 0 : 1; + int l = lhs->isDerivedFrom() ? 0 : 1; + int r = rhs->isDerivedFrom() ? 0 : 1; return r FemPostGroupExtension::getFilter() { //collect all other items that are not filters std::vector filters; - for (auto obj : Group.getValues()) { - if (obj->isDerivedFrom(Fem::FemPostFilter::getClassTypeId())) { + for (auto& obj : Group.getValues()) { + if (obj->isDerivedFrom()) { filters.push_back(static_cast(obj)); } } @@ -115,7 +115,7 @@ void FemPostGroupExtension::onExtendedUnsetupObject() bool FemPostGroupExtension::allowObject(App::DocumentObject* obj) { // only filters may be added - return obj->isDerivedFrom(Fem::FemPostFilter::getClassTypeId()); + return obj->isDerivedFrom(); } @@ -142,11 +142,9 @@ FemPostObject* FemPostGroupExtension::getLastPostObject() bool FemPostGroupExtension::holdsPostObject(FemPostObject* obj) { + for (const auto& group_obj : Group.getValues()) { - std::vector::const_iterator it = Group.getValues().begin(); - for (; it != Group.getValues().end(); ++it) { - - if (*it == obj) { + if (group_obj == obj) { return true; } } diff --git a/src/Mod/Fem/App/FemPostGroupExtension.h b/src/Mod/Fem/App/FemPostGroupExtension.h index cbb9ef125e..47e53fe96b 100644 --- a/src/Mod/Fem/App/FemPostGroupExtension.h +++ b/src/Mod/Fem/App/FemPostGroupExtension.h @@ -30,6 +30,12 @@ namespace Fem { +enum PostGroupMode +{ + Serial, + Parallel +}; + // object grouping FEM filters and building the structure of the pipeline class FemExport FemPostGroupExtension : public App::GroupExtension { diff --git a/src/Mod/Fem/App/FemPostObject.h b/src/Mod/Fem/App/FemPostObject.h index d9fa1f3c4a..7144b00b95 100644 --- a/src/Mod/Fem/App/FemPostObject.h +++ b/src/Mod/Fem/App/FemPostObject.h @@ -27,11 +27,12 @@ #include "PropertyPostDataObject.h" #include #include + #include -#include #include #include +class vtkDataSet; namespace Fem { diff --git a/src/Mod/Fem/App/FemPostPipeline.cpp b/src/Mod/Fem/App/FemPostPipeline.cpp index 002a5b0e0d..4a1c48adee 100644 --- a/src/Mod/Fem/App/FemPostPipeline.cpp +++ b/src/Mod/Fem/App/FemPostPipeline.cpp @@ -39,9 +39,10 @@ #include #include #include -#include #include #include +#include +#include #endif #include @@ -102,23 +103,20 @@ std::vector FemFrameSourceAlgorithm::getFrameValues() vtkDataObject* block = multiblock->GetBlock(i); // check if the TimeValue field is available if (!block->GetFieldData()->HasArray("TimeValue")) { - break; + // a frame with no valid value is a undefined state + return std::vector(); } // store the time value! vtkDataArray* TimeValue = block->GetFieldData()->GetArray("TimeValue"); if (!TimeValue->IsA("vtkFloatArray") || TimeValue->GetNumberOfTuples() < 1) { - break; + // a frame with no valid value is a undefined state + return std::vector(); } tFrames[i] = vtkFloatArray::SafeDownCast(TimeValue)->GetValue(0); } - if (tFrames.size() != nblocks) { - // not every block had time data - return std::vector(); - } - return tFrames; } @@ -189,7 +187,6 @@ int FemFrameSourceAlgorithm::RequestData(vtkInformation*, return 1; } - PROPERTY_SOURCE_WITH_EXTENSIONS(Fem::FemPostPipeline, Fem::FemPostObject) FemPostPipeline::FemPostPipeline() @@ -237,7 +234,7 @@ Fem::FemPostFunctionProvider* FemPostPipeline::getFunctionProvider() // see if we have one for (auto obj : Group.getValues()) { - if (obj->isDerivedFrom(FemPostFunctionProvider::getClassTypeId())) { + if (obj->isDerivedFrom()) { return static_cast(obj); } } @@ -247,7 +244,7 @@ Fem::FemPostFunctionProvider* FemPostPipeline::getFunctionProvider() bool FemPostPipeline::allowObject(App::DocumentObject* obj) { // we additionally allow FunctionPRoviders to be added - if (obj->isDerivedFrom(FemPostFunctionProvider::getClassTypeId())) { + if (obj->isDerivedFrom()) { return true; } @@ -406,7 +403,7 @@ void FemPostPipeline::onChanged(const Property* prop) value = frames[Frame.getValue()]; } for (const auto& obj : Group.getValues()) { - if (obj->isDerivedFrom(FemPostFilter::getClassTypeId())) { + if (obj->isDerivedFrom()) { static_cast(obj)->Frame.setValue(value); } } @@ -427,16 +424,15 @@ void FemPostPipeline::onChanged(const Property* prop) } FemPostFilter* filter = NULL; - std::vector::iterator it = objs.begin(); - for (; it != objs.end(); ++it) { + for (auto& obj : objs) { // prepare the filter: make all connections new - FemPostFilter* nextFilter = *it; + FemPostFilter* nextFilter = obj; nextFilter->getFilterInput()->RemoveAllInputConnections(0); // handle input modes (Parallel is seperated, alll other settings are serial, just in // case an old document is loaded with "custom" mode, idx 2) - if (Mode.getValue() == 1) { + if (Mode.getValue() == Fem::PostGroupMode::Parallel) { // parallel: all filters get out input nextFilter->getFilterInput()->SetInputConnection( m_transform_filter->GetOutputPort(0)); @@ -464,7 +460,7 @@ void FemPostPipeline::onChanged(const Property* prop) void FemPostPipeline::filterChanged(FemPostFilter* filter) { // we only need to update the following children if we are in serial mode - if (Mode.getValue() == 0) { + if (Mode.getValue() == Fem::PostGroupMode::Serial) { std::vector objs = Group.getValues(); @@ -472,17 +468,16 @@ void FemPostPipeline::filterChanged(FemPostFilter* filter) return; } bool started = false; - std::vector::iterator it = objs.begin(); - for (; it != objs.end(); ++it) { + for (auto& obj : objs) { if (started) { - (*it)->touch(); - if((*it)->hasExtension(Fem::FemPostGroupExtension::getExtensionClassTypeId())) { - (*it)->getExtension()->recomputeChildren(); + obj->touch(); + if(obj->hasExtension(Fem::FemPostGroupExtension::getExtensionClassTypeId())) { + obj->getExtension()->recomputeChildren(); } } - if (*it == filter) { + if (obj == filter) { started = true; } } @@ -592,10 +587,10 @@ void FemPostPipeline::load(FemResultObject* res) // set multiple result objects as frames for one pipeline // Notes: // 1. values vector must contain growing value, smallest first -void FemPostPipeline::load(std::vector res, - std::vector values, +void FemPostPipeline::load(std::vector& res, + std::vector& values, Base::Unit unit, - std::string frame_type) + std::string& frame_type) { if (res.size() != values.size()) { @@ -612,7 +607,7 @@ void FemPostPipeline::load(std::vector res, auto multiblock = vtkSmartPointer::New(); for (ulong i = 0; i < res.size(); i++) { - if (!res[i]->Mesh.getValue()->isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) { + if (!res[i]->Mesh.getValue()->isDerivedFrom()) { Base::Console().Error("Result mesh object is not derived from Fem::FemMeshObject.\n"); return; } @@ -679,8 +674,8 @@ void FemPostPipeline::onDocumentRestored() { // if a old document was loaded with "custom" mode setting, the current value // would be out of range. Reset it to "serial" - if (Mode.getValue() > 1 || Mode.getValue() < 0) { - Mode.setValue(long(0)); + if (Mode.getValue() > Fem::PostGroupMode::Parallel || Mode.getValue() < Fem::PostGroupMode::Serial) { + Mode.setValue(Fem::PostGroupMode::Serial); } } diff --git a/src/Mod/Fem/App/FemPostPipeline.h b/src/Mod/Fem/App/FemPostPipeline.h index e0d7b7a781..1db058306b 100644 --- a/src/Mod/Fem/App/FemPostPipeline.h +++ b/src/Mod/Fem/App/FemPostPipeline.h @@ -33,8 +33,9 @@ #include #include -#include -#include + +class vtkInformation; +class vtkInformationVector; namespace Fem @@ -93,7 +94,7 @@ public: // load from results void load(FemResultObject* res); - void load(std::vector res, std::vector values, Base::Unit unit, std::string frame_type); + void load(std::vector& res, std::vector& values, Base::Unit unit, std::string& frame_type); // Group pipeline handling void filterChanged(FemPostFilter* filter) override; diff --git a/src/Mod/Fem/App/PropertyPostDataObject.cpp b/src/Mod/Fem/App/PropertyPostDataObject.cpp index cdd8faa7a4..8f495a1faf 100644 --- a/src/Mod/Fem/App/PropertyPostDataObject.cpp +++ b/src/Mod/Fem/App/PropertyPostDataObject.cpp @@ -56,6 +56,7 @@ #include #endif #include +#include #include "PropertyPostDataObject.h" diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 9e1411a231..2b3023ec55 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1843,7 +1843,7 @@ void setupFilter(Gui::Command* cmd, std::string Name) pipeline = selObject; } else { pipeline = Fem::FemPostGroupExtension::getGroupOfObject(selObject); - if (!pipeline || !pipeline->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (!pipeline || !pipeline->isDerivedFrom()) { QMessageBox::warning( Gui::getMainWindow(), qApp->translate("setupFilter", "Error: Object not in a post processing group"), @@ -2027,7 +2027,7 @@ bool CmdFemPostClipFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2064,7 +2064,7 @@ bool CmdFemPostCutFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2101,7 +2101,7 @@ bool CmdFemPostDataAlongLineFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2139,7 +2139,7 @@ bool CmdFemPostDataAtPointFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2252,7 +2252,7 @@ bool CmdFemPostScalarClipFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2289,7 +2289,7 @@ bool CmdFemPostWarpVectorFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2326,7 +2326,7 @@ bool CmdFemPostContoursFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } @@ -2724,7 +2724,7 @@ bool CmdFemPostBranchFilter::isActive() } // only activate if a post object is selected for (auto obj : selection ) { - if (obj.pObject->isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (obj.pObject->isDerivedFrom()) { return true; } } diff --git a/src/Mod/Fem/Gui/Resources/icons/FEM_PostBranchFilter.svg b/src/Mod/Fem/Gui/Resources/icons/FEM_PostBranchFilter.svg index 39dfd204f1..9e4440146c 100644 --- a/src/Mod/Fem/Gui/Resources/icons/FEM_PostBranchFilter.svg +++ b/src/Mod/Fem/Gui/Resources/icons/FEM_PostBranchFilter.svg @@ -6,34 +6,12 @@ height="64" id="svg2" version="1.1" - sodipodi:docname="FEM_PostBranch.svg" - inkscape:version="1.4 (e7c3feb100, 2024-10-09)" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> - + id="path2" /> + id="path2-5" /> + id="path2-6-3" /> + id="path2-6" /> diff --git a/src/Mod/Fem/Gui/Resources/icons/FEM_PostFrames.svg b/src/Mod/Fem/Gui/Resources/icons/FEM_PostFrames.svg index 7bb690a987..c185c534d4 100644 --- a/src/Mod/Fem/Gui/Resources/icons/FEM_PostFrames.svg +++ b/src/Mod/Fem/Gui/Resources/icons/FEM_PostFrames.svg @@ -6,34 +6,12 @@ height="64" id="svg2" version="1.1" - sodipodi:docname="FEM_PostSteps.svg" - inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> - + id="path1" /> + id="path1-6" /> diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 503be20e16..e9e6f3c610 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -330,9 +330,8 @@ void TaskDlgPost::clicked(int button) bool TaskDlgPost::accept() { try { - std::vector::iterator it = m_boxes.begin(); - for (; it != m_boxes.end(); ++it) { - (*it)->applyPythonCode(); + for (auto& box : m_boxes) { + box->applyPythonCode(); } } catch (const Base::Exception& e) {