1 /*
2
3 The interface between the GUI and the netgen library
4
5 */
6
7 #include <mystdlib.h>
8 #include <myadt.hpp>
9 #include <linalg.hpp>
10
11 #include <meshing.hpp>
12
13
14 #include <inctcl.hpp>
15 #include <visual.hpp>
16
17
18 #include <csg.hpp>
19
20 #ifdef SOCKETS
21 #include "../libsrc/sockets/sockets.hpp"
22 #include "../libsrc/sockets/socketmanager.hpp"
23 #endif
24
25
26 // to be sure to include the 'right' togl-version
27 #include "Togl2.1/togl.h"
28 // EXTERN int Togl_PixelScale (const Togl * togl);
29
30 #include "fonts.hpp"
31
32 extern bool nodisplay;
33
34 #include <nginterface.h>
35
36
37 #include "../libsrc/interface/writeuser.hpp"
38
39 namespace netgen
40 {
41 DLL_HEADER extern MeshingParameters mparam;
42 DLL_HEADER extern void ImportSolution2(const char * filename);
43 #include "demoview.hpp"
44 }
45
46
47 #ifdef ACIS
48 #include "ng_acis.hpp"
49 #endif
50
51
52 #ifdef JPEGLIB
53 #include <jpeglib.h>
54 #endif
55
56 #ifdef FFMPEG
57 #include "encoding.hpp"
58 #endif
59
60 #ifdef NGSOLVE
61 extern "C" void NGSolve_Exit();
62 #endif
63
64 // extern void * ngsolve_handle;
65
66
67 namespace netgen
68 {
69 extern Flags parameters;
70
71 /*
72 NetgenOutStream operator<< ( ostream & ost, Imp imp )
73 {
74 return ( NetgenOutStream ( &ost, imp ) );
75 }
76
77 NetgenOutStream operator<< ( ostream & ost, Proc proc )
78 {
79 return ( NetgenOutStream ( &ost, proc ) );
80 }
81
82
83 NetgenOutStream operator<< ( ostream & ost, Procs & procs )
84 {
85 return ( NetgenOutStream ( &ost, procs ) );
86 }
87 */
88
89 DLL_HEADER extern std::shared_ptr<NetgenGeometry> ng_geometry;
90 DLL_HEADER extern std::shared_ptr<Mesh> mesh;
91 Tcl_Interp * tcl_interp;
92
93
94 #ifdef SOCKETS
95 AutoPtr<ClientSocket> clientsocket;
96 ServerSocketManager serversocketmanager;
97 //NgArray< AutoPtr < ServerInfo > > servers;
98 NgArray< ServerInfo* > servers;
99 AutoPtr<ServerSocketUserNetgen> serversocketusernetgen;
100 #endif
101
102
103
104 // visualization scenes, pointer vs selects which one is drawn:
105
106 DLL_HEADER extern VisualSceneSurfaceMeshing vssurfacemeshing;
107 DLL_HEADER extern VisualSceneMeshDoctor vsmeshdoc;
108
109 static VisualSceneSpecPoints vsspecpoints;
110
111
112
113 DLL_HEADER extern VisualScene *visual_scene;
114 DLL_HEADER extern VisualScene visual_scene_cross;
115
116
117
118 extern char * err_needsmesh;// = (char*) "This operation needs a mesh";
119 extern char * err_jobrunning;// = (char*) "Meshing Job already running";
120
121
122
123
124
125 #ifndef SMALLLIB
126 // // Destination for messages, errors, ...
127 #ifndef WIN32
Ng_PrintDest(const char * s)128 DLL_HEADER void Ng_PrintDest(const char * s)
129 {
130 /*
131 #ifdef PARALLEL
132 int id, ntasks;
133 MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
134 MPI_Comm_rank(MPI_COMM_WORLD, &id);
135 #else
136 int id = 0; int ntasks = 1;
137 #endif
138 */
139
140 if (id == 0)
141 (*mycout) << s << flush;
142
143 /*
144 if ( ntasks == 1 )
145 (*mycout) << s << flush;
146 else
147 (*mycout) << "p" << id << ": " << s << flush ;
148 */
149 }
150 #endif
MyError2(const char * ch)151 void MyError2(const char * ch)
152 {
153 cout << ch;
154 (*testout) << "Error !!! " << ch << endl << flush;
155 }
156 #endif
157
158 static clock_t starttimea;
ResetTime2()159 void ResetTime2 ()
160 {
161 starttimea = clock();
162 }
163
164 #ifndef SMALLLIB
GetTime2()165 double GetTime2 ()
166 {
167 return double(clock() - starttimea) / CLOCKS_PER_SEC;
168 }
169 #endif
170
171
172
173
174
175 // file handling ..
Ng_New(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])176 int Ng_New (ClientData clientData,
177 Tcl_Interp * interp,
178 int argc, tcl_const char *argv[])
179 {
180 if (strcmp (argv[1], "mesh") == 0)
181 mesh.reset();
182
183 if (strcmp (argv[1], "geom") == 0)
184 {
185 /*
186 delete ng_geometry;
187 ng_geometry = new NetgenGeometry;
188 */
189 ng_geometry = make_shared<NetgenGeometry>();
190 }
191
192 return TCL_OK;
193 }
194
195
196
197
198 int Ng_ImportMesh (ClientData clientData,
199 Tcl_Interp * interp,
200 int argc, tcl_const char *argv[]);
201
Ng_LoadMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])202 int Ng_LoadMesh (ClientData clientData,
203 Tcl_Interp * interp,
204 int argc, tcl_const char *argv[])
205 {
206 string filename (argv[1]);
207
208 if (filename.find(".vol") == string::npos)
209 {
210 return Ng_ImportMesh(clientData,interp,argc,argv);
211 }
212
213 PrintMessage (1, "load mesh from file ", filename);
214
215 mesh = make_shared<Mesh>();
216 try
217 {
218 istream * infile;
219 // if (filename.substr (filename.length()-3, 3) == ".gz")
220 if (filename.find(".vol.gz") != string::npos)
221 infile = new igzstream (filename.c_str());
222 else
223 infile = new ifstream (filename.c_str());
224
225 // ifstream infile(filename.c_str());
226 mesh -> Load(*infile);
227 // vsmesh.SetMesh (mesh);
228 SetGlobalMesh (mesh);
229
230 #ifdef PARALLEL
231 MyMPI_SendCmd ("mesh");
232 mesh -> Distribute();
233 #endif
234 for (int i = 0; i < geometryregister.Size(); i++)
235 {
236 NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (*infile);
237 if (hgeom)
238 {
239 ng_geometry = shared_ptr<NetgenGeometry>(hgeom);
240 break;
241 }
242 }
243 delete infile;
244
245 /*
246 string auxstring;
247 if(infile.good())
248 {
249 infile >> auxstring;
250 if(auxstring == "csgsurfaces")
251 {
252 CSGeometry * geometry = new CSGeometry ("");
253 geometry -> LoadSurfaces(infile);
254
255 delete ng_geometry;
256 ng_geometry = geometry;
257 }
258 }
259 */
260 }
261 catch (NgException e)
262 {
263 PrintMessage (3, e.What());
264 return TCL_ERROR;
265 }
266
267 PrintMessage (2, mesh->GetNP(), " Points, ",
268 mesh->GetNE(), " Elements.");
269
270 return TCL_OK;
271 }
272
273
274
275
276
Ng_SaveMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])277 int Ng_SaveMesh (ClientData clientData,
278 Tcl_Interp * interp,
279 int argc, tcl_const char *argv[])
280 {
281 if (!mesh)
282 {
283 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
284 return TCL_ERROR;
285 }
286
287 string filename (argv[1]);
288 PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
289
290 ostream * outfile;
291 if (filename.substr (filename.length()-3, 3) == ".gz")
292 outfile = new ogzstream (filename.c_str());
293 else
294 outfile = new ofstream (filename.c_str());
295
296 mesh -> Save (*outfile);
297 // *outfile << endl << endl << "endmesh" << endl << endl;
298
299 if (ng_geometry && !mesh->GetGeometry())
300 ng_geometry -> SaveToMeshFile (*outfile);
301
302 delete outfile;
303 PrintMessage (1, "Save mesh to file .... DONE!");
304 return TCL_OK;
305 }
306
307
308
309
310
Ng_MergeMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])311 int Ng_MergeMesh (ClientData clientData,
312 Tcl_Interp * interp,
313 int argc, tcl_const char *argv[])
314 {
315 string filename (argv[1]);
316
317 PrintMessage (1, "merge with mesh from file ", filename);
318
319 try
320 {
321 CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry.get());
322
323 //mesh -> Merge (filename);
324 ifstream infile(filename.c_str());
325 const int offset = (geometry) ? geometry->GetNSurf() : 0;
326 mesh -> Merge(infile,offset);
327
328 string auxstring;
329 if(infile.good())
330 {
331 infile >> auxstring;
332 if(geometry && auxstring == "csgsurfaces")
333 geometry -> LoadSurfaces(infile);
334 }
335 }
336 catch (NgException e)
337 {
338 PrintMessage (3, e.What());
339 return TCL_ERROR;
340 }
341
342 PrintMessage (2, mesh->GetNP(), " Points, ",
343 mesh->GetNSE(), " Surface Elements.");
344
345 return TCL_OK;
346 }
347
348
Ng_GetExportFormats(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])349 int Ng_GetExportFormats (ClientData clientData,
350 Tcl_Interp * interp,
351 int argc, tcl_const char *argv[])
352 {
353 NgArray<const char*> userformats;
354 NgArray<const char*> extensions;
355 RegisterUserFormats (userformats, extensions);
356
357 ostringstream fstr;
358 for (int i = 1; i <= userformats.Size(); i++)
359 fstr << "{ {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n";
360
361 Tcl_SetResult (interp, const_cast<char*>(fstr.str().c_str()), TCL_VOLATILE);
362 return TCL_OK;
363 }
364
365
Ng_ExportMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])366 int Ng_ExportMesh (ClientData clientData,
367 Tcl_Interp * interp,
368 int argc, tcl_const char *argv[])
369 {
370 if (!mesh)
371 {
372 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
373 return TCL_ERROR;
374 }
375
376 string filename (argv[1]);
377 string filetype (argv[2]);
378 PrintMessage (1, "Export mesh to file ", filename, ".... Please Wait!");
379
380 // CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
381 if (WriteUserFormat (filetype, *mesh, /* *ng_geometry, */ filename))
382 {
383 ostringstream ost;
384 ost << "Sorry, nothing known about file format " << filetype << endl;
385 Tcl_SetResult (interp, (char*)ost.str().c_str(), TCL_VOLATILE);
386 return TCL_ERROR;
387 }
388
389 PrintMessage (1, "Export mesh to file .... DONE!");
390 return TCL_OK;
391 }
392
393
394
Ng_ImportMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])395 int Ng_ImportMesh (ClientData clientData,
396 Tcl_Interp * interp,
397 int argc, tcl_const char *argv[])
398 {
399 const string filename (argv[1]);
400 PrintMessage (1, "import mesh from ", filename);
401
402 mesh = make_shared<Mesh>();
403
404 ReadFile (*mesh, filename);
405 PrintMessage (2, mesh->GetNP(), " Points, ",
406 mesh->GetNE(), " Elements.");
407
408 SetGlobalMesh (mesh);
409 mesh->SetGlobalH (mparam.maxh);
410 mesh->CalcLocalH(mparam.grading);
411
412 return TCL_OK;
413 }
414
415
416
Ng_ImportSolution(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])417 int Ng_ImportSolution (ClientData clientData,
418 Tcl_Interp * interp,
419 int argc, tcl_const char *argv[])
420 {
421 if (!mesh)
422 {
423 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
424 return TCL_ERROR;
425 }
426
427 const char * filename = argv[1];
428 PrintMessage (1, "Import solution from file ", filename);
429
430 ImportSolution2 (filename);
431 return TCL_OK;
432 }
433
434
435
436 static DemoView * demoview = 0;
Ng_ShowDemo(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])437 int Ng_ShowDemo (ClientData clientData,
438 Tcl_Interp * interp,
439 int argc, tcl_const char *argv[])
440 {
441 const char * filename = argv[1];
442 PrintMessage (1, "Show demo ", filename);
443 demoview = new DemoView (filename);
444
445 return TCL_OK;
446 }
447
448
449
Ng_DemoSetTime(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])450 int Ng_DemoSetTime (ClientData clientData,
451 Tcl_Interp * interp,
452 int argc, tcl_const char *argv[])
453 {
454 cout << "demosettime, time = " << argv[1] << endl;
455 int result = -1;
456
457 static char strminusone[] = "-1";
458 static char str0[] = "0";
459
460 if (demoview)
461 result = demoview->SetTime (atof (argv[1]));
462
463 if (result == -1)
464 Tcl_SetResult (interp, strminusone, TCL_STATIC);
465 else
466 Tcl_SetResult (interp, str0, TCL_STATIC);
467
468 return TCL_OK;
469 }
470
471
472
473
474
475
476
Ng_SaveSolution(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])477 int Ng_SaveSolution (ClientData clientData,
478 Tcl_Interp * interp,
479 int argc, tcl_const char *argv[])
480 {
481 if (!mesh)
482 {
483 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
484 return TCL_ERROR;
485 }
486
487 const char * filename = argv[1];
488 PrintMessage (1, "Save solution to file ", filename);
489
490 netgen::GetVSSolution().SaveSolutionData (filename);
491 return TCL_OK;
492 }
493
494
495
496
Ng_SetNextTimeStamp(ClientData clientData,Tcl_Interp * interp,int argqc,tcl_const char * argv[])497 int Ng_SetNextTimeStamp (ClientData clientData,
498 Tcl_Interp * interp,
499 int argqc, tcl_const char *argv[])
500 {
501 if (mesh)
502 mesh -> SetNextTimeStamp();
503 return TCL_OK;
504 }
505
506
507
508
Ng_LoadGeometry(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])509 int Ng_LoadGeometry (ClientData clientData,
510 Tcl_Interp * interp,
511 int argc, tcl_const char *argv[])
512 {
513 if (multithread.running)
514 {
515 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
516 return TCL_ERROR;
517 }
518
519 tcl_const char * lgfilename = argv[1];
520
521 #ifdef LOG_STREAM
522 (*logout) << "Load geometry file: " << lgfilename << endl;
523 #endif
524
525 #ifdef STAT_STREAM
526 (*statout) << lgfilename << " & " << endl;
527 #endif
528
529
530 try
531 {
532 for (int i = 0; i < geometryregister.Size(); i++)
533 {
534 NetgenGeometry * hgeom = geometryregister[i]->Load (lgfilename);
535 if (hgeom)
536 {
537 // delete ng_geometry;
538 // ng_geometry = hgeom;
539 ng_geometry = shared_ptr<NetgenGeometry> (hgeom);
540 geometryregister[i]->SetParameters(interp);
541
542 mesh.reset();
543 return TCL_OK;
544 }
545 }
546
547
548 ifstream infile(lgfilename);
549
550 if (strlen(lgfilename) < 4)
551 {
552 cout << "ERROR: cannot recognise file format!" << endl;
553 }
554 else
555 {
556 if ((strcmp (&lgfilename[strlen(lgfilename)-4], "iges") == 0) ||
557 (strcmp (&lgfilename[strlen(lgfilename)-3], "igs") == 0) ||
558 (strcmp (&lgfilename[strlen(lgfilename)-3], "IGS") == 0) ||
559 (strcmp (&lgfilename[strlen(lgfilename)-4], "IGES") == 0))
560 {
561 Tcl_SetResult (interp, (char*)"IGES import requires the OpenCascade geometry kernel. "
562 "Please install OpenCascade as described in the Netgen-website",
563 TCL_STATIC);
564 return TCL_ERROR;
565 }
566
567 else if (strcmp (&lgfilename[strlen(lgfilename)-3], "sat") == 0)
568 {
569 #ifdef ACIS
570 PrintMessage (1, "Load ACIS geometry file ", lgfilename);
571 acisgeometry = netgen::LoadACIS_SAT (lgfilename);
572 #endif
573 }
574 else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "step") == 0) ||
575 (strcmp (&lgfilename[strlen(lgfilename)-3], "stp") == 0) ||
576 (strcmp (&lgfilename[strlen(lgfilename)-3], "STP") == 0) ||
577 (strcmp (&lgfilename[strlen(lgfilename)-4], "STEP") == 0))
578 {
579 #ifdef ACISxxx
580 PrintMessage (1, "Load STEP geometry file ", lgfilename);
581 acisgeometry = netgen::LoadACIS_STEP (lgfilename);
582 #else
583 Tcl_SetResult (interp, (char*)"IGES import requires the OpenCascade geometry kernel. "
584 "Please install OpenCascade as described in the Netgen-website",
585 TCL_STATIC);
586 return TCL_ERROR;
587 #endif
588 }
589 else if ((strcmp (&lgfilename[strlen(lgfilename)-4], "brep") == 0) ||
590 (strcmp (&lgfilename[strlen(lgfilename)-4], "Brep") == 0) ||
591 (strcmp (&lgfilename[strlen(lgfilename)-4], "BREP") == 0))
592 {
593 Tcl_SetResult (interp, (char*)"BREP import requires the OpenCascade geometry kernel. "
594 "Please install OpenCascade as described in the Netgen-website",
595 TCL_STATIC);
596 return TCL_ERROR;
597 }
598 }
599 }
600
601 catch (NgException e)
602 {
603 Tcl_SetResult (interp, const_cast<char*> (e.What().c_str()), TCL_VOLATILE);
604 return TCL_ERROR;
605 }
606
607 mesh.reset();
608 return TCL_OK;
609 }
610
611
612
613
614
615
616
617
618
619
Ng_SaveGeometry(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])620 int Ng_SaveGeometry (ClientData clientData,
621 Tcl_Interp * interp,
622 int argc, tcl_const char *argv[])
623 {
624 if (argc == 2)
625 {
626 const char * cfilename = argv[1];
627
628 try
629 {
630 ng_geometry -> Save (string (cfilename));
631 }
632 catch (NgException e)
633 {
634 Tcl_SetResult (interp, const_cast<char*> (e.What().c_str()), TCL_VOLATILE);
635 return TCL_ERROR;
636 }
637
638 PrintMessage (1, "Save geometry to file ", cfilename);
639
640 if (strlen(cfilename) < 4) {cout << "ERROR: can not recognise file format!!!" << endl;}
641 else
642 {
643 #ifdef ACIS
644 if (acisgeometry)
645 {
646 char * filename = const_cast<char*> (argv[1]);
647 if (strcmp (&filename[strlen(filename)-3], "sat") == 0)
648 {
649 acisgeometry -> SaveSATFile (filename);
650 }
651 }
652 #endif
653 /*
654 if (strcmp (&cfilename[strlen(cfilename)-3], "ngg") == 0)
655 {
656 CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
657 if (geometry)
658 {
659 ofstream of(cfilename);
660 geometry->Save (of);
661 }
662 }
663 */
664 }
665 }
666
667 return TCL_OK;
668 }
669
670
671
672
673
674
675
676
677
Ng_ReadStatus(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])678 int Ng_ReadStatus (ClientData clientData,
679 Tcl_Interp * interp,
680 int argc, tcl_const char *argv[])
681 {
682 char buf[20], lstring[200];
683 static int prev_np = -1;
684 static int prev_ne = -1;
685 static int prev_nse = -1;
686
687 if (mesh)
688 {
689 if (prev_np != mesh->GetNP())
690 {
691 sprintf (buf, "%u", unsigned(mesh->GetNP()));
692 Tcl_SetVar (interp, "::status_np", buf, 0);
693 prev_np = mesh->GetNP();
694 }
695
696 if (prev_ne != mesh->GetNE())
697 {
698 sprintf (buf, "%u", unsigned(mesh->GetNE()));
699 Tcl_SetVar (interp, "::status_ne", buf, 0);
700 prev_ne = mesh->GetNE();
701 }
702
703 if (prev_nse != mesh->GetNSE())
704 {
705 sprintf (buf, "%u", unsigned(mesh->GetNSE()));
706 Tcl_SetVar (interp, "::status_nse", buf, 0);
707 prev_nse = mesh->GetNSE();
708 }
709
710 auto tets_in_qualclass = mesh->GetQualityHistogram();
711 lstring[0] = 0;
712 for (int i = 0; i < tets_in_qualclass.Size(); i++)
713 {
714 sprintf (buf, " %d", tets_in_qualclass[i]);
715 strcat (lstring, buf);
716 }
717 for (int i = tets_in_qualclass.Size(); i < 20; i++)
718 strcat (lstring, " 0");
719 Tcl_SetVar (interp, "::status_tetqualclasses", lstring, 0);
720 }
721 else
722 {
723 if (prev_np != 0)
724 {
725 Tcl_SetVar (interp, "::status_np", "0", 0);
726 prev_np = 0;
727 }
728
729 if (prev_ne != 0)
730 {
731 Tcl_SetVar (interp, "::status_ne", "0", 0);
732 prev_ne = 0;
733 }
734
735 if (prev_nse != 0)
736 {
737 Tcl_SetVar (interp, "::status_nse", "0", 0);
738 prev_nse = 0;
739 }
740 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);
741 }
742
743 static string prev_working;
744 string working = multithread.running ? "working" : " ";
745 if (working != prev_working)
746 {
747 Tcl_SetVar (interp, "::status_working", working.c_str(), 0);
748 prev_working = working;
749 }
750
751 /*
752 if (multithread.running)
753 Tcl_SetVar (interp, "::status_working", "working", 0);
754 else
755 Tcl_SetVar (interp, "::status_working", " ", 0);
756 */
757
758 static string prev_task;
759 if (prev_task != string(multithread.task))
760 {
761 prev_task = multithread.task;
762 Tcl_SetVar (interp, "::status_task", prev_task.c_str(), 0);
763 }
764
765 static double prev_percent = -1;
766 if (prev_percent != multithread.percent)
767 {
768 prev_percent = multithread.percent;
769 sprintf (buf, "%lf", prev_percent);
770 Tcl_SetVar (interp, "::status_percent", buf, 0);
771 }
772
773
774 {
775 lock_guard<mutex> guard(tcl_todo_mutex);
776 if (multithread.tcl_todo->length())
777 {
778 Tcl_Eval (interp, multithread.tcl_todo->c_str());
779 *multithread.tcl_todo = "";
780 }
781 }
782
783 return TCL_OK;
784 }
785
786
Ng_MemInfo(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])787 int Ng_MemInfo (ClientData clientData,
788 Tcl_Interp * interp,
789 int argc, tcl_const char *argv[])
790 {/*
791 if (argc < 2) return TCL_ERROR;
792
793 if (strcmp (argv[1], "usedmb") == 0)
794 { // returns string of 512 '0' or '1'
795
796 static char usedmb[513];
797 for (int i = 0; i < 512; i++)
798 usedmb[i] = (i % 7 == 0) ? '1' : '0';
799
800 usedmb[512] = 0;
801 BaseDynamicMem::GetUsed (512, usedmb);
802 Tcl_SetResult (interp, usedmb, TCL_STATIC);
803 return TCL_OK;
804 }
805 */
806 return TCL_ERROR;
807 }
808
809
810
Ng_BCProp(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])811 int Ng_BCProp (ClientData clientData,
812 Tcl_Interp * interp,
813 int argc, tcl_const char *argv[])
814 {
815 static char buf[100];
816
817 if (argc < 2)
818 {
819 Tcl_SetResult (interp, (char*)"Ng_BCProp needs arguments", TCL_STATIC);
820 return TCL_ERROR;
821 }
822
823 if (strcmp (argv[1], "setbc") == 0)
824 {
825 int facenr = atoi (argv[2]);
826 int bcnr = atoi (argv[3]);
827 if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
828 mesh->GetFaceDescriptor (facenr).SetBCProperty (bcnr);
829 }
830
831 if (strcmp (argv[1], "setall") == 0)
832 {
833 int bcnr = atoi (argv[2]);
834 if (mesh)
835 {
836 int nfd = mesh->GetNFD();
837 for (int i = 1; i <= nfd; i++)
838 mesh->GetFaceDescriptor (i).SetBCProperty (bcnr);
839 }
840 }
841
842 if (strcmp (argv[1], "getbc") == 0)
843 {
844 int facenr = atoi (argv[2]);
845 if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
846 {
847 sprintf (buf, "%d", mesh->GetFaceDescriptor(facenr).BCProperty());
848 }
849 else
850 {
851 strcpy (buf, "0");
852 }
853 Tcl_SetResult (interp, buf, TCL_STATIC);
854 }
855
856 if (strcmp (argv[1], "getbcname") == 0)
857 {
858 int facenr = atoi (argv[2]);
859 if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
860 {
861 sprintf (buf, "%s", mesh->GetFaceDescriptor(facenr).GetBCName().c_str());
862 }
863 else
864 {
865 strcpy (buf, "-");
866 }
867 Tcl_SetResult (interp, buf, TCL_STATIC);
868 }
869
870
871 if (strcmp (argv[1], "getactive") == 0)
872 {
873 sprintf (buf, "%d", vsmesh.SelectedFace());
874 Tcl_SetResult (interp, buf, TCL_STATIC);
875 }
876
877 if (strcmp (argv[1], "setactive") == 0)
878 {
879 int facenr = atoi (argv[2]);
880 if (mesh && facenr >= 1 && facenr <= mesh->GetNFD())
881 {
882 vsmesh.SetSelectedFace (facenr);
883 }
884 }
885
886 if (strcmp (argv[1], "getnfd") == 0)
887 {
888 if (mesh)
889 sprintf (buf, "%d", mesh->GetNFD());
890 else
891 sprintf (buf, "0");
892 Tcl_SetResult (interp, buf, TCL_STATIC);
893 }
894
895 return TCL_OK;
896 }
897
898
899
900
901
Ng_Refine(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])902 int Ng_Refine (ClientData clientData,
903 Tcl_Interp * interp,
904 int argc, tcl_const char *argv[])
905 {
906 if (!mesh)
907 {
908 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
909 return TCL_ERROR;
910 }
911 if (multithread.running)
912 {
913 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
914 return TCL_ERROR;
915 }
916
917 #ifdef ACIS
918 if (acisgeometry)
919 {
920 ACISRefinementSurfaces ref (*acisgeometry);
921 ACISMeshOptimize2dSurfaces opt(*acisgeometry);
922 ref.Set2dOptimizer(&opt);
923 ref.Refine (*mesh);
924 }
925 else
926 #endif
927 {
928 // ng_geometry -> GetRefinement().Refine(*mesh);
929 mesh->GetGeometry()->GetRefinement().Refine(*mesh);
930 }
931
932 //redo second order refinement if desired
933 if (mparam.secondorder)
934 const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder(*mesh);
935
936 return TCL_OK;
937 }
938
Ng_SecondOrder(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])939 int Ng_SecondOrder (ClientData clientData,
940 Tcl_Interp * interp,
941 int argc, tcl_const char *argv[])
942 {
943 if (!mesh)
944 {
945 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
946 return TCL_ERROR;
947 }
948 if (multithread.running)
949 {
950 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
951 return TCL_ERROR;
952 }
953
954 const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
955
956 return TCL_OK;
957 }
958
959
HighOrderDummy(void *)960 void * HighOrderDummy (void *)
961 {
962 // mparam.elementorder = atoi (Tcl_GetVar (interp, "options.elementorder", 0));
963 const char * savetask = multithread.task;
964
965 Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
966 mesh -> GetCurvedElements().BuildCurvedElements (&ref, mparam.elementorder);
967
968 multithread.task = savetask;
969 multithread.running = 0;
970 multithread.terminate = 1;
971
972 mesh -> SetNextMajorTimeStamp();
973 return 0;
974 }
975
Ng_HighOrder(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])976 int Ng_HighOrder (ClientData clientData,
977 Tcl_Interp * interp,
978 int argc, tcl_const char *argv[])
979 {
980 if (!mesh)
981 {
982 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
983 return TCL_ERROR;
984 }
985 if (multithread.running)
986 {
987 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
988 return TCL_ERROR;
989 }
990
991 multithread.running = 1;
992 multithread.terminate = 0;
993
994 mparam.elementorder = atoi(argv[1]);
995
996
997 HighOrderDummy(NULL);
998
999 return TCL_OK;
1000 }
1001
1002
1003
ValidateDummy(void *)1004 void * ValidateDummy (void *)
1005 {
1006 Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
1007 ref.ValidateSecondOrder (*mesh);
1008
1009 multithread.running = 0;
1010 return NULL;
1011 }
1012
1013
1014
Ng_ValidateSecondOrder(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1015 int Ng_ValidateSecondOrder (ClientData clientData,
1016 Tcl_Interp * interp,
1017 int argc, tcl_const char *argv[])
1018 {
1019 if (!mesh)
1020 {
1021 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1022 return TCL_ERROR;
1023 }
1024 if (multithread.running)
1025 {
1026 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1027 return TCL_ERROR;
1028 }
1029
1030 multithread.running = 1;
1031 RunParallel (ValidateDummy, NULL);
1032
1033 return TCL_OK;
1034 }
1035
1036
Ng_ZRefinement(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1037 int Ng_ZRefinement (ClientData clientData,
1038 Tcl_Interp * interp,
1039 int argc, tcl_const char *argv[])
1040 {
1041 if (!mesh)
1042 {
1043 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1044 return TCL_ERROR;
1045 }
1046 if (multithread.running)
1047 {
1048 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1049 return TCL_ERROR;
1050 }
1051
1052 ZRefinementOptions opt;
1053 opt.minref = 5;
1054
1055 if (argc >= 2) opt.minref = atoi (argv[1]);
1056
1057 ZRefinement (*mesh, ng_geometry.get(), opt);
1058
1059 return TCL_OK;
1060 }
1061
Ng_HPRefinement(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1062 int Ng_HPRefinement (ClientData clientData,
1063 Tcl_Interp * interp,
1064 int argc, tcl_const char *argv[])
1065 {
1066 if (!mesh)
1067 {
1068 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1069 return TCL_ERROR;
1070 }
1071 if (multithread.running)
1072 {
1073 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1074 return TCL_ERROR;
1075 }
1076
1077 int levels = atoi (argv[1]);
1078
1079
1080 Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
1081 HPRefinement (*mesh, &ref, levels);
1082 return TCL_OK;
1083 }
1084
1085
Ng_LoadMeshSize(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1086 int Ng_LoadMeshSize (ClientData clientData,
1087 Tcl_Interp * interp,
1088 int argc, tcl_const char *argv[])
1089 {
1090 if (!mesh)
1091 {
1092 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1093 return TCL_ERROR;
1094 }
1095 if (multithread.running)
1096 {
1097 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1098 return TCL_ERROR;
1099 }
1100
1101 mesh->LoadLocalMeshSize(argv[1]);
1102 return TCL_OK;
1103 }
1104
1105
Ng_MeshSizeFromSurfaceMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1106 int Ng_MeshSizeFromSurfaceMesh (ClientData clientData,
1107 Tcl_Interp * interp,
1108 int argc, tcl_const char *argv[])
1109 {
1110 if (!mesh)
1111 {
1112 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1113 return TCL_ERROR;
1114 }
1115 if (multithread.running)
1116 {
1117 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1118 return TCL_ERROR;
1119 }
1120
1121 mesh->SetGlobalH (mparam.maxh);
1122 mesh->CalcLocalH(mparam.grading);
1123
1124 return TCL_OK;
1125 }
1126
1127
1128
1129
1130
1131 // Philippose Rajan - 13 June 2009
1132 // Added a new TCL function call for the generation
1133 // of prismatic boundary layers
Ng_GenerateBoundaryLayer(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1134 int Ng_GenerateBoundaryLayer (ClientData clientData,
1135 Tcl_Interp * interp,
1136 int argc, tcl_const char *argv[])
1137 {
1138 if (!mesh)
1139 {
1140 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1141 return TCL_ERROR;
1142 }
1143
1144 if(multithread.running)
1145 {
1146 Tcl_SetResult(interp, err_jobrunning, TCL_STATIC);
1147 return TCL_ERROR;
1148 }
1149
1150
1151
1152
1153
1154 cout << "Generate Prismatic Boundary Layers (Experimental)...." << endl;
1155
1156 // Use an array to support creation of boundary
1157 // layers for multiple surfaces in the future...
1158 Array<int> surfid;
1159 int surfinp = 0;
1160 int prismlayers = 1;
1161 double hfirst = 0.01;
1162 double growthfactor = 1.0;
1163
1164
1165 while(surfinp >= 0)
1166 {
1167 cout << "Enter Surface ID (-1 to end list): ";
1168 cin >> surfinp;
1169 if(surfinp >= 0) surfid.Append(surfinp);
1170 }
1171
1172 cout << "Number of surfaces entered = " << surfid.Size() << endl;
1173 cout << "Selected surfaces are:" << endl;
1174
1175 for(auto i : Range(surfid))
1176 cout << "Surface " << i << ": " << surfid[i] << endl;
1177
1178 cout << endl << "Enter number of prism layers: ";
1179 cin >> prismlayers;
1180 if(prismlayers < 1) prismlayers = 1;
1181
1182 cout << "Enter height of first layer: ";
1183 cin >> hfirst;
1184 if(hfirst <= 0.0) hfirst = 0.01;
1185
1186 cout << "Enter layer growth / shrink factor: ";
1187 cin >> growthfactor;
1188 if(growthfactor <= 0.0) growthfactor = 0.5;
1189
1190 BoundaryLayerParameters blp;
1191 blp.surfid = surfid;
1192 for(auto i : Range(prismlayers))
1193 {
1194 auto layer = i+1;
1195 if(growthfactor == 1)
1196 blp.heights.Append(layer * hfirst);
1197 else
1198 blp.heights.Append(hfirst * (pow(growthfactor, (layer+1))-1)/(growthfactor-1));
1199 }
1200 GenerateBoundaryLayer (*mesh, blp);
1201 return TCL_OK;
1202 }
1203
1204
Ng_InsertVirtualBL(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1205 int Ng_InsertVirtualBL (ClientData clientData,
1206 Tcl_Interp * interp,
1207 int argc, tcl_const char *argv[])
1208 {
1209 if (!mesh)
1210 {
1211 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1212 return TCL_ERROR;
1213 }
1214 if (multithread.running)
1215 {
1216 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1217 return TCL_ERROR;
1218 }
1219
1220 InsertVirtualBoundaryLayer (*mesh);
1221 return TCL_OK;
1222 }
1223
Ng_CutOffAndCombine(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1224 int Ng_CutOffAndCombine (ClientData clientData,
1225 Tcl_Interp * interp,
1226 int argc, tcl_const char *argv[])
1227 {
1228 Mesh othermesh;
1229 othermesh.Load (argv[1]);
1230 othermesh.SetGlobalH (mparam.maxh);
1231 othermesh.CalcLocalH(mparam.grading);
1232
1233 CutOffAndCombine (*mesh, othermesh);
1234 return TCL_OK;
1235 }
1236
1237
Ng_HelmholtzMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1238 int Ng_HelmholtzMesh (ClientData clientData,
1239 Tcl_Interp * interp,
1240 int argc, tcl_const char *argv[])
1241 {
1242 HelmholtzMesh (*mesh);
1243 return TCL_OK;
1244 }
1245
1246
1247
1248
Ng_SetMeshingParameters(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1249 int Ng_SetMeshingParameters (ClientData clientData,
1250 Tcl_Interp * interp,
1251 int argc, tcl_const char *argv[])
1252 {
1253 mparam.maxh = atof (Tcl_GetVar (interp, "::options.meshsize", 0));
1254 mparam.minh = atof (Tcl_GetVar (interp, "::options.minmeshsize", 0));
1255
1256 mparam.meshsizefilename = Tcl_GetVar (interp, "::options.meshsizefilename", 0);
1257 // if (!strlen (mparam.meshsizefilename)) mparam.meshsizefilename = NULL;
1258
1259 mparam.curvaturesafety = atof (Tcl_GetVar (interp, "::options.curvaturesafety", 0));
1260 mparam.segmentsperedge = atof (Tcl_GetVar (interp, "::options.segmentsperedge", 0));
1261 mparam.badellimit = atof (Tcl_GetVar (interp, "::options.badellimit", 0));
1262 mparam.secondorder = atoi (Tcl_GetVar (interp, "::options.secondorder", 0));
1263 mparam.elementorder = atoi (Tcl_GetVar (interp, "::options.elementorder", 0));
1264 mparam.quad = atoi (Tcl_GetVar (interp, "::options.quad", 0));
1265 mparam.try_hexes = atoi (Tcl_GetVar (interp, "::options.try_hexes", 0));
1266
1267 mparam.inverttets = atoi (Tcl_GetVar (interp, "::options.inverttets", 0));
1268 mparam.inverttrigs = atoi (Tcl_GetVar (interp, "::options.inverttrigs", 0));
1269 mparam.uselocalh = atoi (Tcl_GetVar (interp, "::options.localh", 0));
1270 mparam.grading = atof (Tcl_GetVar (interp, "::options.grading", 0));
1271 mparam.delaunay = atoi (Tcl_GetVar (interp, "::options.delaunay", 0));
1272 mparam.checkoverlap = atoi (Tcl_GetVar (interp, "::options.checkoverlap", 0));
1273 mparam.checkoverlappingboundary = atoi (Tcl_GetVar (interp, "::options.checkoverlappingboundary", 0));
1274 mparam.checkchartboundary = atoi (Tcl_GetVar (interp, "::options.checkchartboundary", 0));
1275 mparam.optsteps3d = atoi (Tcl_GetVar (interp, "::options.optsteps3d", 0));
1276 mparam.optsteps2d = atoi (Tcl_GetVar (interp, "::options.optsteps2d", 0));
1277 mparam.opterrpow = atof (Tcl_GetVar (interp, "::options.opterrpow", 0));
1278
1279 mparam.parthread = atoi (Tcl_GetVar (interp, "::options.parthread", 0));
1280 mparam.elsizeweight = atof (Tcl_GetVar (interp, "::options.elsizeweight", 0));
1281
1282 mparam.autozrefine = atoi (Tcl_GetVar (interp, "::options.autozrefine", 0));
1283
1284 // extern int printmessage_importance;
1285 extern int printdots;
1286 printmessage_importance = atoi (Tcl_GetVar (interp, "::options.printmsg", 0));
1287 printdots = (printmessage_importance >= 4);
1288
1289 mparam.parallel_meshing = atoi (Tcl_GetVar (interp, "::options.parallel_meshing", 0));
1290 mparam.nthreads = atoi (Tcl_GetVar (interp, "::options.nthreads", 0));
1291 if(atoi(Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0)))
1292 mparam.closeedgefac = atof(Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
1293 else
1294 mparam.closeedgefac = {};
1295
1296 //BaseMoveableMem::totalsize = 0;
1297 // 1048576 * atoi (Tcl_GetVar (interp, "::options.memory", 0));
1298 if (mesh)
1299 {
1300 mesh->SetGlobalH (mparam.maxh);
1301 mesh->SetMinimalH (mparam.minh);
1302 }
1303
1304 #ifdef PARALLELGL
1305 MyMPI_SendCmd ("bcastparthread");
1306 MyMPI_Bcast (mparam.parthread, MPI_COMM_WORLD);
1307 #endif
1308
1309 return TCL_OK;
1310 }
1311
1312
1313
Ng_SetDebugParameters(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1314 int Ng_SetDebugParameters (ClientData clientData,
1315 Tcl_Interp * interp,
1316 int argc, tcl_const char *argv[])
1317 {
1318 debugparam.slowchecks = atoi (Tcl_GetVar (interp, "::debug.slowchecks", 0));
1319 debugparam.debugoutput = atoi (Tcl_GetVar (interp, "::debug.debugoutput", 0));
1320 debugparam.haltexistingline = atoi (Tcl_GetVar (interp, "::debug.haltexistingline", 0));
1321 debugparam.haltoverlap = atoi (Tcl_GetVar (interp, "::debug.haltoverlap", 0));
1322 debugparam.haltsuccess = atoi (Tcl_GetVar (interp, "::debug.haltsuccess", 0));
1323 debugparam.haltnosuccess = atoi (Tcl_GetVar (interp, "::debug.haltnosuccess", 0));
1324 debugparam.haltlargequalclass = atoi (Tcl_GetVar (interp, "::debug.haltlargequalclass", 0));
1325 debugparam.haltsegment = atoi (Tcl_GetVar (interp, "::debug.haltsegment", 0));
1326 debugparam.haltnode = atoi (Tcl_GetVar (interp, "::debug.haltnode", 0));
1327 debugparam.haltface = atoi (Tcl_GetVar (interp, "::debug.haltface", 0));
1328 debugparam.haltsegmentp1 = atoi (Tcl_GetVar (interp, "::debug.haltsegmentp1", 0));
1329 debugparam.haltsegmentp2 = atoi (Tcl_GetVar (interp, "::debug.haltsegmentp2", 0));
1330 debugparam.haltfacenr = atoi (Tcl_GetVar (interp, "::debug.haltfacenr", 0));
1331 return TCL_OK;
1332 }
1333
1334
1335
Ng_SetCommandLineParameter(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1336 int Ng_SetCommandLineParameter (ClientData clientData,
1337 Tcl_Interp * interp,
1338 int argc, tcl_const char *argv[])
1339 {
1340 if (argc != 2)
1341 {
1342 Tcl_SetResult (interp, (char*)"Ng_SetCommandLineParameter needs 1 parameter",
1343 TCL_STATIC);
1344 return TCL_ERROR;
1345 }
1346
1347 if (argv[1][0] == '-')
1348 parameters.SetCommandLineFlag (argv[1]);
1349 else
1350 {
1351 if (strstr(argv[1], ".py"))
1352 parameters.SetFlag ("py", argv[1]);
1353 else
1354 parameters.SetFlag ("geofile", argv[1]);
1355 }
1356 return TCL_OK;
1357 }
1358
1359
Ng_GetCommandLineParameter(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1360 int Ng_GetCommandLineParameter (ClientData clientData,
1361 Tcl_Interp * interp,
1362 int argc, tcl_const char *argv[])
1363 {
1364 if (argc != 2)
1365 {
1366 Tcl_SetResult (interp, (char*)"Ng_GetCommandLineParameter needs 1 parameter",
1367 TCL_STATIC);
1368 return TCL_ERROR;
1369 }
1370
1371 static char buf[10];
1372
1373 if (parameters.StringFlagDefined (argv[1]))
1374 Tcl_SetResult (interp,
1375 const_cast<char*>(parameters.GetStringFlag (argv[1], NULL).c_str()), TCL_VOLATILE);
1376 else if (parameters.NumFlagDefined (argv[1]))
1377 {
1378 sprintf (buf, "%lf", parameters.GetNumFlag (argv[1], 0));
1379 Tcl_SetResult (interp, buf, TCL_STATIC);
1380 }
1381 else if (parameters.GetDefineFlag (argv[1]))
1382 Tcl_SetResult (interp, (char*)"defined", TCL_STATIC);
1383 else
1384 Tcl_SetResult (interp, (char*)"undefined", TCL_STATIC);
1385
1386 return TCL_OK;
1387 }
1388
1389
1390 static int perfstepsstart;
1391 static int perfstepsend;
1392
1393 static char* optstring = NULL;
1394 static char* optstringcsg = NULL;
1395
MeshingDummy(void *)1396 void * MeshingDummy (void *)
1397 {
1398
1399 const char * savetask = multithread.task;
1400 multithread.task = "Generate Mesh";
1401
1402 ResetTime();
1403
1404
1405 try
1406 {
1407
1408 #ifdef LOG_STREAM
1409 (*logout) << "Start meshing" << endl;
1410 (*logout) << "Meshing parameters:" << endl;
1411 mparam.Print (*logout);
1412 #endif
1413
1414 #ifdef ACIS
1415 if (acisgeometry)
1416 {
1417 ACISGenerateMesh(*acisgeometry, mesh.Ptr(), perfstepsstart, perfstepsend, optstring);
1418 }
1419 else
1420 #endif
1421 if (ng_geometry)
1422 {
1423 if (perfstepsstart == 1)
1424 {
1425 mesh = make_shared<Mesh> ();
1426 // vsmesh.SetMesh (mesh);
1427 SetGlobalMesh (mesh);
1428 mesh -> SetGeometry(ng_geometry);
1429 }
1430 if(!mesh)
1431 throw Exception("Need existing global mesh");
1432 mparam.perfstepsstart = perfstepsstart;
1433 mparam.perfstepsend = perfstepsend;
1434 if(optstring)
1435 mparam.optimize3d = *optstring;
1436 int res = ng_geometry -> GenerateMesh (mesh, mparam);
1437
1438 if (res != MESHING3_OK)
1439 {
1440 multithread.task = savetask;
1441 multithread.running = 0;
1442 return 0;
1443 }
1444 }
1445 else if (mesh)
1446 {
1447 if(perfstepsstart > 1 && perfstepsstart < 5)
1448 throw Exception("Need geometry for surface mesh operations!");
1449 MeshVolume(mparam, *mesh);
1450 OptimizeVolume(mparam, *mesh);
1451 return 0;
1452 }
1453 else // no ng_geometry
1454 {
1455 multithread.task = savetask;
1456 multithread.running = 0;
1457 return 0;
1458 }
1459
1460
1461
1462 if (mparam.autozrefine)
1463 {
1464 ZRefinementOptions opt;
1465 opt.minref = 5;
1466 ZRefinement (*mesh, ng_geometry.get(), opt);
1467 mesh -> SetNextMajorTimeStamp();
1468 }
1469
1470 if (mparam.secondorder)
1471 {
1472 const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
1473 mesh -> SetNextMajorTimeStamp();
1474 }
1475
1476 if (mparam.elementorder > 1)
1477 {
1478 mesh -> GetCurvedElements().BuildCurvedElements (&const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()),
1479 mparam.elementorder);
1480
1481 mesh -> SetNextMajorTimeStamp();
1482 }
1483
1484
1485 PrintMessage (1, "Meshing done, time = ", GetTime(), " sec");
1486 }
1487
1488 catch (NgException e)
1489 {
1490 cout << e.What() << endl;
1491 }
1492
1493 multithread.task = savetask;
1494 multithread.running = 0;
1495
1496 #ifdef OCCGEOMETRYorig
1497 // currently not active
1498 OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry);
1499 if (occgeometry && occgeometry->ErrorInSurfaceMeshing())
1500 {
1501 char script[] = "rebuildoccdialog";
1502 Tcl_GlobalEval (tcl_interp, script);
1503 }
1504 #endif
1505 return NULL;
1506 }
1507
1508
MeshingVal(tcl_const char * str)1509 int MeshingVal(tcl_const char* str)
1510 {
1511 if (strcmp(str, "ag") == 0) {return MESHCONST_ANALYSE;}
1512 if (strcmp(str, "me") == 0) {return MESHCONST_MESHEDGES;}
1513 if (strcmp(str, "ms") == 0) {return MESHCONST_MESHSURFACE;}
1514 if (strcmp(str, "os") == 0) {return MESHCONST_OPTSURFACE;}
1515 if (strcmp(str, "mv") == 0) {return MESHCONST_MESHVOLUME;}
1516 if (strcmp(str, "ov") == 0) {return MESHCONST_OPTVOLUME;}
1517
1518 cout << "TCL TK ERROR, wrong meshing value, return='" << str << "'" << endl;
1519 return 0;
1520 }
1521
1522
1523
Ng_GenerateMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1524 int Ng_GenerateMesh (ClientData clientData,
1525 Tcl_Interp * interp,
1526 int argc, tcl_const char *argv[])
1527 {
1528 if (multithread.running)
1529 {
1530 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1531 return TCL_ERROR;
1532 }
1533
1534 multithread.running = 1;
1535 multithread.terminate = 0;
1536
1537 extern void Render(bool blocking);
1538 mparam.render_function = &Render;
1539
1540 for (int i = 0; i < geometryregister.Size(); i++)
1541 geometryregister[i] -> SetParameters (interp);
1542
1543
1544 Ng_SetMeshingParameters (clientData, interp, 0, argv);
1545
1546 perfstepsstart = 1;
1547 perfstepsend = 6;
1548
1549 if (optstringcsg) delete optstringcsg;
1550 optstringcsg = NULL;
1551 if (optstring) delete optstring;
1552 optstring = NULL;
1553
1554 if (argc == 2)
1555 {
1556 perfstepsstart = 1;
1557 perfstepsend = MeshingVal(argv[1]);
1558 }
1559 else if (argc == 3)
1560 {
1561 perfstepsstart = MeshingVal(argv[1]);
1562 perfstepsend = MeshingVal(argv[2]);
1563 }
1564 else if (argc == 4)
1565 {
1566 perfstepsstart = MeshingVal(argv[1]);
1567 perfstepsend = MeshingVal(argv[2]);
1568 optstring = new char[strlen(argv[3])+1];
1569 strcpy(optstring, argv[3]);
1570 optstringcsg = new char[strlen(argv[3])+1];
1571 strcpy(optstringcsg, argv[3]);
1572 }
1573
1574 RunParallel (MeshingDummy, NULL);
1575
1576 return TCL_OK;
1577 }
1578
1579
Ng_StopMeshing(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1580 int Ng_StopMeshing (ClientData clientData,
1581 Tcl_Interp * interp,
1582 int argc, tcl_const char *argv[])
1583 {
1584 multithread.terminate = 1;
1585 return TCL_OK;
1586 }
1587
Ng_MeshInfo(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1588 int Ng_MeshInfo (ClientData clientData,
1589 Tcl_Interp * interp,
1590 int argc, tcl_const char *argv[])
1591 {
1592 if (!mesh)
1593 {
1594 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1595 return TCL_ERROR;
1596 }
1597
1598 ostringstream str;
1599
1600 if (argc >= 2 && strcmp (argv[1], "dim") == 0)
1601 str << mesh->GetDimension();
1602 else if (argc >= 2 && strcmp (argv[1], "np") == 0)
1603 str << mesh->GetNP();
1604 else if (argc >= 2 && strcmp (argv[1], "ne") == 0)
1605 str << mesh->GetNE();
1606 else if (argc >= 2 && strcmp (argv[1], "nse") == 0)
1607 str << mesh->GetNSE();
1608 else if (argc >= 2 && strcmp (argv[1], "nseg") == 0)
1609 str << mesh->GetNSeg();
1610 else if (argc >= 2 && strcmp (argv[1], "bbox") == 0)
1611 {
1612 Point3d pmin, pmax;
1613 mesh->GetBox (pmin, pmax);
1614 str << pmin.X() << " " << pmax.X() << " "
1615 << pmin.Y() << " " << pmax.Y() << " "
1616 << pmin.Z() << " " << pmax.Z() << endl;
1617 }
1618 else
1619 {
1620 cout << "argv[1] = " << argv[1] << endl;
1621 Tcl_SetResult (interp, (char*)"Ng_MeshInfo requires an argument out of \n dim np ne", TCL_STATIC);
1622 return TCL_ERROR;
1623 }
1624
1625 Tcl_SetResult (interp, (char*)str.str().c_str(), TCL_VOLATILE);
1626 return TCL_OK;
1627 }
1628
Ng_MeshQuality(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1629 int Ng_MeshQuality (ClientData clientData,
1630 Tcl_Interp * interp,
1631 int argc, tcl_const char *argv[])
1632 {
1633 if (!mesh)
1634 {
1635 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1636 return TCL_ERROR;
1637 }
1638 if (multithread.running)
1639 {
1640 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1641 return TCL_ERROR;
1642 }
1643
1644 double angles[4];
1645 char buf[10];
1646
1647 if (mesh)
1648 mesh->CalcMinMaxAngle(mparam.badellimit, angles);
1649 else
1650 {
1651 angles[0] = angles[1] = angles[2] = angles[3] = 0;
1652 }
1653 sprintf (buf, "%5.1lf", angles[0]);
1654 Tcl_SetVar (interp, argv[1], buf, 0);
1655 sprintf (buf, "%5.1lf", angles[1]);
1656 Tcl_SetVar (interp, argv[2], buf, 0);
1657 sprintf (buf, "%5.1lf", angles[2]);
1658 Tcl_SetVar (interp, argv[3], buf, 0);
1659 sprintf (buf, "%5.1lf", angles[3]);
1660 Tcl_SetVar (interp, argv[4], buf, 0);
1661
1662 return TCL_OK;
1663 }
1664
Ng_CheckSurfaceMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1665 int Ng_CheckSurfaceMesh (ClientData clientData,
1666 Tcl_Interp * interp,
1667 int argc, tcl_const char *argv[])
1668 {
1669 if (!mesh)
1670 {
1671 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1672 return TCL_ERROR;
1673 }
1674 if (multithread.running)
1675 {
1676 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1677 return TCL_ERROR;
1678 }
1679
1680 mesh->FindOpenElements();
1681 if (mesh->CheckConsistentBoundary())
1682 {
1683 PrintMessage (1, "surface mesh not consistent, trying orientation");
1684 mesh->SurfaceMeshOrientation();
1685 }
1686 else
1687 {
1688 PrintMessage (1, "surface mesh consistent");
1689 }
1690
1691 mesh->CheckOverlappingBoundary();
1692 return TCL_OK;
1693 }
1694
Ng_CheckVolumeMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1695 int Ng_CheckVolumeMesh (ClientData clientData,
1696 Tcl_Interp * interp,
1697 int argc, tcl_const char *argv[])
1698 {
1699 if (!mesh)
1700 {
1701 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1702 return TCL_ERROR;
1703 }
1704 if (multithread.running)
1705 {
1706 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1707 return TCL_ERROR;
1708 }
1709
1710 mesh->CheckVolumeMesh();
1711 return TCL_OK;
1712 }
1713
1714
Ng_DeleteVolMesh(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1715 int Ng_DeleteVolMesh (ClientData clientData,
1716 Tcl_Interp * interp,
1717 int argc, tcl_const char *argv[])
1718 {
1719 if (mesh)
1720 mesh->ClearVolumeElements();
1721
1722 return TCL_OK;
1723 }
1724
1725
Ng_SplitSeparatedFaces(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1726 int Ng_SplitSeparatedFaces (ClientData clientData,
1727 Tcl_Interp * interp,
1728 int argc, tcl_const char *argv[])
1729 {
1730 if (mesh)
1731 mesh->SplitSeparatedFaces ();
1732 return TCL_OK;
1733 }
1734
1735
1736
Ng_RestrictH(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1737 int Ng_RestrictH (ClientData clientData,
1738 Tcl_Interp * interp,
1739 int argc, tcl_const char *argv[])
1740 {
1741 if (!mesh)
1742 {
1743 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1744 return TCL_ERROR;
1745 }
1746 if (multithread.running)
1747 {
1748 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1749 return TCL_ERROR;
1750 }
1751
1752 if (argc != 3)
1753 return TCL_OK;
1754 if (!mesh)
1755 return TCL_OK;
1756
1757
1758 double loch = atof (argv[2]);
1759 if (strcmp (argv[1], "face") == 0)
1760 {
1761 cout << "Restrict h at face to " << loch << endl;
1762 mesh -> RestrictLocalH (RESTRICTH_FACE, vsmesh.SelectedFace(), loch);
1763 }
1764 if (strcmp (argv[1], "edge") == 0)
1765 {
1766 cout << "Restrict h at edge to " << loch << endl;
1767 mesh -> RestrictLocalH (RESTRICTH_EDGE, vsmesh.SelectedEdge(), loch);
1768 }
1769 if (strcmp (argv[1], "point") == 0)
1770 {
1771 cout << "Restrict h at point to " << loch << endl;
1772 mesh -> RestrictLocalH (RESTRICTH_POINT, vsmesh.SelectedPoint(), loch);
1773 }
1774
1775 return TCL_OK;
1776 }
1777
1778
1779
1780
1781
Ng_Anisotropy(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1782 int Ng_Anisotropy (ClientData clientData,
1783 Tcl_Interp * interp,
1784 int argc, tcl_const char *argv[])
1785 {
1786 if (!mesh)
1787 {
1788 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1789 return TCL_ERROR;
1790 }
1791 if (multithread.running)
1792 {
1793 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1794 return TCL_ERROR;
1795 }
1796
1797 if (argc != 2)
1798 return TCL_OK;
1799 if (!mesh)
1800 return TCL_OK;
1801
1802 if (strcmp (argv[1], "edge") == 0)
1803 {
1804 int edgenr = vsmesh.SelectedEdge();
1805 for (int i = 1; i <= mesh->GetNSeg(); i++)
1806 {
1807 Segment & seg = mesh->LineSegment(i);
1808 if (seg.edgenr == edgenr)
1809 {
1810 seg.singedge_left = 1 - seg.singedge_left;
1811 seg.singedge_right = 1 - seg.singedge_right;
1812 }
1813 }
1814 }
1815
1816 return TCL_OK;
1817 }
1818
1819
1820
1821
1822 BisectionOptions biopt;
1823
BisectDummy(void *)1824 void * BisectDummy (void *)
1825 {
1826 const Refinement & ref = mesh->GetGeometry()->GetRefinement();
1827 MeshOptimize2d * opt = NULL;
1828
1829 /*
1830 #ifdef ACIS
1831 if (acisgeometry)
1832 {
1833 // ref = new ACISRefinementSurfaces(*acisgeometry);
1834 opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
1835 ref->Set2dOptimizer(opt);
1836 }
1837 #endif
1838 else
1839 {
1840 ref = new RefinementSurfaces(*geometry);
1841 opt = new MeshOptimize2dSurfaces(*geometry);
1842 ref->Set2dOptimizer(opt);
1843 }
1844 */
1845
1846 if(!mesh->LocalHFunctionGenerated())
1847 mesh->CalcLocalH(mparam.grading);
1848
1849 mesh->LocalHFunction().SetGrading (mparam.grading);
1850 ref . Bisect (*mesh, biopt);
1851 mesh -> UpdateTopology();
1852 mesh -> GetCurvedElements().BuildCurvedElements (&ref, mparam.elementorder);
1853
1854 multithread.running = 0;
1855
1856 delete opt;
1857 return NULL;
1858 }
1859
1860
Ng_Bisect(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1861 int Ng_Bisect (ClientData clientData,
1862 Tcl_Interp * interp,
1863 int argc, tcl_const char *argv[])
1864 {
1865 if (!mesh)
1866 {
1867 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1868 return TCL_ERROR;
1869 }
1870 if (multithread.running)
1871 {
1872 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1873 return TCL_ERROR;
1874 }
1875
1876
1877 if (multithread.running)
1878 {
1879 cout << "Thread alrad running" << endl;
1880 return TCL_OK;
1881 }
1882 multithread.running = 1;
1883
1884 biopt.outfilename = NULL; // "ngfepp.vol";
1885 biopt.femcode = "fepp";
1886 biopt.refinementfilename = NULL;
1887
1888 if (argc >= 2)
1889 biopt.refinementfilename = argv[1];
1890
1891
1892 BisectDummy (0);
1893
1894 /*
1895 extern void BisectTets (Mesh &, const CSGeometry *);
1896 BisectTets (*mesh, geometry);
1897 */
1898 return TCL_OK;
1899 }
1900
1901
1902
1903 // int Ng_BisectCopyMesh (ClientData clientData,
1904 // Tcl_Interp * interp,
1905 // int argc, tcl_const char *argv[])
1906 // {
1907 // if (!mesh)
1908 // {
1909 // Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1910 // return TCL_ERROR;
1911 // }
1912 // if (multithread.running)
1913 // {
1914 // Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1915 // return TCL_ERROR;
1916 // }
1917
1918 // BisectTetsCopyMesh (*mesh, geometry.Ptr(), biopt);
1919 // return TCL_OK;
1920 // }
1921
1922
1923
1924
1925
1926
Ng_Split2Tets(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])1927 int Ng_Split2Tets (ClientData clientData,
1928 Tcl_Interp * interp,
1929 int argc, tcl_const char *argv[])
1930 {
1931 if (!mesh)
1932 {
1933 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
1934 return TCL_ERROR;
1935 }
1936 if (multithread.running)
1937 {
1938 Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
1939 return TCL_ERROR;
1940 }
1941
1942 mesh->Split2Tets ();
1943
1944 return TCL_OK;
1945 }
1946
1947
1948
1949
1950
1951
1952
1953
1954 extern int Ng_MeshDoctor (ClientData clientData,
1955 Tcl_Interp * interp,
1956 int argc, tcl_const char *argv[]);
1957
1958
1959
1960
1961
1962
1963
GetVisualizationScenes()1964 SymbolTable<VisualScene*> & GetVisualizationScenes ()
1965 {
1966 static SymbolTable<VisualScene*> vss;
1967 return vss;
1968 }
1969
AddVisualizationScene(const string & name,VisualScene * avs)1970 void AddVisualizationScene (const string & name,
1971 VisualScene * avs)
1972 {
1973 GetVisualizationScenes().Set (name.c_str(), avs);
1974 }
1975
1976
SetVisualScene(Tcl_Interp * interp)1977 void SetVisualScene (Tcl_Interp * interp)
1978 {
1979 const char * vismode = vispar.selectvisual;
1980 // Tcl_GetVar (interp, "selectvisual", 0);
1981 VisualScene *& vs = visual_scene;
1982 vs = &visual_scene_cross;
1983 if (GetVisualizationScenes().Used(vismode))
1984 {
1985 vs = GetVisualizationScenes()[vismode];
1986 }
1987 else if (vismode)
1988 {
1989 if (strcmp (vismode, "geometry") == 0)
1990 {
1991 for (int i = 0; i < geometryregister.Size(); i++)
1992 {
1993 VisualScene * hvs = geometryregister[i]->GetVisualScene (ng_geometry.get());
1994 if (hvs)
1995 {
1996 vs = hvs;
1997 return;
1998 }
1999 }
2000
2001 #ifdef ACIS
2002 else if (acisgeometry)
2003 vs = &vsacisgeom;
2004 #endif // ACIS
2005 }
2006
2007 if (strcmp (vismode, "mesh") == 0)
2008 {
2009 if (!meshdoctor.active)
2010 vs = &vsmesh;
2011 else
2012 vs = &vsmeshdoc;
2013 }
2014
2015 if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing;
2016 if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints;
2017 if (strcmp (vismode, "solution") == 0) vs = &netgen::GetVSSolution();
2018 }
2019 }
2020
2021
2022
2023 Font * font = nullptr;
2024 Togl * togl = NULL;
2025
MyOpenGLText_GUI(const char * text)2026 void MyOpenGLText_GUI (const char * text)
2027 {
2028 glListBase (font->getDisplayListsBase());
2029 glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text);
2030 }
2031
2032 static int
Ng_ToglVersion(ClientData clientData,Tcl_Interp * interp,int objc,Tcl_Obj * const * objv)2033 Ng_ToglVersion(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
2034 {
2035 Tcl_SetResult (interp, (char*)"2", TCL_STATIC);
2036 return TCL_OK;
2037 }
2038
2039 static int
init(ClientData clientData,Tcl_Interp * interp,int objc,Tcl_Obj * const * objv)2040 init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
2041 {
2042 // cout << "call init" << endl;
2043
2044
2045 if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK)
2046 return TCL_ERROR;
2047
2048 // possible values: 12,14,16,18,20,22,24,28,32
2049 font = selectFont(18);
2050
2051 LoadOpenGLFunctionPointers();
2052
2053 glMatrixMode(GL_PROJECTION);
2054 glLoadIdentity();
2055 glMatrixMode(GL_MODELVIEW);
2056
2057 SetVisualScene (Togl_Interp(togl));
2058 visual_scene->DrawScene();
2059 Set_OpenGLText_Callback (&MyOpenGLText_GUI);
2060 return TCL_OK;
2061 }
2062
2063 static int
zap(ClientData clientData,Tcl_Interp * interp,int objc,Tcl_Obj * const * objv)2064 zap(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
2065 {
2066 return TCL_OK;
2067 }
2068
2069
2070 static int
draw(ClientData clientData,Tcl_Interp * interp,int objc,Tcl_Obj * const * objv)2071 draw(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
2072 {
2073 SetVisualScene (interp);
2074
2075 glPushMatrix();
2076
2077 glLoadIdentity();
2078 visual_scene->DrawScene();
2079 Togl_SwapBuffers(togl);
2080
2081 glPopMatrix();
2082
2083 return TCL_OK;
2084 }
2085
2086 static int
reshape(ClientData clientData,Tcl_Interp * interp,int objc,Tcl_Obj * const * objv)2087 reshape(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
2088 {
2089 int w = Togl_Width (togl);
2090 int h = Togl_Height (togl);
2091
2092 // glViewport(0, 0, w, h);
2093 int res[4];
2094 glGetIntegerv(GL_VIEWPORT, res);
2095 // cout << "w = " << w << " h = " << h << endl;
2096 w = res[2];
2097 h = res[3];
2098 /*
2099 cout << "viewport: "
2100 << res[0] << " "
2101 << res[1] << " "
2102 << res[2] << " "
2103 << res[3] << endl;
2104 */
2105 // change font size according to window width
2106 font = selectFont(w/80);
2107
2108 glMatrixMode(GL_PROJECTION);
2109 glLoadIdentity();
2110
2111 // OpenGL near and far clipping planes
2112 double pnear = 0.1;
2113 double pfar = 10;
2114
2115 gluPerspective(20.0f, double(w) / h, pnear, pfar);
2116 glMatrixMode(GL_MODELVIEW);
2117
2118 return TCL_OK;
2119 }
2120
Ng_SnapShot(ClientData clientData,Tcl_Interp * interp,int argc,Tcl_Obj * const * argv)2121 static int Ng_SnapShot(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
2122 {
2123 struct Togl *togl;
2124 if (Togl_GetToglFromObj(interp, argv[1], &togl) != TCL_OK)
2125 return TCL_ERROR;
2126 const char * filename = Tcl_GetString(argv[2]);
2127
2128 int len = strlen(filename);
2129 int w = Togl_PixelScale(togl)*Togl_Width (togl);
2130 int h = Togl_PixelScale(togl)*Togl_Height (togl);
2131
2132 NgArray<unsigned char> buffer(w*h*3);
2133 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
2134 glPixelStorei(GL_PACK_ALIGNMENT,1);
2135 glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]);
2136
2137 #ifdef JPEGLIB
2138 if (strcmp ("jpg", filename+len-3) == 0)
2139 {
2140 cout << "Snapshot to file '" << filename << "'" << endl;
2141
2142 struct jpeg_compress_struct cinfo;
2143 struct jpeg_error_mgr jerr;
2144 FILE *outfile = fopen(filename,"wb");
2145 JSAMPROW row_pointer[1];
2146 int row_stride, quality = 100; // 1...100
2147
2148 cinfo.err = jpeg_std_error( &jerr );
2149 jpeg_create_compress( &cinfo );
2150 jpeg_stdio_dest( &cinfo, outfile );
2151
2152
2153 cinfo.image_width = w;
2154 cinfo.image_height = h;
2155 cinfo.input_components = 3;
2156 cinfo.in_color_space = JCS_RGB;
2157
2158 jpeg_set_defaults( &cinfo );
2159 jpeg_set_quality( &cinfo, quality, FALSE ); // TRUE
2160 jpeg_start_compress( &cinfo, TRUE );
2161
2162 row_stride = 3*w;
2163 while( cinfo.next_scanline < cinfo.image_height ) {
2164 row_pointer[0] = &buffer[ (h-1-cinfo.next_scanline) * row_stride ];
2165 (void)jpeg_write_scanlines( &cinfo, row_pointer, 1 );
2166 }
2167
2168 jpeg_finish_compress( &cinfo );
2169 fclose( outfile );
2170
2171 jpeg_destroy_compress( &cinfo );
2172 fprintf( stdout, "done [ok]\n" );
2173 fflush( stdout );
2174
2175 return TCL_OK;
2176 }
2177 #endif // JPEGLIB
2178 {
2179 string command;
2180 string filename2;
2181
2182 filename2 = filename;
2183
2184 if(filename2.substr(len-3) != ".ppm")
2185 filename2 += ".ppm";
2186
2187 cout << "Snapshot to file '" << filename << endl;
2188
2189 // int w = Togl_Width (togl);
2190 // int h = Togl_Height (togl);
2191
2192 ofstream outfile(filename2);
2193 outfile << "P6" << endl
2194 << "# CREATOR: Netgen" << endl
2195 << w << " " << h << endl
2196 << "255" << endl;
2197 for (int i = 0; i < h; i++)
2198 for (int j = 0; j < w; j++)
2199 for (int k = 0; k < 3; k++)
2200 outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
2201 outfile << flush;
2202
2203 if (filename2 == string(filename))
2204 return TCL_OK;
2205 else
2206 {
2207 // convert image file (Unix/Linux only):
2208 command = string("convert -quality 100 ") + filename2 + " " + filename;
2209
2210 int err = system(command.c_str());
2211 if (err != 0)
2212 {
2213 Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file, stored as .ppm", TCL_VOLATILE);
2214 return TCL_ERROR;
2215 }
2216
2217 command = string("rm ") + filename2;
2218 err = system(command.c_str());
2219
2220 if (err != 0)
2221 {
2222 Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot delete temporary file", TCL_VOLATILE);
2223 return TCL_ERROR;
2224 }
2225 return TCL_OK;
2226 }
2227 }
2228 }
2229
2230
2231
2232 #ifdef FFMPEG
Ng_VideoClip(ClientData clientData,Tcl_Interp * interp,int argc,Tcl_Obj * const * argv)2233 static int Ng_VideoClip(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
2234 {
2235 static Mpeg mpeg;
2236 struct Togl *togl;
2237 if (Togl_GetToglFromObj(interp, argv[1], &togl) != TCL_OK)
2238 return TCL_ERROR;
2239
2240 if (strcmp (Tcl_GetString(argv[2]), "init") == 0)
2241 {
2242 // Can't initialize when running:
2243 //-------------------------------
2244 if( mpeg.IsStarted() ) {
2245 cout << "cannot initialize: already running" << endl;
2246 return TCL_ERROR;
2247 }
2248
2249 const char * filename = Tcl_GetString(argv[3]);
2250 mpeg.Start(filename);
2251
2252 return TCL_OK;
2253 }
2254
2255
2256
2257 else if (strcmp (Tcl_GetString(argv[2]), "addframe") == 0)
2258 {
2259 if(mpeg.AddFrame())
2260 return TCL_ERROR;
2261 }
2262
2263
2264
2265 else if (strcmp (Tcl_GetString(argv[2]), "finalize") == 0)
2266 {
2267 mpeg.Stop();
2268 }
2269 return TCL_OK;
2270 }
2271
2272 #else // FFMPEG
Ng_VideoClip(ClientData clientData,Tcl_Interp * interp,int argc,Tcl_Obj * const * argv)2273 static int Ng_VideoClip(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
2274 {
2275 Tcl_SetResult (Togl_Interp(togl), (char*)"Video not available, Netgen was not compiled with FFMPEG library", TCL_STATIC);
2276 return TCL_ERROR;
2277 }
2278 #endif // FFMPEG
2279
2280
2281
2282
2283
2284
2285
Ng_MouseMove(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2286 int Ng_MouseMove (ClientData clientData,
2287 Tcl_Interp * interp,
2288 int argc, tcl_const char *argv[])
2289 {
2290 int oldx, oldy;
2291 int newx, newy;
2292
2293 oldx = atoi (argv[1]);
2294 oldy = atoi (argv[2]);
2295 newx = atoi (argv[3]);
2296 newy = atoi (argv[4]);
2297
2298 SetVisualScene(interp);
2299 visual_scene->MouseMove (oldx, oldy, newx, newy, argv[5][0]);
2300
2301 return TCL_OK;
2302 }
2303
2304
Ng_MouseDblClick(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2305 int Ng_MouseDblClick (ClientData clientData,
2306 Tcl_Interp * interp,
2307 int argc, tcl_const char *argv[])
2308 {
2309 int px = Togl_PixelScale(togl)*atoi (argv[1]);
2310 int py = Togl_PixelScale(togl)*atoi (argv[2]);
2311
2312 SetVisualScene(interp);
2313 visual_scene->MouseDblClick (px, py);
2314
2315 return TCL_OK;
2316 }
2317
2318
Ng_ZoomAll(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2319 int Ng_ZoomAll (ClientData clientData,
2320 Tcl_Interp * interp,
2321 int argc, tcl_const char *argv[])
2322 {
2323 SetVisualScene(interp);
2324 visual_scene->BuildScene (1);
2325
2326 return TCL_OK;
2327 }
2328
2329
Ng_Center(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2330 int Ng_Center (ClientData clientData,
2331 Tcl_Interp * interp,
2332 int argc, tcl_const char *argv[])
2333 {
2334 SetVisualScene(interp);
2335 visual_scene->BuildScene (2);
2336
2337 return TCL_OK;
2338 }
2339
2340
Ng_StandardRotation(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2341 int Ng_StandardRotation (ClientData clientData,
2342 Tcl_Interp * interp,
2343 int argc, tcl_const char *argv[])
2344 {
2345 SetVisualScene(interp);
2346 visual_scene->StandardRotation (argv[1]);
2347
2348 return TCL_OK;
2349 }
2350
Ng_ArbitraryRotation(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2351 int Ng_ArbitraryRotation (ClientData clientData,
2352 Tcl_Interp * interp,
2353 int argc, tcl_const char *argv[])
2354 {
2355 SetVisualScene(interp);
2356 NgArray<double> alpha;
2357 NgArray<Vec3d> vec;
2358
2359 for(int i=1; i<argc; i+=4)
2360 {
2361 alpha.Append(atof(argv[i]));
2362 vec.Append(Vec3d(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3])));
2363 }
2364
2365 visual_scene->ArbitraryRotation (alpha,vec);
2366
2367 return TCL_OK;
2368 }
2369
2370
2371
Ng_Metis(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2372 int Ng_Metis (ClientData clientData,
2373 Tcl_Interp * interp,
2374 int argc, tcl_const char *argv[])
2375 {
2376 #ifdef PARALLEL
2377 if (!mesh)
2378 {
2379 Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
2380 return TCL_ERROR;
2381 }
2382
2383 int nparts = atoi (argv[1]);
2384 ntasks = nparts+1;
2385 cout << "calling metis ... " << flush;
2386 mesh->ParallelMetis(ntasks);
2387 cout << "done" << endl;
2388 ntasks = 1;
2389
2390 // for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++)
2391 // (*mesh)[ei].SetIndex ( (*mesh)[ei].GetPartition() );
2392
2393 return TCL_OK;
2394
2395 #else
2396 Tcl_SetResult (interp, (char*)"metis not available", TCL_STATIC);
2397 return TCL_ERROR;
2398
2399 #endif
2400
2401
2402
2403 #ifdef OLDOLD
2404 // METIS Partitioning
2405
2406 if (mesh->GetDimension() == 3)
2407 {
2408 using namespace metis;
2409
2410 int ne = mesh->GetNE();
2411 if (ne < 3)
2412 {
2413 Tcl_SetResult (interp, "This operation needs a volume mesh", TCL_STATIC);
2414 return TCL_ERROR;
2415 }
2416
2417 int nn = mesh->GetNP();
2418
2419 ELEMENT_TYPE elementtype = mesh->VolumeElement(1).GetType();
2420 int npe = mesh->VolumeElement(1).GetNP();
2421
2422 for (int i = 2; i<=ne; i++)
2423 if (mesh->VolumeElement(i).GetType() != elementtype)
2424 {
2425 Tcl_SetResult (interp, "Works in 3D only uniformal tet or hex meshes", TCL_STATIC);
2426 return TCL_ERROR;
2427 }
2428
2429 idxtype *elmnts;
2430 elmnts = new idxtype[ne*npe];
2431
2432 int etype;
2433 if (elementtype == TET)
2434 etype = 2;
2435 else if (elementtype == HEX)
2436 etype = 3;
2437 else
2438 {
2439 Tcl_SetResult (interp, "Works in 3D only uniformal tet or hex meshes", TCL_STATIC);
2440 return TCL_ERROR;
2441 }
2442
2443 for (int i=1; i<=ne; i++)
2444 for (int j=1; j<=npe; j++)
2445 elmnts[(i-1)*npe+(j-1)] = mesh->VolumeElement(i).PNum(j)-1;
2446
2447
2448 int numflag = 0;
2449 int nparts = atoi (argv[1]);
2450 int edgecut;
2451 idxtype *epart, *npart;
2452 epart = new idxtype[ne];
2453 npart = new idxtype[nn];
2454
2455 cout << "Starting Metis (" << ne << " Elements, " << nn << " Nodes, " << nparts << " Partitions) ... " << flush;
2456
2457 METIS_PartMeshNodal (&ne, &nn, elmnts, &etype, &numflag, &nparts,
2458 &edgecut, epart, npart);
2459
2460 cout << "done" << endl;
2461
2462 cout << "edge-cut: " << edgecut << ", balance: " << ComputeElementBalance(ne, nparts, epart) << endl;
2463
2464 for (int i=1; i<=ne; i++)
2465 mesh->VolumeElement(i).SetPartition(epart[i-1]);
2466
2467 mesh->SetNextTimeStamp();
2468 }
2469
2470
2471 #endif
2472 return TCL_OK;
2473 }
2474
2475
2476
2477
2478
SelectFaceInOCCDialogTree(int facenr)2479 void SelectFaceInOCCDialogTree (int facenr)
2480 {
2481 char script[50];
2482 sprintf (script, "selectentity {Face %i}", facenr);
2483 Tcl_GlobalEval (tcl_interp, script);
2484 }
2485
2486
2487
2488
2489
2490 #ifndef ACIS
Ng_ACISCommand(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2491 int Ng_ACISCommand (ClientData clientData,
2492 Tcl_Interp * interp,
2493 int argc, tcl_const char *argv[])
2494 {
2495 if (argc >= 2)
2496 {
2497 if (strcmp (argv[1], "isACISavailable") == 0)
2498 {
2499 Tcl_SetResult (interp, (char*)"no", TCL_STATIC);
2500 return TCL_OK;
2501 }
2502 }
2503 Tcl_SetResult (interp, (char*)"undefined ACiS command", TCL_STATIC);
2504 return TCL_ERROR;
2505 }
2506 #endif
2507
2508
2509 // from ng_interface
Ng_SetVisualizationParameter(const char * name,const char * value)2510 void Ng_SetVisualizationParameter (const char * name, const char * value)
2511 {
2512 // #ifdef OPENGL
2513 // #ifndef NOTCL
2514 char buf[100];
2515 sprintf (buf, "visoptions.%s", name);
2516 if (printmessage_importance>0)
2517 {
2518 cout << "name = " << name << ", value = " << value << endl;
2519 cout << "set tcl-variable " << buf << " to " << value << endl;
2520 }
2521 Tcl_SetVar (tcl_interp, buf, const_cast<char*> (value), 0);
2522 Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;");
2523 // #endif
2524 // #endif
2525 }
2526 }
2527
2528
2529 using namespace netgen;
2530
Ng_SetMouseEventHandler(netgen::MouseEventHandler * handler)2531 void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler)
2532 {
2533 vsmesh.SetMouseEventHandler (handler);
2534 }
2535
Ng_SetUserVisualizationObject(netgen::UserVisualizationObject * vis)2536 void Ng_SetUserVisualizationObject (netgen::UserVisualizationObject * vis)
2537 {
2538 netgen::GetVSSolution().AddUserVisualizationObject (vis);
2539 }
2540
2541
2542
2543
2544 namespace netgen
2545 {
2546
2547
2548 int firsttime = 1;
2549 int animcnt = 0;
PlayAnimFile(const char * name,int speed,int maxcnt)2550 void PlayAnimFile(const char* name, int speed, int maxcnt)
2551 {
2552 //extern Mesh * mesh;
2553
2554 /*
2555 if (mesh) mesh->DeleteMesh();
2556 if (!mesh) mesh = new Mesh();
2557 */
2558 mesh = make_shared<Mesh>();
2559
2560 int ne, np, i;
2561
2562 char str[80];
2563 char str2[80];
2564
2565 //int tend = 5000;
2566 // for (ti = 1; ti <= tend; ti++)
2567 //{
2568 int rti = (animcnt%(maxcnt-1)) + 1;
2569 animcnt+=speed;
2570
2571 sprintf(str2,"%05i.sol",rti);
2572 strcpy(str,"mbssol/");
2573 strcat(str,name);
2574 strcat(str,str2);
2575
2576 if (printmessage_importance>0)
2577 cout << "read file '" << str << "'" << endl;
2578
2579 ifstream infile(str);
2580 infile >> ne;
2581 for (i = 1; i <= ne; i++)
2582 {
2583 int j;
2584 Element2d tri(TRIG);
2585 tri.SetIndex(1); //faceind
2586
2587 for (j = 1; j <= 3; j++)
2588 infile >> tri.PNum(j);
2589
2590 infile >> np;
2591 for (i = 1; i <= np; i++)
2592 {
2593 Point3d p;
2594 infile >> p.X() >> p.Y() >> p.Z();
2595 if (firsttime)
2596 mesh->AddPoint (p);
2597 else
2598 mesh->Point(i) = Point<3> (p);
2599 }
2600
2601 //firsttime = 0;
2602 Ng_Redraw();
2603 }
2604 }
2605
2606
2607
2608
Ng_SetVisParameters(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2609 int Ng_SetVisParameters (ClientData clientData,
2610 Tcl_Interp * interp,
2611 int argc, tcl_const char *argv[])
2612 {
2613 if (!Tcl_GetVar (interp, "::viewoptions.light.amb", TCL_GLOBAL_ONLY))
2614 return TCL_ERROR;
2615
2616 vispar.lightamb = atof (Tcl_GetVar (interp, "::viewoptions.light.amb", TCL_GLOBAL_ONLY));
2617 vispar.lightdiff = atof (Tcl_GetVar (interp, "::viewoptions.light.diff", TCL_GLOBAL_ONLY));
2618 vispar.lightspec = atof (Tcl_GetVar (interp, "::viewoptions.light.spec", TCL_GLOBAL_ONLY));
2619 vispar.shininess = atof (Tcl_GetVar (interp, "::viewoptions.mat.shininess", TCL_GLOBAL_ONLY));
2620 vispar.locviewer = atoi (Tcl_GetVar (interp, "::viewoptions.light.locviewer", TCL_GLOBAL_ONLY));
2621 vispar.transp = atof (Tcl_GetVar (interp, "::viewoptions.mat.transp", TCL_GLOBAL_ONLY));
2622
2623 VisualizationParameters::Clipping hclip;
2624 hclip.normal.X() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.nx", TCL_GLOBAL_ONLY));
2625 hclip.normal.Y() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.ny", TCL_GLOBAL_ONLY));
2626 hclip.normal.Z() = atof (Tcl_GetVar (interp, "::viewoptions.clipping.nz", TCL_GLOBAL_ONLY));
2627 hclip.dist = atof (Tcl_GetVar (interp, "::viewoptions.clipping.dist", TCL_GLOBAL_ONLY));
2628 hclip.dist2 = atof (Tcl_GetVar (interp, "::viewoptions.clipping.dist2", TCL_GLOBAL_ONLY));
2629 hclip.enable = atoi (Tcl_GetVar (interp, "::viewoptions.clipping.enable", TCL_GLOBAL_ONLY));
2630 vispar.clipdomain =
2631 atoi (Tcl_GetVar (interp, "::viewoptions.clipping.onlydomain", TCL_GLOBAL_ONLY));
2632 vispar.donotclipdomain =
2633 atoi (Tcl_GetVar (interp, "::viewoptions.clipping.notdomain", TCL_GLOBAL_ONLY));
2634
2635 if ( ! (hclip == vispar.clipping) )
2636 {
2637 vispar.clipping = hclip;
2638 vispar.clipping.timestamp = NextTimeStamp();
2639 }
2640
2641 vispar.whitebackground = atoi (Tcl_GetVar (interp, "::viewoptions.whitebackground", TCL_GLOBAL_ONLY));
2642 vispar.drawcoordinatecross = atoi (Tcl_GetVar (interp, "::viewoptions.drawcoordinatecross", TCL_GLOBAL_ONLY));
2643 vispar.drawcolorbar = atoi (Tcl_GetVar (interp, "::viewoptions.drawcolorbar", TCL_GLOBAL_ONLY));
2644 vispar.drawnetgenlogo = atoi (Tcl_GetVar (interp, "::viewoptions.drawnetgenlogo", TCL_GLOBAL_ONLY));
2645 vispar.stereo = atoi (Tcl_GetVar (interp, "::viewoptions.stereo", TCL_GLOBAL_ONLY));
2646 vispar.colormeshsize = atoi (Tcl_GetVar (interp, "::viewoptions.colormeshsize", TCL_GLOBAL_ONLY));
2647 VisualScene :: SetBackGroundColor (vispar.whitebackground ? 1 : 0);
2648
2649 strcpy (vispar.selectvisual, Tcl_GetVar (interp, "::selectvisual", TCL_GLOBAL_ONLY));
2650
2651 // vispar.showstltrias = atoi (Tcl_GetVar (interp, "::viewoptions.stl.showtrias", TCL_GLOBAL_ONLY));
2652
2653 vispar.stlshowtrias =
2654 atoi (Tcl_GetVar (interp, "::stloptions.showtrias", TCL_GLOBAL_ONLY));
2655 vispar.stlshowfilledtrias =
2656 atoi (Tcl_GetVar (interp, "::stloptions.showfilledtrias", TCL_GLOBAL_ONLY));
2657 vispar.stlshowedges =
2658 atoi (Tcl_GetVar (interp, "::stloptions.showedges", TCL_GLOBAL_ONLY));
2659 vispar.stlshowmarktrias =
2660 atoi (Tcl_GetVar (interp, "::stloptions.showmarktrias", TCL_GLOBAL_ONLY));
2661 vispar.stlshowactivechart =
2662 atoi (Tcl_GetVar (interp, "::stloptions.showactivechart", TCL_GLOBAL_ONLY));
2663 vispar.stlchartnumber =
2664 atoi (Tcl_GetVar (interp, "::stloptions.chartnumber", TCL_GLOBAL_ONLY));
2665 vispar.stlchartnumberoffset =
2666 atoi (Tcl_GetVar (interp, "::stloptions.chartnumberoffset", TCL_GLOBAL_ONLY));
2667
2668 vispar.occshowsurfaces =
2669 atoi (Tcl_GetVar (interp, "::occoptions.showsurfaces", TCL_GLOBAL_ONLY));
2670 vispar.occshowedges =
2671 atoi (Tcl_GetVar (interp, "::occoptions.showedges", TCL_GLOBAL_ONLY));
2672
2673 vispar.drawoutline =
2674 atoi (Tcl_GetVar (interp, "::viewoptions.drawoutline", TCL_GLOBAL_ONLY));
2675 vispar.drawfilledtrigs =
2676 atoi (Tcl_GetVar (interp, "::viewoptions.drawfilledtrigs", TCL_GLOBAL_ONLY));
2677 vispar.subdivisions =
2678 atoi (Tcl_GetVar (interp, "::visoptions.subdivisions", TCL_GLOBAL_ONLY));
2679 vispar.drawbadels =
2680 atoi (Tcl_GetVar (interp, "::viewoptions.drawbadels", TCL_GLOBAL_ONLY));
2681 vispar.drawedges =
2682 atoi (Tcl_GetVar (interp, "::viewoptions.drawedges", TCL_GLOBAL_ONLY));
2683
2684 vispar.drawtetsdomain =
2685 atoi (Tcl_GetVar (interp, "::viewoptions.drawtetsdomain", TCL_GLOBAL_ONLY));
2686 vispar.drawtets =
2687 atoi (Tcl_GetVar (interp, "::viewoptions.drawtets", TCL_GLOBAL_ONLY));
2688 vispar.drawprisms =
2689 atoi (Tcl_GetVar (interp, "::viewoptions.drawprisms", TCL_GLOBAL_ONLY));
2690 vispar.drawpyramids =
2691 atoi (Tcl_GetVar (interp, "::viewoptions.drawpyramids", TCL_GLOBAL_ONLY));
2692 vispar.drawhexes =
2693 atoi (Tcl_GetVar (interp, "::viewoptions.drawhexes", TCL_GLOBAL_ONLY));
2694 /*
2695 vispar.shrink =
2696 atof (Tcl_GetVar (interp, "::viewoptions.shrink", TCL_GLOBAL_ONLY));
2697 */
2698 double hshrink = atof (Tcl_GetVar (interp, "::viewoptions.shrink", TCL_GLOBAL_ONLY));
2699 if (hshrink != vispar.shrink)
2700 { vispar.shrink = hshrink; vispar.clipping.timestamp = NextTimeStamp();}
2701 vispar.drawidentified =
2702 atoi (Tcl_GetVar (interp, "::viewoptions.drawidentified", TCL_GLOBAL_ONLY));
2703 vispar.drawpointnumbers =
2704 atoi (Tcl_GetVar (interp, "::viewoptions.drawpointnumbers", TCL_GLOBAL_ONLY));
2705 vispar.drawedgenumbers =
2706 atoi (Tcl_GetVar (interp, "::viewoptions.drawedgenumbers", TCL_GLOBAL_ONLY));
2707 vispar.drawfacenumbers =
2708 atoi (Tcl_GetVar (interp, "::viewoptions.drawfacenumbers", TCL_GLOBAL_ONLY));
2709 vispar.drawelementnumbers =
2710 atoi (Tcl_GetVar (interp, "::viewoptions.drawelementnumbers", TCL_GLOBAL_ONLY));
2711 vispar.drawdomainsurf =
2712 atoi (Tcl_GetVar (interp, "::viewoptions.drawdomainsurf", TCL_GLOBAL_ONLY));
2713
2714 vispar.drawededges =
2715 atoi (Tcl_GetVar (interp, "::viewoptions.drawededges", TCL_GLOBAL_ONLY));
2716 vispar.drawedpoints =
2717 atoi (Tcl_GetVar (interp, "::viewoptions.drawedpoints", TCL_GLOBAL_ONLY));
2718 vispar.drawedpointnrs =
2719 atoi (Tcl_GetVar (interp, "::viewoptions.drawedpointnrs", TCL_GLOBAL_ONLY));
2720 vispar.drawedtangents =
2721 atoi (Tcl_GetVar (interp, "::viewoptions.drawedtangents", TCL_GLOBAL_ONLY));
2722 vispar.drawededgenrs =
2723 atoi (Tcl_GetVar (interp, "::viewoptions.drawededgenrs", TCL_GLOBAL_ONLY));
2724
2725 vispar.drawcurveproj =
2726 atoi (Tcl_GetVar (interp, "::viewoptions.drawcurveproj", TCL_GLOBAL_ONLY));
2727 vispar.drawcurveprojedge =
2728 atoi (Tcl_GetVar (interp, "::viewoptions.drawcurveprojedge", TCL_GLOBAL_ONLY));
2729
2730 vispar.centerpoint =
2731 atoi (Tcl_GetVar (interp, "::viewoptions.centerpoint", TCL_GLOBAL_ONLY));
2732 vispar.use_center_coords =
2733 atoi (Tcl_GetVar (interp, "::viewoptions.usecentercoords", TCL_GLOBAL_ONLY)) > 0;
2734 vispar.centerx =
2735 atof (Tcl_GetVar (interp, "::viewoptions.centerx", TCL_GLOBAL_ONLY));
2736 vispar.centery =
2737 atof (Tcl_GetVar (interp, "::viewoptions.centery", TCL_GLOBAL_ONLY));
2738 vispar.centerz =
2739 atof (Tcl_GetVar (interp, "::viewoptions.centerz", TCL_GLOBAL_ONLY));
2740 vispar.drawelement =
2741 atoi (Tcl_GetVar (interp, "::viewoptions.drawelement", TCL_GLOBAL_ONLY));
2742 vispar.drawmetispartition =
2743 atoi (Tcl_GetVar (interp, "::viewoptions.drawmetispartition", TCL_GLOBAL_ONLY));
2744
2745 vispar.drawspecpoint =
2746 atoi (Tcl_GetVar (interp, "::viewoptions.drawspecpoint", TCL_GLOBAL_ONLY));
2747 vispar.specpointx =
2748 atof (Tcl_GetVar (interp, "::viewoptions.specpointx", TCL_GLOBAL_ONLY));
2749 vispar.specpointy =
2750 atof (Tcl_GetVar (interp, "::viewoptions.specpointy", TCL_GLOBAL_ONLY));
2751 vispar.specpointz =
2752 atof (Tcl_GetVar (interp, "::viewoptions.specpointz", TCL_GLOBAL_ONLY));
2753
2754
2755 vsspecpoints.len =
2756 atof (Tcl_GetVar (interp, "::viewoptions.specpointvlen", TCL_GLOBAL_ONLY));
2757
2758 vispar.occdeflection = pow(10.0,-1-atof (Tcl_GetVar (interp, "::occoptions.deflection", TCL_GLOBAL_ONLY)));
2759
2760
2761
2762 #ifdef PARALLELGL
2763 vsmesh.Broadcast ();
2764 #endif
2765
2766 return TCL_OK;
2767 }
2768
2769
2770
Ng_BuildFieldLines(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2771 int Ng_BuildFieldLines (ClientData clientData,
2772 Tcl_Interp * interp,
2773 int argc, tcl_const char *argv[])
2774 {
2775 netgen::GetVSSolution().BuildFieldLinesPlot();
2776 return TCL_OK;
2777 }
2778
2779
2780
Ng_Exit(ClientData clientData,Tcl_Interp * interp,int argc,tcl_const char * argv[])2781 int Ng_Exit (ClientData clientData,
2782 Tcl_Interp * interp,
2783 int argc, tcl_const char *argv[])
2784 {
2785 /*
2786 #ifdef PARALLEL
2787 int id, rc, ntasks;
2788 MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
2789 MPI_Comm_rank(MPI_COMM_WORLD, &id);
2790 if ( id != 0 )
2791 return TCL_OK;
2792 #endif
2793 */
2794
2795 /*
2796 if (ngsolve_handle)
2797 {
2798 void (*ngs_exit)();
2799 ngs_exit = ( void (*)() ) dlsym (ngsolve_handle, "NGSolve_Exit");
2800 if (ngs_exit) (*ngs_exit)();
2801 }
2802 */
2803
2804 #ifdef NGSOLVE
2805 NGSolve_Exit ();
2806 #endif
2807
2808
2809
2810 #ifdef ACIS
2811 outcome res;
2812 res = api_terminate_faceter();
2813 if(!res.ok())
2814 cerr << "problem with terminating acis faceter" << endl;
2815 res = api_terminate_constructors();
2816 if(!res.ok())
2817 cerr << "problem with terminating acis constructors" << endl;
2818 res = api_terminate_kernel();
2819 if(!res.ok())
2820 cerr << "problem with terminating acis kernel" << endl;
2821 res = api_stop_modeller();
2822 if(!res.ok())
2823 cerr << "problem with terminating acis modeller" << endl;
2824
2825 //cout << "stopped acis, outcome = " << res.ok() << endl;
2826 #endif
2827
2828 #ifdef PARALLELGL
2829 if (id == 0) MyMPI_SendCmd ("end");
2830 MPI_Finalize();
2831 #endif
2832
2833 mesh.reset();
2834 ng_geometry.reset();
2835
2836 if (testout != &cout)
2837 delete testout;
2838
2839 return TCL_OK;
2840 }
2841
2842
2843 #ifdef SOCKETS
ServerSocketManagerRunDummy(void * nix)2844 void * ServerSocketManagerRunDummy ( void * nix )
2845 {
2846 serversocketmanager.Run();
2847 return NULL;
2848 }
2849
2850 extern "C" int Ng_ServerSocketManagerRun( void );
Ng_ServerSocketManagerRun(void)2851 int Ng_ServerSocketManagerRun( void )
2852 {
2853 if(mparam.parthread)
2854 RunParallel(ServerSocketManagerRunDummy,NULL);
2855 else
2856 serversocketmanager.Run();
2857
2858 return TCL_OK;
2859 }
2860
2861 extern "C" int Ng_ServerSocketManagerInit(int port);
Ng_ServerSocketManagerInit(int port)2862 int Ng_ServerSocketManagerInit(int port)
2863 {
2864 serversocketmanager.Init(port);
2865 return TCL_OK;
2866 }
2867 #endif //SOCKETS
2868
2869
2870 extern "C" int Ng_Init (Tcl_Interp * interp);
2871 extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
2872
2873 extern "C" int Ng_stl_Init (Tcl_Interp * interp);
2874 extern "C" int Ng_geom2d_Init (Tcl_Interp * interp);
2875 #ifdef OCCGEOMETRY
2876 extern "C" int Ng_occ_Init (Tcl_Interp * interp);
2877 #endif
2878
2879
2880 // extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
2881
2882 // int main_Eero (ClientData clientData,
2883 // Tcl_Interp * interp,
2884 // int argc, tcl_const char *argv[]);
2885
2886
Ng_Init(Tcl_Interp * interp)2887 int Ng_Init (Tcl_Interp * interp)
2888 {
2889 #ifdef SOCKETS
2890 if(serversocketmanager.Good())
2891 serversocketusernetgen.Reset(new ServerSocketUserNetgen (serversocketmanager, mesh, geometry));
2892 #endif
2893
2894 Ng_CSG_Init(interp);
2895 Ng_stl_Init(interp);
2896 Ng_geom2d_Init (interp);
2897 #ifdef OCCGEOMETRY
2898 Ng_occ_Init (interp);
2899 #endif
2900
2901
2902 // Ng_Geom2d_Init(interp);
2903
2904 tcl_interp = interp;
2905
2906 // Tcl_CreateCommand (interp, "Ng_Eero", main_Eero,
2907 // (ClientData)NULL,
2908 // (Tcl_CmdDeleteProc*) NULL);
2909
2910
2911 Tcl_CreateCommand (interp, "Ng_New", Ng_New,
2912 (ClientData)NULL,
2913 (Tcl_CmdDeleteProc*) NULL);
2914
2915 // Tcl_CreateCommand (interp, "Ng_Lock", Ng_Lock,
2916 // (ClientData)NULL,
2917 // (Tcl_CmdDeleteProc*) NULL);
2918
2919 Tcl_CreateCommand (interp, "Ng_LoadGeometry", Ng_LoadGeometry,
2920 (ClientData)NULL,
2921 (Tcl_CmdDeleteProc*) NULL);
2922
2923 Tcl_CreateCommand (interp, "Ng_SaveGeometry", Ng_SaveGeometry,
2924 (ClientData)NULL,
2925 (Tcl_CmdDeleteProc*) NULL);
2926
2927
2928 Tcl_CreateCommand (interp, "Ng_LoadMesh", Ng_LoadMesh,
2929 (ClientData)NULL,
2930 (Tcl_CmdDeleteProc*) NULL);
2931
2932 Tcl_CreateCommand (interp, "Ng_SaveMesh", Ng_SaveMesh,
2933 (ClientData)NULL,
2934 (Tcl_CmdDeleteProc*) NULL);
2935
2936 Tcl_CreateCommand (interp, "Ng_MergeMesh", Ng_MergeMesh,
2937 (ClientData)NULL,
2938 (Tcl_CmdDeleteProc*) NULL);
2939
2940 Tcl_CreateCommand (interp, "Ng_GetExportFormats", Ng_GetExportFormats,
2941 (ClientData)NULL,
2942 (Tcl_CmdDeleteProc*) NULL);
2943
2944 Tcl_CreateCommand (interp, "Ng_ExportMesh", Ng_ExportMesh,
2945 (ClientData)NULL,
2946 (Tcl_CmdDeleteProc*) NULL);
2947
2948 Tcl_CreateCommand (interp, "Ng_ImportMesh", Ng_ImportMesh,
2949 (ClientData)NULL,
2950 (Tcl_CmdDeleteProc*) NULL);
2951
2952 Tcl_CreateCommand (interp, "Ng_ImportSolution", Ng_ImportSolution,
2953 (ClientData)NULL,
2954 (Tcl_CmdDeleteProc*) NULL);
2955
2956 Tcl_CreateCommand (interp, "Ng_ShowDemo", Ng_ShowDemo,
2957 (ClientData)NULL,
2958 (Tcl_CmdDeleteProc*) NULL);
2959
2960 Tcl_CreateCommand (interp, "Ng_DemoSetTime", Ng_DemoSetTime,
2961 (ClientData)NULL,
2962 (Tcl_CmdDeleteProc*) NULL);
2963
2964 Tcl_CreateCommand (interp, "Ng_SaveSolution", Ng_SaveSolution,
2965 (ClientData)NULL,
2966 (Tcl_CmdDeleteProc*) NULL);
2967
2968
2969
2970
2971
2972
2973 // meshing
2974 Tcl_CreateCommand (interp, "Ng_GenerateMesh", Ng_GenerateMesh,
2975 (ClientData)NULL,
2976 (Tcl_CmdDeleteProc*) NULL);
2977
2978 Tcl_CreateCommand (interp, "Ng_StopMeshing", Ng_StopMeshing,
2979 (ClientData)NULL,
2980 (Tcl_CmdDeleteProc*) NULL);
2981
2982 Tcl_CreateCommand (interp, "Ng_MeshInfo", Ng_MeshInfo,
2983 (ClientData)NULL,
2984 (Tcl_CmdDeleteProc*) NULL);
2985
2986 Tcl_CreateCommand (interp, "Ng_MeshQuality", Ng_MeshQuality,
2987 (ClientData)NULL,
2988 (Tcl_CmdDeleteProc*) NULL);
2989
2990 Tcl_CreateCommand (interp, "Ng_CheckSurfaceMesh", Ng_CheckSurfaceMesh,
2991 (ClientData)NULL,
2992 (Tcl_CmdDeleteProc*) NULL);
2993
2994 Tcl_CreateCommand (interp, "Ng_CheckVolumeMesh", Ng_CheckVolumeMesh,
2995 (ClientData)NULL,
2996 (Tcl_CmdDeleteProc*) NULL);
2997
2998 Tcl_CreateCommand (interp, "Ng_DeleteVolMesh", Ng_DeleteVolMesh,
2999 (ClientData)NULL,
3000 (Tcl_CmdDeleteProc*) NULL);
3001
3002 Tcl_CreateCommand (interp, "Ng_SplitSeparatedFaces", Ng_SplitSeparatedFaces,
3003 (ClientData)NULL,
3004 (Tcl_CmdDeleteProc*) NULL);
3005
3006 Tcl_CreateCommand (interp, "Ng_SetNextTimeStamp", Ng_SetNextTimeStamp,
3007 (ClientData)NULL,
3008 (Tcl_CmdDeleteProc*) NULL);
3009
3010 Tcl_CreateCommand (interp, "Ng_Refine", Ng_Refine,
3011 (ClientData)NULL,
3012 (Tcl_CmdDeleteProc*) NULL);
3013
3014 Tcl_CreateCommand (interp, "Ng_SecondOrder", Ng_SecondOrder,
3015 (ClientData)NULL,
3016 (Tcl_CmdDeleteProc*) NULL);
3017
3018 Tcl_CreateCommand (interp, "Ng_HighOrder", Ng_HighOrder,
3019 (ClientData)NULL,
3020 (Tcl_CmdDeleteProc*) NULL);
3021
3022 Tcl_CreateCommand (interp, "Ng_ValidateSecondOrder", Ng_ValidateSecondOrder,
3023 (ClientData)NULL,
3024 (Tcl_CmdDeleteProc*) NULL);
3025
3026 Tcl_CreateCommand (interp, "Ng_RestrictH", Ng_RestrictH,
3027 (ClientData)NULL,
3028 (Tcl_CmdDeleteProc*) NULL);
3029
3030 Tcl_CreateCommand (interp, "Ng_Anisotropy", Ng_Anisotropy,
3031 (ClientData)NULL,
3032 (Tcl_CmdDeleteProc*) NULL);
3033
3034 Tcl_CreateCommand (interp, "Ng_Bisect", Ng_Bisect,
3035 (ClientData)NULL,
3036 (Tcl_CmdDeleteProc*) NULL);
3037
3038 // Tcl_CreateCommand (interp, "Ng_BisectCopyMesh", Ng_BisectCopyMesh,
3039 // (ClientData)NULL,
3040 // (Tcl_CmdDeleteProc*) NULL);
3041
3042 Tcl_CreateCommand (interp, "Ng_Split2Tets", Ng_Split2Tets,
3043 (ClientData)NULL,
3044 (Tcl_CmdDeleteProc*) NULL);
3045
3046 Tcl_CreateCommand (interp, "Ng_ZRefinement", Ng_ZRefinement,
3047 (ClientData)NULL,
3048 (Tcl_CmdDeleteProc*) NULL);
3049
3050 Tcl_CreateCommand (interp, "Ng_HPRefinement", Ng_HPRefinement,
3051 (ClientData)NULL,
3052 (Tcl_CmdDeleteProc*) NULL);
3053
3054 Tcl_CreateCommand (interp, "Ng_LoadMeshSize", Ng_LoadMeshSize,
3055 (ClientData)NULL,
3056 (Tcl_CmdDeleteProc*) NULL);
3057
3058 Tcl_CreateCommand (interp, "Ng_MeshSizeFromSurfaceMesh", Ng_MeshSizeFromSurfaceMesh,
3059 (ClientData)NULL,
3060 (Tcl_CmdDeleteProc*) NULL);
3061
3062
3063 Tcl_CreateCommand (interp, "Ng_GenerateBoundaryLayer", Ng_GenerateBoundaryLayer,
3064 (ClientData)NULL,
3065 (Tcl_CmdDeleteProc*) NULL);
3066
3067 Tcl_CreateCommand (interp, "Ng_InsertVirtualBL", Ng_InsertVirtualBL,
3068 (ClientData)NULL,
3069 (Tcl_CmdDeleteProc*) NULL);
3070
3071 Tcl_CreateCommand (interp, "Ng_CutOffAndCombine", Ng_CutOffAndCombine,
3072 (ClientData)NULL,
3073 (Tcl_CmdDeleteProc*) NULL);
3074
3075 Tcl_CreateCommand (interp, "Ng_HelmholtzMesh", Ng_HelmholtzMesh,
3076 (ClientData)NULL,
3077 (Tcl_CmdDeleteProc*) NULL);
3078
3079 Tcl_CreateCommand (interp, "Ng_ReadStatus", Ng_ReadStatus,
3080 (ClientData)NULL,
3081 (Tcl_CmdDeleteProc*) NULL);
3082
3083 Tcl_CreateCommand (interp, "Ng_MemInfo", Ng_MemInfo,
3084 (ClientData)NULL,
3085 (Tcl_CmdDeleteProc*) NULL);
3086
3087
3088 Tcl_CreateCommand (interp, "Ng_MeshDoctor", Ng_MeshDoctor,
3089 (ClientData)NULL,
3090 (Tcl_CmdDeleteProc*) NULL);
3091
3092 Tcl_CreateCommand (interp, "Ng_BCProp", Ng_BCProp,
3093 (ClientData)NULL,
3094 (Tcl_CmdDeleteProc*) NULL);
3095
3096
3097
3098
3099 Tcl_CreateCommand (interp, "Ng_ACISCommand",
3100 Ng_ACISCommand,
3101 (ClientData)NULL,
3102 (Tcl_CmdDeleteProc*) NULL);
3103
3104
3105 Tcl_CreateCommand (interp, "Ng_MouseMove", Ng_MouseMove,
3106 (ClientData)NULL,
3107 (Tcl_CmdDeleteProc*) NULL);
3108
3109 Tcl_CreateCommand (interp, "Ng_MouseDblClick", Ng_MouseDblClick,
3110 (ClientData)NULL,
3111 (Tcl_CmdDeleteProc*) NULL);
3112
3113
3114 Tcl_CreateCommand (interp, "Ng_ZoomAll", Ng_ZoomAll,
3115 (ClientData)NULL,
3116 (Tcl_CmdDeleteProc*) NULL);
3117
3118 Tcl_CreateCommand (interp, "Ng_Center", Ng_Center,
3119 (ClientData)NULL,
3120 (Tcl_CmdDeleteProc*) NULL);
3121
3122 Tcl_CreateCommand (interp, "Ng_StandardRotation", Ng_StandardRotation,
3123 (ClientData)NULL,
3124 (Tcl_CmdDeleteProc*) NULL);
3125
3126 Tcl_CreateCommand (interp, "Ng_ArbitraryRotation", Ng_ArbitraryRotation,
3127 (ClientData)NULL,
3128 (Tcl_CmdDeleteProc*) NULL);
3129
3130
3131 Tcl_CreateCommand (interp, "Ng_SetVisParameters", Ng_SetVisParameters,
3132 (ClientData)NULL,
3133 (Tcl_CmdDeleteProc*) NULL);
3134
3135 Tcl_CreateCommand (interp, "Ng_SetMeshingParameters", Ng_SetMeshingParameters,
3136 (ClientData)NULL,
3137 (Tcl_CmdDeleteProc*) NULL);
3138
3139 Tcl_CreateCommand (interp, "Ng_SetDebugParameters", Ng_SetDebugParameters,
3140 (ClientData)NULL,
3141 (Tcl_CmdDeleteProc*) NULL);
3142
3143 Tcl_CreateCommand (interp, "Ng_SetCommandLineParameter",
3144 Ng_SetCommandLineParameter,
3145 (ClientData)NULL,
3146 (Tcl_CmdDeleteProc*) NULL);
3147
3148 Tcl_CreateCommand (interp, "Ng_GetCommandLineParameter",
3149 Ng_GetCommandLineParameter,
3150 (ClientData)NULL,
3151 (Tcl_CmdDeleteProc*) NULL);
3152
3153 Tcl_CreateCommand (interp, "Ng_Exit",
3154 Ng_Exit,
3155 (ClientData)NULL,
3156 (Tcl_CmdDeleteProc*) NULL);
3157
3158 Tcl_CreateCommand (interp, "Ng_Metis",
3159 Ng_Metis,
3160 (ClientData)NULL,
3161 (Tcl_CmdDeleteProc*) NULL);
3162
3163
3164 Tcl_CreateCommand (interp, "Ng_BuildFieldLines",
3165 Ng_BuildFieldLines,
3166 (ClientData)NULL,
3167 (Tcl_CmdDeleteProc*) NULL);
3168
3169 /*
3170 * Specify the C callback functions for widget creation, display,
3171 * and reshape.
3172 */
3173 Tcl_CreateObjCommand(interp, "Ng_GetToglVersion", Ng_ToglVersion, NULL, NULL);
3174
3175 if (!nodisplay)
3176 {
3177 if (Togl_Init(interp) == TCL_ERROR)
3178 return TCL_ERROR;
3179
3180
3181 Tcl_CreateObjCommand(interp, "init", init, NULL, NULL);
3182 Tcl_CreateObjCommand(interp, "zap", zap, NULL, NULL);
3183 Tcl_CreateObjCommand(interp, "draw", draw, NULL, NULL);
3184 Tcl_CreateObjCommand(interp, "reshape", reshape, NULL, NULL);
3185
3186 // Togl_TimerFunc( idle );
3187 Tcl_CreateObjCommand(interp, "Ng_SnapShot", Ng_SnapShot, NULL, NULL);
3188 Tcl_CreateObjCommand(interp, "Ng_VideoClip", Ng_VideoClip, NULL, NULL);
3189 }
3190
3191
3192 multithread.pause = 0;
3193 multithread.testmode = 0;
3194 multithread.redraw = 0;
3195 multithread.drawing = 1;
3196 multithread.terminate = 0;
3197 multithread.running = 0;
3198
3199 multithread.task = "";
3200 multithread.percent = 20;
3201
3202
3203 Tcl_LinkVar (interp, "multithread_pause",
3204 (char*)&multithread.pause, TCL_LINK_INT);
3205 Tcl_LinkVar (interp, "multithread_testmode",
3206 (char*)&multithread.testmode, TCL_LINK_INT);
3207 Tcl_LinkVar (interp, "multithread_redraw",
3208 (char*)&multithread.redraw, TCL_LINK_INT);
3209 Tcl_LinkVar (interp, "multithread_drawing",
3210 (char*)&multithread.drawing, TCL_LINK_INT);
3211 Tcl_LinkVar (interp, "multithread_terminate",
3212 (char*)&multithread.terminate, TCL_LINK_INT);
3213 Tcl_LinkVar (interp, "multithread_running",
3214 (char*)&multithread.running, TCL_LINK_INT);
3215
3216
3217 //testout->setstate(ios_base::badbit);
3218
3219 myerr = &cerr;
3220 extern ostream * mycout;
3221 mycout = &cout;
3222
3223 testmode = 0;
3224
3225
3226
3227 #ifdef ACIS
3228 outcome res;
3229 res = api_start_modeller (0);
3230 if(!res.ok())
3231 cerr << "problem with starting acis modeller" << endl;
3232
3233 #ifdef ACIS_R17
3234 unlock_spatial_products_661();
3235 #endif
3236 res = api_initialize_kernel();
3237 if(!res.ok())
3238 cerr << "problem with starting acis kernel" << endl;
3239 res = api_initialize_constructors();
3240 if(!res.ok())
3241 cerr << "problem with starting acis constructors" << endl;
3242 res = api_initialize_faceter();
3243 if(!res.ok())
3244 cerr << "problem with starting acis faceter" << endl;
3245 #endif
3246
3247
3248 return TCL_OK;
3249 }
3250
3251
3252 }
3253
3254
3255