Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] do_intersect bug
- Date: Tue, 12 Jul 2011 09:04:41 +0200
Hello,
Thanks for the bug report.
Try replacing the file
include/CGAL/internal/Intersections_3/Bbox_3_Line_3_do_intersect.h
by the one attached.
Please tell us if you encounter another issue.
Best regards,
Sebastien.
DimanNe wrote:
http://cgal-discuss.949826.n4.nabble.com/file/n3655807/main.cpp main.cpp
In main.cpp I try to ask is there intersection of
TBBox BBox(0, -4, 0,
300, 4, 300);
and
TLine Line(TPoint(150, -5, 0),
TPoint(150, -5, 1));
as you can see y-coord of Line is lower (= -5) than bottom of BBox (= -4)
but output is
%g++ main.cpp -I/usr/local/include/ -L /usr/local/lib/ -lCGAL
%./a.out
1
v
1
%uname -a
FreeBSD Impedance 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Tue Apr 5 18:35:50
MSD 2011
Void@Impedance:/usr/obj/usr/src/sys/GENERIC
i386
%g++ --version
g++ (GCC) 4.2.2 20070831 prerelease [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PORTNAME= cgal
PORTVERSION= 3.6.1
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/do-intersect-bug-tp3655807p3655807.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
// Copyright (c) 2008 ETH Zurich (Switzerland) // Copyright (c) 2008-2009 INRIA Sophia-Antipolis (France) // All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; version 2.1 of the License. // See the file LICENSE.LGPL distributed with CGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/trunk/Intersections_3/include/CGAL/internal/Intersections_3/Bbox_3_Line_3_do_intersect.h $ // $Id: Bbox_3_Line_3_do_intersect.h 56667 2010-06-09 07:37:13Z sloriot $ // // // Author(s) : Camille Wormser, Jane Tournois, Pierre Alliez, Stephane Tayeb #ifndef CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_LINE_3_DO_INTERSECT_H #define CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_LINE_3_DO_INTERSECT_H #include <CGAL/Line_3.h> #include <CGAL/Bbox_3.h> // inspired from http://cag.csail.mit.edu/~amy/papers/box-jgt.pdf namespace CGAL { namespace internal { template <typename FT> inline bool bbox_line_do_intersect_aux(const FT& px, const FT& py, const FT& pz, const FT& qx, const FT& qy, const FT& qz, const FT& bxmin, const FT& bymin, const FT& bzmin, const FT& bxmax, const FT& bymax, const FT& bzmax) { // ----------------------------------- // treat x coord // ----------------------------------- FT dmin, tmin, tmax; if ( qx >= px ) { tmin = bxmin - px; tmax = bxmax - px; dmin = qx - px; } else { tmin = px - bxmax; tmax = px - bxmin; dmin = px - qx; } //if px is not in the x-slab if ( dmin == FT(0) && (tmin > FT(0) || tmax < FT(0)) ) return false; FT dmax = dmin; // ----------------------------------- // treat y coord // ----------------------------------- FT d_, tmin_, tmax_; if ( qy >= py ) { tmin_ = bymin - py; tmax_ = bymax - py; d_ = qy - py; } else { tmin_ = py - bymax; tmax_ = py - bymin; d_ = py - qy; } //if py is not in the y-slab if ( d_ == FT(0) && (tmin_ > FT(0) || tmax_ < FT(0)) ) return false; if ( (dmin*tmax_) < (d_*tmin) || (dmax*tmin_) > (d_*tmax) ) return false; if( (dmin*tmin_) > (d_*tmin) ) { tmin = tmin_; dmin = d_; } if( (dmax*tmax_) < (d_*tmax) ) { tmax = tmax_; dmax = d_; } // ----------------------------------- // treat z coord // ----------------------------------- if ( qz >= pz ) { tmin_ = bzmin - pz; tmax_ = bzmax - pz; d_ = qz - pz; } else { tmin_ = pz - bzmax; tmax_ = pz - bzmin; d_ = pz - qz; } //if pz is not in the z-slab if ( d_ == FT(0) && (tmin_ > FT(0) || tmax_ < FT(0)) ) return false; return ( (dmin*tmax_) >= (d_*tmin) && (dmax*tmin_) <= (d_*tmax) ); } template <class K> bool do_intersect(const typename K::Line_3& line, const CGAL::Bbox_3& bbox, const K&) { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; const Point_3& point = line.point(); const Vector_3& v = line.to_vector(); return bbox_line_do_intersect_aux( point.x(), point.y(), point.z(), point.x()+v.x(), point.y()+v.y(), point.z()+v.z(), FT(bbox.xmin()), FT(bbox.ymin()), FT(bbox.zmin()), FT(bbox.xmax()), FT(bbox.ymax()), FT(bbox.zmax()) ); } } // namespace internal template <class K> bool do_intersect(const CGAL::Line_3<K>& line, const CGAL::Bbox_3& bbox) { return typename K::Do_intersect_3()(line, bbox); } template <class K> bool do_intersect(const CGAL::Bbox_3& bbox, const CGAL::Line_3<K>& line) { return typename K::Do_intersect_3()(line, bbox); } } //namespace CGAL #endif // CGAL_INTERNAL_INTERSECTIONS_3_BBOX_3_LINE_3_DO_INTERSECT_H
- [cgal-discuss] do_intersect bug, DimanNe, 07/09/2011
- Re: [cgal-discuss] do_intersect bug, Sebastien Loriot (GeometryFactory), 07/12/2011
- [cgal-discuss] Re: do_intersect bug, DimanNe, 07/12/2011
- Re: [cgal-discuss] do_intersect bug, Sebastien Loriot (GeometryFactory), 07/12/2011
Archive powered by MHonArc 2.6.16.