[Surface]: Change to BaseClass

This commit is contained in:
Matteo-Grellier
2022-08-22 16:40:23 +02:00
committed by wwmayer
parent c85c8cfb33
commit 27bf1dff0e
8 changed files with 20 additions and 71 deletions

View File

@@ -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");
}

View File

@@ -22,14 +22,10 @@
#ifndef BLEND_CURVE_H
#define BLEND_CURVE_H
#include <Geom_BezierCurve.hxx>
// #include <Mod/Part/App/Geometry.h>
// #include <App/PropertyLinks.h>
// #include <App/PropertyStandard.h>
// #include <App/PropertyUnits.h>
// #include <Base/Persistence.h>
// #include <Mod/Part/App/PartFeature.h>
#include <Mod/Surface/SurfaceGlobal.h>
#include <Base/BaseClass.h>
#include <Mod/Surface/App/Blending/BlendPoint.h>
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<BlendPoint> 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

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PersistencePy"
FatherInclude="Base/PersistencePy.h"
Father="BaseClassPy"
FatherInclude="Base/BaseClassPy.h"
FatherNamespace="Base"
Name="BlendCurvePy"
PythonName="Surface.BlendCurve"

View File

@@ -27,8 +27,6 @@
#endif
#include "Blending/BlendCurvePy.h"
#include "Blending/BlendPointPy.h"
// #include "Mod/Part/App/Geometry.h"
// #include <Base/GeometryPyCXX.h>
#include "Blending/BlendCurvePy.cpp"
#include <Base/VectorPy.h>
#include <Mod/Part/App/BezierCurvePy.h>

View File

@@ -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());
}
}

View File

@@ -23,14 +23,11 @@
#ifndef BLEND_POINT_H
#define BLEND_POINT_H
#include <App/PropertyLinks.h>
#include <App/PropertyStandard.h>
#include <App/PropertyUnits.h>
#include <Base/Persistence.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Surface/SurfaceGlobal.h>
#include <Mod/Part/App/FeaturePartSpline.h>
#include <Base/BaseClass.h>
#include <Base/Vector3D.h>
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<Base::Vector3d> 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

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PersistencePy"
FatherInclude="Base/PersistencePy.h"
Father="BaseClassPy"
FatherInclude="Base/BaseClassPy.h"
FatherNamespace="Base"
Name="BlendPointPy"
PythonName="Surface.BlendPoint"

View File

@@ -149,6 +149,10 @@ App::DocumentObjectExecReturn *FeatureBlendCurve::execute(void)
return StdReturn;
}
PyObject* Surface::BlendCurve::getPyObject(){
return nullptr;
}
double FeatureBlendCurve::RelativeToRealParameters(double relativeValue, double fp, double lp)
{
return fp + relativeValue * (lp - fp);