From 27bf1dff0e57cc27b2b84a4b6e63bb22a5e93735 Mon Sep 17 00:00:00 2001 From: Matteo-Grellier Date: Mon, 22 Aug 2022 16:40:23 +0200 Subject: [PATCH] [Surface]: Change to BaseClass --- src/Mod/Surface/App/Blending/BlendCurve.cpp | 26 +++---------------- src/Mod/Surface/App/Blending/BlendCurve.h | 16 +++--------- src/Mod/Surface/App/Blending/BlendCurvePy.xml | 4 +-- .../Surface/App/Blending/BlendCurvePyImp.cpp | 2 -- src/Mod/Surface/App/Blending/BlendPoint.cpp | 18 +------------ src/Mod/Surface/App/Blending/BlendPoint.h | 17 ++++-------- src/Mod/Surface/App/Blending/BlendPointPy.xml | 4 +-- .../App/Blending/FeatureBlendCurve.cpp | 4 +++ 8 files changed, 20 insertions(+), 71 deletions(-) diff --git a/src/Mod/Surface/App/Blending/BlendCurve.cpp b/src/Mod/Surface/App/Blending/BlendCurve.cpp index 147962b5c4..541cf7d545 100644 --- a/src/Mod/Surface/App/Blending/BlendCurve.cpp +++ b/src/Mod/Surface/App/Blending/BlendCurve.cpp @@ -68,12 +68,12 @@ Handle(Geom_BezierCurve) BlendCurve::compute() try { // Uniform Parametrization TColStd_Array1OfReal params(1, nb_pts); - for (int i = 0; i < nb_pts; ++i) { + for (size_t i = 0; i < nb_pts; ++i) { params(i + 1) = (double)i / ((double)nb_pts - 1); } int num_poles = 0; - for (int i = 0; i < nb_pts; ++i) { + for (size_t i = 0; i < nb_pts; ++i) { num_poles += blendPoints[i].nbVectors(); } @@ -93,7 +93,7 @@ Handle(Geom_BezierCurve) BlendCurve::compute() math_Vector res_z(1, num_poles, 0.0); int row_idx = 1; int cons_idx = 1; - for (int i = 0; i < nb_pts; ++i) { + for (size_t i = 0; i < nb_pts; ++i) { math_Matrix bezier_eval(1, blendPoints[i].nbVectors(), 1, num_poles, 0.0); Standard_Integer first_non_zero; BSplCLib::EvalBsplineBasis(blendPoints[i].nbVectors() - 1, num_poles, knots, params(cons_idx), first_non_zero, bezier_eval, Standard_False); @@ -149,23 +149,3 @@ void BlendCurve::setSize(int i, double f, bool relative) PyErr_SetString(PyExc_Exception, e.GetMessageString()); } } - -unsigned int BlendCurve::getMemSize(void) const -{ - return 1; -} - -PyObject *BlendCurve::getPyObject(void) -{ - return new BlendCurvePy(new BlendCurve(blendPoints)); -} - -void BlendCurve::Save(Base::Writer & /*writer*/) const -{ - throw Base::NotImplementedError("BlendCurve::Save"); -} - -void BlendCurve::Restore(Base::XMLReader & /*reader*/) -{ - throw Base::NotImplementedError("BlendCurve::Restore"); -} diff --git a/src/Mod/Surface/App/Blending/BlendCurve.h b/src/Mod/Surface/App/Blending/BlendCurve.h index 5e75e0ca8f..4520d80dd1 100644 --- a/src/Mod/Surface/App/Blending/BlendCurve.h +++ b/src/Mod/Surface/App/Blending/BlendCurve.h @@ -22,14 +22,10 @@ #ifndef BLEND_CURVE_H #define BLEND_CURVE_H + #include -// #include -// #include -// #include -// #include -// #include -// #include #include +#include #include namespace Surface @@ -37,10 +33,9 @@ namespace Surface /*! * Create a BezierCurve interpolating a list of BlendPoints */ -class SurfaceExport BlendCurve: public Base::Persistence +class SurfaceExport BlendCurve: public Base::BaseClass { public: - std::vector blendPoints; BlendCurve(); @@ -64,11 +59,6 @@ public: void setSize(int, double, bool); virtual PyObject *getPyObject(void); - // Persistence implementer --------------------- - virtual unsigned int getMemSize(void) const; - virtual void Save(Base::Writer & /*writer*/) const; - virtual void Restore(Base::XMLReader & /*reader*/); - }; }// namespace Surface diff --git a/src/Mod/Surface/App/Blending/BlendCurvePy.xml b/src/Mod/Surface/App/Blending/BlendCurvePy.xml index aab9d90313..977eef9fef 100644 --- a/src/Mod/Surface/App/Blending/BlendCurvePy.xml +++ b/src/Mod/Surface/App/Blending/BlendCurvePy.xml @@ -1,8 +1,8 @@ #include "Blending/BlendCurvePy.cpp" #include #include diff --git a/src/Mod/Surface/App/Blending/BlendPoint.cpp b/src/Mod/Surface/App/Blending/BlendPoint.cpp index e96179808e..1adebe02fe 100644 --- a/src/Mod/Surface/App/Blending/BlendPoint.cpp +++ b/src/Mod/Surface/App/Blending/BlendPoint.cpp @@ -82,20 +82,4 @@ int BlendPoint::nbVectors() PyObject *BlendPoint::getPyObject(void) { return new BlendPointPy(new BlendPoint(vectors)); -} - -void BlendPoint::Save(Base::Writer & /*writer*/) const -{ - throw Base::NotImplementedError("BlendPoint::Save"); -} - -void BlendPoint::Restore(Base::XMLReader & /*reader*/) -{ - throw Base::NotImplementedError("BlendPoint::Restore"); -} - -unsigned int BlendPoint::getMemSize(void) const -{ - // do we need to loop on the vectors list ? - return sizeof(vectors) * sizeof(vectors.front()); -} +} \ No newline at end of file diff --git a/src/Mod/Surface/App/Blending/BlendPoint.h b/src/Mod/Surface/App/Blending/BlendPoint.h index c555521c4d..5b24575359 100644 --- a/src/Mod/Surface/App/Blending/BlendPoint.h +++ b/src/Mod/Surface/App/Blending/BlendPoint.h @@ -23,14 +23,11 @@ #ifndef BLEND_POINT_H #define BLEND_POINT_H -#include -#include -#include -#include -#include #include -#include +#include +#include + namespace Surface { @@ -39,10 +36,11 @@ namespace Surface * Create a list of vectors formed by a point and some derivatives * obtained from a curve or surface */ -class SurfaceExport BlendPoint: public Base::Persistence +class SurfaceExport BlendPoint: public Base::BaseClass { public: std::vector vectors; + BlendPoint(); /*! * Constructor @@ -70,11 +68,6 @@ public: */ int nbVectors(); virtual PyObject *getPyObject(void); - // Persistence implementer --------------------- - virtual unsigned int getMemSize(void) const; - virtual void Save(Base::Writer & /*writer*/) const; - virtual void Restore(Base::XMLReader & /*reader*/); - private: }; }// namespace Surface diff --git a/src/Mod/Surface/App/Blending/BlendPointPy.xml b/src/Mod/Surface/App/Blending/BlendPointPy.xml index 5c6f1c1798..1305d115e3 100644 --- a/src/Mod/Surface/App/Blending/BlendPointPy.xml +++ b/src/Mod/Surface/App/Blending/BlendPointPy.xml @@ -1,8 +1,8 @@