Coin: SbBSPTree.h Source File

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

SbBSPTree.h
1#ifndef COIN_SBBSPTREE_H
2#define COIN_SBBSPTREE_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <cstddef> // for NULL definition
37#include <Inventor/lists/SbList.h>
38#include <Inventor/SbVec3f.h>
39#include <Inventor/SbBox3f.h>
40
41#ifdef COIN_INTERNAL
42 #define COIN_ALLOW_SBINTLIST
43 #include <Inventor/lists/SbIntList.h>
44 #undef COIN_ALLOW_SBINTLIST
45#else
46 #include <Inventor/lists/SbIntList.h>
47#endif // COIN_INTERNAL
48
49class SbSphere;
50class coin_bspnode;
51
52// *************************************************************************
53
54 class COIN_DLL_API SbBSPTree {
55public:
56 SbBSPTree(const int maxnodepts = 64, const int initsize = 4);
57 ~SbBSPTree();
58
59 int numPoints() const;
60 SbVec3f getPoint(const int idx) const;
61 void getPoint(const int idx, SbVec3f & pt) const;
62 void * getUserData(const int idx) const;
63 void setUserData(const int idx, void * const data);
64
65 int addPoint(const SbVec3f & pt, void * const userdata = NULL);
66 int removePoint(const SbVec3f & pt);
67 void removePoint(const int idx);
68 int findPoint(const SbVec3f & pos) const;
69 int findClosest(const SbVec3f & pos) const;
70 void clear(const int initsize = 4);
71 void findPoints(const SbSphere & sphere, SbIntList & array) const;
72 int findClosest(const SbSphere & sphere, SbIntList & array) const;
73
74 const SbBox3f & getBBox() const;
75 const SbVec3f * getPointsArrayPtr() const;
76
77 // Please stop using these two functions. They will be removed in
78 // Coin 3.0. Use the SbIntList versions instead.
79 void findPoints(const SbSphere & sphere, SbList <int> & array) const;
80 int findClosest(const SbSphere & sphere, SbList <int> & array) const;
81
82private:
83 friend class coin_bspnode;
84 SbList <SbVec3f> pointsArray;
85 SbList <void *> userdataArray;
86 coin_bspnode * topnode;
87 int maxnodepoints;
88 SbBox3f boundingBox;
89};
90
91#endif // !COIN_SBBSPTREE_H
SbBSPTree::getPoint
SbVec3f getPoint(const int idx) const
Definition SbBSPTree.cpp:410
SbBSPTree::numPoints
int numPoints() const
Definition SbBSPTree.cpp:400
SbBSPTree::findPoint
int findPoint(const SbVec3f &pos) const
Definition SbBSPTree.cpp:513
SbBSPTree::setUserData
void setUserData(const int idx, void *const data)
Definition SbBSPTree.cpp:444
SbBSPTree::getPointsArrayPtr
const SbVec3f * getPointsArrayPtr() const
Definition SbBSPTree.cpp:592
SbBSPTree::findPoints
void findPoints(const SbSphere &sphere, SbIntList &array) const
Definition SbBSPTree.cpp:603
SbBSPTree::SbBSPTree
SbBSPTree(const int maxnodepts=64, const int initsize=4)
Definition SbBSPTree.cpp:380
SbBSPTree::findClosest
int findClosest(const SbVec3f &pos) const
Definition SbBSPTree.cpp:545
SbBSPTree::addPoint
int addPoint(const SbVec3f &pt, void *const userdata=NULL)
Definition SbBSPTree.cpp:461
SbBSPTree::getBBox
const SbBox3f & getBBox() const
Definition SbBSPTree.cpp:536
SbBSPTree::removePoint
int removePoint(const SbVec3f &pt)
Definition SbBSPTree.cpp:477
SbBSPTree::clear
void clear(const int initsize=4)
Definition SbBSPTree.cpp:522
SbBSPTree::getUserData
void * getUserData(const int idx) const
Definition SbBSPTree.cpp:432
SbBox3f
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition SbBox3f.h:46
SbIntList
The SbIntList class is a container for integer numbers.
Definition SbIntList.h:40
SbSphere
The SbSphere class is a representation of a sphere.
Definition SbSphere.h:42
SbVec3f
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51