Nektar++
Loading...
Searching...
No Matches
CADSystemOCE.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: CADSystemOCE.cpp
4//
5// For more information, please see: http://www.nektar.info/
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: cad object methods.
32//
33////////////////////////////////////////////////////////////////////////////////
34
37
44
47
48#include <ElCLib.hxx>
49#include <Interface_Static.hxx>
50#include <gce_MakeCirc.hxx>
51#include <gce_MakePln.hxx>
52
53#include <BRepBndLib.hxx>
54#include <BRepBuilderAPI_MakeShell.hxx>
55#include <BRepBuilderAPI_MakeSolid.hxx>
56#include <BRepClass3d_SolidClassifier.hxx>
57#include <BRepOffsetAPI_MakeFilling.hxx>
58#include <BRepPrimAPI_MakeBox.hxx>
59#include <Bnd_Box.hxx>
60#include <GC_MakeArcOfCircle.hxx>
61#include <ShapeFix_Shell.hxx>
62#include <ShapeFix_Solid.hxx>
63#include <StlAPI_Writer.hxx>
64#include <TopoDS_Solid.hxx>
65
66#include <Geom2d_Line.hxx>
67
68using namespace std;
69
71{
72
74 "oce", CADSystemOCE::create, "Uses OCE as cad engine");
75
76void filterModShape(TopTools_DataMapOfShapeShape &modShape, TopoDS_Shape &S)
77{
78 bool repeat = true;
79 while (repeat)
80 {
81 repeat = false;
82 if (modShape.IsBound(S))
83 {
84 repeat = true;
85 S = modShape.Find(S);
86 }
87 }
88}
89
90/**
91 * @brief For a given shell @p shell, attempt to find a point that is strictly
92 * on the interior of the shape.
93 */
94gp_Pnt FindInteriorPoint(TopoDS_Shell &shell)
95{
96 // Grab a face.
97 TopExp_Explorer ex;
98 ex.Init(shell, TopAbs_FACE);
99
100 BRepBuilderAPI_MakeSolid makeSolid(shell);
101 TopoDS_Solid solid = makeSolid.Solid();
102
103 // Compute solid volume. if it's negative, then the shell was constructed
104 // inside-out, so reverse the solid.
105 GProp_GProps solidProps;
106 BRepGProp::VolumeProperties(solid, solidProps);
107 if (solidProps.Mass() < 0.0)
108 {
109 solid.Reverse();
110 }
111
112 BRepClass3d_SolidClassifier cls(solid);
113
114 for (ex.Init(shell, TopAbs_FACE); ex.More(); ex.Next())
115 {
116 // Get bounds for the face and grab a handle to a Geom_Surface.
117 TopoDS_Face face = TopoDS::Face(ex.Current());
118 Handle(Geom_Surface) s = BRep_Tool::Surface(face);
119
120 NekDouble umin, umax, vmin, vmax;
121 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
122
123 // Take central point on parametrisation and compute normal, which
124 // should be outwards facing assuming the shell has been fixed.
125 GeomLProp_SLProps d(s, 2, Precision::Confusion());
126 d.SetParameters(0.5 * (umin + umax), 0.5 * (vmin + vmax));
127
128 gp_XYZ pnt = s->Value(0.5 * (umin + umax), 0.5 * (vmin + vmax)).XYZ();
129
130 // If for some reason we don't have a normal for this face, continue to
131 // the next one.
132 if (!d.IsNormalDefined())
133 {
134 continue;
135 }
136
137 // Compute inwards facing normal and multiply by a scale factor which is
138 // hopefully somewhat proportional to the direction we care about.
139 GProp_GProps faceProp;
140 BRepGProp::SurfaceProperties(face, faceProp);
141
142 // Follow the inwards normal direction and backtrack. Use the classifier
143 // to figure out if we're inside the volume (or not).
144 gp_XYZ n = d.Normal().XYZ() * sqrt(faceProp.Mass());
145 NekDouble alpha = 1.0;
146
147 for (int i = 0; i < 2; ++i)
148 {
149 // Try inwards and outwards facing directions.
150 n *= -1.0;
151
152 while (alpha > 1e-4)
153 {
154 gp_Pnt testPnt(pnt + n * alpha);
155 cls.Perform(testPnt, Precision::Confusion());
156 TopAbs_State state = cls.State();
157
158 if (state == TopAbs_IN)
159 {
160 return testPnt;
161 }
162
163 alpha /= 2.0;
164 }
165 }
166
167 // Failed on this face, try the next one.
168 }
169
170 ASSERTL0(false, "Failed to find point internal to geometry.");
171 return gp_Pnt();
172}
173
175{
176 Handle(XSControl_WorkSession) WS;
177 Handle(Interface_InterfaceModel) Model;
178 Handle(XSControl_TransferReader) TR;
179 Handle(Transfer_TransientProcess) TP;
180 Handle(XCAFDoc_ShapeTool) STool;
181
182 bool fromStep = false;
183
184 if (m_config.count("UseNACA") == 0)
185 {
186 // not a naca profile behave normally
187 // could be a geo
188 if (fs::path(m_name).extension() == ".geo")
189 {
191 }
192 else
193 {
194 // Takes step file and makes OpenCascade shape
195 // Say what unit the model is wanted in rather than inheriting
196 // it. OpenCASCADE converts a STEP file from whatever its header
197 // declares into the unit named by this global, which defaults to
198 // millimetres -- the same assumption CADUnits makes on the way
199 // out. Leaving it to the default made the whole pipeline's scale
200 // depend on a setting anything else in the process could change.
201 Interface_Static::SetCVal("xstep.cascade.unit", "MM");
202
203 STEPCAFControl_Reader readerCAF;
204 readerCAF.SetNameMode(true);
205 readerCAF.SetLayerMode(true);
206 readerCAF.SetColorMode(true);
207
208 Handle(TDocStd_Document) document =
209 new TDocStd_Document(Storage::Version());
210 readerCAF.ReadFile(m_name.c_str());
211 readerCAF.Transfer(document);
212
213 STEPControl_Reader reader = readerCAF.Reader();
214
215 WS = reader.WS();
216 Model = WS->Model();
217 TR = WS->TransferReader();
218 TP = TR->TransientProcess();
219 XCAFDoc_DocumentTool::ShapeTool(document->Main());
220
221 reader.NbRootsForTransfer();
222 reader.TransferRoots();
223 m_shape = reader.OneShape();
224 if (m_shape.IsNull())
225 {
226 return false;
227 }
228 fromStep = true;
229 }
230 }
231 else
232 {
234 }
235
236 TopExp_Explorer explr;
237
238 TopTools_DataMapOfShapeShape modShape;
239
240 if (!m_2d)
241 {
242 // Sewing joins faces whose edges lie within a tolerance of each
243 // other, so the tolerance has to mean something relative to the
244 // model: the fixed 0.1 this replaces is a sixth of a model one CAD
245 // unit across and invisible on one a kilometre across, and which of
246 // those a given STEP file is depends on what the part is, not on
247 // anything NekMesh knows.
248 //
249 // A fraction of the diagonal of the bounding box instead, floored so
250 // that a model with no extent cannot produce a zero tolerance. The
251 // fraction is chosen to land near the old fixed value on the
252 // geometries this was developed against -- it comes out at 1.3e-4 on
253 // 3d_bl_wing against the 1e-4 the old one amounted to -- and errs
254 // tight rather than loose, 8.7e-6 on brakedisc. That is the safer
255 // direction: sewing too loosely fuses faces that should have stayed
256 // apart and says nothing, while sewing too tightly leaves an edge
257 // bounded by one face and trips the topology check below.
258 Bnd_Box bb;
259 BRepBndLib::Add(m_shape, bb);
260
261 NekDouble diagonal = sqrt(bb.SquareExtent());
262 NekDouble sewTolerance =
263 std::max(1e-5 * diagonal, Precision::Confusion());
264
265 m_log(VERBOSE) << "Sewing faces with a tolerance of "
266 << CADUnits::FromCAD(sewTolerance) << "." << endl;
267
268 BRepBuilderAPI_Sewing sew(sewTolerance);
269
270 for (explr.Init(m_shape, TopAbs_FACE); explr.More(); explr.Next())
271 {
272 sew.Add(explr.Current());
273 }
274
275 sew.Perform();
276
277 for (explr.Init(m_shape, TopAbs_FACE); explr.More(); explr.Next())
278 {
279 if (sew.IsModified(explr.Current()))
280 {
281 modShape.Bind(explr.Current(), sew.Modified(explr.Current()));
282 }
283 }
284
285 m_shape = sew.SewedShape();
286 }
287
288 // build map of verticies
289 for (explr.Init(m_shape, TopAbs_VERTEX); explr.More(); explr.Next())
290 {
291 TopoDS_Shape v = explr.Current();
292 if (m_mapOfVerts.Contains(v))
293 {
294 continue;
295 }
296 int i = m_mapOfVerts.Add(v);
297 AddVert(i, v);
298 }
299
300 // For each face of the geometry, get the local edges which bound it. If
301 // they are valid (their type != 7), then add them to an edge map. This
302 // filters out the dummy edges which OCC uses.
303 for (explr.Init(m_shape, TopAbs_EDGE); explr.More(); explr.Next())
304 {
305 TopoDS_Shape e = explr.Current().Oriented(TopAbs_FORWARD);
306 if (m_mapOfEdges.Contains(e))
307 {
308 continue;
309 }
310
311 if (!BRep_Tool::Degenerated(TopoDS::Edge(e)))
312 {
313 int i = m_mapOfEdges.Add(e);
314 AddCurve(i, e);
315 }
316 }
317
318 for (explr.Init(m_shape, TopAbs_FACE); explr.More(); explr.Next())
319 {
320 TopoDS_Shape f = explr.Current();
321 if (m_mapOfFaces.Contains(f))
322 {
323 m_log(FATAL) << "the CAD model lists the same face twice, which "
324 "leaves the surface mesher no way to tell which "
325 "of the two a mesh element belongs to."
326 << endl;
327 }
328 int i = m_mapOfFaces.Add(f);
329
330 AddSurf(i, f);
331 }
332
333 // Attempts to extract patch names from STEP file
334 if (fromStep)
335 {
336 int nb = Model->NbEntities();
337 for (int i = 1; i <= nb; i++)
338 {
339 if (!Model->Value(i)->DynamicType()->SubType(
340 "StepRepr_RepresentationItem"))
341 {
342 continue;
343 }
344
345 Handle(StepRepr_RepresentationItem) enti =
346 Handle(StepRepr_RepresentationItem)::DownCast(Model->Value(i));
347 Handle(TCollection_HAsciiString) name = enti->Name();
348
349 if (name->IsEmpty())
350 {
351 continue;
352 }
353
354 Handle(Transfer_Binder) binder = TP->Find(Model->Value(i));
355 if (binder.IsNull() || !binder->HasResult())
356 {
357 continue;
358 }
359
360 TopoDS_Shape S = TransferBRep::ShapeResult(TP, binder);
361
362 if (S.IsNull())
363 {
364 continue;
365 }
366
367 if (S.ShapeType() == TopAbs_FACE)
368 {
369 string s(name->ToCString());
370
371 if (m_mapOfFaces.Contains(S))
372 {
373 int id = m_mapOfFaces.FindIndex(S);
374
375 m_surfs[id]->SetName(s);
376 }
377 else
378 {
379 filterModShape(modShape, S);
380 if (m_mapOfFaces.Contains(S))
381 {
382 int id = m_mapOfFaces.FindIndex(S);
383 m_surfs[id]->SetName(s);
384 }
385 else
386 {
387 // ASSERTL0(false, "Name error");
388 }
389 }
390 }
391 }
392 }
393 // attempts to identify properties of the vertex on the degen edge
394 for (int i = 1; i <= m_mapOfFaces.Extent(); i++)
395 {
396 TopoDS_Shape face = m_mapOfFaces.FindKey(i).Oriented(TopAbs_FORWARD);
397
398 TopTools_IndexedMapOfShape localEdges;
399 TopExp::MapShapes(face, TopAbs_EDGE, localEdges);
400
401 for (int j = 1; j <= localEdges.Extent(); j++)
402 {
403 TopoDS_Shape edge = localEdges.FindKey(j);
404 if (BRep_Tool::Degenerated(TopoDS::Edge(edge)))
405 {
406 gp_Pnt2d p1, p2;
407
408 BRep_Tool::UVPoints(TopoDS::Edge(edge), TopoDS::Face(face), p1,
409 p2);
410
411 m_verts[m_mapOfVerts.FindIndex(TopExp::FirstVertex(
412 TopoDS::Edge(edge), Standard_True))]
413 ->SetDegen(i, m_surfs[i], (p1.X() + p2.X()) / 2.0,
414 (p1.Y() + p2.Y()) / 2.0);
415 }
416 }
417 }
418
419 if (!m_2d)
420 {
421 CheckClosed();
422 }
423
424 Report();
425
426 return true;
427}
428
429void CADSystemOCE::AddVert(int i, TopoDS_Shape in)
430{
432
433 newVert->SetLogger(m_log);
434 std::static_pointer_cast<CADVertOCE>(newVert)->Initialise(i, in);
435
436 m_verts[i] = newVert;
437}
438
439void CADSystemOCE::AddCurve(int i, TopoDS_Shape in)
440{
442 newCurve->SetLogger(m_log);
443 std::static_pointer_cast<CADCurveOCE>(newCurve)->Initialise(i, in);
444
445 TopoDS_Vertex fv = TopExp::FirstVertex(TopoDS::Edge(in));
446 TopoDS_Vertex lv = TopExp::LastVertex(TopoDS::Edge(in));
447
448 vector<CADVertSharedPtr> vs;
449 vs.push_back(m_verts[m_mapOfVerts.FindIndex(fv)]);
450 vs.push_back(m_verts[m_mapOfVerts.FindIndex(lv)]);
451 newCurve->SetVert(vs);
452
453 m_curves[i] = newCurve;
454}
455
456void CADSystemOCE::AddSurf(int i, TopoDS_Shape in)
457{
459 newSurf->SetLogger(m_log);
460 std::static_pointer_cast<CADSurfOCE>(newSurf)->Initialise(i, in);
461
462 // do the exploration on forward oriented
463 TopoDS_Shape face = in.Oriented(TopAbs_FORWARD);
464 TopTools_IndexedMapOfShape mapOfWires;
465 TopExp::MapShapes(face, TopAbs_WIRE, mapOfWires);
466 vector<EdgeLoopSharedPtr> edgeloops;
467 // now we acutally analyse the loops for cad building
468 for (int j = 1; j <= mapOfWires.Extent(); j++)
469 {
471
472 TopoDS_Shape wire = mapOfWires.FindKey(j);
473
474 BRepTools_WireExplorer exp;
475
476 exp.Init(TopoDS::Wire(wire));
477
478 while (exp.More())
479 {
480 TopoDS_Shape edge = exp.Current();
481
482 if (m_mapOfEdges.Contains(edge))
483 {
484 int e = m_mapOfEdges.FindIndex(edge);
485 edgeloop->edges.push_back(m_curves[e]);
486 edgeloop->edgeo.push_back(exp.Orientation() == TopAbs_FORWARD
489 }
490 exp.Next();
491 }
492 edgeloops.push_back(edgeloop);
493 }
494
495 int tote = 0;
496 for (int k = 0; k < edgeloops.size(); k++)
497 {
498 tote += edgeloops[k]->edges.size();
499 }
500
501 // A face bounded by one curve is one whose boundary closes on itself
502 // without a vertex to break it -- a full circle or a complete cone. The
503 // face mesher needs a boundary it can walk from a start to an end.
504 if (tote == 1)
505 {
506 m_log(FATAL) << "CAD surface " << i
507 << " is bounded by a single "
508 "closed curve, which the surface mesher cannot work "
509 "from. Split that curve in the CAD package so the "
510 "surface has a boundary with ends."
511 << endl;
512 }
513
514 CADSurf::OrientateEdges(newSurf, edgeloops);
515 newSurf->SetEdges(edgeloops);
516
517 // now the loops are orientated, tell the curves how they are
518 for (int k = 0; k < edgeloops.size(); k++)
519 {
520 for (int j = 0; j < edgeloops[k]->edges.size(); j++)
521 {
522 edgeloops[k]->edges[j]->SetAdjSurf(
523 make_pair(newSurf, edgeloops[k]->edgeo[j]));
524 }
525 }
526
527 m_surfs[i] = newSurf;
528}
529
530std::array<NekDouble, 6> CADSystemOCE::GetBoundingBox()
531{
532 // lowest(), not min(): for a floating point type min() is the smallest
533 // positive normal value, so a geometry lying entirely on the negative
534 // side of an axis never raised the corresponding maximum above it and
535 // came out with a bounding box that did not contain it.
536 std::array<NekDouble, 6> bound;
537 bound[0] = numeric_limits<NekDouble>::max(); // xmin
538 bound[1] = numeric_limits<NekDouble>::lowest(); // xmax
539 bound[2] = numeric_limits<NekDouble>::max(); // ymin
540 bound[3] = numeric_limits<NekDouble>::lowest(); // ymax
541 bound[4] = numeric_limits<NekDouble>::max(); // zmin
542 bound[5] = numeric_limits<NekDouble>::lowest(); // zmax
543
544 for (int i = 1; i <= m_curves.size(); i++)
545 {
547 auto ends = c->GetMinMax();
548
549 bound[0] = min(bound[0], min(ends[0], ends[3]));
550 bound[1] = max(bound[1], max(ends[0], ends[3]));
551
552 bound[2] = min(bound[2], min(ends[1], ends[4]));
553 bound[3] = max(bound[3], max(ends[1], ends[4]));
554
555 bound[4] = min(bound[4], min(ends[2], ends[5]));
556 bound[5] = max(bound[5], max(ends[2], ends[5]));
557 }
558
559 return bound;
560}
561
562TopoDS_Shape CADSystemOCE::BuildNACA(string naca)
563{
564 if (naca.length() != 4)
565 {
566 m_log(FATAL) << "a NACA profile is named by four digits; '" << naca
567 << "' has " << naca.length() << "." << endl;
568 }
569 vector<NekDouble> data;
570 ParseUtils::GenerateVector(m_config["UseNACA"], data);
571 if (data.size() != 5)
572 {
573 m_log(FATAL) << "UseNACA needs five numbers -- the domain's xmin, "
574 "ymin, xmax and ymax, then the angle of attack in "
575 "degrees -- and was given "
576 << data.size() << "." << endl;
577 }
578
579 int n = std::stoi(naca);
580 NekDouble T = (n % 100) / 100.0;
581 n /= 100;
582 NekDouble P = (n % 10) / 10.0;
583 n /= 10;
584 NekDouble M = (n % 10) / 100.0;
585
586 int np = 25;
587
589 NekDouble dtheta = M_PI / (np - 1);
590 for (int i = 0; i < np; i++)
591 {
592 xc[i] = (1.0 - cos(i * dtheta)) / 2.0;
593 }
594
595 Array<OneD, NekDouble> yc(np), dyc(np);
596 for (int i = 0; i < np; i++)
597 {
598 if (xc[i] < P)
599 {
600 yc[i] = M / P / P * (2.0 * P * xc[i] - xc[i] * xc[i]);
601 dyc[i] = 2.0 * M / P / P * (P - xc[i]);
602 }
603 else
604 {
605 yc[i] = M / (1.0 - P) / (1.0 - P) *
606 (1.0 - 2.0 * P + 2.0 * P * xc[i] - xc[i] * xc[i]);
607 dyc[i] = 2.0 * M / (1.0 - P) / (1.0 - P) * (P - xc[i]);
608 }
609 }
610
612 for (int i = 0; i < np; i++)
613 {
614 yt[i] = T / 0.2 *
615 (0.2969 * sqrt(xc[i]) - 0.1260 * xc[i] -
616 0.3516 * xc[i] * xc[i] + 0.2843 * xc[i] * xc[i] * xc[i] -
617 0.1015 * xc[i] * xc[i] * xc[i] * xc[i]);
618 }
619
620 Array<OneD, NekDouble> x(2 * np - 1), y(2 * np - 1);
621 int l = 0;
622 for (int i = np - 1; i >= 0; i--, l++)
623 {
624 NekDouble theta = atan(dyc[i]);
625
626 x[l] = xc[i] - yt[i] * sin(theta);
627 y[l] = yc[i] + yt[i] * cos(theta);
628 }
629 for (int i = 1; i < np; i++)
630 {
631 NekDouble theta = atan(dyc[i]);
632
633 x[i + np - 1] = xc[i] + yt[i] * sin(theta);
634 y[i + np - 1] = yc[i] - yt[i] * cos(theta);
635 }
636
637 TColgp_Array1OfPnt pointArray(0, 2 * np - 2);
638
639 for (int i = 0; i < 2 * np - 1; i++)
640 {
641 pointArray.SetValue(i, CADUnits::PntToCAD({x[i], y[i], 0.0}));
642 }
643
644 GeomAPI_PointsToBSpline spline(pointArray);
645 Handle(Geom_BSplineCurve) curve = spline.Curve();
646
647 BRepBuilderAPI_MakeEdge areoEdgeBuilder(curve);
648 TopoDS_Edge aeroEdge = areoEdgeBuilder.Edge();
649 BRepBuilderAPI_MakeEdge aeroTEBuilder(
650 CADUnits::PntToCAD({x[0], y[0], 0.0}),
651 CADUnits::PntToCAD({x[2 * np - 2], y[2 * np - 2], 0.0}));
652 TopoDS_Edge TeEdge = aeroTEBuilder.Edge();
653
654 BRepBuilderAPI_MakeWire aeroWireBuilder(aeroEdge, TeEdge);
655 TopoDS_Wire aeroWire = aeroWireBuilder.Wire();
656
657 gp_Trsf transform;
658 gp_Ax1 rotAx(CADUnits::PntToCAD({0.5, 0.0, 0.0}),
659 gp_Dir(gp_Vec(0.0, 0.0, -1.0)));
660 transform.SetRotation(rotAx, data[4] / 180.0 * M_PI);
661 TopLoc_Location mv(transform);
662 aeroWire.Move(mv);
663
664 BRepBuilderAPI_MakeEdge domInlBuilder(
665 CADUnits::PntToCAD({data[0], data[1], 0.0}),
666 CADUnits::PntToCAD({data[0], data[3], 0.0}));
667 TopoDS_Edge inlEdge = domInlBuilder.Edge();
668
669 BRepBuilderAPI_MakeEdge domTopBuilder(
670 CADUnits::PntToCAD({data[0], data[3], 0.0}),
671 CADUnits::PntToCAD({data[2], data[3], 0.0}));
672 TopoDS_Edge topEdge = domTopBuilder.Edge();
673
674 BRepBuilderAPI_MakeEdge domOutBuilder(
675 CADUnits::PntToCAD({data[2], data[3], 0.0}),
676 CADUnits::PntToCAD({data[2], data[1], 0.0}));
677 TopoDS_Edge outEdge = domOutBuilder.Edge();
678
679 BRepBuilderAPI_MakeEdge domBotBuilder(
680 CADUnits::PntToCAD({data[2], data[1], 0.0}),
681 CADUnits::PntToCAD({data[0], data[1], 0.0}));
682 TopoDS_Edge botEdge = domBotBuilder.Edge();
683
684 BRepBuilderAPI_MakeWire domWireBuilder(inlEdge, topEdge, outEdge, botEdge);
685 TopoDS_Wire domWire = domWireBuilder.Wire();
686
687 BRepBuilderAPI_MakeFace face(domWire, true);
688 face.Add(aeroWire);
689
690 ShapeFix_Face sf(face.Face());
691 sf.FixOrientation();
692
693 return sf.Face();
694}
695
696/**
697 * @brief Helper function for Gmsh file construction.
698 */
699template <typename T>
700inline bool ContainsIDs(std::string name, unsigned int id, std::string contName,
701 std::vector<int> &facetids,
702 std::map<unsigned int, T> &toSearch)
703{
704 bool valid = true;
705 for (auto &fid : facetids)
706 {
707 if (toSearch.find(fid) == toSearch.end())
708 {
709 NEKERROR(ErrorUtil::ewarning, name + " ID " + std::to_string(id) +
710 " refers to "
711 "unknown " +
712 contName + " ID " +
713 std::to_string(fid));
714 }
715 }
716
717 return valid;
718}
719
720/**
721 * @brief Helper function for Gmsh file construction.
722 */
723template <typename T>
724inline void CheckWarning(std::string name, unsigned int id,
725 std::map<unsigned int, T> &toSearch)
726{
727 if (toSearch.find(id) != toSearch.end())
728 {
729 NEKERROR(ErrorUtil::ewarning, "Duplicate .geo " + name + " " +
730 std::to_string(id) +
731 " found, will be overwritten.");
732 }
733}
734
735/**
736 * @brief Create a OpenCASCADE object from a Gmsh file @p geo.
737 *
738 * This routine implements a reader for simple Gmsh .geo files. Currently, it
739 * supports:
740 *
741 * - 0D: points;
742 * - 1D: lines, splines, bsplines, circles, ellipses and line loops;
743 * - 2D: surfaces and ruled surfaces;
744 * - 3D: volumes
745 *
746 * Most other information, including physical lines, surfaces and volumes is all
747 * ignored at present.
748 *
749 * @param geo Name of the .geo file to read.
750 * @return An OpenCASCADE TopoDS_Shape that defines the geometry.
751 */
752TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
753{
754 using GeoAst::Geom;
755
756 ifstream f(geo.c_str());
757 const std::string str((std::istreambuf_iterator<char>(f)),
758 std::istreambuf_iterator<char>());
759
760 // Construct a parser for the geo file. Ensure that we use the correct
761 // skipper so that comments are ignored.
765 GeoAst::GeoFile geoFile;
766
767 // Run parser.
768 std::string::const_iterator iter = str.begin();
769 std::string::const_iterator end = str.end();
770 bool r = qi::phrase_parse(iter, end, geoParser, skip, geoFile);
771
772 // If parsing failed, output an error.
773 if (!r)
774 {
775 std::string::const_iterator some = iter + 30;
776 std::string context(iter, (some > end) ? end : some);
777
778 m_log(FATAL) << "Parsing of geo file failed, "
779 << "stopped at: \": " << context << "...\"" << endl;
780 }
781
782 // Build points.
783 map<unsigned int, gp_Pnt> cPoints;
784 for (auto &point : geoFile.points)
785 {
786 CheckWarning("point", point.id, cPoints);
787 cPoints[point.id] = CADUnits::PntToCAD({point.x, point.y, point.z});
788 }
789
790 //
791 // Build edges.
792 //
793 map<unsigned int, TopoDS_Edge> cEdges;
794 map<unsigned int, std::string> cEdgeTypes;
795 map<unsigned int, Geom> edgeMap;
796
797 // Get straight lines.
798 for (auto &line : geoFile.lines)
799 {
800 if (line.ids.size() != 2)
801 {
803 "Line " + std::to_string(line.id) +
804 " contains more than two points, ignoring.");
805 continue;
806 }
807
808 CheckWarning("line", line.id, cEdges);
809 if (!ContainsIDs("Line", line.id, "point", line.ids, cPoints))
810 {
811 continue;
812 }
813
814 BRepBuilderAPI_MakeEdge em(cPoints[line.ids[0]], cPoints[line.ids[1]]);
815 cEdges[line.id] = em.Edge();
816 edgeMap[line.id] = line;
817 cEdgeTypes[line.id] = "line";
818 }
819
820 // Get splines.
821 for (auto &spline : geoFile.splines)
822 {
823 if (spline.ids.size() < 2)
824 {
826 "Spline " + std::to_string(spline.id) +
827 " does not contain enough points, ignoring.");
828 continue;
829 }
830
831 CheckWarning("spline", spline.id, cEdges);
832 if (!ContainsIDs("Spline", spline.id, "point", spline.ids, cPoints))
833 {
834 continue;
835 }
836
837 TColgp_Array1OfPnt pointArray(0, spline.ids.size() - 1);
838
839 for (int i = 0; i < spline.ids.size(); i++)
840 {
841 pointArray.SetValue(i, cPoints[spline.ids[i]]);
842 }
843 GeomAPI_PointsToBSpline oceSpline(pointArray);
844 Handle(Geom_BSplineCurve) curve = oceSpline.Curve();
845
846 BRepBuilderAPI_MakeEdge em(curve);
847 cEdges[spline.id] = em.Edge();
848 edgeMap[spline.id] = spline;
849 cEdgeTypes[spline.id] = "spline";
850 }
851
852 // Get B-Splines.
853 for (auto &bspline : geoFile.bsplines)
854 {
855 if (bspline.ids.size() < 2)
856 {
858 "BSpline " + std::to_string(bspline.id) +
859 " does not "
860 "contain enough points, ignoring.");
861 continue;
862 }
863
864 CheckWarning("bspline", bspline.id, cEdges);
865 if (!ContainsIDs("BSpline", bspline.id, "point", bspline.ids, cPoints))
866 {
867 continue;
868 }
869
870 TColgp_Array1OfPnt pointArray(0, bspline.ids.size() - 1);
871
872 for (int i = 0; i < bspline.ids.size(); i++)
873 {
874 pointArray.SetValue(i, cPoints[bspline.ids[i]]);
875 }
876 Handle(Geom_BezierCurve) curve = new Geom_BezierCurve(pointArray);
877
878 BRepBuilderAPI_MakeEdge em(curve);
879 cEdges[bspline.id] = em.Edge();
880 edgeMap[bspline.id] = bspline;
881 cEdgeTypes[bspline.id] = "bspline";
882 }
883
884 // Get circles.
885 for (auto &circle : geoFile.circles)
886 {
887 if (circle.ids.size() != 3)
888 {
890 "Circle " + std::to_string(circle.id) +
891 " should contain only three points.");
892 continue;
893 }
894
895 CheckWarning("circle", circle.id, cEdges);
896 if (!ContainsIDs("Circle", circle.id, "point", circle.ids, cPoints))
897 {
898 continue;
899 }
900
901 gp_Pnt start = cPoints[circle.ids[0]];
902 gp_Pnt centre = cPoints[circle.ids[1]];
903 gp_Pnt end = cPoints[circle.ids[2]];
904
905 Standard_Real radius = start.Distance(centre);
906 gce_MakeCirc mkArc(centre, gce_MakePln(start, centre, end).Value(),
907 radius);
908
909 const gp_Circ &circ = mkArc.Value();
910 Handle(Geom_Circle) c = new Geom_Circle(circ);
911
912 Standard_Real alpha1 = ElCLib::Parameter(circ, start);
913 Standard_Real alpha2 = ElCLib::Parameter(circ, end);
914 if ((alpha1 > alpha2) ^ (fabs(alpha2 - alpha1) > M_PI))
915 {
916 std::swap(alpha1, alpha2);
917 }
918
919 Handle(Geom_TrimmedCurve) tc =
920 new Geom_TrimmedCurve(c, alpha1, alpha2, false);
921
922 BRepBuilderAPI_MakeEdge em(tc);
923 em.Build();
924 cEdges[circle.id] = em.Edge();
925 edgeMap[circle.id] = circle;
926 cEdgeTypes[circle.id] = "circle";
927 }
928
929 // Get ellipses.
930 for (auto &ellipse : geoFile.ellipses)
931 {
932 if (ellipse.ids.size() != 4)
933 {
934 NEKERROR(ErrorUtil::ewarning, "Ellipse " +
935 std::to_string(ellipse.id) +
936 " should contain"
937 " only four points.");
938 continue;
939 }
940
941 CheckWarning("ellipse", ellipse.id, cEdges);
942 if (!ContainsIDs("Ellipse", ellipse.id, "point", ellipse.ids, cPoints))
943 {
944 continue;
945 }
946
947 gp_Pnt start = cPoints[ellipse.ids[0]];
948 gp_Pnt centre = cPoints[ellipse.ids[1]];
949 // data[2] useless??
950 gp_Pnt end = cPoints[ellipse.ids[3]];
951
952 NekDouble major = start.Distance(centre);
953
954 gp_Vec v1(centre, start);
955 gp_Vec v2(centre, end);
956
957 gp_Vec vx(1.0, 0.0, 0.0);
958 NekDouble angle = v1.Angle(vx);
959
960 // Check for negative rotation
961 if (v1.Y() < 0)
962 {
963 angle *= -1;
964 }
965
966 v2.Rotate(gp_Ax1(), angle);
967 NekDouble minor =
968 fabs(v2.Y() / sqrt(1.0 - v2.X() * v2.X() / (major * major)));
969
970 gp_Elips e;
971 e.SetLocation(centre);
972 e.SetMajorRadius(major);
973 e.SetMinorRadius(minor);
974 e.Rotate(e.Axis(), angle);
975 Handle(Geom_Ellipse) ge = new Geom_Ellipse(e);
976
977 ShapeAnalysis_Curve sac;
978 NekDouble p1, p2;
979 sac.Project(ge, start, 1e-8, start, p1);
980 sac.Project(ge, end, 1e-8, end, p2);
981
982 // Make sure the arc is always of length less than pi
983 if (fabs(p2 - p1) > M_PI)
984 {
985 std::swap(p1, p2);
986 }
987
988 Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(ge, p1, p2, true);
989
990 BRepBuilderAPI_MakeEdge em(tc);
991 em.Build();
992 cEdges[ellipse.id] = em.Edge();
993 edgeMap[ellipse.id] = ellipse;
994 cEdgeTypes[ellipse.id] = "ellipse";
995 }
996
997 //
998 // Build wires.
999 //
1000 map<unsigned int, TopoDS_Wire> cWires;
1001 map<unsigned int, Geom> loopMap;
1002 for (auto &loop : geoFile.lineLoops)
1003 {
1004 // Make IDs all positive since we don't care about the orientations and
1005 // will get OCC to construct this for us.
1006 for (auto &id : loop.ids)
1007 {
1008 id = std::abs(id);
1009 }
1010
1011 CheckWarning("line loop", loop.id, cWires);
1012 if (!ContainsIDs("Line Loop", loop.id, "edge", loop.ids, cEdges))
1013 {
1014 continue;
1015 }
1016
1017 BRepBuilderAPI_MakeWire wm;
1018 for (auto &edgeId : loop.ids)
1019 {
1020 wm.Add(cEdges[edgeId]);
1021 }
1022 cWires[loop.id] = wm.Wire();
1023 loopMap[loop.id] = loop;
1024 }
1025
1026 //
1027 // Build faces.
1028 //
1029 map<unsigned int, TopoDS_Face> cFaces;
1030 map<unsigned int, Geom> faceMap;
1031
1032 // Construct plane surfaces.
1033 for (auto &planeSurf : geoFile.planeSurfs)
1034 {
1035 BRepBuilderAPI_MakeFace face(cWires[planeSurf.ids[0]], true);
1036 for (int i = 1; i < planeSurf.ids.size(); i++)
1037 {
1038 face.Add(cWires[planeSurf.ids[i]]);
1039 }
1040
1041 ASSERTL0(face.Error() == BRepBuilderAPI_FaceDone, "build geo failed");
1042
1043 ShapeFix_Face sf(face.Face());
1044 sf.FixOrientation();
1045
1046 cFaces[planeSurf.id] = sf.Face();
1047 faceMap[planeSurf.id] = planeSurf;
1048 }
1049
1050 // At this point, 2D simulations should be good because we have (at most)
1051 // one surface.
1052 if (m_2d)
1053 {
1054 ASSERTL0(cFaces.size() == 1,
1055 "2D simulations should define at most one plane surface in "
1056 "the .geo file.");
1057
1058 return cFaces.begin()->second;
1059 }
1060
1061 // Build ruled surfaces. This is probably amongst the most complex parts of
1062 // this code, since we need to construct a filling for the wire which may be
1063 // based off a couple of different approaches:
1064 //
1065 // 1) If Gmsh is using the OpenCASCADE kernel, then we should always use the
1066 // BRepFill_Filling class, which uses some kind of magic to blend
1067 // curvature of the edges to construct a filling.
1068 // 2) If Gmsh is using its built-in kernel, then ruled surfaces are must
1069 // have either three of four curves, and then the filling is defined
1070 // using a transfinite interpolation.
1071 // 3) ...unless those three or four curves are circle arcs, in which case we
1072 // test to see if we're on a sphere first.
1073 //
1074 // Most of this is straightforward, asides from (2) which requires a custom
1075 // OpenCASCADE class to handle the transfinite interpolation.
1076 for (auto &surf : geoFile.ruledSurfs)
1077 {
1078 CheckWarning("surface", surf.id, cFaces);
1079 if (!ContainsIDs("Ruled Surface", surf.id, "line loop", surf.ids,
1080 cWires))
1081 {
1082 continue;
1083 }
1084 if (surf.ids.size() != 1)
1085 {
1087 "Surface " + std::to_string(surf.id) +
1088 " should only "
1089 "contain a single line loop, ignoring.");
1090 continue;
1091 }
1092
1093 Geom &loop = loopMap[surf.ids[0]];
1094
1095 // Get edges.
1096 const int nEdges = loop.ids.size();
1097
1098 // Special case (3) above: 3 or 4 circular edges should define a
1099 // spherical surface. This is what the built-in geo kernel supports, but
1100 // OpenCASCADE engine gives a regular filling.
1101 bool isSphere = true;
1102 if (nEdges == 3 || nEdges == 4)
1103 {
1104 for (int i = 0; i < nEdges; ++i)
1105 {
1106 if (cEdgeTypes[loop.ids[i]] != "circle")
1107 {
1108 isSphere = false;
1109 break;
1110 }
1111 }
1112
1113 // Now check circle origins are defined at the same point.
1114 if (isSphere)
1115 {
1116 int originId = edgeMap[loop.ids[0]].ids[1];
1117 for (int i = 1; i < nEdges; ++i)
1118 {
1119 if (originId != edgeMap[loop.ids[i]].ids[1])
1120 {
1121 isSphere = false;
1122 break;
1123 }
1124 }
1125 }
1126 }
1127
1128 // If we're a sphere, all is good and construct a spherical surface.
1129 if (isSphere)
1130 {
1131 gp_Pnt origin = cPoints[edgeMap[loop.ids[0]].ids[1]];
1132 gp_Sphere sph;
1133 sph.SetLocation(origin);
1134 sph.SetRadius(
1135 origin.Distance(cPoints[edgeMap[loop.ids[0]].ids[0]]));
1136 BRepBuilderAPI_MakeFace makeFace(sph, cWires[surf.ids[0]]);
1137
1138 ShapeFix_Face sf(makeFace.Face());
1139 sf.FixOrientation();
1140 cFaces[surf.id] = sf.Face();
1141 continue;
1142 }
1143
1144 // Attempt to emulate the built-in CAD kernel, which performs a
1145 // transfinite interpolation.
1146 bool builtIn = true;
1147 if (nEdges == 4 && builtIn)
1148 {
1149 // Attempt to reconstruct shape from standard Gmsh kernel by
1150 // creating a custom transfinite surface. So far only 4 edges are
1151 // supported. This requires a few things:
1152 //
1153 // - edges are handles to our OCC curves
1154 // - clims define the start and end parameter for each curve
1155 // - vertIds define the vertex IDs for the patch
1156 // - fwd[i] is true if the CCW-orientated edge i on the patch is the
1157 // same direction of curve[i].
1158 // - verts[i] are the coordinate points of the vertex given by
1159 // vertIds[i].
1160 std::vector<Handle(Geom_Curve)> edges(nEdges);
1161 std::vector<pair<double, double>> clims(nEdges);
1162 std::vector<int> vertIds(nEdges);
1163 std::vector<bool> fwd(nEdges);
1164 std::vector<gp_Pnt> verts(nEdges);
1165
1166 for (int i = 0; i < nEdges; ++i)
1167 {
1168 auto edge = edgeMap[loop.ids[i]];
1169 auto nextEdge = edgeMap[loop.ids[(i + 1) % nEdges]];
1170
1171 std::pair<double, double> clim;
1172 edges[i] = BRep_Tool::Curve(cEdges[loop.ids[i]], clim.first,
1173 clim.second);
1174 clims[i] = clim;
1175
1176 // Determine orientation.
1177 fwd[i] = true;
1178 if ((edge.ids[0] == nextEdge.ids[0]) ||
1179 (edge.ids[0] == nextEdge.ids.back()))
1180 {
1181 fwd[i] = false;
1182 }
1183 else if ((edge.ids.back() != nextEdge.ids[0]) &&
1184 (edge.ids.back() != nextEdge.ids.back()))
1185 {
1186 ASSERTL0(false, "connectivity issue");
1187 }
1188
1189 verts[i] =
1190 fwd[i] ? cPoints[edge.ids[0]] : cPoints[edge.ids.back()];
1191 }
1192
1193 // Create new transfinite surface.
1194 Handle(Geom_TransfiniteSurface) tf =
1195 new Geom_TransfiniteSurface(edges, fwd, clims, verts);
1196
1197 BRepBuilderAPI_MakeFace mkFace(tf, cWires[surf.ids[0]]);
1198 TopoDS_Face face = mkFace.Face();
1199
1200 // This is an attempt to figure out the pcurves for each face.For
1201 // some reason, it isn't working and seems to get nuked by the
1202 // sewing operation above. Not quite sure why, but it means some
1203 // OpenCASCADE operations won't work properly. For now the most
1204 // serious implication is that we need the user to supply a list of
1205 // void points so that holes in 3D geometries are reproduced.
1206 if (nEdges == 4 && false)
1207 {
1208 BRep_Builder B;
1209 TopLoc_Location L;
1210 BRep_Tool::Surface(face, L);
1211 Handle(Geom2d_Line) e0, e1, e2, e3;
1212 e0 = new Geom2d_Line(gp_Pnt2d(0, 0), gp_Dir2d(1, 0));
1213 e1 = new Geom2d_Line(gp_Pnt2d(1, 0), gp_Dir2d(0, 1));
1214 e2 = new Geom2d_Line(gp_Pnt2d(0, 1), gp_Dir2d(1, 0));
1215 e3 = new Geom2d_Line(gp_Pnt2d(0, 0), gp_Dir2d(0, 1));
1216
1217 B.UpdateEdge(cEdges[loop.ids[0]], e0, tf, L, 0.);
1218 B.UpdateEdge(cEdges[loop.ids[1]], e1, tf, L, 0.);
1219 B.UpdateEdge(cEdges[loop.ids[2]], e2, tf, L, 0.);
1220 B.UpdateEdge(cEdges[loop.ids[3]], e3, tf, L, 0.);
1221 B.Range(cEdges[loop.ids[0]], face, 0, 1);
1222 B.Range(cEdges[loop.ids[1]], face, 0, 1);
1223 B.Range(cEdges[loop.ids[2]], face, 0, 1);
1224 B.Range(cEdges[loop.ids[3]], face, 0, 1);
1225 }
1226
1227 cFaces[surf.id] = face;
1228 continue;
1229 }
1230
1231 // Otherwise we will just go ahead and construct a filling from
1232 // OpenCASCADE.
1233 BRepOffsetAPI_MakeFilling fill;
1234 TopExp_Explorer ex;
1235
1236 // Add all edges from our line loop.
1237 for (ex.Init(cWires[surf.ids[0]], TopAbs_EDGE); ex.More(); ex.Next())
1238 {
1239 const TopoDS_Edge &shape = TopoDS::Edge(ex.Current());
1240 fill.Add(shape, GeomAbs_C0);
1241 }
1242
1243 fill.Build();
1244 cFaces[surf.id] = TopoDS::Face(fill.Shape());
1245 }
1246
1247 //
1248 // Construct shells.
1249 //
1250 map<unsigned int, TopoDS_Shell> cShells;
1251 for (auto &sloop : geoFile.surfLoops)
1252 {
1253 CheckWarning("surface loop", sloop.id, cShells);
1254 if (!ContainsIDs("Surface Loop", sloop.id, "surface", sloop.ids,
1255 cFaces))
1256 {
1257 continue;
1258 }
1259
1260 BRep_Builder builder;
1261 BRepPrim_Builder b(builder);
1262 TopoDS_Shell shell;
1263 b.MakeShell(shell);
1264 for (auto &id : sloop.ids)
1265 {
1266 b.AddShellFace(shell, cFaces[id]);
1267 }
1268 cShells[sloop.id] = shell;
1269 }
1270
1271 map<unsigned int, TopoDS_Shape> cVolumes;
1272 for (auto &vol : geoFile.volumes)
1273 {
1274 for (auto &id : vol.ids)
1275 {
1276 id = std::abs(id);
1277 }
1278
1279 CheckWarning("volume", vol.id, cVolumes);
1280 if (!ContainsIDs("Volume", vol.id, "surface loop", vol.ids, cShells))
1281 {
1282 continue;
1283 }
1284
1285 BRepBuilderAPI_MakeSolid solidMaker;
1286
1287 for (int i = 0; i < vol.ids.size(); ++i)
1288 {
1289 solidMaker.Add(cShells[vol.ids[i]]);
1290 }
1291
1292 cVolumes[vol.id] = solidMaker.Solid();
1293 }
1294
1295 ASSERTL0(cVolumes.size() == 1,
1296 "3D .geo file should define exactly one volume.");
1297
1298 return cVolumes.begin()->second;
1299}
1300
1301} // namespace Nektar::SpatialDomains
NekDouble L
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
int64_t id
A class that defines a transfinite surface defined by four curves.
Interpreter class for the evaluation of mathematical expressions.
Definition Interpreter.h:76
tBasePtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
static void OrientateEdges(CADSurfSharedPtr surf, std::vector< EdgeLoopSharedPtr > &ein)
Static function which orientates the edge loop on a surface.
Definition CADSurf.cpp:56
CADCurveSharedPtr GetCurve(int i)
Gets a curve from the map.
Definition CADSystem.h:172
std::map< int, CADSurfSharedPtr > m_surfs
Map of surfaces.
Definition CADSystem.h:323
std::map< std::string, std::string > m_config
Configuration options which might be used per-engine, serialised in strings.
Definition CADSystem.h:330
Logger m_log
Logger object.
Definition CADSystem.h:334
std::map< int, CADVertSharedPtr > m_verts
Map of vertices.
Definition CADSystem.h:325
std::map< int, CADCurveSharedPtr > m_curves
Map of curves.
Definition CADSystem.h:321
void Report()
Reports basic properties to screen.
Definition CADSystem.h:339
void CheckClosed()
Fail unless every curve is bounded by exactly two surfaces.
Definition CADSystem.h:265
std::string m_name
Name of CAD file.
Definition CADSystem.h:317
TopTools_IndexedMapOfShape m_mapOfVerts
TopoDS_Shape m_shape
OCC master object.
TopoDS_Shape BuildNACA(std::string naca)
void AddCurve(int i, TopoDS_Shape in)
Function to add curve to CADSystem::m_curves.
bool LoadCAD() override
Initialises CAD and makes surface, curve and vertex maps.
TopTools_IndexedMapOfShape m_mapOfEdges
static CADSystemSharedPtr create(std::string name)
void AddVert(int i, TopoDS_Shape in)
Function to add curve to CADSystem::m_verts.
std::array< NekDouble, 6 > GetBoundingBox() override
Returns bounding box of the domain.
TopTools_IndexedMapOfShape m_mapOfFaces
void AddSurf(int i, TopoDS_Shape in)
Function to add surface to CADSystem::m_surfs.
TopoDS_Shape BuildGeo(std::string geo)
Create a OpenCASCADE object from a Gmsh file geo.
gp_Pnt PntToCAD(const std::array< NekDouble, 3 > &p)
A point on its way into OpenCASCADE.
Definition CADUnits.hpp:95
NekDouble FromCAD(NekDouble length)
A length on its way out of OpenCASCADE.
Definition CADUnits.hpp:83
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition CADCurve.h:247
gp_Pnt FindInteriorPoint(TopoDS_Shell &shell)
For a given shell shell, attempt to find a point that is strictly on the interior of the shape.
std::shared_ptr< CADVert > CADVertSharedPtr
Definition CADCurve.h:49
void filterModShape(TopTools_DataMapOfShapeShape &modShape, TopoDS_Shape &S)
void CheckWarning(std::string name, unsigned int id, std::map< unsigned int, T > &toSearch)
Helper function for Gmsh file construction.
EngineFactory & GetEngineFactory()
Definition CADSystem.cpp:42
CADSurfFactory & GetCADSurfFactory()
Definition CADSystem.cpp:60
bool ContainsIDs(std::string name, unsigned int id, std::string contName, std::vector< int > &facetids, std::map< unsigned int, T > &toSearch)
Helper function for Gmsh file construction.
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition CADCurve.h:51
CADCurveFactory & GetCADCurveFactory()
Definition CADSystem.cpp:54
CADVertFactory & GetCADVertFactory()
Definition CADSystem.cpp:48
std::shared_ptr< EdgeLoop > EdgeLoopSharedPtr
Definition CADSurf.h:63
@ FATAL
Fatal errors that trigger exceptions.
Definition Log.hpp:65
@ VERBOSE
Verbose output.
Definition Log.hpp:68
STL namespace.
scalarT< T > max(scalarT< T > lhs, scalarT< T > rhs)
Definition scalar.hpp:304
scalarT< T > min(scalarT< T > lhs, scalarT< T > rhs)
Definition scalar.hpp:299
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289
A skipper that boost::qi can use to ignore all comments in the .geo file. We support the use of singl...
struct which descibes a collection of cad edges which are a loop on the cad surface
Definition CADSurf.h:56
Lightweight wrapper for a .geo file structure.
std::vector< Geom > lineLoops
Vector of line loops.
std::vector< Geom > ellipses
Vector of ellipses.
std::vector< Geom > circles
Vector of circles.
std::vector< Geom > surfLoops
Vector of surface loops.
std::vector< Geom > volumes
Vector of volumes.
std::vector< Geom > ruledSurfs
Vector of ruled surfaces (or 'surfaces' in the newer .geo formats).
std::vector< Point > points
Vector of points.
std::vector< Geom > bsplines
Vector of bsplines.
std::vector< Geom > splines
Vector of splines.
std::vector< Geom > planeSurfs
Vector of plane surfaces.
std::vector< Geom > lines
Vector of lines.
Wrapper for all other Geometry types, which are defined using a list of integer IDs....
A lightweight parser for the .geo format.