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