2009-01-13 04:40:13 +05:00
|
|
|
/*
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
The interface between the GUI and the netgen library
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <mystdlib.h>
|
|
|
|
#include <myadt.hpp>
|
|
|
|
#include <linalg.hpp>
|
|
|
|
|
2009-03-15 17:25:09 +05:00
|
|
|
#include <meshing.hpp>
|
|
|
|
|
2009-08-25 14:44:03 +06:00
|
|
|
|
2014-10-08 18:46:25 +06:00
|
|
|
#include <inctcl.hpp>
|
2009-01-13 04:40:13 +05:00
|
|
|
#include <visual.hpp>
|
|
|
|
|
2009-03-15 17:25:09 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
#include <csg.hpp>
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef SOCKETS
|
|
|
|
#include "../libsrc/sockets/sockets.hpp"
|
|
|
|
#include "../libsrc/sockets/socketmanager.hpp"
|
|
|
|
#endif
|
|
|
|
|
2021-10-13 21:24:05 +05:00
|
|
|
#include "../libsrc/general/gzstream.h"
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2009-01-20 14:08:01 +05:00
|
|
|
// to be sure to include the 'right' togl-version
|
2016-02-08 19:53:16 +05:00
|
|
|
#include "Togl2.1/togl.h"
|
2018-05-24 00:32:17 +05:00
|
|
|
// EXTERN int Togl_PixelScale (const Togl * togl);
|
2018-05-24 00:14:49 +05:00
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
#include "fonts.hpp"
|
2009-01-20 14:08:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
extern bool nodisplay;
|
|
|
|
|
2011-03-07 21:38:43 +05:00
|
|
|
#include <nginterface.h>
|
2009-05-09 15:48:16 +06:00
|
|
|
|
|
|
|
|
2016-07-10 21:07:36 +05:00
|
|
|
#include "../libsrc/interface/writeuser.hpp"
|
2009-05-09 15:48:16 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
namespace netgen
|
|
|
|
{
|
2015-10-19 13:08:30 +05:00
|
|
|
DLL_HEADER extern MeshingParameters mparam;
|
|
|
|
DLL_HEADER extern void ImportSolution2(const char * filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
#include "demoview.hpp"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ACIS
|
|
|
|
#include "ng_acis.hpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-04-05 21:10:33 +06:00
|
|
|
#ifdef JPEGLIB
|
2009-01-13 04:40:13 +05:00
|
|
|
#include <jpeglib.h>
|
2009-04-05 21:10:33 +06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FFMPEG
|
2017-02-03 19:28:59 +05:00
|
|
|
#include "encoding.hpp"
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NGSOLVE
|
|
|
|
extern "C" void NGSolve_Exit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// extern void * ngsolve_handle;
|
|
|
|
|
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
extern Flags parameters;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2012-07-06 13:49:05 +06:00
|
|
|
/*
|
2009-01-13 04:40:13 +05:00
|
|
|
NetgenOutStream operator<< ( ostream & ost, Imp imp )
|
|
|
|
{
|
|
|
|
return ( NetgenOutStream ( &ost, imp ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
NetgenOutStream operator<< ( ostream & ost, Proc proc )
|
|
|
|
{
|
|
|
|
return ( NetgenOutStream ( &ost, proc ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetgenOutStream operator<< ( ostream & ost, Procs & procs )
|
|
|
|
{
|
|
|
|
return ( NetgenOutStream ( &ost, procs ) );
|
|
|
|
}
|
2012-07-06 13:49:05 +06:00
|
|
|
*/
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2015-10-19 13:08:30 +05:00
|
|
|
DLL_HEADER extern std::shared_ptr<NetgenGeometry> ng_geometry;
|
|
|
|
DLL_HEADER extern std::shared_ptr<Mesh> mesh;
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_Interp * tcl_interp;
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef SOCKETS
|
|
|
|
AutoPtr<ClientSocket> clientsocket;
|
|
|
|
ServerSocketManager serversocketmanager;
|
2019-07-09 13:39:16 +05:00
|
|
|
//NgArray< AutoPtr < ServerInfo > > servers;
|
|
|
|
NgArray< ServerInfo* > servers;
|
2009-01-13 04:40:13 +05:00
|
|
|
AutoPtr<ServerSocketUserNetgen> serversocketusernetgen;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// visualization scenes, pointer vs selects which one is drawn:
|
|
|
|
|
2015-10-19 13:08:30 +05:00
|
|
|
DLL_HEADER extern VisualSceneSurfaceMeshing vssurfacemeshing;
|
|
|
|
DLL_HEADER extern VisualSceneMeshDoctor vsmeshdoc;
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
static VisualSceneSpecPoints vsspecpoints;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
2019-12-10 16:18:53 +05:00
|
|
|
DLL_HEADER extern VisualScene *visual_scene;
|
|
|
|
DLL_HEADER extern VisualScene visual_scene_cross;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-09 13:57:43 +06:00
|
|
|
extern char * err_needsmesh;// = (char*) "This operation needs a mesh";
|
|
|
|
extern char * err_jobrunning;// = (char*) "Meshing Job already running";
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-09 16:22:16 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
static clock_t starttimea;
|
2014-08-30 06:15:59 +06:00
|
|
|
void ResetTime2 ()
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
starttimea = clock();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef SMALLLIB
|
2015-10-19 13:08:30 +05:00
|
|
|
double GetTime2 ()
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
return double(clock() - starttimea) / CLOCKS_PER_SEC;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// file handling ..
|
|
|
|
int Ng_New (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2009-01-31 03:12:17 +05:00
|
|
|
if (strcmp (argv[1], "mesh") == 0)
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh.reset();
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
if (strcmp (argv[1], "geom") == 0)
|
|
|
|
{
|
2013-02-27 19:49:17 +06:00
|
|
|
/*
|
2011-01-11 01:18:01 +05:00
|
|
|
delete ng_geometry;
|
|
|
|
ng_geometry = new NetgenGeometry;
|
2013-02-27 19:49:17 +06:00
|
|
|
*/
|
2014-09-08 21:21:09 +06:00
|
|
|
ng_geometry = make_shared<NetgenGeometry>();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ImportMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[]);
|
|
|
|
|
|
|
|
int Ng_LoadMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2022-02-17 20:52:07 +05:00
|
|
|
auto filename = filesystem::u8path(argv[1]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2022-02-17 20:52:07 +05:00
|
|
|
if (filename.string().find(".vol") == string::npos)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
return Ng_ImportMesh(clientData,interp,argc,argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintMessage (1, "load mesh from file ", filename);
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh = make_shared<Mesh>();
|
2009-01-13 04:40:13 +05:00
|
|
|
try
|
|
|
|
{
|
2022-02-17 20:52:07 +05:00
|
|
|
mesh -> Load(filename);
|
2015-01-09 02:17:42 +05:00
|
|
|
SetGlobalMesh (mesh);
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2022-04-29 15:23:40 +05:00
|
|
|
#ifdef PARALLEL_NETGEN
|
2012-07-05 17:05:33 +06:00
|
|
|
MyMPI_SendCmd ("mesh");
|
|
|
|
mesh -> Distribute();
|
|
|
|
#endif
|
2022-02-17 20:52:07 +05:00
|
|
|
if(mesh->GetGeometry())
|
|
|
|
ng_geometry = mesh->GetGeometry();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
catch (NgException e)
|
|
|
|
{
|
|
|
|
PrintMessage (3, e.What());
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintMessage (2, mesh->GetNP(), " Points, ",
|
|
|
|
mesh->GetNE(), " Elements.");
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SaveMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2013-02-27 23:29:12 +06:00
|
|
|
string filename (argv[1]);
|
2009-10-28 04:04:42 +05:00
|
|
|
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
2013-02-27 23:29:12 +06:00
|
|
|
|
|
|
|
ostream * outfile;
|
|
|
|
if (filename.substr (filename.length()-3, 3) == ".gz")
|
|
|
|
outfile = new ogzstream (filename.c_str());
|
|
|
|
else
|
|
|
|
outfile = new ofstream (filename.c_str());
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2013-02-27 23:29:12 +06:00
|
|
|
mesh -> Save (*outfile);
|
2016-05-06 10:30:59 +05:00
|
|
|
// *outfile << endl << endl << "endmesh" << endl << endl;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2016-05-06 10:30:59 +05:00
|
|
|
if (ng_geometry && !mesh->GetGeometry())
|
2013-02-27 23:29:12 +06:00
|
|
|
ng_geometry -> SaveToMeshFile (*outfile);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2013-02-27 23:29:12 +06:00
|
|
|
delete outfile;
|
2009-10-28 04:04:42 +05:00
|
|
|
PrintMessage (1, "Save mesh to file .... DONE!");
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_MergeMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
string filename (argv[1]);
|
|
|
|
|
|
|
|
PrintMessage (1, "merge with mesh from file ", filename);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry.get());
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
//mesh -> Merge (filename);
|
|
|
|
ifstream infile(filename.c_str());
|
|
|
|
const int offset = (geometry) ? geometry->GetNSurf() : 0;
|
|
|
|
mesh -> Merge(infile,offset);
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
string auxstring;
|
|
|
|
if(infile.good())
|
|
|
|
{
|
|
|
|
infile >> auxstring;
|
2014-04-28 13:10:21 +06:00
|
|
|
if(geometry && auxstring == "csgsurfaces")
|
2009-01-13 04:40:13 +05:00
|
|
|
geometry -> LoadSurfaces(infile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NgException e)
|
|
|
|
{
|
|
|
|
PrintMessage (3, e.What());
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintMessage (2, mesh->GetNP(), " Points, ",
|
|
|
|
mesh->GetNSE(), " Surface Elements.");
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-09 23:41:02 +05:00
|
|
|
int Ng_GetImportFormats (ClientData clientData,
|
2019-08-04 14:12:19 +05:00
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2023-10-09 23:41:02 +05:00
|
|
|
ostringstream fstr;
|
|
|
|
UserFormatRegister::IterateFormats([&](auto & entry) {
|
|
|
|
fstr << "{ {" << entry.format << "} {" << entry.extensions[0];
|
|
|
|
for(auto ext : entry.extensions.Range(1, entry.extensions.Size()))
|
|
|
|
fstr << ' ' << ext;
|
|
|
|
fstr << "} }\n";
|
|
|
|
}, true, false);
|
2019-08-04 14:12:19 +05:00
|
|
|
|
2023-10-09 23:41:02 +05:00
|
|
|
Tcl_SetResult (interp, const_cast<char*>(fstr.str().c_str()), TCL_VOLATILE);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_GetExportFormats (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2019-08-04 14:12:19 +05:00
|
|
|
ostringstream fstr;
|
2023-10-09 23:41:02 +05:00
|
|
|
UserFormatRegister::IterateFormats([&](auto & entry) {
|
|
|
|
fstr << "{ {" << entry.format << "} {" << entry.extensions[0];
|
|
|
|
for(auto ext : entry.extensions.Range(1, entry.extensions.Size()))
|
|
|
|
fstr << ' ' << ext;
|
|
|
|
fstr << "} }\n";
|
|
|
|
}, false, true);
|
2019-08-04 14:12:19 +05:00
|
|
|
|
|
|
|
Tcl_SetResult (interp, const_cast<char*>(fstr.str().c_str()), TCL_VOLATILE);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
int Ng_ExportMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
string filename (argv[1]);
|
|
|
|
string filetype (argv[2]);
|
2009-10-28 04:04:42 +05:00
|
|
|
PrintMessage (1, "Export mesh to file ", filename, ".... Please Wait!");
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
// CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
|
2017-07-25 01:26:18 +05:00
|
|
|
if (WriteUserFormat (filetype, *mesh, /* *ng_geometry, */ filename))
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
ostringstream ost;
|
|
|
|
ost << "Sorry, nothing known about file format " << filetype << endl;
|
|
|
|
Tcl_SetResult (interp, (char*)ost.str().c_str(), TCL_VOLATILE);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-10-28 04:04:42 +05:00
|
|
|
PrintMessage (1, "Export mesh to file .... DONE!");
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ImportMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
const string filename (argv[1]);
|
2023-10-09 23:41:02 +05:00
|
|
|
const string format (argv[2]);
|
2009-01-13 04:40:13 +05:00
|
|
|
PrintMessage (1, "import mesh from ", filename);
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh = make_shared<Mesh>();
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2023-10-09 23:41:02 +05:00
|
|
|
ReadUserFormat (*mesh, filename, format);
|
2009-01-13 04:40:13 +05:00
|
|
|
PrintMessage (2, mesh->GetNP(), " Points, ",
|
|
|
|
mesh->GetNE(), " Elements.");
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2019-09-20 14:31:52 +05:00
|
|
|
SetGlobalMesh (mesh);
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->SetGlobalH (mparam.maxh);
|
2011-07-25 14:40:23 +06:00
|
|
|
mesh->CalcLocalH(mparam.grading);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ImportSolution (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * filename = argv[1];
|
|
|
|
PrintMessage (1, "Import solution from file ", filename);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2015-10-19 13:08:30 +05:00
|
|
|
ImportSolution2 (filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static DemoView * demoview = 0;
|
|
|
|
int Ng_ShowDemo (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
const char * filename = argv[1];
|
|
|
|
PrintMessage (1, "Show demo ", filename);
|
|
|
|
demoview = new DemoView (filename);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_DemoSetTime (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
cout << "demosettime, time = " << argv[1] << endl;
|
|
|
|
int result = -1;
|
|
|
|
|
|
|
|
static char strminusone[] = "-1";
|
|
|
|
static char str0[] = "0";
|
|
|
|
|
|
|
|
if (demoview)
|
|
|
|
result = demoview->SetTime (atof (argv[1]));
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
if (result == -1)
|
|
|
|
Tcl_SetResult (interp, strminusone, TCL_STATIC);
|
|
|
|
else
|
|
|
|
Tcl_SetResult (interp, str0, TCL_STATIC);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SaveSolution (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * filename = argv[1];
|
|
|
|
PrintMessage (1, "Save solution to file ", filename);
|
|
|
|
|
2017-08-28 21:19:20 +05:00
|
|
|
netgen::GetVSSolution().SaveSolutionData (filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int Ng_SetNextTimeStamp (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argqc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2011-01-11 01:18:01 +05:00
|
|
|
mesh -> SetNextTimeStamp();
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_LoadGeometry (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcl_const char * lgfilename = argv[1];
|
|
|
|
|
|
|
|
#ifdef LOG_STREAM
|
|
|
|
(*logout) << "Load geometry file: " << lgfilename << endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef STAT_STREAM
|
|
|
|
(*statout) << lgfilename << " & " << endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
for (int i = 0; i < geometryregister.Size(); i++)
|
|
|
|
{
|
|
|
|
NetgenGeometry * hgeom = geometryregister[i]->Load (lgfilename);
|
|
|
|
if (hgeom)
|
|
|
|
{
|
2013-02-27 19:49:17 +06:00
|
|
|
// delete ng_geometry;
|
|
|
|
// ng_geometry = hgeom;
|
2014-09-08 21:21:09 +06:00
|
|
|
ng_geometry = shared_ptr<NetgenGeometry> (hgeom);
|
2019-10-02 20:20:13 +05:00
|
|
|
geometryregister[i]->SetParameters(interp);
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh.reset();
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
ifstream infile(lgfilename);
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
if (strlen(lgfilename) < 4)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
cout << "ERROR: cannot recognise file format!" << endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
if ((strcmp (&lgfilename[strlen(lgfilename)-4], "iges") == 0) ||
|
2009-01-13 04:40:13 +05:00
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-3], "igs") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-3], "IGS") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-4], "IGES") == 0))
|
|
|
|
{
|
2009-01-20 14:08:01 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"IGES import requires the OpenCascade geometry kernel. "
|
2009-01-31 03:12:17 +05:00
|
|
|
"Please install OpenCascade as described in the Netgen-website",
|
|
|
|
TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
else if (strcmp (&lgfilename[strlen(lgfilename)-3], "sat") == 0)
|
|
|
|
{
|
|
|
|
#ifdef ACIS
|
|
|
|
PrintMessage (1, "Load ACIS geometry file ", lgfilename);
|
|
|
|
acisgeometry = netgen::LoadACIS_SAT (lgfilename);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "step") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-3], "stp") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-3], "STP") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-4], "STEP") == 0))
|
|
|
|
{
|
|
|
|
#ifdef ACISxxx
|
|
|
|
PrintMessage (1, "Load STEP geometry file ", lgfilename);
|
|
|
|
acisgeometry = netgen::LoadACIS_STEP (lgfilename);
|
|
|
|
#else
|
2009-01-20 14:08:01 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"IGES import requires the OpenCascade geometry kernel. "
|
2009-01-31 03:12:17 +05:00
|
|
|
"Please install OpenCascade as described in the Netgen-website",
|
|
|
|
TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "brep") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-4], "Brep") == 0) ||
|
|
|
|
(strcmp (&lgfilename[strlen(lgfilename)-4], "BREP") == 0))
|
|
|
|
{
|
2009-01-20 14:08:01 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"BREP import requires the OpenCascade geometry kernel. "
|
2009-01-31 03:12:17 +05:00
|
|
|
"Please install OpenCascade as described in the Netgen-website",
|
|
|
|
TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
catch (NgException e)
|
|
|
|
{
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_SetResult (interp, const_cast<char*> (e.What().c_str()), TCL_VOLATILE);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh.reset();
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SaveGeometry (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
const char * cfilename = argv[1];
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ng_geometry -> Save (string (cfilename));
|
|
|
|
}
|
|
|
|
catch (NgException e)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, const_cast<char*> (e.What().c_str()), TCL_VOLATILE);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
PrintMessage (1, "Save geometry to file ", cfilename);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
if (strlen(cfilename) < 4) {cout << "ERROR: can not recognise file format!!!" << endl;}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef ACIS
|
|
|
|
if (acisgeometry)
|
|
|
|
{
|
|
|
|
char * filename = const_cast<char*> (argv[1]);
|
|
|
|
if (strcmp (&filename[strlen(filename)-3], "sat") == 0)
|
|
|
|
{
|
|
|
|
acisgeometry -> SaveSATFile (filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-11 01:18:01 +05:00
|
|
|
/*
|
|
|
|
if (strcmp (&cfilename[strlen(cfilename)-3], "ngg") == 0)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
|
|
|
|
if (geometry)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
ofstream of(cfilename);
|
|
|
|
geometry->Save (of);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
*/
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ReadStatus (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
char buf[20], lstring[200];
|
2019-10-23 01:54:27 +05:00
|
|
|
static int prev_np = -1;
|
|
|
|
static int prev_ne = -1;
|
|
|
|
static int prev_nse = -1;
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2019-10-23 01:54:27 +05:00
|
|
|
if (prev_np != mesh->GetNP())
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNP()));
|
2019-10-23 01:54:27 +05:00
|
|
|
Tcl_SetVar (interp, "::status_np", buf, 0);
|
|
|
|
prev_np = mesh->GetNP();
|
|
|
|
}
|
2019-10-04 15:25:14 +05:00
|
|
|
|
2019-10-23 01:54:27 +05:00
|
|
|
if (prev_ne != mesh->GetNE())
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNE()));
|
2019-10-23 01:54:27 +05:00
|
|
|
Tcl_SetVar (interp, "::status_ne", buf, 0);
|
|
|
|
prev_ne = mesh->GetNE();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev_nse != mesh->GetNSE())
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%u", unsigned(mesh->GetNSE()));
|
2019-10-23 01:54:27 +05:00
|
|
|
Tcl_SetVar (interp, "::status_nse", buf, 0);
|
|
|
|
prev_nse = mesh->GetNSE();
|
|
|
|
}
|
|
|
|
|
2019-10-04 15:25:14 +05:00
|
|
|
auto tets_in_qualclass = mesh->GetQualityHistogram();
|
|
|
|
lstring[0] = 0;
|
|
|
|
for (int i = 0; i < tets_in_qualclass.Size(); i++)
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), " %d", tets_in_qualclass[i]);
|
2019-10-04 15:25:14 +05:00
|
|
|
strcat (lstring, buf);
|
|
|
|
}
|
|
|
|
for (int i = tets_in_qualclass.Size(); i < 20; i++)
|
|
|
|
strcat (lstring, " 0");
|
|
|
|
Tcl_SetVar (interp, "::status_tetqualclasses", lstring, 0);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-23 01:54:27 +05:00
|
|
|
if (prev_np != 0)
|
|
|
|
{
|
|
|
|
Tcl_SetVar (interp, "::status_np", "0", 0);
|
|
|
|
prev_np = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev_ne != 0)
|
|
|
|
{
|
|
|
|
Tcl_SetVar (interp, "::status_ne", "0", 0);
|
|
|
|
prev_ne = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev_nse != 0)
|
|
|
|
{
|
|
|
|
Tcl_SetVar (interp, "::status_nse", "0", 0);
|
|
|
|
prev_nse = 0;
|
|
|
|
}
|
2019-10-04 15:25:14 +05:00
|
|
|
Tcl_SetVar (interp, "::status_tetqualclasses", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", 0);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:54:27 +05:00
|
|
|
static string prev_working;
|
|
|
|
string working = multithread.running ? "working" : " ";
|
|
|
|
if (working != prev_working)
|
|
|
|
{
|
|
|
|
Tcl_SetVar (interp, "::status_working", working.c_str(), 0);
|
|
|
|
prev_working = working;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-01-13 04:40:13 +05:00
|
|
|
if (multithread.running)
|
|
|
|
Tcl_SetVar (interp, "::status_working", "working", 0);
|
|
|
|
else
|
|
|
|
Tcl_SetVar (interp, "::status_working", " ", 0);
|
2019-10-23 01:54:27 +05:00
|
|
|
*/
|
|
|
|
|
|
|
|
static string prev_task;
|
|
|
|
if (prev_task != string(multithread.task))
|
|
|
|
{
|
|
|
|
prev_task = multithread.task;
|
|
|
|
Tcl_SetVar (interp, "::status_task", prev_task.c_str(), 0);
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2019-10-23 01:54:27 +05:00
|
|
|
static double prev_percent = -1;
|
|
|
|
if (prev_percent != multithread.percent)
|
|
|
|
{
|
|
|
|
prev_percent = multithread.percent;
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%lf", prev_percent);
|
2019-10-23 01:54:27 +05:00
|
|
|
Tcl_SetVar (interp, "::status_percent", buf, 0);
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2015-06-26 19:30:27 +05:00
|
|
|
{
|
2016-02-22 22:43:51 +05:00
|
|
|
lock_guard<mutex> guard(tcl_todo_mutex);
|
2015-06-26 19:30:27 +05:00
|
|
|
if (multithread.tcl_todo->length())
|
|
|
|
{
|
|
|
|
Tcl_Eval (interp, multithread.tcl_todo->c_str());
|
|
|
|
*multithread.tcl_todo = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_MemInfo (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
2015-10-19 13:08:30 +05:00
|
|
|
{/*
|
2009-01-13 04:40:13 +05:00
|
|
|
if (argc < 2) return TCL_ERROR;
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "usedmb") == 0)
|
|
|
|
{ // returns string of 512 '0' or '1'
|
|
|
|
|
|
|
|
static char usedmb[513];
|
|
|
|
for (int i = 0; i < 512; i++)
|
|
|
|
usedmb[i] = (i % 7 == 0) ? '1' : '0';
|
|
|
|
|
|
|
|
usedmb[512] = 0;
|
|
|
|
BaseDynamicMem::GetUsed (512, usedmb);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_SetResult (interp, usedmb, TCL_STATIC);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2015-10-19 13:08:30 +05:00
|
|
|
*/
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_BCProp (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
static char buf[100];
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, (char*)"Ng_BCProp needs arguments", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "setbc") == 0)
|
|
|
|
{
|
|
|
|
int facenr = atoi (argv[2]);
|
|
|
|
int bcnr = atoi (argv[3]);
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->GetFaceDescriptor (facenr).SetBCProperty (bcnr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "setall") == 0)
|
|
|
|
{
|
|
|
|
int bcnr = atoi (argv[2]);
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
int nfd = mesh->GetNFD();
|
|
|
|
for (int i = 1; i <= nfd; i++)
|
|
|
|
mesh->GetFaceDescriptor (i).SetBCProperty (bcnr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "getbc") == 0)
|
|
|
|
{
|
|
|
|
int facenr = atoi (argv[2]);
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%d", mesh->GetFaceDescriptor(facenr).BCProperty());
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy (buf, "0");
|
|
|
|
}
|
|
|
|
Tcl_SetResult (interp, buf, TCL_STATIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "getbcname") == 0)
|
|
|
|
{
|
|
|
|
int facenr = atoi (argv[2]);
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%s", mesh->GetFaceDescriptor(facenr).GetBCName().c_str());
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy (buf, "-");
|
|
|
|
}
|
|
|
|
Tcl_SetResult (interp, buf, TCL_STATIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "getactive") == 0)
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%d", vsmesh.SelectedFace());
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetResult (interp, buf, TCL_STATIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "setactive") == 0)
|
|
|
|
{
|
|
|
|
int facenr = atoi (argv[2]);
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
vsmesh.SetSelectedFace (facenr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "getnfd") == 0)
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%d", mesh->GetNFD());
|
2009-01-13 04:40:13 +05:00
|
|
|
else
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "0");
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetResult (interp, buf, TCL_STATIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
int Ng_Refine (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ACIS
|
2009-08-25 20:00:20 +06:00
|
|
|
if (acisgeometry)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
ACISRefinementSurfaces ref (*acisgeometry);
|
|
|
|
ACISMeshOptimize2dSurfaces opt(*acisgeometry);
|
|
|
|
ref.Set2dOptimizer(&opt);
|
|
|
|
ref.Refine (*mesh);
|
|
|
|
}
|
|
|
|
else
|
2011-01-11 01:18:01 +05:00
|
|
|
#endif
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2015-08-08 22:10:48 +05:00
|
|
|
// ng_geometry -> GetRefinement().Refine(*mesh);
|
|
|
|
mesh->GetGeometry()->GetRefinement().Refine(*mesh);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
2010-10-17 16:44:39 +06:00
|
|
|
//redo second order refinement if desired
|
|
|
|
if (mparam.secondorder)
|
2015-08-08 22:10:48 +05:00
|
|
|
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder(*mesh);
|
2010-10-17 16:44:39 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_SecondOrder (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2015-08-08 22:10:48 +05:00
|
|
|
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void * HighOrderDummy (void *)
|
|
|
|
{
|
|
|
|
// mparam.elementorder = atoi (Tcl_GetVar (interp, "options.elementorder", 0));
|
|
|
|
const char * savetask = multithread.task;
|
|
|
|
|
2015-08-08 22:10:48 +05:00
|
|
|
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
|
2009-08-25 20:00:20 +06:00
|
|
|
mesh -> GetCurvedElements().BuildCurvedElements (&ref, mparam.elementorder);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
multithread.task = savetask;
|
|
|
|
multithread.running = 0;
|
|
|
|
multithread.terminate = 1;
|
|
|
|
|
|
|
|
mesh -> SetNextMajorTimeStamp();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_HighOrder (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
multithread.running = 1;
|
|
|
|
multithread.terminate = 0;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
mparam.elementorder = atoi(argv[1]);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-08-25 14:44:03 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
HighOrderDummy(NULL);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void * ValidateDummy (void *)
|
|
|
|
{
|
2015-08-08 22:10:48 +05:00
|
|
|
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
|
2009-01-13 04:40:13 +05:00
|
|
|
ref.ValidateSecondOrder (*mesh);
|
|
|
|
|
|
|
|
multithread.running = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ValidateSecondOrder (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
multithread.running = 1;
|
|
|
|
RunParallel (ValidateDummy, NULL);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ZRefinement (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ZRefinementOptions opt;
|
|
|
|
opt.minref = 5;
|
|
|
|
|
|
|
|
if (argc >= 2) opt.minref = atoi (argv[1]);
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
ZRefinement (*mesh, ng_geometry.get(), opt);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_HPRefinement (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
int levels = atoi (argv[1]);
|
|
|
|
|
|
|
|
|
2015-08-08 22:10:48 +05:00
|
|
|
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
|
2009-08-25 20:00:20 +06:00
|
|
|
HPRefinement (*mesh, &ref, levels);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_LoadMeshSize (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->LoadLocalMeshSize(argv[1]);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_MeshSizeFromSurfaceMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->SetGlobalH (mparam.maxh);
|
2011-07-25 14:40:23 +06:00
|
|
|
mesh->CalcLocalH(mparam.grading);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-19 11:41:22 +06:00
|
|
|
// Philippose Rajan - 13 June 2009
|
|
|
|
// Added a new TCL function call for the generation
|
|
|
|
// of prismatic boundary layers
|
|
|
|
int Ng_GenerateBoundaryLayer (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-06-19 11:41:22 +06:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult(interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-12-18 19:00:58 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cout << "Generate Prismatic Boundary Layers (Experimental)...." << endl;
|
|
|
|
|
|
|
|
// Use an array to support creation of boundary
|
|
|
|
// layers for multiple surfaces in the future...
|
2024-09-27 16:12:14 +05:00
|
|
|
std::vector<int> surfid;
|
2014-12-18 19:00:58 +05:00
|
|
|
int surfinp = 0;
|
|
|
|
int prismlayers = 1;
|
|
|
|
double hfirst = 0.01;
|
|
|
|
double growthfactor = 1.0;
|
|
|
|
|
|
|
|
|
|
|
|
while(surfinp >= 0)
|
|
|
|
{
|
|
|
|
cout << "Enter Surface ID (-1 to end list): ";
|
|
|
|
cin >> surfinp;
|
2024-09-27 16:12:14 +05:00
|
|
|
if(surfinp >= 0) surfid.push_back(surfinp);
|
2014-12-18 19:00:58 +05:00
|
|
|
}
|
|
|
|
|
2024-09-27 16:12:14 +05:00
|
|
|
cout << "Number of surfaces entered = " << surfid.size() << endl;
|
2014-12-18 19:00:58 +05:00
|
|
|
cout << "Selected surfaces are:" << endl;
|
|
|
|
|
2024-09-27 16:12:14 +05:00
|
|
|
for(auto i : Range(surfid.size()))
|
2020-04-19 23:00:06 +05:00
|
|
|
cout << "Surface " << i << ": " << surfid[i] << endl;
|
2014-12-18 19:00:58 +05:00
|
|
|
|
|
|
|
cout << endl << "Enter number of prism layers: ";
|
|
|
|
cin >> prismlayers;
|
|
|
|
if(prismlayers < 1) prismlayers = 1;
|
|
|
|
|
|
|
|
cout << "Enter height of first layer: ";
|
|
|
|
cin >> hfirst;
|
|
|
|
if(hfirst <= 0.0) hfirst = 0.01;
|
|
|
|
|
|
|
|
cout << "Enter layer growth / shrink factor: ";
|
|
|
|
cin >> growthfactor;
|
|
|
|
if(growthfactor <= 0.0) growthfactor = 0.5;
|
|
|
|
|
|
|
|
BoundaryLayerParameters blp;
|
2024-09-27 16:12:14 +05:00
|
|
|
blp.boundary = surfid;
|
|
|
|
std::vector<double> thickness;
|
2020-04-19 23:00:06 +05:00
|
|
|
for(auto i : Range(prismlayers))
|
|
|
|
{
|
|
|
|
auto layer = i+1;
|
|
|
|
if(growthfactor == 1)
|
2024-09-27 16:12:14 +05:00
|
|
|
thickness.push_back(layer * hfirst);
|
2020-04-19 23:00:06 +05:00
|
|
|
else
|
2024-09-27 16:12:14 +05:00
|
|
|
thickness.push_back(hfirst * (pow(growthfactor, (layer+1))-1)/(growthfactor-1));
|
2020-04-19 23:00:06 +05:00
|
|
|
}
|
2024-09-27 16:12:14 +05:00
|
|
|
blp.thickness = thickness;
|
2014-12-18 19:00:58 +05:00
|
|
|
GenerateBoundaryLayer (*mesh, blp);
|
2009-06-19 11:41:22 +06:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
int Ng_InsertVirtualBL (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
InsertVirtualBoundaryLayer (*mesh);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_CutOffAndCombine (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
Mesh othermesh;
|
|
|
|
othermesh.Load (argv[1]);
|
|
|
|
othermesh.SetGlobalH (mparam.maxh);
|
2011-07-25 14:40:23 +06:00
|
|
|
othermesh.CalcLocalH(mparam.grading);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
CutOffAndCombine (*mesh, othermesh);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_HelmholtzMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
HelmholtzMesh (*mesh);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SetMeshingParameters (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
mparam.maxh = atof (Tcl_GetVar (interp, "::options.meshsize", 0));
|
|
|
|
mparam.minh = atof (Tcl_GetVar (interp, "::options.minmeshsize", 0));
|
2014-08-30 06:15:59 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
mparam.meshsizefilename = Tcl_GetVar (interp, "::options.meshsizefilename", 0);
|
2014-08-31 18:12:31 +06:00
|
|
|
// if (!strlen (mparam.meshsizefilename)) mparam.meshsizefilename = NULL;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
mparam.curvaturesafety = atof (Tcl_GetVar (interp, "::options.curvaturesafety", 0));
|
|
|
|
mparam.segmentsperedge = atof (Tcl_GetVar (interp, "::options.segmentsperedge", 0));
|
|
|
|
mparam.badellimit = atof (Tcl_GetVar (interp, "::options.badellimit", 0));
|
|
|
|
mparam.secondorder = atoi (Tcl_GetVar (interp, "::options.secondorder", 0));
|
|
|
|
mparam.elementorder = atoi (Tcl_GetVar (interp, "::options.elementorder", 0));
|
|
|
|
mparam.quad = atoi (Tcl_GetVar (interp, "::options.quad", 0));
|
2017-07-25 00:49:49 +05:00
|
|
|
mparam.try_hexes = atoi (Tcl_GetVar (interp, "::options.try_hexes", 0));
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
mparam.inverttets = atoi (Tcl_GetVar (interp, "::options.inverttets", 0));
|
|
|
|
mparam.inverttrigs = atoi (Tcl_GetVar (interp, "::options.inverttrigs", 0));
|
|
|
|
mparam.uselocalh = atoi (Tcl_GetVar (interp, "::options.localh", 0));
|
|
|
|
mparam.grading = atof (Tcl_GetVar (interp, "::options.grading", 0));
|
|
|
|
mparam.delaunay = atoi (Tcl_GetVar (interp, "::options.delaunay", 0));
|
|
|
|
mparam.checkoverlap = atoi (Tcl_GetVar (interp, "::options.checkoverlap", 0));
|
|
|
|
mparam.checkoverlappingboundary = atoi (Tcl_GetVar (interp, "::options.checkoverlappingboundary", 0));
|
|
|
|
mparam.checkchartboundary = atoi (Tcl_GetVar (interp, "::options.checkchartboundary", 0));
|
|
|
|
mparam.optsteps3d = atoi (Tcl_GetVar (interp, "::options.optsteps3d", 0));
|
|
|
|
mparam.optsteps2d = atoi (Tcl_GetVar (interp, "::options.optsteps2d", 0));
|
|
|
|
mparam.opterrpow = atof (Tcl_GetVar (interp, "::options.opterrpow", 0));
|
|
|
|
|
|
|
|
mparam.parthread = atoi (Tcl_GetVar (interp, "::options.parthread", 0));
|
|
|
|
mparam.elsizeweight = atof (Tcl_GetVar (interp, "::options.elsizeweight", 0));
|
|
|
|
|
|
|
|
mparam.autozrefine = atoi (Tcl_GetVar (interp, "::options.autozrefine", 0));
|
|
|
|
|
2021-09-06 20:44:46 +05:00
|
|
|
// extern int printmessage_importance;
|
2009-01-13 04:40:13 +05:00
|
|
|
extern int printdots;
|
|
|
|
printmessage_importance = atoi (Tcl_GetVar (interp, "::options.printmsg", 0));
|
|
|
|
printdots = (printmessage_importance >= 4);
|
|
|
|
|
2019-09-26 19:15:50 +05:00
|
|
|
mparam.parallel_meshing = atoi (Tcl_GetVar (interp, "::options.parallel_meshing", 0));
|
|
|
|
mparam.nthreads = atoi (Tcl_GetVar (interp, "::options.nthreads", 0));
|
2019-11-04 23:34:46 +05:00
|
|
|
if(atoi(Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0)))
|
|
|
|
mparam.closeedgefac = atof(Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
|
|
|
|
else
|
|
|
|
mparam.closeedgefac = {};
|
2019-09-26 19:15:50 +05:00
|
|
|
|
2009-08-24 06:03:40 +06:00
|
|
|
//BaseMoveableMem::totalsize = 0;
|
2009-01-25 04:28:47 +05:00
|
|
|
// 1048576 * atoi (Tcl_GetVar (interp, "::options.memory", 0));
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
mesh->SetGlobalH (mparam.maxh);
|
|
|
|
mesh->SetMinimalH (mparam.minh);
|
|
|
|
}
|
|
|
|
|
2019-03-16 10:30:47 +05:00
|
|
|
#ifdef PARALLELGL
|
2011-07-22 02:52:45 +06:00
|
|
|
MyMPI_SendCmd ("bcastparthread");
|
2019-02-13 02:11:55 +05:00
|
|
|
MyMPI_Bcast (mparam.parthread, MPI_COMM_WORLD);
|
2011-07-22 02:52:45 +06:00
|
|
|
#endif
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SetDebugParameters (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
debugparam.slowchecks = atoi (Tcl_GetVar (interp, "::debug.slowchecks", 0));
|
|
|
|
debugparam.debugoutput = atoi (Tcl_GetVar (interp, "::debug.debugoutput", 0));
|
|
|
|
debugparam.haltexistingline = atoi (Tcl_GetVar (interp, "::debug.haltexistingline", 0));
|
|
|
|
debugparam.haltoverlap = atoi (Tcl_GetVar (interp, "::debug.haltoverlap", 0));
|
|
|
|
debugparam.haltsuccess = atoi (Tcl_GetVar (interp, "::debug.haltsuccess", 0));
|
|
|
|
debugparam.haltnosuccess = atoi (Tcl_GetVar (interp, "::debug.haltnosuccess", 0));
|
|
|
|
debugparam.haltlargequalclass = atoi (Tcl_GetVar (interp, "::debug.haltlargequalclass", 0));
|
|
|
|
debugparam.haltsegment = atoi (Tcl_GetVar (interp, "::debug.haltsegment", 0));
|
|
|
|
debugparam.haltnode = atoi (Tcl_GetVar (interp, "::debug.haltnode", 0));
|
|
|
|
debugparam.haltface = atoi (Tcl_GetVar (interp, "::debug.haltface", 0));
|
|
|
|
debugparam.haltsegmentp1 = atoi (Tcl_GetVar (interp, "::debug.haltsegmentp1", 0));
|
|
|
|
debugparam.haltsegmentp2 = atoi (Tcl_GetVar (interp, "::debug.haltsegmentp2", 0));
|
|
|
|
debugparam.haltfacenr = atoi (Tcl_GetVar (interp, "::debug.haltfacenr", 0));
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-04 21:59:01 +05:00
|
|
|
int Ng_SetCommandLineParameter (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, (char*)"Ng_SetCommandLineParameter needs 1 parameter",
|
|
|
|
TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argv[1][0] == '-')
|
|
|
|
parameters.SetCommandLineFlag (argv[1]);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strstr(argv[1], ".py"))
|
|
|
|
parameters.SetFlag ("py", argv[1]);
|
|
|
|
else
|
|
|
|
parameters.SetFlag ("geofile", argv[1]);
|
|
|
|
}
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-08-30 18:36:11 +06:00
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
int Ng_GetCommandLineParameter (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"Ng_GetCommandLineParameter needs 1 parameter",
|
2009-01-13 04:40:13 +05:00
|
|
|
TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char buf[10];
|
|
|
|
|
|
|
|
if (parameters.StringFlagDefined (argv[1]))
|
2019-08-22 18:00:42 +05:00
|
|
|
Tcl_SetResult (interp,
|
|
|
|
const_cast<char*>(parameters.GetStringFlag (argv[1], NULL).c_str()), TCL_VOLATILE);
|
2009-01-13 04:40:13 +05:00
|
|
|
else if (parameters.NumFlagDefined (argv[1]))
|
|
|
|
{
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%lf", parameters.GetNumFlag (argv[1], 0));
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetResult (interp, buf, TCL_STATIC);
|
|
|
|
}
|
|
|
|
else if (parameters.GetDefineFlag (argv[1]))
|
|
|
|
Tcl_SetResult (interp, (char*)"defined", TCL_STATIC);
|
|
|
|
else
|
|
|
|
Tcl_SetResult (interp, (char*)"undefined", TCL_STATIC);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int perfstepsstart;
|
|
|
|
static int perfstepsend;
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
static char* optstring = NULL;
|
|
|
|
static char* optstringcsg = NULL;
|
|
|
|
|
|
|
|
void * MeshingDummy (void *)
|
|
|
|
{
|
|
|
|
|
|
|
|
const char * savetask = multithread.task;
|
|
|
|
multithread.task = "Generate Mesh";
|
|
|
|
|
|
|
|
ResetTime();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef LOG_STREAM
|
|
|
|
(*logout) << "Start meshing" << endl;
|
|
|
|
(*logout) << "Meshing parameters:" << endl;
|
|
|
|
mparam.Print (*logout);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ACIS
|
2009-08-25 20:00:20 +06:00
|
|
|
if (acisgeometry)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
ACISGenerateMesh(*acisgeometry, mesh.Ptr(), perfstepsstart, perfstepsend, optstring);
|
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
else
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|
2016-02-08 19:53:16 +05:00
|
|
|
if (ng_geometry)
|
2009-08-25 20:00:20 +06:00
|
|
|
{
|
2019-09-16 15:30:45 +05:00
|
|
|
if (perfstepsstart == 1)
|
|
|
|
{
|
|
|
|
mesh = make_shared<Mesh> ();
|
|
|
|
// vsmesh.SetMesh (mesh);
|
|
|
|
SetGlobalMesh (mesh);
|
|
|
|
mesh -> SetGeometry(ng_geometry);
|
|
|
|
}
|
|
|
|
if(!mesh)
|
|
|
|
throw Exception("Need existing global mesh");
|
2016-12-05 17:50:21 +05:00
|
|
|
mparam.perfstepsstart = perfstepsstart;
|
|
|
|
mparam.perfstepsend = perfstepsend;
|
2019-09-17 21:59:19 +05:00
|
|
|
if(optstring)
|
|
|
|
mparam.optimize3d = *optstring;
|
2016-12-05 17:50:21 +05:00
|
|
|
int res = ng_geometry -> GenerateMesh (mesh, mparam);
|
2014-09-08 21:21:09 +06:00
|
|
|
|
2010-03-23 17:52:07 +05:00
|
|
|
if (res != MESHING3_OK)
|
|
|
|
{
|
|
|
|
multithread.task = savetask;
|
|
|
|
multithread.running = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
}
|
2019-09-20 15:37:40 +05:00
|
|
|
else if (mesh)
|
|
|
|
{
|
2019-09-30 15:02:08 +05:00
|
|
|
if(perfstepsstart > 1 && perfstepsstart < 5)
|
|
|
|
throw Exception("Need geometry for surface mesh operations!");
|
2019-09-20 15:37:40 +05:00
|
|
|
MeshVolume(mparam, *mesh);
|
|
|
|
OptimizeVolume(mparam, *mesh);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-02-08 19:53:16 +05:00
|
|
|
else // no ng_geometry
|
|
|
|
{
|
|
|
|
multithread.task = savetask;
|
|
|
|
multithread.running = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
if (mparam.autozrefine)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2009-08-25 20:00:20 +06:00
|
|
|
ZRefinementOptions opt;
|
|
|
|
opt.minref = 5;
|
2014-09-08 21:21:09 +06:00
|
|
|
ZRefinement (*mesh, ng_geometry.get(), opt);
|
2009-08-25 20:00:20 +06:00
|
|
|
mesh -> SetNextMajorTimeStamp();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
if (mparam.secondorder)
|
|
|
|
{
|
2015-08-08 22:10:48 +05:00
|
|
|
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
|
2009-08-25 20:00:20 +06:00
|
|
|
mesh -> SetNextMajorTimeStamp();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mparam.elementorder > 1)
|
|
|
|
{
|
2015-08-08 22:10:48 +05:00
|
|
|
mesh -> GetCurvedElements().BuildCurvedElements (&const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()),
|
2009-08-25 20:00:20 +06:00
|
|
|
mparam.elementorder);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
mesh -> SetNextMajorTimeStamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PrintMessage (1, "Meshing done, time = ", GetTime(), " sec");
|
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
catch (NgException e)
|
|
|
|
{
|
|
|
|
cout << e.What() << endl;
|
|
|
|
}
|
2009-08-25 20:00:20 +06:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
multithread.task = savetask;
|
|
|
|
multithread.running = 0;
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
#ifdef OCCGEOMETRYorig
|
|
|
|
// currently not active
|
|
|
|
OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry);
|
|
|
|
if (occgeometry && occgeometry->ErrorInSurfaceMeshing())
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
char script[] = "rebuildoccdialog";
|
|
|
|
Tcl_GlobalEval (tcl_interp, script);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
int MeshingVal(tcl_const char* str)
|
|
|
|
{
|
|
|
|
if (strcmp(str, "ag") == 0) {return MESHCONST_ANALYSE;}
|
|
|
|
if (strcmp(str, "me") == 0) {return MESHCONST_MESHEDGES;}
|
|
|
|
if (strcmp(str, "ms") == 0) {return MESHCONST_MESHSURFACE;}
|
|
|
|
if (strcmp(str, "os") == 0) {return MESHCONST_OPTSURFACE;}
|
|
|
|
if (strcmp(str, "mv") == 0) {return MESHCONST_MESHVOLUME;}
|
|
|
|
if (strcmp(str, "ov") == 0) {return MESHCONST_OPTVOLUME;}
|
|
|
|
|
|
|
|
cout << "TCL TK ERROR, wrong meshing value, return='" << str << "'" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
int Ng_GenerateMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
multithread.running = 1;
|
|
|
|
multithread.terminate = 0;
|
2014-08-30 06:15:59 +06:00
|
|
|
|
2014-12-04 15:24:45 +05:00
|
|
|
extern void Render(bool blocking);
|
2014-08-30 06:15:59 +06:00
|
|
|
mparam.render_function = &Render;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
for (int i = 0; i < geometryregister.Size(); i++)
|
|
|
|
geometryregister[i] -> SetParameters (interp);
|
2009-08-30 18:36:11 +06:00
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_SetMeshingParameters (clientData, interp, 0, argv);
|
|
|
|
|
|
|
|
perfstepsstart = 1;
|
|
|
|
perfstepsend = 6;
|
|
|
|
|
|
|
|
if (optstringcsg) delete optstringcsg;
|
|
|
|
optstringcsg = NULL;
|
|
|
|
if (optstring) delete optstring;
|
|
|
|
optstring = NULL;
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
perfstepsstart = 1;
|
|
|
|
perfstepsend = MeshingVal(argv[1]);
|
|
|
|
}
|
|
|
|
else if (argc == 3)
|
|
|
|
{
|
|
|
|
perfstepsstart = MeshingVal(argv[1]);
|
|
|
|
perfstepsend = MeshingVal(argv[2]);
|
|
|
|
}
|
|
|
|
else if (argc == 4)
|
|
|
|
{
|
|
|
|
perfstepsstart = MeshingVal(argv[1]);
|
|
|
|
perfstepsend = MeshingVal(argv[2]);
|
|
|
|
optstring = new char[strlen(argv[3])+1];
|
|
|
|
strcpy(optstring, argv[3]);
|
|
|
|
optstringcsg = new char[strlen(argv[3])+1];
|
|
|
|
strcpy(optstringcsg, argv[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
RunParallel (MeshingDummy, NULL);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_StopMeshing (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
multithread.terminate = 1;
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_MeshInfo (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ostringstream str;
|
|
|
|
|
|
|
|
if (argc >= 2 && strcmp (argv[1], "dim") == 0)
|
|
|
|
str << mesh->GetDimension();
|
|
|
|
else if (argc >= 2 && strcmp (argv[1], "np") == 0)
|
|
|
|
str << mesh->GetNP();
|
|
|
|
else if (argc >= 2 && strcmp (argv[1], "ne") == 0)
|
|
|
|
str << mesh->GetNE();
|
|
|
|
else if (argc >= 2 && strcmp (argv[1], "nse") == 0)
|
|
|
|
str << mesh->GetNSE();
|
|
|
|
else if (argc >= 2 && strcmp (argv[1], "nseg") == 0)
|
|
|
|
str << mesh->GetNSeg();
|
|
|
|
else if (argc >= 2 && strcmp (argv[1], "bbox") == 0)
|
|
|
|
{
|
|
|
|
Point3d pmin, pmax;
|
|
|
|
mesh->GetBox (pmin, pmax);
|
|
|
|
str << pmin.X() << " " << pmax.X() << " "
|
|
|
|
<< pmin.Y() << " " << pmax.Y() << " "
|
|
|
|
<< pmin.Z() << " " << pmax.Z() << endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cout << "argv[1] = " << argv[1] << endl;
|
|
|
|
Tcl_SetResult (interp, (char*)"Ng_MeshInfo requires an argument out of \n dim np ne", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_MeshQuality (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
double angles[4];
|
|
|
|
char buf[10];
|
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->CalcMinMaxAngle(mparam.badellimit, angles);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
angles[0] = angles[1] = angles[2] = angles[3] = 0;
|
|
|
|
}
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%5.1lf", angles[0]);
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetVar (interp, argv[1], buf, 0);
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%5.1lf", angles[1]);
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetVar (interp, argv[2], buf, 0);
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%5.1lf", angles[2]);
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetVar (interp, argv[3], buf, 0);
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "%5.1lf", angles[3]);
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_SetVar (interp, argv[4], buf, 0);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_CheckSurfaceMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->FindOpenElements();
|
|
|
|
if (mesh->CheckConsistentBoundary())
|
|
|
|
{
|
|
|
|
PrintMessage (1, "surface mesh not consistent, trying orientation");
|
|
|
|
mesh->SurfaceMeshOrientation();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PrintMessage (1, "surface mesh consistent");
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->CheckOverlappingBoundary();
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Ng_CheckVolumeMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
mesh->CheckVolumeMesh();
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_DeleteVolMesh (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->ClearVolumeElements();
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_SplitSeparatedFaces (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->SplitSeparatedFaces ();
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_RestrictH (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc != 3)
|
|
|
|
return TCL_OK;
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
|
|
|
|
|
|
|
|
double loch = atof (argv[2]);
|
|
|
|
if (strcmp (argv[1], "face") == 0)
|
|
|
|
{
|
|
|
|
cout << "Restrict h at face to " << loch << endl;
|
|
|
|
mesh -> RestrictLocalH (RESTRICTH_FACE, vsmesh.SelectedFace(), loch);
|
|
|
|
}
|
|
|
|
if (strcmp (argv[1], "edge") == 0)
|
|
|
|
{
|
|
|
|
cout << "Restrict h at edge to " << loch << endl;
|
|
|
|
mesh -> RestrictLocalH (RESTRICTH_EDGE, vsmesh.SelectedEdge(), loch);
|
|
|
|
}
|
|
|
|
if (strcmp (argv[1], "point") == 0)
|
|
|
|
{
|
|
|
|
cout << "Restrict h at point to " << loch << endl;
|
|
|
|
mesh -> RestrictLocalH (RESTRICTH_POINT, vsmesh.SelectedPoint(), loch);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_Anisotropy (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
return TCL_OK;
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "edge") == 0)
|
|
|
|
{
|
|
|
|
int edgenr = vsmesh.SelectedEdge();
|
|
|
|
for (int i = 1; i <= mesh->GetNSeg(); i++)
|
|
|
|
{
|
|
|
|
Segment & seg = mesh->LineSegment(i);
|
|
|
|
if (seg.edgenr == edgenr)
|
|
|
|
{
|
|
|
|
seg.singedge_left = 1 - seg.singedge_left;
|
|
|
|
seg.singedge_right = 1 - seg.singedge_right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BisectionOptions biopt;
|
|
|
|
|
|
|
|
void * BisectDummy (void *)
|
|
|
|
{
|
2015-08-08 22:10:48 +05:00
|
|
|
const Refinement & ref = mesh->GetGeometry()->GetRefinement();
|
2009-01-13 04:40:13 +05:00
|
|
|
MeshOptimize2d * opt = NULL;
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
/*
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef ACIS
|
2011-01-11 01:18:01 +05:00
|
|
|
if (acisgeometry)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
// ref = new ACISRefinementSurfaces(*acisgeometry);
|
2009-01-13 04:40:13 +05:00
|
|
|
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
|
|
|
|
ref->Set2dOptimizer(opt);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ref = new RefinementSurfaces(*geometry);
|
|
|
|
opt = new MeshOptimize2dSurfaces(*geometry);
|
|
|
|
ref->Set2dOptimizer(opt);
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
*/
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
if(!mesh->LocalHFunctionGenerated())
|
2011-07-25 14:40:23 +06:00
|
|
|
mesh->CalcLocalH(mparam.grading);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh->LocalHFunction().SetGrading (mparam.grading);
|
2011-01-11 01:18:01 +05:00
|
|
|
ref . Bisect (*mesh, biopt);
|
2009-01-13 04:40:13 +05:00
|
|
|
mesh -> UpdateTopology();
|
2011-01-11 01:18:01 +05:00
|
|
|
mesh -> GetCurvedElements().BuildCurvedElements (&ref, mparam.elementorder);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
multithread.running = 0;
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
delete opt;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_Bisect (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
cout << "Thread alrad running" << endl;
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
multithread.running = 1;
|
|
|
|
|
|
|
|
biopt.outfilename = NULL; // "ngfepp.vol";
|
|
|
|
biopt.femcode = "fepp";
|
|
|
|
biopt.refinementfilename = NULL;
|
|
|
|
|
|
|
|
if (argc >= 2)
|
|
|
|
biopt.refinementfilename = argv[1];
|
|
|
|
|
|
|
|
|
|
|
|
BisectDummy (0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
extern void BisectTets (Mesh &, const CSGeometry *);
|
|
|
|
BisectTets (*mesh, geometry);
|
|
|
|
*/
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int Ng_BisectCopyMesh (ClientData clientData,
|
|
|
|
// Tcl_Interp * interp,
|
|
|
|
// int argc, tcl_const char *argv[])
|
|
|
|
// {
|
2014-09-08 21:21:09 +06:00
|
|
|
// if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
// {
|
|
|
|
// Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
// return TCL_ERROR;
|
|
|
|
// }
|
|
|
|
// if (multithread.running)
|
|
|
|
// {
|
|
|
|
// Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
|
|
|
// return TCL_ERROR;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// BisectTetsCopyMesh (*mesh, geometry.Ptr(), biopt);
|
|
|
|
// return TCL_OK;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_Split2Tets (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
if (!mesh)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
if (multithread.running)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_ERROR;
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
mesh->Split2Tets ();
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-08-30 18:36:11 +06:00
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
extern int Ng_MeshDoctor (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-02 22:21:52 +05:00
|
|
|
SymbolTable<VisualScene*> & GetVisualizationScenes ()
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2019-01-02 22:21:52 +05:00
|
|
|
static SymbolTable<VisualScene*> vss;
|
2009-01-13 04:40:13 +05:00
|
|
|
return vss;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddVisualizationScene (const string & name,
|
|
|
|
VisualScene * avs)
|
|
|
|
{
|
|
|
|
GetVisualizationScenes().Set (name.c_str(), avs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SetVisualScene (Tcl_Interp * interp)
|
|
|
|
{
|
|
|
|
const char * vismode = vispar.selectvisual;
|
|
|
|
// Tcl_GetVar (interp, "selectvisual", 0);
|
2019-12-10 16:18:53 +05:00
|
|
|
VisualScene *& vs = visual_scene;
|
|
|
|
vs = &visual_scene_cross;
|
2009-01-13 04:40:13 +05:00
|
|
|
if (GetVisualizationScenes().Used(vismode))
|
|
|
|
{
|
2019-01-02 22:21:52 +05:00
|
|
|
vs = GetVisualizationScenes()[vismode];
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
else if (vismode)
|
|
|
|
{
|
|
|
|
if (strcmp (vismode, "geometry") == 0)
|
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
for (int i = 0; i < geometryregister.Size(); i++)
|
|
|
|
{
|
2014-09-08 21:21:09 +06:00
|
|
|
VisualScene * hvs = geometryregister[i]->GetVisualScene (ng_geometry.get());
|
2011-01-11 01:18:01 +05:00
|
|
|
if (hvs)
|
|
|
|
{
|
|
|
|
vs = hvs;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef ACIS
|
|
|
|
else if (acisgeometry)
|
|
|
|
vs = &vsacisgeom;
|
|
|
|
#endif // ACIS
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
if (strcmp (vismode, "mesh") == 0)
|
|
|
|
{
|
|
|
|
if (!meshdoctor.active)
|
|
|
|
vs = &vsmesh;
|
|
|
|
else
|
|
|
|
vs = &vsmeshdoc;
|
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2019-09-22 01:08:35 +05:00
|
|
|
if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing;
|
2009-01-13 04:40:13 +05:00
|
|
|
if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints;
|
2017-08-28 21:19:20 +05:00
|
|
|
if (strcmp (vismode, "solution") == 0) vs = &netgen::GetVSSolution();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-20 14:08:01 +05:00
|
|
|
|
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
Font * font = nullptr;
|
2011-02-28 18:34:54 +05:00
|
|
|
Togl * togl = NULL;
|
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
void MyOpenGLText_GUI (const char * text)
|
2009-09-09 03:54:32 +06:00
|
|
|
{
|
2016-02-08 19:53:16 +05:00
|
|
|
glListBase (font->getDisplayListsBase());
|
|
|
|
glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
Ng_ToglVersion(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, (char*)"2", TCL_STATIC);
|
|
|
|
return TCL_OK;
|
2009-09-09 03:54:32 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
|
|
|
{
|
2016-02-08 19:53:16 +05:00
|
|
|
// cout << "call init" << endl;
|
2009-09-09 04:14:23 +06:00
|
|
|
|
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
|
|
|
|
return TCL_ERROR;
|
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
// possible values: 12,14,16,18,20,22,24,28,32
|
|
|
|
font = selectFont(18);
|
2009-09-09 03:54:32 +06:00
|
|
|
|
2016-12-02 16:27:26 +05:00
|
|
|
LoadOpenGLFunctionPointers();
|
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
SetVisualScene (Togl_Interp(togl));
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->DrawScene();
|
2022-10-06 18:29:13 +05:00
|
|
|
Set_OpenGLText_Callback (&MyOpenGLText_GUI, font->Width());
|
2009-09-09 03:54:32 +06:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
zap(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
|
|
|
{
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
draw(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
|
|
|
{
|
|
|
|
SetVisualScene (interp);
|
|
|
|
|
|
|
|
glPushMatrix();
|
2011-02-28 18:34:54 +05:00
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
glLoadIdentity();
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->DrawScene();
|
2009-09-09 03:54:32 +06:00
|
|
|
Togl_SwapBuffers(togl);
|
2011-02-28 18:34:54 +05:00
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
reshape(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
|
|
|
|
{
|
|
|
|
int w = Togl_Width (togl);
|
|
|
|
int h = Togl_Height (togl);
|
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
// glViewport(0, 0, w, h);
|
|
|
|
int res[4];
|
|
|
|
glGetIntegerv(GL_VIEWPORT, res);
|
|
|
|
// cout << "w = " << w << " h = " << h << endl;
|
|
|
|
w = res[2];
|
|
|
|
h = res[3];
|
|
|
|
/*
|
|
|
|
cout << "viewport: "
|
|
|
|
<< res[0] << " "
|
|
|
|
<< res[1] << " "
|
|
|
|
<< res[2] << " "
|
|
|
|
<< res[3] << endl;
|
|
|
|
*/
|
|
|
|
// change font size according to window width
|
|
|
|
font = selectFont(w/80);
|
2009-09-09 03:54:32 +06:00
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
// OpenGL near and far clipping planes
|
|
|
|
double pnear = 0.1;
|
|
|
|
double pfar = 10;
|
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
gluPerspective(20.0f, double(w) / h, pnear, pfar);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-22 20:24:17 +05:00
|
|
|
static int Ng_SnapShot(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2017-05-22 20:24:17 +05:00
|
|
|
struct Togl *togl;
|
|
|
|
if (Togl_GetToglFromObj(interp, argv[1], &togl) != TCL_OK)
|
|
|
|
return TCL_ERROR;
|
|
|
|
const char * filename = Tcl_GetString(argv[2]);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2018-05-24 00:14:49 +05:00
|
|
|
int w = Togl_PixelScale(togl)*Togl_Width (togl);
|
|
|
|
int h = Togl_PixelScale(togl)*Togl_Height (togl);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<unsigned char> buffer(w*h*3);
|
2017-09-22 14:06:00 +05:00
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
|
|
|
glPixelStorei(GL_PACK_ALIGNMENT,1);
|
2017-05-22 20:24:17 +05:00
|
|
|
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2017-05-22 20:24:17 +05:00
|
|
|
#ifdef JPEGLIB
|
2024-09-03 14:11:45 +05:00
|
|
|
int len = strlen(filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
if (strcmp ("jpg", filename+len-3) == 0)
|
|
|
|
{
|
|
|
|
cout << "Snapshot to file '" << filename << "'" << endl;
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
struct jpeg_compress_struct cinfo;
|
2009-01-13 04:40:13 +05:00
|
|
|
struct jpeg_error_mgr jerr;
|
|
|
|
FILE *outfile = fopen(filename,"wb");
|
|
|
|
JSAMPROW row_pointer[1];
|
2014-04-28 13:10:21 +06:00
|
|
|
int row_stride, quality = 100; // 1...100
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
cinfo.err = jpeg_std_error( &jerr );
|
|
|
|
jpeg_create_compress( &cinfo );
|
|
|
|
jpeg_stdio_dest( &cinfo, outfile );
|
2009-01-31 03:12:17 +05:00
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
cinfo.image_width = w;
|
|
|
|
cinfo.image_height = h;
|
|
|
|
cinfo.input_components = 3;
|
|
|
|
cinfo.in_color_space = JCS_RGB;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
jpeg_set_defaults( &cinfo );
|
2014-04-28 13:10:21 +06:00
|
|
|
jpeg_set_quality( &cinfo, quality, FALSE ); // TRUE
|
2009-01-13 04:40:13 +05:00
|
|
|
jpeg_start_compress( &cinfo, TRUE );
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
row_stride = 3*w;
|
|
|
|
while( cinfo.next_scanline < cinfo.image_height ) {
|
|
|
|
row_pointer[0] = &buffer[ (h-1-cinfo.next_scanline) * row_stride ];
|
|
|
|
(void)jpeg_write_scanlines( &cinfo, row_pointer, 1 );
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
jpeg_finish_compress( &cinfo );
|
|
|
|
fclose( outfile );
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
jpeg_destroy_compress( &cinfo );
|
2009-01-31 03:12:17 +05:00
|
|
|
fprintf( stdout, "done [ok]\n" );
|
2009-01-13 04:40:13 +05:00
|
|
|
fflush( stdout );
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2017-05-22 20:24:17 +05:00
|
|
|
#endif // JPEGLIB
|
|
|
|
{
|
2017-09-22 14:06:00 +05:00
|
|
|
string command;
|
2024-08-07 13:49:21 +05:00
|
|
|
std::filesystem::path filepath(filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2024-08-07 13:49:21 +05:00
|
|
|
bool need_conversion = filepath.extension() != ".ppm";
|
|
|
|
if (need_conversion)
|
|
|
|
filepath += ".ppm";
|
2017-09-22 14:06:00 +05:00
|
|
|
|
2024-08-07 13:49:21 +05:00
|
|
|
cout << IM(3) << "Snapshot to file '" << filepath.string() << endl;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2024-08-07 13:49:21 +05:00
|
|
|
ofstream outfile(filepath);
|
2017-05-22 20:24:17 +05:00
|
|
|
outfile << "P6" << endl
|
|
|
|
<< "# CREATOR: Netgen" << endl
|
|
|
|
<< w << " " << h << endl
|
|
|
|
<< "255" << endl;
|
|
|
|
for (int i = 0; i < h; i++)
|
|
|
|
for (int j = 0; j < w; j++)
|
|
|
|
for (int k = 0; k < 3; k++)
|
|
|
|
outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
|
|
|
|
outfile << flush;
|
|
|
|
|
2024-08-07 13:49:21 +05:00
|
|
|
if (need_conversion)
|
2017-05-22 20:24:17 +05:00
|
|
|
{
|
2017-09-22 14:06:00 +05:00
|
|
|
// convert image file (Unix/Linux only):
|
2024-08-07 13:49:21 +05:00
|
|
|
command = string("convert -quality 100 ") + filepath.string() + " " + filename;
|
2017-09-22 14:06:00 +05:00
|
|
|
|
|
|
|
int err = system(command.c_str());
|
|
|
|
if (err != 0)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file, stored as .ppm", TCL_VOLATILE);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2024-08-07 13:49:21 +05:00
|
|
|
std::filesystem::remove(filepath);
|
2017-05-22 20:24:17 +05:00
|
|
|
}
|
2024-08-07 13:49:21 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
2017-05-22 20:24:17 +05:00
|
|
|
}
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2009-04-05 21:10:33 +06:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef FFMPEG
|
2017-02-03 19:28:59 +05:00
|
|
|
static int Ng_VideoClip(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
|
|
|
|
{
|
|
|
|
static Mpeg mpeg;
|
|
|
|
struct Togl *togl;
|
|
|
|
if (Togl_GetToglFromObj(interp, argv[1], &togl) != TCL_OK)
|
|
|
|
return TCL_ERROR;
|
2009-04-07 19:15:21 +06:00
|
|
|
|
2017-02-03 19:28:59 +05:00
|
|
|
if (strcmp (Tcl_GetString(argv[2]), "init") == 0)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
// Can't initialize when running:
|
|
|
|
//-------------------------------
|
2017-02-03 19:28:59 +05:00
|
|
|
if( mpeg.IsStarted() ) {
|
2009-01-13 04:40:13 +05:00
|
|
|
cout << "cannot initialize: already running" << endl;
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
|
2017-02-03 19:28:59 +05:00
|
|
|
const char * filename = Tcl_GetString(argv[3]);
|
|
|
|
mpeg.Start(filename);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
2009-04-05 21:10:33 +06:00
|
|
|
|
|
|
|
|
2017-02-03 19:28:59 +05:00
|
|
|
else if (strcmp (Tcl_GetString(argv[2]), "addframe") == 0)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2017-02-03 19:28:59 +05:00
|
|
|
if(mpeg.AddFrame())
|
2009-04-05 21:10:33 +06:00
|
|
|
return TCL_ERROR;
|
2009-01-31 03:12:17 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-05 21:10:33 +06:00
|
|
|
|
2017-02-03 19:28:59 +05:00
|
|
|
else if (strcmp (Tcl_GetString(argv[2]), "finalize") == 0)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2017-02-03 19:28:59 +05:00
|
|
|
mpeg.Stop();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
2017-02-03 19:28:59 +05:00
|
|
|
#else // FFMPEG
|
|
|
|
static int Ng_VideoClip(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2010-04-22 17:44:07 +06:00
|
|
|
Tcl_SetResult (Togl_Interp(togl), (char*)"Video not available, Netgen was not compiled with FFMPEG library", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
2017-02-03 19:28:59 +05:00
|
|
|
#endif // FFMPEG
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_MouseMove (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
int oldx, oldy;
|
|
|
|
int newx, newy;
|
|
|
|
|
|
|
|
oldx = atoi (argv[1]);
|
|
|
|
oldy = atoi (argv[2]);
|
|
|
|
newx = atoi (argv[3]);
|
|
|
|
newy = atoi (argv[4]);
|
|
|
|
|
|
|
|
SetVisualScene(interp);
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->MouseMove (oldx, oldy, newx, newy, argv[5][0]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_MouseDblClick (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2018-05-24 00:14:49 +05:00
|
|
|
int px = Togl_PixelScale(togl)*atoi (argv[1]);
|
|
|
|
int py = Togl_PixelScale(togl)*atoi (argv[2]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
SetVisualScene(interp);
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->MouseDblClick (px, py);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_ZoomAll (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
SetVisualScene(interp);
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->BuildScene (1);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int Ng_Center (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
SetVisualScene(interp);
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->BuildScene (2);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int Ng_StandardRotation (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
SetVisualScene(interp);
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->StandardRotation (argv[1]);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int Ng_ArbitraryRotation (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
|
|
|
SetVisualScene(interp);
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<double> alpha;
|
|
|
|
NgArray<Vec3d> vec;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
for(int i=1; i<argc; i+=4)
|
|
|
|
{
|
|
|
|
alpha.Append(atof(argv[i]));
|
|
|
|
vec.Append(Vec3d(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3])));
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2019-12-10 16:18:53 +05:00
|
|
|
visual_scene->ArbitraryRotation (alpha,vec);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int Ng_Metis (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2015-02-06 03:53:17 +05:00
|
|
|
#ifdef PARALLEL
|
2011-01-11 01:18:01 +05:00
|
|
|
if (!mesh)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2015-02-06 03:53:17 +05:00
|
|
|
int nparts = atoi (argv[1]);
|
|
|
|
ntasks = nparts+1;
|
|
|
|
cout << "calling metis ... " << flush;
|
2021-06-08 16:48:27 +05:00
|
|
|
mesh->ParallelMetis(ntasks);
|
2015-02-06 03:53:17 +05:00
|
|
|
cout << "done" << endl;
|
|
|
|
ntasks = 1;
|
2019-02-15 18:34:27 +05:00
|
|
|
|
|
|
|
// for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++)
|
|
|
|
// (*mesh)[ei].SetIndex ( (*mesh)[ei].GetPartition() );
|
2015-02-06 03:53:17 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
|
|
|
|
#else
|
|
|
|
Tcl_SetResult (interp, (char*)"metis not available", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef OLDOLD
|
2011-01-11 01:18:01 +05:00
|
|
|
// METIS Partitioning
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
if (mesh->GetDimension() == 3)
|
|
|
|
{
|
|
|
|
using namespace metis;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int ne = mesh->GetNE();
|
|
|
|
if (ne < 3)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, "This operation needs a volume mesh", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int nn = mesh->GetNP();
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
ELEMENT_TYPE elementtype = mesh->VolumeElement(1).GetType();
|
|
|
|
int npe = mesh->VolumeElement(1).GetNP();
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
for (int i = 2; i<=ne; i++)
|
|
|
|
if (mesh->VolumeElement(i).GetType() != elementtype)
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, "Works in 3D only uniformal tet or hex meshes", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
idxtype *elmnts;
|
|
|
|
elmnts = new idxtype[ne*npe];
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int etype;
|
|
|
|
if (elementtype == TET)
|
|
|
|
etype = 2;
|
|
|
|
else if (elementtype == HEX)
|
|
|
|
etype = 3;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Tcl_SetResult (interp, "Works in 3D only uniformal tet or hex meshes", TCL_STATIC);
|
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
for (int i=1; i<=ne; i++)
|
|
|
|
for (int j=1; j<=npe; j++)
|
|
|
|
elmnts[(i-1)*npe+(j-1)] = mesh->VolumeElement(i).PNum(j)-1;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
int numflag = 0;
|
|
|
|
int nparts = atoi (argv[1]);
|
|
|
|
int edgecut;
|
|
|
|
idxtype *epart, *npart;
|
|
|
|
epart = new idxtype[ne];
|
|
|
|
npart = new idxtype[nn];
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
cout << "Starting Metis (" << ne << " Elements, " << nn << " Nodes, " << nparts << " Partitions) ... " << flush;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
METIS_PartMeshNodal (&ne, &nn, elmnts, &etype, &numflag, &nparts,
|
|
|
|
&edgecut, epart, npart);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
cout << "done" << endl;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
cout << "edge-cut: " << edgecut << ", balance: " << ComputeElementBalance(ne, nparts, epart) << endl;
|
|
|
|
|
|
|
|
for (int i=1; i<=ne; i++)
|
|
|
|
mesh->VolumeElement(i).SetPartition(epart[i-1]);
|
|
|
|
|
|
|
|
mesh->SetNextTimeStamp();
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
void SelectFaceInOCCDialogTree (int facenr)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
2011-01-11 01:18:01 +05:00
|
|
|
char script[50];
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (script, size(script), "selectentity {Face %i}", facenr);
|
2011-01-11 01:18:01 +05:00
|
|
|
Tcl_GlobalEval (tcl_interp, script);
|
2009-01-13 04:40:13 +05:00
|
|
|
}
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef ACIS
|
|
|
|
int Ng_ACISCommand (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
2009-01-31 03:12:17 +05:00
|
|
|
int argc, tcl_const char *argv[])
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
if (argc >= 2)
|
|
|
|
{
|
|
|
|
if (strcmp (argv[1], "isACISavailable") == 0)
|
|
|
|
{
|
2009-01-20 14:08:01 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"no", TCL_STATIC);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
}
|
2009-01-20 14:08:01 +05:00
|
|
|
Tcl_SetResult (interp, (char*)"undefined ACiS command", TCL_STATIC);
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_ERROR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-03-07 21:38:43 +05:00
|
|
|
// from ng_interface
|
|
|
|
void Ng_SetVisualizationParameter (const char * name, const char * value)
|
|
|
|
{
|
|
|
|
// #ifdef OPENGL
|
|
|
|
// #ifndef NOTCL
|
|
|
|
char buf[100];
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf (buf, size(buf), "visoptions.%s", name);
|
2011-03-07 21:38:43 +05:00
|
|
|
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<char*> (value), 0);
|
|
|
|
Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;");
|
|
|
|
// #endif
|
|
|
|
// #endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using namespace netgen;
|
|
|
|
|
2012-08-30 19:40:17 +06:00
|
|
|
void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler)
|
|
|
|
{
|
|
|
|
vsmesh.SetMouseEventHandler (handler);
|
|
|
|
}
|
|
|
|
|
2014-02-24 01:31:40 +06:00
|
|
|
void Ng_SetUserVisualizationObject (netgen::UserVisualizationObject * vis)
|
|
|
|
{
|
2017-08-28 21:19:20 +05:00
|
|
|
netgen::GetVSSolution().AddUserVisualizationObject (vis);
|
2014-02-24 01:31:40 +06:00
|
|
|
}
|
2012-08-30 19:40:17 +06:00
|
|
|
|
2011-03-07 21:38:43 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
int firsttime = 1;
|
|
|
|
int animcnt = 0;
|
|
|
|
void PlayAnimFile(const char* name, int speed, int maxcnt)
|
|
|
|
{
|
|
|
|
//extern Mesh * mesh;
|
|
|
|
|
|
|
|
/*
|
2014-09-08 21:21:09 +06:00
|
|
|
if (mesh) mesh->DeleteMesh();
|
|
|
|
if (!mesh) mesh = new Mesh();
|
2011-03-07 21:38:43 +05:00
|
|
|
*/
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh = make_shared<Mesh>();
|
2011-03-07 21:38:43 +05:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-12-08 19:19:07 +05:00
|
|
|
snprintf(str2, sizeof(str2), "%05i.sol",rti);
|
2011-03-07 21:38:43 +05:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
int Ng_SetVisParameters (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
2009-01-31 03:12:17 +05:00
|
|
|
{
|
2009-01-13 04:40:13 +05:00
|
|
|
if (!Tcl_GetVar (interp, "::viewoptions.light.amb", TCL_GLOBAL_ONLY))
|
|
|
|
return TCL_ERROR;
|
|
|
|
|
|
|
|
vispar.lightamb = atof (Tcl_GetVar (interp, "::viewoptions.light.amb", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.lightdiff = atof (Tcl_GetVar (interp, "::viewoptions.light.diff", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.lightspec = atof (Tcl_GetVar (interp, "::viewoptions.light.spec", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.shininess = atof (Tcl_GetVar (interp, "::viewoptions.mat.shininess", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.locviewer = atoi (Tcl_GetVar (interp, "::viewoptions.light.locviewer", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.transp = atof (Tcl_GetVar (interp, "::viewoptions.mat.transp", TCL_GLOBAL_ONLY));
|
2014-08-08 21:51:13 +06:00
|
|
|
|
2012-11-05 17:28:58 +06:00
|
|
|
VisualizationParameters::Clipping hclip;
|
|
|
|
hclip.normal.X() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.nx", TCL_GLOBAL_ONLY));
|
|
|
|
hclip.normal.Y() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.ny", TCL_GLOBAL_ONLY));
|
|
|
|
hclip.normal.Z() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.nz", TCL_GLOBAL_ONLY));
|
|
|
|
hclip.dist = atof (Tcl_GetVar (interp, "::viewoptions.clipping.dist", TCL_GLOBAL_ONLY));
|
2013-02-03 20:44:27 +06:00
|
|
|
hclip.dist2 = atof (Tcl_GetVar (interp, "::viewoptions.clipping.dist2", TCL_GLOBAL_ONLY));
|
2012-11-05 17:28:58 +06:00
|
|
|
hclip.enable = atoi (Tcl_GetVar (interp, "::viewoptions.clipping.enable", TCL_GLOBAL_ONLY));
|
2009-01-13 04:40:13 +05:00
|
|
|
vispar.clipdomain =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.clipping.onlydomain", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.donotclipdomain =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.clipping.notdomain", TCL_GLOBAL_ONLY));
|
|
|
|
|
2012-11-05 17:28:58 +06:00
|
|
|
if ( ! (hclip == vispar.clipping) )
|
2014-08-08 21:51:13 +06:00
|
|
|
{
|
|
|
|
vispar.clipping = hclip;
|
|
|
|
vispar.clipping.timestamp = NextTimeStamp();
|
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
vispar.whitebackground = atoi (Tcl_GetVar (interp, "::viewoptions.whitebackground", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawcoordinatecross = atoi (Tcl_GetVar (interp, "::viewoptions.drawcoordinatecross", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawcolorbar = atoi (Tcl_GetVar (interp, "::viewoptions.drawcolorbar", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawnetgenlogo = atoi (Tcl_GetVar (interp, "::viewoptions.drawnetgenlogo", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stereo = atoi (Tcl_GetVar (interp, "::viewoptions.stereo", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.colormeshsize = atoi (Tcl_GetVar (interp, "::viewoptions.colormeshsize", TCL_GLOBAL_ONLY));
|
|
|
|
VisualScene :: SetBackGroundColor (vispar.whitebackground ? 1 : 0);
|
|
|
|
|
|
|
|
strcpy (vispar.selectvisual, Tcl_GetVar (interp, "::selectvisual", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
// vispar.showstltrias = atoi (Tcl_GetVar (interp, "::viewoptions.stl.showtrias", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.stlshowtrias =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.showtrias", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlshowfilledtrias =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.showfilledtrias", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlshowedges =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.showedges", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlshowmarktrias =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.showmarktrias", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlshowactivechart =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.showactivechart", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlchartnumber =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.chartnumber", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.stlchartnumberoffset =
|
|
|
|
atoi (Tcl_GetVar (interp, "::stloptions.chartnumberoffset", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.occshowsurfaces =
|
2009-01-31 03:12:17 +05:00
|
|
|
atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", TCL_GLOBAL_ONLY));
|
2009-01-13 04:40:13 +05:00
|
|
|
vispar.occshowedges =
|
2009-01-31 03:12:17 +05:00
|
|
|
atoi (Tcl_GetVar (interp, "::occoptions.showedges", TCL_GLOBAL_ONLY));
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
vispar.drawoutline =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawoutline", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawfilledtrigs =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawfilledtrigs", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.subdivisions =
|
|
|
|
atoi (Tcl_GetVar (interp, "::visoptions.subdivisions", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawbadels =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawbadels", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawedges =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawedges", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.drawtetsdomain =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawtetsdomain", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawtets =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawtets", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawprisms =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawprisms", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawpyramids =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawpyramids", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawhexes =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawhexes", TCL_GLOBAL_ONLY));
|
2014-01-27 02:23:48 +06:00
|
|
|
/*
|
2009-01-13 04:40:13 +05:00
|
|
|
vispar.shrink =
|
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.shrink", TCL_GLOBAL_ONLY));
|
2014-01-27 02:23:48 +06:00
|
|
|
*/
|
|
|
|
double hshrink = atof (Tcl_GetVar (interp, "::viewoptions.shrink", TCL_GLOBAL_ONLY));
|
|
|
|
if (hshrink != vispar.shrink)
|
|
|
|
{ vispar.shrink = hshrink; vispar.clipping.timestamp = NextTimeStamp();}
|
2009-01-13 04:40:13 +05:00
|
|
|
vispar.drawidentified =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawidentified", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawpointnumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawpointnumbers", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawedgenumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawedgenumbers", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawfacenumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawfacenumbers", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawelementnumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawelementnumbers", TCL_GLOBAL_ONLY));
|
2023-08-29 19:43:25 +05:00
|
|
|
vispar.drawsurfaceelementnumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawsurfaceelementnumbers", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawsegmentnumbers =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawsegmentnumbers", TCL_GLOBAL_ONLY));
|
2009-01-13 04:40:13 +05:00
|
|
|
vispar.drawdomainsurf =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawdomainsurf", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.drawededges =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawededges", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawedpoints =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawedpoints", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawedpointnrs =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawedpointnrs", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawedtangents =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawedtangents", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawededgenrs =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawededgenrs", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.drawcurveproj =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawcurveproj", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawcurveprojedge =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawcurveprojedge", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
vispar.centerpoint =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.centerpoint", TCL_GLOBAL_ONLY));
|
2009-01-31 03:12:17 +05:00
|
|
|
vispar.use_center_coords =
|
2009-01-13 04:40:13 +05:00
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.usecentercoords", TCL_GLOBAL_ONLY)) > 0;
|
2009-01-31 03:12:17 +05:00
|
|
|
vispar.centerx =
|
2009-01-13 04:40:13 +05:00
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.centerx", TCL_GLOBAL_ONLY));
|
2009-01-31 03:12:17 +05:00
|
|
|
vispar.centery =
|
2009-01-13 04:40:13 +05:00
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.centery", TCL_GLOBAL_ONLY));
|
2009-01-31 03:12:17 +05:00
|
|
|
vispar.centerz =
|
2009-01-13 04:40:13 +05:00
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.centerz", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawelement =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawelement", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.drawmetispartition =
|
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawmetispartition", TCL_GLOBAL_ONLY));
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
vispar.drawspecpoint =
|
2009-01-13 04:40:13 +05:00
|
|
|
atoi (Tcl_GetVar (interp, "::viewoptions.drawspecpoint", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.specpointx =
|
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.specpointx", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.specpointy =
|
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.specpointy", TCL_GLOBAL_ONLY));
|
|
|
|
vispar.specpointz =
|
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.specpointz", TCL_GLOBAL_ONLY));
|
|
|
|
|
|
|
|
|
|
|
|
vsspecpoints.len =
|
|
|
|
atof (Tcl_GetVar (interp, "::viewoptions.specpointvlen", TCL_GLOBAL_ONLY));
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
vispar.occdeflection = pow(10.0,-1-atof (Tcl_GetVar (interp, "::occoptions.deflection", TCL_GLOBAL_ONLY)));
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PARALLELGL
|
|
|
|
vsmesh.Broadcast ();
|
2009-01-31 03:12:17 +05:00
|
|
|
#endif
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_BuildFieldLines (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2017-08-28 21:19:20 +05:00
|
|
|
netgen::GetVSSolution().BuildFieldLinesPlot();
|
2009-01-13 04:40:13 +05:00
|
|
|
return TCL_OK;
|
|
|
|
}
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
int Ng_Exit (ClientData clientData,
|
|
|
|
Tcl_Interp * interp,
|
|
|
|
int argc, tcl_const char *argv[])
|
|
|
|
{
|
2012-06-13 17:37:13 +06:00
|
|
|
/*
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef PARALLEL
|
|
|
|
int id, rc, ntasks;
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &id);
|
|
|
|
if ( id != 0 )
|
|
|
|
return TCL_OK;
|
|
|
|
#endif
|
2012-06-13 17:37:13 +06:00
|
|
|
*/
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
/*
|
|
|
|
if (ngsolve_handle)
|
|
|
|
{
|
|
|
|
void (*ngs_exit)();
|
|
|
|
ngs_exit = ( void (*)() ) dlsym (ngsolve_handle, "NGSolve_Exit");
|
|
|
|
if (ngs_exit) (*ngs_exit)();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef NGSOLVE
|
|
|
|
NGSolve_Exit ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ACIS
|
|
|
|
outcome res;
|
|
|
|
res = api_terminate_faceter();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with terminating acis faceter" << endl;
|
|
|
|
res = api_terminate_constructors();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with terminating acis constructors" << endl;
|
|
|
|
res = api_terminate_kernel();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with terminating acis kernel" << endl;
|
|
|
|
res = api_stop_modeller();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with terminating acis modeller" << endl;
|
|
|
|
|
|
|
|
//cout << "stopped acis, outcome = " << res.ok() << endl;
|
|
|
|
#endif
|
|
|
|
|
2019-03-16 10:30:47 +05:00
|
|
|
#ifdef PARALLELGL
|
2012-06-13 17:37:13 +06:00
|
|
|
if (id == 0) MyMPI_SendCmd ("end");
|
|
|
|
MPI_Finalize();
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|
2009-01-24 18:35:44 +05:00
|
|
|
|
2014-09-08 21:21:09 +06:00
|
|
|
mesh.reset();
|
|
|
|
ng_geometry.reset();
|
2011-06-30 18:49:38 +06:00
|
|
|
|
2009-01-24 18:35:44 +05:00
|
|
|
if (testout != &cout)
|
|
|
|
delete testout;
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
#ifdef SOCKETS
|
2009-01-13 04:40:13 +05:00
|
|
|
void * ServerSocketManagerRunDummy ( void * nix )
|
|
|
|
{
|
|
|
|
serversocketmanager.Run();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int Ng_ServerSocketManagerRun( void );
|
|
|
|
int Ng_ServerSocketManagerRun( void )
|
|
|
|
{
|
|
|
|
if(mparam.parthread)
|
|
|
|
RunParallel(ServerSocketManagerRunDummy,NULL);
|
|
|
|
else
|
|
|
|
serversocketmanager.Run();
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" int Ng_ServerSocketManagerInit(int port);
|
|
|
|
int Ng_ServerSocketManagerInit(int port)
|
|
|
|
{
|
|
|
|
serversocketmanager.Init(port);
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
#endif //SOCKETS
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" int Ng_Init (Tcl_Interp * interp);
|
2011-01-11 01:18:01 +05:00
|
|
|
extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
|
2011-03-03 02:50:49 +05:00
|
|
|
|
|
|
|
extern "C" int Ng_stl_Init (Tcl_Interp * interp);
|
|
|
|
extern "C" int Ng_geom2d_Init (Tcl_Interp * interp);
|
2012-06-12 16:01:59 +06:00
|
|
|
#ifdef OCCGEOMETRY
|
|
|
|
extern "C" int Ng_occ_Init (Tcl_Interp * interp);
|
2011-01-14 22:03:35 +05:00
|
|
|
#endif
|
|
|
|
|
2012-06-12 16:01:59 +06:00
|
|
|
|
2011-03-07 21:38:43 +05:00
|
|
|
// extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
// int main_Eero (ClientData clientData,
|
|
|
|
// Tcl_Interp * interp,
|
|
|
|
// int argc, tcl_const char *argv[]);
|
|
|
|
|
|
|
|
|
|
|
|
int Ng_Init (Tcl_Interp * interp)
|
|
|
|
{
|
|
|
|
#ifdef SOCKETS
|
|
|
|
if(serversocketmanager.Good())
|
|
|
|
serversocketusernetgen.Reset(new ServerSocketUserNetgen (serversocketmanager, mesh, geometry));
|
|
|
|
#endif
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
Ng_CSG_Init(interp);
|
2011-03-03 02:50:49 +05:00
|
|
|
Ng_stl_Init(interp);
|
|
|
|
Ng_geom2d_Init (interp);
|
2012-08-20 20:10:50 +06:00
|
|
|
#ifdef OCCGEOMETRY
|
|
|
|
Ng_occ_Init (interp);
|
2012-06-12 16:01:59 +06:00
|
|
|
#endif
|
2011-01-14 22:03:35 +05:00
|
|
|
|
|
|
|
|
2011-02-28 17:59:27 +05:00
|
|
|
// Ng_Geom2d_Init(interp);
|
2011-01-11 01:18:01 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
tcl_interp = interp;
|
|
|
|
|
|
|
|
// Tcl_CreateCommand (interp, "Ng_Eero", main_Eero,
|
|
|
|
// (ClientData)NULL,
|
|
|
|
// (Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_New", Ng_New,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
// Tcl_CreateCommand (interp, "Ng_Lock", Ng_Lock,
|
|
|
|
// (ClientData)NULL,
|
|
|
|
// (Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_LoadGeometry", Ng_LoadGeometry,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SaveGeometry", Ng_SaveGeometry,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_LoadMesh", Ng_LoadMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SaveMesh", Ng_SaveMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MergeMesh", Ng_MergeMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2023-10-09 23:41:02 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_GetImportFormats", Ng_GetImportFormats,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2019-08-04 14:12:19 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_GetExportFormats", Ng_GetExportFormats,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_ExportMesh", Ng_ExportMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ImportMesh", Ng_ImportMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ImportSolution", Ng_ImportSolution,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ShowDemo", Ng_ShowDemo,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_DemoSetTime", Ng_DemoSetTime,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SaveSolution", Ng_SaveSolution,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2010-08-10 00:03:25 +06:00
|
|
|
|
2009-03-15 17:25:09 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
// meshing
|
|
|
|
Tcl_CreateCommand (interp, "Ng_GenerateMesh", Ng_GenerateMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_StopMeshing", Ng_StopMeshing,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MeshInfo", Ng_MeshInfo,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MeshQuality", Ng_MeshQuality,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_CheckSurfaceMesh", Ng_CheckSurfaceMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_CheckVolumeMesh", Ng_CheckVolumeMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_DeleteVolMesh", Ng_DeleteVolMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SplitSeparatedFaces", Ng_SplitSeparatedFaces,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SetNextTimeStamp", Ng_SetNextTimeStamp,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_Refine", Ng_Refine,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SecondOrder", Ng_SecondOrder,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_HighOrder", Ng_HighOrder,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ValidateSecondOrder", Ng_ValidateSecondOrder,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_RestrictH", Ng_RestrictH,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_Anisotropy", Ng_Anisotropy,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_Bisect", Ng_Bisect,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
// Tcl_CreateCommand (interp, "Ng_BisectCopyMesh", Ng_BisectCopyMesh,
|
|
|
|
// (ClientData)NULL,
|
|
|
|
// (Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_Split2Tets", Ng_Split2Tets,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ZRefinement", Ng_ZRefinement,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_HPRefinement", Ng_HPRefinement,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_LoadMeshSize", Ng_LoadMeshSize,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MeshSizeFromSurfaceMesh", Ng_MeshSizeFromSurfaceMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
2009-06-19 11:41:22 +06:00
|
|
|
Tcl_CreateCommand (interp, "Ng_GenerateBoundaryLayer", Ng_GenerateBoundaryLayer,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_InsertVirtualBL", Ng_InsertVirtualBL,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_CutOffAndCombine", Ng_CutOffAndCombine,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_HelmholtzMesh", Ng_HelmholtzMesh,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ReadStatus", Ng_ReadStatus,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MemInfo", Ng_MemInfo,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MeshDoctor", Ng_MeshDoctor,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_BCProp", Ng_BCProp,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_ACISCommand",
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_ACISCommand,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MouseMove", Ng_MouseMove,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_MouseDblClick", Ng_MouseDblClick,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ZoomAll", Ng_ZoomAll,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_Center", Ng_Center,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_StandardRotation", Ng_StandardRotation,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_ArbitraryRotation", Ng_ArbitraryRotation,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SetVisParameters", Ng_SetVisParameters,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_SetMeshingParameters", Ng_SetMeshingParameters,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
Tcl_CreateCommand (interp, "Ng_SetDebugParameters", Ng_SetDebugParameters,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2019-08-04 21:59:01 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_SetCommandLineParameter",
|
|
|
|
Ng_SetCommandLineParameter,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_GetCommandLineParameter",
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_GetCommandLineParameter,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_Exit",
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_Exit,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_Metis",
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_Metis,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_CreateCommand (interp, "Ng_BuildFieldLines",
|
2009-01-13 04:40:13 +05:00
|
|
|
Ng_BuildFieldLines,
|
|
|
|
(ClientData)NULL,
|
|
|
|
(Tcl_CmdDeleteProc*) NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Specify the C callback functions for widget creation, display,
|
|
|
|
* and reshape.
|
|
|
|
*/
|
2016-02-08 19:53:16 +05:00
|
|
|
Tcl_CreateObjCommand(interp, "Ng_GetToglVersion", Ng_ToglVersion, NULL, NULL);
|
|
|
|
|
2009-09-09 04:14:23 +06:00
|
|
|
if (!nodisplay)
|
2009-09-09 03:54:32 +06:00
|
|
|
{
|
2009-09-09 04:14:23 +06:00
|
|
|
if (Togl_Init(interp) == TCL_ERROR)
|
|
|
|
return TCL_ERROR;
|
|
|
|
|
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
Tcl_CreateObjCommand(interp, "init", init, NULL, NULL);
|
|
|
|
Tcl_CreateObjCommand(interp, "zap", zap, NULL, NULL);
|
|
|
|
Tcl_CreateObjCommand(interp, "draw", draw, NULL, NULL);
|
|
|
|
Tcl_CreateObjCommand(interp, "reshape", reshape, NULL, NULL);
|
2009-09-09 04:14:23 +06:00
|
|
|
|
2009-09-09 03:54:32 +06:00
|
|
|
// Togl_TimerFunc( idle );
|
2017-05-22 20:24:17 +05:00
|
|
|
Tcl_CreateObjCommand(interp, "Ng_SnapShot", Ng_SnapShot, NULL, NULL);
|
2017-02-03 19:28:59 +05:00
|
|
|
Tcl_CreateObjCommand(interp, "Ng_VideoClip", Ng_VideoClip, NULL, NULL);
|
2009-09-09 03:54:32 +06:00
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
multithread.pause = 0;
|
|
|
|
multithread.testmode = 0;
|
|
|
|
multithread.redraw = 0;
|
|
|
|
multithread.drawing = 1;
|
|
|
|
multithread.terminate = 0;
|
|
|
|
multithread.running = 0;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
multithread.task = "";
|
|
|
|
multithread.percent = 20;
|
|
|
|
|
2009-01-31 03:12:17 +05:00
|
|
|
|
|
|
|
Tcl_LinkVar (interp, "multithread_pause",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.pause, TCL_LINK_INT);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_LinkVar (interp, "multithread_testmode",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.testmode, TCL_LINK_INT);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_LinkVar (interp, "multithread_redraw",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.redraw, TCL_LINK_INT);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_LinkVar (interp, "multithread_drawing",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.drawing, TCL_LINK_INT);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_LinkVar (interp, "multithread_terminate",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.terminate, TCL_LINK_INT);
|
2009-01-31 03:12:17 +05:00
|
|
|
Tcl_LinkVar (interp, "multithread_running",
|
2009-01-13 04:40:13 +05:00
|
|
|
(char*)&multithread.running, TCL_LINK_INT);
|
|
|
|
|
|
|
|
|
|
|
|
//testout->setstate(ios_base::badbit);
|
|
|
|
|
|
|
|
myerr = &cerr;
|
|
|
|
extern ostream * mycout;
|
|
|
|
mycout = &cout;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
testmode = 0;
|
|
|
|
|
2011-01-11 01:18:01 +05:00
|
|
|
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef ACIS
|
|
|
|
outcome res;
|
|
|
|
res = api_start_modeller (0);
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with starting acis modeller" << endl;
|
2009-01-31 03:12:17 +05:00
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#ifdef ACIS_R17
|
|
|
|
unlock_spatial_products_661();
|
2009-01-31 03:12:17 +05:00
|
|
|
#endif
|
2009-01-13 04:40:13 +05:00
|
|
|
res = api_initialize_kernel();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with starting acis kernel" << endl;
|
|
|
|
res = api_initialize_constructors();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with starting acis constructors" << endl;
|
|
|
|
res = api_initialize_faceter();
|
|
|
|
if(!res.ok())
|
|
|
|
cerr << "problem with starting acis faceter" << endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return TCL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|