vis-library

This commit is contained in:
Joachim Schoeberl 2014-10-06 09:57:44 +00:00
parent be8fa7286f
commit c216e3f3ed
20 changed files with 249 additions and 99 deletions

View File

@ -2,4 +2,4 @@ AM_CPPFLAGS =
METASOURCES = AUTO METASOURCES = AUTO
SUBDIRS = general gprim linalg include meshing interface csg geom2d occ stlgeom visualization SUBDIRS = general gprim linalg include meshing visualization interface csg geom2d occ stlgeom

View File

@ -26,7 +26,7 @@ if NGGUI
lib_LTLIBRARIES += libcsgvis.la lib_LTLIBRARIES += libcsgvis.la
libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
libcsgvis_la_LIBADD = libcsg.la libcsgvis_la_LIBADD = libcsg.la $(top_builddir)/libsrc/visualization/libvisual.la
endif endif
# $(top_builddir)/libsrc/geom2d/libgeom2d.la # $(top_builddir)/libsrc/geom2d/libgeom2d.la

View File

@ -24,8 +24,8 @@ namespace netgen
static VisualSceneGeometry vsgeom; static VisualSceneGeometry vsgeom;
char * err_needscsgeometry = (char*) "This operation needs an CSG geometry"; char * err_needscsgeometry = (char*) "This operation needs an CSG geometry";
extern char * err_needsmesh; char * err_needsmesh = (char*) "This operation needs a mesh";
extern char * err_jobrunning; char * err_jobrunning = (char*) "Meshing Job already running";

View File

@ -483,11 +483,20 @@ namespace netgen
CalcTransformationMatrices(); CalcTransformationMatrices();
} }
} }
void Hi () { cout << "hi from csgvis" << endl; }
#ifdef NG_PYTHON
#include <boost/python.hpp>
namespace bp = boost::python;
BOOST_PYTHON_MODULE(libcsgvis)
{
cout << "exporting csg-vis " << endl;
bp::def("hi", &Hi);
}
#endif

View File

@ -10,6 +10,7 @@ libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \
wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp
libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la \
$(top_builddir)/libsrc/visualization/libvisual.la
# libinterface_la_LDFLAGS = -rdynamic # libinterface_la_LDFLAGS = -rdynamic

View File

