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