From f0aa12497ad598b17a962739c0744098209d0103 Mon Sep 17 00:00:00 2001 From: mosfet80 Date: Mon, 10 Feb 2025 18:04:26 +0100 Subject: [PATCH] clean SketchObject.cpp (#15728) * clean SketchObject.cpp Code clean small optimization * Restore comment --------- Co-authored-by: Chris Hennes --- src/Mod/Sketcher/App/SketchObject.cpp | 40 ++++++++------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 95e3689dda..e925fd7c4d 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -581,16 +581,15 @@ int SketchObject::solve(bool updateGeoAfterSolving /*=true*/) // achieved. if (err == 0) { FullyConstrained.setValue(lastDoF == 0); - } - - if (err == 0 && updateGeoAfterSolving) { - // set the newly solved geometry - std::vector geomlist = solvedSketch.extractGeometry(); - Part::PropertyGeometryList tmp; - tmp.setValues(std::move(geomlist)); - // Only set values if there is actual changes - if (!Geometry.isSame(tmp)) - Geometry.moveValues(std::move(tmp)); + if (updateGeoAfterSolving) { + // set the newly solved geometry + std::vector geomlist = solvedSketch.extractGeometry(); + Part::PropertyGeometryList tmp; + tmp.setValues(std::move(geomlist)); + // Only set values if there is actual changes + if (!Geometry.isSame(tmp)) + Geometry.moveValues(std::move(tmp)); + } } else if (err < 0) { // if solver failed, invalid constraints were likely added before solving @@ -3061,9 +3060,6 @@ int SketchObject::fillet(int GeoId1, int GeoId2, const Base::Vector3d& refPnt1, Base::Vector3d refp1 = curve1->pointAtParameter(refparam1); Base::Vector3d refp2 = curve2->pointAtParameter(refparam2); - // Base::Console().Log("refpoints: - // (%f,%f,%f);(%f,%f,%f)",refp1.x,refp1.y,refp1.z,refp2.x,refp2.y,refp2.z); - Base::Vector3d normalintersect( (-dir1.x * dir2.x * refp1.y + dir1.x * dir2.x * refp2.y - dir1.x * dir2.y * refp2.x + dir2.x * dir1.y * refp1.x) @@ -7596,17 +7592,13 @@ int SketchObject::carbonCopy(App::DocumentObject* pObj, bool construction) } } - // We shall solve in all cases, because recompute may fail, and leave the + // Solve even if `noRecomputes==false`, because recompute may fail, and leave the // sketch in an inconsistent state. A concrete example. If the copied sketch // has broken external geometry, its recomputation will fail. And because we // use expression for copied constraint to add dependency to the copied // sketch, this sketch will not be recomputed (because its dependency fails // to recompute). -#if 0 - if (noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver -#endif - solve(); - + solve(); return svals.size(); } @@ -7892,7 +7884,6 @@ int SketchObject::delAllExternal() const std::vector originalSubElements = SubElements; Objects.clear(); - SubElements.clear(); const std::vector& constraints = Constraints.getValues(); @@ -8136,14 +8127,6 @@ static gp_Vec ProjVecOnPlane_UVN(const gp_Vec& V, const gp_Pln& Pl) return gp_Vec(vector.X(), vector.Y(), 0.0); } -// Auxiliary Method: returns vector projection in XYZ space -#if 0 -static gp_Vec ProjVecOnPlane_XYZ( const gp_Vec& V, const gp_Pln& Pl) -{ - return V.Dot(Pl.Position().XDirection()) * Pl.Position().XDirection() + - V.Dot(Pl.Position().YDirection()) * Pl.Position().YDirection(); -} -#endif // Auxiliary Method: returns point projection in UV space of plane static gp_Vec2d ProjPointOnPlane_UV(const gp_Pnt& P, const gp_Pln& Pl) @@ -9571,7 +9554,6 @@ const std::vector> SketchObject::getCoincidenc void SketchObject::isCoincidentWithExternalGeometry(int GeoId, bool& start_external, bool& mid_external, bool& end_external) { - start_external = false; mid_external = false; end_external = false;