Part: [skip ci] harmonizing the way to add sub-modules to Part module
This commit is contained in:
@@ -376,34 +376,13 @@ PyMOD_INIT_FUNC(Part)
|
||||
Base::Interpreter().addType(&Part::GeometryBoolExtensionPy ::Type,partModule,"GeometryBoolExtension");
|
||||
Base::Interpreter().addType(&Part::GeometryDoubleExtensionPy ::Type,partModule,"GeometryDoubleExtension");
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
static struct PyModuleDef BRepOffsetAPIDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"BRepOffsetAPI", "BRepOffsetAPI", -1, 0,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
PyObject* brepModule = PyModule_Create(&BRepOffsetAPIDef);
|
||||
#else
|
||||
PyObject* brepModule = Py_InitModule3("BRepOffsetAPI", 0, "BrepOffsetAPI");
|
||||
#endif
|
||||
Py_INCREF(brepModule);
|
||||
PyModule_AddObject(partModule, "BRepOffsetAPI", brepModule);
|
||||
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepModule,"MakePipeShell");
|
||||
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakeFillingPy::Type,brepModule,"MakeFilling");
|
||||
// BRepOffsetAPI package
|
||||
PyObject* brepOffsetApiModule(module.getAttr("BRepOffsetAPI").ptr());
|
||||
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepOffsetApiModule,"MakePipeShell");
|
||||
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakeFillingPy::Type,brepOffsetApiModule,"MakeFilling");
|
||||
|
||||
// Geom2d package
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
static struct PyModuleDef geom2dDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"Geom2dD", "Geom2d", -1, 0,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
PyObject* geom2dModule = PyModule_Create(&geom2dDef);
|
||||
#else
|
||||
PyObject* geom2dModule = Py_InitModule3("Geom2d", 0, "Geom2d");
|
||||
#endif
|
||||
Py_INCREF(geom2dModule);
|
||||
PyModule_AddObject(partModule, "Geom2d", geom2dModule);
|
||||
PyObject* geom2dModule(module.getAttr("Geom2d").ptr());
|
||||
Base::Interpreter().addType(&Part::Geometry2dPy::Type,geom2dModule,"Geometry2d");
|
||||
Base::Interpreter().addType(&Part::Curve2dPy::Type,geom2dModule,"Curve2d");
|
||||
Base::Interpreter().addType(&Part::Conic2dPy::Type,geom2dModule,"Conic2d");
|
||||
|
||||
@@ -271,6 +271,28 @@ PartExport std::list<TopoDS_Edge> sort_Edges(double tol3d, std::list<TopoDS_Edge
|
||||
}
|
||||
|
||||
namespace Part {
|
||||
class BRepOffsetAPIModule : public Py::ExtensionModule<BRepOffsetAPIModule>
|
||||
{
|
||||
public:
|
||||
BRepOffsetAPIModule() : Py::ExtensionModule<BRepOffsetAPIModule>("BRepOffsetAPI")
|
||||
{
|
||||
initialize("This is a module working with the BRepOffsetAPI package."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~BRepOffsetAPIModule() {}
|
||||
};
|
||||
|
||||
class Geom2dModule : public Py::ExtensionModule<Geom2dModule>
|
||||
{
|
||||
public:
|
||||
Geom2dModule() : Py::ExtensionModule<Geom2dModule>("Geom2d")
|
||||
{
|
||||
initialize("This is a module working with 2d geometries."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Geom2dModule() {}
|
||||
};
|
||||
|
||||
class GeomPlateModule : public Py::ExtensionModule<GeomPlateModule>
|
||||
{
|
||||
public:
|
||||
@@ -295,6 +317,8 @@ public:
|
||||
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
BRepOffsetAPIModule brepOffsetApi;
|
||||
Geom2dModule geom2d;
|
||||
GeomPlateModule geomPlate;
|
||||
ShapeUpgradeModule shapeUpgrade;
|
||||
public:
|
||||
@@ -513,6 +537,8 @@ public:
|
||||
);
|
||||
initialize("This is a module working with shapes."); // register with Python
|
||||
|
||||
PyModule_AddObject(m_module, "BRepOffsetAPI", brepOffsetApi.module().ptr());
|
||||
PyModule_AddObject(m_module, "Geom2d", geom2d.module().ptr());
|
||||
PyModule_AddObject(m_module, "GeomPlate", geomPlate.module().ptr());
|
||||
PyModule_AddObject(m_module, "ShapeUpgrade", shapeUpgrade.module().ptr());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user