diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 125e774b..563e0b76 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -44,12 +44,10 @@ void RunParallel ( void * (*fun)(void *), void * in) - +#include "writeuser.hpp" namespace netgen { -#include "writeuser.hpp" - extern shared_ptr mesh; extern shared_ptr ng_geometry; diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index b39698ef..7604f7f2 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -8,9 +8,10 @@ #include "nginterface_v2.hpp" // #include +#include "writeuser.hpp" + namespace netgen { -#include "writeuser.hpp" extern shared_ptr mesh; } diff --git a/libsrc/interface/readuser.cpp b/libsrc/interface/readuser.cpp index 3f798a93..97cd193c 100644 --- a/libsrc/interface/readuser.cpp +++ b/libsrc/interface/readuser.cpp @@ -11,10 +11,10 @@ #include #include -namespace netgen -{ #include "writeuser.hpp" +namespace netgen +{ void ReadFile (Mesh & mesh, const string & hfilename) { diff --git a/libsrc/interface/writeelmer.cpp b/libsrc/interface/writeelmer.cpp index f97a738f..805d3dca 100644 --- a/libsrc/interface/writeelmer.cpp +++ b/libsrc/interface/writeelmer.cpp @@ -12,11 +12,11 @@ #include #include +#include "writeuser.hpp" + namespace netgen { -#include "writeuser.hpp" - extern MeshingParameters mparam; diff --git a/libsrc/interface/writepermas.cpp b/libsrc/interface/writepermas.cpp index fc46e87c..7d2013e1 100644 --- a/libsrc/interface/writepermas.cpp +++ b/libsrc/interface/writepermas.cpp @@ -13,10 +13,10 @@ #include using namespace std; +#include "writeuser.hpp" namespace netgen { -#include "writeuser.hpp" // Forward declarations (don't know, where to define them, sorry) int addComponent(string &strComp, string &strSitu, ofstream &out); diff --git a/libsrc/interface/writeuser.cpp b/libsrc/interface/writeuser.cpp index 62bfb691..6aa5754e 100644 --- a/libsrc/interface/writeuser.cpp +++ b/libsrc/interface/writeuser.cpp @@ -10,10 +10,11 @@ #include #include -namespace netgen -{ #include "writeuser.hpp" + +namespace netgen +{ extern MeshingParameters mparam; diff --git a/libsrc/interface/writeuser.hpp b/libsrc/interface/writeuser.hpp index cb9e58f6..04bdeeb0 100644 --- a/libsrc/interface/writeuser.hpp +++ b/libsrc/interface/writeuser.hpp @@ -7,6 +7,7 @@ /* Date: 10. Dec. 97 */ /**************************************************************************/ +namespace netgen { DLL_HEADER extern void WriteFile (int typ, @@ -162,5 +163,7 @@ extern bool DLL_HEADER WriteUserFormat (const string & format, const NetgenGeometry & geom, const string & filename); +} + #endif diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index c5438103..b6a9675e 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -8,6 +8,7 @@ #include "meshing.hpp" #include #include +#include <../interface/writeuser.hpp> using namespace netgen; @@ -357,7 +358,22 @@ DLL_HEADER void ExportNetgenMeshing() })) // static_cast(&Mesh::Load)) .def("Save", static_cast(&Mesh::Save)) - + .def("Export", FunctionPointer + ([] (Mesh & self, string filename, string format) + { + if (WriteUserFormat (format, self, *self.GetGeometry(), filename)) + { + string err = string ("nothing known about format")+format; + Array names, extensions; + RegisterUserFormats (names, extensions); + err += "\navailable formats are:\n"; + for (auto name : names) + err += string("'") + name + "'\n"; + throw NgException (err); + } + }), + (bp::arg("self"), bp::arg("filename"), bp::arg("format"))) + .add_property("dim", &Mesh::GetDimension, &Mesh::SetDimension) .def("Elements3D", diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index 279d5400..cf2f25bd 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -29,11 +29,10 @@ namespace netgen #endif +#include "../libsrc/interface/writeuser.hpp" namespace netgen { -#include "../libsrc/interface/writeuser.hpp" - //extern string ngdir; Flags parameters; } diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index a31766db..957bf7c3 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -36,12 +36,12 @@ extern bool nodisplay; #include +#include "../libsrc/interface/writeuser.hpp" namespace netgen { DLL_HEADER extern MeshingParameters mparam; DLL_HEADER extern void ImportSolution2(const char * filename); -#include "../libsrc/interface/writeuser.hpp" #include "demoview.hpp" }