当前位置: 首页 > news >正文

CGAL::2D Arrangements-3

3.Arrangement查询

Arrangement里面最重要的查询操作是point-location,给定一个点,查找到包含这个点的Arrangement。通常情况下,point-location查询得到的结果是Arrangement的一个face,退化情况下会是一个edge,查一个重合的点。

3.1 point-Location查询
3.3 垂直射线扫描

另一个经常用到Arrangement的查找,是垂直射线扫描查找:给定一个查找点,哪些Arrangement单元会跟从这个点发射的垂直射线相交?一般情况下,可能这个射线交到一边edge,也有可能交到一个vertex,或者这个Arrangement单元不跟这个射线相交。

在前面章节讲到的point-location类,也是一个ArrangementVerticalRayShoot_2概念(concept)的一个model,所以他们全都有成员方法ray_shoot_up(q)和 ray_shoot_down(q),这其中的Q是一个用来查询的point。

在头文件point_location_utils.h中有下面的辅助方法:

template <typename VerticalRayShooting>
void shoot_vertical_ray(const RayShoot& vrs,const typenameVerticalRayShooting::Arrangement_2::Point_2& q)
{typedef VerticalRayShooting                           Vertical_ray_shooting;// Perform the point-location query.typename Vertical_ray_shooting::result_type obj = vrs.ray_shoot_up(q);// Print the result.typedef typename Vertical_ray_shooting::Arrangement_2 Arrangement_2;typedef typename Arrangement_2::Vertex_const_handle   Vertex_const_handle;typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;typedef typename Arrangement_2::Face_const_handle     Face_const_handle;const Vertex_const_handle* v;const Halfedge_const_handle* e;const Face_const_handle* f;std::cout << "Shooting up from (" << q << ") : ";if (v = boost::get<Vertex_const_handle>(&obj))         // we hit a vertexstd::cout << "hit " << (((*v)->is_isolated()) ? "an isolated" : "a")<< " vertex: " << (*v)->point() << std::endl;else if (e = boost::get<Halfedge_const_handle>(&obj))  // we hit an edgestd::cout << "hit an edge: " << (*e)->curve() << std::endl;else if (f = boost::get<Face_const_handle>(&obj)) {    // we hit nothingCGAL_assertion((*f)->is_unbounded());std::cout << "hit nothing.\n";}else CGAL_error();
}

下面的程序段,使用了上面的函数模式,在一个Arrangement上执行垂直射线扫描查询:

// Answering vertical ray-shooting queries.
#include <CGAL/basic.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arr_trapezoid_ric_point_location.h>
#include "arr_inexact_construction_segments.h"
#include "point_location_utils.h"
typedef CGAL::Arr_walk_along_line_point_location<Arrangement> Walk_pl;
typedef CGAL::Arr_trapezoid_ric_point_location<Arrangement>   Trap_pl;
int main() {// Construct the arrangement.Arrangement arr;construct_segments_arr(arr);// Perform some vertical ray-shooting queries using the walk strategy.Walk_pl walk_pl(arr);shoot_vertical_ray(walk_pl, Point(1, 4));shoot_vertical_ray(walk_pl, Point(4, 3));shoot_vertical_ray(walk_pl, Point(6, 3));// Attach the trapezoid-RIC object to the arrangement and perform queries.Trap_pl trap_pl(arr);shoot_vertical_ray(trap_pl, Point(3, 2));shoot_vertical_ray(trap_pl, Point(5, 2));shoot_vertical_ray(trap_pl, Point(1, 0));return 0;
}

http://www.lryc.cn/news/297381.html

相关文章:

  • 机器学习--K近邻算法,以及python中通过Scikit-learn库实现K近邻算法API使用技巧
  • Redis 使用 RDB 持久化方式的过程
  • 仰暮计划|“我非常感谢党的领导,作为一名普通百姓,我也愿意为国家的发展继续贡献微薄的力量”
  • 【思科ssh】思科模拟器配置ssh登录
  • python创建pdf文件
  • ubuntu开机报错/dev/nume0n1p2:clean
  • openstack(T版)公有云--Dashboard服务
  • Vue ElementUI中el-table表格嵌套样式问题
  • ssm+vue的校园一卡通密钥管理系统(有报告)。Javaee项目,ssm vue前后端分离项目。
  • docker进阶 问题1
  • 【OpenVINO™】在 MacOS 上使用 OpenVINO™ C# API 部署 Yolov5 (下篇)
  • 使用CHATGPT进行论文写作的缺点和风险
  • 【Android-Gradle】多模块开发中,定义额外属性(全局变量),穿梭在不同的Gradle文件中(kotlin脚本版)
  • React18原理: Fiber架构下的单线程CPU调度策略
  • 个人搜集的gstreamer学习链接
  • Blazor Wasm Gitee 码云登录
  • Android 自定义BaseActivity
  • 基于鲲鹏服务器的LNMP配置
  • MIT-Missing Semester_Topic 6:Version Control (Git) 练习题
  • OpenHarmony轻量级内核-LiteOS-M
  • TCP 传输控制协议——详细
  • ArcGIS学习(六)地理数据库
  • 保研机试算法训练个人记录笔记(四)——哈希算法
  • ChatGPT实战100例 - (14) 打造AI编程助手 Code Copilot
  • 表单标记(html)
  • Linux文件和目录管理
  • 【go】gorm\xorm\ent事务处理
  • 【数据分享】1929-2023年全球站点的逐月平均风速(Shp\Excel\免费获取)
  • IP地址详解
  • Python爬虫http基本原理#2