From cd78f0e4408f23169d4230aabbfe7dc27c3257cc Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 21 Sep 2019 22:08:35 +0200 Subject: [PATCH] draw stl meshing 2d local coordinates --- libsrc/meshing/meshing2.cpp | 51 ++++++++++++++++++++------------- libsrc/visualization/mvdraw.hpp | 4 +++ ng/ngpkg.cpp | 2 +- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index a696e608..76aa6e60 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -1,9 +1,12 @@ #include #include "meshing.hpp" +#include namespace netgen { + extern DLL_HEADER void Render(bool blocking = false); static void glrender (int wait); + VisualSceneSurfaceMeshing vssurfacemeshing; // global variable for visualization @@ -15,7 +18,7 @@ namespace netgen // // static int geomtrig; // //static const char * rname; // static int cntelem, trials, nfaces; -// static int oldnl; + static int oldnl; // static int qualclass; @@ -241,14 +244,20 @@ namespace netgen bool debugflag; // double h; - - NgArray locpoints; + + auto locpointsptr = make_shared>(); + vssurfacemeshing.locpointsptr = locpointsptr; + auto& locpoints = *locpointsptr; NgArray legalpoints; - NgArray plainpoints; + auto plainpointsptr = make_shared>(); + auto& plainpoints = *plainpointsptr; + vssurfacemeshing.plainpointsptr = plainpointsptr; NgArray plainzones; - NgArray loclines; + auto loclinesptr = make_shared>(); + auto &loclines = *loclinesptr; + vssurfacemeshing.loclinesptr = loclinesptr; int cntelem = 0, trials = 0, nfaces = 0; - int oldnl = 0; + oldnl = 0; int qualclass; @@ -1579,14 +1588,11 @@ namespace netgen - -// #define OPENGL -#ifdef OPENGLxx +#ifdef OPENGL /* *********************** Draw Surface Meshing **************** */ -#include #include namespace netgen @@ -1594,7 +1600,6 @@ namespace netgen extern STLGeometry * stlgeometry; extern Mesh * mesh; - VisualSceneSurfaceMeshing vssurfacemeshing; @@ -1604,8 +1609,9 @@ namespace netgen if (multithread.drawing) { - // vssurfacemeshing.Render(); - Render (); + // vssurfacemeshing.Render(); + // Render (); + Render(); if (wait || multithread.testmode) { @@ -1630,7 +1636,12 @@ namespace netgen void VisualSceneSurfaceMeshing :: DrawScene () { - int i, j, k; + // int i, j, k; + if(!locpointsptr) + return; + auto& locpoints = *locpointsptr; + auto& loclines = *loclinesptr; + auto& plainpoints = *plainpointsptr; if (loclines.Size() != changeval) { @@ -1657,7 +1668,7 @@ namespace netgen // SetLight(); glPushMatrix(); - glMultMatrixf (transformationmat); + glMultMatrixd (transformationmat); glShadeModel (GL_SMOOTH); // glDisable (GL_COLOR_MATERIAL); @@ -1694,7 +1705,7 @@ namespace netgen glPolygonOffset (1, -1); glLineWidth (3); - for (i = 1; i <= loclines.Size(); i++) + for (int i = 1; i <= loclines.Size(); i++) { if (i == 1) { @@ -1731,7 +1742,7 @@ namespace netgen float mat_colp[] = { 1, 0, 0, 1 }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); glBegin (GL_POINTS); - for (i = 1; i <= locpoints.Size(); i++) + for (int i = 1; i <= locpoints.Size(); i++) { Point3d p = locpoints.Get(i); glVertex3f (p.X(), p.Y(), p.Z()); @@ -1751,7 +1762,7 @@ namespace netgen double scalex = 0.1, scaley = 0.1; glBegin (GL_LINES); - for (i = 1; i <= loclines.Size(); i++) + for (int i = 1; i <= loclines.Size(); i++) { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d); if (i == 1) @@ -1776,7 +1787,7 @@ namespace netgen glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp); glBegin (GL_POINTS); - for (i = 1; i <= plainpoints.Size(); i++) + for (int i = 1; i <= plainpoints.Size(); i++) { Point2d p = plainpoints.Get(i); glVertex3f (scalex * p.X(), scaley * p.Y(), -5); @@ -1971,7 +1982,7 @@ namespace netgen void VisualSceneSurfaceMeshing :: BuildScene (int zoomall) { - int i, j, k; + // int i, j, k; /* center = stlgeometry -> GetBoundingBox().Center(); rad = stlgeometry -> GetBoundingBox().Diam() / 2; diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index 9df510a7..94f4c7a5 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -96,6 +96,10 @@ namespace netgen class VisualSceneSurfaceMeshing : public VisualScene { public: + shared_ptr> locpointsptr; + shared_ptr> loclinesptr; + shared_ptr> plainpointsptr; + bool clearptr; VisualSceneSurfaceMeshing (); virtual ~VisualSceneSurfaceMeshing (); diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index c4866ab7..a0226cf3 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -1940,7 +1940,7 @@ namespace netgen vs = &vsmeshdoc; } - // if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing; + if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing; if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints; if (strcmp (vismode, "solution") == 0) vs = &netgen::GetVSSolution(); }