diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index c8c504d6..fbda9417 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -158,9 +158,11 @@ void Ng_LoadMeshFromStream ( istream & input ) { mesh.reset (new Mesh()); mesh -> Load(input); + /* vssolution.SetMesh(mesh); vsmesh.SetMesh(mesh); - + */ + SetGlobalMesh (mesh); for (int i = 0; i < geometryregister.Size(); i++) { NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input); @@ -2345,3 +2347,10 @@ void Ng_GetArgs (int & argc, char ** &argv) argc = h_argc; argv = h_argv; } + + + +void LinkFunction () +{ + Ng_Redraw(); +} diff --git a/libsrc/interface/nginterface_v2.cpp b/libsrc/interface/nginterface_v2.cpp index 469d3b9f..2e191146 100644 --- a/libsrc/interface/nginterface_v2.cpp +++ b/libsrc/interface/nginterface_v2.cpp @@ -25,8 +25,9 @@ namespace netgen shared_ptr hmesh = netgen::mesh; netgen::mesh = mesh; - vssolution.SetMesh(mesh); - vsmesh.SetMesh(mesh); + // vssolution.SetMesh(mesh); + // vsmesh.SetMesh(mesh); + SetGlobalMesh (mesh); return hmesh; } @@ -59,8 +60,9 @@ namespace netgen netgen::mesh = make_shared(); netgen::mesh -> Load (ist); mesh = netgen::mesh; - vssolution.SetMesh(mesh); - vsmesh.SetMesh(mesh); + // vssolution.SetMesh(mesh); + // vsmesh.SetMesh(mesh); + SetGlobalMesh (mesh); } void Ngx_Mesh :: SaveMesh (ostream & ost) const diff --git a/libsrc/meshing/global.cpp b/libsrc/meshing/global.cpp index 2d2bf582..c3b0fce6 100644 --- a/libsrc/meshing/global.cpp +++ b/libsrc/meshing/global.cpp @@ -20,6 +20,8 @@ namespace netgen shared_ptr mesh; shared_ptr ng_geometry; + weak_ptr global_mesh; + // Flags parameters; int silentflag = 0; int testmode = 0; diff --git a/libsrc/meshing/global.hpp b/libsrc/meshing/global.hpp index 5538de65..e5cd1f82 100644 --- a/libsrc/meshing/global.hpp +++ b/libsrc/meshing/global.hpp @@ -52,6 +52,14 @@ namespace netgen extern int h_argc; extern char ** h_argv; + + + extern weak_ptr global_mesh; + inline void SetGlobalMesh (shared_ptr m) + { + cout << "set global mesh" << endl; + global_mesh = m; + } } #endif diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 31b47447..a352eaeb 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -154,7 +154,7 @@ void ExportNetgenMeshing() ) */ .def ("BoundaryLayer", FunctionPointer - ([](Mesh & self, int bc, double thickness, string material) + ([](Mesh & self, int bc, double thickness, int volnr, string material) { BoundaryLayerParameters blp; @@ -174,7 +174,8 @@ void ExportNetgenMeshing() maxind = max (maxind, self[ei].GetIndex()); cout << "maxind = " << maxind << endl; self.SetMaterial (maxind+1, material.c_str()); - blp.matnr = maxind+1; + blp.new_matnr = maxind+1; + blp.bulk_matnr = volnr; GenerateBoundaryLayer (self, blp); } )) diff --git a/libsrc/visualization/Makefile.am b/libsrc/visualization/Makefile.am index 1df58318..052be80d 100644 --- a/libsrc/visualization/Makefile.am +++ b/libsrc/visualization/Makefile.am @@ -6,14 +6,20 @@ include_HEADERS = soldata.hpp AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) METASOURCES = AUTO -if NGGUI lib_LTLIBRARIES = libvisual.la + + +libvisual_la_SOURCES = + +if NGGUI libvisual_la_LIBADD = $(LIBGLU) $(TCL_LIB_SPEC) +libvisual_la_SOURCES += meshdoc.cpp mvdraw.cpp \ + vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp visualpkg.cpp +else +libvisual_la_SOURCES += visual_dummy.cpp endif -libvisual_la_SOURCES = meshdoc.cpp mvdraw.cpp \ - vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp visualpkg.cpp diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index 16e49612..5773ce3e 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -156,7 +156,7 @@ namespace netgen double minh, maxh; // for meshsize coloring - weak_ptr wp_mesh; + // weak_ptr wp_mesh; public: VisualSceneMesh (); @@ -166,8 +166,9 @@ namespace netgen virtual void DrawScene (); virtual void MouseDblClick (int px, int py); - void SetMesh (shared_ptr mesh) { wp_mesh = mesh; } - shared_ptr GetMesh () { return shared_ptr(wp_mesh); } + // void SetMesh (shared_ptr mesh) { wp_mesh = mesh; } + // shared_ptr GetMesh () { return shared_ptr(wp_mesh); } + shared_ptr GetMesh () const { return shared_ptr(global_mesh); } void SetMouseEventHandler (MouseEventHandler * handler) { user_me_handler = handler; } diff --git a/libsrc/visualization/visualpkg.cpp b/libsrc/visualization/visualpkg.cpp index 2bbb6ced..7c0d178f 100644 --- a/libsrc/visualization/visualpkg.cpp +++ b/libsrc/visualization/visualpkg.cpp @@ -303,7 +303,6 @@ namespace netgen Tcl_Interp * interp, int argc, tcl_const char *argv[]) { - auto mesh = vssolution.GetMesh(); int i; char buf[1000]; buf[0] = 0; @@ -366,6 +365,7 @@ namespace netgen if (strcmp (argv[1], "getdimension") == 0) { + auto mesh = vssolution.GetMesh(); sprintf (buf, "%d", mesh->GetDimension()); } } diff --git a/libsrc/visualization/vsfieldlines.cpp b/libsrc/visualization/vsfieldlines.cpp index b37410de..5e259b42 100644 --- a/libsrc/visualization/vsfieldlines.cpp +++ b/libsrc/visualization/vsfieldlines.cpp @@ -442,7 +442,7 @@ namespace netgen void VisualSceneSolution :: BuildFieldLinesFromBox(Array & startpoints) { - shared_ptr mesh (wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) return; if(fieldlines_startarea_parameter[0] > fieldlines_startarea_parameter[3] || @@ -472,7 +472,7 @@ namespace netgen void VisualSceneSolution :: BuildFieldLinesFromLine(Array & startpoints) { - shared_ptr mesh (wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) return; @@ -491,7 +491,7 @@ namespace netgen void VisualSceneSolution :: BuildFieldLinesFromFile(Array & startpoints) { - shared_ptr mesh (wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) return; ifstream * infile; @@ -573,7 +573,7 @@ namespace netgen void VisualSceneSolution :: BuildFieldLinesFromFace(Array & startpoints) { - shared_ptr mesh (wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) return; Array elements_2d; @@ -660,7 +660,7 @@ namespace netgen void VisualSceneSolution :: BuildFieldLinesPlot () { - shared_ptr mesh (wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) return; if (fieldlinestimestamp >= solutiontimestamp) diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index bbb68218..dde141c6 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -75,7 +75,7 @@ namespace netgen { try { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) { @@ -91,6 +91,7 @@ namespace netgen BuildScene(); + glEnable(GL_DEPTH_TEST); glClearColor(backcolor, backcolor, backcolor, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -321,7 +322,7 @@ namespace netgen { try { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) { @@ -911,7 +912,7 @@ namespace netgen void VisualSceneMesh :: BuildFilledList (bool names) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); static int timer = NgProfiler::CreateTimer ("Mesh::BuildFilledList"); NgProfiler::RegionTimer reg (timer); @@ -1301,7 +1302,7 @@ namespace netgen void VisualSceneMesh :: BuildLineList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); static int timer = NgProfiler::CreateTimer ("Mesh::BuildLineList"); NgProfiler::RegionTimer reg (timer); @@ -1583,7 +1584,7 @@ namespace netgen void VisualSceneMesh :: BuildEdgeList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!lock) { @@ -1760,7 +1761,7 @@ namespace netgen void VisualSceneMesh :: BuildTetList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (tettimestamp > mesh->GetTimeStamp () && tettimestamp > vispar.clipping.timestamp ) @@ -2110,7 +2111,7 @@ namespace netgen void VisualSceneMesh :: BuildPrismList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (prismtimestamp > mesh->GetTimeStamp () && prismtimestamp > vispar.clipping.timestamp ) @@ -2440,7 +2441,7 @@ namespace netgen void VisualSceneMesh :: BuildHexList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (hextimestamp > mesh->GetTimeStamp () && hextimestamp > vispar.clipping.timestamp ) @@ -2650,7 +2651,7 @@ namespace netgen void VisualSceneMesh :: BuildPyramidList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (pyramidtimestamp > mesh->GetTimeStamp () && pyramidtimestamp > vispar.clipping.timestamp ) @@ -3006,7 +3007,7 @@ namespace netgen void VisualSceneMesh :: BuildDomainSurfList() { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (domainsurflist) glDeleteLists (domainsurflist, 1); @@ -3124,7 +3125,7 @@ namespace netgen void VisualSceneMesh :: MouseDblClick (int px, int py) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); BuildFilledList (true); @@ -3553,7 +3554,8 @@ void ExportMeshVis() ([](shared_ptr mesh) { auto vs = make_shared(); - vs->SetMesh(mesh); + // vs->SetMesh(mesh); + SetGlobalMesh (mesh); return vs; })); diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index c39341f7..81131953 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -68,15 +68,16 @@ namespace netgen ClearSolutionData(); } + /* void VisualSceneSolution :: SetMesh (shared_ptr amesh) { wp_mesh = amesh; } - + */ void VisualSceneSolution :: AddSolutionData (SolData * sd) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); NgLock meshlock1 (mesh->MajorMutex(), 1); int funcnr = -1; @@ -160,7 +161,7 @@ namespace netgen void VisualSceneSolution :: SaveSolutionData (const char * filename) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); PrintMessage (1, "Write solution data to file ", filename); @@ -351,7 +352,7 @@ namespace netgen { try { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) { @@ -700,7 +701,7 @@ namespace netgen { try { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!mesh) { @@ -1124,7 +1125,7 @@ namespace netgen void VisualSceneSolution :: Draw1DElements () { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (element1dlist) glDeleteLists (element1dlist, 1); @@ -1176,7 +1177,7 @@ namespace netgen void VisualSceneSolution :: DrawSurfaceElements () { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); static int timer = NgProfiler::CreateTimer ("Solution::DrawSurfaceElements"); NgProfiler::RegionTimer reg (timer); @@ -1619,7 +1620,7 @@ namespace netgen void VisualSceneSolution :: DrawSurfaceElementLines () { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); #ifdef PARALLELGL if (id == 0 && ntasks > 1) @@ -1728,7 +1729,7 @@ namespace netgen const SolData * vsol, int comp) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); if (!draw_isosurface) return; if (!sol) return; @@ -1979,7 +1980,7 @@ namespace netgen const Point<3> & pmin, const Point<3> & pmax, const int sei, const SolData * vsol) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); int dir,dir1,dir2; double s,t; @@ -2091,7 +2092,7 @@ namespace netgen void VisualSceneSolution :: DrawSurfaceVectors () { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); SurfaceElementIndex sei; @@ -2427,7 +2428,7 @@ namespace netgen void VisualSceneSolution :: GetMinMax (int funcnr, int comp, double & minv, double & maxv) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); static int timer1 = NgProfiler::CreateTimer ("getminmax, vol"); static int timer2 = NgProfiler::CreateTimer ("getminmax, surf"); @@ -2576,7 +2577,7 @@ namespace netgen const double xref[], const double x[], const double dxdxref[], int comp, double & val) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); double lam1 = xref[0]; double lam2 = xref[1]; @@ -2749,7 +2750,7 @@ namespace netgen double lam1, double lam2, double lam3, int comp, double & val) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); val = 0; bool ok = 0; @@ -2920,7 +2921,7 @@ namespace netgen double lam1, double lam2, double lam3, int comp, complex & val) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); val = 0.0; bool ok = 0; @@ -3165,7 +3166,7 @@ namespace netgen double lam1, double lam2, int comp, double & val) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); bool ok; if (comp == 0) @@ -3399,7 +3400,7 @@ namespace netgen const double xref[], const double x[], const double dxdxref[], int comp, double & val) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); double lam1 = xref[0], lam2 = xref[1]; @@ -3648,7 +3649,7 @@ namespace netgen Vec<3> VisualSceneSolution :: GetSurfDeformation (SurfaceElementIndex elnr, int facetnr, double lam1, double lam2) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); Vec<3> def; if (deform && vecfunction != -1) @@ -3675,7 +3676,7 @@ namespace netgen void VisualSceneSolution :: GetPointDeformation (int pnum, Point<3> & p, SurfaceElementIndex elnr) const { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); p = mesh->Point (pnum+1); if (deform && vecfunction != -1) @@ -3715,7 +3716,7 @@ namespace netgen void VisualSceneSolution :: GetClippingPlaneTrigs (Array & trigs, Array & pts) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); static int timer_vals = NgProfiler::CreateTimer ("ClipPlaneTrigs - vertex values"); static int timer1 = NgProfiler::CreateTimer ("ClipPlaneTrigs1"); @@ -4058,7 +4059,7 @@ namespace netgen void VisualSceneSolution :: GetClippingPlaneGrid (Array & pts) { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); Vec3d n(clipplane[0], clipplane[1], clipplane[2]); @@ -4116,7 +4117,7 @@ namespace netgen void VisualSceneSolution :: DrawClipPlaneTrigs () { - shared_ptr mesh(wp_mesh); + shared_ptr mesh = GetMesh(); #ifdef PARALLELGL diff --git a/libsrc/visualization/vssolution.hpp b/libsrc/visualization/vssolution.hpp index d7b3ad0a..f5ff2c78 100644 --- a/libsrc/visualization/vssolution.hpp +++ b/libsrc/visualization/vssolution.hpp @@ -177,7 +177,7 @@ private: void BuildFieldLinesFromFace(Array & startpoints); void BuildFieldLinesFromBox(Array & startpoints); void BuildFieldLinesFromLine(Array & startpoints); - weak_ptr wp_mesh; + // weak_ptr wp_mesh; public: VisualSceneSolution (); virtual ~VisualSceneSolution (); @@ -186,8 +186,9 @@ public: virtual void DrawScene (); virtual void MouseDblClick (int px, int py); - void SetMesh (shared_ptr amesh); - shared_ptr GetMesh () { return shared_ptr(wp_mesh); } + // void SetMesh (shared_ptr amesh); + // shared_ptr GetMesh () { return shared_ptr(wp_mesh); } + shared_ptr GetMesh () const { return shared_ptr(global_mesh); } void BuildFieldLinesPlot ();