Surface mesh结构学习

CGAL 5.6 - Surface Mesh: User Manual

Surface_mesh 类是半边数据结构的实现,可用来表示多面体表面。它是半边数据结构(Halfedge Data Structures)和三维多面体表面(3D Polyhedral Surface)这两个 CGAL 软件包的替代品。其主要区别在于它是基于索引的,而不是基于指针的。此外,向顶点、半边、边和面添加信息的机制要简单得多,而且是在运行时而不是编译时完成的。

由于数据结构使用整数索引作为顶点、半边、边和面的描述符,因此它的内存占用比基于指针的 64 位版本更少。由于索引是连续的,因此可用作存储属性的向量索引。

当元素被移除时,它们只会被标记为已移除,必须调用垃圾回收函数才能真正移除它们。

Surface_mesh 提供了四个嵌套类,分别代表半边数据结构的基本元素:

Surface_mesh::Vertex_index曲面网格::顶点索引
Surface_mesh::Halfedge_index曲面网格::半边索引
Surface_mesh::Face_index曲面网格::面索引
Surface_mesh::Edge_index曲面网格::边索引

1、新建Surface_mesh结构

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/self_intersections.h>typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh; //mesh结构
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;int main()
{Mesh m;// Add the points as verticesvertex_descriptor u = m.add_vertex(K::Point_3(0, 1, 0));vertex_descriptor v = m.add_vertex(K::Point_3(0, 0, 0));vertex_descriptor w = m.add_vertex(K::Point_3(1, 1, 0));m.add_face(u, v, w);int num = num_faces(m); //结果num = 1return 0;
}

2、自相交判断

在很多算法中,对于输入的Mesh都要求是非自相交的模型。现在来检查以下上述模型是否自相交

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/self_intersections.h>typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh; //mesh结构
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;int main()
{Mesh m;// Add the points as verticesvertex_descriptor u = m.add_vertex(K::Point_3(0, 1, 0));vertex_descriptor v = m.add_vertex(K::Point_3(0, 0, 0));vertex_descriptor w = m.add_vertex(K::Point_3(1, 1, 0));vertex_descriptor x = m.add_vertex(K::Point_3(1, 0, 0));m.add_face(u, v, w);int num = num_faces(m); //结果num = 1face_descriptor f = m.add_face(u, v, x);if (f == Mesh::null_face()){std::cerr << "The face could not be added because of an orientation error." << std::endl;//结果intersect = true; 即当前模型为自相交模型bool intersect = CGAL::Polygon_mesh_processing::does_self_intersect(m);std::cout << "intersect:"<< intersect << std::endl;assert(f != Mesh::null_face());f = m.add_face(u, x, v);num = num_faces(m);//结果intersect = true; 即当前模型为自相交模型intersect = CGAL::Polygon_mesh_processing::does_self_intersect(m);std::cout << "intersect:" << intersect << std::endl;assert(f != Mesh::null_face());}std::cout << num << std::endl;return 0;
}

3、获取Surface_Mesh的所有点  

#include <vector>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;
int main()
{Mesh m;// u            x// +------------+// |            |// |            |// |      f     |// |            |// |            |// +------------+// v            w// Add the points as verticesvertex_descriptor u = m.add_vertex(K::Point_3(0, 1, 0));vertex_descriptor v = m.add_vertex(K::Point_3(0, 0, 0));vertex_descriptor w = m.add_vertex(K::Point_3(1, 0, 0));vertex_descriptor x = m.add_vertex(K::Point_3(1, 1, 0));/* face_descriptor f = */ m.add_face(u, v, w, x);{std::cout << "all vertices " << std::endl;// The vertex iterator type is a nested type of the Vertex_rangeMesh::Vertex_range::iterator  vb, ve;Mesh::Vertex_range r = m.vertices();// The iterators can be accessed through the C++ range APIvb = r.begin();ve = r.end();// or with boost::tie, as the CGAL range derives from std::pairfor (boost::tie(vb, ve) = m.vertices(); vb != ve; ++vb) {std::cout << *vb << std::endl;}// Instead of the classical for loop one can use// the boost macro for a rangefor (vertex_descriptor vd : m.vertices()) {std::cout << vd << std::endl;}}return 0;
}

 

