HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Sort.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU_Sort.h (GU Library, C++)
7  *
8  * COMMENTS: Declarations of helper classes for sorting geometry
9  */
10 
11 #include <UT/UT_KDTree.h>
12 
13 // A KD-Tree to sort the model's point or primitive positions
14 class GU_SortKDTree : public UT_KDTree {
15 public:
17  : UT_KDTree(3, size)
18  , myPos(size)
19  {
20  myPos.entries(size);
21  setMaxLeafNodes(4);
23  }
24 
25  void setPos(int idx, const UT_Vector3 &pos) { myPos(idx) = pos; }
26 
27  const int *getIndices() const { return myList; }
28 
29  int comparePosition(int idx0, int idx1, int dim) const override
30  {
31  return myPos(idx0)[dim] < myPos(idx1)[dim] ? -1 : 1;
32  }
33  const float *getP(int idx) const override { return myPos(idx).vec; }
34 
35 private:
36  UT_Vector3Array myPos;
37 };
38 
void setBalancer(ut_KDBalancer balance)
Definition: UT_KDTree.h:542
GU_SortKDTree(size_t size)
Definition: GU_Sort.h:16
void setMaxLeafNodes(int max_leaf_nodes)
Definition: UT_KDTree.h:548
void setPos(int idx, const UT_Vector3 &pos)
Definition: GU_Sort.h:25
const int * getIndices() const
Definition: GU_Sort.h:27
int comparePosition(int idx0, int idx1, int dim) const override
Definition: GU_Sort.h:29
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
GLsizeiptr size
Definition: glcorearb.h:664
const float * getP(int idx) const override
Return the position associated with the given point.
Definition: GU_Sort.h:33
int * myList
Definition: UT_KDTree.h:874