@ -9,7 +9,8 @@
#endif #endif
#include "nginterface.h" #include "nginterface.h"
#include "../visualization/soldata.hpp" // #include "../visualization/soldata.hpp"
#include <visual.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
@ -160,6 +161,8 @@ void Ng_LoadMeshFromStream ( istream & input )
{ {
mesh.reset (new Mesh()); mesh.reset (new Mesh());
mesh -> Load(input); mesh -> Load(input);
vssolution.SetMesh(mesh);
vsmesh.SetMesh(mesh);
for (int i = 0; i < geometryregister.Size(); i++) for (int i = 0; i < geometryregister.Size(); i++)
{ {

View File

@ -16,10 +16,11 @@ namespace netgen
ostream * mycout = &cout; ostream * mycout = &cout;
ostream * myerr = &cerr; ostream * myerr = &cerr;
// some functions (visualization) still need a global mesh
shared_ptr<Mesh> mesh;
shared_ptr<NetgenGeometry> ng_geometry;
// Flags parameters; // Flags parameters;
int silentflag = 0; int silentflag = 0;
int testmode = 0; int testmode = 0;

View File

@ -7,7 +7,9 @@ AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL
METASOURCES = AUTO METASOURCES = AUTO
if NGGUI if NGGUI
noinst_LTLIBRARIES = libvisual.la lib_LTLIBRARIES = libvisual.la
libvisual_la_LIBADD = $(LIBGLU) $(TCL_LIB_SPEC)
endif endif

View File

@ -16,7 +16,7 @@
namespace netgen namespace netgen
{ {
extern shared_ptr<Mesh> mesh;
void ImportSolution (const char * filename) void ImportSolution (const char * filename)
{ {
@ -56,7 +56,7 @@ void ImportSolution (const char * filename)
flags.PrintFlags (*testout); flags.PrintFlags (*testout);
(*testout) << "done" << endl; (*testout) << "done" << endl;
size = int(flags.GetNumFlag ("size", Ng_GetNP())); size = int(flags.GetNumFlag ("size", mesh->GetNP())); // Ng_GetNP()));
comps = int(flags.GetNumFlag ("components", 1)); comps = int(flags.GetNumFlag ("components", 1));
type = flags.GetStringFlag ("type", "nodal"); type = flags.GetStringFlag ("type", "nodal");
order = int(flags.GetNumFlag ("order", 1)); order = int(flags.GetNumFlag ("order", 1));

View File

@ -1,3 +1,6 @@
namespace netgen
{
class VisualSceneMeshDoctor : public VisualScene class VisualSceneMeshDoctor : public VisualScene
{ {
@ -35,3 +38,5 @@ public:
extern MeshDoctorParameters meshdoctor; extern MeshDoctorParameters meshdoctor;
}

View File

@ -35,6 +35,13 @@ namespace netgen
#endif #endif
*/ */
void MyOpenGLText (const char * text)
{
cout << "MyOpenGLText: " << text << endl;
}
// texture for color decoding // texture for color decoding
// GLubyte * VisualScene :: colortexture = NULL; // GLubyte * VisualScene :: colortexture = NULL;
GLuint VisualScene :: coltexname = 1; GLuint VisualScene :: coltexname = 1;

View File

@ -5,16 +5,6 @@
namespace netgen namespace netgen
{ {
/*
extern void InitDrawMesh ();
extern void DrawMesh ();
extern void MouseMove(int oldx, int oldy,
int newx, int newy,
char mode);
extern void Render ();
*/
class VisualScene class VisualScene
{ {
@ -44,11 +34,9 @@ namespace netgen
static int selecttimestamp; static int selecttimestamp;
public: public:
static int viewport[4]; static int viewport[4];
// static GLubyte * colortexture;
static GLuint coltexname; static GLuint coltexname;
static int ntexcols; static int ntexcols;
// static bool linear_colors;
int invcolor; int invcolor;
@ -168,6 +156,8 @@ namespace netgen
double minh, maxh; // for meshsize coloring double minh, maxh; // for meshsize coloring
weak_ptr<Mesh> wp_mesh;
public: public:
VisualSceneMesh (); VisualSceneMesh ();
virtual ~VisualSceneMesh (); virtual ~VisualSceneMesh ();
@ -176,6 +166,9 @@ namespace netgen
virtual void DrawScene (); virtual void DrawScene ();
virtual void MouseDblClick (int px, int py); virtual void MouseDblClick (int px, int py);
void SetMesh (shared_ptr<Mesh> mesh) { wp_mesh = mesh; }
shared_ptr<Mesh> GetMesh () { return shared_ptr<Mesh>(wp_mesh); }
void SetMouseEventHandler (MouseEventHandler * handler) void SetMouseEventHandler (MouseEventHandler * handler)
{ user_me_handler = handler; } { user_me_handler = handler; }
@ -207,6 +200,7 @@ namespace netgen
void BuildDomainSurfList(); void BuildDomainSurfList();
}; };
extern VisualSceneMesh vsmesh;
class VisualSceneSpecPoints : public VisualScene class VisualSceneSpecPoints : public VisualScene

View File

@ -24,12 +24,7 @@ Visualization
#include "mvdraw.hpp" #include "mvdraw.hpp"
#include <complex> #include <complex>
namespace netgen
{
#include "vssolution.hpp" #include "vssolution.hpp"
#include "meshdoc.hpp" #include "meshdoc.hpp"
}
#endif #endif

View File

@ -15,7 +15,7 @@
namespace netgen namespace netgen
{ {
extern shared_ptr<Mesh> mesh; // extern shared_ptr<Mesh> mesh;
@ -442,6 +442,9 @@ namespace netgen
void VisualSceneSolution :: BuildFieldLinesFromBox(Array<Point3d> & startpoints) void VisualSceneSolution :: BuildFieldLinesFromBox(Array<Point3d> & startpoints)
{ {
shared_ptr<Mesh> mesh (wp_mesh);
if (!mesh) return;
if(fieldlines_startarea_parameter[0] > fieldlines_startarea_parameter[3] || if(fieldlines_startarea_parameter[0] > fieldlines_startarea_parameter[3] ||
fieldlines_startarea_parameter[1] > fieldlines_startarea_parameter[4] || fieldlines_startarea_parameter[1] > fieldlines_startarea_parameter[4] ||
fieldlines_startarea_parameter[2] > fieldlines_startarea_parameter[5]) fieldlines_startarea_parameter[2] > fieldlines_startarea_parameter[5])
@ -469,6 +472,10 @@ namespace netgen
void VisualSceneSolution :: BuildFieldLinesFromLine(Array<Point3d> & startpoints) void VisualSceneSolution :: BuildFieldLinesFromLine(Array<Point3d> & startpoints)
{ {
shared_ptr<Mesh> mesh (wp_mesh);
if (!mesh) return;
for (int i = 1; i <= startpoints.Size(); i++) for (int i = 1; i <= startpoints.Size(); i++)
{ {
double s = double (rand()) / RAND_MAX; double s = double (rand()) / RAND_MAX;
@ -484,6 +491,9 @@ namespace netgen
void VisualSceneSolution :: BuildFieldLinesFromFile(Array<Point3d> & startpoints) void VisualSceneSolution :: BuildFieldLinesFromFile(Array<Point3d> & startpoints)
{ {
shared_ptr<Mesh> mesh (wp_mesh);
if (!mesh) return;
ifstream * infile; ifstream * infile;
infile = new ifstream(fieldlines_filename.c_str()); infile = new ifstream(fieldlines_filename.c_str());
@ -563,6 +573,9 @@ namespace netgen
void VisualSceneSolution :: BuildFieldLinesFromFace(Array<Point3d> & startpoints) void VisualSceneSolution :: BuildFieldLinesFromFace(Array<Point3d> & startpoints)
{ {
shared_ptr<Mesh> mesh (wp_mesh);
if (!mesh) return;
Array<SurfaceElementIndex> elements_2d; Array<SurfaceElementIndex> elements_2d;
//cout << "fieldlines_startface " << fieldlines_startface << endl; //cout << "fieldlines_startface " << fieldlines_startface << endl;
@ -647,6 +660,9 @@ namespace netgen
void VisualSceneSolution :: BuildFieldLinesPlot () void VisualSceneSolution :: BuildFieldLinesPlot ()
{ {
shared_ptr<Mesh> mesh (wp_mesh);
if (!mesh) return;
if (fieldlinestimestamp >= solutiontimestamp) if (fieldlinestimestamp >= solutiontimestamp)
return; return;
fieldlinestimestamp = solutiontimestamp; fieldlinestimestamp = solutiontimestamp;

View File

@ -15,7 +15,7 @@
namespace netgen namespace netgen
{ {
extern shared_ptr<Mesh> mesh; // extern shared_ptr<Mesh> mesh;
extern NetgenGeometry * ng_geometry; extern NetgenGeometry * ng_geometry;
VisualSceneMesh vsmesh; VisualSceneMesh vsmesh;
@ -73,6 +73,10 @@ namespace netgen
void VisualSceneMesh :: DrawScene () void VisualSceneMesh :: DrawScene ()
{ {
try
{
shared_ptr<Mesh> mesh(wp_mesh);
if (!mesh) if (!mesh)
{ {
VisualScene::DrawScene(); VisualScene::DrawScene();
@ -301,12 +305,25 @@ namespace netgen
} }
glFinish(); glFinish();
}
catch (bad_weak_ptr e)
{
cout << "don't have a mesh to visualize" << endl;
VisualScene::DrawScene();
}
} }
void VisualSceneMesh :: BuildScene (int zoomall) void VisualSceneMesh :: BuildScene (int zoomall)
{ {
if (!mesh) try
{
shared_ptr<Mesh> mesh(wp_mesh);
if (!mesh)
{ {
VisualScene::BuildScene (zoomall); VisualScene::BuildScene (zoomall);
return; return;
@ -880,6 +897,13 @@ namespace netgen
} }
vstimestamp = meshtimestamp; vstimestamp = meshtimestamp;
}
catch (bad_weak_ptr e)
{
cout << "vsmesh::buildscene: don't have a mesh to visualize" << endl;
VisualScene::BuildScene (zoomall);
}
} }
@ -887,6 +911,8 @@ namespace netgen
void VisualSceneMesh :: BuildFilledList (bool names) void VisualSceneMesh :: BuildFilledList (bool names)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
static int timer = NgProfiler::CreateTimer ("Mesh::BuildFilledList"); static int timer = NgProfiler::CreateTimer ("Mesh::BuildFilledList");
NgProfiler::RegionTimer reg (timer); NgProfiler::RegionTimer reg (timer);
@ -1275,6 +1301,8 @@ namespace netgen
void VisualSceneMesh :: BuildLineList() void VisualSceneMesh :: BuildLineList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
static int timer = NgProfiler::CreateTimer ("Mesh::BuildLineList"); static int timer = NgProfiler::CreateTimer ("Mesh::BuildLineList");
NgProfiler::RegionTimer reg (timer); NgProfiler::RegionTimer reg (timer);
@ -1555,6 +1583,8 @@ namespace netgen
void VisualSceneMesh :: BuildEdgeList() void VisualSceneMesh :: BuildEdgeList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (!lock) if (!lock)
{ {
lock = new NgLock (mesh->Mutex()); lock = new NgLock (mesh->Mutex());
@ -1730,6 +1760,8 @@ namespace netgen
void VisualSceneMesh :: BuildTetList() void VisualSceneMesh :: BuildTetList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (tettimestamp > mesh->GetTimeStamp () && if (tettimestamp > mesh->GetTimeStamp () &&
tettimestamp > vispar.clipping.timestamp ) tettimestamp > vispar.clipping.timestamp )
return; return;
@ -2078,6 +2110,8 @@ namespace netgen
void VisualSceneMesh :: BuildPrismList() void VisualSceneMesh :: BuildPrismList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (prismtimestamp > mesh->GetTimeStamp () && if (prismtimestamp > mesh->GetTimeStamp () &&
prismtimestamp > vispar.clipping.timestamp ) prismtimestamp > vispar.clipping.timestamp )
return; return;
@ -2406,6 +2440,8 @@ namespace netgen
void VisualSceneMesh :: BuildHexList() void VisualSceneMesh :: BuildHexList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (hextimestamp > mesh->GetTimeStamp () && if (hextimestamp > mesh->GetTimeStamp () &&
hextimestamp > vispar.clipping.timestamp ) hextimestamp > vispar.clipping.timestamp )
return; return;
@ -2614,6 +2650,8 @@ namespace netgen
void VisualSceneMesh :: BuildPyramidList() void VisualSceneMesh :: BuildPyramidList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (pyramidtimestamp > mesh->GetTimeStamp () && if (pyramidtimestamp > mesh->GetTimeStamp () &&
pyramidtimestamp > vispar.clipping.timestamp ) pyramidtimestamp > vispar.clipping.timestamp )
return; return;
@ -2968,6 +3006,8 @@ namespace netgen
void VisualSceneMesh :: BuildDomainSurfList() void VisualSceneMesh :: BuildDomainSurfList()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (domainsurflist) if (domainsurflist)
glDeleteLists (domainsurflist, 1); glDeleteLists (domainsurflist, 1);
@ -3084,6 +3124,8 @@ namespace netgen
void VisualSceneMesh :: MouseDblClick (int px, int py) void VisualSceneMesh :: MouseDblClick (int px, int py)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
BuildFilledList (true); BuildFilledList (true);
MouseDblClickSelect(px,py,clipplane,backcolor,transformationmat,center,rad, MouseDblClickSelect(px,py,clipplane,backcolor,transformationmat,center,rad,
@ -3302,6 +3344,8 @@ namespace netgen
int & selelement, int & selface, int & seledge, int & selpoint, int & selelement, int & selface, int & seledge, int & selpoint,
int & selpoint2, int & locpi) int & selpoint2, int & locpi)
{ {
auto mesh = vsmesh.GetMesh();
int i, hits; int i, hits;
// select surface triangle by mouse click // select surface triangle by mouse click

View File

@ -14,9 +14,12 @@
#include <limits> #include <limits>
namespace netgen namespace netgen
{ {
extern shared_ptr<Mesh> mesh;
VisualSceneSolution vssolution;
// extern shared_ptr<Mesh> mesh;
extern VisualSceneMesh vsmesh; extern VisualSceneMesh vsmesh;
@ -60,7 +63,7 @@ namespace netgen
surface_vector_timestamp = GetTimeStamp(); surface_vector_timestamp = GetTimeStamp();
isosurface_timestamp = GetTimeStamp(); isosurface_timestamp = GetTimeStamp();
timetimestamp = GetTimeStamp(); timetimestamp = GetTimeStamp();
AddVisualizationScene ("solution", &vssolution); // AddVisualizationScene ("solution", &vssolution);
} }
VisualSceneSolution :: ~VisualSceneSolution () VisualSceneSolution :: ~VisualSceneSolution ()
@ -70,6 +73,8 @@ namespace netgen
void VisualSceneSolution :: AddSolutionData (SolData * sd) void VisualSceneSolution :: AddSolutionData (SolData * sd)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
NgLock meshlock1 (mesh->MajorMutex(), 1); NgLock meshlock1 (mesh->MajorMutex(), 1);
int funcnr = -1; int funcnr = -1;
for (int i = 0; i < soldata.Size(); i++) for (int i = 0; i < soldata.Size(); i++)
@ -152,6 +157,8 @@ namespace netgen
void VisualSceneSolution :: SaveSolutionData (const char * filename) void VisualSceneSolution :: SaveSolutionData (const char * filename)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
PrintMessage (1, "Write solution data to file ", filename); PrintMessage (1, "Write solution data to file ", filename);
@ -339,6 +346,10 @@ namespace netgen
void VisualSceneSolution :: DrawScene () void VisualSceneSolution :: DrawScene ()
{ {
try
{
shared_ptr<Mesh> mesh(wp_mesh);
if (!mesh) if (!mesh)
{ {
VisualScene::DrawScene(); VisualScene::DrawScene();
@ -600,6 +611,12 @@ namespace netgen
// delete lock; // delete lock;
// mem_lock.UnLock(); // mem_lock.UnLock();
}
catch (bad_weak_ptr e)
{
cout << "don't have a mesh to visualize" << endl;
VisualScene::DrawScene();
}
} }
@ -678,6 +695,10 @@ namespace netgen
void VisualSceneSolution :: BuildScene (int zoomall) void VisualSceneSolution :: BuildScene (int zoomall)
{ {
try
{
shared_ptr<Mesh> mesh(wp_mesh);
if (!mesh) if (!mesh)
{ {
VisualScene::BuildScene (zoomall); VisualScene::BuildScene (zoomall);
@ -1090,10 +1111,18 @@ namespace netgen
} }
clipplanetimestamp = max2 (vispar.clipping.timestamp, solutiontimestamp); clipplanetimestamp = max2 (vispar.clipping.timestamp, solutiontimestamp);
}
catch (bad_weak_ptr e)
{
cout << "vssolution::buildscene: don't have a mesh to visualize" << endl;
VisualScene::BuildScene (zoomall);
}
} }
void VisualSceneSolution :: Draw1DElements () void VisualSceneSolution :: Draw1DElements ()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (element1dlist) if (element1dlist)
glDeleteLists (element1dlist, 1); glDeleteLists (element1dlist, 1);
@ -1144,6 +1173,8 @@ namespace netgen
void VisualSceneSolution :: DrawSurfaceElements () void VisualSceneSolution :: DrawSurfaceElements ()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
static int timer = NgProfiler::CreateTimer ("Solution::DrawSurfaceElements"); static int timer = NgProfiler::CreateTimer ("Solution::DrawSurfaceElements");
NgProfiler::RegionTimer reg (timer); NgProfiler::RegionTimer reg (timer);
@ -1585,6 +1616,8 @@ namespace netgen
void VisualSceneSolution :: DrawSurfaceElementLines () void VisualSceneSolution :: DrawSurfaceElementLines ()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
#ifdef PARALLELGL #ifdef PARALLELGL
if (id == 0 && ntasks > 1) if (id == 0 && ntasks > 1)
{ {
@ -1692,6 +1725,8 @@ namespace netgen
const SolData * vsol, const SolData * vsol,
int comp) int comp)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
if (!draw_isosurface) return; if (!draw_isosurface) return;
if (!sol) return; if (!sol) return;
@ -1941,6 +1976,8 @@ namespace netgen
const Point<3> & pmin, const Point<3> & pmax, const Point<3> & pmin, const Point<3> & pmax,
const int sei, const SolData * vsol) const int sei, const SolData * vsol)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
int dir,dir1,dir2; int dir,dir1,dir2;
double s,t; double s,t;
@ -2051,6 +2088,8 @@ namespace netgen
void VisualSceneSolution :: DrawSurfaceVectors () void VisualSceneSolution :: DrawSurfaceVectors ()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
SurfaceElementIndex sei; SurfaceElementIndex sei;
const SolData * vsol = NULL; const SolData * vsol = NULL;
@ -2385,6 +2424,8 @@ namespace netgen
void VisualSceneSolution :: void VisualSceneSolution ::
GetMinMax (int funcnr, int comp, double & minv, double & maxv) const GetMinMax (int funcnr, int comp, double & minv, double & maxv) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
static int timer1 = NgProfiler::CreateTimer ("getminmax, vol"); static int timer1 = NgProfiler::CreateTimer ("getminmax, vol");
static int timer2 = NgProfiler::CreateTimer ("getminmax, surf"); static int timer2 = NgProfiler::CreateTimer ("getminmax, surf");
@ -2532,6 +2573,7 @@ namespace netgen
const double xref[], const double x[], const double dxdxref[], const double xref[], const double x[], const double dxdxref[],
int comp, double & val) const int comp, double & val) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
double lam1 = xref[0]; double lam1 = xref[0];
double lam2 = xref[1]; double lam2 = xref[1];
@ -2704,6 +2746,7 @@ namespace netgen
double lam1, double lam2, double lam3, double lam1, double lam2, double lam3,
int comp, double & val) const int comp, double & val) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
val = 0; val = 0;
bool ok = 0; bool ok = 0;
@ -2874,6 +2917,8 @@ namespace netgen
double lam1, double lam2, double lam3, double lam1, double lam2, double lam3,
int comp, complex<double> & val) const int comp, complex<double> & val) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
val = 0.0; val = 0.0;
bool ok = 0; bool ok = 0;
@ -3117,6 +3162,8 @@ namespace netgen
double lam1, double lam2, double lam1, double lam2,
int comp, double & val) const int comp, double & val) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
bool ok; bool ok;
if (comp == 0) if (comp == 0)
{ {
@ -3349,6 +3396,8 @@ namespace netgen
const double xref[], const double x[], const double dxdxref[], const double xref[], const double x[], const double dxdxref[],
int comp, double & val) const int comp, double & val) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
double lam1 = xref[0], lam2 = xref[1]; double lam1 = xref[0], lam2 = xref[1];
bool ok; bool ok;
@ -3596,6 +3645,8 @@ namespace netgen
Vec<3> VisualSceneSolution :: Vec<3> VisualSceneSolution ::
GetSurfDeformation (SurfaceElementIndex elnr, int facetnr, double lam1, double lam2) const GetSurfDeformation (SurfaceElementIndex elnr, int facetnr, double lam1, double lam2) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
Vec<3> def; Vec<3> def;
if (deform && vecfunction != -1) if (deform && vecfunction != -1)
{ {
@ -3621,6 +3672,8 @@ namespace netgen
void VisualSceneSolution :: GetPointDeformation (int pnum, Point<3> & p, void VisualSceneSolution :: GetPointDeformation (int pnum, Point<3> & p,
SurfaceElementIndex elnr) const SurfaceElementIndex elnr) const
{ {
shared_ptr<Mesh> mesh(wp_mesh);
p = mesh->Point (pnum+1); p = mesh->Point (pnum+1);
if (deform && vecfunction != -1) if (deform && vecfunction != -1)
{ {
@ -3659,6 +3712,8 @@ namespace netgen
void VisualSceneSolution :: GetClippingPlaneTrigs (Array<ClipPlaneTrig> & trigs, void VisualSceneSolution :: GetClippingPlaneTrigs (Array<ClipPlaneTrig> & trigs,
Array<ClipPlanePoint> & pts) Array<ClipPlanePoint> & pts)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
static int timer_vals = NgProfiler::CreateTimer ("ClipPlaneTrigs - vertex values"); static int timer_vals = NgProfiler::CreateTimer ("ClipPlaneTrigs - vertex values");
static int timer1 = NgProfiler::CreateTimer ("ClipPlaneTrigs1"); static int timer1 = NgProfiler::CreateTimer ("ClipPlaneTrigs1");
// static int timer1a = NgProfiler::CreateTimer ("ClipPlaneTrigs1a"); // static int timer1a = NgProfiler::CreateTimer ("ClipPlaneTrigs1a");
@ -4000,6 +4055,8 @@ namespace netgen
void VisualSceneSolution :: GetClippingPlaneGrid (Array<ClipPlanePoint> & pts) void VisualSceneSolution :: GetClippingPlaneGrid (Array<ClipPlanePoint> & pts)
{ {
shared_ptr<Mesh> mesh(wp_mesh);
Vec3d n(clipplane[0], clipplane[1], clipplane[2]); Vec3d n(clipplane[0], clipplane[1], clipplane[2]);
double mu = -clipplane[3] / n.Length2(); double mu = -clipplane[3] / n.Length2();
@ -4056,6 +4113,8 @@ namespace netgen
void VisualSceneSolution :: DrawClipPlaneTrigs () void VisualSceneSolution :: DrawClipPlaneTrigs ()
{ {
shared_ptr<Mesh> mesh(wp_mesh);
#ifdef PARALLELGL #ifdef PARALLELGL
if (id == 0 && ntasks > 1) if (id == 0 && ntasks > 1)
@ -4764,6 +4823,7 @@ namespace netgen
Tcl_Interp * interp, Tcl_Interp * interp,
int argc, tcl_const char *argv[]) int argc, tcl_const char *argv[])
{ {
auto mesh = vssolution.GetMesh();
int i; int i;
char buf[1000]; char buf[1000];
buf[0] = 0; buf[0] = 0;
@ -4850,6 +4910,62 @@ namespace netgen
return TCL_OK; return TCL_OK;
} }
void Ng_ClearSolutionData ()
{
#ifdef OPENGL
// if (nodisplay) return;
vssolution.ClearSolutionData();
#endif
}
} }
#include "../include/nginterface.h"
// namespace netgen
// {
void Ng_InitSolutionData (Ng_SolutionData * soldata)
{
soldata -> name = NULL;
soldata -> data = NULL;
soldata -> components = 1;
soldata -> dist = 1;
soldata -> order = 1;
soldata -> iscomplex = 0;
soldata -> draw_surface = 1;
soldata -> draw_volume = 1;
soldata -> soltype = NG_SOLUTION_NODAL;
soldata -> solclass = 0;
}
void Ng_SetSolutionData (Ng_SolutionData * soldata)
{
#ifdef OPENGL
// if (nodisplay) return;
// vssolution.ClearSolutionData ();
netgen::VisualSceneSolution::SolData * vss = new netgen::VisualSceneSolution::SolData;
vss->name = new char[strlen (soldata->name)+1];
strcpy (vss->name, soldata->name);
vss->data = soldata->data;
vss->components = soldata->components;
vss->dist = soldata->dist;
vss->order = soldata->order;
vss->iscomplex = bool(soldata->iscomplex);
vss->draw_surface = soldata->draw_surface;
vss->draw_volume = soldata->draw_volume;
vss->soltype = netgen::VisualSceneSolution::SolType (soldata->soltype);
vss->solclass = soldata->solclass;
netgen::vssolution.AddSolutionData (vss);
#endif
}
// }
#endif // NOTCL #endif // NOTCL

View File

@ -1,7 +1,8 @@
#ifndef FILE_VSSOLUTION #ifndef FILE_VSSOLUTION
#define FILE_VSSOLUTION #define FILE_VSSOLUTION
namespace netgen
{
#ifndef SMALLLIB #ifndef SMALLLIB
#ifndef NOTCL #ifndef NOTCL
@ -173,7 +174,7 @@ private:
void BuildFieldLinesFromFace(Array<Point3d> & startpoints); void BuildFieldLinesFromFace(Array<Point3d> & startpoints);
void BuildFieldLinesFromBox(Array<Point3d> & startpoints); void BuildFieldLinesFromBox(Array<Point3d> & startpoints);
void BuildFieldLinesFromLine(Array<Point3d> & startpoints); void BuildFieldLinesFromLine(Array<Point3d> & startpoints);
weak_ptr<Mesh> wp_mesh;
public: public:
VisualSceneSolution (); VisualSceneSolution ();
virtual ~VisualSceneSolution (); virtual ~VisualSceneSolution ();
@ -182,6 +183,9 @@ public:
virtual void DrawScene (); virtual void DrawScene ();
virtual void MouseDblClick (int px, int py); virtual void MouseDblClick (int px, int py);
void SetMesh (shared_ptr<Mesh> amesh) { wp_mesh = amesh; }
shared_ptr<Mesh> GetMesh () { return shared_ptr<Mesh>(wp_mesh); }
void BuildFieldLinesPlot (); void BuildFieldLinesPlot ();
void AddSolutionData (SolData * soldata); void AddSolutionData (SolData * soldata);
@ -437,7 +441,7 @@ public:
extern VisualSceneSolution vssolution; extern VisualSceneSolution vssolution;
}
#endif #endif

View File

@ -111,13 +111,10 @@ namespace netgen
static VisualScene vscross; static VisualScene vscross;
extern VisualSceneSurfaceMeshing vssurfacemeshing; extern VisualSceneSurfaceMeshing vssurfacemeshing;
extern VisualSceneMesh vsmesh;
extern VisualSceneMeshDoctor vsmeshdoc; extern VisualSceneMeshDoctor vsmeshdoc;
static VisualSceneSpecPoints vsspecpoints; static VisualSceneSpecPoints vsspecpoints;
VisualSceneSolution vssolution;
VisualScene *vs = &vscross; VisualScene *vs = &vscross;
@ -1279,6 +1276,7 @@ namespace netgen
mesh = shared_ptr<Mesh> (hmesh); mesh = shared_ptr<Mesh> (hmesh);
*/ */
mesh = make_shared<Mesh> (); mesh = make_shared<Mesh> ();
vsmesh.SetMesh (mesh);
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend); int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend);
// int res = ng_geometry -> GenerateMesh (mesh.Ptr(), mparam, perfstepsstart, perfstepsend); // int res = ng_geometry -> GenerateMesh (mesh.Ptr(), mparam, perfstepsstart, perfstepsend);
@ -1845,7 +1843,7 @@ namespace netgen
// if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing; // if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing;
if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints; if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints;
// if (strcmp (vismode, "solution") == 0) vs = &vssolution; if (strcmp (vismode, "solution") == 0) vs = &vssolution;
} }
} }
@ -2737,44 +2735,6 @@ namespace netgen
using namespace netgen; using namespace netgen;
void Ng_InitSolutionData (Ng_SolutionData * soldata)
{
soldata -> name = NULL;
soldata -> data = NULL;
soldata -> components = 1;
soldata -> dist = 1;
soldata -> order = 1;
soldata -> iscomplex = 0;
soldata -> draw_surface = 1;
soldata -> draw_volume = 1;
soldata -> soltype = NG_SOLUTION_NODAL;
soldata -> solclass = 0;
}
void Ng_SetSolutionData (Ng_SolutionData * soldata)
{
#ifdef OPENGL
if (nodisplay)
return;
// vssolution.ClearSolutionData ();
VisualSceneSolution::SolData * vss = new VisualSceneSolution::SolData;
vss->name = new char[strlen (soldata->name)+1];
strcpy (vss->name, soldata->name);
vss->data = soldata->data;
vss->components = soldata->components;
vss->dist = soldata->dist;
vss->order = soldata->order;
vss->iscomplex = bool(soldata->iscomplex);
vss->draw_surface = soldata->draw_surface;
vss->draw_volume = soldata->draw_volume;
vss->soltype = VisualSceneSolution::SolType (soldata->soltype);
vss->solclass = soldata->solclass;
vssolution.AddSolutionData (vss);
#endif
}
void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler) void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler)
{ {
@ -2786,14 +2746,6 @@ void Ng_SetUserVisualizationObject (netgen::UserVisualizationObject * vis)
vssolution.AddUserVisualizationObject (vis); vssolution.AddUserVisualizationObject (vis);
} }
void Ng_ClearSolutionData ()
{
#ifdef OPENGL
if (nodisplay)
return;
vssolution.ClearSolutionData();
#endif
}

View File

@ -1221,10 +1221,9 @@ namespace netgen
void Render() void Render() { ; }
{ void MyOpenGLText (const char * text) { ; }
;
}
} // End of namespace netgen } // End of namespace netgen

View File

@ -2,7 +2,9 @@ from netgen import __platform
if __platform.startswith('linux') or __platform.startswith('darwin'): if __platform.startswith('linux') or __platform.startswith('darwin'):
# Linux or Mac OS X # Linux or Mac OS X
from libcsg.csg import * from libcsg.csg import *
from libmesh.meshing import * from libcsgvis import *
import libmesh.meshing
# from libmesh.meshing import *
if __platform.startswith('win'): if __platform.startswith('win'):
# Windows # Windows
from nglib.csg import * from nglib.csg import *