00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2009 Ilya Baran <ibaran@mit.edu> 00005 // 00006 // Eigen is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 3 of the License, or (at your option) any later version. 00010 // 00011 // Alternatively, you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License as 00013 // published by the Free Software Foundation; either version 2 of 00014 // the License, or (at your option) any later version. 00015 // 00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License and a copy of the GNU General Public License along with 00023 // Eigen. If not, see <http://www.gnu.org/licenses/>. 00024 00025 #ifndef EIGEN_BVH_MODULE_H 00026 #define EIGEN_BVH_MODULE_H 00027 00028 #include <Eigen/Core> 00029 #include <Eigen/Geometry> 00030 #include <Eigen/StdVector> 00031 #include <algorithm> 00032 #include <queue> 00033 00034 namespace Eigen { 00035 00036 /** \ingroup Unsupported_modules 00037 * \defgroup BVH_Module BVH module 00038 * \ingroup eigen_grp 00039 * \ingroup eigen_grp 00040 * \brief This module provides generic bounding volume hierarchy algorithms 00041 * and reference tree implementations. 00042 * 00043 * 00044 * \code 00045 * #include <unsupported/Eigen/BVH> 00046 * \endcode 00047 * 00048 * A bounding volume hierarchy (BVH) can accelerate many geometric queries. This module provides a generic implementation 00049 * of the two basic algorithms over a BVH: intersection of a query object against all objects in the hierarchy and minimization 00050 * of a function over the objects in the hierarchy. It also provides intersection and minimization over a cartesian product of 00051 * two BVH's. A BVH accelerates intersection by using the fact that if a query object does not intersect a volume, then it cannot 00052 * intersect any object contained in that volume. Similarly, a BVH accelerates minimization because the minimum of a function 00053 * over a volume is no greater than the minimum of a function over any object contained in it. 00054 * 00055 * Some sample queries that can be written in terms of intersection are: 00056 * - Determine all points where a ray intersects a triangle mesh 00057 * - Given a set of points, determine which are contained in a query sphere 00058 * - Given a set of spheres, determine which contain the query point 00059 * - Given a set of disks, determine if any is completely contained in a query rectangle (represent each 2D disk as a point \f$(x,y,r)\f$ 00060 * in 3D and represent the rectangle as a pyramid based on the original rectangle and shrinking in the \f$r\f$ direction) 00061 * - Given a set of points, count how many pairs are \f$d\pm\epsilon\f$ apart (done by looking at the cartesian product of the set 00062 * of points with itself) 00063 * 00064 * Some sample queries that can be written in terms of function minimization over a set of objects are: 00065 * - Find the intersection between a ray and a triangle mesh closest to the ray origin (function is infinite off the ray) 00066 * - Given a polyline and a query point, determine the closest point on the polyline to the query 00067 * - Find the diameter of a point cloud (done by looking at the cartesian product and using negative distance as the function) 00068 * - Determine how far two meshes are from colliding (this is also a cartesian product query) 00069 * 00070 * This implementation decouples the basic algorithms both from the type of hierarchy (and the types of the bounding volumes) and 00071 * from the particulars of the query. To enable abstraction from the BVH, the BVH is required to implement a generic mechanism 00072 * for traversal. To abstract from the query, the query is responsible for keeping track of results. 00073 * 00074 * To be used in the algorithms, a hierarchy must implement the following traversal mechanism (see KdBVH for a sample implementation): \code 00075 typedef Volume //the type of bounding volume 00076 typedef Object //the type of object in the hierarchy 00077 typedef Index //a reference to a node in the hierarchy--typically an int or a pointer 00078 typedef VolumeIterator //an iterator type over node children--returns Index 00079 typedef ObjectIterator //an iterator over object (leaf) children--returns const Object & 00080 Index getRootIndex() const //returns the index of the hierarchy root 00081 const Volume &getVolume(Index index) const //returns the bounding volume of the node at given index 00082 void getChildren(Index index, VolumeIterator &outVBegin, VolumeIterator &outVEnd, 00083 ObjectIterator &outOBegin, ObjectIterator &outOEnd) const 00084 //getChildren takes a node index and makes [outVBegin, outVEnd) range over its node children 00085 //and [outOBegin, outOEnd) range over its object children 00086 \endcode 00087 * 00088 * To use the hierarchy, call BVIntersect or BVMinimize, passing it a BVH (or two, for cartesian product) and a minimizer or intersector. 00089 * For an intersection query on a single BVH, the intersector encapsulates the query and must provide two functions: 00090 * \code 00091 bool intersectVolume(const Volume &volume) //returns true if the query intersects the volume 00092 bool intersectObject(const Object &object) //returns true if the intersection search should terminate immediately 00093 \endcode 00094 * The guarantee that BVIntersect provides is that intersectObject will be called on every object whose bounding volume 00095 * intersects the query (but possibly on other objects too) unless the search is terminated prematurely. It is the 00096 * responsibility of the intersectObject function to keep track of the results in whatever manner is appropriate. 00097 * The cartesian product intersection and the BVMinimize queries are similar--see their individual documentation. 00098 * 00099 * The following is a simple but complete example for how to use the BVH to accelerate the search for a closest red-blue point pair: 00100 * \include BVH_Example.cpp 00101 * Output: \verbinclude BVH_Example.out 00102 00103 */ 00104 //@{ 00105 00106 #include "src/BVH/BVAlgorithms.h" 00107 #include "src/BVH/KdBVH.h" 00108 00109 //@} 00110 00111 } 00112 00113 #endif // EIGEN_BVH_MODULE_H
| Page generated by Doxygen 1.7.4 for MRPT 0.9.5 SVN:2717 at Sun Oct 16 16:08:03 PDT 2011 | Hosted on: |