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