mirror of https://github.com/CGAL/cgal
AABB tree: rename is_smaller to is_contained
another code cleanup
This commit is contained in:
parent
a8188eb668
commit
b9c28d07aa
|
|
@ -24,17 +24,15 @@
|
||||||
#include <CGAL/Bbox_3.h>
|
#include <CGAL/Bbox_3.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace AABB {
|
|
||||||
|
|
||||||
template<typename Primitive, typename Node>
|
template<typename Primitive, typename Node>
|
||||||
struct Drawing_traits
|
struct AABB_drawing_traits
|
||||||
{
|
{
|
||||||
typedef CGAL::Bbox_3 Bbox;
|
typedef CGAL::Bbox_3 Bbox;
|
||||||
bool go_further() { return true; }
|
bool go_further() { return true; }
|
||||||
|
|
||||||
bool intersection(const int&, const Primitive&)
|
bool intersection(const int&, const Primitive&)
|
||||||
{
|
{
|
||||||
// gl_draw(m_psc.compute_bbox(i));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,9 +84,8 @@ struct Drawing_traits
|
||||||
::glVertex3d(px,py,pz);
|
::glVertex3d(px,py,pz);
|
||||||
::glVertex3d(qx,qy,qz);
|
::glVertex3d(qx,qy,qz);
|
||||||
}
|
}
|
||||||
}; // Drawing_traits
|
}; // AABB_drawing_traits
|
||||||
|
|
||||||
} // end namespace AABB_tree
|
|
||||||
} // end namespace CGAL
|
} // end namespace CGAL
|
||||||
|
|
||||||
#endif // CGAL_AABB_DRAWING_TRAITS_H
|
#endif // CGAL_AABB_DRAWING_TRAITS_H
|
||||||
|
|
|
||||||
|
|
@ -87,13 +87,10 @@ public:
|
||||||
Traversal_traits& traits,
|
Traversal_traits& traits,
|
||||||
const int nb_primitives) const;
|
const int nb_primitives) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef AABB_node<AABBTraits> Node;
|
typedef AABB_node<AABBTraits> Node;
|
||||||
typedef typename AABBTraits::Primitive Primitive;
|
typedef typename AABBTraits::Primitive Primitive;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Helper functions
|
/// Helper functions
|
||||||
const Node& left_child() const
|
const Node& left_child() const
|
||||||
{ return *static_cast<Node*>(m_p_left_child); }
|
{ return *static_cast<Node*>(m_p_left_child); }
|
||||||
|
|
@ -113,9 +110,8 @@ private:
|
||||||
/// bounding box
|
/// bounding box
|
||||||
Bounding_box m_bbox;
|
Bounding_box m_bbox;
|
||||||
|
|
||||||
/// children nodes:
|
/// children nodes, either pointing towards children (if children are not leaves),
|
||||||
/// either pointing towards children (if the children are not leaves)
|
/// or pointing toward input primitives (if children are leaves).
|
||||||
/// or pointing toward input primitives (if the children are leaves).
|
|
||||||
void *m_p_left_child;
|
void *m_p_left_child;
|
||||||
void *m_p_right_child;
|
void *m_p_right_child;
|
||||||
|
|
||||||
|
|
@ -169,9 +165,6 @@ AABB_node<Tr>::traversal(const Query& query,
|
||||||
Traversal_traits& traits,
|
Traversal_traits& traits,
|
||||||
const int nb_primitives) const
|
const int nb_primitives) const
|
||||||
{
|
{
|
||||||
// CGAL_assertion(NULL!=m_p_left_child);
|
|
||||||
// CGAL_assertion(NULL!=m_p_right_child);
|
|
||||||
|
|
||||||
// Recursive traversal
|
// Recursive traversal
|
||||||
switch(nb_primitives)
|
switch(nb_primitives)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<typename GeomTraits, typename Polyhedron_>
|
template<typename GeomTraits, typename Polyhedron>
|
||||||
class AABB_polyhedron_edge_primitive
|
class AABB_polyhedron_edge_primitive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,16 +40,14 @@ namespace CGAL {
|
||||||
typedef typename GeomTraits::FT FT;
|
typedef typename GeomTraits::FT FT;
|
||||||
typedef typename GeomTraits::Point_3 Point;
|
typedef typename GeomTraits::Point_3 Point;
|
||||||
typedef typename GeomTraits::Segment_3 Datum;
|
typedef typename GeomTraits::Segment_3 Datum;
|
||||||
typedef typename Polyhedron_::Edge_const_iterator Id;
|
typedef typename Polyhedron::Halfedge_handle Id;
|
||||||
|
|
||||||
/// Self
|
/// Self
|
||||||
typedef AABB_polyhedron_edge_primitive<GeomTraits, Polyhedron_> Self;
|
typedef AABB_polyhedron_edge_primitive<GeomTraits, Polyhedron> Self;
|
||||||
|
|
||||||
/// Constructors
|
|
||||||
//AABB_polyhedron_triangle_primitive() { };
|
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
AABB_polyhedron_edge_primitive(const Id& handle)
|
AABB_polyhedron_edge_primitive(const Id& handle)
|
||||||
: m_handle(handle) { };
|
: m_halfedge_handle(handle) { };
|
||||||
|
|
||||||
// Default copy constructor and assignment operator are ok
|
// Default copy constructor and assignment operator are ok
|
||||||
|
|
||||||
|
|
@ -59,20 +57,20 @@ namespace CGAL {
|
||||||
/// Returns by constructing on the fly the geometric datum wrapped by the primitive
|
/// Returns by constructing on the fly the geometric datum wrapped by the primitive
|
||||||
Datum datum() const;
|
Datum datum() const;
|
||||||
/// Returns the identifier
|
/// Returns the identifier
|
||||||
const Id id() const { return m_handle; }
|
const Id id() const { return m_halfedge_handle; }
|
||||||
|
|
||||||
/// Returns a point on the primitive
|
/// Returns a point on the primitive
|
||||||
Point point_on() const;
|
Point point_on() const;
|
||||||
|
|
||||||
/// Returns the x/y/z reference coordinate for sorting
|
/// Returns the x/y/z reference coordinate for sorting
|
||||||
/// here simply one vertex of the triangle
|
/// here simply one vertex of the triangle
|
||||||
const FT xref() const { return m_handle->vertex()->point().x(); }
|
const FT xref() const { return m_halfedge_handle->vertex()->point().x(); }
|
||||||
const FT yref() const { return m_handle->vertex()->point().y(); }
|
const FT yref() const { return m_halfedge_handle->vertex()->point().y(); }
|
||||||
const FT zref() const { return m_handle->vertex()->point().z(); }
|
const FT zref() const { return m_halfedge_handle->vertex()->point().z(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Halfedge handle
|
/// Id, here a polyhedron halfedge handle
|
||||||
Id m_handle;
|
Id m_halfedge_handle;
|
||||||
}; // end class AABB_polyhedron_edge_primitive
|
}; // end class AABB_polyhedron_edge_primitive
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -81,17 +79,16 @@ namespace CGAL {
|
||||||
AABB_polyhedron_edge_primitive<GT,P_>::datum() const
|
AABB_polyhedron_edge_primitive<GT,P_>::datum() const
|
||||||
{
|
{
|
||||||
typedef typename GT::Point_3 Point;
|
typedef typename GT::Point_3 Point;
|
||||||
typedef typename GT::Segment_3 Segment;
|
const Point& a = m_halfedge_handle->vertex()->point();
|
||||||
const Point& a = m_handle->vertex()->point();
|
const Point& b = m_halfedge_handle->opposite()->vertex()->point();
|
||||||
const Point& b = m_handle->opposite()->vertex()->point();
|
return Datum(a,b); // returns a 3D segment
|
||||||
return Datum(a,b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename GT, typename P_>
|
template<typename GT, typename P_>
|
||||||
typename AABB_polyhedron_edge_primitive<GT,P_>::Point
|
typename AABB_polyhedron_edge_primitive<GT,P_>::Point
|
||||||
AABB_polyhedron_edge_primitive<GT,P_>::point_on() const
|
AABB_polyhedron_edge_primitive<GT,P_>::point_on() const
|
||||||
{
|
{
|
||||||
return m_handle->vertex()->point();
|
return m_halfedge_handle->vertex()->point();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<typename GeomTraits, typename Polyhedron_>
|
template<typename GeomTraits, typename Polyhedron>
|
||||||
class AABB_polyhedron_triangle_primitive
|
class AABB_polyhedron_triangle_primitive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,16 +40,14 @@ namespace CGAL {
|
||||||
typedef typename GeomTraits::FT FT;
|
typedef typename GeomTraits::FT FT;
|
||||||
typedef typename GeomTraits::Point_3 Point;
|
typedef typename GeomTraits::Point_3 Point;
|
||||||
typedef typename GeomTraits::Triangle_3 Datum;
|
typedef typename GeomTraits::Triangle_3 Datum;
|
||||||
typedef typename Polyhedron_::Facet_const_iterator Id;
|
typedef typename Polyhedron::Facet_handle Id;
|
||||||
|
|
||||||
/// Self
|
/// Self
|
||||||
typedef AABB_polyhedron_triangle_primitive<GeomTraits, Polyhedron_> Self;
|
typedef AABB_polyhedron_triangle_primitive<GeomTraits, Polyhedron> Self;
|
||||||
|
|
||||||
/// Constructors
|
/// Constructors
|
||||||
//AABB_polyhedron_triangle_primitive() { };
|
|
||||||
|
|
||||||
AABB_polyhedron_triangle_primitive(const Id& handle)
|
AABB_polyhedron_triangle_primitive(const Id& handle)
|
||||||
: m_handle(handle) { };
|
: m_facet_handle(handle) { };
|
||||||
|
|
||||||
// Default copy constructor and assignment operator are ok
|
// Default copy constructor and assignment operator are ok
|
||||||
|
|
||||||
|
|
@ -63,17 +61,17 @@ namespace CGAL {
|
||||||
Point point_on() const;
|
Point point_on() const;
|
||||||
|
|
||||||
/// Returns the identifier
|
/// Returns the identifier
|
||||||
const Id id() const { return m_handle; }
|
const Id id() const { return m_facet_handle; }
|
||||||
|
|
||||||
/// Returns the x/y/z reference coordinate for sorting
|
/// Returns the x/y/z reference coordinate for sorting
|
||||||
/// here simply one vertex of the triangle
|
/// here simply one vertex of the triangle
|
||||||
const FT xref() const { return m_handle->halfedge()->vertex()->point().x(); }
|
const FT xref() const { return m_facet_handle->halfedge()->vertex()->point().x(); }
|
||||||
const FT yref() const { return m_handle->halfedge()->vertex()->point().y(); }
|
const FT yref() const { return m_facet_handle->halfedge()->vertex()->point().y(); }
|
||||||
const FT zref() const { return m_handle->halfedge()->vertex()->point().z(); }
|
const FT zref() const { return m_facet_handle->halfedge()->vertex()->point().z(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The handle
|
/// The id, here a polyhedron facet handle
|
||||||
Id m_handle;
|
Id m_facet_handle;
|
||||||
}; // end class AABB_polyhedron_triangle_primitive
|
}; // end class AABB_polyhedron_triangle_primitive
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,10 +80,9 @@ namespace CGAL {
|
||||||
AABB_polyhedron_triangle_primitive<GT,P_>::datum() const
|
AABB_polyhedron_triangle_primitive<GT,P_>::datum() const
|
||||||
{
|
{
|
||||||
typedef typename GT::Point_3 Point;
|
typedef typename GT::Point_3 Point;
|
||||||
typedef typename GT::Triangle_3 Triangle;
|
const Point& a = m_facet_handle->halfedge()->vertex()->point();
|
||||||
const Point& a = m_handle->halfedge()->vertex()->point();
|
const Point& b = m_facet_handle->halfedge()->next()->vertex()->point();
|
||||||
const Point& b = m_handle->halfedge()->next()->vertex()->point();
|
const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point();
|
||||||
const Point& c = m_handle->halfedge()->next()->next()->vertex()->point();
|
|
||||||
return Datum(a,b,c);
|
return Datum(a,b,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +90,7 @@ namespace CGAL {
|
||||||
typename AABB_polyhedron_triangle_primitive<GT,P_>::Point
|
typename AABB_polyhedron_triangle_primitive<GT,P_>::Point
|
||||||
AABB_polyhedron_triangle_primitive<GT,P_>::point_on() const
|
AABB_polyhedron_triangle_primitive<GT,P_>::point_on() const
|
||||||
{
|
{
|
||||||
return m_handle->halfedge()->vertex()->point();
|
return m_facet_handle->halfedge()->vertex()->point();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace CGAL
|
} // end namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ public:
|
||||||
m_datum = *it; // copy segment
|
m_datum = *it; // copy segment
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
const Datum& datum() const { return m_datum; }
|
|
||||||
Datum& datum() { return m_datum; }
|
|
||||||
Id id() { return m_it; }
|
Id id() { return m_it; }
|
||||||
|
Datum& datum() { return m_datum; }
|
||||||
|
const Datum& datum() const { return m_datum; }
|
||||||
|
|
||||||
/// Returns the x/y/z reference coordinate for sorting
|
/// Returns the x/y/z reference coordinate for sorting
|
||||||
/// here simply the source vertex of the segment
|
/// here simply the source vertex of the segment
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,12 @@ template<typename GeomTraits, typename AABB_primitive>
|
||||||
class AABB_traits
|
class AABB_traits
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Ray query type
|
/// query types
|
||||||
typedef typename GeomTraits::Ray_3 Ray_3;
|
typedef typename GeomTraits::Ray_3 Ray_3;
|
||||||
/// Line query type
|
|
||||||
typedef typename GeomTraits::Line_3 Line_3;
|
typedef typename GeomTraits::Line_3 Line_3;
|
||||||
/// Segment query type
|
|
||||||
typedef typename GeomTraits::Segment_3 Segment_3;
|
typedef typename GeomTraits::Segment_3 Segment_3;
|
||||||
|
|
||||||
// TODO: delete once "inside..." disappears
|
// TOFIX: delete once "inside..." disappears
|
||||||
typedef typename GeomTraits::Triangle_3 Triangle_3;
|
typedef typename GeomTraits::Triangle_3 Triangle_3;
|
||||||
|
|
||||||
/// AABBTraits concept types
|
/// AABBTraits concept types
|
||||||
|
|
@ -61,18 +59,18 @@ public:
|
||||||
typedef typename GeomTraits::Point_3 Projection_query;
|
typedef typename GeomTraits::Point_3 Projection_query;
|
||||||
|
|
||||||
// types for search tree
|
// types for search tree
|
||||||
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
|
// TOFIX: how can we avoid repeating those?
|
||||||
typedef typename GeomTraits::Construct_cartesian_const_iterator_3
|
typedef typename GeomTraits::FT FT;
|
||||||
Construct_cartesian_const_iterator_3;
|
|
||||||
typedef typename GeomTraits::Point_3 Point_3;
|
typedef typename GeomTraits::Point_3 Point_3;
|
||||||
typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3;
|
|
||||||
typedef typename GeomTraits::Sphere_3 Sphere_3;
|
typedef typename GeomTraits::Sphere_3 Sphere_3;
|
||||||
|
typedef typename GeomTraits::Iso_cuboid_3 Iso_cuboid_3;
|
||||||
|
typedef typename GeomTraits::Construct_center_3 Construct_center_3;
|
||||||
typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3;
|
typedef typename GeomTraits::Construct_iso_cuboid_3 Construct_iso_cuboid_3;
|
||||||
typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3;
|
typedef typename GeomTraits::Construct_min_vertex_3 Construct_min_vertex_3;
|
||||||
typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3;
|
typedef typename GeomTraits::Construct_max_vertex_3 Construct_max_vertex_3;
|
||||||
typedef typename GeomTraits::Construct_center_3 Construct_center_3;
|
|
||||||
typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3;
|
typedef typename GeomTraits::Compute_squared_radius_3 Compute_squared_radius_3;
|
||||||
typedef typename GeomTraits::FT FT;
|
typedef typename GeomTraits::Cartesian_const_iterator_3 Cartesian_const_iterator_3;
|
||||||
|
typedef typename GeomTraits::Construct_cartesian_const_iterator_3 Construct_cartesian_const_iterator_3;
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
AABB_traits() { };
|
AABB_traits() { };
|
||||||
|
|
@ -136,7 +134,7 @@ public:
|
||||||
const Primitive& pr,
|
const Primitive& pr,
|
||||||
Projection& projection_return) const;
|
Projection& projection_return) const;
|
||||||
|
|
||||||
bool is_smaller(const Sphere& a, const Sphere& b) const;
|
bool is_contained(const Sphere& a, const Sphere& b) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Private types
|
/// Private types
|
||||||
|
|
@ -290,7 +288,7 @@ AABB_traits<GT,P>::intersection(const Sphere& sphere,
|
||||||
|
|
||||||
template<typename GT, typename P>
|
template<typename GT, typename P>
|
||||||
bool
|
bool
|
||||||
AABB_traits<GT,P>::is_smaller(const Sphere& a, const Sphere& b) const
|
AABB_traits<GT,P>::is_contained(const Sphere& a, const Sphere& b) const
|
||||||
{
|
{
|
||||||
CGAL_precondition(a.center() == b.center());
|
CGAL_precondition(a.center() == b.center());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ namespace CGAL {
|
||||||
if ( AABBTraits().intersection(sphere_, primitive, projection) )
|
if ( AABBTraits().intersection(sphere_, primitive, projection) )
|
||||||
{
|
{
|
||||||
const Sphere sphere = AABBTraits().sphere(center_, projection);
|
const Sphere sphere = AABBTraits().sphere(center_, projection);
|
||||||
if ( AABBTraits().is_smaller(sphere, sphere_) )
|
if ( AABBTraits().is_contained(sphere, sphere_) )
|
||||||
{
|
{
|
||||||
projection_ = projection;
|
projection_ = projection;
|
||||||
sphere_ = sphere;
|
sphere_ = sphere;
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ public:
|
||||||
m_datum = *it; // copy triangle
|
m_datum = *it; // copy triangle
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
const Datum& datum() const { return m_datum; }
|
|
||||||
Datum& datum() { return m_datum; }
|
|
||||||
Id id() { return m_it; }
|
Id id() { return m_it; }
|
||||||
|
Datum& datum() { return m_datum; }
|
||||||
|
const Datum& datum() const { return m_datum; }
|
||||||
|
|
||||||
/// Returns the x/y/z reference coordinate for sorting
|
/// Returns the x/y/z reference coordinate for sorting
|
||||||
/// here simply the first vertex of the triangle
|
/// here simply the first vertex of the triangle
|
||||||
|
|
|
||||||
|
|
@ -144,18 +144,23 @@ void test_several_kernels(const char *filename)
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "Polyhedron " << filename << std::endl;
|
std::cout << "Polyhedron " << filename << std::endl;
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
std::cout << "Simple cartesian float kernel" << std::endl;
|
std::cout << "Simple cartesian float kernel" << std::endl;
|
||||||
test<CGAL::Simple_cartesian<float> >(filename);
|
test<CGAL::Simple_cartesian<float> >(filename);
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
std::cout << "Cartesian float kernel" << std::endl;
|
std::cout << "Cartesian float kernel" << std::endl;
|
||||||
test<CGAL::Cartesian<float> >(filename);
|
test<CGAL::Cartesian<float> >(filename);
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
std::cout << "Simple cartesian double kernel" << std::endl;
|
std::cout << "Simple cartesian double kernel" << std::endl;
|
||||||
test<CGAL::Simple_cartesian<double> >(filename);
|
test<CGAL::Simple_cartesian<double> >(filename);
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
std::cout << "Cartesian double kernel" << std::endl;
|
std::cout << "Cartesian double kernel" << std::endl;
|
||||||
test<CGAL::Cartesian<double> >(filename);
|
test<CGAL::Cartesian<double> >(filename);
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
std::cout << "Epic kernel" << std::endl;
|
std::cout << "Epic kernel" << std::endl;
|
||||||
test<CGAL::Exact_predicates_inexact_constructions_kernel>(filename);
|
test<CGAL::Exact_predicates_inexact_constructions_kernel>(filename);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue