Simbody  3.8
OBBTree.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMMATH_OBB_TREE_H_
2 #define SimTK_SIMMATH_OBB_TREE_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKmath *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2011-12 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
30 #include "SimTKcommon.h"
32 #include "simmath/internal/Geo.h"
35 
36 #include <cassert>
37 
38 namespace SimTK {
39 
40 //==============================================================================
41 // OBB LEAF
42 //==============================================================================
44 class OBBLeaf {
45 public:
46  virtual ~OBBLeaf() {}
47 };
48 
49 //==============================================================================
50 // OBB NODE
51 //==============================================================================
54 public:
55  OBBNode() : contents(0) {clear();}
56  ~OBBNode() {clear();}
57 
58  void clear() {
59  delete contents; contents=0;
60  x0=y0=nx=ny=-1;
61  children.clear();
62  }
63 
64  bool isLeaf() const {return children.empty();}
65  int getNumChildren() const {return (int)children.size();}
66  const OBBNode& getChild(int i) const {return children[i];}
67  OBBNode& updChild(int i) {return children[i];}
68 
69  // A box enclosing the contents.
71  int depth; // 0 is root
72  int height; // a leaf is 0, node is max of children+1
73 
74  // A cone enclosing the entire range of normals.
75  UnitVec3 normal; // central normal
76  Real coneHalfAngle; // 0<=a<=pi, pi/2 makes a halfspace
77 
78  // An arbitrary point on the contained surface, used in
79  // distance queries where distance to box is min distance, distance
80  // to point is max distance.
82 
83  int x0,y0; // Range of patches in this node
84  int nx,ny;
85 
87 
88  // If no children, leaf contents:
89  OBBLeaf* contents; // non-null only for leaf (NOT USED YET)
90  Vec2 centerUW; // (u,w) parameters of patch center
91  Vec2 dims; // half-u, half-w sizes
92  Geo::BicubicBezierPatch patch; // TODO: no need to keep this around
93 };
94 
95 
96 //==============================================================================
97 // OBB TREE
98 //==============================================================================
101 public:
102  const OBBNode& getRoot() const {return root;}
103  OBBNode& updRoot() {return root;}
104 private:
105  OBBNode root;
106 };
107 
108 
109 
110 } // namespace SimTK
111 
112 #endif // SimTK_SIMMATH_OBB_TREE_H_
Defines geometric primitive shapes and algorthms.
Provides primitive operations for a single bicubic Bezier patch using either single or double precisi...
Defines primitive operations involving 3d rectangular boxes.
Includes internal headers providing declarations for the basic SimTK Core classes,...
This is the header file that every Simmath compilation unit should include first.
#define SimTK_SIMMATH_EXPORT
Definition: SimTKmath/include/simmath/internal/common.h:64
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:1520
A primitive useful for computations involving a single bicubic Bezier patch.
Definition: Geo_BicubicBezierPatch.h:101
TODO: A 3d box oriented and positioned with respect to an unspecified frame F.
Definition: Geo_Box.h:528
TODO.
Definition: OBBTree.h:44
virtual ~OBBLeaf()
Definition: OBBTree.h:46
TODO.
Definition: OBBTree.h:53
UnitVec3 normal
Definition: OBBTree.h:75
bool isLeaf() const
Definition: OBBTree.h:64
~OBBNode()
Definition: OBBTree.h:56
void clear()
Definition: OBBTree.h:58
OBBNode()
Definition: OBBTree.h:55
OBBNode & updChild(int i)
Definition: OBBTree.h:67
Geo::OrientedBox box
Definition: OBBTree.h:70
const OBBNode & getChild(int i) const
Definition: OBBTree.h:66
Array_< OBBNode > children
Definition: OBBTree.h:86
Real coneHalfAngle
Definition: OBBTree.h:76
int height
Definition: OBBTree.h:72
int nx
Definition: OBBTree.h:84
Vec2 centerUW
Definition: OBBTree.h:90
int x0
Definition: OBBTree.h:83
Vec2 dims
Definition: OBBTree.h:91
int depth
Definition: OBBTree.h:71
OBBLeaf * contents
Definition: OBBTree.h:89
int getNumChildren() const
Definition: OBBTree.h:65
Geo::BicubicBezierPatch patch
Definition: OBBTree.h:92
Vec3 pointOnSurface
Definition: OBBTree.h:81
TODO.
Definition: OBBTree.h:100
const OBBNode & getRoot() const
Definition: OBBTree.h:102
OBBNode & updRoot()
Definition: OBBTree.h:103
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:607