From dd02c7a6f3872e4c67a3b9105cbe5f2b098edea1 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Sun, 6 Nov 2022 23:06:07 +0530 Subject: [PATCH] [Sketcher][planegcs] Handle type issues with `int` and `size_t` ... and `unsigned int` Suggestions thanks to @abdullahtahiriyo --- src/Mod/Sketcher/App/planegcs/GCS.cpp | 2 +- src/Mod/Sketcher/App/planegcs/GCS.h | 2 +- src/Mod/Sketcher/App/planegcs/Geo.cpp | 6 +++--- src/Mod/Sketcher/App/planegcs/Geo.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.cpp b/src/Mod/Sketcher/App/planegcs/GCS.cpp index 85ac511c78..9b2ce7e82d 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/planegcs/GCS.cpp @@ -812,7 +812,7 @@ int System::addConstraintTangentCircumf(Point &p1, Point &p2, double *rad1, doub return addConstraint(constr); } -int System::addConstraintTangentAtBSplineKnot(BSpline &b, Line &l, size_t knotindex, int tagId, bool driving) +int System::addConstraintTangentAtBSplineKnot(BSpline &b, Line &l, unsigned int knotindex, int tagId, bool driving) { Constraint *constr = new ConstraintSlopeAtBSplineKnot(b, l, knotindex); constr->setTag(tagId); diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index aa55774cdd..6de364afa6 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -257,7 +257,7 @@ namespace GCS int tagId=0, bool driving = true); int addConstraintTangentCircumf(Point &p1, Point &p2, double *rd1, double *rd2, bool internal=false, int tagId=0, bool driving = true); - int addConstraintTangentAtBSplineKnot(BSpline &b, Line &l, size_t knotindex, + int addConstraintTangentAtBSplineKnot(BSpline &b, Line &l, unsigned int knotindex, int tagId=0, bool driving = true); // derived constraints diff --git a/src/Mod/Sketcher/App/planegcs/Geo.cpp b/src/Mod/Sketcher/App/planegcs/Geo.cpp index 1ed70be814..9c595dcde8 100644 --- a/src/Mod/Sketcher/App/planegcs/Geo.cpp +++ b/src/Mod/Sketcher/App/planegcs/Geo.cpp @@ -712,7 +712,7 @@ BSpline* BSpline::Copy() return crv; } -double BSpline::getLinCombFactor(double x, size_t k, size_t i, size_t p) +double BSpline::getLinCombFactor(double x, size_t k, size_t i, unsigned int p) { // Adapted to C++ from the python implementation in the Wikipedia page for de Boor algorithm // https://en.wikipedia.org/wiki/De_Boor%27s_algorithm. @@ -734,7 +734,7 @@ double BSpline::getLinCombFactor(double x, size_t k, size_t i, size_t p) return 0.0; d[idxOfPole] = 1.0; - for (size_t r = 1; static_cast(r) < p + 1; ++r) { + for (size_t r = 1; r < p + 1; ++r) { for (size_t j = p; j > r - 1; --j) { double alpha = (x - flattenedknots[j + k - p]) / @@ -746,7 +746,7 @@ double BSpline::getLinCombFactor(double x, size_t k, size_t i, size_t p) return d[p]; } -double BSpline::splineValue(double x, size_t k, size_t p, VEC_D& d, const VEC_D& flatknots) +double BSpline::splineValue(double x, size_t k, unsigned int p, VEC_D& d, const VEC_D& flatknots) { for (size_t r = 1; r < p + 1; ++r) { for (size_t j = p; j > r - 1; --j) { diff --git a/src/Mod/Sketcher/App/planegcs/Geo.h b/src/Mod/Sketcher/App/planegcs/Geo.h index 0ab64871ef..6a4b24b5f4 100644 --- a/src/Mod/Sketcher/App/planegcs/Geo.h +++ b/src/Mod/Sketcher/App/planegcs/Geo.h @@ -304,7 +304,7 @@ namespace GCS /// k is the range in `flattenedknots` that contains x /// i is index of control point /// p is the degree - double getLinCombFactor(double x, size_t k, size_t i, size_t p); + double getLinCombFactor(double x, size_t k, size_t i, unsigned int p); inline double getLinCombFactor(double x, size_t k, size_t i) { return getLinCombFactor(x, k, i, degree); } void setupFlattenedKnots(); @@ -314,7 +314,7 @@ namespace GCS /// p is the degree /// d is the vector of (relevant) poles (this will be changed) /// flatknots is the vector of knots - static double splineValue(double x, size_t k, size_t p, VEC_D& d, const VEC_D& flatknots); + static double splineValue(double x, size_t k, unsigned int p, VEC_D& d, const VEC_D& flatknots); }; } //namespace GCS