mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-27 06:10:34 +05:00
1430b89e39
- Replace PYBIND11_PLUGIN with PYBIND11_MODULE - Fix warnings about symbol visibility by replacing 'namespace pybind11' with 'namespace PYBIND11_NAMESPACE' - Pybind sets the default visibility of its namespace to 'hidden' Thus, our export functions like ExportCSG(py::module &m) also are hidden by default. To work around that define DLL_HEADER '__attribute__ ((visibility ("default"))) on GNUC platforms.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#ifdef NG_PYTHON
|
|
#ifdef OCCGEOMETRY
|
|
|
|
#include <../general/ngpython.hpp>
|
|
|
|
#include <meshing.hpp>
|
|
#include <occgeom.hpp>
|
|
|
|
using namespace netgen;
|
|
|
|
namespace netgen
|
|
{
|
|
extern std::shared_ptr<NetgenGeometry> ng_geometry;
|
|
}
|
|
|
|
|
|
DLL_HEADER void ExportNgOCC(py::module &m)
|
|
{
|
|
py::class_<OCCGeometry, shared_ptr<OCCGeometry>> (m, "OCCGeometry")
|
|
.def(py::init<>())
|
|
;
|
|
m.def("LoadOCCGeometry",FunctionPointer([] (const string & filename)
|
|
{
|
|
cout << "load OCC geometry";
|
|
ifstream ist(filename);
|
|
OCCGeometry * instance = new OCCGeometry();
|
|
instance = LoadOCC_STEP(filename.c_str());
|
|
return shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
|
}));
|
|
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<OCCGeometry> geo, MeshingParameters ¶m)
|
|
{
|
|
auto mesh = make_shared<Mesh>();
|
|
SetGlobalMesh(mesh);
|
|
mesh->SetGeometry(geo);
|
|
ng_geometry = geo;
|
|
try
|
|
{
|
|
geo->GenerateMesh(mesh,param);
|
|
}
|
|
catch (NgException ex)
|
|
{
|
|
cout << "Caught NgException: " << ex.What() << endl;
|
|
}
|
|
return mesh;
|
|
}))
|
|
;
|
|
}
|
|
|
|
PYBIND11_MODULE(libNgOCC, m) {
|
|
ExportNgOCC(m);
|
|
}
|
|
|
|
#endif // OCCGEOMETRY
|
|
#endif // NG_PYTHON
|