AABB tree: replace xref/yref/zref and point_on by a single reference_point() function for primitive.

NOTE: the reference point is used both for sorting the primitives and for constructing the search KD-tree
This commit is contained in:
Pierre Alliez 2009-04-27 08:58:19 +00:00
parent b9c28d07aa
commit 18c93be7bc
7 changed files with 12 additions and 52 deletions

View File

@ -23,8 +23,6 @@ The concept \ccRefName\ describes the requirements for the primitives stored in
\ccTypes
\ccNestedType{FT}{Field number type.}
\ccNestedType{Point}{3D point type.}
\ccNestedType{Datum}{Type of input datum.}
@ -43,17 +41,8 @@ The concept \ccRefName\ describes the requirements for the primitives stored in
\ccMethod{Id id();}
{Returns the corresponding identifier. This identifier is only used as a reference for the objects in the output of the \ccc{AABB_tree} methods.}
\ccMethod{FT xref();}
{Returns the \ccc{x} reference coordinate of the primitive used for sorting the primitives. It can be the x coordinate of either one vertex of the geometric object, or of its centroid, or any other reference point taken on the object.}
\ccMethod{FT yref();}
{Returns the \ccc{y} reference coordinate of the primitive used for sorting the primitives.}
\ccMethod{FT zref();}
{Returns the \ccc{z} reference coordinate of the primitive used for sorting the primitives.}
\ccMethod{Point point_on();}
{Returns a 3D point located on the geometric object wrapped by the primitive. This function is used to construct the search KD-tree internal to the AABB tree in order to accelerate projection queries.}
\ccMethod{Point reference_point();}
{Returns a 3D point located on the geometric object wrapped by the primitive. This function is used to sort the primitives during the AABB tree construction and to construct the search KD-tree internal to the AABB tree in order to accelerate projection queries.}
\ccSeeAlso
\ccc{AABB_tree<Traits>}

View File

@ -37,7 +37,6 @@ namespace CGAL {
{
public:
/// AABBTrianglePrimitive types
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Segment_3 Datum;
typedef typename Polyhedron::Halfedge_handle Id;
@ -60,13 +59,7 @@ namespace CGAL {
const Id id() const { return m_halfedge_handle; }
/// Returns a point on the primitive
Point point_on() const;
/// Returns the x/y/z reference coordinate for sorting
/// here simply one vertex of the triangle
const FT xref() const { return m_halfedge_handle->vertex()->point().x(); }
const FT yref() const { return m_halfedge_handle->vertex()->point().y(); }
const FT zref() const { return m_halfedge_handle->vertex()->point().z(); }
Point reference_point() const;
private:
/// Id, here a polyhedron halfedge handle
@ -86,7 +79,7 @@ namespace CGAL {
template<typename GT, typename P_>
typename AABB_polyhedron_edge_primitive<GT,P_>::Point
AABB_polyhedron_edge_primitive<GT,P_>::point_on() const
AABB_polyhedron_edge_primitive<GT,P_>::reference_point() const
{
return m_halfedge_handle->vertex()->point();
}

View File

@ -37,7 +37,6 @@ namespace CGAL {
{
public:
/// AABBTrianglePrimitive types
typedef typename GeomTraits::FT FT;
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Triangle_3 Datum;
typedef typename Polyhedron::Facet_handle Id;
@ -58,17 +57,11 @@ namespace CGAL {
Datum datum() const;
/// Returns a point on the primitive
Point point_on() const;
Point reference_point() const;
/// Returns the identifier
const Id id() const { return m_facet_handle; }
/// Returns the x/y/z reference coordinate for sorting
/// here simply one vertex of the triangle
const FT xref() const { return m_facet_handle->halfedge()->vertex()->point().x(); }
const FT yref() const { return m_facet_handle->halfedge()->vertex()->point().y(); }
const FT zref() const { return m_facet_handle->halfedge()->vertex()->point().z(); }
private:
/// The id, here a polyhedron facet handle
Id m_facet_handle;
@ -88,7 +81,7 @@ namespace CGAL {
template<typename GT, typename P_>
typename AABB_polyhedron_triangle_primitive<GT,P_>::Point
AABB_polyhedron_triangle_primitive<GT,P_>::point_on() const
AABB_polyhedron_triangle_primitive<GT,P_>::reference_point() const
{
return m_facet_handle->halfedge()->vertex()->point();
}

View File

@ -32,7 +32,6 @@ class AABB_segment_primitive
{
// type
public:
typedef typename GeomTraits::FT FT; // field number type
typedef typename GeomTraits::Point_3 Point; // point type
typedef typename GeomTraits::Segment_3 Datum; // datum type
typedef Iterator Id; // Id type
@ -54,15 +53,8 @@ public:
Datum& datum() { return m_datum; }
const Datum& datum() const { return m_datum; }
/// Returns the x/y/z reference coordinate for sorting
/// here simply the source vertex of the segment
// (could be as well the centroid computed on the fly)
const FT xref() const { return m_datum.source().x(); }
const FT yref() const { return m_datum.source().y(); }
const FT zref() const { return m_datum.source().z(); }
/// Returns a point on the primitive
Point point_on() const { m_datum.source(); }
Point reference_point() const { return m_datum.source(); }
};
} // end namespace CGAL

View File

@ -80,11 +80,11 @@ public:
/// Comparison functions
static bool x_less_than(const Primitive& pr1, const Primitive& pr2)
{ return pr1.xref() < pr2.xref(); }
{ return pr1.reference_point().x() < pr2.reference_point().x(); }
static bool y_less_than(const Primitive& pr1, const Primitive& pr2)
{ return pr1.yref() < pr2.yref(); }
{ return pr1.reference_point().y() < pr2.reference_point().y(); }
static bool z_less_than(const Primitive& pr1, const Primitive& pr2)
{ return pr1.zref() < pr2.zref(); }
{ return pr1.reference_point().z() < pr2.reference_point().z(); }
/// UNDOCUMENTED FEATURE
/// TODO: see what to do

View File

@ -352,7 +352,7 @@ namespace CGAL {
for(it = m_data.begin(); it != m_data.end(); it++)
{
const Primitive& pr = *it;
points.push_back(pr.point_on());
points.push_back(pr.reference_point());
}
m_search_tree.init(points.begin(), points.end());
m_search_tree_constructed = true;

View File

@ -33,7 +33,6 @@ namespace CGAL {
public:
// types
typedef Iterator Id; // Id type
typedef typename GeomTraits::FT FT; // field number type
typedef typename GeomTraits::Point_3 Point; // point type
typedef typename GeomTraits::Triangle_3 Datum; // datum type
@ -54,14 +53,8 @@ namespace CGAL {
Datum& datum() { return m_datum; }
const Datum& datum() const { return m_datum; }
/// Returns the x/y/z reference coordinate for sorting
/// here simply the first vertex of the triangle
const FT xref() const { return m_datum.vertex(0).x(); }
const FT yref() const { return m_datum.vertex(0).y(); }
const FT zref() const { return m_datum.vertex(0).z(); }
/// Returns a point on the primitive
Point point_on() const { m_datum.vertex(0); }
Point reference_point() const { return m_datum.vertex(0); }
};
} // end namespace CGAL