implement ArcOfConic2d and ArcOfCircle2d
This commit is contained in:
parent
a0fc75d619
commit
3374737c5a
|
@ -14,31 +14,17 @@
|
|||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
|
||||
<UserDocu>Describes a portion of a circle</UserDocu>
|
||||
</Documentation>
|
||||
<!--
|
||||
<Attribute Name="Radius" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The radius of the circle.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Radius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the circle.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Circle" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The internal circle representation</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Circle" Type="Object"/>
|
||||
</Attribute>
|
||||
-->
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -23,21 +23,20 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <gp_Circ.hxx>
|
||||
# include <Geom_Circle.hxx>
|
||||
# include <GC_MakeArcOfCircle.hxx>
|
||||
# include <GC_MakeCircle.hxx>
|
||||
# include <Geom_TrimmedCurve.hxx>
|
||||
# include <gp_Circ2d.hxx>
|
||||
# include <Geom2d_Circle.hxx>
|
||||
# include <GCE2d_MakeArcOfCircle.hxx>
|
||||
# include <GCE2d_MakeCircle.hxx>
|
||||
# include <Geom2d_TrimmedCurve.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/Geom2d/ArcOfCircle2dPy.h>
|
||||
#include <Mod/Part/App/Geom2d/ArcOfCircle2dPy.cpp>
|
||||
//#include "CirclePy.h"
|
||||
//#include "OCCError.h"
|
||||
#include <Mod/Part/App/Geom2d/Circle2dPy.h>
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -46,30 +45,7 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et);
|
|||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ArcOfCircle2dPy::representation(void) const
|
||||
{
|
||||
#if 0
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
gp_Pnt loc = axis.Location();
|
||||
Standard_Real fRad = circle->Radius();
|
||||
Standard_Real u1 = trim->FirstParameter();
|
||||
Standard_Real u2 = trim->LastParameter();
|
||||
|
||||
std::stringstream str;
|
||||
str << "ArcOfCircle (";
|
||||
str << "Radius : " << fRad << ", ";
|
||||
str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), ";
|
||||
str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << "), ";
|
||||
str << "Parameter : (" << u1 << ", " << u2 << ")";
|
||||
str << ")";
|
||||
|
||||
return str.str();
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
return "<Arc of circle2d object>";
|
||||
}
|
||||
|
||||
PyObject *ArcOfCircle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
|
@ -81,23 +57,20 @@ PyObject *ArcOfCircle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
|
|||
// constructor method
|
||||
int ArcOfCircle2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
PyObject* o;
|
||||
double u1, u2;
|
||||
PyObject *sense=Py_True;
|
||||
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::CirclePy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
|
||||
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::Circle2dPy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
|
||||
try {
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast
|
||||
(static_cast<CirclePy*>(o)->getGeomCirclePtr()->handle());
|
||||
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast
|
||||
(static_cast<Circle2dPy*>(o)->getGeom2dCirclePtr()->handle());
|
||||
GCE2d_MakeArcOfCircle arc(circle->Circ2d(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
|
||||
if (!arc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
getGeomArcOfCirclePtr()->setHandle(arc.Value());
|
||||
getGeom2dArcOfCirclePtr()->setHandle(arc.Value());
|
||||
return 0;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
@ -113,113 +86,48 @@ int ArcOfCircle2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
|||
|
||||
PyErr_Clear();
|
||||
PyObject *pV1, *pV2, *pV3;
|
||||
if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), &pV1,
|
||||
&(Base::VectorPy::Type), &pV2,
|
||||
&(Base::VectorPy::Type), &pV3)) {
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
|
||||
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
|
||||
Base::Vector3d v3 = static_cast<Base::VectorPy*>(pV3)->value();
|
||||
if (PyArg_ParseTuple(args, "O!O!O!", Base::Vector2dPy::type_object(), &pV1,
|
||||
Base::Vector2dPy::type_object(), &pV2,
|
||||
Base::Vector2dPy::type_object(), &pV3)) {
|
||||
Base::Vector2d v1 = Py::Vector2d(pV1).getCxxObject()->value();
|
||||
Base::Vector2d v2 = Py::Vector2d(pV2).getCxxObject()->value();
|
||||
Base::Vector2d v3 = Py::Vector2d(pV3).getCxxObject()->value();
|
||||
|
||||
GC_MakeArcOfCircle arc(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Pnt(v2.x,v2.y,v2.z),
|
||||
gp_Pnt(v3.x,v3.y,v3.z));
|
||||
GCE2d_MakeArcOfCircle arc(gp_Pnt2d(v1.x,v1.y),
|
||||
gp_Pnt2d(v2.x,v2.y),
|
||||
gp_Pnt2d(v3.x,v3.y));
|
||||
if (!arc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
getGeomArcOfCirclePtr()->setHandle(arc.Value());
|
||||
getGeom2dArcOfCirclePtr()->setHandle(arc.Value());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// All checks failed
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"ArcOfCircle constructor expects a circle curve and a parameter range or three points");
|
||||
"ArcOfCircle2d constructor expects a circle curve and a parameter range or three points");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
|
||||
Py::Float ArcOfCircle2dPy::getRadius(void) const
|
||||
{
|
||||
return Py::Float(getGeomArcOfCirclePtr()->getRadius());
|
||||
return Py::Float(getGeom2dArcOfCirclePtr()->getRadius());
|
||||
}
|
||||
|
||||
void ArcOfCircle2dPy::setRadius(Py::Float arg)
|
||||
{
|
||||
getGeomArcOfCirclePtr()->setRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfCircle2dPy::getCenter(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfCirclePtr()->getCenter());
|
||||
}
|
||||
|
||||
void ArcOfCircle2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfCircle2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ArcOfCircle2dPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(circle->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
getGeom2dArcOfCirclePtr()->setRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfCircle2dPy::getCircle(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
return Py::Object(new CirclePy(new GeomCircle(circle)), true);
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(curve->BasisCurve());
|
||||
return Py::asObject(new Circle2dPy(new Geom2dCircle(circle)));
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject *ArcOfCircle2dPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -12,27 +12,37 @@
|
|||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
|
||||
<UserDocu>Describes a portion of a circle</UserDocu>
|
||||
<UserDocu>Describes an abstract arc of conic in 2d space</UserDocu>
|
||||
</Documentation>
|
||||
<!--
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the circle.</UserDocu>
|
||||
<UserDocu>Location of the conic.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
<Parameter Name="Location" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
returns the eccentricity value of the conic e.
|
||||
e = 0 for a circle
|
||||
0 < e < 1 for an ellipse (e = 0 if MajorRadius = MinorRadius)
|
||||
e > 1 for a hyperbola
|
||||
e = 1 for a parabola
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="XAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
<UserDocu>The X axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
<Parameter Name="XAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Circle" ReadOnly="true">
|
||||
<Attribute Name="YAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The internal circle representation</UserDocu>
|
||||
<UserDocu>The Y axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Circle" Type="Object"/>
|
||||
<Parameter Name="YAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
-->
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -23,11 +23,8 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <gp_Circ.hxx>
|
||||
# include <Geom_Circle.hxx>
|
||||
# include <GC_MakeArcOfCircle.hxx>
|
||||
# include <GC_MakeCircle.hxx>
|
||||
# include <Geom_TrimmedCurve.hxx>
|
||||
# include <Geom2d_Conic.hxx>
|
||||
# include <Geom2d_TrimmedCurve.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/Geometry2d.h>
|
||||
|
@ -36,176 +33,100 @@
|
|||
#include <Mod/Part/App/OCCError.h>
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
extern const char* gce_ErrorStatusText(gce_ErrorType et);
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ArcOfConic2dPy::representation(void) const
|
||||
{
|
||||
#if 0
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
gp_Pnt loc = axis.Location();
|
||||
Standard_Real fRad = circle->Radius();
|
||||
Standard_Real u1 = trim->FirstParameter();
|
||||
Standard_Real u2 = trim->LastParameter();
|
||||
|
||||
std::stringstream str;
|
||||
str << "ArcOfCircle (";
|
||||
str << "Radius : " << fRad << ", ";
|
||||
str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), ";
|
||||
str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << "), ";
|
||||
str << "Parameter : (" << u1 << ", " << u2 << ")";
|
||||
str << ")";
|
||||
|
||||
return str.str();
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
return "<Arc of conic2d object>";
|
||||
}
|
||||
|
||||
PyObject *ArcOfConic2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// never create such objects with the constructor
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"You cannot create an instance of the abstract class 'ArcOfConic2d'.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int ArcOfConic2dPy::PyInit(PyObject* args, PyObject* /*kwds*/)
|
||||
{
|
||||
#if 0
|
||||
PyObject* o;
|
||||
double u1, u2;
|
||||
PyObject *sense=Py_True;
|
||||
if (PyArg_ParseTuple(args, "O!dd|O!", &(Part::CirclePy::Type), &o, &u1, &u2, &PyBool_Type, &sense)) {
|
||||
try {
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast
|
||||
(static_cast<CirclePy*>(o)->getGeomCirclePtr()->handle());
|
||||
GC_MakeArcOfCircle arc(circle->Circ(), u1, u2, PyObject_IsTrue(sense) ? Standard_True : Standard_False);
|
||||
if (!arc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
getGeomArcOfCirclePtr()->setHandle(arc.Value());
|
||||
return 0;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return -1;
|
||||
}
|
||||
catch (...) {
|
||||
PyErr_SetString(PartExceptionOCCError, "creation of arc failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
PyObject *pV1, *pV2, *pV3;
|
||||
if (PyArg_ParseTuple(args, "O!O!O!", &(Base::VectorPy::Type), &pV1,
|
||||
&(Base::VectorPy::Type), &pV2,
|
||||
&(Base::VectorPy::Type), &pV3)) {
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
|
||||
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
|
||||
Base::Vector3d v3 = static_cast<Base::VectorPy*>(pV3)->value();
|
||||
|
||||
GC_MakeArcOfCircle arc(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Pnt(v2.x,v2.y,v2.z),
|
||||
gp_Pnt(v3.x,v3.y,v3.z));
|
||||
if (!arc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(arc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
getGeomArcOfCirclePtr()->setHandle(arc.Value());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// All checks failed
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"ArcOfCircle constructor expects a circle curve and a parameter range or three points");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#if 0
|
||||
Py::Object ArcOfConic2dPy::getCenter(void) const
|
||||
|
||||
Py::Object ArcOfConic2dPy::getLocation(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfCirclePtr()->getCenter());
|
||||
Base::Vector2d loc = getGeom2dArcOfConicPtr()->getLocation();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(loc.x));
|
||||
arg.setItem(1, Py::Float(loc.y));
|
||||
return method.apply(arg);
|
||||
}
|
||||
|
||||
void ArcOfConic2dPy::setCenter(Py::Object arg)
|
||||
void ArcOfConic2dPy::setLocation(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
Base::Vector2d loc = Py::Vector2d(arg.ptr()).getCxxObject()->value();
|
||||
getGeom2dArcOfConicPtr()->setLocation(loc);
|
||||
}
|
||||
|
||||
Py::Object ArcOfConic2dPy::getAxis(void) const
|
||||
Py::Float ArcOfConic2dPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
return Py::Float(conic->Eccentricity());
|
||||
}
|
||||
|
||||
void ArcOfConic2dPy::setAxis(Py::Object arg)
|
||||
Py::Object ArcOfConic2dPy::getXAxis(void) const
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(circle->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
gp_Dir2d xdir = conic->XAxis().Direction();
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(xdir.X()));
|
||||
arg.setItem(1, Py::Float(xdir.Y()));
|
||||
return method.apply(arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfConic2dPy::getCircle(void) const
|
||||
void ArcOfConic2dPy::setXAxis(Py::Object arg)
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfCirclePtr()->handle());
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(trim->BasisCurve());
|
||||
return Py::Object(new CirclePy(new GeomCircle(circle)), true);
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
Base::Vector2d dir = Py::Vector2d(arg.ptr()).getCxxObject()->value();
|
||||
gp_Ax2d xaxis = conic->XAxis();
|
||||
xaxis.SetDirection(gp_Dir2d(dir.x, dir.y));
|
||||
conic->SetXAxis(xaxis);
|
||||
}
|
||||
#endif
|
||||
|
||||
Py::Object ArcOfConic2dPy::getYAxis(void) const
|
||||
{
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
gp_Dir2d ydir = conic->YAxis().Direction();
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
Py::Tuple arg(2);
|
||||
arg.setItem(0, Py::Float(ydir.X()));
|
||||
arg.setItem(1, Py::Float(ydir.Y()));
|
||||
return method.apply(arg);
|
||||
}
|
||||
|
||||
void ArcOfConic2dPy::setYAxis(Py::Object arg)
|
||||
{
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(getGeom2dArcOfConicPtr()->handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
Base::Vector2d dir = Py::Vector2d(arg.ptr()).getCxxObject()->value();
|
||||
gp_Ax2d yaxis = conic->YAxis();
|
||||
yaxis.SetDirection(gp_Dir2d(dir.x, dir.y));
|
||||
conic->SetYAxis(yaxis);
|
||||
}
|
||||
|
||||
PyObject *ArcOfConic2dPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -27,24 +27,6 @@
|
|||
</Documentation>
|
||||
<Parameter Name="MinorRadius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the ellipse</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Ellipse" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The internal ellipse representation</UserDocu>
|
||||
|
|
|
@ -149,79 +149,6 @@ void ArcOfEllipse2dPy::setMinorRadius(Py::Float arg)
|
|||
getGeomArcOfEllipsePtr()->setMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float ArcOfEllipse2dPy::getAngleXU(void) const
|
||||
{
|
||||
return Py::Float(getGeomArcOfEllipsePtr()->getAngleXU());
|
||||
}
|
||||
|
||||
void ArcOfEllipse2dPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
getGeomArcOfEllipsePtr()->setAngleXU((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipse2dPy::getCenter(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfEllipsePtr()->getCenter());
|
||||
}
|
||||
|
||||
void ArcOfEllipse2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfEllipsePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfEllipsePtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipse2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfEllipsePtr()->handle());
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ArcOfEllipse2dPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfEllipsePtr()->handle());
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(ellipse->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
ellipse->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipse2dPy::getEllipse(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
|
|
|
@ -27,24 +27,6 @@
|
|||
</Documentation>
|
||||
<Parameter Name="MinorRadius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the hyperbola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the hyperbola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the hyperbola</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Hyperbola" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The internal hyperbola representation</UserDocu>
|
||||
|
|
|
@ -149,79 +149,6 @@ void ArcOfHyperbola2dPy::setMinorRadius(Py::Float arg)
|
|||
getGeomArcOfHyperbolaPtr()->setMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float ArcOfHyperbola2dPy::getAngleXU(void) const
|
||||
{
|
||||
return Py::Float(getGeomArcOfHyperbolaPtr()->getAngleXU());
|
||||
}
|
||||
|
||||
void ArcOfHyperbola2dPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
getGeomArcOfHyperbolaPtr()->setAngleXU((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfHyperbola2dPy::getCenter(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfHyperbolaPtr()->getCenter());
|
||||
}
|
||||
|
||||
void ArcOfHyperbola2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfHyperbolaPtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfHyperbolaPtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfHyperbola2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfHyperbolaPtr()->handle());
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = hyperbola->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ArcOfHyperbola2dPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfHyperbolaPtr()->handle());
|
||||
Handle_Geom_Hyperbola hyperbola = Handle_Geom_Hyperbola::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(hyperbola->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
hyperbola->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfHyperbola2dPy::getHyperbola(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
|
|
|
@ -20,24 +20,6 @@
|
|||
<UserDocu>The focal length of the parabola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Focal" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the parabola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the parabola.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the parabola</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Parabola" ReadOnly="true">
|
||||
<Documentation>
|
||||
|
|
|
@ -137,79 +137,6 @@ void ArcOfParabola2dPy::setFocal(Py::Float arg)
|
|||
getGeomArcOfParabolaPtr()->setFocal((double)arg);
|
||||
}
|
||||
|
||||
Py::Float ArcOfParabola2dPy::getAngleXU(void) const
|
||||
{
|
||||
return Py::Float(getGeomArcOfParabolaPtr()->getAngleXU());
|
||||
}
|
||||
|
||||
void ArcOfParabola2dPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
getGeomArcOfParabolaPtr()->setAngleXU((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfParabola2dPy::getCenter(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfParabolaPtr()->getCenter());
|
||||
}
|
||||
|
||||
void ArcOfParabola2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfParabolaPtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfParabolaPtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfParabola2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfParabolaPtr()->handle());
|
||||
Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = parabola->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ArcOfParabola2dPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfParabolaPtr()->handle());
|
||||
Handle_Geom_Parabola parabola = Handle_Geom_Parabola::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(parabola->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
parabola->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfParabola2dPy::getParabola(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
Constructor="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>Describes an abstract conic in 2d space
|
||||
</UserDocu>
|
||||
<UserDocu>Describes an abstract conic in 2d space</UserDocu>
|
||||
</Documentation>
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
<UserDocu>Changes the direction of parametrization of the curve.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<!--
|
||||
<Methode Name="toShape" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>Return the shape for the geometry.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="discretize" Const="true" Keyword="true">
|
||||
<!--
|
||||
<Methode Name="discretize" Const="true" Keyword="true">
|
||||
<Documentation>
|
||||
<UserDocu>Discretizes the curve and returns a list of points.
|
||||
The function accepts keywords as argument:
|
||||
|
|
|
@ -59,10 +59,7 @@
|
|||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/Geom2d/Curve2dPy.h>
|
||||
#include <Mod/Part/App/Geom2d/Curve2dPy.cpp>
|
||||
#include <Mod/Part/App/BSplineSurfacePy.h>
|
||||
#include <Mod/Part/App/PlanePy.h>
|
||||
#include <Mod/Part/App/PointPy.h>
|
||||
#include <Mod/Part/App/BSplineCurvePy.h>
|
||||
#include <Mod/Part/App/GeometrySurfacePy.h>
|
||||
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
@ -112,12 +109,18 @@ PyObject* Curve2dPy::reverse(PyObject *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern Py::Object shape2pyshape(const TopoDS_Shape &shape);
|
||||
|
||||
PyObject* Curve2dPy::toShape(PyObject *args)
|
||||
{
|
||||
PyObject* p;
|
||||
if (!PyArg_ParseTuple(args, "O!", &(Part::GeometrySurfacePy::Type), &p))
|
||||
return 0;
|
||||
try {
|
||||
TopoDS_Shape sh = getGeometry2dPtr()->toShape(Handle_Geom_Surface());
|
||||
return new TopoShapeEdgePy(new TopoShape(sh));
|
||||
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast(
|
||||
static_cast<GeometrySurfacePy*>(p)->getGeomSurfacePtr()->handle());
|
||||
TopoDS_Shape sh = getGeometry2dPtr()->toShape(surf);
|
||||
return Py::new_reference_to(shape2pyshape(sh));
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
@ -129,6 +132,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
|
||||
{
|
||||
try {
|
||||
|
|
|
@ -47,18 +47,6 @@
|
|||
</Documentation>
|
||||
<Parameter Name="MinorRadius" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="AngleXU" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The angle between the X axis and the major axis of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="AngleXU" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The eccentricity of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Focal" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>The focal distance of the ellipse.</UserDocu>
|
||||
|
@ -82,18 +70,6 @@ the second focus is on the negative side.
|
|||
</Documentation>
|
||||
<Parameter Name="Focus2" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the ellipse.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Axis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Axis" Type="Object"/>
|
||||
</Attribute>
|
||||
-->
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -154,44 +154,6 @@ void Ellipse2dPy::setMinorRadius(Py::Float arg)
|
|||
ellipse->SetMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float Ellipse2dPy::getAngleXU(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
|
||||
gp_Pnt center = ellipse->Axis().Location();
|
||||
gp_Dir normal = ellipse->Axis().Direction();
|
||||
gp_Dir xdir = ellipse->XAxis().Direction();
|
||||
|
||||
gp_Ax2 xdirref(center, normal); // this is a reference system, might be CCW or CW depending on the creation method
|
||||
|
||||
return Py::Float(-xdir.AngleWithRef(xdirref.XDirection(),normal));
|
||||
|
||||
}
|
||||
|
||||
void Ellipse2dPy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
|
||||
|
||||
gp_Pnt center = ellipse->Axis().Location();
|
||||
gp_Dir normal = ellipse->Axis().Direction();
|
||||
|
||||
gp_Ax1 normaxis(center, normal);
|
||||
|
||||
gp_Ax2 xdirref(center, normal);
|
||||
|
||||
xdirref.Rotate(normaxis,arg);
|
||||
|
||||
ellipse->SetPosition(xdirref);
|
||||
|
||||
}
|
||||
|
||||
Py::Float Ellipse2dPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
return Py::Float(ellipse->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float Ellipse2dPy::getFocal(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
|
@ -211,73 +173,6 @@ Py::Object Ellipse2dPy::getFocus2(void) const
|
|||
gp_Pnt loc = ellipse->Focus2();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
Py::Object Ellipse2dPy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
gp_Pnt loc = ellipse->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void Ellipse2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
ellipse->SetLocation(gp_Pnt(loc.x, loc.y, loc.z));
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
gp_Pnt loc;
|
||||
loc.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
loc.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
loc.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
ellipse->SetLocation(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object Ellipse2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void Ellipse2dPy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(getGeomEllipsePtr()->handle());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(ellipse->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
ellipse->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
PyObject *Ellipse2dPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
|
|
|
@ -666,7 +666,7 @@ Geom2dArcOfConic::~Geom2dArcOfConic()
|
|||
{
|
||||
}
|
||||
|
||||
Base::Vector2d Geom2dArcOfConic::getCenter(void) const
|
||||
Base::Vector2d Geom2dArcOfConic::getLocation(void) const
|
||||
{
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(handle());
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(curve->BasisCurve());
|
||||
|
@ -674,7 +674,7 @@ Base::Vector2d Geom2dArcOfConic::getCenter(void) const
|
|||
return Base::Vector2d(loc.X(),loc.Y());
|
||||
}
|
||||
|
||||
void Geom2dArcOfConic::setCenter(const Base::Vector2d& Center)
|
||||
void Geom2dArcOfConic::setLocation(const Base::Vector2d& Center)
|
||||
{
|
||||
gp_Pnt2d p1(Center.x,Center.y);
|
||||
Handle_Geom2d_TrimmedCurve curve = Handle_Geom2d_TrimmedCurve::DownCast(handle());
|
||||
|
|
|
@ -224,8 +224,8 @@ public:
|
|||
virtual ~Geom2dArcOfConic();
|
||||
virtual Geometry2d *clone(void) const = 0;
|
||||
|
||||
Base::Vector2d getCenter(void) const;
|
||||
void setCenter(const Base::Vector2d& Center);
|
||||
Base::Vector2d getLocation(void) const;
|
||||
void setLocation(const Base::Vector2d& Center);
|
||||
bool isReversed() const;
|
||||
|
||||
Base::Vector2d getStartPoint() const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user