48
58
ifstream infile (filename);
53
if (strcmp (&filename[strlen(filename)-3], "geo") == 0)
68
if ((strcmp (&filename[strlen(filename)-3], "geo") == 0) ||
69
(strcmp (&filename[strlen(filename)-3], "GEO") == 0) ||
70
(strcmp (&filename[strlen(filename)-3], "Geo") == 0))
56
geometry = new CSGeometry(filename);
60
lexer = new yyFlexLexer (&infile);
62
extern int yyparse ();
67
geometry = netgen::ParseCSG (infile);
72
geometry.Reset (netgen::ParseCSG (infile));
70
throw NgException ("input file not found");
76
geometry.Reset (new CSGeometry ());
77
throw NgException ("input file not found");
72
80
geometry -> FindIdenticSurfaces(1e-6);
82
double detail = atof (Tcl_GetVar (tcl_interp, "geooptions.detail", 0));
83
double facets = atof (Tcl_GetVar (tcl_interp, "geooptions.facets", 0));
73
84
Box<3> box (geometry->BoundingBox());
75
geometry->CalcTriangleApproximation (box, 0.01, 10);
86
if (atoi (Tcl_GetVar (tcl_interp, "geooptions.drawcsg", 0)))
87
geometry->CalcTriangleApproximation(box, detail, facets);
89
// geometry->CalcTriangleApproximation (box, 0.01, 10);
92
else if (strcmp (&filename[strlen(filename)-4], "in2d") == 0)
94
geometry2d.Reset (new SplineGeometry2d());
95
geometry2d -> Load (filename);
98
else if ((strcmp (&filename[strlen(filename)-3], "stl") == 0) ||
99
(strcmp (&filename[strlen(filename)-3], "STL") == 0) ||
100
(strcmp (&filename[strlen(filename)-3], "Stl") == 0))
102
ifstream infile(filename);
103
stlgeometry = STLGeometry :: Load (infile);
104
stlgeometry->edgesfound = 0;
106
stlgeometry->Clear();
107
stlgeometry->BuildEdges();
108
stlgeometry->MakeAtlas(meshdummy);
109
stlgeometry->CalcFaceNums();
110
stlgeometry->AddFaceEdges();
111
stlgeometry->LinkEdges();
115
else if ((strcmp (&filename[strlen(filename)-4], "iges") == 0) ||
116
(strcmp (&filename[strlen(filename)-3], "igs") == 0) ||
117
(strcmp (&filename[strlen(filename)-3], "IGS") == 0) ||
118
(strcmp (&filename[strlen(filename)-4], "IGES") == 0))
120
PrintMessage (1, "Load IGES geometry file ", filename);
121
occgeometry = LoadOCC_IGES (filename);
123
else if ((strcmp (&filename[strlen(filename)-4], "step") == 0) ||
124
(strcmp (&filename[strlen(filename)-3], "stp") == 0) ||
125
(strcmp (&filename[strlen(filename)-3], "STP") == 0) ||
126
(strcmp (&filename[strlen(filename)-4], "STEP") == 0))
128
PrintMessage (1, "Load STEP geometry file ", filename);
129
occgeometry = LoadOCC_STEP (filename);
79
geometry = new CSGeometry("");
81
if (strcmp (&filename[strlen(filename)-4], "in2d") == 0)
86
geometry2d = new SplineGeometry2d();
87
geometry2d -> Load (filename);
92
cerr << "Unknown geometry extension!!" << endl;
134
cerr << "Unknown geometry extension!!" << endl;
492
555
BisectionOptions biopt;
493
556
biopt.usemarkedelements = 1;
494
558
biopt.refine_hp = 0;
495
if (reftype == NG_REFINE_P || reftype == NG_REFINE_HP)
559
if (reftype == NG_REFINE_P)
561
if (reftype == NG_REFINE_HP)
496
562
biopt.refine_hp = 1;
498
if (geometry && mesh->GetDimension() == 3)
500
RefinementSurfaces ref (*geometry);
501
ref.Bisect (*mesh, biopt);
566
ref = new Refinement2d(*geometry2d);
503
567
else if (stlgeometry)
505
RefinementSTLGeometry ref (*stlgeometry);
506
ref.Bisect (*mesh, biopt);
510
Refinement2d ref (*geometry2d);
511
ref.Bisect (*mesh, biopt);
568
ref = new RefinementSTLGeometry(*stlgeometry);
570
else if (occgeometry)
571
ref = new OCCRefinementSurfaces (*occgeometry);
573
else if (geometry && mesh->GetDimension() == 3)
574
ref = new RefinementSurfaces(*geometry);
515
cout << "No geometry available" << endl;
517
ref.Bisect (*mesh, biopt);
577
ref = new Refinement();
580
ref -> Bisect (*mesh, biopt);
520
582
mesh -> UpdateTopology();
583
// mesh -> GetCurvedElements().BuildCurvedElements (ref, mparam.elementorder);
523
587
void Ng_SecondOrder ()
1140
1239
vss->soltype = VisualSceneSolution::SolType (soldata->soltype);
1141
1240
vss->solclass = soldata->solclass;
1142
1241
vssolution.AddSolutionData (vss);
1245
void Ng_ClearSolutionData ()
1247
vssolution.ClearSolutionData();
1146
1252
void Ng_Redraw ()
1148
1255
vssolution.UpdateSolutionTimeStamp();
1153
1261
void Ng_SetVisualizationParameter (const char * name, const char * value)
1156
1265
sprintf (buf, "visoptions.%s", name);
1157
1266
cout << "name = " << name << ", value = " << value << endl;
1158
1267
cout << "set tcl-variable " << buf << " to " << value << endl;
1159
1268
Tcl_SetVar (tcl_interp, buf, const_cast<char*> (value), 0);
1160
1269
Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;");
1240
1350
pairs[2*i+1] = apairs[i].I2();
1243
/*<<<<<< nginterface.cpp
1245
for (i = 1; i <= np; i++)
1248
infile >> p.X() >> p.Y() >> p.Z();
1261
int Ng_GetNPeriodicVertices ()
1263
ARRAY<INDEX_2> apairs;
1264
mesh->GetIdentifications().GetPairs (0, apairs);
1265
return apairs.Size();
1269
// pairs should be an integer array of 2*npairs
1270
void Ng_GetPeriodicVertices (int * pairs)
1272
ARRAY<INDEX_2> apairs;
1273
mesh->GetIdentifications().GetPairs (0, apairs);
1274
for (int i = 0; i < apairs.Size(); i++)
1276
pairs[2*i] = apairs[i].I1();
1277
pairs[2*i+1] = apairs[i].I2();
1281
mesh->AddSurfaceElement (tri);
1285
for (i = 1; i <= np; i++)
1288
infile >> p.X() >> p.Y() >> p.Z();
1357
int Ng_GetNPeriodicEdges ()
1359
ARRAY<INDEX,PointIndex::BASE> map;
1360
const MeshTopology & top = mesh->GetTopology();
1361
int nse = mesh->GetNSeg();
1364
// for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++)
1366
mesh->GetIdentifications().GetMap(0, map);
1367
//(*testout) << "ident-map " << id << ":" << endl << map << endl;
1369
for (SegmentIndex si = 0; si < nse; si++)
1371
PointIndex other1 = map[(*mesh)[si].p1];
1372
PointIndex other2 = map[(*mesh)[si].p2];
1373
// (*testout) << "seg = " << (*mesh)[si] << "; other = "
1374
// << other1 << "-" << other2 << endl;
1375
if (other1 && other2 && mesh->IsSegment (other1, other2))
1384
void Ng_GetPeriodicEdges (int * pairs)
1386
ARRAY<INDEX,PointIndex::BASE> map;
1387
const MeshTopology & top = mesh->GetTopology();
1388
int nse = mesh->GetNSeg();
1391
// for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++)
1393
mesh->GetIdentifications().GetMap(0, map);
1395
//(*testout) << "map = " << map << endl;
1397
for (SegmentIndex si = 0; si < nse; si++)
1399
PointIndex other1 = map[(*mesh)[si].p1];
1400
PointIndex other2 = map[(*mesh)[si].p2];
1401
if (other1 && other2 && mesh->IsSegment (other1, other2))
1403
SegmentIndex otherseg = mesh->SegmentNr (other1, other2);
1404
pairs[cnt++] = top.GetSegmentEdge (si+1);
1405
pairs[cnt++] = top.GetSegmentEdge (otherseg+1);
1413
void Ng_PushStatus (const char * str)
1415
PushStatus (MyStr (str));
1418
void Ng_PopStatus ()
1423
void Ng_SetThreadPercentage (double percent)
1425
SetThreadPercent (percent);
1429
///// Added by Roman Stainko ....
1430
int Ng_GetVertex_Elements( int vnr, int* elems )
1432
const MeshTopology& topology = mesh->GetTopology();
1433
ArrayMem<int,4> indexArray;
1434
topology.GetVertexElements( vnr, indexArray );
1436
for( int i=0; i<indexArray.Size(); i++ )
1437
elems[i] = indexArray[i];
1439
return indexArray.Size();
1442
///// Added by Roman Stainko ....
1443
int Ng_GetVertex_SurfaceElements( int vnr, int* elems )
1445
const MeshTopology& topology = mesh->GetTopology();
1446
ArrayMem<int,4> indexArray;
1447
topology.GetVertexSurfaceElements( vnr, indexArray );
1449
for( int i=0; i<indexArray.Size(); i++ )
1450
elems[i] = indexArray[i];
1452
return indexArray.Size();
1455
///// Added by Roman Stainko ....
1456
int Ng_GetVertex_NElements( int vnr )
1458
const MeshTopology& topology = mesh->GetTopology();
1459
ArrayMem<int,4> indexArray;
1460
topology.GetVertexElements( vnr, indexArray );
1462
return indexArray.Size();
1465
///// Added by Roman Stainko ....
1466
int Ng_GetVertex_NSurfaceElements( int vnr )
1468
const MeshTopology& topology = mesh->GetTopology();
1469
ArrayMem<int,4> indexArray;
1470
topology.GetVertexSurfaceElements( vnr, indexArray );
1472
return indexArray.Size();