diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 15fa497b..bb646d08 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -356,9 +356,6 @@ DLL_HEADER void ExportCSG() { // testout = new ofstream ("test.out"); shared_ptr dummy; - cout << "Genrate Mesh" << endl; - // cout << "Genrate Mesh, params = " << param << endl; - // cout << "geom, bbox = " << geo.BoundingBox() << endl; geo.FindIdenticSurfaces(1e-8 * geo.MaxSize()); geo.GenerateMesh (dummy, param, 0, 6); ng_geometry.reset (&geo, NOOP_Deleter); diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index bad98dbe..a3fdc2ad 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -9,12 +9,29 @@ using namespace netgen; namespace bp = boost::python; +namespace netgen +{ + extern std::shared_ptr ng_geometry; +} + DLL_HEADER void ExportGeom2d() { ModuleScope module("geom2d"); - bp::class_("SplineGeometry") + bp::class_, boost::noncopyable>("SplineGeometry") + .def("__init__", bp::make_constructor + (FunctionPointer + ([](const string & filename) + { + cout << "load geometry"; + ifstream ist(filename); + auto geom = make_shared(); + geom->Load (filename.c_str()); + ng_geometry = geom; + return geom; + }))) + .def("Load",&SplineGeometry2d::Load) .def("AppendPoint", FunctionPointer([](SplineGeometry2d &self, double px, double py) { @@ -201,10 +218,11 @@ DLL_HEADER void ExportGeom2d() //cout << i << " : " << self.splines[i]->GetPoint(0.1) << " , " << self.splines[i]->GetPoint(0.5) << endl; } })) - .def("GenerateMesh", FunctionPointer([](SplineGeometry2d &self, MeshingParameters & mparam) + .def("GenerateMesh", FunctionPointer([](shared_ptr self, MeshingParameters & mparam) { - shared_ptr mesh; - self.GenerateMesh(mesh, mparam, 0, 0); + shared_ptr mesh = make_shared (); + ng_geometry = self; + self->GenerateMesh(mesh, mparam, 0, 0); return mesh; })) diff --git a/libsrc/meshing/msghandler.cpp b/libsrc/meshing/msghandler.cpp index 20393c78..abb7a20f 100644 --- a/libsrc/meshing/msghandler.cpp +++ b/libsrc/meshing/msghandler.cpp @@ -15,7 +15,8 @@ extern void Ng_PrintDest(const char * s); //the dots for progression of program void PrintDot(char ch) { - if (printdots) + // if (printdots) + if (printmessage_importance >= 4) { char st[2]; st[0] = ch; diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index da1ccaa7..c7069e4f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,4 +1,4 @@ -install(FILES __init__.py meshing.py csg.py +install(FILES __init__.py meshing.py csg.py geom2d.py DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen COMPONENT netgen ) diff --git a/python/Makefile.am b/python/Makefile.am index e2fd713e..640e7162 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -1,3 +1,4 @@ -python_PYTHON = __init__.py meshing.py csg.py +python_PYTHON = __init__.py meshing.py csg.py geom2d.py + diff --git a/python/csg.py b/python/csg.py index 85af4611..7998b29e 100644 --- a/python/csg.py +++ b/python/csg.py @@ -21,8 +21,8 @@ def VS (obj): -def csg_meshing_func (geom, maxh): - return GenerateMesh (geom, MeshingParameters (maxh=maxh)) +def csg_meshing_func (geom, **args): + return GenerateMesh (geom, MeshingParameters (**args)) CSGeometry.GenerateMesh = csg_meshing_func diff --git a/python/geom2d.py b/python/geom2d.py index d439ae36..bb6537a1 100644 --- a/python/geom2d.py +++ b/python/geom2d.py @@ -1,11 +1,33 @@ -from nglib.meshing import * -from nglib.geom2d import * - -geom = SplineGeometry() -geom.Load("square.in2d") - -param = MeshingParameters() -param.maxh = 0.05 - -m1 = geom.GenerateMesh (param) - +from netgen import __platform +if __platform.startswith('linux') or __platform.startswith('darwin'): + # Linux or Mac OS X + from libgeom2d.geom2d import * +# import libcsgvis.csgvis as csgvis +# from libcsgvis.csgvis import MouseMove + from libmesh.meshing import * +if __platform.startswith('win'): + # Windows + from nglib.geom2d import * +# import nglib.csgvis as csgvis +# from nglib.csgvis import MouseMove + from nglib.meshing import * + + + + +unit_square = SplineGeometry() +pi1 = unit_square.AppendPoint(0,0) +pi2 = unit_square.AppendPoint(1,0) +pi3 = unit_square.AppendPoint(1,1) +pi4 = unit_square.AppendPoint(0,1) +unit_square.Append(["line",pi1,pi2], bc=1) +unit_square.Append(["line",pi2,pi3], bc=2) +unit_square.Append(["line",pi3,pi4], bc=3) +unit_square.Append(["line",pi4,pi1], bc=4) + + +all = ['SplineGeometry', 'unit_square'] + + + +