mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
load stl fix and some vis
This commit is contained in:
parent
25d2e497b1
commit
a5e411d008
@ -7,6 +7,7 @@
|
|||||||
using namespace netgen;
|
using namespace netgen;
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
//extern shared_ptr<Mesh> mesh;
|
||||||
extern shared_ptr<NetgenGeometry> ng_geometry;
|
extern shared_ptr<NetgenGeometry> ng_geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,13 +16,12 @@ DLL_HEADER void ExportSTL(py::module & m)
|
|||||||
{
|
{
|
||||||
py::class_<STLGeometry,shared_ptr<STLGeometry>> (m,"STLGeometry")
|
py::class_<STLGeometry,shared_ptr<STLGeometry>> (m,"STLGeometry")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
.def("Load", FunctionPointer([] (shared_ptr<STLGeometry> self, const string & filename)
|
;
|
||||||
|
m.def("LoadSTLGeometry", FunctionPointer([] (const string & filename)
|
||||||
{
|
{
|
||||||
ifstream ist(filename);
|
ifstream ist(filename);
|
||||||
self->Load(ist);
|
return shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
||||||
|
}));
|
||||||
}))
|
|
||||||
;
|
|
||||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> geo, MeshingParameters ¶m)
|
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<STLGeometry> geo, MeshingParameters ¶m)
|
||||||
{
|
{
|
||||||
auto mesh = make_shared<Mesh>();
|
auto mesh = make_shared<Mesh>();
|
||||||
@ -46,4 +46,5 @@ PYBIND11_PLUGIN(libstl) {
|
|||||||
ExportSTL(m);
|
ExportSTL(m);
|
||||||
return m.ptr();
|
return m.ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1210,3 +1210,36 @@ void VisualSceneSTLMeshing :: MouseDblClick (int px, int py)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NG_PYTHON
|
||||||
|
#include <../general/ngpython.hpp>
|
||||||
|
|
||||||
|
DLL_HEADER void ExportSTLVis(py::module &m)
|
||||||
|
{
|
||||||
|
using namespace netgen;
|
||||||
|
|
||||||
|
py::class_<VisualSceneSTLGeometry, shared_ptr<VisualSceneSTLGeometry>>
|
||||||
|
(m, "VisualSceneSTLGeometry")
|
||||||
|
.def("Draw", &VisualSceneSTLGeometry::DrawScene)
|
||||||
|
;
|
||||||
|
|
||||||
|
m.def("SetBackGroundColor", &VisualSceneSTLGeometry::SetBackGroundColor);
|
||||||
|
|
||||||
|
m.def("VS",
|
||||||
|
[](STLGeometry & geom)
|
||||||
|
{
|
||||||
|
auto vs = make_shared<VisualSceneSTLGeometry>();
|
||||||
|
|
||||||
|
vs->SetGeometry(&geom);
|
||||||
|
return vs;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
PYBIND11_PLUGIN(libcsgvis) {
|
||||||
|
py::module m("csg", "pybind csg");
|
||||||
|
ExportSTLVis(m);
|
||||||
|
return m.ptr();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -16,6 +16,7 @@ void DLL_HEADER ExportCSG(py::module &m);
|
|||||||
void DLL_HEADER ExportCSGVis(py::module &m);
|
void DLL_HEADER ExportCSGVis(py::module &m);
|
||||||
void DLL_HEADER ExportGeom2d(py::module &m);
|
void DLL_HEADER ExportGeom2d(py::module &m);
|
||||||
void DLL_HEADER ExportSTL(py::module &m);
|
void DLL_HEADER ExportSTL(py::module &m);
|
||||||
|
void DLL_HEADER ExportSTLVis(py::module &m);
|
||||||
|
|
||||||
PYBIND11_PLUGIN(libngpy)
|
PYBIND11_PLUGIN(libngpy)
|
||||||
{
|
{
|
||||||
@ -32,6 +33,8 @@ PYBIND11_PLUGIN(libngpy)
|
|||||||
ExportGeom2d(geom2d);
|
ExportGeom2d(geom2d);
|
||||||
py::module stl = ngpy.def_submodule("_stl", "pybind stl module");
|
py::module stl = ngpy.def_submodule("_stl", "pybind stl module");
|
||||||
ExportSTL(stl);
|
ExportSTL(stl);
|
||||||
|
py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module");
|
||||||
|
ExportSTLVis(stlvis);
|
||||||
return ngpy.ptr();
|
return ngpy.ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user