mirror of https://github.com/CGAL/cgal
WIP review
This commit is contained in:
parent
9ede1f3ee7
commit
3c875e8a18
|
|
@ -39,18 +39,17 @@ do_intersect(const CGAL::Bbox_2& c,
|
|||
return CGAL::do_overlap(c, bbox);
|
||||
}
|
||||
|
||||
typename boost::optional< typename
|
||||
boost::variant< Bbox_2> >
|
||||
typename boost::optional< typename boost::variant< Bbox_2> >
|
||||
inline
|
||||
intersection(const CGAL::Bbox_2& a,
|
||||
const CGAL::Bbox_2& b) {
|
||||
|
||||
typedef typename
|
||||
boost::variant< Bbox_2> variant_type;
|
||||
typedef typename boost::optional< variant_type > Result_type;
|
||||
typedef typename boost::optional< variant_type > result_type;
|
||||
if(!do_intersect(a,b))
|
||||
{
|
||||
return Result_type();
|
||||
return result_type();
|
||||
}
|
||||
|
||||
double xmin, xmax, ymin, ymax;
|
||||
|
|
@ -60,7 +59,7 @@ intersection(const CGAL::Bbox_2& a,
|
|||
ymin = (std::max)(a.ymin(), b.ymin());
|
||||
ymax = (std::min)(a.ymax(), b.ymax());
|
||||
|
||||
return Result_type(std::forward<Bbox_2>(Bbox_2(xmin, ymin, xmax, ymax)));
|
||||
return result_type(std::forward<Bbox_2>(Bbox_2(xmin, ymin, xmax, ymax)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/Iso_rectangle_2.h>
|
||||
#include <CGAL/kernel_assertions.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/Intersections_2/Iso_rectangle_2_Iso_rectangle_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -34,35 +32,34 @@ namespace CGAL {
|
|||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Iso_rectangle_2<K> &line,
|
||||
const Iso_rectangle_2<K> &rect,
|
||||
const Bbox_2 &box)
|
||||
{
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return do_intersect(rec, line);
|
||||
return do_intersect(K::Iso_rectangle_2(box), rect);
|
||||
}
|
||||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Bbox_2 &box,
|
||||
const Iso_rectangle_2<K> &line)
|
||||
const Iso_rectangle_2<K> &rect)
|
||||
{
|
||||
return do_intersect(line, box);
|
||||
return do_intersect(rect, box);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Iso_rectangle_2, Bbox_2>::result_type
|
||||
intersection(const CGAL::Bbox_2& box,
|
||||
const Iso_rectangle_2<K>& line) {
|
||||
intersection(const Bbox_2& box,
|
||||
const Iso_rectangle_2<K>& rect) {
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return intersection(rec, line);
|
||||
return intersection(rec, rect);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Iso_rectangle_2, Bbox_2>::result_type
|
||||
intersection(const Iso_rectangle_2<K>& line,
|
||||
const CGAL::Bbox_2& box) {
|
||||
return intersection(box, line);
|
||||
intersection(const Iso_rectangle_2<K>& rect,
|
||||
const Bbox_2& box) {
|
||||
return intersection(box, rect);
|
||||
}
|
||||
|
||||
}
|
||||
#endif // BBOX_2_ISO_RECTANGLE_2_H
|
||||
#endif // CGAL_INTERSECTIONS_BBOX_2_ISO_RECTANGLE_2_H
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <CGAL/Intersections_2/Iso_rectangle_2_Point_2.h>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
namespace Intersections {
|
||||
namespace internal {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/Segment_2.h>
|
||||
#include <CGAL/kernel_assertions.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/Intersections_2/Iso_rectangle_2_Segment_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -34,35 +32,35 @@ namespace CGAL {
|
|||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Segment_2<K> &line,
|
||||
const Segment_2<K> &seg,
|
||||
const Bbox_2 &box)
|
||||
{
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return do_intersect(rec, line);
|
||||
return do_intersect(rec, seg);
|
||||
}
|
||||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Bbox_2 &box,
|
||||
const Segment_2<K> &line)
|
||||
const Segment_2<K> &seg)
|
||||
{
|
||||
return do_intersect(line, box);
|
||||
return do_intersect(seg, box);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Segment_2, Bbox_2>::result_type
|
||||
intersection(const CGAL::Bbox_2& box,
|
||||
const Segment_2<K>& line) {
|
||||
const Segment_2<K>& seg) {
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return intersection(rec, line);
|
||||
return intersection(rec, seg);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Segment_2, Bbox_2>::result_type
|
||||
intersection(const Segment_2<K>& line,
|
||||
intersection(const Segment_2<K>& seg,
|
||||
const CGAL::Bbox_2& box) {
|
||||
return intersection(box, line);
|
||||
return intersection(box, seg);
|
||||
}
|
||||
|
||||
}
|
||||
#endif // BBOX_2_SEGMENT_2_H
|
||||
#endif // CGAL_INTERSECTIONS_BBOX_2_SEGMENT_2_H
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/Triangle_2.h>
|
||||
#include <CGAL/kernel_assertions.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/Intersections_2/Iso_rectangle_2_Triangle_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -34,35 +32,35 @@ namespace CGAL {
|
|||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Triangle_2<K> &line,
|
||||
const Triangle_2<K> &tr,
|
||||
const Bbox_2 &box)
|
||||
{
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return do_intersect(rec, line);
|
||||
return do_intersect(rec, tr);
|
||||
}
|
||||
|
||||
template <class K>
|
||||
inline bool do_intersect(
|
||||
const Bbox_2 &box,
|
||||
const Triangle_2<K> &line)
|
||||
const Triangle_2<K> &tr)
|
||||
{
|
||||
return do_intersect(line, box);
|
||||
return do_intersect(tr, box);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Triangle_2, Bbox_2>::result_type
|
||||
intersection(const CGAL::Bbox_2& box,
|
||||
const Triangle_2<K>& line) {
|
||||
intersection(const Bbox_2& box,
|
||||
const Triangle_2<K>& tr) {
|
||||
typename K::Iso_rectangle_2 rec(box.xmin(), box.ymin(), box.xmax(), box.ymax());
|
||||
return intersection(rec, line);
|
||||
return intersection(rec, tr);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
typename Intersection_traits<K, typename K::Triangle_2, Bbox_2>::result_type
|
||||
intersection(const Triangle_2<K>& line,
|
||||
const CGAL::Bbox_2& box) {
|
||||
return intersection(box, line);
|
||||
intersection(const Triangle_2<K>& tr,
|
||||
const Bbox_2& box) {
|
||||
return intersection(box, tr);
|
||||
}
|
||||
|
||||
}
|
||||
#endif // BBOX_2_TRIANGLE_2_H
|
||||
#endif // CGAL_INTERSECTIONS_BBOX_2_TRIANGLE_2_H
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
namespace CGAL {
|
||||
namespace Intersections {
|
||||
namespace internal {
|
||||
|
||||
template <class K>
|
||||
bool
|
||||
do_intersect(const typename K::Circle_2 & c,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
namespace CGAL {
|
||||
namespace Intersections {
|
||||
namespace internal {
|
||||
|
||||
template <class K>
|
||||
bool
|
||||
do_intersect(const typename K::Circle_2 & c,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
namespace CGAL {
|
||||
namespace Intersections {
|
||||
namespace internal {
|
||||
|
||||
template <class K>
|
||||
bool
|
||||
do_intersect(const typename K::Circle_2 & c,
|
||||
|
|
|
|||
|
|
@ -329,9 +329,9 @@ Triangle_2_Triangle_2_pair<K>::intersection_point() const
|
|||
|
||||
|
||||
//algorithm taken from here : https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
|
||||
template <typename K, typename ArrayOfPoints, typename Exact>
|
||||
template <typename K, typename Exact>
|
||||
struct Is_cw{
|
||||
bool operator()(const ArrayOfPoints& ps)
|
||||
bool operator()(const std::vector<typename K::Point_2>& ps)
|
||||
{
|
||||
typename K::FT res(0);
|
||||
std::size_t length = ps.size();
|
||||
|
|
@ -343,9 +343,9 @@ bool operator()(const ArrayOfPoints& ps)
|
|||
}
|
||||
};
|
||||
|
||||
template <typename K, typename ArrayOfPoints>
|
||||
struct Is_cw<K, ArrayOfPoints,Tag_true>{
|
||||
bool operator()(const ArrayOfPoints& ps)
|
||||
template <typename K>
|
||||
struct Is_cw<K,Tag_true>{
|
||||
bool operator()(const std::vector<typename K::Point_2>& ps)
|
||||
{
|
||||
return !CGAL::left_turn(ps[0], ps[1], ps[2]);
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ intersection(const typename K::Triangle_2 &tr1,
|
|||
for (int i =0; i < ispair.vertex_count(); i++) {
|
||||
points[i] = ispair.vertex(i);
|
||||
}
|
||||
if(Is_cw<K, Container, typename Algebraic_structure_traits<typename K::FT>::Is_exact>()(points))
|
||||
if(Is_cw<K, typename Algebraic_structure_traits<typename K::FT>::Is_exact>()(points))
|
||||
{
|
||||
std::size_t length = points.size();
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ struct Test
|
|||
{
|
||||
if (p.size() != q.size())
|
||||
return false;
|
||||
if (CGAL::Intersections::internal::Is_cw<K, Pol,
|
||||
if (CGAL::Intersections::internal::Is_cw<K,
|
||||
typename CGAL::Algebraic_structure_traits<typename K::FT>::Is_exact>()(p))
|
||||
return false;
|
||||
for(typename Pol::const_iterator itp = p.begin(), itq = q.begin(); itp != p.end(); ++itp, ++itq)
|
||||
|
|
@ -110,9 +110,12 @@ struct Test
|
|||
|
||||
bool approx_equal(const T & p, const T & q)
|
||||
{
|
||||
std::vector<P> vec(3);
|
||||
for(int i=0; i<3; ++i){vec[i]=p[i];}
|
||||
if (CGAL::Intersections::internal::Is_cw<K, std::vector<P>,
|
||||
if(p.size() != q.size())
|
||||
return false;
|
||||
|
||||
std::vector<P> vec { p[0], p[1], p[2] };
|
||||
|
||||
if (CGAL::Intersections::internal::Is_cw<K,
|
||||
typename CGAL::Algebraic_structure_traits<typename K::FT>::Is_exact>(vec))
|
||||
return false;
|
||||
return p == q;
|
||||
|
|
@ -336,11 +339,15 @@ struct Test
|
|||
|
||||
check_no_do_intersect (C(p( 2, 8), 6), S(p(-3, -2), p( 2, -4)));
|
||||
check_no_do_intersect (C(p( 2, 8), 6), S(p(-3, 22), p( 2, 34)));
|
||||
check_no_do_intersect (C(p( 2, 8), 9), S(p(2.5, 3.5), p(3, 4)));
|
||||
|
||||
check_do_intersect (C(p( 3, 4), 0), S(p(-3, 8), p( 6, 2)));
|
||||
check_do_intersect (C(p( 4, 3), 4), S(p( 6, -7), p( 5, 2)));
|
||||
|
||||
check_do_intersect (C(p(-3, 1), 7), S(p(-1, -3), p(-6, 7)));
|
||||
|
||||
check_do_intersect (C(p(1, 1), 4), S(p(-1, 1), p(-6, -8)));
|
||||
check_do_intersect (C(p(1, 1), 4), S(p(-1, 4), p(-1, -4)));
|
||||
}
|
||||
|
||||
void C_R()
|
||||
|
|
@ -360,6 +367,7 @@ struct Test
|
|||
{
|
||||
std::cout << "Circle - Triangle" << std::endl;
|
||||
check_no_do_intersect (C(p( 2, 8), 6), T(p(6,0), p( 8, 0), p(8,2)));
|
||||
check_no_do_intersect (C(p( 0, 0), 9), T(p(1,1), p( 1, -1), p(0.1,0.1)));
|
||||
|
||||
check_do_intersect (C(p( 3, 4), 0), T(p(-3, 8), p( 6, 2), p(4,6)));
|
||||
check_do_intersect (C(p( 4, 3), 4), T(p( 6, -7), p( 5, 2), p(2,-3)));
|
||||
|
|
|
|||
|
|
@ -39,9 +39,10 @@ CGAL_INTERSECTION_TRAITS_2(Line_3, Segment_3, Point_3, Segment_3)
|
|||
CGAL_INTERSECTION_TRAITS_2(Segment_3, Line_3, Point_3, Segment_3)
|
||||
|
||||
CGAL_INTERSECTION_TRAITS_2(Line_3, Triangle_3, Point_3, Segment_3)
|
||||
CGAL_INTERSECTION_TRAITS_2(Line_3, Tetrahedron_3, Point_3, Segment_3)
|
||||
CGAL_INTERSECTION_TRAITS_2(Triangle_3, Line_3, Point_3, Segment_3)
|
||||
|
||||
CGAL_INTERSECTION_TRAITS_2(Line_3, Tetrahedron_3, Point_3, Segment_3)
|
||||
|
||||
CGAL_INTERSECTION_TRAITS_2(Plane_3, Plane_3, Line_3, Plane_3)
|
||||
|
||||
CGAL_INTERSECTION_TRAITS_2(Plane_3, Ray_3, Point_3, Ray_3)
|
||||
|
|
|
|||
Loading…
Reference in New Issue