From f069933fc337fa8f090a6fb66305eec000f158d2 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 7 Mar 2011 16:38:43 +0000 Subject: [PATCH] nglib / nginterface interfaces --- libsrc/include/nginterface.h | 6 ++ libsrc/interface/Makefile.am | 5 +- ng/Makefile.am | 4 +- ng/ngpkg.cpp | 158 ++++++++++++++++++++++++++++++++++- nglib/nglib.cpp | 11 +++ 5 files changed, 176 insertions(+), 8 deletions(-) diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index e120f57c..0524151d 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -215,6 +215,8 @@ extern "C" { DLL_HEADER const NG_EDGE * Ng_ME_GetEdges (NG_ELEMENT_TYPE et); DLL_HEADER const NG_FACE * Ng_ME_GetFaces (NG_ELEMENT_TYPE et); + DLL_HEADER void Ng_UpdateTopology(); + DLL_HEADER int Ng_GetNEdges(); DLL_HEADER int Ng_GetNFaces(); @@ -391,6 +393,10 @@ extern "C" { // if qualityloss is not equal to NULL at input, a (1-based) list of qualitylosses (due to projection) // is saved in *qualityloss, its size is the return value DLL_HEADER int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss); + + typedef void * Ng_Mesh; + DLL_HEADER Ng_Mesh Ng_SelectMesh (Ng_Mesh mesh); + #ifdef __cplusplus } #endif diff --git a/libsrc/interface/Makefile.am b/libsrc/interface/Makefile.am index ec316261..b8f52e2d 100644 --- a/libsrc/interface/Makefile.am +++ b/libsrc/interface/Makefile.am @@ -2,8 +2,9 @@ noinst_HEADERS = writeuser.hpp AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface $(TCL_INCLUDES) -DOPENGL METASOURCES = AUTO -noinst_LTLIBRARIES = libinterface.la -libinterface_la_SOURCES = read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \ +lib_LTLIBRARIES = libinterface.la +libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \ + read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \ writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp \ writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp \ wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp diff --git a/ng/Makefile.am b/ng/Makefile.am index 46ba7df1..96aca130 100644 --- a/ng/Makefile.am +++ b/ng/Makefile.am @@ -3,8 +3,8 @@ include_HEADERS = AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES) bin_PROGRAMS = netgen -netgen_SOURCES = demoview.cpp ngappinit.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp ngpkg.cpp demoview.hpp parallelfunc.hpp togl_1_7.h - +netgen_SOURCES = demoview.cpp ngappinit.cpp onetcl.cpp parallelfunc.cpp parallelinterface.cpp ngpkg.cpp demoview.hpp parallelfunc.hpp togl_1_7.h +# nginterface.cpp nginterface_v2.cpp netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/csg/libcsgvis.la \ diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index c9a1ebce..175432b9 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -31,9 +31,8 @@ The interface between the GUI and the netgen library extern bool nodisplay; - -// #include -extern "C" void RunParallel ( void * (*fun)(void *), void * in); +#include +// extern "C" void RunParallel ( void * (*fun)(void *), void * in); @@ -2637,6 +2636,157 @@ namespace netgen #endif + // from ng_interface + void Ng_SetVisualizationParameter (const char * name, const char * value) + { + // #ifdef OPENGL + // #ifndef NOTCL + char buf[100]; + sprintf (buf, "visoptions.%s", name); + if (printmessage_importance>0) + { + cout << "name = " << name << ", value = " << value << endl; + cout << "set tcl-variable " << buf << " to " << value << endl; + } + Tcl_SetVar (tcl_interp, buf, const_cast (value), 0); + Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;"); + // #endif + // #endif + } +} + + +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 + // 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_ClearSolutionData () +{ +#ifdef OPENGL + vssolution.ClearSolutionData(); +#endif +} + + + +namespace netgen +{ + extern void Render (); +} + +void Ng_Redraw () +{ +#ifdef OPENGL + extern bool nodisplay; // he: global in ngappinit.cpp + if (!nodisplay) + { + netgen::vssolution.UpdateSolutionTimeStamp(); + Render(); + } +#endif +} + + + + + +namespace netgen +{ + + +int firsttime = 1; +int animcnt = 0; +void PlayAnimFile(const char* name, int speed, int maxcnt) +{ + //extern Mesh * mesh; + + /* + if (mesh.Ptr()) mesh->DeleteMesh(); + if (!mesh.Ptr()) mesh = new Mesh(); + */ + mesh.Reset (new Mesh()); + + int ne, np, i; + + char str[80]; + char str2[80]; + + //int tend = 5000; + // for (ti = 1; ti <= tend; ti++) + //{ + int rti = (animcnt%(maxcnt-1)) + 1; + animcnt+=speed; + + sprintf(str2,"%05i.sol",rti); + strcpy(str,"mbssol/"); + strcat(str,name); + strcat(str,str2); + + if (printmessage_importance>0) + cout << "read file '" << str << "'" << endl; + + ifstream infile(str); + infile >> ne; + for (i = 1; i <= ne; i++) + { + int j; + Element2d tri(TRIG); + tri.SetIndex(1); //faceind + + for (j = 1; j <= 3; j++) + infile >> tri.PNum(j); + + infile >> np; + for (i = 1; i <= np; i++) + { + Point3d p; + infile >> p.X() >> p.Y() >> p.Z(); + if (firsttime) + mesh->AddPoint (p); + else + mesh->Point(i) = Point<3> (p); + } + + //firsttime = 0; + Ng_Redraw(); + } +} + + int Ng_SetVisParameters (ClientData clientData, @@ -2916,7 +3066,7 @@ namespace netgen // extern "C" int Ng_occ_Init (Tcl_Interp * interp); #endif - // extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp); + // extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp); // int main_Eero (ClientData clientData, // Tcl_Interp * interp, diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp index 694f9ccb..8a3b493b 100644 --- a/nglib/nglib.cpp +++ b/nglib/nglib.cpp @@ -22,6 +22,8 @@ #include #endif +#include + namespace netgen { extern void MeshFromSpline2D (SplineGeometry2d & geometry, @@ -1208,3 +1210,12 @@ namespace netgen } } // End of namespace netgen + + + +void Ng_Redraw () { ; } +void Ng_ClearSolutionData () { ; } +void Ng_SetSolutionData (Ng_SolutionData * soldata) { ; } +void Ng_InitSolutionData (Ng_SolutionData * soldata) { ; } + +