OpenLexocad  27.1
ShapeTool.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Base/Color.h>
4 #include <Base/Double.h>
5 #include <Base/Int.h>
6 #include <Base/String.h>
7 #include <Geom/Ax2.h>
8 #include <Geom/Bnd_Box.h>
9 #include <Geom/BrepData.h>
10 #include <Geom/Pnt.h>
11 #include <Geom/Precision.h>
12 #include <Geom/Trsf.h>
13 #include <Geom/Vec.h>
14 #include <Topo/Clash.h>
15 #include <Topo/FaceTool.h>
17 #include <Topo/HealingOptions.h>
18 #include <Topo/NurbsOptions.h>
19 #include <Topo/RayHit.h>
20 #include <Topo/Shape.h>
21 #include <Topo/ShapeAttributes.h>
22 #include <Topo/ShapeInfo.h>
23 #include <Topo/SimplifyOptions.h>
24 #include <Topo/ThreadTask.h>
25 #include <Topo/VisibleEdge.h>
26 #include <Topo/WireTool.h>
27 
28 #include <list>
29 
30 
31 class TopoDS_Shape;
32 class ENTITY;
33 class BODY;
34 class CA_Ray;
36 
37 namespace Acis
38 {
39 class AcisHelper;
40 class AcisBrepGeometryAdaptor;
41 class PolyToAcisConverter;
42 } // namespace Acis
43 
44 namespace Mesh
45 {
46 class OmfMeshTool;
47 }
48 
49 namespace Mesher
50 {
51 class EdgeData;
52 class ShapeTesselator;
53 class ShapeTesselator_OCC;
54 class EdgeData_OCC;
55 class ShapeTessellationQuality;
56 } // namespace Mesher
57 
58 namespace MesherAcis
59 {
60 class ShapeTesselator_Acis;
61 class TriangleData_Acis;
62 class EdgeData_Acis;
63 class facet_body_thread_worker;
64 } // namespace MesherAcis
65 
66 namespace Core
67 {
68 class CoreDocument;
69 }
70 
71 namespace App
72 {
73 class SubElement;
74 class Element;
75 } // namespace App
76 
77 namespace Topo
78 {
85 class LX_TOPO_EXPORT ShapeTool
86 {
87 public:
88  ShapeTool(void);
89  virtual ~ShapeTool(void);
90 
91  friend class Mesher::EdgeData;
92  friend class Mesher::EdgeData_OCC;
93  friend class Mesher::ShapeTesselator;
94  friend class Mesher::ShapeTesselator_OCC;
95  friend class MesherAcis::ShapeTesselator_Acis;
96  friend class MesherAcis::TriangleData_Acis;
97  friend class MesherAcis::EdgeData_Acis;
98  friend class MesherAcis::facet_body_thread_worker;
99  friend class Mesh::OmfMeshTool;
100  friend class Acis::AcisHelper;
101  friend class Acis::AcisBrepGeometryAdaptor;
102  friend class Acis::PolyToAcisConverter;
103 
105  // //
106  // --------------------- BEGIN API --------------------- //
107  // //
108  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
109  // //
111 
113  {
114  NO_HINT,
115  BEAM_HINT,
116  COLUMN_HINT,
117  DOOR_HINT,
118  MEMBER_HINT,
119  PLATE_HINT,
120  SLAB_HINT,
121  WALL_HINT,
122  WINDOW_HINT
123  };
124 
126  static pShape makeShape(pVertex vertex);
128  static pShape makeShape(pEdge edge);
130  static pShape makeShape(pWire wire, double precision = Geom::Precision::linear_Resolution());
132  static pShape makeShape(pFace face);
134  static pShape makeShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
136  static pShape makeShape(BODY* aBody);
138  static pShape makeLazyFacetedBrepShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
140  static pShape makeInventorMeshShape(pIndexedMesh);
142  static pShape makeInventorMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
144  static pShape makeOMFMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
146  static pIndexedMesh makeIndexedMesh(pConstBrepData data, std::vector<PNTS>& defectPolygons, bool createEdges = false);
148  static pIndexedMesh makeIndexedMesh(pConstShape input, bool createEdges = false);
150  static pShape makeAcisShape(pShape input);
152  static bool createBrepData(pConstShape input, pBrepData data);
154  static void makeShapeAsync(pConstBrepData data, std::function<void(pShape newShape, std::vector<PNTS> defectPolygons)> onShapeMadeCB);
156  static pShape makeShape(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices, std::vector<PNTS>& defectPolygons);
158  static pShape makeShape(const std::vector<Base::Int>& model, const std::vector<Geom::Pnt>& vertices, std::vector<PNTS>& defectPolygons);
160  static void makeShapeAsync(const std::vector<int>& model,
161  const std::vector<Geom::Pnt>& vertices,
162  std::function<void(pShape newShape, std::vector<PNTS> defectPolygons)> onShapeMadeCB);
164  static bool makeShapes_parallel(const std::vector<pConstBrepData>& breps, std::map<pConstBrepData, pShape>& shapes);
165 
168  static pShape makeShape(const std::vector<pFace>& faces, double precision = Geom::Precision::linear_Resolution());
170  static pShape makeFaceSet(const std::vector<pFace>& faces);
172  static pShape makeFaceSet(pConstBrepData data);
175  static pShape makeCompound(const std::vector<pConstShape>& shapes);
177  static pShape makeShape(Core::DocObject* curve, double startParam = 0, double endParam = 0);
178 
180  static int getLumpsCount(pConstTopologicalItem item);
182  static int getFaceCount(pConstTopologicalItem item);
184  static int getWireCount(pConstTopologicalItem item);
186  static int getEdgeCount(pConstTopologicalItem item);
188  static int getVertexCount(pConstTopologicalItem item);
190  static int getPolygonCount(pConstTopologicalItem item, Topo::ShapeTessellationQuality quality);
191 
193  static pConstFace getFaceByIndex(pConstTopologicalItem item, int idx);
195  static pConstWire getWireByIndex(pConstTopologicalItem item, int idx);
197  static pConstEdge getEdgeByIndex(pConstTopologicalItem item, int idx);
199  static pConstVertex getVertexByIndex(pConstTopologicalItem item, int idx);
200 
202  static int getIndexFromShell(pConstTopologicalItem item, pConstShell shell);
204  static int getIndexFromFace(pConstTopologicalItem item, pConstFace face);
205 
207  static std::vector<int> getIndexesFromFaces(pConstTopologicalItem item, const std::vector<pConstFace> faces);
208 
210  static int getIndexFromWire(pConstTopologicalItem item, pConstWire wire);
212  static int getIndexFromEdge(pConstTopologicalItem item, pConstEdge edge);
214  static int getIndexFromVertex(pConstTopologicalItem item, const Geom::Pnt& v);
216  static int getIndexFromVertex(pConstTopologicalItem item, pConstVertex vtx);
217 
219  static std::vector<pConstShell> getShells(pConstTopologicalItem item);
221  static std::vector<pConstFace> getFaces(pConstTopologicalItem item);
223  static std::vector<pFace> getFacesAsCopy(pConstTopologicalItem item);
225  static std::vector<pConstWire> getWires(pConstTopologicalItem item);
227  static std::vector<pConstEdge> getEdges(pConstTopologicalItem item);
229  static std::vector<VisibleEdge> getEdges_visible(std::vector<pConstShape> shapes,
230  const Geom::Pnt& cam_position,
231  const Geom::Pnt& cam_target,
232  bool cam_perspective = true);
234  static std::vector<pConstVertex> getVertices(pConstTopologicalItem item);
236  static std::vector<int> getAdjacentFaceIndicesFromVertexIndex(pConstTopologicalItem item, int vertexIdx);
238  static std::vector<pConstFace> getAdjacentFacesFromEdge(pConstTopologicalItem item, pConstEdge edge);
240  static std::vector<int> getEdgeIndicesFromFace(pConstTopologicalItem item, int faceIndex);
242  static std::vector<int> getVertexIndicesFromWire(pConstTopologicalItem item, int wireIdx);
244  static std::vector<int> getWireIndicesFromFace(pConstTopologicalItem item, int faceIdx);
246  static void getVerticesAsPoints(pConstTopologicalItem item, std::vector<Geom::Pnt>& vertices);
248  static Geom::Bnd_Box getBoundingBox(pConstTopologicalItem item);
250  static Geom::Trsf getTransform(pConstShape shape);
253  static bool calculateLocalAxes(pConstShape shape, Geom::Ax2& localAxes);
255  static bool calculateDetail(pConstShape shape, CA_Detail& detail, const CA_Snap& snap);
257  static pSolid cast2Solid(pShape shape);
259  static pCompound cast2Compound(pShape shape);
261  static pMesh cast2Mesh(pShape shape);
263  static pConstSolid cast2ConstSolid(pConstShape shape);
265  static pConstCompound cast2ConstCompound(pConstShape shape);
267  static pConstMesh cast2ConstMesh(pConstShape shape);
269  static double getVolume(pConstTopologicalItem item);
271  static bool getCentroid(pConstShape shape, Geom::Pnt &centroid);
273  static void setNeedMassUpdate(pConstShape shape, bool on);
275  static bool write(pConstShape shape, std::ostream& writer);
277  static bool write(pConstShape shape, Base::AbstractWriter& writer);
279  static bool write(const std::string& format, pConstShape shape, const Base::String& fileName);
281  static bool write(const std::string& format, std::vector<pConstShape> shapes, const Base::String& fileName);
284  static bool writeAcisFile(std::vector<pConstShape> shapes,
285  const Base::String& fileName,
286  bool isText,
287  int major_version = -1,
288  int minor_version = -1,
289  double scale = 1.);
292  static bool appendAcisFile(std::vector<pConstShape> shapes,
293  const Base::String& fileName,
294  bool isText,
295  int major_version = -1,
296  int minor_version = -1,
297  double scale = 1.);
299  static bool canWriteAs(const std::string& format, pConstShape shape);
301  static std::string getWriteFormat(pConstShape shape);
303  static pShape read(const std::string& format, std::istream& reader);
305  static pShape read(const std::string& format, const std::string& data, float version);
307  /*DEPRECATED("Pass fileName as Base::String.") */ static pShape read(const std::string& format, const std::string& fileName);
309  static pShape read(const std::string& format, const Base::String& fileName);
310 
313  static bool intersectBBoxes(pConstShape shape1, pConstShape shape2);
314  static pShape cut(pConstShape base, pConstShape tool, bool* ok = 0);
315  static pShape cut(pConstShape base, const std::vector<pConstShape> tools, bool* ok = 0);
316  static pShape fuse(pConstShape base, pConstShape tool, bool* ok = 0);
317  static pShape common(pConstShape base, pConstShape tool, bool* ok = 0);
318  static pShape section(pConstShape base, pConstShape tool, bool* ok = 0);
319  static pShape s_cut(pConstShape base, pConstShape tool);
320  static pShape s_common(pConstShape base, pConstShape tool);
321  static pShape cutWithPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
322  static pShape splitByPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
324 
326  static pShape transformed(pConstShape base, const Geom::Trsf& t);
328  static pShape scaled(pConstShape base, const Geom::XYZ& scale);
331  static bool isNull(pConstShape shape);
332 
334  static bool isValid(pConstShape shape, int checkLevel = 30);
336  static bool isValid(pConstWire wire, int checkLevel = 30);
338  static bool isValid(pConstFace face, int checkLevel = 30);
340  static bool isValid(pConstVertex vertex, int checkLevel = 30);
342  static bool isValid(pConstEdge edge, int checkLevel = 30);
344  static bool isValidInCadwork3d(pConstTopologicalItem shape);
346  static bool isEqual(pConstTopologicalItem shape1, pConstTopologicalItem shape2);
348  static Topo::GeometricInformation getGeometricInformation(pConstTopologicalItem item);
350  static void getAxesOrientedSurfaces(pConstShape shape, double& XYSurface, double& XZSurface, double& YZSurface);
351  static void getVerticalAndHorizontalFaceAreas(pConstShape shape,
352  double& verticalFaceSurface,
353  std::vector<double>& verticalFaceSurfaces,
354  double& verticalLargestFaceSurface,
355  double& horizontalFaceSurface);
357  static void getVerticalAndHorizontalFaceAreas(pConstShape shape,
358  Base::Double& verticalFaceSurface,
359  std::vector<double>& verticalFaceSurfaces,
360  Base::Double& verticalLargestFaceSurface,
361  Base::Double& horizontalFaceSurface);
363  static double getAreaFromTop(pConstShape shape, pMesh * areFromTopMesh = nullptr);
364  // Returns area of the largest face of the shape
365  static double getLargestFaceArea(pConstShape shape);
367  static pShape copy(pConstShape shape, bool deepCopy = true);
369  static App::Element* makeDbgElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color = Base::Color(204, 204, 204));
371  static App::SubElement* makeDbgSubElementFromShape(Core::CoreDocument* doc,
372  pConstShape shape,
373  const Base::Color& color = Base::Color(204, 204, 204));
376  static pMesh triangulationToMesh(pConstShape shape);
378  static bool isFaceted(pConstTopologicalItem shape);
380  static bool hasVoids(pConstTopologicalItem shape);
382  static pShape mergePlanarFaces(pConstShape shape);
384  static bool convertToPolygonalFaces(pConstShape shape, std::vector<pFace>& polyFaces, bool precise = false);
386  static bool hasNurbsFace(pConstShape shape);
388  static bool hasTriangulation(pConstShape shape);
390  static pConstVertex getClosestVertexToPoint(pConstTopologicalItem item, const Geom::Pnt& p);
395  static bool hasFaces(pConstShape shape, bool& allSubShapesHaveFaces);
397  static std::vector<pShape> getShapesFromAcisFile(const Base::String& fileName, double scaleFactor = 1., std::function<int(int)> callback = 0);
399  static pShape importBrep(Base::String filename);
401  static pShape extrudedWire(pConstWire wire, const Geom::Dir& extrudedDirection, double depth, double precision);
403  static pShape thickenSheets(pConstShape shape, double thickness, bool doubleSided = false, Base::String& errorInfo = Base::String());
405  static pShape deformed(pConstShape shape, const Geom::GTrsf& t, const Geom::Pnt& p);
407  static pShape mirrored(pConstShape shape, const Geom::Ax2& ax);
409  static Topo::ToolOutcome clash(pConstShape shape1, pConstShape shape2, bool& hasClash);
411  static Topo::ToolOutcome clashBodies(pConstShape shape1,
412  pConstShape shape2,
413  Topo::BodyClashType& clashType,
416  static pConstWire isSingleWire(pConstShape shape);
418  static pConstFace isSingleFace(pConstShape shape);
420  static pConstEdge isSingleEdge(pConstShape shape);
422  static pConstVertex isSingleVertex(pConstShape shape);
424  static bool isShell(pConstShape shape);
426  static bool isOpenShell(pConstShape shape);
428  static bool isClosedShell(pConstShape shape);
430  static bool isClosedSolid(pConstShape shape);
432  static bool isWire(pConstShape shape);
434  static bool isCompound(pConstShape shape);
436  static bool isMesh(pConstShape shape);
438  static bool isVertex(pConstShape shape);
440  static bool isExtrudedAreaSolid(pConstShape aShape,
441  Geom::Ax2& aPosition,
442  double& aLength,
443  pConstFace& aProfile,
444  BuildingElementHintEnum aHint = BuildingElementHintEnum::NO_HINT);
446  static bool isCylinder(pConstShape shape, Geom::Ax2& position, double& length, double& radius);
447 
449  static bool getAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int& value);
451  static bool setAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int value);
453  static bool removeAttribute(pConstTopologicalItem shape, const Base::String& name);
455  static bool getAttributeString(pConstTopologicalItem shape, const Base::String& name, Base::String&);
457  static bool setAttributeString(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
459  static bool setAttributeStringNonCopy(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
461  static size_t getAttributeCount(pConstTopologicalItem shape);
463  static bool setCdwkSATAttributes(pConstShape shape, const Topo::Cdwk_SAT_Attributes& att);
465  static void releaseCdwkSATAttributes(pConstShape shape);
466 
468  static bool cleanupShape(pShape shape);
469 
470  static bool hasSliverFaces(pConstShape shape);
471  static pShape removedSliverFaces(pConstShape shape, double aTolerance = -1);
472 
474  static bool imprint(pShape base, pShape tool);
475 
477  static Topo::ToolOutcome rayPick(const std::vector<pConstTopologicalItem>& targets, const CA_Ray& ray, Topo::RayHitVector& found);
479  static void removeFaceting(pConstTopologicalItem item);
481  static bool getColorRGB(pConstShape shape, int& r, int& g, int& b);
482 
483  template <class _InputIterator, class _Function>
484  static void do_parallel(_InputIterator first, _InputIterator last, _Function fn)
485  {
486  while (first != last)
487  {
488  fn(*first);
489  ++first;
490  }
491  }
492 
493  static pShape skinning(Base::String& errorInfo,
494  const Topo::SkinningOptions& skinOptions,
495  const double& precision = Geom::Precision::linear_Resolution());
496  static pShape sweeping(Base::String& errorInfo, const Topo::SweepingOptions& sweepOptions);
497 
499  static double getModelingTolerance();
500  static Topo::ThreadPool* getThreadPool();
501  static void transformShape2LocalSpaceOfElement(App::Element* elem, pShape shape);
502  static bool hasPolyHedral();
503  static bool getModelFromPolyHedral(pShape shape, std::vector<int>& model, std::vector<Geom::Pnt>& vertices);
504  static pShape makePolyHedral(const std::vector<int>& model,
505  const std::vector<Geom::Pnt>& vertices,
506  bool checkShape,
507  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
508  static bool is_polyhedral_body(BODY const* iBody);
509 
511  // //
512  // ---------------------- END API ---------------------- //
513  // //
515 
516 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
517 
518  static std::vector<Geom::Pnt> getIntersectionPoints(pConstShape shape, const std::vector<pConstShape> shapes);
519  static std::vector<Geom::Pnt> getAllIntersectionPoints(const std::vector<pConstShape> shapes);
520  static void getAllIntersectionPointsIn2DMode(const std::vector<pConstShape>& shapes,
521  const Geom::Pnt& pnt,
522  const double& distance,
523  std::vector<Geom::Pnt>& intersectionPoints);
524  static void getAllIntersectionPointsWithLineIn2DMode(const std::vector<pConstShape>& shapes,
525  const Geom::Pnt& linePnt1,
526  const Geom::Pnt& linePnt2,
527  std::vector<Geom::Pnt>& intersectionPoints);
528  // convenience method
529  static void getAllIntersectionPointsWithLineIn2DMode(pConstShape shape,
530  const Geom::Pnt& linePnt1,
531  const Geom::Pnt& linePnt2,
532  std::vector<Geom::Pnt>& intersectionPoints);
533 
534  static pShape createShell(pConstShape shape);
535  static pShape createSheet(pConstShape shape, bool doubleSided);
536  static std::vector<pShape> splitLumps(pConstShape shape);
538  static bool makeShapes(const std::vector<pFace>& faces, std::vector<pShape>& shapes, double precision = Geom::Precision::linear_Resolution());
539 
541  static Topo::ToolOutcome createElementFromShape(Core::CoreDocument* doc, pConstShape shape, App::Element*& newElement, App::Element* sample = 0);
542  static size_t getShapeCount();
543  static void shapeCountInc();
544  static void shapeCountDec();
546  static bool getBoundingBoxSizes(pConstTopologicalItem item, Geom::XYZ& sizes); //
547  static pShape simplifyShape(pConstShape shape, const SimplifyOptions& opts);
548  static pShape offsetShape(pConstShape shape, double offset);
549  static void debugShape(pConstShape shape, int checkLevel, ShapeInfo& info);
550  static bool isManifold(pConstShape shape);
551  static bool restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
552  static int getFaceIndexByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
553  static std::vector<int> getFaceIndexesByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
554 
555  static void getFacesByMaxNormalToVectorAngle(pConstShape aShape,
556  std::map<int, Geom::Vec> aDirectionsToSortBy,
557  std::map<int, std::vector<pConstFace> >& aFacesListMap,
558  float aMaxAngleRad = 0.75);
560  static bool getTopoDS_Shape(pConstTopologicalItem shape, TopoDS_Shape& topoShape);
561 
562  static bool getEntityAttribute_Int(ENTITY* ent, int& v);
563  static bool setEntityAttribute_Int(ENTITY* ent, int v);
564 
567  static void __setOCCShapeTool__(Topo::ShapeTool* tool) { _occTool = tool; }
569  static void __setAcisShapeTool__(Topo::ShapeTool* tool) { _acisTool = tool; }
571  static void __setDefaultShapeTool__(Topo::ShapeTool* tool) { _defaultTool = tool; }
573  static void __setInventorShapeTool__(Topo::ShapeTool* tool) { _inventorTool = tool; }
575  static void __setOMFShapeTool__(Topo::ShapeTool* tool) { _omfTool = tool; }
577  static void __setAcisMeshShapeTool__(Topo::ShapeTool* tool) { _acisMeshShapeTool = tool; }
579  static pConstShape getFirstShape_Helper(App::Element* elem);
580 
581 protected:
583  static ENTITY* getAcisEntity(pConstTopologicalItem item);
584 
585  virtual pShape _makeShape(pVertex vertex);
586  virtual pShape _makeShape(pEdge edge);
587  virtual pShape _makeShape(pWire wire, double precision);
588  virtual pShape _makeShape(pFace face);
589  virtual pShape _makeShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
590  virtual pShape _makeShape(BODY* aBody);
591  virtual pShape _makeLazyFacetedBrepShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
592  virtual pShape _makeInventorMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
593  virtual pShape _makeInventorMeshShape(pIndexedMesh p);
594  virtual pIndexedMesh _makeIndexedMesh(pConstBrepData data, std::vector<PNTS>& defectPolygons, bool createEdges = false);
595  virtual pIndexedMesh _makeIndexedMesh(pConstShape input, bool createEdges = false);
596  virtual pShape _makeOMFMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
597  virtual pShape _makeAcisShape(pShape input);
598  virtual bool _createBrepData(pConstShape input, pBrepData data);
599  virtual pShape _makeShape(const std::vector<pFace>& faces, double tolerance);
600  virtual bool _makeShapes(const std::vector<pFace>& faces, std::vector<pShape>& shapes, double precision);
601  virtual pShape _makeShape(const std::vector<int>& model,
602  const std::vector<Geom::Pnt>& vertices,
603  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
604  virtual bool _makeShapes_parallel(const std::vector<pConstBrepData>& breps, std::map<pConstBrepData, pShape>& shapes);
605  virtual pShape _makeFaceSet(const std::vector<pFace>& faces);
606  virtual pShape _makeFaceSet(pConstBrepData data);
607  virtual pShape _makeCompound(const std::vector<pConstShape>& shapes);
608  virtual int _getFaceCount(pConstTopologicalItem item);
609  virtual int _getWireCount(pConstTopologicalItem item);
610  virtual int _getEdgeCount(pConstTopologicalItem item);
611  virtual int _getVertexCount(pConstTopologicalItem item);
612  virtual int _getLumpsCount(pConstTopologicalItem item);
613  virtual int _getPolygonCount(pConstTopologicalItem item, Topo::ShapeTessellationQuality quality);
614  virtual pShape _makeShape(Core::DocObject* curve, double startParam, double endParam);
615 
616  virtual pConstFace _getFaceByIndex(pConstTopologicalItem item, int idx);
617  virtual pConstWire _getWireByIndex(pConstTopologicalItem item, int idx);
618  virtual pConstEdge _getEdgeByIndex(pConstTopologicalItem item, int idx);
619  virtual pConstVertex _getVertexByIndex(pConstTopologicalItem item, int idx);
620 
621  virtual std::vector<pConstFace> _getFaces(pConstTopologicalItem item);
622  virtual std::vector<pConstWire> _getWires(pConstTopologicalItem item);
623  virtual std::vector<pConstEdge> _getEdges(pConstTopologicalItem item);
624  virtual std::vector<pConstEdge> _getAllEdges(pConstTopologicalItem item);
625  virtual std::vector<pConstVertex> _getVertices(pConstTopologicalItem item);
626 
627 
628  virtual int _getIndexFromFace(pConstTopologicalItem item, pConstFace face);
629  virtual std::vector<int> _getIndexesFromFaces(pConstTopologicalItem item, const std::vector<pConstFace> faces);
630  virtual int _getIndexFromWire(pConstTopologicalItem item, pConstWire wire);
631  virtual int _getIndexFromEdge(pConstTopologicalItem item, pConstEdge edge);
632  virtual int _getIndexFromVertex(pConstTopologicalItem item, const Geom::Pnt& v);
633  virtual int _getIndexFromVertex(pConstTopologicalItem item, pConstVertex vtx);
634 
635  virtual std::vector<int> _getAdjacentFaceIndicesFromVertexIndex(pConstTopologicalItem item, int vertexIdx);
636  virtual std::vector<pConstFace> _getAdjacentFacesFromEdge(pConstTopologicalItem item, pConstEdge edge);
637  virtual void _getVerticesAsPoints(pConstTopologicalItem item, std::vector<Geom::Pnt>& vertices);
638  virtual Geom::Bnd_Box _getBoundingBox(pConstTopologicalItem item);
639 
640  virtual Geom::Trsf _getTransform(pConstShape shape);
641  virtual bool _calculateDetail(pConstShape shape, CA_Detail& detail, const CA_Snap& snap);
642 
643  virtual pSolid _cast2Solid(pShape shape);
644  virtual pCompound _cast2Compound(pShape shape);
645  virtual pMesh _cast2Mesh(pShape shape);
646  virtual pConstSolid _cast2ConstSolid(pConstShape shape);
647  virtual pConstCompound _cast2ConstCompound(pConstShape shape);
648  virtual pConstMesh _cast2ConstMesh(pConstShape shape);
649 
650  virtual double _getVolume(pConstTopologicalItem item);
651  virtual bool _getCentroid(pConstShape shape, Geom::Pnt& centroid);
652  virtual void _setNeedMassUpdate(pConstShape shape, bool on);
653  virtual bool _write(pConstShape shape, std::ostream& writer);
654  virtual bool _write(pConstShape shape, Base::AbstractWriter& writer);
655 
656  virtual std::string _getWriteFormat(pConstShape shape);
657 
658  virtual bool _write(const std::string& format, pConstShape shape, const Base::String& fileName);
659  virtual bool _write(const std::string& format, std::vector<pConstShape> shapes, const Base::String& fileName);
660  virtual bool _writeAcisFile(std::vector<pConstShape> shapes,
661  const Base::String& fileName,
662  bool isText,
663  int major_version,
664  int minor_version,
665  double scale);
666  virtual bool _appendAcisFile(std::vector<pConstShape> shapes,
667  const Base::String& fileName,
668  bool isText,
669  int major_version,
670  int minor_version,
671  double scale);
672  virtual bool _canWriteAs(const std::string& format, pConstShape shape);
673  virtual bool _intersectBBoxes(pConstShape shape1, pConstShape shape2);
674 
675  virtual pShape _cut(pConstShape base, pConstShape tool, bool* ok);
676  virtual pShape _cut(pConstShape base, const std::vector<pConstShape> tools, bool* ok);
677  virtual pShape _fuse(pConstShape base, pConstShape tool, bool* ok);
678  virtual bool _imprint(pShape base, pShape tool);
679  virtual pShape _common(pConstShape base, pConstShape tool, bool* ok);
680  virtual pShape _section(pConstShape base, pConstShape tool, bool* ok);
681  virtual pShape _s_cut(pConstShape base, pConstShape tool);
682  virtual pShape _s_common(pConstShape base, pConstShape tool);
683  virtual pShape _cutWithPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
684  virtual pShape _splitByPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
685 
686  virtual pShape _transformed(pConstShape base, const Geom::Trsf& t);
687  virtual pShape _scaled(pConstShape base, const Geom::XYZ& scale);
688  virtual bool _isValid(pConstShape shape, int checkLevel);
689  virtual bool _isValid(pConstFace face, int checkLevel);
690  virtual bool _isValid(pConstWire wire, int checkLevel);
691  virtual bool _isValid(pConstVertex vertex, int checkLevel);
692  virtual bool _isValid(pConstEdge edge, int checkLevel);
693  virtual bool _isValid(pShape shape, int checkLevel);
694  virtual bool _isValid(pFace face, int checkLevel);
695  virtual bool _isValid(pWire wire, int checkLevel);
696  virtual bool _isValid(pVertex vertex, int checkLevel);
697  virtual bool _isValid(pEdge edge, int checkLevel);
698  virtual bool _isValidInCadwork3d(pConstTopologicalItem shape);
699  virtual bool _isEqual(pConstTopologicalItem item1, pConstTopologicalItem item2);
700  virtual bool _cleanupShape(pShape shape);
701 
702  virtual Topo::GeometricInformation _getGeometricInformation(pConstTopologicalItem shape);
703  virtual void _getAxesOrientedSurfaces(pConstShape shape, double& XYSurface, double& XZSurface, double& YZSurface);
704  virtual void _getVerticalAndHorizontalFaceAreas(pConstShape shape,
705  double& verticalFaceSurface,
706  std::vector<double>& verticalFaceSurfaces,
707  double& verticalLargestFaceSurface,
708  double& horizontalFaceSurface);
709  virtual double _getAreaFromTop(pConstShape shape, pMesh * areaFromTopMesh);
710  virtual pShape _copy(pConstShape shape, bool deepCopy);
711  virtual App::Element* _makeDbgElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color);
712  virtual App::SubElement* _makeDbgSubElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color);
713  virtual bool _getTopoDS_Shape(pConstTopologicalItem shape, TopoDS_Shape& topoShape);
714  virtual bool _isFaceted(pConstTopologicalItem shape);
715  virtual bool _hasVoids(pConstTopologicalItem shape);
716  virtual pShape _mergePlanarFaces(pConstShape shape);
717  virtual bool _convertToPolygonalFaces(pConstShape shape, std::vector<pFace>& polyFaces, bool precise = false);
718 
719  virtual pShape _extrudedWire(pConstWire wire, const Geom::Dir& extrudedDirection, double depth, double precision);
720  virtual std::vector<Geom::Pnt> _getIntersectionPoints(pConstShape shape, const std::vector<pConstShape> shapes);
721  virtual std::vector<Geom::Pnt> _getAllIntersectionPoints(const std::vector<pConstShape> shapes);
722  virtual bool _hasTriangulation(pConstShape shape);
723  virtual pShape _createShell(pConstShape shape);
724  virtual pShape _createSheet(pConstShape shape, bool doubleSided);
725 
726  virtual std::vector<pShape> _splitLumps(pConstShape shape);
727 
728  virtual bool _hasFaces(pConstShape shape, bool& allSubShapesHaveFaces);
729  virtual bool _isNull(pConstShape shape);
730  virtual pShape _deformed(pConstShape shape, const Geom::GTrsf& t, const Geom::Pnt& p);
731  virtual std::vector<pShape> _getShapesFromAcisFile(const Base::String& fileName, double scaleFactor = 1., std::function<int(int)> callback = 0);
732  virtual pShape _importBrep(const Base::String& filename);
733  virtual pShape _mirrored(pConstShape shape, const Geom::Ax2& ax);
734  virtual Topo::ToolOutcome _clash(pConstShape shape1, pConstShape shape2, bool& hasClash);
735  virtual Topo::ToolOutcome _clashBodies(pConstShape shape1,
736  pConstShape shape2,
737  Topo::BodyClashType& clashType,
739  virtual std::vector<VisibleEdge> _getEdges_visible(std::vector<pConstShape> shapes,
740  const Geom::Pnt& cam_position,
741  const Geom::Pnt& cam_target,
742  bool cam_perspective = true);
743  virtual Topo::ToolOutcome _createElementFromShape(Core::CoreDocument* doc,
744  pConstShape shape,
745  App::Element*& newElement,
746  App::Element* sample = 0);
747  virtual bool _getAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int& value);
748  virtual bool _setAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int value);
749  virtual bool _removeAttribute(pConstTopologicalItem shape, const Base::String& name);
750  virtual Topo::ToolOutcome _rayPick(const std::vector<pConstTopologicalItem>& targets, const CA_Ray& ray, Topo::RayHitVector& found);
751  virtual void _removeFaceting(pConstTopologicalItem item);
752  virtual bool _getColorRGB(pConstShape shape, int& r, int& g, int& b);
753  virtual pShape _simplifyShape(pConstShape shape, const SimplifyOptions& opts);
754  virtual pShape _offsetShape(pConstShape shape, double offset);
755  virtual pShape _thickenSheets(pConstShape shape, double thickness, bool doubleSided, Base::String& errorInfo);
756 
757  virtual pShape _skinning(Base::String& errorInfo, const Topo::SkinningOptions&, const double&)
758  {
759  errorInfo = L"Not implemented";
760  return nullptr;
761  }
762  virtual pShape _sweeping(Base::String& errorInfo, const Topo::SweepingOptions&)
763  {
764  errorInfo = L"Not implemented";
765  return nullptr;
766  }
767 
768  virtual double _getModelingTolerance();
769  virtual void _debugShape(pConstShape shape, int checkLevel, Topo::ShapeInfo& info);
770  virtual bool _isManifold(pConstShape shape);
771  virtual bool _restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
772 
773  virtual bool _getAttributeString(pConstTopologicalItem shape, const Base::String& name, Base::String&);
774  virtual bool _setAttributeString(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
775  // Don't copy attribute at Copy/Slip/Merge
776  virtual bool _setAttributeStringNonCopy(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
777  virtual size_t _getAttributeCount(pConstTopologicalItem shape);
778  virtual int _getFaceIndexByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
779  virtual std::vector<int> _getFaceIndexesByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
780 
781  virtual Topo::ThreadPool* _getThreadPool();
782  virtual bool _setCdwkSATAttributes(pConstShape shape, const Topo::Cdwk_SAT_Attributes& att);
783  virtual void _releaseCdwkSATAttributes(pConstShape shape) {}
784  virtual void _transformShape2LocalSpaceOfElement(App::Element* elem, pShape shape);
785  virtual pShape _removedSliverFaces(pConstShape aShape, double aTolerance);
786  virtual bool _hasSliverFaces(pConstShape shape);
787 
788  virtual bool _hasPolyHedral();
789  virtual bool _getModelFromPolyHedral(pShape shape, std::vector<int>& model, std::vector<Geom::Pnt>& vertices);
790  virtual pShape _makePolyHedral(const std::vector<int>& model,
791  const std::vector<Geom::Pnt>& vertices,
792  bool checkShape,
793  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
794  virtual bool _is_polyhedral_body(BODY const* iBody);
795 
796  virtual bool _getEntityAttribute_Int(ENTITY* ent, int& v);
797  virtual bool _setEntityAttribute_Int(ENTITY* ent, int v);
798 
799 #endif
800 private:
801  static bool _hasSameShapeTool(pConstTopologicalItem shape1, pConstTopologicalItem shape2);
802  static Topo::ShapeTool* getShapeTool(pConstTopologicalItem item);
803 
804  static Topo::ShapeTool* _acisTool;
805  static Topo::ShapeTool* _occTool;
806  static Topo::ShapeTool* _defaultTool;
807  static Topo::ShapeTool* _inventorTool;
808  static Topo::ShapeTool* _omfTool;
809  static Topo::ShapeTool* _acisMeshShapeTool;
810 
811  static size_t _shapeCount;
813 };
814 
815 
816 
817 } // namespace Topo
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:97
Definition: Shape.h:146
std::shared_ptr< Topo::Solid const > pConstSolid
Definition: Shape.h:94
CoreDocument()
std::shared_ptr< Topo::Solid > pSolid
Definition: Shape.h:79
Definition: Color.h:45
std::shared_ptr< Topo::Compound > pCompound
Definition: Shape.h:78
Definition: Pln.h:57
BuildingElementHintEnum
Definition: ShapeTool.h:112
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
std::shared_ptr< Topo::Vertex > pVertex
Definition: Shape.h:85
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Shape.h:98
std::shared_ptr< Topo::TopologicalItem const > pConstTopologicalItem
Definition: Shape.h:89
static const double linear_Resolution()
Definition: Precision.h:24
Core::PropertyText name
Definition: CoreDocument.h:167
Definition: ShapeInfo.h:6
Definition: Shape.h:693
Definition: FaceTool.h:24
std::shared_ptr< Topo::Face const > pConstFace
Definition: Shape.h:96
std::shared_ptr< Geom::BrepData > pBrepData
Definition: BrepData.h:28
Definition: Bnd_Box.h:63
std::shared_ptr< Topo::Face > pFace
Definition: Shape.h:81
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
LX_CORE_EXPORT Version & version
Definition: Double.h:6
Definition: CoreDocument.h:210
Tools for creating, manipulating and querying Shapes.
Definition: ShapeTool.h:85
Definition: GeometricInformation.h:6
std::vector< RayHit > RayHitVector
Definition: RayHit.h:44
Definition: Ax2.h:67
Definition: XYZ.h:43
std::shared_ptr< Topo::Shell const > pConstShell
Definition: Shape.h:95
Definition: SimplifyOptions.h:5
Definition: Trsf.h:57
Definition: Dir.h:45
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:31
Core::PropertyText filename
Definition: CoreDocument.h:176
Definition: Base.h:12
std::shared_ptr< Geom::IndexedMesh > pIndexedMesh
Definition: IndexedMesh.h:55
std::shared_ptr< Topo::MeshShape > pMesh
Definition: Shape.h:77
Definition: Variant.h:55
static void do_parallel(_InputIterator first, _InputIterator last, _Function fn)
Definition: ShapeTool.h:484
Definition: ShapeAttributes.h:23
Definition: NurbsOptions.h:191
Definition: GlobalAttachment.h:10
std::shared_ptr< Topo::Vertex const > pConstVertex
Definition: Shape.h:100
Definition: NurbsOptions.h:17
Definition: Writer.h:16
std::shared_ptr< Topo::Compound const > pConstCompound
Definition: Shape.h:93
Definition: GTrsf.h:47
double distance(const Geom::Vec &v1, const Geom::Vec &v2)
Returns the distance between two points.
Definition: Vec.h:345
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:82
BodyClashType
Definition: Clash.h:5
Definition: ThreadTask.h:34
std::shared_ptr< Topo::Shape const > pConstShape
Definition: Variant.h:77
std::shared_ptr< Topo::MeshShape const > pConstMesh
Definition: Shape.h:92
ClashMode
Definition: Clash.h:17
Base::String fileName
Definition: CoreDocument.h:186
virtual bool restoreGlobalAttachment(Base::GlobalAttachment *gAtta, std::istream *, uint64_t streamsize, const Base::String &entryName)
Definition: DocObject.h:51
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:76
std::shared_ptr< Topo::Edge > pEdge
Definition: Shape.h:83