CGAL 2维布尔运算

研究了几天nef_2,终于明白了一点,写下来记录一下

本文主要讨论nef布尔运算后Explorer的情况

#include <CGAL/Gmpq.h>
#include <CGAL/Lazy_exact_nt.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Bounded_kernel.h>
#include <CGAL/Nef_polyhedron_2.h>

typedef CGAL::Lazy_exact_nt<CGAL::Gmpq> FT;
typedef CGAL::Simple_cartesian<FT> Kernel;
typedef CGAL::Bounded_kernel<Kernel> Extended_kernel;
typedef CGAL::Nef_polyhedron_2<Extended_kernel> Nef_polyhedron;
typedef Nef_polyhedron::Point Point;

typedef Nef_polyhedron::Explorer Explorer;
typedef Explorer::Face_const_iterator Face_const_iterator;
typedef Explorer::Hole_const_iterator Hole_const_iterator;
typedef Explorer::Halfedge_around_face_const_circulator Halfedge_around_face_const_circulator;
typedef Explorer::Vertex_const_handle Vertex_const_handle;
typedef Explorer::Point_const_iterator Point_const_iterator;
typedef Explorer::Isolated_vertex_const_iterator Isolated_vertex_const_iterator;

头文件和预定义,没什么好说的,下面开始三角形和线段的定义

Point r1[3] = { Point(20, 15), Point(25, 5), Point(30, 15) };
  Point s0[2] = { Point(20, 10), Point(25, 16) };

std::list<std::pair<Point*, Point*> > polylines, polylines1;
    polylines.push_back(std::make_pair(r1 + 0, r1 + 3));
    polylines1.push_back(std::make_pair(s0 + 0, s0 + 2));

  Nef_polyhedron RST0(polylines.begin(), polylines.end(), Nef_polyhedron::POLYGONS);//定义多边形
    Nef_polyhedron RST1(polylines1.begin(), polylines1.end(), Nef_polyhedron::POLYLINES);//多段线

//相交运算

Nef_polyhedron RST = RST1.intersection(RST0);

//使用探测器

Explorer explorer = RST.explorer();

//遍历点

std::cout << "Point" << std::endl;
    for (Point_const_iterator pntPos = explorer.points_begin(); pntPos != explorer.points_end(); ++pntPos)
    {
        std::cout << pntPos->x() << "," << pntPos->y() << std::endl;
    }

//半边

std::cout << "halfedges" << std::endl;
    for (Explorer::Halfedge_const_iterator posEdge = explorer.halfedges_begin(); posEdge != explorer.halfedges_end(); ++posEdge)
    {
        Vertex_const_handle vh = explorer.target(posEdge);
        std::cout << explorer.point(vh) << " [" << explorer.point(vh).x() << " | " << explorer.point(vh).y() << "],  ";
    }

//开始面的遍历

//第一个面是无限大的面,没有外轮廓,只包含洞

Face_const_iterator posFace = explorer.faces_begin();
    for (Hole_const_iterator hit = explorer.holes_begin(posFace); hit != explorer.holes_end(posFace); hit++)
    {
        std::cout << " A hole" << std::endl;

//半边循环
        Halfedge_around_face_const_circulator hafc(hit), done(hafc);
        do
        {
            Vertex_const_handle vh = explorer.target(hafc);
            std::cout << explorer.point(vh) << " [" << explorer.point(vh).x() << " | " << explorer.point(vh).y() << "],  ";
            hafc++;
        } while (hafc != done);
    }

//其他面,有外轮廓,包含洞

for (++posFace; posFace != explorer.faces_end(); ++posFace)
    {
        
        Halfedge_around_face_const_circulator hafc = explorer.face_cycle(posFace), done(hafc);
        do
        {
            Vertex_const_handle vh = explorer.target(hafc);
            std::cout << explorer.point(vh) << " [" << explorer.point(vh).x()<< " | " << explorer.point(vh).y() << "],  ";
            hafc++;
        } while (hafc != done);
    }

时间: 2024-08-03 18:17:31

CGAL 2维布尔运算的相关文章

二维码扫码积分系统定制开发

