From 48a37e4d1e2190d059a744837e3b5d7fc020b590 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 26 Jul 2024 21:48:33 -0500 Subject: [PATCH] Sketcher/Toponaming: Minor code cleanup during review --- src/Mod/Sketcher/App/SketchObject.cpp | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index e898f21569..a9582df276 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -104,6 +104,8 @@ #include #include +#include + #include "SketchObject.h" #include "SketchObjectPy.h" #include "SolverGeometryExtension.h" @@ -612,22 +614,25 @@ int SketchObject::solve(bool updateGeoAfterSolving /*=true*/) namespace bg = boost::geometry; namespace bgi = boost::geometry::index; +// NOLINTNEXTLINE BOOST_GEOMETRY_REGISTER_POINT_3D( Base::Vector3d,double,bg::cs::cartesian,x,y,z) class SketchObject::GeoHistory { +private: + static constexpr int bgiMaxElements = 16; public: - typedef bgi::linear<16> Parameters; + using Parameters = bgi::linear; - typedef std::set IdSet; - typedef std::pair IdSets; - typedef std::list AdjList; + using IdSet = std::set; + using IdSets = std::pair; + using AdjList = std::list; //associate a geo with connected ones on both points - typedef std::map AdjMap; + using AdjMap = std::map; // maps start/end points to all existing geo to query and update adjacencies - typedef std::pair Value; + using Value = std::pair; AdjList adjlist; AdjMap adjmap; @@ -636,7 +641,7 @@ public: AdjList::iterator find(const Base::Vector3d &pt,bool strict=true){ std::vector ret; rtree.query(bgi::nearest(pt,1),std::back_inserter(ret)); - if(ret.size()) { + if(!ret.empty()) { // NOTE: we are using square distance here, the 1e-6 threshold is // very forgiving. We should have used Precision::SquareConfisuion(), // which is 1e-14. However, there is a problem with current @@ -647,13 +652,9 @@ public: double tol = strict?Precision::SquareConfusion()*10:1e-6; double d = Base::DistanceP2(ret[0].first,pt); if(d(); FC_TIME_INIT(t); const auto &geos = getInternalGeometry(); geoHistory->clear(); - for(int i=0;i<(int)geos.size();++i) { - auto geo = geos[i]; + for(auto geo : geos) { auto pstart = getPoint(geo,PointPos::start); auto pend = getPoint(geo,PointPos::end); int id = GeometryFacade::getId(geo); @@ -7098,7 +7098,7 @@ bool SketchObject::modifyBSplineKnotMultiplicity(int GeoId, int knotIndex, int m if (GeoId < 0 || GeoId > getHighestCurveIndex()) THROWMT(Base::ValueError, - QT_TRANSLATE_NOOP("Exceptions", "BSpline Geometry Index (GeoID) is out of bounds.")) + QT_TRANSLATE_NOOP("Exceptions", "B-spline Geometry Index (GeoID) is out of bounds.")) if (multiplicityincr == 0)// no change in multiplicity THROWMT( @@ -7110,7 +7110,7 @@ bool SketchObject::modifyBSplineKnotMultiplicity(int GeoId, int knotIndex, int m if (geo->getTypeId() != Part::GeomBSplineCurve::getClassTypeId()) THROWMT(Base::TypeError, QT_TRANSLATE_NOOP("Exceptions", - "The Geometry Index (GeoId) provided is not a B-spline curve.")) + "The Geometry Index (GeoId) provided is not a B-spline.")) const Part::GeomBSplineCurve* bsp = static_cast(geo); @@ -7283,7 +7283,7 @@ bool SketchObject::insertBSplineKnot(int GeoId, double param, int multiplicity) if (GeoId < 0 || GeoId > getHighestCurveIndex()) THROWMT( Base::ValueError, - QT_TRANSLATE_NOOP("Exceptions", "BSpline Geometry Index (GeoID) is out of bounds.")); + QT_TRANSLATE_NOOP("Exceptions", "B-spline Geometry Index (GeoID) is out of bounds.")); if (multiplicity == 0) THROWMT(Base::ValueError, @@ -7294,7 +7294,7 @@ bool SketchObject::insertBSplineKnot(int GeoId, double param, int multiplicity) if (geo->getTypeId() != Part::GeomBSplineCurve::getClassTypeId()) THROWMT(Base::TypeError, QT_TRANSLATE_NOOP("Exceptions", - "The Geometry Index (GeoId) provided is not a B-spline curve.")); + "The Geometry Index (GeoId) provided is not a B-spline.")); const Part::GeomBSplineCurve* bsp = static_cast(geo); @@ -7306,12 +7306,12 @@ bool SketchObject::insertBSplineKnot(int GeoId, double param, int multiplicity) THROWMT(Base::ValueError, QT_TRANSLATE_NOOP( "Exceptions", - "Knot multiplicity cannot be higher than the degree of the BSpline.")); + "Knot multiplicity cannot be higher than the degree of the B-spline.")); if (param > lastParam || param < firstParam) THROWMT(Base::ValueError, QT_TRANSLATE_NOOP("Exceptions", - "Knot cannot be inserted outside the BSpline parameter range.")); + "Knot cannot be inserted outside the B-spline parameter range.")); std::unique_ptr bspline; @@ -8267,7 +8267,7 @@ Part::Geometry* projectLine(const BRepAdaptor_Curve& curve, const Handle(Geom_Pl invPlm.multVec(p1, p1); invPlm.multVec(p2, p2); - if (Base::Distance(p1, p2) < Precision::Confusion()) { + if (Base::DistanceP2(p1, p2) < Precision::SquareConfusion()) { Base::Vector3d p = (p1 + p2) / 2; Part::GeomPoint* point = new Part::GeomPoint(p); GeometryFacade::setConstruction(point, true);