Move 3D .bbox() to the functors to make Lazy_kernel pass, and enhance the test-suite to test .bbox()

This commit is contained in:
Sylvain Pion 2006-12-27 23:26:06 +00:00
parent 370e6a1695
commit 70b3bee5af
21 changed files with 209 additions and 98 deletions

View File

@ -17,16 +17,17 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL_ISO_CUBOID_3_H
#define CGAL_ISO_CUBOID_3_H
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -73,7 +74,7 @@ public:
top, far_, close)) {}
Iso_cuboid_3(const RT& min_hx, const RT& min_hy, const RT& min_hz,
const RT& max_hx, const RT& max_hy, const RT& max_hz,
const RT& max_hx, const RT& max_hy, const RT& max_hz,
const RT& hw)
: Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), min_hx, min_hy, min_hz,
max_hx, max_hy, max_hz, hw)) {}
@ -83,7 +84,7 @@ public:
: Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), min_hx, min_hy, min_hz,
max_hx, max_hy, max_hz)) {}
// TODO FIXME : why is Qrt not working here ?
// TODO FIXME : why is Qrt not working here ?
// TODO : the Cartesian and Homogeneous functors should be split here
// given that the Qrt differs.
// (or is the Homogeneous optimization simply not worth it ?)
@ -159,7 +160,7 @@ public:
return xmin();
else if (i == 1)
return ymin();
else
else
return zmin();
}
@ -171,7 +172,7 @@ public:
return xmax();
else if (i == 1)
return ymax();
else
else
return zmax();
}
@ -217,6 +218,12 @@ public:
return R().compute_volume_3_object()(*this);
}
Bbox_3
bbox() const
{
return R().construct_bbox_3_object()(*this);
}
};

View File

@ -1703,45 +1703,6 @@ namespace CommonKernelFunctors {
{ return t.rep().vertex(i); }
};
template <typename K>
class Construct_bbox_3
{
typedef typename K::Point_3 Point_3;
typedef typename K::Segment_3 Segment_3;
typedef typename K::Iso_cuboid_3 Iso_cuboid_3;
typedef typename K::Triangle_3 Triangle_3;
typedef typename K::Tetrahedron_3 Tetrahedron_3;
typedef typename K::Sphere_3 Sphere_3;
public:
typedef Bbox_3 result_type;
typedef Arity_tag< 1 > Arity;
Bbox_3
operator()( const Point_3& p) const
{ return p.bbox(); }
Bbox_3
operator()( const Segment_3& s) const
{ return s.bbox(); }
Bbox_3
operator()( const Triangle_3& t) const
{ return t.bbox(); }
Bbox_3
operator()( const Iso_cuboid_3& r) const
{ return r.bbox(); }
Bbox_3
operator()( const Tetrahedron_3& t) const
{ return t.bbox(); }
Bbox_3
operator()( const Sphere_3& s) const
{ return s.bbox(); }
};
template <typename K>
class Construct_cartesian_const_iterator_2
{

View File

@ -29,6 +29,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -160,6 +161,11 @@ public:
return 3;
}
Bbox_3 bbox() const
{
return R().construct_bbox_3_object()(*this);
}
Point_3 transform(const Aff_transformation_3 &t) const
{
return t.transform(*this);

View File

@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
CGAL_BEGIN_NAMESPACE
@ -118,7 +119,10 @@ public:
bool is_degenerate() const;
Bbox_2 bbox() const;
Bbox_2 bbox() const
{
return R().construct_bbox_2_object()(*this);
}
bool
operator==(const Segment_2 &s) const
@ -126,7 +130,6 @@ public:
return R().equal_2_object()(*this, s);
}
bool
operator!=(const Segment_2 &s) const
{
@ -269,14 +272,6 @@ Segment_2<R_>::is_degenerate() const
}
template < class R_ >
CGAL_KERNEL_INLINE
Bbox_2
Segment_2<R_>::bbox() const
{
return R().construct_bbox_2_object()(*this);
}
template < class R >
std::ostream &

View File

