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