diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 6f9e1bcc..a4744170 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -6,7 +6,12 @@ using namespace netgen; +namespace netgen +{ + extern shared_ptr ng_geometry; +} +inline void NOOP_Deleter(void *) { ; } // a shadow solid tree using shared pointers. @@ -305,7 +310,7 @@ void ExportCSG() auto mod_nr = bp::extract (tup[1])(); Array si; mod_solid -> GetSolid() -> GetSurfaceIndices (si); - cout << "change bc on surfaces: " << si << " to " << mod_nr << endl; + // cout << "change bc on surfaces: " << si << " to " << mod_nr << endl; for (int j = 0; j < si.Size(); j++) { @@ -313,6 +318,7 @@ void ExportCSG() bcm.bcname = NULL; bcm.tlonr = tlonr; bcm.si = si[j]; + bcm.bcnr = mod_nr; self.bcmodifications.Append (bcm); } } @@ -355,6 +361,7 @@ void ExportCSG() // cout << "geom, bbox = " << geo.BoundingBox() << endl; geo.FindIdenticSurfaces(1e-8 * geo.MaxSize()); geo.GenerateMesh (dummy, param, 0, 6); + ng_geometry.reset (&geo, NOOP_Deleter); return dummy; })) ; diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 26a57028..31b47447 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -11,6 +11,11 @@ using namespace netgen; namespace bp = boost::python; +namespace netgen +{ + extern shared_ptr ng_geometry; +} + template void ExportArray () @@ -97,7 +102,22 @@ void ExportNetgenMeshing() bp::class_,boost::noncopyable>("Mesh", bp::no_init) .def(bp::init<>("create empty mesh")) .def("__str__", &ToString) - .def("Load", static_cast(&Mesh::Load)) + .def("Load", FunctionPointer + ([](Mesh & self, const string & filename) + { + ifstream input(filename); + self.Load(input); + for (int i = 0; i < geometryregister.Size(); i++) + { + NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input); + if (hgeom) + { + ng_geometry.reset (hgeom); + break; + } + } + })) + // static_cast(&Mesh::Load)) .def("Save", static_cast(&Mesh::Save)) .def("Elements3D",