Part: Enable trimmed curves to set their parameter range, from c++ and Python
============================================================================= >>> geometries = ActiveSketch.Geometry >>> geo2 = geometries[2] >>> geo2 ArcOfCircle (Radius : 27.5267, Position : (-70.4702, -31.8933, 0), Direction : (0, 0, 1), Parameter : (1.34187, 2.35619)) >>> geo2.setParameterRange(1,3) >>> geometries[2]=geo2 >>> ActiveSketch.Geometry=geometries
This commit is contained in:
@@ -29,5 +29,12 @@
|
||||
const Geom_Ellipse & value(void) const {return *getGeom_EllipsePtr();}
|
||||
</ClassDeclarations>
|
||||
-->
|
||||
<Methode Name="setParameterRange" Const="false">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Re-trims this curve to the provided parameter range ([Float=First, Float=Last])
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -197,6 +197,31 @@ int ArcPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* ArcPy::setParameterRange(PyObject * args)
|
||||
{
|
||||
Handle(Geom_Geometry) g = getGeomTrimmedCurvePtr()->handle();
|
||||
Handle(Geom_TrimmedCurve) c = Handle(Geom_TrimmedCurve)::DownCast(g);
|
||||
try {
|
||||
if (!c.IsNull()) {
|
||||
double u,v;
|
||||
u=c->FirstParameter();
|
||||
v=c->LastParameter();
|
||||
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
|
||||
return 0;
|
||||
getGeomTrimmedCurvePtr()->setRange(u,v);
|
||||
Py_Return;
|
||||
}
|
||||
}
|
||||
catch (Base::CADKernelError& e) {
|
||||
PyErr_SetString(PartExceptionOCCError, e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a trimmed curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
PyObject *ArcPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
@@ -204,5 +229,5 @@ PyObject *ArcPy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int ArcPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1549,6 +1549,25 @@ bool GeomTrimmedCurve::intersectBasisCurves( const GeomTrimmedCurve * c,
|
||||
|
||||
}
|
||||
|
||||
void GeomTrimmedCurve::getRange(double& u, double& v) const
|
||||
{
|
||||
Handle(Geom_TrimmedCurve) curve = Handle(Geom_TrimmedCurve)::DownCast(handle());
|
||||
u = curve->FirstParameter();
|
||||
v = curve->LastParameter();
|
||||
}
|
||||
|
||||
void GeomTrimmedCurve::setRange(double u, double v)
|
||||
{
|
||||
try {
|
||||
Handle(Geom_TrimmedCurve) curve = Handle(Geom_TrimmedCurve)::DownCast(handle());
|
||||
|
||||
curve->SetTrim(u, v);
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
THROWM(Base::CADKernelError,e.GetMessageString())
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Part::GeomArcOfConic,Part::GeomTrimmedCurve)
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ protected:
|
||||
|
||||
protected:
|
||||
Geometry();
|
||||
|
||||
|
||||
protected:
|
||||
boost::uuids::uuid tag;
|
||||
boost::uuids::uuid tag;
|
||||
|
||||
private:
|
||||
Geometry(const Geometry&);
|
||||
@@ -172,12 +172,12 @@ public:
|
||||
double curvatureAt(double u) const;
|
||||
double length(double u, double v) const;
|
||||
bool normalAt(double u, Base::Vector3d& dir) const;
|
||||
bool intersect(GeomCurve * c,
|
||||
std::vector<std::pair<Base::Vector3d, Base::Vector3d>>& points,
|
||||
bool intersect(GeomCurve * c,
|
||||
std::vector<std::pair<Base::Vector3d, Base::Vector3d>>& points,
|
||||
double tol = Precision::Confusion()) const;
|
||||
|
||||
|
||||
void reverse(void);
|
||||
|
||||
|
||||
protected:
|
||||
static bool intersect(const Handle(Geom_Curve) c, const Handle(Geom_Curve) c2,
|
||||
std::vector<std::pair<Base::Vector3d, Base::Vector3d>>& points,
|
||||
@@ -228,11 +228,11 @@ class PartExport GeomBSplineCurve : public GeomBoundedCurve
|
||||
public:
|
||||
GeomBSplineCurve();
|
||||
GeomBSplineCurve(const Handle(Geom_BSplineCurve)&);
|
||||
|
||||
|
||||
GeomBSplineCurve( const std::vector<Base::Vector3d>& poles, const std::vector<double>& weights,
|
||||
const std::vector<double>& knots, const std::vector<int>& multiplicities,
|
||||
int degree, bool periodic=false, bool checkrational = true);
|
||||
|
||||
|
||||
virtual ~GeomBSplineCurve();
|
||||
virtual Geometry *copy(void) const;
|
||||
|
||||
@@ -353,10 +353,13 @@ public:
|
||||
void setHandle(const Handle(Geom_TrimmedCurve)&);
|
||||
const Handle(Geom_Geometry)& handle() const;
|
||||
|
||||
bool intersectBasisCurves( const GeomTrimmedCurve * c,
|
||||
std::vector<std::pair<Base::Vector3d, Base::Vector3d>>& points,
|
||||
bool intersectBasisCurves( const GeomTrimmedCurve * c,
|
||||
std::vector<std::pair<Base::Vector3d, Base::Vector3d>>& points,
|
||||
double tol = Precision::Confusion()) const;
|
||||
|
||||
|
||||
virtual void getRange(double& u, double& v) const;
|
||||
virtual void setRange(double u, double v);
|
||||
|
||||
protected:
|
||||
Handle(Geom_TrimmedCurve) myCurve;
|
||||
};
|
||||
@@ -395,6 +398,9 @@ public:
|
||||
virtual void getRange(double& u, double& v, bool emulateCCWXY) const = 0;
|
||||
virtual void setRange(double u, double v, bool emulateCCWXY) = 0;
|
||||
|
||||
inline virtual void getRange(double& u, double& v) const { getRange(u,v,false);};
|
||||
inline virtual void setRange(double u, double v) { setRange(u,v,false);};
|
||||
|
||||
bool isReversed() const;
|
||||
double getAngleXU(void) const;
|
||||
void setAngleXU(double angle);
|
||||
@@ -429,7 +435,7 @@ public:
|
||||
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
|
||||
|
||||
const Handle(Geom_Geometry)& handle() const;
|
||||
|
||||
|
||||
void setHandle(const Handle(Geom_Circle)&);
|
||||
|
||||
private:
|
||||
@@ -537,7 +543,7 @@ public:
|
||||
GeomHyperbola(const Handle(Geom_Hyperbola)&);
|
||||
virtual ~GeomHyperbola();
|
||||
virtual Geometry *copy(void) const;
|
||||
|
||||
|
||||
double getMajorRadius(void) const;
|
||||
void setMajorRadius(double Radius);
|
||||
double getMinorRadius(void) const;
|
||||
@@ -598,7 +604,7 @@ public:
|
||||
GeomParabola(const Handle(Geom_Parabola)&);
|
||||
virtual ~GeomParabola();
|
||||
virtual Geometry *copy(void) const;
|
||||
|
||||
|
||||
double getFocal(void) const;
|
||||
void setFocal(double length);
|
||||
|
||||
@@ -628,9 +634,9 @@ public:
|
||||
|
||||
double getFocal(void) const;
|
||||
void setFocal(double length);
|
||||
|
||||
|
||||
Base::Vector3d getFocus(void) const;
|
||||
|
||||
|
||||
virtual void getRange(double& u, double& v, bool emulateCCWXY) const;
|
||||
virtual void setRange(double u, double v, bool emulateCCWXY);
|
||||
|
||||
@@ -687,7 +693,7 @@ public:
|
||||
Base::Vector3d getStartPoint() const;
|
||||
Base::Vector3d getEndPoint() const;
|
||||
|
||||
void setPoints(const Base::Vector3d& p1,
|
||||
void setPoints(const Base::Vector3d& p1,
|
||||
const Base::Vector3d& p2);
|
||||
|
||||
// Persistence implementer ---------------------
|
||||
@@ -1038,7 +1044,7 @@ private:
|
||||
|
||||
|
||||
// Helper functions for fillet tools
|
||||
PartExport
|
||||
PartExport
|
||||
bool find2DLinesIntersection(const Base::Vector3d &orig1, const Base::Vector3d &dir1,
|
||||
const Base::Vector3d &orig2, const Base::Vector3d &dir2,
|
||||
Base::Vector3d &point);
|
||||
|
||||
Reference in New Issue
Block a user