implement Circle2d
This commit is contained in:
parent
d50e3b2a53
commit
a0fc75d619
|
@ -15,7 +15,7 @@
|
|||
<UserDocu>Describes a circle in 3D space
|
||||
To create a circle there are several ways:
|
||||
Part.Circle()
|
||||
Creates a default circle with center (0,0,0) and radius 1
|
||||
Creates a default circle with center (0,0) and radius 1
|
||||
|
||||
Part.Circle(Circle)
|
||||
Creates a copy of the given circle
|
||||
|
@ -23,44 +23,18 @@ Part.Circle(Circle)
|
|||
Part.Circle(Circle, Distance)
|
||||
Creates a circle parallel to given circle at a certain distance
|
||||
|
||||
Part.Circle(Center,Normal,Radius)
|
||||
Creates a circle defined by center, normal direction and radius
|
||||
Part.Circle(Center,Radius)
|
||||
Creates a circle defined by center and radius
|
||||
|
||||
Part.Circle(Point1,Point2,Point3)
|
||||
Creates a circle defined by three non-linear points
|
||||
</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="XAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The X axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="XAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="YAxis" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The Y axis direction of the circle</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="YAxis" Type="Object"/>
|
||||
</Attribute>
|
||||
-->
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <gp_Circ.hxx>
|
||||
# include <Geom_Circle.hxx>
|
||||
# include <GC_MakeCircle.hxx>
|
||||
# include <gp_Circ2d.hxx>
|
||||
# include <Geom2d_Circle.hxx>
|
||||
# include <GCE2d_MakeCircle.hxx>
|
||||
#endif
|
||||
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
|
@ -33,7 +33,6 @@
|
|||
#include <Mod/Part/App/Geom2d/Circle2dPy.cpp>
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -42,81 +41,53 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et);
|
|||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string Circle2dPy::representation(void) const
|
||||
{
|
||||
#if 0
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
gp_Pnt loc = axis.Location();
|
||||
Standard_Real fRad = circle->Radius();
|
||||
|
||||
std::stringstream str;
|
||||
str << "Circle (";
|
||||
str << "Radius : " << fRad << ", ";
|
||||
str << "Position : (" << loc.X() << ", "<< loc.Y() << ", "<< loc.Z() << "), ";
|
||||
str << "Direction : (" << dir.X() << ", "<< dir.Y() << ", "<< dir.Z() << ")";
|
||||
str << ")";
|
||||
|
||||
return str.str();
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
return "<Circle2d object>";
|
||||
}
|
||||
|
||||
PyObject *Circle2dPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
#if 1
|
||||
return 0;
|
||||
#else
|
||||
// create a new instance of Circle2dPy and the Twin object
|
||||
Handle_Geom_Circle circle = new Geom_Circle(gp_Circ());
|
||||
return new Circle2dPy(new GeomCircle(circle));
|
||||
#endif
|
||||
return new Circle2dPy(new Geom2dCircle());
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
#if 0
|
||||
// circle and distance for offset
|
||||
PyObject *pCirc;
|
||||
double dist;
|
||||
static char* keywords_cd[] = {"Circle","Distance",NULL};
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", keywords_cd, &(Circle2dPy::Type), &pCirc, &dist)) {
|
||||
Circle2dPy* pcCircle = static_cast<Circle2dPy*>(pCirc);
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast
|
||||
(pcCircle->getGeomCirclePtr()->handle());
|
||||
GC_MakeCircle mc(circle->Circ(), dist);
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast
|
||||
(pcCircle->getGeom2dCirclePtr()->handle());
|
||||
GCE2d_MakeCircle mc(circle->Circ2d(), dist);
|
||||
if (!mc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circ = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
circ->SetCirc(mc.Value()->Circ());
|
||||
Handle_Geom2d_Circle circ = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
circ->SetCirc2d(mc.Value()->Circ2d());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// center, normal and radius
|
||||
// center and radius
|
||||
PyObject *pV1, *pV2, *pV3;
|
||||
static char* keywords_cnr[] = {"Center","Normal","Radius",NULL};
|
||||
static char* keywords_cnr[] = {"Center","Radius",NULL};
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!O!d", keywords_cnr,
|
||||
&(Base::VectorPy::Type), &pV1,
|
||||
&(Base::VectorPy::Type), &pV2,
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!d", keywords_cnr,
|
||||
Base::Vector2dPy::type_object(), &pV1,
|
||||
&dist)) {
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pV1)->value();
|
||||
Base::Vector3d v2 = static_cast<Base::VectorPy*>(pV2)->value();
|
||||
GC_MakeCircle mc(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Dir(v2.x,v2.y,v2.z),
|
||||
dist);
|
||||
Base::Vector2d v1 = Py::Vector2d(pV1).getCxxObject()->value();
|
||||
GCE2d_MakeCircle mc(gp_Pnt2d(v1.x,v1.y), dist);
|
||||
if (!mc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
circle->SetCirc(mc.Value()->Circ());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
circle->SetCirc2d(mc.Value()->Circ2d());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -124,33 +95,33 @@ int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
|
|||
PyErr_Clear();
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", keywords_c, &(Circle2dPy::Type), &pCirc)) {
|
||||
Circle2dPy* pcCircle = static_cast<Circle2dPy*>(pCirc);
|
||||
Handle_Geom_Circle circ1 = Handle_Geom_Circle::DownCast
|
||||
(pcCircle->getGeomCirclePtr()->handle());
|
||||
Handle_Geom_Circle circ2 = Handle_Geom_Circle::DownCast
|
||||
(this->getGeomCirclePtr()->handle());
|
||||
circ2->SetCirc(circ1->Circ());
|
||||
Handle_Geom2d_Circle circ1 = Handle_Geom2d_Circle::DownCast
|
||||
(pcCircle->getGeom2dCirclePtr()->handle());
|
||||
Handle_Geom2d_Circle circ2 = Handle_Geom2d_Circle::DownCast
|
||||
(this->getGeom2dCirclePtr()->handle());
|
||||
circ2->SetCirc2d(circ1->Circ2d());
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char* keywords_ppp[] = {"Point1","Point2","Point3",NULL};
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!O!O!", keywords_ppp,
|
||||
&(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_MakeCircle mc(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Pnt(v2.x,v2.y,v2.z),
|
||||
gp_Pnt(v3.x,v3.y,v3.z));
|
||||
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();
|
||||
GCE2d_MakeCircle mc(gp_Pnt2d(v1.x,v1.y),
|
||||
gp_Pnt2d(v2.x,v2.y),
|
||||
gp_Pnt2d(v3.x,v3.y));
|
||||
if (!mc.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(mc.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
circle->SetCirc(mc.Value()->Circ());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
circle->SetCirc2d(mc.Value()->Circ2d());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -158,7 +129,7 @@ int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
|
|||
static char* keywords_n[] = {NULL};
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "", keywords_n)) {
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
circle->SetRadius(1.0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -167,156 +138,23 @@ int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
|
|||
"-- empty parameter list\n"
|
||||
"-- Circle\n"
|
||||
"-- Circle, Distance\n"
|
||||
"-- Center, Normal, Radius\n"
|
||||
"-- Center, Radius\n"
|
||||
"-- Point1, Point2, Point3");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
|
||||
Py::Float Circle2dPy::getRadius(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
return Py::Float(circle->Radius());
|
||||
}
|
||||
|
||||
void Circle2dPy::setRadius(Py::Float arg)
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
Handle_Geom2d_Circle circle = Handle_Geom2d_Circle::DownCast(getGeom2dCirclePtr()->handle());
|
||||
circle->SetRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Object Circle2dPy::getCenter(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Pnt loc = circle->Location();
|
||||
return Py::Vector(Base::Vector3d(loc.X(), loc.Y(), loc.Z()));
|
||||
}
|
||||
|
||||
void Circle2dPy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomCirclePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomCirclePtr()->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 Circle2dPy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void Circle2dPy::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_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object Circle2dPy::getXAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->XAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void Circle2dPy::setXAxis(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_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = circle->Position();
|
||||
pos.SetXDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set X axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object Circle2dPy::getYAxis(void) const
|
||||
{
|
||||
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
gp_Ax1 axis = circle->YAxis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void Circle2dPy::setYAxis(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_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||
try {
|
||||
gp_Ax2 pos;
|
||||
pos = circle->Position();
|
||||
pos.SetYDirection(gp_Dir(val.x, val.y, val.z));
|
||||
circle->SetPosition(pos);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set Y axis");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
PyObject *Circle2dPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -15,11 +15,23 @@
|
|||
<UserDocu>Describes an abstract conic in 2d space
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Attribute Name="Center" ReadOnly="false">
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Center of the conic.</UserDocu>
|
||||
<UserDocu>Location of the conic.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Center" Type="Object"/>
|
||||
<Parameter Name="Location" Type="Object"/>
|
||||
</Attribute>
|
||||
<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>
|
||||
|
|
|
@ -54,9 +54,9 @@ int Conic2dPy::PyInit(PyObject* args, PyObject* kwds)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Py::Object Conic2dPy::getCenter(void) const
|
||||
Py::Object Conic2dPy::getLocation(void) const
|
||||
{
|
||||
Base::Vector2d loc = getGeom2dConicPtr()->getCenter();
|
||||
Base::Vector2d loc = getGeom2dConicPtr()->getLocation();
|
||||
|
||||
Py::Module module("__FreeCADBase__");
|
||||
Py::Callable method(module.getAttr("Vector2d"));
|
||||
|
@ -66,10 +66,16 @@ Py::Object Conic2dPy::getCenter(void) const
|
|||
return method.apply(arg);
|
||||
}
|
||||
|
||||
void Conic2dPy::setCenter(Py::Object arg)
|
||||
void Conic2dPy::setLocation(Py::Object arg)
|
||||
{
|
||||
Base::Vector2d loc = Py::Vector2d(arg.ptr()).getCxxObject()->value();
|
||||
getGeom2dConicPtr()->setCenter(loc);
|
||||
getGeom2dConicPtr()->setLocation(loc);
|
||||
}
|
||||
|
||||
Py::Float Conic2dPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(getGeom2dConicPtr()->handle());
|
||||
return Py::Float(conic->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Object Conic2dPy::getXAxis(void) const
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
The abstract class GeometryCurve is the root class of all curve objects.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="reverse">
|
||||
<Documentation>
|
||||
<UserDocu>Changes the direction of parametrization of the curve.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<!--
|
||||
<Methode Name="toShape" Const="true">
|
||||
<Documentation>
|
||||
|
@ -70,11 +75,13 @@ length([uMin,uMax,Tol]) -> Float</UserDocu>
|
|||
parameterAtDistance([abscissa, startingParameter]) -> Float the</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
-->
|
||||
<Methode Name="value">
|
||||
<Documentation>
|
||||
<UserDocu>Computes the point of parameter u on this curve</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<!--
|
||||
<Methode Name="tangent">
|
||||
<Documentation>
|
||||
<UserDocu>Computes the tangent of parameter u on this curve</UserDocu>
|
||||
|
@ -131,6 +138,7 @@ of the nearest orthogonal projection of the point.</UserDocu>
|
|||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
-->
|
||||
<Attribute Name="Continuity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
|
@ -139,6 +147,22 @@ of the nearest orthogonal projection of the point.</UserDocu>
|
|||
</Documentation>
|
||||
<Parameter Name="Continuity" Type="String"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Closed" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Returns true if the curve is closed.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Closed" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Periodic" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Returns true if the curve is periodic.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Periodic" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FirstParameter" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
|
@ -155,6 +179,5 @@ of the nearest orthogonal projection of the point.</UserDocu>
|
|||
</Documentation>
|
||||
<Parameter Name="LastParameter" Type="Float"/>
|
||||
</Attribute>
|
||||
-->
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -14,12 +14,6 @@
|
|||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
<UserDocu>Describes a parabola in 2D space</UserDocu>
|
||||
</Documentation>
|
||||
<Attribute Name="Eccentricity" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Returns 1. (which is the eccentricity of any parabola).</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Eccentricity" Type="Float"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Focal" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The focal distance is the distance between
|
||||
|
|
|
@ -61,12 +61,6 @@ int Parabola2dPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
return -1;
|
||||
}
|
||||
|
||||
Py::Float Parabola2dPy::getEccentricity(void) const
|
||||
{
|
||||
Handle_Geom2d_Parabola curve = Handle_Geom2d_Parabola::DownCast(getGeometry2dPtr()->handle());
|
||||
return Py::Float(curve->Eccentricity());
|
||||
}
|
||||
|
||||
Py::Float Parabola2dPy::getFocal(void) const
|
||||
{
|
||||
Handle_Geom2d_Parabola curve = Handle_Geom2d_Parabola::DownCast(getGeometry2dPtr()->handle());
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include <Base/Tools.h>
|
||||
|
||||
#include "Geometry2d.h"
|
||||
#include <Mod/Part/App/Geom2d/Parabola2dPy.h>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -587,14 +588,14 @@ Geom2dConic::~Geom2dConic()
|
|||
{
|
||||
}
|
||||
|
||||
Base::Vector2d Geom2dConic::getCenter(void) const
|
||||
Base::Vector2d Geom2dConic::getLocation(void) const
|
||||
{
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(handle());
|
||||
const gp_Pnt2d& loc = conic->Location();
|
||||
return Base::Vector2d(loc.X(),loc.Y());
|
||||
}
|
||||
|
||||
void Geom2dConic::setCenter(const Base::Vector2d& Center)
|
||||
void Geom2dConic::setLocation(const Base::Vector2d& Center)
|
||||
{
|
||||
gp_Pnt2d p1(Center.x,Center.y);
|
||||
Handle_Geom2d_Conic conic = Handle_Geom2d_Conic::DownCast(handle());
|
||||
|
@ -1742,8 +1743,7 @@ void Geom2dParabola::Restore(Base::XMLReader& reader)
|
|||
|
||||
PyObject *Geom2dParabola::getPyObject(void)
|
||||
{
|
||||
return 0;
|
||||
//return new ParabolaPy((GeomParabola*)this->clone());
|
||||
return new Parabola2dPy(static_cast<Geom2dParabola*>(this->clone()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
|
|
@ -200,8 +200,8 @@ public:
|
|||
virtual ~Geom2dConic();
|
||||
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;
|
||||
|
||||
virtual unsigned int getMemSize(void) const = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user