2016-12-09 20:34:22 +05:00
|
|
|
|
|
|
|
#ifdef NG_PYTHON
|
|
|
|
|
|
|
|
#include <../general/ngpython.hpp>
|
|
|
|
#include <stlgeom.hpp>
|
|
|
|
|
2016-12-12 18:22:24 +05:00
|
|
|
#ifdef WIN32
|
|
|
|
#define DLL_HEADER __declspec(dllexport)
|
|
|
|
#endif
|
|
|
|
|
2016-12-09 20:34:22 +05:00
|
|
|
using namespace netgen;
|
|
|
|
namespace netgen
|
|
|
|
{
|
2016-12-12 17:14:47 +05:00
|
|
|
//extern shared_ptr<Mesh> mesh;
|
2016-12-09 20:34:22 +05:00
|
|
|
extern shared_ptr<NetgenGeometry> ng_geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DLL_HEADER void ExportSTL(py::module & m)
|
|
|
|
{
|
|
|
|
py::class_<STLGeometry,shared_ptr<STLGeometry>> (m,"STLGeometry")
|
|
|
|
.def(py::init<>())
|
|
|
|
;
|
2016-12-12 17:14:47 +05:00
|
|
|
m.def("LoadSTLGeometry", FunctionPointer([] (const string & filename)
|
|
|
|
{
|
|
|
|
ifstream ist(filename);
|
|
|
|
return shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
|
|
|
}));
|
2016-12-09 20:34:22 +05:00
|
|
|
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> 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;
|
|
|
|
}))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2017-09-01 12:33:57 +05:00
|
|
|
PYBIND11_MODULE(libstl, m) {
|
2016-12-09 20:34:22 +05:00
|
|
|
ExportSTL(m);
|
|
|
|
}
|
2016-12-12 17:14:47 +05:00
|
|
|
|
2016-12-09 20:34:22 +05:00
|
|
|
#endif
|