implement Circle2d
This commit is contained in:
@@ -94,6 +94,24 @@ int Curve2dPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* Curve2dPy::reverse(PyObject *args)
|
||||
{
|
||||
try {
|
||||
Handle_Geom2d_Curve curve = Handle_Geom2d_Curve::DownCast(getGeom2dCurvePtr()->handle());
|
||||
curve->Reverse();
|
||||
Py_Return;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
{
|
||||
@@ -335,18 +353,24 @@ PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
PyObject* Curve2dPy::value(PyObject *args)
|
||||
{
|
||||
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
|
||||
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
|
||||
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
|
||||
try {
|
||||
if (!c.IsNull()) {
|
||||
double u;
|
||||
if (!PyArg_ParseTuple(args, "d", &u))
|
||||
return 0;
|
||||
gp_Pnt p = c->Value(u);
|
||||
return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z()));
|
||||
gp_Pnt2d p = c->Value(u);
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(p.X()));
|
||||
arg.setItem(1, Py::Float(p.Y()));
|
||||
return Py::new_reference_to(method.apply(arg));
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
@@ -358,7 +382,7 @@ PyObject* Curve2dPy::value(PyObject *args)
|
||||
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PyObject* Curve2dPy::tangent(PyObject *args)
|
||||
{
|
||||
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
|
||||
@@ -567,10 +591,10 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Py::String Curve2dPy::getContinuity(void) const
|
||||
{
|
||||
GeomAbs_Shape c = Handle_Geom_Curve::DownCast
|
||||
GeomAbs_Shape c = Handle_Geom2d_Curve::DownCast
|
||||
(getGeometry2dPtr()->handle())->Continuity();
|
||||
std::string str;
|
||||
switch (c) {
|
||||
@@ -602,18 +626,30 @@ Py::String Curve2dPy::getContinuity(void) const
|
||||
return Py::String(str);
|
||||
}
|
||||
|
||||
Py::Boolean Curve2dPy::getClosed(void) const
|
||||
{
|
||||
return Py::Boolean(Handle_Geom2d_Curve::DownCast
|
||||
(getGeometry2dPtr()->handle())->IsClosed() ? true : false);
|
||||
}
|
||||
|
||||
Py::Boolean Curve2dPy::getPeriodic(void) const
|
||||
{
|
||||
return Py::Boolean(Handle_Geom2d_Curve::DownCast
|
||||
(getGeometry2dPtr()->handle())->IsPeriodic() ? true : false);
|
||||
}
|
||||
|
||||
Py::Float Curve2dPy::getFirstParameter(void) const
|
||||
{
|
||||
return Py::Float(Handle_Geom_Curve::DownCast
|
||||
return Py::Float(Handle_Geom2d_Curve::DownCast
|
||||
(getGeometry2dPtr()->handle())->FirstParameter());
|
||||
}
|
||||
|
||||
Py::Float Curve2dPy::getLastParameter(void) const
|
||||
{
|
||||
return Py::Float(Handle_Geom_Curve::DownCast
|
||||
return Py::Float(Handle_Geom2d_Curve::DownCast
|
||||
(getGeometry2dPtr()->handle())->LastParameter());
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject *Curve2dPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user