@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -158,6 +159,11 @@ public:
return R().is_degenerate_3_object()(*this);
}
Bbox_3 bbox() const
{
return R().construct_bbox_3_object()(*this);
}
Line_3
supporting_line() const
{

View File

@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -161,6 +162,12 @@ public:
//return CGAL_NTS is_zero(squared_radius());
}
Bbox_3
bbox() const
{
return R().construct_bbox_3_object()(*this);
}
};
template <class R_>

View File

@ -17,7 +17,7 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Andreas Fabri, Stefan Schirra
@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -139,6 +140,12 @@ public:
return R().compute_volume_3_object()(*this);
}
Bbox_3
bbox() const
{
return R().construct_bbox_3_object()(*this);
}
};

View File

@ -17,7 +17,7 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Andreas Fabri
@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
CGAL_BEGIN_NAMESPACE
@ -70,7 +71,7 @@ public:
{
return R().compute_area_2_object()(vertex(0), vertex(1), vertex(2));
}
Orientation
orientation() const
{
@ -83,96 +84,85 @@ public:
return R().bounded_side_2_object()(*this,p);
}
Oriented_side
oriented_side(const Point_2 &p) const
{
return R().oriented_side_2_object()(*this,p);
}
bool
operator==(const Triangle_2 &t) const
{
return R().equal_2_object()(*this,t);
}
bool
operator!=(const Triangle_2 &t) const
{
return !(*this == t);
}
typename Qualified_result_of<typename R::Construct_vertex_2, Triangle_2, int>::type
vertex(int i) const
{
return R().construct_vertex_2_object()(*this,i);
}
typename Qualified_result_of<typename R::Construct_vertex_2, Triangle_2, int>::type
operator[](int i) const
{
return vertex(i);
}
bool
has_on_bounded_side(const Point_2 &p) const
{
return bounded_side(p) == ON_BOUNDED_SIDE;
}
bool
has_on_unbounded_side(const Point_2 &p) const
{
return bounded_side(p) == ON_UNBOUNDED_SIDE;
}
bool
has_on_boundary(const Point_2 &p) const
{
return bounded_side(p) == ON_BOUNDARY;
}
bool
has_on_negative_side(const Point_2 &p) const
{
return oriented_side(p) == ON_NEGATIVE_SIDE;
}
bool
has_on_positive_side(const Point_2 &p) const
{
return oriented_side(p) == ON_POSITIVE_SIDE;
}
bool
is_degenerate() const
{
return R().collinear_2_object()(vertex(0), vertex(1), vertex(2));
}
Bbox_2
bbox() const
{
return R().construct_bbox_2_object()(*this);
}
Triangle_2
opposite() const
{
return R().construct_opposite_triangle_2_object()(*this);
}
Triangle_2
Triangle_2
transform(const Aff_transformation_2 &t) const
{
return Triangle_2(t.transform(vertex(0)),

View File

@ -17,7 +17,7 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Andreas Fabri, Stefan Schirra
@ -27,6 +27,7 @@
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_3.h>
CGAL_BEGIN_NAMESPACE
@ -98,6 +99,12 @@ public:
return R().is_degenerate_3_object()(*this);
}
Bbox_3
bbox() const
{
return R().construct_bbox_3_object()(*this);
}
FT squared_area() const // TODO : use Qrt
{
return R().compute_squared_area_3_object()(*this);

View File

@ -14,14 +14,16 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL__TEST_CLS_CIRCLE_2_H
#define CGAL__TEST_CLS_CIRCLE_2_H
#include <CGAL/Bbox_2.h>
template <class R>
bool
_test_cls_circle_2(const R& )
@ -61,7 +63,7 @@ _test_cls_circle_2(const R& )
CGAL::Circle_2<R> c1( p0, p1, p2);
CGAL::Circle_2<R> c2( p0, p1, p3);
CGAL::Circle_2<R> c3( p1, p0, p2);
CGAL::Circle_2<R> c4( p3, FT( n9 )); // n9 = (n6)^2
const CGAL::Circle_2<R> c4( p3, FT( n9 )); // n9 = (n6)^2
CGAL::Vector_2<R> vx6 = vx * n6;
CGAL::Vector_2<R> vy6 = vy * n6;
CGAL::Circle_2<R> c5( p3 - vx6, p3 + vx6, p3 + vy6);
@ -172,7 +174,16 @@ _test_cls_circle_2(const R& )
assert( c12.is_degenerate() );
assert( c13.is_degenerate() );
std::cout << '.';
CGAL::Bbox_2 bb = c4.bbox();
assert(bb.xmin() <= -4.0);
assert(bb.xmax() >= 8.0);
assert(bb.ymin() <= -4.0);
assert(bb.ymax() >= 8.0);
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_CLS_CIRCLE_2_H

View File

@ -14,14 +14,16 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL__TEST_CLS_ISO_CUBOID_3_H
#define CGAL__TEST_CLS_ISO_CUBOID_3_H
#include <CGAL/Bbox_3.h>
template <class R>
bool
_test_cls_iso_cuboid_3(const R& )
@ -60,7 +62,7 @@ _test_cls_iso_cuboid_3(const R& )
CGAL::Point_3<R> p12(n1, n1, n3 ); // ( 1, 1, 3)
CGAL::Point_3<R> p13(n4, n1, n3 ); // ( 4, 1, 3)
CGAL::Iso_cuboid_3<R> r1( p1, p3);
const CGAL::Iso_cuboid_3<R> r1( p1, p3);
CGAL::Iso_cuboid_3<R> r1_( p1, p3, 0);
CGAL::Iso_cuboid_3<R> r2( p3, p1);
CGAL::Iso_cuboid_3<R> r3( p2, p5);
@ -162,6 +164,16 @@ _test_cls_iso_cuboid_3(const R& )
assert( r3.volume() == r4.volume() );
assert( r5.volume() == FT(84) );
std::cout << '.';
CGAL::Bbox_3 bb = r1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 4.0);
assert(bb.ymin() <= 1.0);
assert(bb.ymax() >= 4.0);
assert(bb.zmin() <= 1.0);
assert(bb.zmax() >= 3.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -14,14 +14,16 @@
//
// $URL$
// $Id$
//
//
//
// Author(s) : Stefan Schirra
#ifndef CGAL__TEST_CLS_ISO_RECTANGLE_2_H
#define CGAL__TEST_CLS_ISO_RECTANGLE_2_H
#include <CGAL/Bbox_2.h>
template <class R>
bool
_test_cls_iso_rectangle_2(const R& )
@ -54,7 +56,7 @@ _test_cls_iso_rectangle_2(const R& )
CGAL::Point_2<R> p8( n4, n6, n2); // ( 2, 3)
CGAL::Point_2<R> p9(-n3, n7); // (-3, 7)
CGAL::Iso_rectangle_2<R> r1( p1, p3);
const CGAL::Iso_rectangle_2<R> r1( p1, p3);
CGAL::Iso_rectangle_2<R> r1_( p1, p3, 0);
CGAL::Iso_rectangle_2<R> r2( p3, p1);
CGAL::Iso_rectangle_2<R> r3( p2, p5);
@ -109,7 +111,7 @@ _test_cls_iso_rectangle_2(const R& )
assert( (r2.max)() == p3 );
std::cout << '.';
assert ( r1.min_coord(0) == r1.xmin() );
assert ( r1.min_coord(1) == r1.ymin() );
assert ( r2.max_coord(0) == r2.xmax() );
@ -145,6 +147,14 @@ _test_cls_iso_rectangle_2(const R& )
assert( CGAL::Iso_rectangle_2<R>( p1, p7 ).area() == FT(1) );
assert( CGAL::Iso_rectangle_2<R>( p9, p3 ).area() == FT(21) );
std::cout << '.';
CGAL::Bbox_2 bb = r1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 4.0);
assert(bb.ymin() <= 1.0);
assert(bb.ymax() >= 4.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_POINT_2_H
#define CGAL__TEST_CLS_POINT_2_H
#include <CGAL/Bbox_2.h>
template <class R>
bool
_test_cls_point_2(const R& )
@ -158,6 +160,14 @@ _test_cls_point_2(const R& )
it2++;
assert(it == it2);
std::cout << '.';
CGAL::Bbox_2 bb = p3.bbox();
assert(bb.xmin() <= -35.0);
assert(bb.xmax() >= -35.0);
assert(bb.ymin() <= 50.0);
assert(bb.ymax() >= 50.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_POINT_3_H
#define CGAL__TEST_CLS_POINT_3_H
#include <CGAL/Bbox_3.h>
template <class R>
bool
_test_cls_point_3(const R& )
@ -170,6 +172,16 @@ _test_cls_point_3(const R& )
assert(it == it2);
std::cout << '.';
CGAL::Bbox_3 bb = p3.bbox();
assert(bb.xmin() <= -35.0);
assert(bb.xmax() >= -35.0);
assert(bb.ymin() <= 50.0);
assert(bb.ymax() >= 50.0);
assert(bb.zmin() <= -20.0);
assert(bb.zmax() >= -20.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_SEGMENT_2_H
#define CGAL__TEST_CLS_SEGMENT_2_H
#include <CGAL/Bbox_2.h>
template <class R>
bool
_test_cls_segment_2(const R& )
@ -121,7 +123,16 @@ _test_cls_segment_2(const R& )
assert( CGAL::Segment_2<R>( p3, p3).is_degenerate() );
std::cout << '.';
CGAL::Bbox_2 bb = s1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 5.0);
assert(bb.ymin() <= 2.0);
assert(bb.ymax() >= 4.0);
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_CLS_SEGMENT_2_H

View File

@ -104,6 +104,16 @@ _test_cls_segment_3(const R& )
assert( sdeg.is_degenerate() );
assert( CGAL::parallel(sdeg, sdeg) );
std::cout << '.';
CGAL::Bbox_3 bb = s2.bbox();
assert(bb.xmin() <= -2.0);
assert(bb.xmax() >= 1.0);
assert(bb.ymin() <= 1.0);
assert(bb.ymax() >= 3.0);
assert(bb.zmin() <= 2.0);
assert(bb.zmax() >= 4.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_SPHERE_3_H
#define CGAL__TEST_CLS_SPHERE_3_H
#include <CGAL/Bbox_3.h>
template <class R>
bool
_test_cls_sphere_3(const R& )
@ -61,7 +63,7 @@ _test_cls_sphere_3(const R& )
CGAL::Sphere_3<R> c1( p0, p1, p2, p4);
CGAL::Sphere_3<R> c2( p0, p1, p3, p5);
CGAL::Sphere_3<R> c3( p1, p0, p2, p4);
CGAL::Sphere_3<R> c4( p3, FT( n9 )); // n9 = (n6)^2
const CGAL::Sphere_3<R> c4( p3, FT( n9 )); // n9 = (n6)^2
CGAL::Vector_3<R> vx6 = vx * n6;
CGAL::Vector_3<R> vy6 = vy * n6;
CGAL::Sphere_3<R> c5( p3 - vx6, p3 + vx6, p3 + vy6);
@ -228,6 +230,16 @@ _test_cls_sphere_3(const R& )
assert( c12.is_degenerate() );
assert( c13.is_degenerate() );
std::cout << '.';
CGAL::Bbox_3 bb = c4.bbox();
assert(bb.xmin() <= -4.0);
assert(bb.xmax() >= 8.0);
assert(bb.ymin() <= -4.0);
assert(bb.ymax() >= 8.0);
assert(bb.zmin() <= -4.0);
assert(bb.zmax() >= 8.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_TETRAHEDRON_3_H
#define CGAL__TEST_CLS_TETRAHEDRON_3_H
#include <CGAL/Bbox_3.h>
template <class R>
bool
_test_cls_tetrahedron_3(const R& )
@ -46,7 +48,7 @@ _test_cls_tetrahedron_3(const R& )
RT n9 = 8;
CGAL::Point_3<R> p1( n1, n2, n3, n4); // (6, 8, -2)
CGAL::Point_3<R> p2( n2, n9, n3,-n3); // (4, -2, -1)
CGAL::Point_3<R> p2( n2, n9, n3,-n3); // (4, 2, -1)
CGAL::Point_3<R> p3( n5, n6, n1, n5); // (1, 10, 4)
CGAL::Point_3<R> p4( n7, n7, n8, n5); // (3, 3, 8)
@ -55,7 +57,7 @@ _test_cls_tetrahedron_3(const R& )
CGAL::Point_3<R> ps1( n7, n0, n0, n5); // (3, 0, 0)
CGAL::Point_3<R> ps0( CGAL::ORIGIN ); // (0, 0, 0)
CGAL::Tetrahedron_3<R> t1(p1,p2,p3,p4);
const CGAL::Tetrahedron_3<R> t1(p1,p2,p3,p4);
CGAL::Tetrahedron_3<R> t2(p2,p1,p3,p4);
CGAL::Tetrahedron_3<R> t3(ps0,ps1,ps2,ps3); // positive oriented
CGAL::Tetrahedron_3<R> t4(ps0,ps1,ps3,ps2); // negative oriented
@ -169,7 +171,18 @@ _test_cls_tetrahedron_3(const R& )
assert ( t9.volume() == FT(-288) );
assert ( CGAL::volume(ps0,p10,p11,p12) == FT(-288) );
std::cout << '.';
CGAL::Bbox_3 bb = t1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 6.0);
assert(bb.ymin() <= 2.0);
assert(bb.ymax() >= 10.0);
assert(bb.zmin() <= -2.0);
assert(bb.zmax() >= 8.0);
std::cout << "done" << std::endl;
return true;
}
#endif // CGAL__TEST_CLS_TETRAHEDRON_3_H

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_TRIANGLE_2_H
#define CGAL__TEST_CLS_TRIANGLE_2_H
#include <CGAL/Bbox_2.h>
template <class R>
bool
_test_cls_triangle_2(const R& )
@ -140,6 +142,14 @@ _test_cls_triangle_2(const R& )
assert ( t2.area() == -t5.area() );
assert ( t3.area() == FT(5) );
std::cout << '.';
CGAL::Bbox_2 bb = t1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 7.0);
assert(bb.ymin() <= 1.0);
assert(bb.ymax() >= 5.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -22,6 +22,8 @@
#ifndef CGAL__TEST_CLS_TRIANGLE_3_H
#define CGAL__TEST_CLS_TRIANGLE_3_H
#include <CGAL/Bbox_3.h>
template <class R>
bool
_test_cls_triangle_3(const R& )
@ -46,7 +48,7 @@ _test_cls_triangle_3(const R& )
RT n9 = 8;
CGAL::Point_3<R> p1( n1, n2, n3, n4); // (6, 8, -2)
CGAL::Point_3<R> p2( n2, n9, n3,-n3); // (-4, 2, -1)
CGAL::Point_3<R> p2( n2, n9, n3,-n3); // (4, 2, -1)
CGAL::Point_3<R> p3( n5, n6, n1, n5); // (1, 10, 4)
CGAL::Point_3<R> p4( n7, n7, n8, n5); // (3, 3, 6)
CGAL::Point_3<R> p5( n2, n1, n0, n4); // (8, 6, 0)
@ -56,7 +58,7 @@ _test_cls_triangle_3(const R& )
CGAL::Point_3<R> ps2( n0, n7, n0, n5); // (0, 3, 0)
CGAL::Point_3<R> ps1( n7, n0, n0, n5); // (3, 0, 0)
CGAL::Triangle_3<R> t1(p1,p2,p3);
const CGAL::Triangle_3<R> t1(p1,p2,p3);
CGAL::Triangle_3<R> t2(p4,p2,p3);
CGAL::Triangle_3<R> t3(ps1,ps2,ps3);
CGAL::Triangle_3<R> t4(ps2,ps1,ps3);
@ -111,6 +113,16 @@ _test_cls_triangle_3(const R& )
assert ( t6.squared_area() == FT(25) );
assert ( t6.squared_area() == CGAL::squared_area(ps3,p5,p6) );
std::cout << '.';
CGAL::Bbox_3 bb = t1.bbox();
assert(bb.xmin() <= 1.0);
assert(bb.xmax() >= 6.0);
assert(bb.ymin() <= 2.0);
assert(bb.ymax() >= 10.0);
assert(bb.zmin() <= -2.0);
assert(bb.zmax() >= 4.0);
std::cout << "done" << std::endl;
return true;
}

View File

@ -21,6 +21,8 @@ CXXFLAGS = \
-I../../../Filtered_kernel/include \
-I../../../Cartesian_kernel/include \
-I../../../Homogeneous_kernel/include \
-I../../../STL_Extension/include \
-I../../../Timer/include \
$(TESTSUITE_CXXFLAGS) \
$(EXTRA_FLAGS) \
$(CGAL_CXXFLAGS) \