OpenLexocad  27.0
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 #include <Topo/topo_defines.h>
28 
29 #include <list>
30 
31 
32 class TopoDS_Shape;
33 class ENTITY;
34 class BODY;
35 class CA_Ray;
37 
38 namespace Acis
39 {
40 class AcisHelper;
41 class AcisBrepGeometryAdaptor;
42 class PolyToAcisConverter;
43 } // namespace Acis
44 
45 namespace Mesh
46 {
47 class OmfMeshTool;
48 }
49 
50 namespace Mesher
51 {
52 class EdgeData;
53 class ShapeTesselator;
54 class ShapeTesselator_OCC;
55 class EdgeData_OCC;
56 class ShapeTessellationQuality;
57 } // namespace Mesher
58 
59 namespace MesherAcis
60 {
61 class ShapeTesselator_Acis;
62 class TriangleData_Acis;
63 class EdgeData_Acis;
64 class facet_body_thread_worker;
65 } // namespace MesherAcis
66 
67 namespace Core
68 {
69 class CoreDocument;
70 }
71 
72 namespace App
73 {
74 class SubElement;
75 class Element;
76 } // namespace App
77 
78 namespace Topo
79 {
87 {
88 public:
89  ShapeTool(void);
90  virtual ~ShapeTool(void);
91 
92  friend class Mesher::EdgeData;
93  friend class Mesher::EdgeData_OCC;
94  friend class Mesher::ShapeTesselator;
95  friend class Mesher::ShapeTesselator_OCC;
96  friend class MesherAcis::ShapeTesselator_Acis;
97  friend class MesherAcis::TriangleData_Acis;
98  friend class MesherAcis::EdgeData_Acis;
99  friend class MesherAcis::facet_body_thread_worker;
100  friend class Mesh::OmfMeshTool;
101  friend class Acis::AcisHelper;
102  friend class Acis::AcisBrepGeometryAdaptor;
103  friend class Acis::PolyToAcisConverter;
104 
106  // //
107  // --------------------- BEGIN API --------------------- //
108  // //
109  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
110  // //
112 
114  {
115  NO_HINT,
116  BEAM_HINT,
117  COLUMN_HINT,
118  DOOR_HINT,
119  MEMBER_HINT,
120  PLATE_HINT,
121  SLAB_HINT,
122  WALL_HINT,
123  WINDOW_HINT
124  };
125 
127  static pShape makeShape(pVertex vertex);
129  static pShape makeShape(pEdge edge);
131  static pShape makeShape(pWire wire, double precision = Geom::Precision::linear_Resolution());
133  static pShape makeShape(pFace face);
135  static pShape makeShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
137  static pShape makeShape(BODY* aBody);
139  static pShape makeLazyFacetedBrepShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
141  static pShape makeInventorMeshShape(pIndexedMesh);
143  static pShape makeInventorMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
145  static pShape makeOMFMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
147  static pIndexedMesh makeIndexedMesh(pConstBrepData data, std::vector<PNTS>& defectPolygons, bool createEdges = false);
149  static pIndexedMesh makeIndexedMesh(pConstShape input, bool createEdges = false);
151  static pShape makeAcisShape(pShape input);
153  static bool createBrepData(pConstShape input, pBrepData data);
155  static void makeShapeAsync(pConstBrepData data, std::function<void(pShape newShape, std::vector<PNTS> defectPolygons)> onShapeMadeCB);
157  static pShape makeShape(const std::vector<int>& model, const std::vector<Geom::Pnt>& vertices, std::vector<PNTS>& defectPolygons);
159  static pShape makeShape(const std::vector<Base::Int>& model, const std::vector<Geom::Pnt>& vertices, std::vector<PNTS>& defectPolygons);
161  static void makeShapeAsync(const std::vector<int>& model,
162  const std::vector<Geom::Pnt>& vertices,
163  std::function<void(pShape newShape, std::vector<PNTS> defectPolygons)> onShapeMadeCB);
165  static bool makeShapes_parallel(const std::vector<pConstBrepData>& breps, std::map<pConstBrepData, pShape>& shapes);
166 
169  static pShape makeShape(const std::vector<pFace>& faces, double precision = Geom::Precision::linear_Resolution());
171  static pShape makeFaceSet(const std::vector<pFace>& faces);
173  static pShape makeFaceSet(pConstBrepData data);
176  static pShape makeCompound(const std::vector<pConstShape>& shapes);
178  static pShape makeShape(Core::DocObject* curve, double startParam = 0, double endParam = 0);
179 
181  static int getLumpsCount(pConstTopologicalItem item);
183  static int getFaceCount(pConstTopologicalItem item);
185  static int getWireCount(pConstTopologicalItem item);
187  static int getEdgeCount(pConstTopologicalItem item);
189  static int getVertexCount(pConstTopologicalItem item);
191  static int getPolygonCount(pConstTopologicalItem item, Topo::ShapeTessellationQuality quality);
192 
194  static pConstFace getFaceByIndex(pConstTopologicalItem item, int idx);
196  static pConstWire getWireByIndex(pConstTopologicalItem item, int idx);
198  static pConstEdge getEdgeByIndex(pConstTopologicalItem item, int idx);
200  static pConstVertex getVertexByIndex(pConstTopologicalItem item, int idx);
201 
203  static int getIndexFromShell(pConstTopologicalItem item, pConstShell shell);
205  static int getIndexFromFace(pConstTopologicalItem item, pConstFace face);
206 
208  static std::vector<int> getIndexesFromFaces(pConstTopologicalItem item, const std::vector<pConstFace> faces);
209 
211  static int getIndexFromWire(pConstTopologicalItem item, pConstWire wire);
213  static int getIndexFromEdge(pConstTopologicalItem item, pConstEdge edge);
215  static int getIndexFromVertex(pConstTopologicalItem item, const Geom::Pnt& v);
217  static int getIndexFromVertex(pConstTopologicalItem item, pConstVertex vtx);
218 
220  static std::vector<pConstShell> getShells(pConstTopologicalItem item);
222  static std::vector<pConstFace> getFaces(pConstTopologicalItem item);
224  static std::vector<pFace> getFacesAsCopy(pConstTopologicalItem item);
226  static std::vector<pConstWire> getWires(pConstTopologicalItem item);
228  static std::vector<pConstEdge> getEdges(pConstTopologicalItem item);
230  static std::vector<VisibleEdge> getEdges_visible(std::vector<pConstShape> shapes,
231  const Geom::Pnt& cam_position,
232  const Geom::Pnt& cam_target,
233  bool cam_perspective = true);
235  static std::vector<pConstVertex> getVertices(pConstTopologicalItem item);
237  static std::vector<int> getAdjacentFaceIndicesFromVertexIndex(pConstTopologicalItem item, int vertexIdx);
239  static std::vector<pConstFace> getAdjacentFacesFromEdge(pConstTopologicalItem item, pConstEdge edge);
241  static std::vector<int> getEdgeIndicesFromFace(pConstTopologicalItem item, int faceIndex);
243  static std::vector<int> getVertexIndicesFromWire(pConstTopologicalItem item, int wireIdx);
245  static std::vector<int> getWireIndicesFromFace(pConstTopologicalItem item, int faceIdx);
247  static void getVerticesAsPoints(pConstTopologicalItem item, std::vector<Geom::Pnt>& vertices);
249  static Geom::Bnd_Box getBoundingBox(pConstTopologicalItem item);
251  static Geom::Trsf getTransform(pConstShape shape);
254  static bool calculateLocalAxes(pConstShape shape, Geom::Ax2& localAxes);
256  static bool calculateDetail(pConstShape shape, CA_Detail& detail, const CA_Snap& snap);
258  static pSolid cast2Solid(pShape shape);
260  static pCompound cast2Compound(pShape shape);
262  static pMesh cast2Mesh(pShape shape);
264  static pConstSolid cast2ConstSolid(pConstShape shape);
266  static pConstCompound cast2ConstCompound(pConstShape shape);
268  static pConstMesh cast2ConstMesh(pConstShape shape);
270  static double getVolume(pConstTopologicalItem item);
272  static bool getCentroid(pConstTopologicalItem item, Geom::Pnt &centroid);
274  static void setNeedMassUpdate(pConstShape shape, bool on);
276  static bool write(pConstShape shape, std::ostream& writer);
278  static bool write(pConstShape shape, Base::AbstractWriter& writer);
280  static bool write(const std::string& format, pConstShape shape, const Base::String& fileName);
282  static bool write(const std::string& format, std::vector<pConstShape> shapes, const Base::String& fileName);
285  static bool writeAcisFile(std::vector<pConstShape> shapes,
286  const Base::String& fileName,
287  bool isText,
288  int major_version = -1,
289  int minor_version = -1,
290  double scale = 1.);
293  static bool appendAcisFile(std::vector<pConstShape> shapes,
294  const Base::String& fileName,
295  bool isText,
296  int major_version = -1,
297  int minor_version = -1,
298  double scale = 1.);
300  static bool canWriteAs(const std::string& format, pConstShape shape);
302  static std::string getWriteFormat(pConstShape shape);
304  static pShape read(const std::string& format, std::istream& reader);
306  static pShape read(const std::string& format, const std::string& data, float version);
308  /*DEPRECATED("Pass fileName as Base::String.") */ static pShape read(const std::string& format, const std::string& fileName);
310  static pShape read(const std::string& format, const Base::String& fileName);
311 
314  static bool intersectBBoxes(pConstShape shape1, pConstShape shape2);
315  static pShape cut(pConstShape base, pConstShape tool, bool* ok = 0);
316  static pShape cut(pConstShape base, const std::vector<pConstShape> tools, bool* ok = 0);
317  static pShape fuse(pConstShape base, pConstShape tool, bool* ok = 0);
318  static pShape common(pConstShape base, pConstShape tool, bool* ok = 0);
319  static pShape section(pConstShape base, pConstShape tool, bool* ok = 0);
320  static pShape s_cut(pConstShape base, pConstShape tool);
321  static pShape s_common(pConstShape base, pConstShape tool);
322  static pShape cutWithPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
323  static pShape splitByPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
325 
327  static pShape transformed(pConstShape base, const Geom::Trsf& t);
329  static pShape scaled(pConstShape base, const Geom::XYZ& scale);
332  static bool isNull(pConstShape shape);
333 
335  static bool isValid(pConstShape shape, int checkLevel = 30);
337  static bool isValid(pConstWire wire, int checkLevel = 30);
339  static bool isValid(pConstFace face, int checkLevel = 30);
341  static bool isValid(pConstVertex vertex, int checkLevel = 30);
343  static bool isValid(pConstEdge edge, int checkLevel = 30);
345  static bool isValidInCadwork3d(pConstTopologicalItem shape);
347  static bool isEqual(pConstTopologicalItem shape1, pConstTopologicalItem shape2);
349  static Topo::GeometricInformation getGeometricInformation(pConstTopologicalItem item);
351  static void getAxesOrientedSurfaces(pConstShape shape, double& XYSurface, double& XZSurface, double& YZSurface);
352  static void getVerticalAndHorizontalFaceAreas(pConstShape shape,
353  double& verticalFaceSurface,
354  std::list<double>& verticalFaceSurfaces,
355  double& verticalLargestFaceSurface,
356  double& horizontalFaceSurface);
358  static void getVerticalAndHorizontalFaceAreas(pConstShape shape,
359  Base::Double& verticalFaceSurface,
360  std::list<double>& verticalFaceSurfaces,
361  Base::Double& verticalLargestFaceSurface,
362  Base::Double& horizontalFaceSurface);
364  static double getAreaFromTop(pConstShape shape);
365  // Returns area of the largest face of the shape
366  static double getLargestFaceArea(pConstShape shape);
368  static pShape copy(pConstShape shape, bool deepCopy = true);
370  static App::Element* makeDbgElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color = Base::Color(204, 204, 204));
372  static App::SubElement* makeDbgSubElementFromShape(Core::CoreDocument* doc,
373  pConstShape shape,
374  const Base::Color& color = Base::Color(204, 204, 204));
377  static pMesh triangulationToMesh(pConstShape shape);
379  static bool isFaceted(pConstTopologicalItem shape);
381  static bool hasVoids(pConstTopologicalItem shape);
383  static pShape mergePlanarFaces(pConstShape shape);
385  static bool convertToPolygonalFaces(pConstShape shape, std::vector<pFace>& polyFaces, bool precise = false);
387  static bool hasNurbsFace(pConstShape shape);
389  static bool hasTriangulation(pConstShape shape);
391  static pConstVertex getClosestVertexToPoint(pConstTopologicalItem item, const Geom::Pnt& p);
396  static bool hasFaces(pConstShape shape, bool& allSubShapesHaveFaces);
398  static std::vector<pShape> getShapesFromAcisFile(const Base::String& fileName, double scaleFactor = 1., std::function<int(int)> callback = 0);
400  static pShape importBrep(Base::String filename);
402  static pShape extrudedWire(pConstWire wire, const Geom::Dir& extrudedDirection, double depth, double precision);
404  static pShape thickenSheets(pConstShape shape, double thickness, bool doubleSided = false, Base::String& errorInfo = Base::String());
406  static pShape deformed(pConstShape shape, const Geom::GTrsf& t, const Geom::Pnt& p);
408  static pShape mirrored(pConstShape shape, const Geom::Ax2& ax);
410  static Topo::ToolOutcome clash(pConstShape shape1, pConstShape shape2, bool& hasClash);
412  static Topo::ToolOutcome clashBodies(pConstShape shape1,
413  pConstShape shape2,
414  Topo::BodyClashType& clashType,
417  static pConstWire isSingleWire(pConstShape shape);
419  static pConstFace isSingleFace(pConstShape shape);
421  static pConstEdge isSingleEdge(pConstShape shape);
423  static pConstVertex isSingleVertex(pConstShape shape);
425  static bool isShell(pConstShape shape);
427  static bool isOpenShell(pConstShape shape);
429  static bool isClosedShell(pConstShape shape);
431  static bool isClosedSolid(pConstShape shape);
433  static bool isWire(pConstShape shape);
435  static bool isCompound(pConstShape shape);
437  static bool isMesh(pConstShape shape);
439  static bool isVertex(pConstShape shape);
441  static bool isExtrudedAreaSolid(pConstShape aShape,
442  Geom::Ax2& aPosition,
443  double& aLength,
444  pConstFace& aProfile,
445  BuildingElementHintEnum aHint = BuildingElementHintEnum::NO_HINT);
447  static bool isCylinder(pConstShape shape, Geom::Ax2& position, double& length, double& radius);
448 
450  static bool getAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int& value);
452  static bool setAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int value);
454  static bool removeAttribute(pConstTopologicalItem shape, const Base::String& name);
456  static bool getAttributeString(pConstTopologicalItem shape, const Base::String& name, Base::String&);
458  static bool setAttributeString(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
460  static bool setAttributeStringNonCopy(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
462  static size_t getAttributeCount(pConstTopologicalItem shape);
464  static bool setCdwkSATAttributes(pConstShape shape, const Topo::Cdwk_SAT_Attributes& att);
466  static void releaseCdwkSATAttributes(pConstShape shape);
467 
469  static bool cleanupShape(pShape shape);
470 
471  static bool hasSliverFaces(pConstShape shape);
472  static pShape removedSliverFaces(pConstShape shape, double aTolerance = -1);
473 
475  static bool imprint(pShape base, pShape tool);
476 
478  static Topo::ToolOutcome rayPick(const std::vector<pConstTopologicalItem>& targets, const CA_Ray& ray, Topo::RayHitVector& found);
480  static void removeFaceting(pConstTopologicalItem item);
482  static bool getColorRGB(pConstShape shape, int& r, int& g, int& b);
483 
484  template <class _InputIterator, class _Function>
485  static void do_parallel(_InputIterator first, _InputIterator last, _Function fn)
486  {
487  while (first != last)
488  {
489  fn(*first);
490  ++first;
491  }
492  }
493 
494  static pShape skinning(Base::String& errorInfo,
495  const Topo::SkinningOptions& skinOptions,
496  const double& precision = Geom::Precision::linear_Resolution());
497  static pShape sweeping(Base::String& errorInfo, const Topo::SweepingOptions& sweepOptions);
498 
500  static double getModelingTolerance();
501  static Topo::ThreadPool* getThreadPool();
502  static void transformShape2LocalSpaceOfElement(App::Element* elem, pShape shape);
503  static bool hasPolyHedral();
504  static bool getModelFromPolyHedral(pShape shape, std::vector<int>& model, std::vector<Geom::Pnt>& vertices);
505  static pShape makePolyHedral(const std::vector<int>& model,
506  const std::vector<Geom::Pnt>& vertices,
507  bool checkShape,
508  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
509  static bool is_polyhedral_body(BODY const* iBody);
510 
512  // //
513  // ---------------------- END API ---------------------- //
514  // //
516 
517 #ifndef LXAPI // INTERFACES BELOW ARE -NOT- PART OF THE LEXOCAD API
518 
519  static std::vector<Geom::Pnt> getIntersectionPoints(pConstShape shape, const std::vector<pConstShape> shapes);
520  static std::vector<Geom::Pnt> getAllIntersectionPoints(const std::vector<pConstShape> shapes);
521  static void getAllIntersectionPointsIn2DMode(const std::vector<pConstShape>& shapes,
522  const Geom::Pnt& pnt,
523  const double& distance,
524  std::vector<Geom::Pnt>& intersectionPoints);
525  static void getAllIntersectionPointsWithLineIn2DMode(const std::vector<pConstShape>& shapes,
526  const Geom::Pnt& linePnt1,
527  const Geom::Pnt& linePnt2,
528  std::vector<Geom::Pnt>& intersectionPoints);
529  // convenience method
530  static void getAllIntersectionPointsWithLineIn2DMode(pConstShape shape,
531  const Geom::Pnt& linePnt1,
532  const Geom::Pnt& linePnt2,
533  std::vector<Geom::Pnt>& intersectionPoints);
534 
535  static pShape createShell(pConstShape shape);
536  static pShape createSheet(pConstShape shape, bool doubleSided);
537  static std::vector<pShape> splitLumps(pConstShape shape);
539  static bool makeShapes(const std::vector<pFace>& faces, std::vector<pShape>& shapes, double precision = Geom::Precision::linear_Resolution());
540 
542  static Topo::ToolOutcome createElementFromShape(Core::CoreDocument* doc, pConstShape shape, App::Element*& newElement, App::Element* sample = 0);
543  static size_t getShapeCount();
544  static void shapeCountInc();
545  static void shapeCountDec();
547  static bool getBoundingBoxSizes(pConstTopologicalItem item, Geom::XYZ& sizes); //
548  static pShape simplifyShape(pConstShape shape, const SimplifyOptions& opts);
549  static pShape offsetShape(pConstShape shape, double offset);
550  static void debugShape(pConstShape shape, int checkLevel, ShapeInfo& info);
551  static bool isManifold(pConstShape shape);
552  static bool restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
553  static int getFaceIndexByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
554  static std::vector<int> getFaceIndexesByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
555 
556  static void getFacesByMaxNormalToVectorAngle(pConstShape aShape,
557  std::map<int, Geom::Vec> aDirectionsToSortBy,
558  std::map<int, std::vector<pConstFace> >& aFacesListMap,
559  float aMaxAngleRad = 0.75);
561  static bool getTopoDS_Shape(pConstTopologicalItem shape, TopoDS_Shape& topoShape);
562 
565  static void __setOCCShapeTool__(Topo::ShapeTool* tool) { _occTool = tool; }
567  static void __setAcisShapeTool__(Topo::ShapeTool* tool) { _acisTool = tool; }
569  static void __setDefaultShapeTool__(Topo::ShapeTool* tool) { _defaultTool = tool; }
571  static void __setInventorShapeTool__(Topo::ShapeTool* tool) { _inventorTool = tool; }
573  static void __setOMFShapeTool__(Topo::ShapeTool* tool) { _omfTool = tool; }
575  static void __setAcisMeshShapeTool__(Topo::ShapeTool* tool) { _acisMeshShapeTool = tool; }
577  static pConstShape getFirstShape_Helper(App::Element* elem);
578 
579 protected:
581  static ENTITY* getAcisEntity(pConstTopologicalItem item);
582 
583  virtual pShape _makeShape(pVertex vertex);
584  virtual pShape _makeShape(pEdge edge);
585  virtual pShape _makeShape(pWire wire, double precision);
586  virtual pShape _makeShape(pFace face);
587  virtual pShape _makeShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
588  virtual pShape _makeShape(BODY* aBody);
589  virtual pShape _makeLazyFacetedBrepShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
590  virtual pShape _makeInventorMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
591  virtual pShape _makeInventorMeshShape(pIndexedMesh p);
592  virtual pIndexedMesh _makeIndexedMesh(pConstBrepData data, std::vector<PNTS>& defectPolygons, bool createEdges = false);
593  virtual pIndexedMesh _makeIndexedMesh(pConstShape input, bool createEdges = false);
594  virtual pShape _makeOMFMeshShape(pConstBrepData data, std::vector<PNTS>& defectPolygons);
595  virtual pShape _makeAcisShape(pShape input);
596  virtual bool _createBrepData(pConstShape input, pBrepData data);
597  virtual pShape _makeShape(const std::vector<pFace>& faces, double tolerance);
598  virtual bool _makeShapes(const std::vector<pFace>& faces, std::vector<pShape>& shapes, double precision);
599  virtual pShape _makeShape(const std::vector<int>& model,
600  const std::vector<Geom::Pnt>& vertices,
601  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
602  virtual bool _makeShapes_parallel(const std::vector<pConstBrepData>& breps, std::map<pConstBrepData, pShape>& shapes);
603  virtual pShape _makeFaceSet(const std::vector<pFace>& faces);
604  virtual pShape _makeFaceSet(pConstBrepData data);
605  virtual pShape _makeCompound(const std::vector<pConstShape>& shapes);
606  virtual int _getFaceCount(pConstTopologicalItem item);
607  virtual int _getWireCount(pConstTopologicalItem item);
608  virtual int _getEdgeCount(pConstTopologicalItem item);
609  virtual int _getVertexCount(pConstTopologicalItem item);
610  virtual int _getLumpsCount(pConstTopologicalItem item);
611  virtual int _getPolygonCount(pConstTopologicalItem item, Topo::ShapeTessellationQuality quality);
612  virtual pShape _makeShape(Core::DocObject* curve, double startParam, double endParam);
613 
614  virtual pConstFace _getFaceByIndex(pConstTopologicalItem item, int idx);
615  virtual pConstWire _getWireByIndex(pConstTopologicalItem item, int idx);
616  virtual pConstEdge _getEdgeByIndex(pConstTopologicalItem item, int idx);
617  virtual pConstVertex _getVertexByIndex(pConstTopologicalItem item, int idx);
618 
619  virtual std::vector<pConstFace> _getFaces(pConstTopologicalItem item);
620  virtual std::vector<pConstWire> _getWires(pConstTopologicalItem item);
621  virtual std::vector<pConstEdge> _getEdges(pConstTopologicalItem item);
622  virtual std::vector<pConstEdge> _getAllEdges(pConstTopologicalItem item);
623  virtual std::vector<pConstVertex> _getVertices(pConstTopologicalItem item);
624 
625 
626  virtual int _getIndexFromFace(pConstTopologicalItem item, pConstFace face);
627  virtual std::vector<int> _getIndexesFromFaces(pConstTopologicalItem item, const std::vector<pConstFace> faces);
628  virtual int _getIndexFromWire(pConstTopologicalItem item, pConstWire wire);
629  virtual int _getIndexFromEdge(pConstTopologicalItem item, pConstEdge edge);
630  virtual int _getIndexFromVertex(pConstTopologicalItem item, const Geom::Pnt& v);
631  virtual int _getIndexFromVertex(pConstTopologicalItem item, pConstVertex vtx);
632 
633  virtual std::vector<int> _getAdjacentFaceIndicesFromVertexIndex(pConstTopologicalItem item, int vertexIdx);
634  virtual std::vector<pConstFace> _getAdjacentFacesFromEdge(pConstTopologicalItem item, pConstEdge edge);
635  virtual void _getVerticesAsPoints(pConstTopologicalItem item, std::vector<Geom::Pnt>& vertices);
636  virtual Geom::Bnd_Box _getBoundingBox(pConstTopologicalItem item);
637 
638  virtual Geom::Trsf _getTransform(pConstShape shape);
639  virtual bool _calculateDetail(pConstShape shape, CA_Detail& detail, const CA_Snap& snap);
640 
641  virtual pSolid _cast2Solid(pShape shape);
642  virtual pCompound _cast2Compound(pShape shape);
643  virtual pMesh _cast2Mesh(pShape shape);
644  virtual pConstSolid _cast2ConstSolid(pConstShape shape);
645  virtual pConstCompound _cast2ConstCompound(pConstShape shape);
646  virtual pConstMesh _cast2ConstMesh(pConstShape shape);
647 
648  virtual double _getVolume(pConstTopologicalItem item);
649  virtual bool _getCentroid(pConstTopologicalItem item, Geom::Pnt& centroid);
650  virtual void _setNeedMassUpdate(pConstShape shape, bool on);
651  virtual bool _write(pConstShape shape, std::ostream& writer);
652  virtual bool _write(pConstShape shape, Base::AbstractWriter& writer);
653 
654  virtual std::string _getWriteFormat(pConstShape shape);
655 
656  virtual bool _write(const std::string& format, pConstShape shape, const Base::String& fileName);
657  virtual bool _write(const std::string& format, std::vector<pConstShape> shapes, const Base::String& fileName);
658  virtual bool _writeAcisFile(std::vector<pConstShape> shapes,
659  const Base::String& fileName,
660  bool isText,
661  int major_version,
662  int minor_version,
663  double scale);
664  virtual bool _appendAcisFile(std::vector<pConstShape> shapes,
665  const Base::String& fileName,
666  bool isText,
667  int major_version,
668  int minor_version,
669  double scale);
670  virtual bool _canWriteAs(const std::string& format, pConstShape shape);
671  virtual bool _intersectBBoxes(pConstShape shape1, pConstShape shape2);
672 
673  virtual pShape _cut(pConstShape base, pConstShape tool, bool* ok);
674  virtual pShape _cut(pConstShape base, const std::vector<pConstShape> tools, bool* ok);
675  virtual pShape _fuse(pConstShape base, pConstShape tool, bool* ok);
676  virtual bool _imprint(pShape base, pShape tool);
677  virtual pShape _common(pConstShape base, pConstShape tool, bool* ok);
678  virtual pShape _section(pConstShape base, pConstShape tool, bool* ok);
679  virtual pShape _s_cut(pConstShape base, pConstShape tool);
680  virtual pShape _s_common(pConstShape base, pConstShape tool);
681  virtual pShape _cutWithPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
682  virtual pShape _splitByPlane(pConstShape aBlank, const Geom::Pln& aPlane, bool* ok = 0);
683 
684  virtual pShape _transformed(pConstShape base, const Geom::Trsf& t);
685  virtual pShape _scaled(pConstShape base, const Geom::XYZ& scale);
686  virtual bool _isValid(pConstShape shape, int checkLevel);
687  virtual bool _isValid(pConstFace face, int checkLevel);
688  virtual bool _isValid(pConstWire wire, int checkLevel);
689  virtual bool _isValid(pConstVertex vertex, int checkLevel);
690  virtual bool _isValid(pConstEdge edge, int checkLevel);
691  virtual bool _isValid(pShape shape, int checkLevel);
692  virtual bool _isValid(pFace face, int checkLevel);
693  virtual bool _isValid(pWire wire, int checkLevel);
694  virtual bool _isValid(pVertex vertex, int checkLevel);
695  virtual bool _isValid(pEdge edge, int checkLevel);
696  virtual bool _isValidInCadwork3d(pConstTopologicalItem shape);
697  virtual bool _isEqual(pConstTopologicalItem item1, pConstTopologicalItem item2);
698  virtual bool _cleanupShape(pShape shape);
699 
700  virtual Topo::GeometricInformation _getGeometricInformation(pConstTopologicalItem shape);
701  virtual void _getAxesOrientedSurfaces(pConstShape shape, double& XYSurface, double& XZSurface, double& YZSurface);
702  virtual void _getVerticalAndHorizontalFaceAreas(pConstShape shape,
703  double& verticalFaceSurface,
704  std::list<double>& verticalFaceSurfaces,
705  double& verticalLargestFaceSurface,
706  double& horizontalFaceSurface);
707  virtual double _getAreaFromTop(pConstShape shape);
708  virtual pShape _copy(pConstShape shape, bool deepCopy);
709  virtual App::Element* _makeDbgElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color);
710  virtual App::SubElement* _makeDbgSubElementFromShape(Core::CoreDocument* doc, pConstShape shape, const Base::Color& color);
711  virtual bool _getTopoDS_Shape(pConstTopologicalItem shape, TopoDS_Shape& topoShape);
712  virtual bool _isFaceted(pConstTopologicalItem shape);
713  virtual bool _hasVoids(pConstTopologicalItem shape);
714  virtual pShape _mergePlanarFaces(pConstShape shape);
715  virtual bool _convertToPolygonalFaces(pConstShape shape, std::vector<pFace>& polyFaces, bool precise = false);
716 
717  virtual pShape _extrudedWire(pConstWire wire, const Geom::Dir& extrudedDirection, double depth, double precision);
718  virtual std::vector<Geom::Pnt> _getIntersectionPoints(pConstShape shape, const std::vector<pConstShape> shapes);
719  virtual std::vector<Geom::Pnt> _getAllIntersectionPoints(const std::vector<pConstShape> shapes);
720  virtual bool _hasTriangulation(pConstShape shape);
721  virtual pShape _createShell(pConstShape shape);
722  virtual pShape _createSheet(pConstShape shape, bool doubleSided);
723 
724  virtual std::vector<pShape> _splitLumps(pConstShape shape);
725 
726  virtual bool _hasFaces(pConstShape shape, bool& allSubShapesHaveFaces);
727  virtual bool _isNull(pConstShape shape);
728  virtual pShape _deformed(pConstShape shape, const Geom::GTrsf& t, const Geom::Pnt& p);
729  virtual std::vector<pShape> _getShapesFromAcisFile(const Base::String& fileName, double scaleFactor = 1., std::function<int(int)> callback = 0);
730  virtual pShape _importBrep(Base::String filename);
731  virtual pShape _mirrored(pConstShape shape, const Geom::Ax2& ax);
732  virtual Topo::ToolOutcome _clash(pConstShape shape1, pConstShape shape2, bool& hasClash);
733  virtual Topo::ToolOutcome _clashBodies(pConstShape shape1,
734  pConstShape shape2,
735  Topo::BodyClashType& clashType,
737  virtual std::vector<VisibleEdge> _getEdges_visible(std::vector<pConstShape> shapes,
738  const Geom::Pnt& cam_position,
739  const Geom::Pnt& cam_target,
740  bool cam_perspective = true);
741  virtual Topo::ToolOutcome _createElementFromShape(Core::CoreDocument* doc,
742  pConstShape shape,
743  App::Element*& newElement,
744  App::Element* sample = 0);
745  virtual bool _getAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int& value);
746  virtual bool _setAttributeInteger(pConstTopologicalItem shape, const Base::String& name, int value);
747  virtual bool _removeAttribute(pConstTopologicalItem shape, const Base::String& name);
748  virtual Topo::ToolOutcome _rayPick(const std::vector<pConstTopologicalItem>& targets, const CA_Ray& ray, Topo::RayHitVector& found);
749  virtual void _removeFaceting(pConstTopologicalItem item);
750  virtual bool _getColorRGB(pConstShape shape, int& r, int& g, int& b);
751  virtual pShape _simplifyShape(pConstShape shape, const SimplifyOptions& opts);
752  virtual pShape _offsetShape(pConstShape shape, double offset);
753  virtual pShape _thickenSheets(pConstShape shape, double thickness, bool doubleSided, Base::String& errorInfo);
754 
755  virtual pShape _skinning(Base::String& errorInfo, const Topo::SkinningOptions&, const double&)
756  {
757  errorInfo = L"Not implemented";
758  return nullptr;
759  }
760  virtual pShape _sweeping(Base::String& errorInfo, const Topo::SweepingOptions&)
761  {
762  errorInfo = L"Not implemented";
763  return nullptr;
764  }
765 
766  virtual double _getModelingTolerance();
767  virtual void _debugShape(pConstShape shape, int checkLevel, Topo::ShapeInfo& info);
768  virtual bool _isManifold(pConstShape shape);
769  virtual bool _restoreGlobalAttachment(Base::GlobalAttachment* gAtta, std::istream*, uint64_t streamsize, const Base::String& entryName);
770 
771  virtual bool _getAttributeString(pConstTopologicalItem shape, const Base::String& name, Base::String&);
772  virtual bool _setAttributeString(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
773  // Don't copy attribute at Copy/Slip/Merge
774  virtual bool _setAttributeStringNonCopy(pConstTopologicalItem shape, const Base::String& name, const Base::String&);
775  virtual size_t _getAttributeCount(pConstTopologicalItem shape);
776  virtual int _getFaceIndexByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
777  virtual std::vector<int> _getFaceIndexesByPointOnFace(pConstTopologicalItem shape, const Geom::Pnt& p);
778 
779  virtual Topo::ThreadPool* _getThreadPool();
780  virtual bool _setCdwkSATAttributes(pConstShape shape, const Topo::Cdwk_SAT_Attributes& att);
781  virtual void _releaseCdwkSATAttributes(pConstShape shape) {}
782  virtual void _transformShape2LocalSpaceOfElement(App::Element* elem, pShape shape);
783  virtual pShape _removedSliverFaces(pConstShape aShape, double aTolerance);
784  virtual bool _hasSliverFaces(pConstShape shape);
785 
786  virtual bool _hasPolyHedral();
787  virtual bool _getModelFromPolyHedral(pShape shape, std::vector<int>& model, std::vector<Geom::Pnt>& vertices);
788  virtual pShape _makePolyHedral(const std::vector<int>& model,
789  const std::vector<Geom::Pnt>& vertices,
790  bool checkShape,
791  std::vector<std::vector<Geom::Pnt> >& defectPolygons);
792  virtual bool _is_polyhedral_body(BODY const* iBody);
793 
794 #endif
795 private:
796  static bool _hasSameShapeTool(pConstTopologicalItem shape1, pConstTopologicalItem shape2);
797  static Topo::ShapeTool* getShapeTool(pConstTopologicalItem item);
798 
799  static Topo::ShapeTool* _acisTool;
800  static Topo::ShapeTool* _occTool;
801  // static Topo::ShapeTool* _carveTool;
802  static Topo::ShapeTool* _defaultTool;
803  static Topo::ShapeTool* _inventorTool;
804  static Topo::ShapeTool* _omfTool;
805  static Topo::ShapeTool* _acisMeshShapeTool;
806 
807  static size_t _shapeCount;
809 };
810 
811 
812 
813 } // namespace Topo
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:98
Definition: Shape.h:147
std::shared_ptr< Topo::Solid const > pConstSolid
Definition: Shape.h:95
CoreDocument()
std::shared_ptr< Topo::Solid > pSolid
Definition: Shape.h:80
Definition: Color.h:47
std::shared_ptr< Topo::Compound > pCompound
Definition: Shape.h:79
Definition: Pln.h:59
BuildingElementHintEnum
Definition: ShapeTool.h:113
#define TOPO_EXPORT
Definition: topo_defines.h:8
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
std::shared_ptr< Topo::Vertex > pVertex
Definition: Shape.h:86
std::shared_ptr< Topo::Edge const > pConstEdge
Definition: Shape.h:99
std::shared_ptr< Topo::TopologicalItem const > pConstTopologicalItem
Definition: Shape.h:90
static const double linear_Resolution()
Definition: Precision.h:26
Core::PropertyText name
Definition: CoreDocument.h:143
Definition: ShapeInfo.h:8
Definition: Shape.h:694
Definition: FaceTool.h:24
std::shared_ptr< Topo::Face const > pConstFace
Definition: Shape.h:97
std::shared_ptr< Geom::BrepData > pBrepData
Definition: BrepData.h:34
Definition: Bnd_Box.h:66
std::shared_ptr< Topo::Face > pFace
Definition: Shape.h:82
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:29
LX_CORE_EXPORT Version & version
Definition: Double.h:8
Definition: CoreDocument.h:197
Tools for creating, manipulating and querying Shapes.
Definition: ShapeTool.h:86
Definition: GeometricInformation.h:8
std::vector< RayHit > RayHitVector
Definition: RayHit.h:45
Definition: Ax2.h:69
Definition: XYZ.h:46
std::shared_ptr< Topo::Shell const > pConstShell
Definition: Shape.h:96
Definition: SimplifyOptions.h:7
Definition: Trsf.h:58
Definition: Dir.h:46
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:37
Core::PropertyText filename
Definition: CoreDocument.h:151
Definition: Base.h:19
std::shared_ptr< Geom::IndexedMesh > pIndexedMesh
Definition: IndexedMesh.h:59
std::shared_ptr< Topo::MeshShape > pMesh
Definition: Shape.h:78
Definition: Variant.h:70
static void do_parallel(_InputIterator first, _InputIterator last, _Function fn)
Definition: ShapeTool.h:485
Definition: ShapeAttributes.h:24
Definition: NurbsOptions.h:192
Definition: GlobalAttachment.h:11
std::shared_ptr< Topo::Vertex const > pConstVertex
Definition: Shape.h:101
Definition: NurbsOptions.h:18
Definition: Writer.h:27
std::shared_ptr< Topo::Compound const > pConstCompound
Definition: Shape.h:94
Definition: GTrsf.h:49
std::shared_ptr< Topo::Wire > pWire
Definition: Shape.h:83
BodyClashType
Definition: Clash.h:5
Definition: ThreadTask.h:36
std::shared_ptr< Topo::Shape const > pConstShape
Definition: Variant.h:81
std::shared_ptr< Topo::MeshShape const > pConstMesh
Definition: Shape.h:93
ClashMode
Definition: Clash.h:17
Base::String fileName
Definition: CoreDocument.h:161
virtual bool restoreGlobalAttachment(Base::GlobalAttachment *gAtta, std::istream *, uint64_t streamsize, const Base::String &entryName)
Definition: DocObject.h:28
std::shared_ptr< Topo::Shape > pShape
Definition: Variant.h:80
std::shared_ptr< Topo::Edge > pEdge
Definition: Shape.h:84