4、获取Surface_Mesh点、边、面的关联点

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>#include <vector>typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;int main()
{Mesh m;// u            x// +------------+// |            |// |            |// |      f     |// |            |// |            |// +------------+// v            w// Add the points as verticesvertex_descriptor u = m.add_vertex(K::Point_3(0, 1, 0));vertex_descriptor v = m.add_vertex(K::Point_3(0, 0, 0));vertex_descriptor w = m.add_vertex(K::Point_3(1, 0, 0));vertex_descriptor x = m.add_vertex(K::Point_3(1, 1, 0));face_descriptor f = m.add_face(u, v, w, x);{std::cout << "vertices around vertex " << v << std::endl;CGAL::Vertex_around_target_circulator<Mesh> vbegin(m.halfedge(v), m), done(vbegin);do {std::cout << *vbegin++ << std::endl;} while (vbegin != done);}{std::cout << "vertices around face " << f << std::endl;CGAL::Vertex_around_face_iterator<Mesh> vbegin, vend;for (boost::tie(vbegin, vend) = vertices_around_face(m.halfedge(f), m);vbegin != vend;++vbegin) {std::cout << *vbegin << std::endl;}}std::cout << "=====" << std::endl;// or the same again, but directly with a range based loopfor (vertex_descriptor vd : vertices_around_face(m.halfedge(f), m)) {std::cout << vd << std::endl;}return 0;
}

【CGAL系列】---了解Surface_Mesh-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/621897.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

(菜鸟自学)搭建虚拟渗透实验室——安装Windows 7 靶机

安装Windows 7 靶机 新建一台虚拟机&#xff0c;并选择Windows 7系统 虚拟机基本配置如下 为虚拟机挂载Windows7的镜像 点击开启虚拟机&#xff0c;将进入安装程序&#xff0c;按如下步骤进行操作&#xff1a; 点击“下一步”》勾选“我接受许可条款”&#xff0c;点击“下…

YOLOv8 Ultralytics:使用Ultralytics框架进行MobileSAM图像分割

YOLOv8 Ultralytics&#xff1a;使用Ultralytics框架进行MobileSAM图像分割 前言相关介绍前提条件实验环境安装环境项目地址LinuxWindows 使用Ultralytics框架进行MobileSAM图像分割参考文献 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更多精彩…

【python】进阶--->MySQL数据库(三)

一、修改列的类型长度及约束 alter table 表名 modify 列名 类型(长度) [约束];修改列名 : alter table 表名 change 旧列名 新列名 类型(长度) [约束];二、数据查询语言 查询表中所有的数据 : select * from 表名; 查询表中部分列数据 : select 列名1, 列名2 from 表名;1. …

进程等待-wait和waitpid

目录 1.为什么要进程等待 2.如何进程等待&#xff1f; 1.wait函数 2.waitpid 1.pid 2.status 3.options/非堵塞轮询 1.为什么要进程等待 1.子进程退出&#xff0c;如果父进程没有退出&#xff0c;那么子进程就会变成僵尸状态。僵尸状态会变得刀枪不入&#xff0c;kiil -…

如何使用vite框架封装一个js库,并发布npm包

目录 前言介绍 一、创建一个vite项目 1、使用创建命令&#xff1a; 2、选择others 3、 模板选择library 4、选择开发语言 ​编辑 二、安装依赖 三、目录介绍 1、vite.config.ts打包文件 2、package.json命令配置文件 三、发布npm 1、注册npm账号 2、设置npm源 3、登…

【模型评估 05】Holdout、交叉检验、自助法

机器学习中&#xff0c;我们通常把样本分为训练集和测试集&#xff0c;训练集用于训练模型&#xff0c;测试集用于评估模型。在样本划分和模型验证的过程中&#xff0c;存在着不同的抽样方法和验证方法。 1. 在模型评估过程中&#xff0c;有哪些主要的验证方法&#xff0c;它们…

Debian(Linux)局域网共享文件-NFS

NFS (Network File system) 是一种客户端-服务器文件系统协议&#xff0c;允许多个系统或用户访问相同的共享文件夹或文件。最新版本是 NFS-V4&#xff0c;共享文件就像存储在本地一样。它提供了中央管理&#xff0c;可以使用防火墙和 Kerberos 身份验证进行保护。 本文将指导…

系列四、Spring Security中的认证 授权(前后端不分离)

一、Spring Security中的认证 & 授权&#xff08;前后端不分离&#xff09; 1.1、MyWebSecurityConfigurerAdapter /*** Author : 一叶浮萍归大海* Date: 2024/1/11 21:50* Description:*/ Configuration public class MyWebSecurityConfigurerAdapter extends WebSecuri…

安卓应用无法拉起部分机型微信支付

错误提示&#xff1a; 2024-01-11 09:01:01.878 11754-11754 MicroMsg.S...ApiImplV10 com.bm.read E register app failed for wechat app signature check failed 2024-01-11 09:01:01.879 11754-11754 MicroMsg.S...ApiImplV10 com.bm.read E s…

建站为什么需要服务器?(Web服务器与计算机对比)

​  在部署网站时&#xff0c;底层基础设施在确保最佳性能、可靠性和可扩展性方面发挥着至关重要的作用。虽然大多数人都熟悉个人计算机 (PC) 作为日常工作和个人任务的设备&#xff0c;但 PC 和 Web 服务器之间存在显著差异。在这篇文章中&#xff0c;我们将讨论这些差异是什…

CentOS:docker容器日志清理

1.先查看磁盘空间 df -h 2.找到容器的containerId-json.log文件,并清理 find /var/lib/docker/containers/ -name *-json.log |xargs du -sh 3、可以根据需求清理对应日志也可以清理数据大的日志 $ cat /dev/null > /var/lib/docker/containers/dbaee0746cc6adad3768b4ef…

java基础知识点系列——数据输入(五)

java基础知识点系列——数据输入&#xff08;五&#xff09; 数据输入概述 Scanner使用步骤 &#xff08;1&#xff09;导包 import java.util.Scanner&#xff08;2&#xff09;创建对象 Scanner sc new Scanner(System.in)&#xff08;3&#xff09;接收数据 int i sc…

MySQL之多表连接查询、AS别名、扩展内容(information_schema的基本应用)

文章目录 前言一、引入多表连接查询二、多表连接查询案例1.准备对应的库表2.案例 三、AS别名用法示例 四、扩展内容1、information_schema的基本应用2、创建视图示例3、information_schema.tables视图的应用3.1、示例 五、show命令总结总结 前言 第三章内容主要描述了mysql使用…

InternLM第4次课笔记

XTuner 大模型单卡低成本微调实战 1 Finetune介绍 2 XTuner介绍 XTuner中微调的技术&#xff1a; 3 8GB显卡玩转LLM 4 动手实战环节 https://github.com/InternLM/tutorial/tree/main/xtuner

YOLOv8 Ultralytics:使用Ultralytics框架进行FastSAM图像分割

YOLOv8 Ultralytics&#xff1a;使用Ultralytics框架进行FastSAM图像分割 前言相关介绍前提条件实验环境安装环境项目地址LinuxWindows 使用Ultralytics框架进行FastSAM图像分割参考文献 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更多精彩内容…

uniCloud 云数据库(1)

目录 1&#xff1a;云数据库入门,基本概念了解 1.1 云数据库是关系型还是Nosql? 1.2 uniCloud 云数据库和关系型数据库的对比 1.3 官方文档传送门 2: 基本操作表 创建 在uniCloud web控制台 进行创建 数据表的3个组成部分 通过传统方式操作数据库 获取集合的引用 集…

企业异地访问办公系统:对比运营商MPLS专线,内网穿透有何优势?

为了实现连锁门店、企业内部各地分支机构ERP、OA、远程监控、自建邮件服务器、智能网络设备等数据传输、互访&#xff0c;使用运营商专线或是采用内网穿透方案&#xff0c;彼此之间究竟有何区别呢&#xff1f; 简单来说&#xff0c;MPLS专线和普通宽带类似是运营商提供的网络租…

ruoyi后台管理系统部署-2-安装mysql

centos7 mysql 安装 1. 手动安装 安装 首先查看系统是否安装了&#xff1a; rpm -qa|grep mariadb rpm -qa | grep mysql systemctl status mysqld find / -name mysql.cnf卸载自带的 mariadb: rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps去官网下载 mysql 安装包&…

【数据结构与算法】之数组系列-20240113

这里写目录标题 一、66. 加一二、121. 买卖股票的最佳时机三、136. 只出现一次的数字四、268. 丢失的数字五、350. 两个数组的交集 II 一、66. 加一 简单 给定一个由 整数 组成的 非空 数组所表示的非负整数&#xff0c;在该数的基础上加一。 最高位数字存放在数组的首位&…