C++ CGAL 4.4排列插入(arr,曲线)与一些曲线碰撞
我试图使用CGAL的安排,但由于不清楚的原因,CGAL 4.4中的一些曲线程序崩溃(在以前的版本4.3中不是这样的问题)。看问题的简单概述,曲线是字母D的轮廓,转换成线段:C++ CGAL 4.4排列插入(arr,曲线)与一些曲线碰撞,c++,insert,cgal,C++,Insert,Cgal,我试图使用CGAL的安排,但由于不清楚的原因,CGAL 4.4中的一些曲线程序崩溃(在以前的版本4.3中不是这样的问题)。看问题的简单概述,曲线是字母D的轮廓,转换成线段: dDouble dpts { 16.261, 95.267, ... 95.267, 16.261, 95.267}; dPoint pts = ... // converting to exact points with 3 decimal places Curve_2 cu = Curve_2(pts.b
dDouble dpts { 16.261, 95.267, ... 95.267, 16.261, 95.267};
dPoint pts = ... // converting to exact points with 3 decimal places
Curve_2 cu = Curve_2(pts.begin(), pts.end());
insert(arr, cu); // <---- here crash, supposed bug in CGAL 4.4 ------
输出:cmake
程序输出
确实是4.4中的一个bug 下面的补丁应该可以修复它 它将在下一次正式修订中确定
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
index 1a04d7d..aa48ded 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
@@ -2742,8 +2742,7 @@ namespace CGAL {
* If q is not in the x-range of cv, returns INVALID_INDEX.
*/
template <typename Compare>
- std::size_t locate_gen(const X_monotone_curve_2& cv,
- Compare compare) const
+ std::size_t locate_gen(const X_monotone_curve_2& cv, Compare compare) const
{
// The direction of cv. SMALLER means left-to-right and
// otherwise right-to-left
@@ -2766,7 +2765,14 @@ namespace CGAL {
Comparison_result res_to = compare(cv[to], ARR_MAX_END);
if (res_to == EQUAL) return to;
- if (res_to == res_from) return INVALID_INDEX;
+ // Check whether the point is either lexicographically to the left of
+ // the curve or lexicographically to the right of the curve.
+ if (res_to == res_from)
+ // If the x-monotone polyline is vertical, return the index of the
+ // segment that is closest to the point. Otherwise, the point is not
+ // in the x-range of the polyline.
+ return (is_vertical_2_object()(cv)) ?
+ ((res_to == SMALLER) ? from : to) : INVALID_INDEX;
// Perform a binary search to locate the segment that contains q in its
// range:
diff--git a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.hb/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
索引1a04d7d..AA48D 100644
---a/排列在曲面上\u 2/包含/CGAL/Arr\u多段线\u 2.h
+++b/排列在曲面上\u 2/包含/CGAL/Arr\u多段线\u 2.h
@@-2742,8+2742,7@@命名空间CGAL{
*如果q不在cv的x范围内,则返回无效的_索引。
*/
模板
-标准::尺寸、位置、根(常数X单调曲线),
-比较(比较)常数
+标准::大小\u t位置\u根(常数X单调曲线\u 2和cv,比较)常数
{
//cv.较小的方向表示从左到右和
//否则从右向左
@@-2766,7+2765,14@@命名空间CGAL{
比较结果res\u to=比较(cv[to],ARR\u MAX\u END);
如果(res_to==相等)返回到;
-if(res_to==res_from)返回无效的_索引;
+//检查该点是否按字典顺序位于
+//曲线或按字典顺序位于曲线右侧。
+if(res_to==res_from)
+//如果x单调多段线是垂直的,则返回
+//最接近该点的段。否则,该点不是
+//在多段线的x范围内。
+返回(是垂直的2对象()(cv))?
+((res_to==更小)?from:to):无效的_索引;
//执行二进制搜索以查找其内部包含q的段
//范围:
感谢您的错误报告。我将您的帖子转发到CGAL开发者邮件列表,Efi修复了该错误。该错误将在下一版本中发布。如果您可以测试该修补程序,并发现它确实解决了您的问题,请“接受”Efi的答案,以“关闭”该问题。
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_VERBOSE_MAKEFILE ON)
set(XXX main)
project(XXX)
SET(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "-std=c++0x -frounding-math")
find_package(CGAL QUIET COMPONENTS Core )
include( ${CGAL_USE_FILE} )
add_executable(${XXX} ${XXX}.cpp)
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
...
-- Using /usr/bin/c++ compiler.
-- Requested component: Core
-- Requested component: MPFR
-- Requested component: GMP
..
16.261 95.267 | 16.261 48.027 | 153.477 48.027 | 164.912 49.104 | 186.691 51.458 | 201.573 54.251 | 211.367 56.921 | 225.415 61.957 |
238.134 68.049 | 249.204 74.952 | 258.604 82.468 | 266.944 91.033 | 272.727 98.754 | 277.419 107.216 | 280.673 116.053 | 282.289 124.687 |
282.364 132.995 | 281.97 136.238 | 279.901 144.167 | 276.218 152.181 | 270.568 160.737 | 262.216 170.448 | 257.505 174.921 | 248.805 181.405 |
237.688 187.749 | 221.082 195.281 | 218.006 196.525 | 204.35 201.024 | 187.094 204.993 | 183.018 205.735 | 165.239 208.084 | 147.989 208.866 |
16.261 208.866 | 16.261 168.055 | 38.329 167.772 | 38.153 95.267 | 16.261 95.267 |
terminate called after throwing an instance of 'CGAL::Precondition_exception'
what(): CGAL ERROR: precondition violation!
Expr: i != INVALID_INDEX
File: /usr/local/include/CGAL/Arr_polyline_traits_2.h
Line: 619
Aborted
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
index 1a04d7d..aa48ded 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_polyline_traits_2.h
@@ -2742,8 +2742,7 @@ namespace CGAL {
* If q is not in the x-range of cv, returns INVALID_INDEX.
*/
template <typename Compare>
- std::size_t locate_gen(const X_monotone_curve_2& cv,
- Compare compare) const
+ std::size_t locate_gen(const X_monotone_curve_2& cv, Compare compare) const
{
// The direction of cv. SMALLER means left-to-right and
// otherwise right-to-left
@@ -2766,7 +2765,14 @@ namespace CGAL {
Comparison_result res_to = compare(cv[to], ARR_MAX_END);
if (res_to == EQUAL) return to;
- if (res_to == res_from) return INVALID_INDEX;
+ // Check whether the point is either lexicographically to the left of
+ // the curve or lexicographically to the right of the curve.
+ if (res_to == res_from)
+ // If the x-monotone polyline is vertical, return the index of the
+ // segment that is closest to the point. Otherwise, the point is not
+ // in the x-range of the polyline.
+ return (is_vertical_2_object()(cv)) ?
+ ((res_to == SMALLER) ? from : to) : INVALID_INDEX;
// Perform a binary search to locate the segment that contains q in its
// range: