From f3637096e3338bce279242fa1c937a979ea32239 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 10 May 2024 10:46:16 +0200 Subject: [PATCH] PD: Fix linter warnings --- src/Mod/PartDesign/App/ShapeBinder.cpp | 72 +++++++++++++++----------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 4ee4c28125..47e6d3376e 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -76,10 +76,12 @@ void ShapeBinder::onChanged(const App::Property* prop) short int ShapeBinder::mustExecute() const { - if (Support.isTouched()) + if (Support.isTouched()) { return 1; - if (TraceSupport.isTouched()) + } + if (TraceSupport.isTouched()) { return 1; + } return Part::Feature::mustExecute(); } @@ -118,8 +120,8 @@ bool ShapeBinder::hasPlacementChanged() const return this->Placement.getValue() != placement; } -App::DocumentObjectExecReturn* ShapeBinder::execute() { - +App::DocumentObjectExecReturn* ShapeBinder::execute() +{ if (!this->isRestoring()) { Part::TopoShape shape(updatedShape()); if (!shape.isNull()) { @@ -151,8 +153,8 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, //we only allow one part feature, so get the first one we find size_t index = 0; for (auto* it : objs) { - if (it && it->isDerivedFrom()) { - obj = static_cast(it); + if (auto part = dynamic_cast(it)) { + obj = part; break; } index++; @@ -168,13 +170,15 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, //collect all subshapes for the object for (index = 0; index < objs.size(); index++) { //we only allow subshapes from a single Part::Feature - if (objs[index] != obj) + if (objs[index] != obj) { continue; + } //in this mode the full shape is not allowed, as we already started the subshape //processing - if (subs[index].empty()) + if (subs[index].empty()) { continue; + } subobjects.push_back(subs[index]); } @@ -182,12 +186,12 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, else { // search for Origin features for (auto* it : objs) { - if (it && it->isDerivedFrom()) { - obj = static_cast(it); + if (auto line = dynamic_cast(it)) { + obj = line; break; } - else if (it && it->isDerivedFrom()) { - obj = static_cast(it); + if (auto plane = dynamic_cast(it)) { + obj = plane; break; } } @@ -196,15 +200,18 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std::vector< std::string > subs) { - if (!obj) + if (!obj) { return TopoDS_Shape(); + } if (obj->isDerivedFrom()) { - Part::Feature* part = static_cast(obj); - if (subs.empty()) + auto part = static_cast(obj); + if (subs.empty()) { return part->Shape.getValue(); + } std::vector shapes; + shapes.reserve(subs.size()); for (const std::string& sub : subs) { shapes.push_back(part->Shape.getShape().getSubShape(sub.c_str())); } @@ -213,16 +220,15 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std: //single subshape. Return directly. return shapes[0]; } - else { - //multiple subshapes. Make a compound. - BRep_Builder builder; - TopoDS_Compound cmp; - builder.MakeCompound(cmp); - for (const TopoDS_Shape& sh : shapes) { - builder.Add(cmp, sh); - } - return cmp; + + //multiple subshapes. Make a compound. + BRep_Builder builder; + TopoDS_Compound cmp; + builder.MakeCompound(cmp); + for (const TopoDS_Shape& sh : shapes) { + builder.Add(cmp, sh); } + return cmp; } else if (obj->isDerivedFrom()) { gp_Lin line; @@ -267,14 +273,18 @@ void ShapeBinder::onSettingDocument() void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) { App::Document* doc = getDocument(); - if (!doc || doc->testStatus(App::Document::Restoring)) + if (!doc || doc->testStatus(App::Document::Restoring)) { return; - if (this == &Obj) + } + if (this == &Obj) { return; - if (!TraceSupport.getValue()) + } + if (!TraceSupport.getValue()) { return; - if (!Prop.isDerivedFrom()) + } + if (!Prop.isDerivedFrom()) { return; + } App::GeoFeature* obj = nullptr; std::vector subs; @@ -282,8 +292,9 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P if (obj) { if (obj == &Obj) { // the directly referenced object has changed - if (hasPlacementChanged()) + if (hasPlacementChanged()) { enforceRecompute(); + } } else if (Obj.hasExtension(App::GroupExtension::getExtensionClassTypeId())) { // check if the changed property belongs to a group-like object @@ -296,8 +307,9 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P auto it = std::find(chain.begin(), chain.end(), &Obj); if (it != chain.end()) { - if (hasPlacementChanged()) + if (hasPlacementChanged()) { enforceRecompute(); + } } } }