微信积分系统 二维码扫码积分系统定制开发找丽姐[158.1816.6626/电微]二维码营销模式系统定制开发 微信扫二维码营销系统开发 扫码领积分系统开发 一.如何实现扫二维码领红包功能? 1.使用扫描二维码领取红包对活动进行设置,包括红包数量.红包金额.促销地区.中奖概率等. 2.将生成的二维码赋到商品上面并赋涂层,一方面可以起到保证二维码的一次性,另一方面也可以引起消费者的好奇心. 3.通过手机微信打开扫一扫,扫码商品二维码关注公众号并领取红包,如果参与分享还可以获得抽奖的机会. 二.微信扫

微信生成二维码 只需一个网址即刻 还有jquery生成二维码

<div class="orderDetails-info"> <img src="http://qr.topscan.com/api.php?text=http://123.net/index.php?s=/Home/Index/yanzheng/mai/{$dange.id}" style="width: 5rem; margin-bottom: 1rem;" > </div> http://qr.tops

家电二维码售后服务平台系统开发

家电二维码售后服务平台系统开发,家电二维码售后系统开发,小吴183.2071.6434微电,家电二维码售后软件开发,家电二维码售后平台开发. 互联网平台的节点有两大类型:第一基数节点,也就是弱连接的节点,其规模要大,越大越好,互联网的价值与节点数的平比成正比.第二活跃节点,也就是强连接的节点,其能量要强,越强越好,互联网的价值与其强度成正比. 一.家电维修行业"维修黑幕"层出不穷 记者从一位从事家电维修人士那里了解到,目前行业公认当前家电维修行业有陷阱,"维修黑幕"

51CTO持续更新《通哥的运维笔记》

<通哥的运维笔记>将持续在51CTO网站更新,希望大家多多关注.互相学习,后期,我将会退出<通哥的运维笔记>系列视频教程,希望带给大家最大的收获,帮助大家更好的学习.进步.<通哥的运维笔记>主要从linux系统管理.虚拟化.cloudstack云平台以及网络管理之CCNA.CCNP.CCIE,等等方面深入讲解.

linux运维升级路线

运维工程师是从一个呆逼进化为苦逼再成长为牛逼的过程,前提在于你要能忍能干能拼,还要具有敏锐的嗅觉感知前方潮流变化.如:今年大数据,人工智能比较火--(相对表示就是 Python 比较火) 之前写过运维基础篇,发现对很多人收益挺大,接下来也写下关于这4年多的运维实践经验,从事了2年多游戏运维,1年多安全运维,1年大数据运维,相关行业信息不能算非常精通,但是熟悉和熟练还是相对可以的. 初级篇 linux运维人员常用工具拓扑详见: 1.rsync工具 很多地方经常会用到rsync工具,实施几台服务器的

微信小程序(4)--二维码窗口

微信小程序二维码窗口: <view class="btn" bindtap="powerDrawer" data-statu="open">button</view> <!--mask--> <view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if=&qu

微信服务器与项目服务器的交互(关注功能、微信扫描带参数二维码)

<?php /** * wechat php test */ //define your token define("TOKEN", "txtj"); $wechatObj = new wechatCallbackapiTest(); if (isset($_GET['echostr'])) { $wechatObj->valid(); }else{ $wechatObj->responseMsg(); } class wechatCallback

网络运维调查

我想在北京就业 通过百度我知道工作职位仅在北京地区网络运维的职位有2668个,朝阳区276个,东城33个,海淀258个,石景山15个,延庆2个,西城48个,昌平67个,丰台74个,怀柔4个,通州28个,密云3个,大兴57个,房山5个,门头沟3个,顺义18个.薪资方面,4001~6000元每个月的有793个,6001~8000元每个月的有1059个,8001~10000元每个月的有709个,10001~15000元每个月的有509个,15001~20000元每个月的有301个,20001~3000

14-高效求最长公共子序列(二维数组存不下)

/*                                   See LCS again时间限制:1000 ms  |  内存限制:65535 KB难度:3 描述 There are A, B two sequences, the number of elements in the sequence is n.m; Each element in the sequence are different and less than 100000. Calculate the length