1 // Gmsh - Copyright (C) 1997-2021 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef GMODELIO_OCC_H
7 #define GMODELIO_OCC_H
8 
9 #include <vector>
10 #include <map>
11 #include "GmshConfig.h"
12 #include "GmshMessage.h"
13 #include "GModel.h"
14 
15 class ExtrudeParams;
16 
17 #if defined(HAVE_OCC)
18 
19 #include <TopoDS_Shape.hxx>
20 #include <TopoDS_Vertex.hxx>
21 #include <TopoDS_Edge.hxx>
22 #include <TopoDS_Wire.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS_Shell.hxx>
25 #include <TopoDS_Solid.hxx>
26 #include <TopoDS_Compound.hxx>
27 #include <TopTools_IndexedMapOfShape.hxx>
28 #include <TopTools_DataMapOfShapeInteger.hxx>
29 #include <TopTools_DataMapOfIntegerShape.hxx>
30 
31 class BRepSweep_Prism;
32 class BRepSweep_Revol;
33 class BRepBuilderAPI_Transform;
34 class BRepBuilderAPI_GTransform;
35 class OCCAttributesRTree;
36 
37 class OCC_Internals {
38 public:
39   enum BooleanOperator { Union, Intersection, Difference, Section, Fragments };
40 
41 private:
42   // have the internals changed since the last synchronisation?
43   bool _changed;
44 
45   // maximum tags for each bound entity (shell, wire, vertex, edge, face, solid)
46   int _maxTag[6];
47 
48   // all the (sub)shapes, updated dynamically when shapes need to be imported
49   // into a GModel
50   TopTools_IndexedMapOfShape _vmap, _emap, _wmap, _fmap, _shmap, _somap;
51 
52   // cache mapping TopoDS_Shapes to their corresponding (future) GEntity tags
53   TopTools_DataMapOfShapeInteger _vertexTag, _edgeTag, _faceTag, _solidTag;
54   TopTools_DataMapOfIntegerShape _tagVertex, _tagEdge, _tagFace, _tagSolid;
55 
56   // cache mapping TopoDS_Shapes to tags for internal use during geometry
57   // construction
58   TopTools_DataMapOfShapeInteger _wireTag, _shellTag;
59   TopTools_DataMapOfIntegerShape _tagWire, _tagShell;
60 
61   // cache of <dim,tag> pairs corresponding to entities that will need to be
62   // removed from the model at the next synchronization
63   std::set<std::pair<int, int> > _toRemove;
64 
65   // cache of <dim,tag> pairs corresponding to entities that should not be
66   // unbound during boolean operations
67   std::set<std::pair<int, int> > _toPreserve;
68 
69   // mesh attributes
70   OCCAttributesRTree *_attributes;
71 
72   // get tag of shape, but search for other candidates at the same location if
73   // the actual shape is not found
74   int _getFuzzyTag(int dim, const TopoDS_Shape &s);
75 
76   // iterate on all bound entities and recompute the maximum tag
77   void _recomputeMaxTag(int dim);
78 
79   // bind and unbind OpenCASCADE shapes to tags
80   void _bind(const TopoDS_Vertex &vertex, int tag, bool recursive = false);
81   void _bind(const TopoDS_Edge &edge, int tag, bool recursive = false);
82   void _bind(const TopoDS_Wire &wire, int tag, bool recursive = false);
83   void _bind(const TopoDS_Face &face, int tag, bool recursive = false);
84   void _bind(const TopoDS_Shell &shell, int tag, bool recursive = false);
85   void _bind(const TopoDS_Solid &solid, int tag, bool recursive = false);
86   void _bind(TopoDS_Shape shape, int dim, int tag, bool recursive = false);
87   void _unbind(const TopoDS_Vertex &vertex, int tag, bool recursive = false);
88   void _unbind(const TopoDS_Edge &edge, int tag, bool recursive = false);
89   void _unbind(const TopoDS_Wire &wire, int tag, bool recursive = false);
90   void _unbind(const TopoDS_Face &face, int tag, bool recursive = false);
91   void _unbind(const TopoDS_Shell &shell, int tag, bool recursive = false);
92   void _unbind(const TopoDS_Solid &solid, int tag, bool recursive = false);
93   void _unbind(TopoDS_Shape shape, int dim, int tag, bool recursive = false);
94   void _unbindWithoutChecks(TopoDS_Shape shape);
95   void _unbind();
96 
97   // bind (potentially) mutliple entities in shape and return the tags in
98   // outTags. If tag > 0 and a single entity if found, use that; if
99   // highestDimOnly is true, only bind the entities (and sub-entities, if
100   // recursive is set) of the highest dimension; if returnNewOnly is set, only
101   // return newly bound entities in outDimTags.
102   void _multiBind(const TopoDS_Shape &shape, int tag,
103                   std::vector<std::pair<int, int> > &outDimTags,
104                   bool returnHighestDimOnly, bool recursive = false,
105                   bool returnNewOnly = false);
106 
107   // is the entity of a given dimension and tag bound?
108   bool _isBound(int dim, int tag);
109 
110   // is the entity of a given dimension and shape bound?
111   bool _isBound(int dim, const TopoDS_Shape &shape);
112 
113   // get the entity of a given dimension and tag
114   TopoDS_Shape _find(int dim, int tag);
115 
116   // get the tag of a shape of a given dimension
117   int _find(int dim, const TopoDS_Shape &shape);
118 
119   // get maximum dimension of shapes bound to tags
120   int _getMaxDim();
121 
122   // get (dim,tag) of all shapes (that will be) bound to tags
123   void _getAllDimTags(std::vector<std::pair<int, int> > &dimTags, int dim = 99);
124 
125   // add a shape and all its subshapes to _vmap, _emap, ..., _somap
126   void _addShapeToMaps(const TopoDS_Shape &shape);
127 
128   // apply various healing algorithms to try to fix the shape
129   void _healShape(TopoDS_Shape &myshape, double tolerance, bool fixDegenerated,
130                   bool fixSmallEdges, bool fixSmallFaces, bool sewFaces,
131                   bool makeSolids, double scaling = 0.0);
132 
133   // apply a geometrical transformation
134   bool _transform(const std::vector<std::pair<int, int> > &inDimTags,
135                   BRepBuilderAPI_Transform *tfo,
136                   BRepBuilderAPI_GTransform *gtfo);
137 
138   // add bspline
139   bool _addBSpline(int &tag, const std::vector<int> &pointTags, int mode,
140                    const int degree = -1,
141                    const std::vector<double> &weights = std::vector<double>(),
142                    const std::vector<double> &knots = std::vector<double>(),
143                    const std::vector<int> &multiplicities = std::vector<int>());
144 
145   // apply extrusion-like operations
146   bool _extrudePerDim(int mode, int inDim, const std::vector<int> &inTags,
147                       double x, double y, double z, double dx, double dy,
148                       double dz, double ax, double ay, double az, double angle,
149                       int wireTag,
150                       std::vector<std::pair<int, int> > &outDimTags,
151                       ExtrudeParams *e, const std::string &trihedron);
152   bool _extrude(int mode, const std::vector<std::pair<int, int> > &inDimTags,
153                 double x, double y, double z, double dx, double dy, double dz,
154                 double ax, double ay, double az, double angle, int wireTag,
155                 std::vector<std::pair<int, int> > &outDimTags,
156                 ExtrudeParams *e = nullptr, const std::string &trihedron = "");
157 
158   // apply fillet-like operations
159   bool _fillet(int mode, const std::vector<int> &volumeTags,
160                const std::vector<int> &curveTags,
161                const std::vector<int> &surfaceTags,
162                const std::vector<double> &param,
163                std::vector<std::pair<int, int> > &outDimTags,
164                bool removeVolume);
165 
166   // set extruded mesh attributes
167   void _setExtrudedAttributes(const TopoDS_Compound &c, BRepSweep_Prism *p,
168                               BRepSweep_Revol *r, ExtrudeParams *e, double x,
169                               double y, double z, double dx, double dy,
170                               double dz, double ax, double ay, double az,
171                               double angle);
172   void _copyExtrudedAttributes(TopoDS_Edge edge, GEdge *ge);
173   void _copyExtrudedAttributes(TopoDS_Face face, GFace *gf);
174   void _copyExtrudedAttributes(TopoDS_Solid solid, GRegion *gr);
175 
176   // bounding box
177   bool _getBoundingBox(const TopoDS_Shape &s, double &xmin, double &ymin,
178                        double &zmin, double &xmax, double &ymax, double &zmax);
179 
180   // STL
181   bool _makeSTL(const TopoDS_Shape &s, std::vector<SPoint3> &vertices,
182                 std::vector<SVector3> &normals, std::vector<int> &triangles);
183 
184 public:
185   OCC_Internals();
186   ~OCC_Internals();
187 
188   // have the internals changed since the last synchronisation?
getChanged()189   bool getChanged() const { return _changed; }
190 
191   // reset all maps
192   void reset();
193 
194   // set/get max tag of entity for each dimension (0, 1, 2, 3), as well as
195   // -2 for shells and -1 for wires
196   void setMaxTag(int dim, int val);
197   int getMaxTag(int dim) const;
198 
199   // add shapes (if tag is < 0, a new tag is automatically created and returned)
200   bool addVertex(int &tag, double x, double y, double z,
201                  double meshSize = MAX_LC);
202   bool addLine(int &tag, int startTag, int endTag);
203   bool addLine(int &tag, const std::vector<int> &pointTags);
204   bool addCircleArc(int &tag, int startTag, int centerTag, int endTag);
205   bool addCircle(int &tag, double x, double y, double z, double r,
206                  double angle1, double angle2);
207   bool addEllipseArc(int &tag, int startTag, int centerTag, int majorTag,
208                      int endTag);
209   bool addEllipse(int &tag, double x, double y, double z, double r1, double r2,
210                   double angle1, double angle2);
211   bool addSpline(int &tag, const std::vector<int> &pointTags);
212   bool addBezier(int &tag, const std::vector<int> &pointTags);
213   bool addBSpline(int &tag, const std::vector<int> &pointTags,
214                   const int degree = -1,
215                   const std::vector<double> &weights = std::vector<double>(),
216                   const std::vector<double> &knots = std::vector<double>(),
217                   const std::vector<int> &multiplicities = std::vector<int>());
218   bool addWire(int &tag, const std::vector<int> &curveTags, bool checkClosed);
219   bool addCurveLoop(int &tag, const std::vector<int> &curveTags);
220   bool addRectangle(int &tag, double x, double y, double z, double dx,
221                     double dy, double roundedRadius = 0.);
222   bool addDisk(int &tag, double xc, double yc, double zc, double rx, double ry);
223   bool addPlaneSurface(int &tag, const std::vector<int> &wireTags);
224   bool addSurfaceFilling(
225     int &tag, int wireTag,
226     const std::vector<int> &pointTags = std::vector<int>(),
227     const std::vector<int> &surfaceTags = std::vector<int>(),
228     const std::vector<int> &surfaceContinuity = std::vector<int>(),
229     const int degree = 3, const int numPointsOnCurves = 15,
230     const int numIter = 2, const bool anisotropic = false,
231     const double tol2d = 0.00001, const double tol3d = 0.0001,
232     const double tolAng = 0.01, const double tolCurv = 0.1,
233     const int maxDegree = 8, const int maxSegments = 9);
234   bool addBSplineFilling(int &tag, int wireTag, const std::string &type = "");
235   bool addBezierFilling(int &tag, int wireTag, const std::string &type = "");
236   bool addBSplineSurface(int &tag, const std::vector<int> &pointTags,
237                          const int numPointsU, const int degreeU,
238                          const int degreeV, const std::vector<double> &weights,
239                          const std::vector<double> &knotsU,
240                          const std::vector<double> &knotsV,
241                          const std::vector<int> &multiplicitiesU,
242                          const std::vector<int> &multiplicitiesV,
243                          const std::vector<int> &wireTags = std::vector<int>(),
244                          bool wire3D = true);
245   bool addBezierSurface(int &tag, const std::vector<int> &pointTags,
246                         const int numPointsU,
247                         const std::vector<int> &wireTags = std::vector<int>(),
248                         bool wire3D = true);
249   bool addTrimmedSurface(int &tag, int surfaceTag,
250                          const std::vector<int> &wireTags, bool wire3D);
251   bool addSurfaceLoop(int &tag, const std::vector<int> &surfaceTags,
252                       bool sewing);
253   bool addVolume(int &tag, const std::vector<int> &shellTags);
254   bool addSphere(int &tag, double xc, double yc, double zc, double radius,
255                  double angle1, double angle2, double angle3);
256   bool addBox(int &tag, double x, double y, double z, double dx, double dy,
257               double dz);
258   bool addCylinder(int &tag, double x, double y, double z, double dx, double dy,
259                    double dz, double r, double angle);
260   bool addCone(int &tag, double x, double y, double z, double dx, double dy,
261                double dz, double r1, double r2, double angle);
262   bool addWedge(int &tag, double x, double y, double z, double dx, double dy,
263                 double dz, double ltx);
264   bool addTorus(int &tag, double x, double y, double z, double r1, double r2,
265                 double angle);
266 
267   // thrusections and thick solids (can create multiple entities)
268   bool addThruSections(int tag, const std::vector<int> &wireTags,
269                        bool makeSolid, bool makeRuled,
270                        std::vector<std::pair<int, int> > &outDimTags,
271                        int maxDegree = -1);
272   bool addThickSolid(int tag, int solidTag,
273                      const std::vector<int> &excludeFaceTags, double offset,
274                      std::vector<std::pair<int, int> > &outDimTags);
275 
276   // extrude and revolve
277   bool extrude(const std::vector<std::pair<int, int> > &inDimTags, double dx,
278                double dy, double dz,
279                std::vector<std::pair<int, int> > &outDimTags,
280                ExtrudeParams *e = nullptr);
281   bool revolve(const std::vector<std::pair<int, int> > &inDimTags, double x,
282                double y, double z, double ax, double ay, double az,
283                double angle, std::vector<std::pair<int, int> > &outDimTags,
284                ExtrudeParams *e = nullptr);
285   bool addPipe(const std::vector<std::pair<int, int> > &inDimTags, int wireTag,
286                std::vector<std::pair<int, int> > &outDimTags,
287                const std::string &trihedron = "");
288 
289   // fillet
290   bool fillet(const std::vector<int> &volumeTags,
291               const std::vector<int> &curveTags,
292               const std::vector<double> &radii,
293               std::vector<std::pair<int, int> > &outDimTags, bool removeVolume);
294 
295   // chamfer
296   bool chamfer(const std::vector<int> &volumeTags,
297                const std::vector<int> &curveTags,
298                const std::vector<int> &surfaceTags,
299                const std::vector<double> &distances,
300                std::vector<std::pair<int, int> > &outDimTags,
301                bool removeVolume);
302 
303   // apply boolean operator
304   bool booleanOperator(
305     int tag, BooleanOperator op,
306     const std::vector<std::pair<int, int> > &objectDimTags,
307     const std::vector<std::pair<int, int> > &toolDimTags,
308     std::vector<std::pair<int, int> > &outDimTags,
309     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
310     bool removeObject, bool removeTool);
311   bool
312   booleanUnion(int tag, const std::vector<std::pair<int, int> > &objectDimTags,
313                const std::vector<std::pair<int, int> > &toolDimTags,
314                std::vector<std::pair<int, int> > &outDimTags,
315                std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
316                bool removeObject, bool removeTool);
317   bool booleanIntersection(
318     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
319     const std::vector<std::pair<int, int> > &toolDimTags,
320     std::vector<std::pair<int, int> > &outDimTags,
321     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
322     bool removeObject, bool removeTool);
323   bool booleanDifference(
324     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
325     const std::vector<std::pair<int, int> > &toolDimTags,
326     std::vector<std::pair<int, int> > &outDimTags,
327     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
328     bool removeObject, bool removeTool);
329   bool booleanFragments(
330     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
331     const std::vector<std::pair<int, int> > &toolDimTags,
332     std::vector<std::pair<int, int> > &outDimTags,
333     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
334     bool removeObject, bool removeTool);
335 
336   // coherence (shortcut for booleanFragments)
337   void removeAllDuplicates();
338   bool mergeVertices(const std::vector<int> &tags);
339 
340   // apply transformations
341   bool translate(const std::vector<std::pair<int, int> > &inDimTags, double dx,
342                  double dy, double dz);
343   bool rotate(const std::vector<std::pair<int, int> > &inDimTags, double x,
344               double y, double z, double ax, double ay, double az,
345               double angle);
346   bool dilate(const std::vector<std::pair<int, int> > &inDimTags, double x,
347               double y, double z, double a, double b, double c);
348   bool symmetry(const std::vector<std::pair<int, int> > &inDimTags, double a,
349                 double b, double c, double d);
350   bool affine(const std::vector<std::pair<int, int> > &inDimTags,
351               const std::vector<double> &mat);
352 
353   // copy and remove
354   bool copy(const std::vector<std::pair<int, int> > &inDimTags,
355             std::vector<std::pair<int, int> > &outDimTags);
356   bool remove(int dim, int tag, bool recursive = false);
357   bool remove(const std::vector<std::pair<int, int> > &dimTags,
358               bool recursive = false);
359 
360   // import shapes from file
361   bool importShapes(const std::string &fileName, bool highestDimOnly,
362                     std::vector<std::pair<int, int> > &outDimTags,
363                     const std::string &format = "");
364 
365   // import shapes from TopoDS_Shape
366   bool importShapes(const TopoDS_Shape *shape, bool highestDimOnly,
367                     std::vector<std::pair<int, int> > &outDimTags);
368 
369   // apply various healing algorithms to try to fix the shapes
370   bool healShapes(const std::vector<std::pair<int, int> > &inDimTags,
371                   std::vector<std::pair<int, int> > &outDimTags,
372                   double tolerance, bool fixDegenerated, bool fixSmallEdges,
373                   bool fixSmallFaces, bool sewFaces, bool makeSolids);
374 
375   // set meshing constraints
376   void setMeshSize(int dim, int tag, double size);
377 
378   // synchronize internal CAD data with the given GModel
379   void synchronize(GModel *model);
380 
381   // export all bound shapes to file
382   bool exportShapes(GModel *model, const std::string &fileName,
383                     const std::string &format = "");
384 
385   // queries
386   bool getEntities(std::vector<std::pair<int, int> > &dimTags, int dim);
387   bool getVertex(int tag, double &x, double &y, double &z);
388   bool getBoundingBox(int dim, int tag, double &xmin, double &ymin,
389                       double &zmin, double &xmax, double &ymax, double &zmax);
390   bool getEntitiesInBoundingBox(double xmin, double ymin, double zmin,
391                                 double xmax, double ymax, double zmax,
392                                 std::vector<std::pair<int, int> > &dimTags,
393                                 int dim);
394   bool getMass(int dim, int tag, double &mass);
395   bool getCenterOfMass(int dim, int tag, double &x, double &y, double &z);
396   bool getMatrixOfInertia(int dim, int tag, std::vector<double> &mat);
397   double getDistance(int dim1, int tag1,
398                      int dim2, int tag2,
399                      double &x1, double &y1, double &z1,
400                      double &x2, double &y2, double &z2);
401   GVertex *getVertexForOCCShape(GModel *model, const TopoDS_Vertex &toFind);
402   GEdge *getEdgeForOCCShape(GModel *model, const TopoDS_Edge &toFind);
403   GFace *getFaceForOCCShape(GModel *model, const TopoDS_Face &toFind);
404   GRegion *getRegionForOCCShape(GModel *model, const TopoDS_Solid &toFind);
405 
406   // STL utilities
407   bool makeFaceSTL(const TopoDS_Face &s, std::vector<SPoint2> &vertices_uv,
408                    std::vector<int> &triangles);
409   bool makeFaceSTL(const TopoDS_Face &s, std::vector<SPoint2> &vertices_uv,
410                    std::vector<SPoint3> &vertices,
411                    std::vector<SVector3> &normals, std::vector<int> &triangles);
412   bool makeFaceSTL(const TopoDS_Face &s, std::vector<SPoint3> &vertices,
413                    std::vector<SVector3> &normals, std::vector<int> &triangles);
414   bool makeEdgeSTLFromFace(const TopoDS_Edge &c, const TopoDS_Face &s,
415                            std::vector<SPoint3> *vertices);
416   bool makeRectangleSTL(double x, double y, double z, double dx, double dy,
417                         double roundedRadius, std::vector<SPoint3> &vertices,
418                         std::vector<SVector3> &normals,
419                         std::vector<int> &triangles);
420   bool makeDiskSTL(double xc, double yc, double zc, double rx, double ry,
421                    std::vector<SPoint3> &vertices,
422                    std::vector<SVector3> &normals, std::vector<int> &triangles);
423   bool makeSphereSTL(double xc, double yc, double zc, double radius,
424                      double angle1, double angle2, double angle3,
425                      std::vector<SPoint3> &vertices,
426                      std::vector<SVector3> &normals,
427                      std::vector<int> &triangles);
428   bool makeBoxSTL(double x, double y, double z, double dx, double dy, double dz,
429                   std::vector<SPoint3> &vertices,
430                   std::vector<SVector3> &normals, std::vector<int> &triangles);
431   bool makeCylinderSTL(double x, double y, double z, double dx, double dy,
432                        double dz, double r, double angle,
433                        std::vector<SPoint3> &vertices,
434                        std::vector<SVector3> &normals,
435                        std::vector<int> &triangles);
436   bool makeConeSTL(double x, double y, double z, double dx, double dy,
437                    double dz, double r1, double r2, double angle,
438                    std::vector<SPoint3> &vertices,
439                    std::vector<SVector3> &normals, std::vector<int> &triangles);
440   bool makeWedgeSTL(double x, double y, double z, double dx, double dy,
441                     double dz, double ltx, std::vector<SPoint3> &vertices,
442                     std::vector<SVector3> &normals,
443                     std::vector<int> &triangles);
444   bool makeTorusSTL(double x, double y, double z, double r1, double r2,
445                     double angle, std::vector<SPoint3> &vertices,
446                     std::vector<SVector3> &normals,
447                     std::vector<int> &triangles);
448   void fixSTLBounds(double &xmin, double &ymin, double &zmin, double &xmax,
449                     double &ymax, double &zmax);
450 };
451 
452 #else
453 
454 class OCC_Internals {
455 private:
_error(std::string what)456   bool _error(std::string what)
457   {
458     Msg::Error("Gmsh requires OpenCASCADE to %s", what.c_str());
459     return false;
460   }
461 
462 public:
463   enum BooleanOperator { Union, Intersection, Difference, Section, Fragments };
OCC_Internals()464   OCC_Internals() {}
getChanged()465   bool getChanged() const { return false; }
reset()466   void reset() {}
setMaxTag(int dim,int val)467   void setMaxTag(int dim, int val) {}
getMaxTag(int dim)468   int getMaxTag(int dim) const { return 0; }
469   bool addVertex(int &tag, double x, double y, double z,
470                  double meshSize = MAX_LC)
471   {
472     return _error("add vertex");
473   }
addLine(int & tag,int startTag,int endTag)474   bool addLine(int &tag, int startTag, int endTag)
475   {
476     return _error("add line");
477   }
addLine(int & tag,const std::vector<int> & pointTags)478   bool addLine(int &tag, const std::vector<int> &pointTags)
479   {
480     return _error("add line");
481   }
addCircleArc(int & tag,int startTag,int centerTag,int endTag)482   bool addCircleArc(int &tag, int startTag, int centerTag, int endTag)
483   {
484     return _error("add circle arc");
485   }
addCircle(int & tag,double x,double y,double z,double r,double angle1,double angle2)486   bool addCircle(int &tag, double x, double y, double z, double r,
487                  double angle1, double angle2)
488   {
489     return _error("add circle");
490   }
addEllipseArc(int & tag,int startTag,int centerTag,int majorTag,int endTag)491   bool addEllipseArc(int &tag, int startTag, int centerTag, int majorTag,
492                      int endTag)
493   {
494     return _error("add ellipse arc");
495   }
addEllipse(int & tag,double x,double y,double z,double r1,double r2,double angle1,double angle2)496   bool addEllipse(int &tag, double x, double y, double z, double r1, double r2,
497                   double angle1, double angle2)
498   {
499     return _error("add ellipse");
500   }
addSpline(int & tag,const std::vector<int> & pointTags)501   bool addSpline(int &tag, const std::vector<int> &pointTags)
502   {
503     return _error("add spline");
504   }
addBezier(int & tag,const std::vector<int> & pointTags)505   bool addBezier(int &tag, const std::vector<int> &pointTags)
506   {
507     return _error("add Bezier");
508   }
509   bool addBSpline(int &tag, const std::vector<int> &pointTags,
510                   const int degree = -1,
511                   const std::vector<double> &weights = std::vector<double>(),
512                   const std::vector<double> &knots = std::vector<double>(),
513                   const std::vector<int> &multiplicities = std::vector<int>())
514   {
515     return _error("add BSpline");
516   }
addWire(int & tag,const std::vector<int> & curveTags,bool closed)517   bool addWire(int &tag, const std::vector<int> &curveTags, bool closed)
518   {
519     return _error("add wire");
520   }
addCurveLoop(int & tag,const std::vector<int> & curveTags)521   bool addCurveLoop(int &tag, const std::vector<int> &curveTags)
522   {
523     return _error("add curve loop");
524   }
525   bool addRectangle(int &tag, double x, double y, double z, double dx,
526                     double dy, double roundedRadius = 0.)
527   {
528     return _error("add rectangle");
529   }
addDisk(int & tag,double xc,double yc,double zc,double rx,double ry)530   bool addDisk(int &tag, double xc, double yc, double zc, double rx, double ry)
531   {
532     return _error("add disk");
533   }
addPlaneSurface(int & tag,const std::vector<int> & wireTags)534   bool addPlaneSurface(int &tag, const std::vector<int> &wireTags)
535   {
536     return _error("add plane surface");
537   }
538   bool addSurfaceFilling(
539     int &tag, int wireTag,
540     const std::vector<int> &pointTags = std::vector<int>(),
541     const std::vector<int> &surfaceTags = std::vector<int>(),
542     const std::vector<int> &surfaceContinuity = std::vector<int>(),
543     const int degree = 3, const int numPointsOnCurves = 15,
544     const int numIter = 2, const bool anisotropic = false,
545     const double tol2d = 0.00001, const double tol3d = 0.0001,
546     const double tolAng = 0.01, const double tolCurv = 0.1,
547     const int maxDegree = 8, const int maxSegments = 9)
548   {
549     return _error("add surface filling");
550   }
551   bool addBSplineFilling(int &tag, int wireTag, const std::string &type = "")
552   {
553     return _error("add BSpline filling");
554   }
555   bool addBezierFilling(int &tag, int wireTag, const std::string &type = "")
556   {
557     return _error("add Bezier filling");
558   }
559   bool addBSplineSurface(int &tag, const std::vector<int> &pointTags,
560                          const int numPointsU, const int degreeU,
561                          const int degreeV, const std::vector<double> &weights,
562                          const std::vector<double> &knotsU,
563                          const std::vector<double> &knotsV,
564                          const std::vector<int> &multiplicitiesU,
565                          const std::vector<int> &multiplicitiesV,
566                          const std::vector<int> &wireTags = std::vector<int>(),
567                          bool wire3D = true)
568   {
569     return _error("add BSpline surface");
570   }
571   bool addBezierSurface(int &tag, const std::vector<int> &pointTags,
572                         const int numPointsU,
573                         const std::vector<int> &wireTags = std::vector<int>(),
574                         bool wire3D = true)
575   {
576     return _error("add Bezier surface");
577   }
addTrimmedSurface(int & tag,int surfaceTag,const std::vector<int> & wireTags,bool wire3D)578   bool addTrimmedSurface(int &tag, int surfaceTag,
579                          const std::vector<int> &wireTags, bool wire3D)
580   {
581     return _error("add trimmed surface");
582   }
addSurfaceLoop(int & tag,const std::vector<int> & surfaceTags,bool sewing)583   bool addSurfaceLoop(int &tag, const std::vector<int> &surfaceTags,
584                       bool sewing)
585   {
586     return _error("add surface loop");
587   }
addVolume(int & tag,const std::vector<int> & shellTags)588   bool addVolume(int &tag, const std::vector<int> &shellTags)
589   {
590     return _error("add volume");
591   }
addSphere(int & tag,double xc,double yc,double zc,double radius,double angle1,double angle2,double angle3)592   bool addSphere(int &tag, double xc, double yc, double zc, double radius,
593                  double angle1, double angle2, double angle3)
594   {
595     return _error("add sphere");
596   }
addBox(int & tag,double x,double y,double z,double dx,double dy,double dz)597   bool addBox(int &tag, double x, double y, double z, double dx, double dy,
598               double dz)
599   {
600     return _error("add block");
601   }
addCylinder(int & tag,double x,double y,double z,double dx,double dy,double dz,double r,double angle)602   bool addCylinder(int &tag, double x, double y, double z, double dx, double dy,
603                    double dz, double r, double angle)
604   {
605     return _error("add cylinder");
606   }
addCone(int & tag,double x,double y,double z,double dx,double dy,double dz,double r1,double r2,double angle)607   bool addCone(int &tag, double x, double y, double z, double dx, double dy,
608                double dz, double r1, double r2, double angle)
609   {
610     return _error("add cone");
611   }
addWedge(int & tag,double x,double y,double z,double dx,double dy,double dz,double ltx)612   bool addWedge(int &tag, double x, double y, double z, double dx, double dy,
613                 double dz, double ltx)
614 
615   {
616     return _error("add wedge");
617   }
addTorus(int & tag,double x,double y,double z,double r1,double r2,double angle)618   bool addTorus(int &tag, double x, double y, double z, double r1, double r2,
619                 double angle)
620   {
621     return _error("add torus");
622   }
623   bool addThruSections(int tag, const std::vector<int> &wireTags,
624                        bool makeSolid, bool makeRuled,
625                        std::vector<std::pair<int, int> > &outDimTags,
626                        int maxDegree = -1)
627   {
628     return _error("add thrusection");
629   }
addThickSolid(int tag,int solidTag,const std::vector<int> & excludeFaceTags,double offset,std::vector<std::pair<int,int>> & outDimTags)630   bool addThickSolid(int tag, int solidTag,
631                      const std::vector<int> &excludeFaceTags, double offset,
632                      std::vector<std::pair<int, int> > &outDimTags)
633   {
634     return _error("add thick solid");
635   }
636   bool extrude(const std::vector<std::pair<int, int> > &inDimTags, double dx,
637                double dy, double dz,
638                std::vector<std::pair<int, int> > &outDimTags,
639                ExtrudeParams *e = 0)
640   {
641     return _error("extrude");
642   }
643   bool revolve(const std::vector<std::pair<int, int> > &inDimTags, double x,
644                double y, double z, double ax, double ay, double az,
645                double angle, std::vector<std::pair<int, int> > &outDimTags,
646                ExtrudeParams *e = 0)
647   {
648     return _error("revolve");
649   }
650   bool addPipe(const std::vector<std::pair<int, int> > &inDimTags, int wireTag,
651                std::vector<std::pair<int, int> > &outDimTags,
652                const std::string &trihedron = "")
653   {
654     return _error("add pipe");
655   }
fillet(const std::vector<int> & volumeTags,const std::vector<int> & curveTags,const std::vector<double> & radii,std::vector<std::pair<int,int>> & outDimTags,bool removeVolume)656   bool fillet(const std::vector<int> &volumeTags,
657               const std::vector<int> &curveTags,
658               const std::vector<double> &radii,
659               std::vector<std::pair<int, int> > &outDimTags, bool removeVolume)
660   {
661     return _error("create fillet");
662   }
chamfer(const std::vector<int> & volumeTags,const std::vector<int> & curveTags,const std::vector<int> & surfaceTags,const std::vector<double> & distances,std::vector<std::pair<int,int>> & outDimTags,bool removeVolume)663   bool chamfer(const std::vector<int> &volumeTags,
664                const std::vector<int> &curveTags,
665                const std::vector<int> &surfaceTags,
666                const std::vector<double> &distances,
667                std::vector<std::pair<int, int> > &outDimTags, bool removeVolume)
668   {
669     return _error("create chamfer");
670   }
booleanOperator(int tag,BooleanOperator op,const std::vector<std::pair<int,int>> & objectDimTags,const std::vector<std::pair<int,int>> & toolDimTags,std::vector<std::pair<int,int>> & outDimTags,std::vector<std::vector<std::pair<int,int>>> & outDimTagsMap,bool removeObject,bool removeTool)671   bool booleanOperator(
672     int tag, BooleanOperator op,
673     const std::vector<std::pair<int, int> > &objectDimTags,
674     const std::vector<std::pair<int, int> > &toolDimTags,
675     std::vector<std::pair<int, int> > &outDimTags,
676     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
677     bool removeObject, bool removeTool)
678   {
679     return _error("apply boolean operator");
680   }
681   bool
booleanUnion(int tag,const std::vector<std::pair<int,int>> & objectDimTags,const std::vector<std::pair<int,int>> & toolDimTags,std::vector<std::pair<int,int>> & outDimTags,std::vector<std::vector<std::pair<int,int>>> & outDimTagsMap,bool removeObject,bool removeTool)682   booleanUnion(int tag, const std::vector<std::pair<int, int> > &objectDimTags,
683                const std::vector<std::pair<int, int> > &toolDimTags,
684                std::vector<std::pair<int, int> > &outDimTags,
685                std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
686                bool removeObject, bool removeTool)
687   {
688     return _error("apply boolean union");
689   }
booleanIntersection(int tag,const std::vector<std::pair<int,int>> & objectDimTags,const std::vector<std::pair<int,int>> & toolDimTags,std::vector<std::pair<int,int>> & outDimTags,std::vector<std::vector<std::pair<int,int>>> & outDimTagsMap,bool removeObject,bool removeTool)690   bool booleanIntersection(
691     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
692     const std::vector<std::pair<int, int> > &toolDimTags,
693     std::vector<std::pair<int, int> > &outDimTags,
694     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
695     bool removeObject, bool removeTool)
696   {
697     return _error("apply boolean intersection");
698   }
booleanDifference(int tag,const std::vector<std::pair<int,int>> & objectDimTags,const std::vector<std::pair<int,int>> & toolDimTags,std::vector<std::pair<int,int>> & outDimTags,std::vector<std::vector<std::pair<int,int>>> & outDimTagsMap,bool removeObject,bool removeTool)699   bool booleanDifference(
700     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
701     const std::vector<std::pair<int, int> > &toolDimTags,
702     std::vector<std::pair<int, int> > &outDimTags,
703     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
704     bool removeObject, bool removeTool)
705   {
706     return _error("apply boolean difference");
707   }
booleanFragments(int tag,const std::vector<std::pair<int,int>> & objectDimTags,const std::vector<std::pair<int,int>> & toolDimTags,std::vector<std::pair<int,int>> & outDimTags,std::vector<std::vector<std::pair<int,int>>> & outDimTagsMap,bool removeObject,bool removeTool)708   bool booleanFragments(
709     int tag, const std::vector<std::pair<int, int> > &objectDimTags,
710     const std::vector<std::pair<int, int> > &toolDimTags,
711     std::vector<std::pair<int, int> > &outDimTags,
712     std::vector<std::vector<std::pair<int, int> > > &outDimTagsMap,
713     bool removeObject, bool removeTool)
714   {
715     return _error("apply boolean fragments");
716   }
removeAllDuplicates()717   void removeAllDuplicates() { _error("remove all duplicates"); }
mergeVertices(const std::vector<int> & tags)718   bool mergeVertices(const std::vector<int> &tags)
719   {
720     return _error("merge vertices");
721   }
translate(const std::vector<std::pair<int,int>> & inDimTags,double dx,double dy,double dz)722   bool translate(const std::vector<std::pair<int, int> > &inDimTags, double dx,
723                  double dy, double dz)
724   {
725     return _error("apply translation");
726   }
rotate(const std::vector<std::pair<int,int>> & inDimTags,double x,double y,double z,double ax,double ay,double az,double angle)727   bool rotate(const std::vector<std::pair<int, int> > &inDimTags, double x,
728               double y, double z, double ax, double ay, double az, double angle)
729   {
730     return _error("apply rotation");
731   }
dilate(const std::vector<std::pair<int,int>> & inDimTags,double x,double y,double z,double a,double b,double c)732   bool dilate(const std::vector<std::pair<int, int> > &inDimTags, double x,
733               double y, double z, double a, double b, double c)
734   {
735     return _error("apply dilatation");
736   }
symmetry(const std::vector<std::pair<int,int>> & inDimTags,double a,double b,double c,double d)737   bool symmetry(const std::vector<std::pair<int, int> > &inDimTags, double a,
738                 double b, double c, double d)
739   {
740     return _error("apply symmetry");
741   }
affine(const std::vector<std::pair<int,int>> & inDimTags,const std::vector<double> & mat)742   bool affine(const std::vector<std::pair<int, int> > &inDimTags,
743               const std::vector<double> &mat)
744   {
745     return _error("apply affine transform");
746   }
copy(const std::vector<std::pair<int,int>> & inDimTags,std::vector<std::pair<int,int>> & outDimTags)747   bool copy(const std::vector<std::pair<int, int> > &inDimTags,
748             std::vector<std::pair<int, int> > &outDimTags)
749   {
750     return _error("copy shape");
751   }
752   bool remove(int dim, int tag, bool recursive = false) { return false; }
753   bool remove(const std::vector<std::pair<int, int> > &dimTags,
754               bool recursive = false)
755   {
756     return false;
757   }
758   bool importShapes(const std::string &fileName, bool highestDimOnly,
759                     std::vector<std::pair<int, int> > &outDimTags,
760                     const std::string &format = "")
761   {
762     return _error("import shape");
763   }
healShapes(const std::vector<std::pair<int,int>> & inDimTags,std::vector<std::pair<int,int>> & outDimTags,double tolerance,bool fixDegenerated,bool fixSmallEdges,bool fixSmallFaces,bool sewFaces,bool makeSolids)764   bool healShapes(const std::vector<std::pair<int, int> > &inDimTags,
765                   std::vector<std::pair<int, int> > &outDimTags,
766                   double tolerance, bool fixDegenerated, bool fixSmallEdges,
767                   bool fixSmallFaces, bool sewFaces, bool makeSolids)
768   {
769     return _error("heal shapes");
770   }
setMeshSize(int dim,int tag,double size)771   void setMeshSize(int dim, int tag, double size) {}
synchronize(GModel * model)772   void synchronize(GModel *model) {}
773   bool exportShapes(GModel *model, const std::string &fileName,
774                     const std::string &format = "")
775   {
776     return _error("export shape");
777   }
getEntities(std::vector<std::pair<int,int>> & dimTags,int dim)778   bool getEntities(std::vector<std::pair<int, int> > &dimTags, int dim)
779   {
780     return false;
781   }
getVertex(int tag,double & x,double & y,double & z)782   bool getVertex(int tag, double &x, double &y, double &z) { return false; }
getBoundingBox(int dim,int tag,double & xmin,double & ymin,double & zmin,double & xmax,double & ymax,double & zmax)783   bool getBoundingBox(int dim, int tag, double &xmin, double &ymin,
784                       double &zmin, double &xmax, double &ymax, double &zmax)
785   {
786     return false;
787   }
getEntitiesInBoundingBox(double xmin,double ymin,double zmin,double xmax,double ymax,double zmax,std::vector<std::pair<int,int>> & dimTags,int dim)788   bool getEntitiesInBoundingBox(double xmin, double ymin, double zmin,
789                                 double xmax, double ymax, double zmax,
790                                 std::vector<std::pair<int, int> > &dimTags,
791                                 int dim)
792   {
793     return false;
794   }
getMass(int dim,int tag,double & mass)795   bool getMass(int dim, int tag, double &mass) { return false; }
getCenterOfMass(int dim,int tag,double & x,double & y,double & z)796   bool getCenterOfMass(int dim, int tag, double &x, double &y, double &z)
797   {
798     return false;
799   }
getMatrixOfInertia(int dim,int tag,std::vector<double> & mat)800   bool getMatrixOfInertia(int dim, int tag, std::vector<double> &mat)
801   {
802     return false;
803   }
getDistance(int dim1,int tag1,int dim2,int tag2,double & x1,double & y1,double & z1,double & x2,double & y2,double & z2)804   double getDistance(int dim1, int tag1,
805                      int dim2, int tag2,
806                      double &x1, double &y1, double &z1,
807                      double &x2, double &y2, double &z2)
808   {
809     return -1;
810   }
makeRectangleSTL(double x,double y,double z,double dx,double dy,double roundedRadius,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)811   bool makeRectangleSTL(double x, double y, double z, double dx, double dy,
812                         double roundedRadius, std::vector<SPoint3> &vertices,
813                         std::vector<SVector3> &normals,
814                         std::vector<int> &triangles)
815   {
816     return false;
817   }
makeDiskSTL(double xc,double yc,double zc,double rx,double ry,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)818   bool makeDiskSTL(double xc, double yc, double zc, double rx, double ry,
819                    std::vector<SPoint3> &vertices,
820                    std::vector<SVector3> &normals, std::vector<int> &triangles)
821   {
822     return false;
823   }
makeSphereSTL(double xc,double yc,double zc,double radius,double angle1,double angle2,double angle3,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)824   bool makeSphereSTL(double xc, double yc, double zc, double radius,
825                      double angle1, double angle2, double angle3,
826                      std::vector<SPoint3> &vertices,
827                      std::vector<SVector3> &normals,
828                      std::vector<int> &triangles)
829   {
830     return false;
831   }
makeBoxSTL(double x,double y,double z,double dx,double dy,double dz,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)832   bool makeBoxSTL(double x, double y, double z, double dx, double dy, double dz,
833                   std::vector<SPoint3> &vertices,
834                   std::vector<SVector3> &normals, std::vector<int> &triangles)
835   {
836     return false;
837   }
makeCylinderSTL(double x,double y,double z,double dx,double dy,double dz,double r,double angle,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)838   bool makeCylinderSTL(double x, double y, double z, double dx, double dy,
839                        double dz, double r, double angle,
840                        std::vector<SPoint3> &vertices,
841                        std::vector<SVector3> &normals,
842                        std::vector<int> &triangles)
843   {
844     return false;
845   }
makeConeSTL(double x,double y,double z,double dx,double dy,double dz,double r1,double r2,double angle,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)846   bool makeConeSTL(double x, double y, double z, double dx, double dy,
847                    double dz, double r1, double r2, double angle,
848                    std::vector<SPoint3> &vertices,
849                    std::vector<SVector3> &normals, std::vector<int> &triangles)
850   {
851     return false;
852   }
makeWedgeSTL(double x,double y,double z,double dx,double dy,double dz,double ltx,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)853   bool makeWedgeSTL(double x, double y, double z, double dx, double dy,
854                     double dz, double ltx, std::vector<SPoint3> &vertices,
855                     std::vector<SVector3> &normals, std::vector<int> &triangles)
856   {
857     return false;
858   }
makeTorusSTL(double x,double y,double z,double r1,double r2,double angle,std::vector<SPoint3> & vertices,std::vector<SVector3> & normals,std::vector<int> & triangles)859   bool makeTorusSTL(double x, double y, double z, double r1, double r2,
860                     double angle, std::vector<SPoint3> &vertices,
861                     std::vector<SVector3> &normals, std::vector<int> &triangles)
862   {
863     return false;
864   }
865 };
866 
867 #endif
868 #endif
869