From 42ea36b93259e58468f9e72baa63a07183130e7d Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Wed, 8 Oct 2014 12:46:25 +0000 Subject: [PATCH] opengl/tcl structure --- libsrc/csg/csgpkg.cpp | 2 +- libsrc/csg/vscsg.cpp | 2 +- libsrc/geom2d/genmesh2d.cpp | 2 +- libsrc/geom2d/geom2dpkg.cpp | 1 + libsrc/include/Makefile.am | 2 +- libsrc/include/incopengl.hpp | 31 ++ libsrc/include/inctcl.hpp | 8 + libsrc/include/incvis.hpp | 40 +-- libsrc/occ/occpkg.cpp | 2 +- libsrc/stlgeom/stlpkg.cpp | 2 +- libsrc/visualization/Makefile.am | 3 +- libsrc/visualization/meshdoc.cpp | 2 +- libsrc/visualization/mvdraw.cpp | 9 +- libsrc/visualization/mvdraw.hpp | 2 +- libsrc/visualization/visual.hpp | 2 +- libsrc/visualization/visualpkg.cpp | 398 ++++++++++++++++++++++++++ libsrc/visualization/vsfieldlines.cpp | 2 +- libsrc/visualization/vssolution.cpp | 366 ----------------------- libsrc/visualization/vssolution.hpp | 28 +- ng/demoview.cpp | 2 +- ng/ngappinit.cpp | 2 +- ng/ngpkg.cpp | 7 +- nglib/nglib.cpp | 6 +- 23 files changed, 484 insertions(+), 437 deletions(-) create mode 100644 libsrc/include/incopengl.hpp create mode 100644 libsrc/include/inctcl.hpp create mode 100644 libsrc/visualization/visualpkg.cpp diff --git a/libsrc/csg/csgpkg.cpp b/libsrc/csg/csgpkg.cpp index cfb4e69b..07489590 100644 --- a/libsrc/csg/csgpkg.cpp +++ b/libsrc/csg/csgpkg.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include diff --git a/libsrc/csg/vscsg.cpp b/libsrc/csg/vscsg.cpp index 97537b7b..6805add4 100644 --- a/libsrc/csg/vscsg.cpp +++ b/libsrc/csg/vscsg.cpp @@ -1,5 +1,5 @@ #include -#include "incvis.hpp" +#include "incopengl.hpp" #include #include diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index f8d0f882..52c8ecf8 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -365,7 +365,7 @@ namespace netgen mp.maxh = h; } - mesh = make_shared(); + // mesh = make_shared(); mesh->SetDimension (2); Point3d pmin(bbox.PMin()(0), bbox.PMin()(1), -bbox.Diam()); diff --git a/libsrc/geom2d/geom2dpkg.cpp b/libsrc/geom2d/geom2dpkg.cpp index 15a64531..735e15e9 100644 --- a/libsrc/geom2d/geom2dpkg.cpp +++ b/libsrc/geom2d/geom2dpkg.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "vsgeom2d.hpp" diff --git a/libsrc/include/Makefile.am b/libsrc/include/Makefile.am index c4420cf2..7b1c9379 100644 --- a/libsrc/include/Makefile.am +++ b/libsrc/include/Makefile.am @@ -1,7 +1,7 @@ noinst_HEADERS = acisgeom.hpp gprim.hpp meshing.hpp occgeom.hpp \ visual.hpp csg.hpp incvis.hpp myadt.hpp opti.hpp geometry2d.hpp \ linalg.hpp mydefs.hpp parallel.hpp stlgeom.hpp mystdlib.h \ -nginterface_v2_impl.hpp +nginterface_v2_impl.hpp inctcl.hpp incopengl.hpp include_HEADERS = nginterface.h nginterface_v2.hpp diff --git a/libsrc/include/incopengl.hpp b/libsrc/include/incopengl.hpp new file mode 100644 index 00000000..f365cf07 --- /dev/null +++ b/libsrc/include/incopengl.hpp @@ -0,0 +1,31 @@ +#define GL_GLEXT_PROTOTYPES + + +# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) +# include +# include +# else +# include +# include +# endif + + +#ifdef TOGL_X11 +// parallel +#define GLX_GLXEXT_PROTOTYPES +#include +#include +#endif + + + + + +// part of OpenGL 1.2, but not in Microsoft's OpenGL 1.1 header: +// GL version sould be checked at runtime +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif + + + diff --git a/libsrc/include/inctcl.hpp b/libsrc/include/inctcl.hpp new file mode 100644 index 00000000..8191a44a --- /dev/null +++ b/libsrc/include/inctcl.hpp @@ -0,0 +1,8 @@ +#include +#include + +#if TK_MAJOR_VERSION==8 && TK_MINOR_VERSION>=4 +#define tcl_const const +#else +#define tcl_const +#endif diff --git a/libsrc/include/incvis.hpp b/libsrc/include/incvis.hpp index b95005db..cc4c0230 100644 --- a/libsrc/include/incvis.hpp +++ b/libsrc/include/incvis.hpp @@ -1,40 +1,6 @@ // libraries for User interface: -#include -#include - -#if TK_MAJOR_VERSION==8 && TK_MINOR_VERSION>=4 -#define tcl_const const -#else -#define tcl_const -#endif - -#define GL_GLEXT_PROTOTYPES - - -# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) -# include -# include -# else -# include -# include -# endif - - -#ifdef TOGL_X11 -// parallel -#define GLX_GLXEXT_PROTOTYPES -#include -#include -#endif - - - -// part of OpenGL 1.2, but not in Microsoft's OpenGL 1.1 header: -// GL version sould be checked at runtime -#ifndef GL_CLAMP_TO_EDGE -#define GL_CLAMP_TO_EDGE 0x812F -#endif - - +nicht mehr verwendet +#include "inctcl.hpp" +#include "incopengl.hpp" diff --git a/libsrc/occ/occpkg.cpp b/libsrc/occ/occpkg.cpp index 8957ed74..9000e10a 100644 --- a/libsrc/occ/occpkg.cpp +++ b/libsrc/occ/occpkg.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include "../meshing/bcfunctions.hpp" diff --git a/libsrc/stlgeom/stlpkg.cpp b/libsrc/stlgeom/stlpkg.cpp index aee80f69..3fb5791d 100644 --- a/libsrc/stlgeom/stlpkg.cpp +++ b/libsrc/stlgeom/stlpkg.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/libsrc/visualization/Makefile.am b/libsrc/visualization/Makefile.am index 4bf6ae3b..0169baa1 100644 --- a/libsrc/visualization/Makefile.am +++ b/libsrc/visualization/Makefile.am @@ -14,6 +14,7 @@ endif libvisual_la_SOURCES = meshdoc.cpp mvdraw.cpp \ - vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp + vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp visualpkg.cpp + diff --git a/libsrc/visualization/meshdoc.cpp b/libsrc/visualization/meshdoc.cpp index ce738068..53900083 100644 --- a/libsrc/visualization/meshdoc.cpp +++ b/libsrc/visualization/meshdoc.cpp @@ -8,7 +8,7 @@ #include - +#include namespace netgen { diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 76d9f069..3975585b 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -35,10 +35,17 @@ namespace netgen #endif */ + void (*opengl_text_function)(const char * text) = NULL; + void Set_OpenGLText_Callback ( void (*fun) (const char * text) ) + { + opengl_text_function = fun; + } void MyOpenGLText (const char * text) { - cout << "MyOpenGLText: " << text << endl; + if (opengl_text_function) + (*opengl_text_function) (text); + // cout << "MyOpenGLText: " << text << endl; } diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index 8126c613..b9898061 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -82,7 +82,7 @@ namespace netgen DLL_HEADER extern void MyOpenGLText (const char * text); - + DLL_HEADER extern void Set_OpenGLText_Callback ( void (*fun) (const char * text) ); diff --git a/libsrc/visualization/visual.hpp b/libsrc/visualization/visual.hpp index 1015fe00..6db3fa18 100644 --- a/libsrc/visualization/visual.hpp +++ b/libsrc/visualization/visual.hpp @@ -17,7 +17,7 @@ Visualization #define PARALLELGL #endif -#include "../include/incvis.hpp" +#include "../include/incopengl.hpp" #include "vispar.hpp" #include "soldata.hpp" diff --git a/libsrc/visualization/visualpkg.cpp b/libsrc/visualization/visualpkg.cpp new file mode 100644 index 00000000..2bbb6ced --- /dev/null +++ b/libsrc/visualization/visualpkg.cpp @@ -0,0 +1,398 @@ +#include +// #include +#include + + +#include +#include +#include +#include + + +// #include +#include + +#include + + + + + + +namespace netgen + +{ + + /* + */ + + + + + + + + + int Ng_Vis_Set (ClientData clientData, + Tcl_Interp * interp, + int argc, tcl_const char *argv[]) + + { + if (argc >= 2) + { + if (strcmp (argv[1], "parameters") == 0) + { + vssolution.imag_part = + atoi (Tcl_GetVar (interp, "::visoptions.imaginary", TCL_GLOBAL_ONLY)); + vssolution.usetexture = + atoi (Tcl_GetVar (interp, "::visoptions.usetexture", TCL_GLOBAL_ONLY)); + if (atoi (Tcl_GetVar (interp, "::visoptions.redrawperiodic", TCL_GLOBAL_ONLY))) + vssolution.usetexture = 2; + + vssolution.invcolor = + atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); + + vssolution.clipsolution = 0; + + if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), + "scal") == 0) + vssolution.clipsolution = 1; + if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), + "vec") == 0) + vssolution.clipsolution = 2; + + tcl_const char * scalname = + Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); + tcl_const char * vecname = + Tcl_GetVar (interp, "::visoptions.vecfunction", TCL_GLOBAL_ONLY); + tcl_const char * fieldlines_vecname = + Tcl_GetVar (interp, "::visoptions.fieldlinesvecfunction", TCL_GLOBAL_ONLY); + + + vssolution.scalfunction = -1; + vssolution.vecfunction = -1; + vssolution.fieldlines_vecfunction = -1; + + int pointpos; // SZ + const char * pch = strchr(scalname,':'); + pointpos = int(pch-scalname+1); + + for (int i = 0; i < vssolution.soldata.Size(); i++) + { + if ( (strlen (vssolution.soldata[i]->name) == size_t(pointpos-1)) && + (strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) ) + { + vssolution.scalfunction = i; + vssolution.scalcomp = atoi (scalname + pointpos); + if ( vssolution.scalcomp > vssolution.soldata[i]->components ) + vssolution.scalcomp = 1; + char newscalname[100]; + for ( int ii = 0; ii < pointpos; ii++ ) + newscalname[ii] = scalname[ii]; + newscalname[pointpos] = ':'; + sprintf (newscalname+pointpos, "%i", vssolution.scalcomp); + + if (strcmp (scalname, newscalname) != 0) + Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY ); + scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); + } + if (strcmp (vssolution.soldata[i]->name, vecname) == 0) + vssolution.vecfunction = i; + + if (strcmp (vssolution.soldata[i]->name, fieldlines_vecname) == 0) + vssolution.fieldlines_vecfunction = i; + } + + if(vssolution.fieldlines_vecfunction != -1 && + vssolution.vecfunction == -1) + { + //cout << "WARNING: Setting vector function in Visualization toolbox to value from Fieldlines toolbox!" << endl; + vssolution.vecfunction = vssolution.fieldlines_vecfunction; + } + + // reset visoptions.scalfunction and visoptions.vecfunction if not avialable + if ( vssolution.scalfunction == -1 && strcmp (scalname, "none") != 0) + Tcl_SetVar ( interp, "::visoptions.scalfunction", "none", TCL_GLOBAL_ONLY ); + if ( vssolution.vecfunction == -1 && strcmp (vecname, "none") != 0) + Tcl_SetVar ( interp, "::visoptions.vecfunction", "none", TCL_GLOBAL_ONLY ); + + tcl_const char * evalname = + Tcl_GetVar (interp, "::visoptions.evaluate", TCL_GLOBAL_ONLY); + + if (strcmp(evalname, "abs") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS; + if (strcmp(evalname, "abstens") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS_TENSOR; + if (strcmp(evalname, "mises") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MISES; + if (strcmp(evalname, "main") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MAIN; + + vssolution.gridsize = + atoi (Tcl_GetVar (interp, "::visoptions.gridsize", TCL_GLOBAL_ONLY)); + + vssolution.xoffset = + atof (Tcl_GetVar (interp, "::visoptions.xoffset", TCL_GLOBAL_ONLY)); + + // cout << "x-offset:" << vssolution.xoffset << endl; + + vssolution.yoffset = + atof (Tcl_GetVar (interp, "::visoptions.yoffset", TCL_GLOBAL_ONLY)); + + vssolution.autoscale = + atoi (Tcl_GetVar (interp, "::visoptions.autoscale", TCL_GLOBAL_ONLY)); + + + /* + vssolution.linear_colors = + atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); + */ + vssolution.logscale = + atoi (Tcl_GetVar (interp, "::visoptions.logscale", TCL_GLOBAL_ONLY)); + + vssolution.mminval = + atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); + vssolution.mmaxval = + atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); + + vssolution.showclipsolution = + atoi (Tcl_GetVar (interp, "::visoptions.showclipsolution", TCL_GLOBAL_ONLY)); + vssolution.showsurfacesolution = + atoi (Tcl_GetVar (interp, "::visoptions.showsurfacesolution", TCL_GLOBAL_ONLY)); + vssolution.lineartexture = + atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); + vssolution.numtexturecols = + atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); + + vssolution.multidimcomponent = + atoi (Tcl_GetVar (interp, "::visoptions.multidimcomponent", TCL_GLOBAL_ONLY)); + + vssolution.drawpointcurves = + atoi (Tcl_GetVar (interp, "::visoptions.drawpointcurves", TCL_GLOBAL_ONLY)); + + vssolution.draw_fieldlines = + atoi (Tcl_GetVar (interp, "::visoptions.drawfieldlines", TCL_GLOBAL_ONLY)); + vssolution.num_fieldlines = + atoi (Tcl_GetVar (interp, "::visoptions.numfieldlines", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_randomstart = + atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesrandomstart", TCL_GLOBAL_ONLY)); + + vssolution.fieldlines_reltolerance = + atof (Tcl_GetVar (interp, "::visoptions.fieldlinestolerance", TCL_GLOBAL_ONLY)); + + if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), + "euler") == 0) + vssolution.fieldlines_rktype = 0; + else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), + "eulercauchy") == 0) + vssolution.fieldlines_rktype = 1; + else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), + "simpson") == 0) + vssolution.fieldlines_rktype = 2; + else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), + "crungekutta") == 0) + vssolution.fieldlines_rktype = 3; + + + vssolution.fieldlines_rellength = + atof (Tcl_GetVar (interp, "::visoptions.fieldlineslength", TCL_GLOBAL_ONLY)); + + vssolution.fieldlines_maxpoints = + atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesmaxpoints", TCL_GLOBAL_ONLY)); + + vssolution.fieldlines_relthickness = + atof (Tcl_GetVar (interp, "::visoptions.fieldlinesthickness", TCL_GLOBAL_ONLY)); + + + vssolution.fieldlines_fixedphase = + (atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesonlyonephase", TCL_GLOBAL_ONLY)) != 0); + + if(vssolution.fieldlines_fixedphase) + vssolution.fieldlines_phase = + atof (Tcl_GetVar (interp, "::visoptions.fieldlinesphase", TCL_GLOBAL_ONLY)); + + + if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), + "box") == 0) + vssolution.fieldlines_startarea = 0; + else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), + "file") == 0) + vssolution.fieldlines_startarea = 1; + else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), + "face") == 0) + vssolution.fieldlines_startarea = 2; + + + if (vssolution.fieldlines_startarea == 0) + { + vssolution.fieldlines_startarea_parameter.SetSize(6); + vssolution.fieldlines_startarea_parameter[0] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1x", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_startarea_parameter[1] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1y", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_startarea_parameter[2] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1z", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_startarea_parameter[3] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2x", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_startarea_parameter[4] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2y", TCL_GLOBAL_ONLY)); + vssolution.fieldlines_startarea_parameter[5] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2z", TCL_GLOBAL_ONLY)); + } + else if (vssolution.fieldlines_startarea == 1) + { + vssolution.fieldlines_filename = Tcl_GetVar (interp, "::visoptions.fieldlinesfilename", TCL_GLOBAL_ONLY); + } + else if (vssolution.fieldlines_startarea == 2) + { + vssolution.fieldlines_startface = atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesstartface", TCL_GLOBAL_ONLY)); + } + + + vssolution.deform = + atoi (Tcl_GetVar (interp, "::visoptions.deformation", TCL_GLOBAL_ONLY)); + vssolution.scaledeform = + atof (Tcl_GetVar (interp, "::visoptions.scaledeform1", TCL_GLOBAL_ONLY)) * + atof (Tcl_GetVar (interp, "::visoptions.scaledeform2", TCL_GLOBAL_ONLY)); + + + if (atoi (Tcl_GetVar (interp, "::visoptions.isolines", TCL_GLOBAL_ONLY))) + vssolution.numisolines = atoi (Tcl_GetVar (interp, "::visoptions.numiso", TCL_GLOBAL_ONLY)); + else + vssolution.numisolines = 0; + vssolution.draw_isosurface = + atoi (Tcl_GetVar (interp, "::visoptions.isosurf", TCL_GLOBAL_ONLY)); + + vssolution.SetSubdivision(atoi (Tcl_GetVar (interp, "::visoptions.subdivisions", TCL_GLOBAL_ONLY))); + + vssolution.UpdateSolutionTimeStamp(); + } + + if (strcmp (argv[1], "parametersrange") == 0) + { + vssolution.invcolor = + atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); + vssolution.mminval = + atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); + vssolution.mmaxval = + atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); + vssolution.lineartexture = + atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); + vssolution.numtexturecols = + atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); + + if (vssolution.usetexture == 0 || vssolution.logscale) + vssolution.UpdateSolutionTimeStamp(); + } + + + if (argc >= 3 && strcmp (argv[1], "time") == 0) + { + vssolution.time = double (atoi (argv[2])) / 1000; + + vssolution.timetimestamp = NextTimeStamp(); + cout << "\rtime = " << vssolution.time << " " << flush; + } + + } + + + vsmesh.SetClippingPlane (); // for computing parameters + vssolution.SetClippingPlane (); // for computing parameters + glDisable(GL_CLIP_PLANE0); + +#ifdef PARALLELGL + vsmesh.Broadcast (); +#endif + + + return TCL_OK; + } + + int Ng_Vis_Field (ClientData clientData, + Tcl_Interp * interp, + int argc, tcl_const char *argv[]) + { + auto mesh = vssolution.GetMesh(); + int i; + char buf[1000]; + buf[0] = 0; + + if (argc >= 2) + { + if (strcmp (argv[1], "setfield") == 0) + { + if (argc < 3) + return TCL_ERROR; + + for (i = 0; i < vssolution.GetNSolData(); i++) + if (strcmp (vssolution.GetSolData(i)->name, argv[2]) == 0) + { + cout << "found soldata " << i << endl; + } + } + + if (strcmp (argv[1], "getnfieldnames") == 0) + { + sprintf (buf, "%d", vssolution.GetNSolData()); + } + + if (strcmp (argv[1], "getfieldname") == 0) + { + sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name); + } + + if (strcmp (argv[1], "iscomplex") == 0) + { + sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->iscomplex); + } + + if (strcmp (argv[1], "getfieldcomponents") == 0) + { + sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->components); + } + + + if (strcmp (argv[1], "getfieldnames") == 0) + { + for (i = 0; i < vssolution.GetNSolData(); i++) + { + strcat (buf, vssolution.GetSolData(i)->name); + strcat (buf, " "); + } + strcat (buf, "var1 var2 var3"); + Tcl_SetResult (interp, buf, TCL_STATIC); + } + + if (strcmp (argv[1], "setcomponent") == 0) + { + cout << "set component " << argv[2] << endl; + } + + if (strcmp (argv[1], "getactivefield") == 0) + { + sprintf (buf, "1"); + } + + if (strcmp (argv[1], "getdimension") == 0) + { + sprintf (buf, "%d", mesh->GetDimension()); + } + } + + Tcl_SetResult (interp, buf, TCL_STATIC); + return TCL_OK; + } + + + extern "C" int Ng_Vis_Init (Tcl_Interp * interp); + + int Ng_Vis_Init (Tcl_Interp * interp) + { + Tcl_CreateCommand (interp, "Ng_Vis_Set", Ng_Vis_Set, + (ClientData)NULL, + (Tcl_CmdDeleteProc*) NULL); + + Tcl_CreateCommand (interp, "Ng_Vis_Field", Ng_Vis_Field, + (ClientData)NULL, + (Tcl_CmdDeleteProc*) NULL); + + + return TCL_OK; + } + + + + +} + diff --git a/libsrc/visualization/vsfieldlines.cpp b/libsrc/visualization/vsfieldlines.cpp index e3ed1dbd..b37410de 100644 --- a/libsrc/visualization/vsfieldlines.cpp +++ b/libsrc/visualization/vsfieldlines.cpp @@ -1,7 +1,7 @@ #ifndef NOTCL #include -#include "incvis.hpp" +#include #include diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index a8035923..6ac3bfb8 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -1,7 +1,4 @@ -#ifndef NOTCL #include -#include "incvis.hpp" - #include #include @@ -4553,367 +4550,6 @@ namespace netgen #endif - int Ng_Vis_Set (ClientData clientData, - Tcl_Interp * interp, - int argc, tcl_const char *argv[]) - - { - if (argc >= 2) - { - if (strcmp (argv[1], "parameters") == 0) - { - vssolution.imag_part = - atoi (Tcl_GetVar (interp, "::visoptions.imaginary", TCL_GLOBAL_ONLY)); - vssolution.usetexture = - atoi (Tcl_GetVar (interp, "::visoptions.usetexture", TCL_GLOBAL_ONLY)); - if (atoi (Tcl_GetVar (interp, "::visoptions.redrawperiodic", TCL_GLOBAL_ONLY))) - vssolution.usetexture = 2; - - vssolution.invcolor = - atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); - - vssolution.clipsolution = 0; - - if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), - "scal") == 0) - vssolution.clipsolution = 1; - if (strcmp (Tcl_GetVar (interp, "::visoptions.clipsolution", TCL_GLOBAL_ONLY), - "vec") == 0) - vssolution.clipsolution = 2; - - tcl_const char * scalname = - Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); - tcl_const char * vecname = - Tcl_GetVar (interp, "::visoptions.vecfunction", TCL_GLOBAL_ONLY); - tcl_const char * fieldlines_vecname = - Tcl_GetVar (interp, "::visoptions.fieldlinesvecfunction", TCL_GLOBAL_ONLY); - - - vssolution.scalfunction = -1; - vssolution.vecfunction = -1; - vssolution.fieldlines_vecfunction = -1; - - int pointpos; // SZ - const char * pch = strchr(scalname,':'); - pointpos = int(pch-scalname+1); - - for (int i = 0; i < vssolution.soldata.Size(); i++) - { - if ( (strlen (vssolution.soldata[i]->name) == size_t(pointpos-1)) && - (strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) ) - { - vssolution.scalfunction = i; - vssolution.scalcomp = atoi (scalname + pointpos); - if ( vssolution.scalcomp > vssolution.soldata[i]->components ) - vssolution.scalcomp = 1; - char newscalname[100]; - for ( int ii = 0; ii < pointpos; ii++ ) - newscalname[ii] = scalname[ii]; - newscalname[pointpos] = ':'; - sprintf (newscalname+pointpos, "%i", vssolution.scalcomp); - - if (strcmp (scalname, newscalname) != 0) - Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY ); - scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); - } - if (strcmp (vssolution.soldata[i]->name, vecname) == 0) - vssolution.vecfunction = i; - - if (strcmp (vssolution.soldata[i]->name, fieldlines_vecname) == 0) - vssolution.fieldlines_vecfunction = i; - } - - if(vssolution.fieldlines_vecfunction != -1 && - vssolution.vecfunction == -1) - { - //cout << "WARNING: Setting vector function in Visualization toolbox to value from Fieldlines toolbox!" << endl; - vssolution.vecfunction = vssolution.fieldlines_vecfunction; - } - - // reset visoptions.scalfunction and visoptions.vecfunction if not avialable - if ( vssolution.scalfunction == -1 && strcmp (scalname, "none") != 0) - Tcl_SetVar ( interp, "::visoptions.scalfunction", "none", TCL_GLOBAL_ONLY ); - if ( vssolution.vecfunction == -1 && strcmp (vecname, "none") != 0) - Tcl_SetVar ( interp, "::visoptions.vecfunction", "none", TCL_GLOBAL_ONLY ); - - tcl_const char * evalname = - Tcl_GetVar (interp, "::visoptions.evaluate", TCL_GLOBAL_ONLY); - - if (strcmp(evalname, "abs") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS; - if (strcmp(evalname, "abstens") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_ABS_TENSOR; - if (strcmp(evalname, "mises") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MISES; - if (strcmp(evalname, "main") == 0) vssolution.evalfunc = VisualSceneSolution::FUNC_MAIN; - - vssolution.gridsize = - atoi (Tcl_GetVar (interp, "::visoptions.gridsize", TCL_GLOBAL_ONLY)); - - vssolution.xoffset = - atof (Tcl_GetVar (interp, "::visoptions.xoffset", TCL_GLOBAL_ONLY)); - - // cout << "x-offset:" << vssolution.xoffset << endl; - - vssolution.yoffset = - atof (Tcl_GetVar (interp, "::visoptions.yoffset", TCL_GLOBAL_ONLY)); - - vssolution.autoscale = - atoi (Tcl_GetVar (interp, "::visoptions.autoscale", TCL_GLOBAL_ONLY)); - - - /* - vssolution.linear_colors = - atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); - */ - vssolution.logscale = - atoi (Tcl_GetVar (interp, "::visoptions.logscale", TCL_GLOBAL_ONLY)); - - vssolution.mminval = - atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); - vssolution.mmaxval = - atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); - - vssolution.showclipsolution = - atoi (Tcl_GetVar (interp, "::visoptions.showclipsolution", TCL_GLOBAL_ONLY)); - vssolution.showsurfacesolution = - atoi (Tcl_GetVar (interp, "::visoptions.showsurfacesolution", TCL_GLOBAL_ONLY)); - vssolution.lineartexture = - atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); - vssolution.numtexturecols = - atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); - - vssolution.multidimcomponent = - atoi (Tcl_GetVar (interp, "::visoptions.multidimcomponent", TCL_GLOBAL_ONLY)); - - vssolution.drawpointcurves = - atoi (Tcl_GetVar (interp, "::visoptions.drawpointcurves", TCL_GLOBAL_ONLY)); - - vssolution.draw_fieldlines = - atoi (Tcl_GetVar (interp, "::visoptions.drawfieldlines", TCL_GLOBAL_ONLY)); - vssolution.num_fieldlines = - atoi (Tcl_GetVar (interp, "::visoptions.numfieldlines", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_randomstart = - atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesrandomstart", TCL_GLOBAL_ONLY)); - - vssolution.fieldlines_reltolerance = - atof (Tcl_GetVar (interp, "::visoptions.fieldlinestolerance", TCL_GLOBAL_ONLY)); - - if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), - "euler") == 0) - vssolution.fieldlines_rktype = 0; - else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), - "eulercauchy") == 0) - vssolution.fieldlines_rktype = 1; - else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), - "simpson") == 0) - vssolution.fieldlines_rktype = 2; - else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesrktype", TCL_GLOBAL_ONLY), - "crungekutta") == 0) - vssolution.fieldlines_rktype = 3; - - - vssolution.fieldlines_rellength = - atof (Tcl_GetVar (interp, "::visoptions.fieldlineslength", TCL_GLOBAL_ONLY)); - - vssolution.fieldlines_maxpoints = - atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesmaxpoints", TCL_GLOBAL_ONLY)); - - vssolution.fieldlines_relthickness = - atof (Tcl_GetVar (interp, "::visoptions.fieldlinesthickness", TCL_GLOBAL_ONLY)); - - - vssolution.fieldlines_fixedphase = - (atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesonlyonephase", TCL_GLOBAL_ONLY)) != 0); - - if(vssolution.fieldlines_fixedphase) - vssolution.fieldlines_phase = - atof (Tcl_GetVar (interp, "::visoptions.fieldlinesphase", TCL_GLOBAL_ONLY)); - - - if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), - "box") == 0) - vssolution.fieldlines_startarea = 0; - else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), - "file") == 0) - vssolution.fieldlines_startarea = 1; - else if (strcmp (Tcl_GetVar (interp, "::visoptions.fieldlinesstartarea", TCL_GLOBAL_ONLY), - "face") == 0) - vssolution.fieldlines_startarea = 2; - - - if (vssolution.fieldlines_startarea == 0) - { - vssolution.fieldlines_startarea_parameter.SetSize(6); - vssolution.fieldlines_startarea_parameter[0] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1x", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_startarea_parameter[1] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1y", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_startarea_parameter[2] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap1z", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_startarea_parameter[3] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2x", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_startarea_parameter[4] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2y", TCL_GLOBAL_ONLY)); - vssolution.fieldlines_startarea_parameter[5] = atof (Tcl_GetVar (interp, "::visoptions.fieldlinesstartareap2z", TCL_GLOBAL_ONLY)); - } - else if (vssolution.fieldlines_startarea == 1) - { - vssolution.fieldlines_filename = Tcl_GetVar (interp, "::visoptions.fieldlinesfilename", TCL_GLOBAL_ONLY); - } - else if (vssolution.fieldlines_startarea == 2) - { - vssolution.fieldlines_startface = atoi (Tcl_GetVar (interp, "::visoptions.fieldlinesstartface", TCL_GLOBAL_ONLY)); - } - - - vssolution.deform = - atoi (Tcl_GetVar (interp, "::visoptions.deformation", TCL_GLOBAL_ONLY)); - vssolution.scaledeform = - atof (Tcl_GetVar (interp, "::visoptions.scaledeform1", TCL_GLOBAL_ONLY)) * - atof (Tcl_GetVar (interp, "::visoptions.scaledeform2", TCL_GLOBAL_ONLY)); - - - if (atoi (Tcl_GetVar (interp, "::visoptions.isolines", TCL_GLOBAL_ONLY))) - vssolution.numisolines = atoi (Tcl_GetVar (interp, "::visoptions.numiso", TCL_GLOBAL_ONLY)); - else - vssolution.numisolines = 0; - vssolution.draw_isosurface = - atoi (Tcl_GetVar (interp, "::visoptions.isosurf", TCL_GLOBAL_ONLY)); - - vssolution.SetSubdivision(atoi (Tcl_GetVar (interp, "::visoptions.subdivisions", TCL_GLOBAL_ONLY))); - - vssolution.UpdateSolutionTimeStamp(); - } - - if (strcmp (argv[1], "parametersrange") == 0) - { - vssolution.invcolor = - atoi (Tcl_GetVar (interp, "::visoptions.invcolor", TCL_GLOBAL_ONLY)); - vssolution.mminval = - atof (Tcl_GetVar (interp, "::visoptions.mminval", TCL_GLOBAL_ONLY)); - vssolution.mmaxval = - atof (Tcl_GetVar (interp, "::visoptions.mmaxval", TCL_GLOBAL_ONLY)); - vssolution.lineartexture = - atoi (Tcl_GetVar (interp, "::visoptions.lineartexture", TCL_GLOBAL_ONLY)); - vssolution.numtexturecols = - atoi (Tcl_GetVar (interp, "::visoptions.numtexturecols", TCL_GLOBAL_ONLY)); - - if (vssolution.usetexture == 0 || vssolution.logscale) - vssolution.UpdateSolutionTimeStamp(); - } - - - if (argc >= 3 && strcmp (argv[1], "time") == 0) - { - vssolution.time = double (atoi (argv[2])) / 1000; - - vssolution.timetimestamp = NextTimeStamp(); - cout << "\rtime = " << vssolution.time << " " << flush; - } - - } - - - vsmesh.SetClippingPlane (); // for computing parameters - vssolution.SetClippingPlane (); // for computing parameters - glDisable(GL_CLIP_PLANE0); - -#ifdef PARALLELGL - vsmesh.Broadcast (); -#endif - - - return TCL_OK; - } - - int Ng_Vis_Field (ClientData clientData, - Tcl_Interp * interp, - int argc, tcl_const char *argv[]) - { - auto mesh = vssolution.GetMesh(); - int i; - char buf[1000]; - buf[0] = 0; - - if (argc >= 2) - { - if (strcmp (argv[1], "setfield") == 0) - { - if (argc < 3) - return TCL_ERROR; - - for (i = 0; i < vssolution.GetNSolData(); i++) - if (strcmp (vssolution.GetSolData(i)->name, argv[2]) == 0) - { - cout << "found soldata " << i << endl; - } - } - - if (strcmp (argv[1], "getnfieldnames") == 0) - { - sprintf (buf, "%d", vssolution.GetNSolData()); - } - - if (strcmp (argv[1], "getfieldname") == 0) - { - sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name); - } - - if (strcmp (argv[1], "iscomplex") == 0) - { - sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->iscomplex); - } - - if (strcmp (argv[1], "getfieldcomponents") == 0) - { - sprintf (buf, "%d", vssolution.GetSolData(atoi(argv[2])-1)->components); - } - - - if (strcmp (argv[1], "getfieldnames") == 0) - { - for (i = 0; i < vssolution.GetNSolData(); i++) - { - strcat (buf, vssolution.GetSolData(i)->name); - strcat (buf, " "); - } - strcat (buf, "var1 var2 var3"); - Tcl_SetResult (interp, buf, TCL_STATIC); - } - - if (strcmp (argv[1], "setcomponent") == 0) - { - cout << "set component " << argv[2] << endl; - } - - if (strcmp (argv[1], "getactivefield") == 0) - { - sprintf (buf, "1"); - } - - if (strcmp (argv[1], "getdimension") == 0) - { - sprintf (buf, "%d", mesh->GetDimension()); - } - } - - Tcl_SetResult (interp, buf, TCL_STATIC); - return TCL_OK; - } - - - extern "C" int Ng_Vis_Init (Tcl_Interp * interp); - - int Ng_Vis_Init (Tcl_Interp * interp) - { - Tcl_CreateCommand (interp, "Ng_Vis_Set", Ng_Vis_Set, - (ClientData)NULL, - (Tcl_CmdDeleteProc*) NULL); - - Tcl_CreateCommand (interp, "Ng_Vis_Field", Ng_Vis_Field, - (ClientData)NULL, - (Tcl_CmdDeleteProc*) NULL); - - - return TCL_OK; - } - - - - void Ng_ClearSolutionData () @@ -4966,6 +4602,4 @@ void Ng_SetSolutionData (Ng_SolutionData * soldata) #endif } -// } -#endif // NOTCL diff --git a/libsrc/visualization/vssolution.hpp b/libsrc/visualization/vssolution.hpp index a4e789b5..a7b5b20a 100644 --- a/libsrc/visualization/vssolution.hpp +++ b/libsrc/visualization/vssolution.hpp @@ -1,22 +1,25 @@ #ifndef FILE_VSSOLUTION #define FILE_VSSOLUTION + +typedef void * ClientData; +struct Tcl_Interp; + + namespace netgen { -#ifndef SMALLLIB -#ifndef NOTCL - extern void ImportSolution (const char * filename); -extern int Ng_Vis_Set (ClientData clientData, - Tcl_Interp * interp, - int argc, tcl_const char *argv[]); -#endif -#endif class FieldLineCalc; + + extern int Ng_Vis_Set (ClientData clientData, + Tcl_Interp * interp, + int argc, const char *argv[]); + + class VisualSceneSolution : public VisualScene { @@ -324,15 +327,10 @@ public: // 0 .. non, 1 .. scalar, 2 .. complex void SetTextureMode (int texturemode) const; -#ifndef SMALLLIB -#ifndef NOTCL friend int Ng_Vis_Set (ClientData clientData, - Tcl_Interp * interp, - int argc, tcl_const char *argv[]); - -#endif -#endif + Tcl_Interp * interp, + int argc, const char *argv[]); #ifdef PARALLELGL diff --git a/ng/demoview.cpp b/ng/demoview.cpp index 77da7b0e..81fb329f 100644 --- a/ng/demoview.cpp +++ b/ng/demoview.cpp @@ -16,7 +16,7 @@ #include #include #include -#include "incvis.hpp" +#include "inctcl.hpp" #include namespace netgen { diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index 20578617..849c99e1 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -4,7 +4,7 @@ */ #include -#include "incvis.hpp" +#include #include #ifdef NGPYTHON diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index f4ae3493..a6d64928 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -11,7 +11,7 @@ The interface between the GUI and the netgen library #include -#include +#include #include @@ -1860,7 +1860,7 @@ namespace netgen static int fontbase = 0; - void MyOpenGLText (const char * text) + void MyOpenGLText_GUI (const char * text) { if (nodisplay) return; @@ -1877,7 +1877,8 @@ namespace netgen return; fontbase = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 ); - + Set_OpenGLText_Callback (&MyOpenGLText_GUI); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp index 7186f132..1e7268f6 100644 --- a/nglib/nglib.cpp +++ b/nglib/nglib.cpp @@ -1222,20 +1222,22 @@ namespace netgen void Render() { ; } - void MyOpenGLText (const char * text) { ; } } // End of namespace netgen - void Ng_Redraw () { ; } void Ng_ClearSolutionData () { ; } +/* void Ng_SetSolutionData (Ng_SolutionData * soldata) { delete soldata->solclass; } void Ng_InitSolutionData (Ng_SolutionData * soldata) { ; } +*/ + + #ifdef NG_PYTHON