OpenLexocad  27.0
BrepData.h
Go to the documentation of this file.
1 #pragma warning(disable : 4251)
2 
3 #pragma once
4 
5 #include <Geom/Dir.h>
6 #include <Geom/GeomEnums.h>
7 #include <Geom/Pnt.h>
9 #include <Geom/Precision.h>
10 #include <Geom/geom_defines.h>
11 
12 #include <map>
13 #include <memory>
14 #include <vector>
15 
16 namespace Core
17 {
18 class PropertyBrepData;
19 class PropertyBrepDataSet;
20 } // namespace Core
21 
22 namespace Topo
23 {
24 class FaceTool;
25 }
26 
27 namespace Geom
28 {
29 class BrepLoop;
30 class BrepFace;
31 class BrepData;
32 } // namespace Geom
33 
34 typedef std::shared_ptr<Geom::BrepData> pBrepData;
35 typedef std::shared_ptr<Geom::BrepFace> pBrepFace;
36 typedef std::shared_ptr<Geom::BrepFace> pBrepLoop;
37 typedef std::shared_ptr<const Geom::BrepData> pConstBrepData;
38 typedef std::shared_ptr<const Geom::BrepFace> pConstBrepFace;
39 typedef std::shared_ptr<const Geom::BrepLoop> pConstBrepLoop;
40 
41 GEOM_EXPIMP_TEMPLATE template class GEOM_EXPORT std::weak_ptr<const Geom::BrepData>;
42 GEOM_EXPIMP_TEMPLATE template class GEOM_EXPORT std::weak_ptr<const Geom::BrepFace>;
43 GEOM_EXPIMP_TEMPLATE template class GEOM_EXPORT std::enable_shared_from_this<const Geom::BrepData>;
44 GEOM_EXPIMP_TEMPLATE template class GEOM_EXPORT std::enable_shared_from_this<const Geom::BrepFace>;
45 
46 namespace Geom
47 {
48 class BrepFaceP;
49 class BrepLoopP;
50 class BrepDataP;
51 
52 class GEOM_EXPORT BrepEdge : public std::enable_shared_from_this<const Geom::BrepEdge>
53 {
54 public:
55 };
56 
58 {
59 public:
60  int from = -1;
61  int to = -1;
62 };
63 
65 {
66 public:
67  int center = -1;
68  double radius = 0;
69  double trim1 = 0;
70  double trim2 = 0;
71  bool sense = true;
72 };
73 
74 class GEOM_EXPORT BrepFace : public std::enable_shared_from_this<const Geom::BrepFace>
75 {
76 public:
77  BrepFace(pConstBrepData elem, int idx, size_t itPos);
78  virtual ~BrepFace();
79  std::vector<int> getModel() const;
80  bool getFaceNormal(Geom::Dir& normal, Geom::Pnt& pntOnFace) const;
81  pConstBrepLoop getOuterLoop() const;
82  std::vector<pConstBrepLoop> getInnerLoops() const;
83  pConstBrepData getElement() const;
84 
85 private:
86  BrepFaceP* _pimpl = nullptr;
87  BrepFace() {}
88 };
89 
91 {
92 public:
93  BrepLoop(pConstBrepFace face, const std::vector<int>& model);
94  virtual ~BrepLoop();
95  void getPolygon(std::vector<Geom::Pnt>& poly) const;
96  std::vector<const Geom::Pnt*> getPolygonPtr() const;
97  const std::vector<int>& getModel() const;
98 
99 private:
100  BrepLoop() {}
101  BrepLoopP* _pimpl = nullptr;
102 };
103 
122 class GEOM_EXPORT BrepData : public std::enable_shared_from_this<const Geom::BrepData>
123 {
124 public:
126  // //
127  // --------------------- BEGIN API --------------------- //
128  // //
129  // ATTENTION: DO NOT CHANGE ANY SIGNATURES IN THE API ! //
130  // //
132 
135  friend class BrepFace;
136  friend class BrepLoop;
137  friend class Topo::FaceTool;
138 
139 
140  BrepData();
141  BrepData(double tolerance);
142  ~BrepData(void);
143 
144  BrepData::BrepData(const BrepData& p);
145  BrepData(const std::vector<Geom::Pnt>& baseFace, const Geom::Vec& extrude);
146 
147  std::vector<Geom::Pnt> getPoints() const;
148  int64_t getUniquePointsCnt() const;
149  std::vector<int> getModel() const;
150  void setModel(const std::vector<int>& model);
151 
152  bool checkLoop(const std::vector<int>& model) const;
153  bool hasDegeneratedLoops() const;
154 
156  void add(pConstBrepData data);
158  int addUniquePoint(const Geom::Pnt& p);
160  int addModelIndex(int idx);
162  int getModelIndexAt(int idx) const;
164  const Geom::Pnt* getPointAt(int idx) const;
166  bool hasPoint(const Geom::Pnt& p);
168  void setEmpty();
169 
171  bool isEmpty() const;
173  int getFaceCount() const;
174 
176  std::vector<pConstBrepFace> getFaces() const;
178  double getModelingTolerance() const { return _tolerance; }
180  bool hasVoids() const;
182  void reverse();
184  void lock();
186  void unlock();
187 
188  Geom::BrepData& operator=(const Geom::BrepData& rhs);
189  bool operator==(const Geom::BrepData& other) const;
190  bool operator!=(const Geom::BrepData& other) const;
191 
192  void addFace(std::vector<int> index);
193 
195  // //
196  // ---------------------- END API ---------------------- //
197  // //
199 
200  int64_t addUniquePointCheckIsNew(const Geom::Pnt& p, bool& r_is_new);
201 
202  void transform(const Geom::Trsf& T);
204  Geom::BrepData transformed(const Geom::Trsf& T) const;
205 
206  void dump();
208  void _addPointAtIndex(const Geom::Pnt& p, int idx);
209 
210 private:
212  // pConstBrepFace getFace(int idx) const;
213 
214  // BrepDataPimp* _private;
215 
216 
217 #ifdef _MSC_VER
218 #pragma warning(disable : 4251)
219 #endif
220  Geom::PointMapWithTolerance uniquePoints;
221  std::vector<int> model;
222  int highestIndex;
223  double _tolerance;
224 
225  BrepDataP* _pimpl;
226 };
227 
228 
229 
230 } // namespace Geom
Definition: Rotation.h:5
Definition: PointMapWithTolerance.h:10
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
friend class BrepFace
Definition: BrepData.h:135
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
std::shared_ptr< Geom::BrepData > pBrepData
Definition: BrepData.h:34
#define GEOM_EXPORT
Definition: geom_defines.h:8
friend class BrepLoop
Definition: BrepData.h:136
std::shared_ptr< const Geom::BrepFace > pConstBrepFace
Definition: BrepData.h:38
std::shared_ptr< Geom::BrepFace > pBrepFace
Definition: BrepData.h:35
std::shared_ptr< Geom::BrepFace > pBrepLoop
Definition: BrepData.h:36
Definition: Trsf.h:58
Definition: Dir.h:46
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:37
The BrepData class holds the boundary representation of a FacetedBrep in the form of a model descript...
Definition: BrepData.h:122
Definition: Base.h:19
std::shared_ptr< const Geom::BrepLoop > pConstBrepLoop
Definition: BrepData.h:39
Definition: Variant.h:70
#define GEOM_EXPIMP_TEMPLATE
Definition: geom_defines.h:9
Definition: BrepData.h:57
Defines a non-persistent vector in 3D space.
Definition: Vec.h:45
Tools for creating, manipulating and querying Faces.
Definition: FaceTool.h:50
Definition: BrepData.h:74
Definition: BrepData.h:52
Definition: BrepData.h:64
double getModelingTolerance() const
Returns the modeling tolerance of the Brep.
Definition: BrepData.h:178
Definition: PropertyBrepData.h:40
Definition: BrepData.h:90
Definition: PropertyBrepData.h:13