OpenLexocad  28.0
BSPTree.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
5 
6 
7 namespace Geom
8 {
9 class Pnt;
10 class Sphr;
11 class base_bspnode;
12 
13 // *************************************************************************
14 
15 class LX_GEOM_EXPORT BSPTree
16 {
17 public:
18  BSPTree(const int64_t maxnodepts = 64, const int64_t initsize = 4);
19  BSPTree(const BSPTree& other); // Copy constructor
21 
22  int64_t numPoints() const;
23  const Geom::Pnt& getPoint(const int64_t idx) const;
24  void getPoint(const int64_t idx, Geom::Pnt& pt) const;
25  void* getUserData(const int64_t idx) const;
26  void setUserData(const int64_t idx, void* const data);
27 
28  int64_t addPoint(const Geom::Pnt& pt, void* const userdata = nullptr);
29  int64_t removePoint(const Geom::Pnt& pt);
30  void removePoint(const int64_t idx);
31  int64_t findPoint(const Geom::Pnt& pos) const;
32  void clear();
33  void findPoints(const Geom::Sphr& sphere, std::vector<int64_t>& array) const;
34  int64_t findClosest(const Geom::Sphr& sphere, std::vector<int64_t>& array) const;
35  void findPoints(const Geom::Pnt& pnt, const double& tol, std::vector<int64_t>& array) const;
36  int64_t findClosest(const Geom::Pnt& pnt, const double& tol, std::vector<int64_t>& array) const;
37  int64_t findClosest(const Geom::Pnt& pnt, const double& tol) const;
38 
39  static void removeFast(std::vector<int64_t>& array, int64_t idx);
40  static void removeFast(std::vector<Geom::Pnt>& array, int64_t idx);
41  static void removeFast(std::vector<void*>& array, int64_t idx);
42 
43  bool operator==(const BSPTree& other) const;
44  BSPTree& operator=(const BSPTree& rhs);
45 
46 private:
47  friend class base_bspnode;
48  std::vector<Geom::Pnt> pointsArray;
49  std::vector<void*> userdataArray;
50  base_bspnode* topnode;
51  int64_t maxnodepoints;
52 };
53 
54 } // namespace Geom
Geom::BSPTree::removePoint
void removePoint(const int64_t idx)
Geom::BSPTree::clear
void clear()
Geom::BSPTree::getUserData
void * getUserData(const int64_t idx) const
Geom::BSPTree::setUserData
void setUserData(const int64_t idx, void *const data)
Geom::BSPTree::removeFast
static void removeFast(std::vector< Geom::Pnt > &array, int64_t idx)
Geom::BSPTree::operator=
BSPTree & operator=(const BSPTree &rhs)
Geom::BSPTree::findPoints
void findPoints(const Geom::Pnt &pnt, const double &tol, std::vector< int64_t > &array) const
Geom::BSPTree::getPoint
const Geom::Pnt & getPoint(const int64_t idx) const
Geom::BSPTree::~BSPTree
~BSPTree()
Geom::Sphr
Defines a non-persistent Sphere in 3D space.
Definition: Sphr.h:8
Geom::BSPTree
Definition: BSPTree.h:16
Geom::BSPTree::BSPTree
BSPTree(const BSPTree &other)
Geom::BSPTree::findClosest
int64_t findClosest(const Geom::Pnt &pnt, const double &tol) const
Geom::BSPTree::addPoint
int64_t addPoint(const Geom::Pnt &pt, void *const userdata=nullptr)
Geom::BSPTree::findClosest
int64_t findClosest(const Geom::Pnt &pnt, const double &tol, std::vector< int64_t > &array) const
Geom::BSPTree::removePoint
int64_t removePoint(const Geom::Pnt &pt)
Geom::BSPTree::findPoints
void findPoints(const Geom::Sphr &sphere, std::vector< int64_t > &array) const
Geom::BSPTree::numPoints
int64_t numPoints() const
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Geom::BSPTree::getPoint
void getPoint(const int64_t idx, Geom::Pnt &pt) const
Geom::BSPTree::removeFast
static void removeFast(std::vector< void * > &array, int64_t idx)
Geom::BSPTree::findClosest
int64_t findClosest(const Geom::Sphr &sphere, std::vector< int64_t > &array) const
Geom::BSPTree::removeFast
static void removeFast(std::vector< int64_t > &array, int64_t idx)
Geom::BSPTree::BSPTree
BSPTree(const int64_t maxnodepts=64, const int64_t initsize=4)
Geom::BSPTree::operator==
bool operator==(const BSPTree &other) const
Geom
Definition: PropertyContainer.h:33
Geom::BSPTree::findPoint
int64_t findPoint(const Geom::Pnt &pos) const