mirror of https://github.com/CGAL/cgal
AABB tree:
- cleanup examples - shorten a bit ref manual of tree.
This commit is contained in:
parent
68fc612c96
commit
74dfd60a12
|
|
@ -2,8 +2,7 @@
|
|||
\section{Implementation Details}
|
||||
\label{AABB_tree_section_details}
|
||||
|
||||
The AABB tree construction is initialized by computing the AABB of the whole set of input primitives. All primitives are then sorted along the longest coordinate axis of this box, and the primitives are separated into two equal size sets. This procedure is applied recursively until an AABB contains a single primitive. In practice the design is slightly different than the one described above as the tree is leafless as presented in {\sc opcode} \cite{cgal:t-ocdl-05}.\\
|
||||
|
||||
The AABB tree construction is initialized by computing the AABB of the whole set of input primitives. All primitives are then sorted along the longest coordinate axis of this box, and the primitives are separated into two equal size sets. This procedure is applied recursively until an AABB contains a single primitive. In practice the design is slightly different than the one described above as the tree is leafless as presented in {\sc opcode} \cite{cgal:t-ocdl-05}.
|
||||
An intersection query traverses the tree by computing intersection tests only with respect to the AABBs during traversal, and with respect to the input primitives at the end of traversal, i.e., in the leafs of the tree.\\
|
||||
|
||||
A distance query between a query point $q$ and, e.g., a set of triangle primitives, is turned into a \emph{ball} query centered at the query point. The ball traverses the tree while recursively querying intersections with the AABBs, and computes the closest point $p$ from the query point to the input primitives at the leafs of the tree. The ball radius is then shrunk to the distance between $p$ and $q$ for all remaining recursive traversals of the tree. Efficiency is achieved through setting the initial ball radius to a small value albeit guaranteed to intersect the input primitives. This is achieved by constructing an internal KD-tree used to query closest hint points from point queries as described in Section \ref{AABB_tree_section_interface}.
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
\section{Examples}
|
||||
\label{AABB_tree_section_examples}
|
||||
|
||||
\subsection{Tree of triangles with a copy of geometric data, for line queries and distance queries}
|
||||
In the following example, a set of 3D triangles is stored in a list. The AABB primitive wraps a triangle as \ccc{datum} and an iterator in the list as \ccc{id}. We compute the number of input triangles intersected by a line query, the closest point from a query point to the input triangles and the squared distance from a query point to the input triangles.
|
||||
\subsection{Tree of triangles, for intersection with ray query and distance queries}
|
||||
In the following example, a set of 3D triangles is stored in a list. The AABB primitive wraps a triangle as \ccc{datum} and an iterator in the list as \ccc{id}. We compute the number of input triangles intersected by a ray query, as well as the closest point and the squared distance from a point query.
|
||||
\ccIncludeExampleCode{AABB_tree/AABB_triangle_3_example.cpp}
|
||||
|
||||
\subsection{Tree of triangles without copying geometric data, for ray queries}
|
||||
In the following example the AABB primitive wraps a facet handle of a triangle polyhedral surface as \ccc{id} and the corresponding 3D triangle as geometric object. We compute the number of intersections between a ray query and the input primitives, and all intersection objects between a segment query and the input primitives.
|
||||
\subsection{Tree of polyhedron triangle facets for intersection with ray and segment queries}
|
||||
In the following example the AABB primitive wraps a facet handle of a triangle polyhedral surface as \ccc{id} and the corresponding 3D triangle as geometric object. We compute the number of intersections with a ray query and all intersection objects with a segment query.
|
||||
\ccIncludeExampleCode{AABB_tree/AABB_polyhedron_facet_example.cpp}
|
||||
|
||||
\subsection{Tree of segments with a copy of geometric data, for plane queries}
|
||||
The following example computes the number of intersections between a 3D plane and a set of 3D segments. The segments are stored into a list, and the AABB primitive wraps a segment as \ccc{datum} and an iterator in the list as \ccc{id}.
|
||||
\subsection{Tree of segments for intersection with plane and triangle queries, and for distance query}
|
||||
In the following example the segments are stored into a list, and the AABB primitive wraps a segment as \ccc{datum} and an iterator in the list as \ccc{id}. We compute the number of intersections with plane and triangles queries, and the closest point from a point query.
|
||||
\ccIncludeExampleCode{AABB_tree/AABB_segment_3_example.cpp}
|
||||
|
||||
\subsection{Tree of segments without copying geometric data, for plane queries}
|
||||
The following example computes the number of intersections between a 3D plane and a set of edges of a triangle polyhedral surface. The AABB primitive wraps a halfedge handle as \ccc{id} and generates a 3D segment on the fly, each time its method \ccc{datum} is called.
|
||||
\subsection{Tree of polyhedron edge segments for intersection with a triangle query and for distance query}
|
||||
In the following example the AABB primitive wraps a halfedge handle as \ccc{id} and generates a 3D segment on the fly, each time its method \ccc{datum} is called. We compute the number of intersections with a triangle query and the closest point from a point query.
|
||||
\ccIncludeExampleCode{AABB_tree/AABB_polyhedron_edge_example.cpp}
|
||||
|
|
|
|||
|
|
@ -128,14 +128,16 @@ squared_distance(const Point& query,
|
|||
\ccMethod{Point
|
||||
closest_point(const Point& query,
|
||||
const Point& hint);}
|
||||
{Returns the point in the union of all input primitives which is closest to the query. In case there are several closest points, one arbitrarily chosen closest point is returned. ÊParameter \ccc{hint} is assumed to be any point located on the input primitives (the closer \ccc{hint} to \ccc{query}, the faster). If \ccc{hint} is closer to \ccc{query} than any of the primitives, \ccc{hint} is returned. Parameter \ccc{hint} can be omitted. If the internal KD-tree data structure has been constructed using function \ccc{accelerate_distance_queries} (see below), it is used to efficiently query the nearest hint point from the query, among a set of hint points stored in the internal KD-tree. Otherwise, the first primitive reference point is chosen as a naive hint point.}
|
||||
{Returns the point in the union of all input primitives which is closest to the query. In case there are several closest points, one arbitrarily chosen closest point is returned. ÊParameter \ccc{hint} is assumed to be any point located on the input primitives (the closer \ccc{hint} to \ccc{query}, the faster). If \ccc{hint} is closer to \ccc{query} than any of the primitives, \ccc{hint} is returned. Parameter \ccc{hint} can be omitted (see \ccc{squared_distance}). }
|
||||
|
||||
\ccMethod{Point_and_primitive_id
|
||||
closest_point_and_primitive(const Point& query,
|
||||
const Point_and_primitive_id& hint);}
|
||||
{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. Parameter \ccc{hint} is assumed to be any point and the corresponding input primitive it lies on (the closer \ccc{hint} to \ccc{query}, the faster). Parameter \ccc{hint} can be omitted. If the internal KD-tree data structure has been constructed using function \ccc{accelerate_distance_queries} (see below), it is used to efficiently query the nearest hint from the query, among a set of hints stored in the internal KD-tree. Otherwise, the first point and primitive pair is chosen as a naive hint.}
|
||||
{Returns a \ccc{Point_and_primitive_id} which realizes the smallest distance between the query point and all input primitives. Parameter \ccc{hint} is assumed to be any point and the corresponding input primitive it lies on (the closer \ccc{hint} to \ccc{query}, the faster). Parameter \ccc{hint} can be omitted (see \ccc{squared_distance}).}
|
||||
|
||||
|
||||
% ACCELERATING THE DISTANCE QUERIES
|
||||
|
||||
\ccHeading{Accelerating the distance queries}
|
||||
|
||||
\ccMethod{bool accelerate_distance_queries();}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ int main()
|
|||
Tree tree(triangles.begin(),triangles.end());
|
||||
|
||||
// counts #intersections
|
||||
Ray ray(a,b);
|
||||
std::cout << tree.number_of_intersected_primitives(ray)
|
||||
<< " intersections(s) with ray" << std::endl;
|
||||
Ray ray_query(a,b);
|
||||
std::cout << tree.number_of_intersected_primitives(ray_query)
|
||||
<< " intersections(s) with ray query" << std::endl;
|
||||
|
||||
// compute closest point and squared distance
|
||||
Point point_query(2.0, 2.0, 2.0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue