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

使用boost::geometry::union_ 合并边界(内、外):方案二

使用boost::geometry::union_ 合并边界(内、外):方案二


typedef boost::geometry::model::d2::point_xy<double> boost_point;
typedef boost::geometry::model::polygon<boost_point> boost_Polygon;struct Point
{float x;float y;Point(float _x,float _y){x = _x;y = _y;}Point(const boost_point & pt){x = pt.x();y = pt.y();}operator boost_point(){return boost_point(x, y);}
};bool TestClientTrafficEvent::TestBorderCombine()
{//str_points_of_cur_frame_data = "POLYGON((1.500000 1.500000,1.500000 2.500000,2.500000 2.500000,2.500000 1.500000,1.500000 1.500000))".std::vector<Point> lhs;{Point lhs_p1(1.5, 1.5); Point lhs_p2(1.5,2.5); //remainPoint lhs_p3(2.5, 2.5); //remainPoint lhs_p4(2.5, 1.5);Point lhs_p5(1.5, 1.5);lhs.push_back(lhs_p1);lhs.push_back(lhs_p2);lhs.push_back(lhs_p3);lhs.push_back(lhs_p4);lhs.push_back(lhs_p5);}//str_points_of_compared_frame_data = "POLYGON((1.000000 1.000000,1.000000 2.000000,2.000000 2.000000,2.000000 1.000000,1.000000 1.000000))";std::vector<Point> rhs;{Point rhs_p1(1.0, 1.0); Point rhs_p2(1.0, 2.0);Point rhs_p3(2.0, 2.0);Point rhs_p4(2.0, 1.0);Point rhs_p5(1.0, 1.0);    }boost_Polygon lhs_lt, rhs_lt;for (auto & pt : lhs){boost::geometry::append(lhs_lt, (boost_point)pt);}for (auto & pt : rhs){boost::geometry::append(rhs_lt, (boost_point)pt);}//进行并集计算std::vector<boost_Polygon> r;boost::geometry::union_(lhs_lt, rhs_lt, r);//通过验证:与传入的顺序无关,均返回相同的结果。std::vector<Point> vctr_combined ;if (!r.empty())//有结果返回{for (auto & pt : r[0].outer()){vctr_combined.push_back(pt);}}    std::cout << "vctr_combined.size()  = " << vctr_combined.size() << std::endl;for(auto iter : vctr_combined){std::cout << "iter.x  = " << iter.x << ", iter.y  = " << iter.y << std::endl;}return true;}
  • P1、P5 为新增自动生成的交叉点

  • P1为首位重合点

  • P1 ~ P8 ~ P8 为顺时针顺序

在这里插入图片描述

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

相关文章:

  • ICCV 2023 | 小鹏汽车纽约石溪:局部上下文感知主动域自适应LADA
  • stable diffusion实践操作-黑白稿线稿上色
  • Python学习教程:集合操作的详细教程
  • 球球的排列
  • 1783_CMD启动MATLAB同时执行一个脚本
  • C语言中内存分配的几种方式
  • 组相联cache如何快速实现cache line eviction并使用PMU events验证
  • 【Stable Diffusion安装】支持python3.11 window版
  • Anycloud37D平台移植wirelesstools
  • 海康机器人工业相机 Win10+Qt+Cmake 开发环境搭建
  • 使用MDK5的一些偏僻使用方法和谋个功能的作用
  • 【实战】十一、看板页面及任务组页面开发(六) —— React17+React Hook+TS4 最佳实践,仿 Jira 企业级项目(二十八)
  • 在 Amazon 搭建无代码可视化的数据分析和建模平台
  • Pinely Round 2 (Div. 1 + Div. 2) G. Swaps(组合计数)
  • elasticSearch+kibana+logstash+filebeat集群改成https认证
  • GPT带我学-设计模式-迭代器模式
  • 数学建模--层次分析法(AHP)的Python实现
  • 机器学习笔记之最优化理论与方法(三)凸集的简单认识(下)
  • Apipost:API文档、调试、Mock与测试的一体化协作平台
  • Homebrew下载安装及使用教程
  • 【Codeforces】CF193D Two Segments
  • 内存管理概述
  • Spring的重试机制-SpringRetry
  • 水稻叶病害数据集(目标检测,yolo使用)
  • 鸿蒙系列-如何使用好 ArkUI 的 @Reusable?
  • 展锐平台音频框架
  • webpack loader和plugins的区别
  • 适配器模式:接口的平滑过渡
  • vscode搭建springboot开发环境
  • SpringMVC-学习笔记