OpenLexocad  28.0
BrepData.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <memory>
5 
6 namespace Core
7 {
8 class PropertyBrepData;
9 class PropertyBrepDataSet;
10 } // namespace Core
11 
12 namespace Topo
13 {
14 class FaceTool;
15 }
16 
17 namespace Geom
18 {
19 class BrepLoop;
20 class BrepFace;
21 class BrepData;
22 class Dir;
23 class Pnt;
24 class Vec;
25 class Trsf;
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;
76  std::vector<pConstBrepLoop> getInnerLoops() 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 
135  BrepData(double tolerance);
136  ~BrepData(void);
137 
138  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 
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);
201 
202  void dump();
204  void _addPointAtIndex(const Geom::Pnt& p, int idx);
205 
206 private:
207  Geom::PointMapWithTolerance uniquePoints;
208  std::vector<int> model;
209  int highestIndex;
210  double _tolerance;
211 
212  BrepDataP* _pimpl;
213 };
214 
215 
216 
217 } // namespace Geom
Geom::BrepData::getFaceCount
int getFaceCount() const
Returns the number of faces in the Brep.
Geom::BrepData::getHash
size_t getHash() const
pConstBrepFace
std::shared_ptr< const Geom::BrepFace > pConstBrepFace
Definition: BrepData.h:32
Geom::BrepData::getPoints
std::vector< Geom::Pnt > getPoints() const
Geom::BrepData::operator!=
bool operator!=(const Geom::BrepData &other) const
Geom::BrepData::BrepFace
friend class BrepFace
Definition: BrepData.h:129
Geom::BrepData::hasVoids
bool hasVoids() const
Checks if the BrepData has voids (holes)
Geom::BrepFace::BrepFace
BrepFace(pConstBrepData elem, int idx, size_t itPos)
Geom::BrepData::BrepData
BrepData()
Geom::BrepData::setModel
void setModel(const std::vector< int > &model)
pBrepData
std::shared_ptr< Geom::BrepData > pBrepData
Definition: BrepData.h:28
Geom::BrepFace
Definition: BrepData.h:69
Geom::BrepData::dump
void dump()
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
Geom::BrepFace::getOuterLoop
pConstBrepLoop getOuterLoop() const
Geom::BrepFace::~BrepFace
virtual ~BrepFace()
pBrepFace
std::shared_ptr< Geom::BrepFace > pBrepFace
Definition: BrepData.h:29
Geom::BrepData::addModelIndex
int addModelIndex(int idx)
Adds a model index and returns the position of the point.
Geom::BrepLoop::~BrepLoop
virtual ~BrepLoop()
Core::PropertyBrepDataSet
Definition: PropertyBrepData.h:38
Geom::BrepData::reverse
void reverse()
Reverses the orientation of all faces.
Geom::BrepData::setEmpty
void setEmpty()
Sets the data structure empty.
Geom::Dir
Definition: Dir.h:45
Geom::BrepLoop::BrepLoop
BrepLoop(pConstBrepFace face, const std::vector< int > &model)
Geom::BrepData::checkLoop
bool checkLoop(const std::vector< int > &model) const
Geom::BrepData
The BrepData class holds the boundary representation of a FacetedBrep in the form of a model descript...
Definition: BrepData.h:117
Geom::BrepData::isEmpty
bool isEmpty() const
Checks if the data structure is empty.
Geom::BrepData::~BrepData
~BrepData(void)
Geom::BrepData::getUniquePointsCnt
int64_t getUniquePointsCnt() const
Topo::FaceTool
Tools for creating, manipulating and querying Faces.
Definition: FaceTool.h:59
Geom::BrepData::addFace
void addFace(std::vector< int > index)
Geom::BrepData::addUniquePointCheckIsNew
int64_t addUniquePointCheckIsNew(const Geom::Pnt &p, bool &r_is_new)
Geom::BrepData::transformed
Geom::BrepData transformed(const Geom::Trsf &T) const
Transforms a vector with the transformation T.
Core
Definition: Base.h:5
Geom::BrepLoop::getPolygon
void getPolygon(std::vector< Geom::Pnt > &poly) const
Geom::BrepData::hasDegeneratedLoops
bool hasDegeneratedLoops() const
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Geom::BrepData::BrepData
BrepData(const std::vector< Geom::Pnt > &baseFace, const Geom::Vec &extrude)
Geom::BrepData::add
void add(pConstBrepData data)
Adds BrepData to this BrepData.
Geom::BrepLoop
Definition: BrepData.h:85
Geom::BrepFace::getModel
std::vector< int > getModel() const
Geom::BrepLoop::getModel
const std::vector< int > & getModel() const
Geom::BrepFace::getInnerLoops
std::vector< pConstBrepLoop > getInnerLoops() const
pConstBrepData
std::shared_ptr< const Geom::BrepData > pConstBrepData
Definition: BrepData.h:31
Topo
Definition: DbgInfo.h:17
Geom::BrepData::operator=
Geom::BrepData & operator=(const Geom::BrepData &rhs)
Geom::BrepData::_addPointAtIndex
void _addPointAtIndex(const Geom::Pnt &p, int idx)
Adds a point at position 'idx'. This is only for fast restoring of saved data. For internal use.
Geom::BrepData::getPointAt
const Geom::Pnt * getPointAt(int idx) const
Throws Base::OutOfRange if index is out of range.
Geom::BrepData::BrepData
BrepData(double tolerance)
Geom::PointMapWithTolerance
Definition: PointMapWithTolerance.h:11
Geom::BrepArc
Definition: BrepData.h:59
Geom::BrepData::getModelingTolerance
double getModelingTolerance() const
Returns the modeling tolerance of the Brep.
Definition: BrepData.h:172
Geom::BrepData::unlock
void unlock()
Unlock mutex.
Core::PropertyBrepData
Definition: PropertyBrepData.h:10
Geom::BrepData::hasPoint
bool hasPoint(const Geom::Pnt &p)
Checks if a point is already in BrepData.
Geom::BrepData::getModelIndexAt
int getModelIndexAt(int idx) const
Throws Base::OutOfRange if index is out of range.
Geom::BrepLoop::getPolygonPtr
std::vector< const Geom::Pnt * > getPolygonPtr() const
Geom::Trsf
Definition: Trsf.h:58
Geom::BrepData::getFaces
std::vector< pConstBrepFace > getFaces() const
Returns all faces.
Geom::BrepData::lock
void lock()
Lock mutex.
Geom::BrepData::BrepLoop
friend class BrepLoop
Definition: BrepData.h:130
Geom::BrepData::BrepData
BrepData(const BrepData &p)
Geom::BrepEdge
Definition: BrepData.h:47
pConstBrepLoop
std::shared_ptr< const Geom::BrepLoop > pConstBrepLoop
Definition: BrepData.h:33
PointMapWithTolerance.h
pBrepLoop
std::shared_ptr< Geom::BrepFace > pBrepLoop
Definition: BrepData.h:30
Geom::BrepData::transform
void transform(const Geom::Trsf &T)
Geom::BrepFace::getFaceNormal
bool getFaceNormal(Geom::Dir &normal, Geom::Pnt &pntOnFace) const
Geom::BrepStraight
Definition: BrepData.h:52
Geom::BrepData::operator==
bool operator==(const Geom::BrepData &other) const
Geom::BrepData::getModel
std::vector< int > getModel() const
Geom::BrepFace::getElement
pConstBrepData getElement() const
Geom::BrepData::addUniquePoint
int addUniquePoint(const Geom::Pnt &p)
Adds a unique point and returns the position of the point.
Geom
Definition: PropertyContainer.h:33