不精确的直线骨架与CGAL
imprecise straight skeleton with CGAL
当我试图用CGAL绘制直线骨架时,我得到了奇怪的结果(对称多边形上的非对称骨架)。
结果与内核:
- Exact_predicates_inexact_constructions_kernel
- Exact_predicates_exact_constructions_kernel
。
使用内核- 笛卡尔
在这里(这更好,但当我循环地移动多边形定义中的点时,它会断开)。
我正在使用这个代码:
#include <vector>
#include <boost/shared_ptr.hpp>
// #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
// typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
// #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
// typedef CGAL::Exact_predicates_exact_constructions_kernel K ;
#include <CGAL/Cartesian.h>
typedef CGAL::Cartesian<float> K;
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
typedef K::Point_2 Point_2;
typedef CGAL::Straight_skeleton_2<K> Ss;
typedef boost::shared_ptr<Ss> SsPtr;
int main() {
Point_2 pts[] = {
Point_2(0, -1385),//top
Point_2(500, 0),//right half:
Point_2(300, 0),
Point_2(400, 173),
Point_2(200, 173),
Point_2(100, 0),
Point_2(-100, 0),//left half:
Point_2(-200, 173),
Point_2(-400, 173),
Point_2(-300, 0),
Point_2(-500, 0),
} ;
std::vector<Point_2> poly(pts,pts+11);
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.begin(), poly.end(), K());
//printing for debugging
for ( Ss::Halfedge_const_iterator i = (*iss).halfedges_begin(); i != (*iss).halfedges_end(); ++i ) {
if ( i->is_bisector()){
std::cout<<"i ";
}
else {
std::cout<<"c ";
}
CGAL::Point_2<K> pa= i->opposite()->vertex()->point();
CGAL::Point_2<K> pb= i->vertex()->point();
std::cout << pa.x() << " " << pa.y() << " " << pb.x() << " " << pb.y() << std::endl;
}
return 0;
}
问题似乎是简并性(4行相交于一点)没有被精确计算。
我使用内核不恰当吗?我应该如何使用它来得到这个结果:https://i.stack.imgur.com/ESk9U.png
作为解决方法,我将多边形高档100,然后调用CGAL,然后再次降低结果。
指出:
显示结果的脚本(用于调试):https://gist.github.com/anonymous/5497523
有道理。答案是您正确地使用了内核。这不是你的代码的问题,这是一个bug在CGAL,我需要修复。Jiri (OP),请私下联系我(fernando。cacciola在gmail),以便你可以跟进这件事。
相关文章:
- 给出不精确答案的递归Karatsuba算法
- 在 c++ 中逐个字符从字符串传递到 int 时不精确
- OpenCV不失真点没有给出失真模型的精确逆
- 为什么``精确的预选赛''不生效
- CGAL - 不能使用import_from_polyhedron_3
- 不能在Cygwin中进行CGAL例子
- C#/.NET定时器和Win32睡眠函数都是不精确的
- 浮点常量不精确的警告
- 如何不指定函数参数的精确求值顺序有助于C&C++编译器生成优化的代码?
- CGAL交点圆和垂直线(不是线段)
- 如何解析 /usr/lib64/libstdc++.so.6:在我的 CGAL cmake 项目中找不到版本 'GLIBCXX_3.4.15'?
- CGAL Precondition_exception具有多边形交叉点和不精确构造内核
- C++指数分布模板类生成不精确的随机数
- Macports cgal不工作!我该如何修复它
- 不精确的直线骨架与CGAL
- 在Qt中,Float的加法不能给出精确的结果
- Opencv waitkey,不精确,不工作
- 基于btIDebugDraw的CGAL渲染器(不带QT)
- 长睡眠(在C++中)比短睡眠更不精确吗
- 如何用CGAL和CORE精确计算sin(2*m*Pi/n)