implement Line class
This commit is contained in:
parent
1855c80f36
commit
c6529d21fe
|
@ -133,6 +133,89 @@ PyObject* Part::PartExceptionOCCRangeError;
|
|||
PyObject* Part::PartExceptionOCCConstructionError;
|
||||
PyObject* Part::PartExceptionOCCDimensionError;
|
||||
|
||||
// <---
|
||||
namespace Part {
|
||||
|
||||
// Compatibility class to keep old code working until removed
|
||||
class LinePyOld : public LineSegmentPy
|
||||
{
|
||||
public:
|
||||
static PyTypeObject Type;
|
||||
virtual PyTypeObject *GetType(void) {return &Type;}
|
||||
|
||||
public:
|
||||
static PyObject *PyMake(struct _typeobject *, PyObject *, PyObject *)
|
||||
{
|
||||
PyErr_SetString(PyExc_DeprecationWarning, "For future usage 'Line' will be an infinite line, use 'LineSegment' instead");
|
||||
PyErr_Print();
|
||||
return new LinePyOld(new GeomLineSegment);
|
||||
}
|
||||
LinePyOld(GeomLineSegment *pcObject, PyTypeObject *T = &Type)
|
||||
: LineSegmentPy(pcObject, T)
|
||||
{
|
||||
}
|
||||
virtual ~LinePyOld()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/// Type structure of LinePyOld
|
||||
PyTypeObject LinePyOld::Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
"Part.GeomLine", /*tp_name*/
|
||||
sizeof(LinePyOld), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
PyDestructor, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash*/
|
||||
0, /*tp_call */
|
||||
0, /*tp_str */
|
||||
0, /*tp_getattro*/
|
||||
0, /*tp_setattro*/
|
||||
/* --- Functions to access object as input/output buffer ---------*/
|
||||
0, /* tp_as_buffer */
|
||||
/* --- Flags to define presence of optional/expanded features */
|
||||
Py_TPFLAGS_HAVE_CLASS, /*tp_flags */
|
||||
"",
|
||||
0, /*tp_traverse */
|
||||
0, /*tp_clear */
|
||||
0, /*tp_richcompare */
|
||||
0, /*tp_weaklistoffset */
|
||||
0, /*tp_iter */
|
||||
0, /*tp_iternext */
|
||||
0, /*tp_methods */
|
||||
0, /*tp_members */
|
||||
0, /*tp_getset */
|
||||
&LineSegmentPy::Type, /*tp_base */
|
||||
0, /*tp_dict */
|
||||
0, /*tp_descr_get */
|
||||
0, /*tp_descr_set */
|
||||
0, /*tp_dictoffset */
|
||||
__PyInit, /*tp_init */
|
||||
0, /*tp_alloc */
|
||||
Part::LinePyOld::PyMake,/*tp_new */
|
||||
0, /*tp_free Low-level free-memory routine */
|
||||
0, /*tp_is_gc For PyObject_IS_GC */
|
||||
0, /*tp_bases */
|
||||
0, /*tp_mro method resolution order */
|
||||
0, /*tp_cache */
|
||||
0, /*tp_subclasses */
|
||||
0, /*tp_weaklist */
|
||||
0, /*tp_del */
|
||||
0 /*tp_version_tag */
|
||||
};
|
||||
|
||||
}
|
||||
// --->
|
||||
|
||||
PyMODINIT_FUNC initPart()
|
||||
{
|
||||
|
@ -207,7 +290,18 @@ PyMODINIT_FUNC initPart()
|
|||
Base::Interpreter().addType(&Part::TopoShapeCompSolidPy ::Type,partModule,"CompSolid");
|
||||
Base::Interpreter().addType(&Part::TopoShapeShellPy ::Type,partModule,"Shell");
|
||||
|
||||
Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"Line");
|
||||
Base::Reference<ParameterGrp> hPartGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
|
||||
|
||||
// General
|
||||
Base::Reference<ParameterGrp> hGenPGrp = hPartGrp->GetGroup("General");
|
||||
if (hGenPGrp->GetBool("LineOld", true)) {
|
||||
Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"_Line");
|
||||
Base::Interpreter().addType(&Part::LinePyOld ::Type,partModule,"Line");
|
||||
}
|
||||
else {
|
||||
Base::Interpreter().addType(&Part::LinePy ::Type,partModule,"Line");
|
||||
}
|
||||
Base::Interpreter().addType(&Part::LineSegmentPy ::Type,partModule,"LineSegment");
|
||||
Base::Interpreter().addType(&Part::PointPy ::Type,partModule,"Point");
|
||||
Base::Interpreter().addType(&Part::CirclePy ::Type,partModule,"Circle");
|
||||
|
|
|
@ -181,12 +181,10 @@ PyObject* ConePy::uIso(PyObject * args)
|
|||
Handle_Geom_ConicalSurface cone = Handle_Geom_ConicalSurface::DownCast
|
||||
(getGeomConePtr()->handle());
|
||||
Handle_Geom_Line c = Handle_Geom_Line::DownCast(cone->UIso(u));
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(c->Lin());
|
||||
this_curv->SetLin(c->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
|
|
@ -168,12 +168,10 @@ PyObject* CylinderPy::uIso(PyObject * args)
|
|||
(getGeomCylinderPtr()->handle());
|
||||
Handle_Geom_Curve c = cyl->UIso(v);
|
||||
if (!Handle_Geom_Line::DownCast(c).IsNull()) {
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(Handle_Geom_Line::DownCast(c)->Lin());
|
||||
this_curv->SetLin(Handle_Geom_Line::DownCast(c)->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
|
||||
|
|
|
@ -281,12 +281,10 @@ PyObject* GeometrySurfacePy::uIso(PyObject * args)
|
|||
Handle_Geom_Curve c = surf->UIso(v);
|
||||
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(aLine->Lin());
|
||||
this_curv->SetLin(aLine->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
else {
|
||||
|
@ -312,12 +310,10 @@ PyObject* GeometrySurfacePy::vIso(PyObject * args)
|
|||
Handle_Geom_Curve c = surf->VIso(v);
|
||||
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(aLine->Lin());
|
||||
this_curv->SetLin(aLine->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<PythonExport
|
||||
Father="GeometryCurvePy"
|
||||
Name="LinePy"
|
||||
Twin="GeomLineSegment"
|
||||
TwinPointer="GeomLineSegment"
|
||||
Twin="GeomLine"
|
||||
TwinPointer="GeomLine"
|
||||
Include="Mod/Part/App/Geometry.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/GeometryCurvePy.h"
|
||||
|
@ -23,33 +23,17 @@ Part.Line(Line)
|
|||
Part.Line(Point1,Point2)
|
||||
Creates a line that goes through two given points</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="setParameterRange">
|
||||
<Attribute Name="Location" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Set the parameter range of the underlying line geometry</UserDocu>
|
||||
<UserDocu>Returns the location of this line.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="StartPoint" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the start point of this line.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="StartPoint" Type="Object"/>
|
||||
<Parameter Name="Location" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="EndPoint" ReadOnly="false">
|
||||
<Attribute Name="Direction" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the end point point of this line.</UserDocu>
|
||||
<UserDocu>Returns the direction of this line.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="EndPoint" Type="Object"/>
|
||||
<Parameter Name="Direction" Type="Object"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Infinite" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Defines the line as infinite. The StartPoint and EndPoint will be ignored as boundaries.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Infinite" Type="Boolean"/>
|
||||
</Attribute>
|
||||
<ClassDeclarations>
|
||||
public:
|
||||
bool Infinite;
|
||||
</ClassDeclarations>
|
||||
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
# include <gp.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
# include <Geom_Line.hxx>
|
||||
# include <Geom_TrimmedCurve.hxx>
|
||||
# include <GC_MakeLine.hxx>
|
||||
# include <GC_MakeSegment.hxx>
|
||||
# include <Precision.hxx>
|
||||
#endif
|
||||
|
||||
|
@ -37,8 +35,8 @@
|
|||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "LinePy.h"
|
||||
#include "LinePy.cpp"
|
||||
#include <Mod/Part/App/LinePy.h>
|
||||
#include <Mod/Part/App/LinePy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -47,24 +45,13 @@ extern const char* gce_ErrorStatusText(gce_ErrorType et);
|
|||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string LinePy::representation(void) const
|
||||
{
|
||||
std::stringstream str;
|
||||
//if(Infinite)
|
||||
// str << "<Line infinite>";
|
||||
//else {
|
||||
Base::Vector3d start = getGeomLineSegmentPtr()->getStartPoint();
|
||||
Base::Vector3d end = getGeomLineSegmentPtr()->getEndPoint();
|
||||
str << "<Line ("
|
||||
<< start.x << "," <<start.y << "," <<start.z << ") ("
|
||||
<< end.x << "," <<end.y << "," <<end.z << ") >";
|
||||
//}
|
||||
|
||||
return str.str();
|
||||
return "<Line object>";
|
||||
}
|
||||
|
||||
PyObject *LinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of LinePy and the Twin object
|
||||
return new LinePy(new GeomLineSegment);
|
||||
return new LinePy(new GeomLine);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
|
@ -73,7 +60,6 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
// default line
|
||||
Infinite=false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -82,46 +68,15 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
if (PyArg_ParseTuple(args, "O!", &(LinePy::Type), &pLine)) {
|
||||
// Copy line
|
||||
LinePy* pcLine = static_cast<LinePy*>(pLine);
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_TrimmedCurve that_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(pcLine->getGeomLineSegmentPtr()->handle());
|
||||
// get Geom_Line of line
|
||||
Handle_Geom_Line that_line = Handle_Geom_Line::DownCast
|
||||
(that_curv->BasisCurve());
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
(pcLine->getGeomLinePtr()->handle());
|
||||
// get Geom_Line of line
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
|
||||
Infinite = pcLine->Infinite;
|
||||
(this->getGeomLinePtr()->handle());
|
||||
|
||||
// Assign the lines
|
||||
this_line->SetLin(that_line->Lin());
|
||||
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
double first, last;
|
||||
if (PyArg_ParseTuple(args, "O!dd", &(LinePy::Type), &pLine, &first, &last)) {
|
||||
// Copy line
|
||||
LinePy* pcLine = static_cast<LinePy*>(pLine);
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_TrimmedCurve that_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(pcLine->getGeomLineSegmentPtr()->handle());
|
||||
Handle_Geom_Line that_line = Handle_Geom_Line::DownCast
|
||||
(that_curv->BasisCurve());
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
|
||||
Infinite = pcLine->Infinite;
|
||||
|
||||
// Assign the lines
|
||||
this_line->SetLin(that_line->Lin());
|
||||
this_curv->SetTrim(first, last);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -136,24 +91,18 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
double distance = Base::Distance(v1, v2);
|
||||
if (distance < gp::Resolution())
|
||||
Standard_Failure::Raise("Both points are equal");
|
||||
GC_MakeSegment ms(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Pnt(v2.x,v2.y,v2.z));
|
||||
GC_MakeLine ms(gp_Pnt(v1.x,v1.y,v1.z),
|
||||
gp_Pnt(v2.x,v2.y,v2.z));
|
||||
if (!ms.IsDone()) {
|
||||
PyErr_SetString(PartExceptionOCCError, gce_ErrorStatusText(ms.Status()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
Handle_Geom_TrimmedCurve that_curv = ms.Value();
|
||||
Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve());
|
||||
this_line->SetLin(that_line->Lin());
|
||||
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
|
||||
|
||||
Infinite = false;
|
||||
// get Geom_Line of line
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(this->getGeomLinePtr()->handle());
|
||||
Handle_Geom_Line that_curv = ms.Value();
|
||||
this_curv->SetLin(that_curv->Lin());
|
||||
return 0;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
@ -174,53 +123,34 @@ int LinePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
|||
return -1;
|
||||
}
|
||||
|
||||
PyObject* LinePy::setParameterRange(PyObject *args)
|
||||
Py::Object LinePy::getLocation(void) const
|
||||
{
|
||||
double first, last;
|
||||
if (!PyArg_ParseTuple(args, "dd", &first, &last))
|
||||
return NULL;
|
||||
|
||||
try {
|
||||
Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
this_curve->SetTrim(first, last);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
Py::Object LinePy::getStartPoint(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
gp_Pnt pnt = this_curve->StartPoint();
|
||||
Handle_Geom_Line this_curve = Handle_Geom_Line::DownCast
|
||||
(this->getGeomLinePtr()->handle());
|
||||
gp_Pnt pnt = this_curve->Position().Location();
|
||||
return Py::Vector(Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z()));
|
||||
}
|
||||
|
||||
void LinePy::setStartPoint(Py::Object arg)
|
||||
void LinePy::setLocation(Py::Object arg)
|
||||
{
|
||||
gp_Pnt p1, p2;
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
p2 = this_curv->EndPoint();
|
||||
gp_Pnt pnt;
|
||||
gp_Dir dir;
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(this->getGeomLinePtr()->handle());
|
||||
dir = this_curv->Position().Direction();
|
||||
|
||||
PyObject *p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d v = static_cast<Base::VectorPy*>(p)->value();
|
||||
p1.SetX(v.x);
|
||||
p1.SetY(v.y);
|
||||
p1.SetZ(v.z);
|
||||
pnt.SetX(v.x);
|
||||
pnt.SetY(v.y);
|
||||
pnt.SetZ(v.z);
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
p1.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
p1.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
p1.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
pnt.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
pnt.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
pnt.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector' or tuple, not ");
|
||||
|
@ -229,21 +159,14 @@ void LinePy::setStartPoint(Py::Object arg)
|
|||
}
|
||||
|
||||
try {
|
||||
// Create line out of two points
|
||||
if (p1.Distance(p2) < gp::Resolution())
|
||||
Standard_Failure::Raise("Both points are equal");
|
||||
GC_MakeSegment ms(p1, p2);
|
||||
GC_MakeLine ms(pnt, dir);
|
||||
if (!ms.IsDone()) {
|
||||
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
|
||||
}
|
||||
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
Handle_Geom_TrimmedCurve that_curv = ms.Value();
|
||||
Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve());
|
||||
this_line->SetLin(that_line->Lin());
|
||||
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
|
||||
// get Geom_Line of line
|
||||
Handle_Geom_Line that_curv = ms.Value();
|
||||
this_curv->SetLin(that_curv->Lin());
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
@ -251,33 +174,33 @@ void LinePy::setStartPoint(Py::Object arg)
|
|||
}
|
||||
}
|
||||
|
||||
Py::Object LinePy::getEndPoint(void) const
|
||||
Py::Object LinePy::getDirection(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
gp_Pnt pnt = this_curve->EndPoint();
|
||||
return Py::Vector(Base::Vector3d(pnt.X(), pnt.Y(), pnt.Z()));
|
||||
Handle_Geom_Line this_curve = Handle_Geom_Line::DownCast
|
||||
(this->getGeomLinePtr()->handle());
|
||||
gp_Dir dir = this_curve->Position().Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void LinePy::setEndPoint(Py::Object arg)
|
||||
void LinePy::setDirection(Py::Object arg)
|
||||
{
|
||||
gp_Pnt p1, p2;
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(this->getGeomLineSegmentPtr()->handle());
|
||||
p1 = this_curv->StartPoint();
|
||||
gp_Pnt pnt;
|
||||
gp_Dir dir;
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(this->getGeomLinePtr()->handle());
|
||||
pnt = this_curv->Position().Location();
|
||||
|
||||
PyObject *p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d v = static_cast<Base::VectorPy*>(p)->value();
|
||||
p2.SetX(v.x);
|
||||
p2.SetY(v.y);
|
||||
p2.SetZ(v.z);
|
||||
dir = gp_Dir(v.x,v.y,v.z);
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
Py::Tuple tuple(arg);
|
||||
p2.SetX((double)Py::Float(tuple.getItem(0)));
|
||||
p2.SetY((double)Py::Float(tuple.getItem(1)));
|
||||
p2.SetZ((double)Py::Float(tuple.getItem(2)));
|
||||
double x = (double)Py::Float(tuple.getItem(0));
|
||||
double y = (double)Py::Float(tuple.getItem(1));
|
||||
double z = (double)Py::Float(tuple.getItem(2));
|
||||
dir = gp_Dir(x,y,z);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector' or tuple, not ");
|
||||
|
@ -286,21 +209,14 @@ void LinePy::setEndPoint(Py::Object arg)
|
|||
}
|
||||
|
||||
try {
|
||||
// Create line out of two points
|
||||
if (p1.Distance(p2) < gp::Resolution())
|
||||
Standard_Failure::Raise("Both points are equal");
|
||||
GC_MakeSegment ms(p1, p2);
|
||||
GC_MakeLine ms(pnt, dir);
|
||||
if (!ms.IsDone()) {
|
||||
throw Py::Exception(gce_ErrorStatusText(ms.Status()));
|
||||
}
|
||||
|
||||
// get Geom_Line of line segment
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
Handle_Geom_TrimmedCurve that_curv = ms.Value();
|
||||
Handle_Geom_Line that_line = Handle_Geom_Line::DownCast(that_curv->BasisCurve());
|
||||
this_line->SetLin(that_line->Lin());
|
||||
this_curv->SetTrim(that_curv->FirstParameter(), that_curv->LastParameter());
|
||||
// get Geom_Line of line
|
||||
Handle_Geom_Line that_curv = ms.Value();
|
||||
this_curv->SetLin(that_curv->Lin());
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
@ -308,17 +224,6 @@ void LinePy::setEndPoint(Py::Object arg)
|
|||
}
|
||||
}
|
||||
|
||||
Py::Boolean LinePy::getInfinite(void) const
|
||||
{
|
||||
return Py::Boolean(Infinite);
|
||||
}
|
||||
|
||||
void LinePy::setInfinite(Py::Boolean arg)
|
||||
{
|
||||
Infinite = arg;
|
||||
}
|
||||
|
||||
|
||||
PyObject *LinePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
|
||||
#include "OCCError.h"
|
||||
#include "Geometry.h"
|
||||
#include "LinePy.h"
|
||||
#include "PlanePy.h"
|
||||
#include "PlanePy.cpp"
|
||||
#include <Mod/Part/App/LinePy.h>
|
||||
#include <Mod/Part/App/PlanePy.h>
|
||||
#include <Mod/Part/App/PlanePy.cpp>
|
||||
|
||||
using namespace Part;
|
||||
|
||||
|
@ -266,12 +266,10 @@ PyObject* PlanePy::uIso(PyObject * args)
|
|||
Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast
|
||||
(getGeomPlanePtr()->handle());
|
||||
Handle_Geom_Line c = Handle_Geom_Line::DownCast(plane->UIso(u));
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(c->Lin());
|
||||
this_curv->SetLin(c->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
@ -291,12 +289,10 @@ PyObject* PlanePy::vIso(PyObject * args)
|
|||
Handle_Geom_Plane plane = Handle_Geom_Plane::DownCast
|
||||
(getGeomPlanePtr()->handle());
|
||||
Handle_Geom_Line c = Handle_Geom_Line::DownCast(plane->VIso(v));
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(c->Lin());
|
||||
this_curv->SetLin(c->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
|
|
@ -169,11 +169,9 @@ PyObject* SurfaceOfExtrusionPy::uIso(PyObject * args)
|
|||
}
|
||||
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
(line->handle());
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
(line->handle());
|
||||
this_line->SetLin(aLine->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
|
@ -212,12 +210,10 @@ PyObject* SurfaceOfExtrusionPy::vIso(PyObject * args)
|
|||
}
|
||||
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
|
||||
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(aLine->Lin());
|
||||
this_curv->SetLin(aLine->Lin());
|
||||
return new LinePy(line);
|
||||
}
|
||||
PyErr_Format(PyExc_NotImplementedError, "Iso curve is of type '%s'",
|
||||
|
|
|
@ -104,7 +104,7 @@ std::string TopoShapeEdgePy::representation(void) const
|
|||
|
||||
PyObject *TopoShapeEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of TopoShapeEdgePy and the Twin object
|
||||
// create a new instance of TopoShapeEdgePy and the Twin object
|
||||
return new TopoShapeEdgePy(new TopoShape);
|
||||
}
|
||||
|
||||
|
@ -691,13 +691,10 @@ Py::Object TopoShapeEdgePy::getCurve() const
|
|||
{
|
||||
case GeomAbs_Line:
|
||||
{
|
||||
GeomLineSegment* line = new GeomLineSegment();
|
||||
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
|
||||
GeomLine* line = new GeomLine();
|
||||
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
|
||||
(line->handle());
|
||||
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
|
||||
(this_curv->BasisCurve());
|
||||
this_line->SetLin(adapt.Line());
|
||||
this_curv->SetTrim(adapt.FirstParameter(), adapt.LastParameter());
|
||||
this_curv->SetLin(adapt.Line());
|
||||
return Py::Object(new LinePy(line),true);
|
||||
}
|
||||
case GeomAbs_Circle:
|
||||
|
@ -892,5 +889,5 @@ PyObject *TopoShapeEdgePy::getCustomAttributes(const char* /*attr*/) const
|
|||
|
||||
int TopoShapeEdgePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <Mod/Part/App/EllipsePy.h>
|
||||
#include <Mod/Part/App/HyperbolaPy.h>
|
||||
#include <Mod/Part/App/ArcOfHyperbolaPy.h>
|
||||
#include <Mod/Part/App/LinePy.h>
|
||||
#include <Mod/Part/App/LineSegmentPy.h>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
@ -684,7 +684,7 @@ Py::Tuple Sketch::getPyGeometry(void) const
|
|||
tuple[i] = Py::asObject(new VectorPy(temp));
|
||||
} else if (it->type == Line) {
|
||||
GeomLineSegment *lineSeg = static_cast<GeomLineSegment*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new LinePy(lineSeg));
|
||||
tuple[i] = Py::asObject(new LineSegmentPy(lineSeg));
|
||||
} else if (it->type == Arc) {
|
||||
GeomArcOfCircle *aoc = static_cast<GeomArcOfCircle*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new ArcOfCirclePy(aoc));
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/GeometryCurvePy.h>
|
||||
#include <Mod/Part/App/LinePy.h>
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user