mirror of https://github.com/CGAL/cgal
specialized new Bounding box for extended kernel
This commit is contained in:
parent
890ef3b5a1
commit
cfb055ee35
|
|
@ -27,13 +27,14 @@
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
template <typename Traits>
|
template <typename Extended_tag, typename Kernel> class Bounding_box_3;
|
||||||
|
|
||||||
|
template <typename Extended_tag, typename Kernel>
|
||||||
class Bounding_box_3 :
|
class Bounding_box_3 :
|
||||||
public Box_intersection_d::Box_d< double, 3> {
|
public Box_intersection_d::Box_d< double, 3> {
|
||||||
|
|
||||||
typedef Box_intersection_d::Box_d< double, 3> Base;
|
typedef Box_intersection_d::Box_d< double, 3> Base;
|
||||||
|
typedef typename Kernel::Point_3 Point_3;
|
||||||
typedef typename Traits::Point_3 Point_3;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Bounding_box_3() : Base() {}
|
Bounding_box_3() : Base() {}
|
||||||
|
|
@ -43,9 +44,29 @@ public:
|
||||||
q[0] = CGAL::to_interval( p.x() );
|
q[0] = CGAL::to_interval( p.x() );
|
||||||
q[1] = CGAL::to_interval( p.y() );
|
q[1] = CGAL::to_interval( p.y() );
|
||||||
q[2] = CGAL::to_interval( p.z() );
|
q[2] = CGAL::to_interval( p.z() );
|
||||||
Box_intersection_d::Box_d< double, 3 >::extend(q);
|
Base::extend(q);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Kernel>
|
||||||
|
class Bounding_box_3<Tag_true, Kernel> :
|
||||||
|
public Box_intersection_d::Box_d<typename Kernel::FT, 3> {
|
||||||
|
|
||||||
|
typedef typename Kernel::FT FT;
|
||||||
|
typedef Box_intersection_d::Box_d<FT, 3> Base;
|
||||||
|
typedef typename Kernel::Point_3 Point_3;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Bounding_box_3() : Base() {}
|
||||||
|
|
||||||
|
void extend( const Point_3& p) {
|
||||||
|
FT q[3];
|
||||||
|
q[0] = p.x();
|
||||||
|
q[1] = p.y();
|
||||||
|
q[2] = p.z();
|
||||||
|
Base::extend(q);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
#endif // CGAL_BOUNDING_BOX_3_H
|
#endif // CGAL_BOUNDING_BOX_3_H
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ typedef typename Traits::Objects_bbox Objects_bbox;
|
||||||
|
|
||||||
typedef typename Traits::Kernel Kernel;
|
typedef typename Traits::Kernel Kernel;
|
||||||
typedef typename Kernel::RT RT;
|
typedef typename Kernel::RT RT;
|
||||||
|
typedef typename Kernel::FT FT;
|
||||||
|
|
||||||
typedef Smaller_than<
|
typedef Smaller_than<
|
||||||
Kernel,
|
Kernel,
|
||||||
|
|
@ -624,8 +625,8 @@ void divide_segment_by_plane( Segment_3 s, Plane_3 pl,
|
||||||
c = (CGAL::abs(vec[2]) > CGAL::abs(vec[c]) ? 2 : c);
|
c = (CGAL::abs(vec[2]) > CGAL::abs(vec[c]) ? 2 : c);
|
||||||
|
|
||||||
Point_3 pt_on_minus_x_plane = vec[c] < 0 ?
|
Point_3 pt_on_minus_x_plane = vec[c] < 0 ?
|
||||||
Point_3(RT(b.min_coord(0)), RT(b.min_coord(1)),RT(b.min_coord(2))) :
|
Point_3(FT(b.min_coord(0)), FT(b.min_coord(1)),FT(b.min_coord(2))) :
|
||||||
Point_3(RT(b.max_coord(0)), RT(b.max_coord(1)),RT(b.max_coord(2)));
|
Point_3(FT(b.max_coord(0)), FT(b.max_coord(1)),FT(b.max_coord(2)));
|
||||||
// We compute the intersection between a plane with normal vector in
|
// We compute the intersection between a plane with normal vector in
|
||||||
// the minus x direction and located at the minimum point of the bounding box, and the input ray. When the ray does not intersect the bounding volume, there won't be any object hit, so it is safe to construct a segment that simply lay in the unbounded side of the bounding box. This approach is taken instead of somehow (efficiently) report that there was no hit object, in order to mantain a clear interface with the Iterator class.
|
// the minus x direction and located at the minimum point of the bounding box, and the input ray. When the ray does not intersect the bounding volume, there won't be any object hit, so it is safe to construct a segment that simply lay in the unbounded side of the bounding box. This approach is taken instead of somehow (efficiently) report that there was no hit object, in order to mantain a clear interface with the Iterator class.
|
||||||
Plane_3 pl_on_minus_x;
|
Plane_3 pl_on_minus_x;
|
||||||
|
|
|
||||||
|
|
@ -196,18 +196,77 @@ public:
|
||||||
|
|
||||||
typedef typename Kernel::RT RT;
|
typedef typename Kernel::RT RT;
|
||||||
typedef typename Kernel::Kernel_tag Kernel_tag;
|
typedef typename Kernel::Kernel_tag Kernel_tag;
|
||||||
typedef CGAL::Bounding_box_3<Kernel> Bounding_box_3;
|
typedef CGAL::Bounding_box_3
|
||||||
|
<typename Is_extended_kernel<Kernel>::value_type, Kernel>
|
||||||
|
Bounding_box_3;
|
||||||
|
|
||||||
virtual Bounding_box_3 operator()(const Object_list& o) const;
|
Bounding_box_3 operator()( const Object_list& O) const {
|
||||||
virtual Bounding_box_3 operator()(Object_handle o) const;
|
Bounding_box_3 b;
|
||||||
virtual Bounding_box_3 operator()(Vertex_handle v) const;
|
typename Object_list::const_iterator o;
|
||||||
virtual Bounding_box_3 operator()(Halfedge_handle e) const;
|
for( o = O.begin(); o != O.end(); ++o) {
|
||||||
virtual Bounding_box_3 operator()(Halffacet_handle f) const;
|
Vertex_handle v;
|
||||||
virtual Bounding_box_3 operator()(Halffacet_triangle_handle f) const;
|
if( CGAL::assign( v, *o)) {
|
||||||
|
b.extend(v->point());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~Objects_bbox() {}
|
Bounding_box_3 operator()(Object_handle o) const {
|
||||||
|
Vertex_handle v;
|
||||||
|
Halfedge_handle e;
|
||||||
|
Halffacet_handle f;
|
||||||
|
if( CGAL::assign( v, o))
|
||||||
|
return operator()(v);
|
||||||
|
else if( CGAL::assign( e, o))
|
||||||
|
return operator()(e);
|
||||||
|
else if( CGAL::assign( f, o))
|
||||||
|
return operator()(f);
|
||||||
|
else {
|
||||||
|
Halffacet_triangle_handle t;
|
||||||
|
if( CGAL::assign( t, o))
|
||||||
|
return operator()(t);
|
||||||
|
else
|
||||||
|
CGAL_assertion_msg( 0, "wrong handle");
|
||||||
|
}
|
||||||
|
return Bounding_box_3(); // never reached
|
||||||
|
}
|
||||||
|
|
||||||
SNC_decorator D;
|
Bounding_box_3 operator()(Vertex_handle v) const {
|
||||||
|
Bounding_box_3 b;
|
||||||
|
b.extend(v->point());
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bounding_box_3 operator()(Halfedge_handle e) const {
|
||||||
|
Bounding_box_3 b;
|
||||||
|
b.extend(e->source()->point());
|
||||||
|
b.extend(e->twin()->source()->point());
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bounding_box_3 operator()(Halffacet_triangle_handle t) const {
|
||||||
|
Bounding_box_3 bbox;
|
||||||
|
Triangle_3 tr(t.get_triangle());
|
||||||
|
for( int i = 0; i < 3; ++i)
|
||||||
|
bbox.extend(tr[i]);
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bounding_box_3 operator()(Halffacet_handle f) const {
|
||||||
|
CGAL_assertion( f->facet_cycles_begin() !=
|
||||||
|
Halffacet_cycle_iterator());
|
||||||
|
Halffacet_cycle_iterator fc(f->facet_cycles_begin());
|
||||||
|
SHalfedge_handle e;
|
||||||
|
CGAL_assertion(fc.is_shalfedge());
|
||||||
|
e = SHalfedge_handle(fc);
|
||||||
|
SHalfedge_around_facet_circulator sc(e), send(sc);
|
||||||
|
CGAL_assertion( !is_empty_range( sc, send));
|
||||||
|
Bounding_box_3 b;
|
||||||
|
CGAL_For_all( sc, send)
|
||||||
|
b.extend(sc->source()->source()->point());
|
||||||
|
return b;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Decorator>
|
template <class Decorator>
|
||||||
|
|
@ -244,7 +303,9 @@ public:
|
||||||
|
|
||||||
typedef typename Kernel::RT RT;
|
typedef typename Kernel::RT RT;
|
||||||
typedef typename Kernel::Kernel_tag Kernel_tag;
|
typedef typename Kernel::Kernel_tag Kernel_tag;
|
||||||
typedef CGAL::Bounding_box_3<Kernel> Bounding_box_3;
|
typedef CGAL::Bounding_box_3
|
||||||
|
<typename Is_extended_kernel<Kernel>::value_type, Kernel>
|
||||||
|
Bounding_box_3;
|
||||||
|
|
||||||
typedef typename Kernel::Intersect_3 Intersect;
|
typedef typename Kernel::Intersect_3 Intersect;
|
||||||
typedef CGAL::Objects_bbox<SNC_decorator> Objects_bbox;
|
typedef CGAL::Objects_bbox<SNC_decorator> Objects_bbox;
|
||||||
|
|
@ -549,91 +610,6 @@ Side_of_plane<SNC_decorator>::operator()
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
( const Object_list& O) const {
|
|
||||||
Bounding_box_3 b;
|
|
||||||
typename Object_list::const_iterator o;
|
|
||||||
for( o = O.begin(); o != O.end(); ++o) {
|
|
||||||
Vertex_handle v;
|
|
||||||
if( CGAL::assign( v, *o)) {
|
|
||||||
b.extend(v->point());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
(Object_handle o) const {
|
|
||||||
Vertex_handle v;
|
|
||||||
Halfedge_handle e;
|
|
||||||
Halffacet_handle f;
|
|
||||||
if( CGAL::assign( v, o))
|
|
||||||
return operator()(v);
|
|
||||||
else if( CGAL::assign( e, o))
|
|
||||||
return operator()(e);
|
|
||||||
else if( CGAL::assign( f, o))
|
|
||||||
return operator()(f);
|
|
||||||
else {
|
|
||||||
Halffacet_triangle_handle t;
|
|
||||||
if( CGAL::assign( t, o))
|
|
||||||
return operator()(t);
|
|
||||||
else
|
|
||||||
CGAL_assertion_msg( 0, "wrong handle");
|
|
||||||
}
|
|
||||||
return Bounding_box_3(); // never reached
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
(Vertex_handle v) const {
|
|
||||||
Bounding_box_3 b;
|
|
||||||
b.extend(v->point());
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
(Halfedge_handle e) const {
|
|
||||||
Bounding_box_3 b;
|
|
||||||
b.extend(e->source()->point());
|
|
||||||
b.extend(e->twin()->source()->point());
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
(Halffacet_triangle_handle t) const {
|
|
||||||
Bounding_box_3 bbox;
|
|
||||||
Triangle_3 tr(t.get_triangle());
|
|
||||||
for( int i = 0; i < 3; ++i)
|
|
||||||
bbox.extend(tr[i]);
|
|
||||||
return bbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class SNC_decorator>
|
|
||||||
Bounding_box_3<typename SNC_decorator::Kernel>
|
|
||||||
Objects_bbox<SNC_decorator>::operator()
|
|
||||||
(Halffacet_handle f) const {
|
|
||||||
CGAL_assertion( f->facet_cycles_begin() != Halffacet_cycle_iterator());
|
|
||||||
Halffacet_cycle_iterator fc(f->facet_cycles_begin());
|
|
||||||
SHalfedge_handle e;
|
|
||||||
CGAL_assertion(fc.is_shalfedge());
|
|
||||||
e = SHalfedge_handle(fc);
|
|
||||||
SHalfedge_around_facet_circulator sc(e), send(sc);
|
|
||||||
CGAL_assertion( !is_empty_range( sc, send));
|
|
||||||
Bounding_box_3 b;
|
|
||||||
CGAL_For_all( sc, send)
|
|
||||||
b.extend(sc->source()->source()->point());
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_NEF_SNC_K3_TREE_TRAITS_H
|
#endif // CGAL_NEF_SNC_K3_TREE_TRAITS_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue