implement Line class
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user