当前位置:网站首页>如何用OpenMesh创建一个四棱锥
如何用OpenMesh创建一个四棱锥
2022-07-01 19:03:00 【CSU迦叶】

自己凭空构造一个如图所示的四棱锥,基本信息是[V, E, F] = [5, 9, 6]
各个点的坐标是A(0,0,1) B(-1,1,0) C(1,1,0) D(1,-1,0) E(-1,-1,0)
确定面片添加顺序是AED->ACB->ADC->ABE->BDE->DBC
注意:每个面的点加入的顺序应为相对于该面片朝外的法向量是逆时针分布
// IoTestPro.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArraykernelT.hh>
#include <OpenMesh/Core/Mesh/PolyConnectivity.hh>
typedef OpenMesh::TriMesh_ArrayKernelT<> TriMesh;
int main()
{
TriMesh mesh;//预计是一个四棱锥
TriMesh::VertexHandle vhandle[5];//点的句柄数组
std::vector<TriMesh::VertexHandle> face_vhandles;//一个面中含有多个点
vhandle[0] = mesh.add_vertex(TriMesh::Point(0, 0, 2));//点A
vhandle[1] = mesh.add_vertex(TriMesh::Point(-1, 1, 0));//点B
vhandle[2] = mesh.add_vertex(TriMesh::Point(1, 1, 0));//点C
vhandle[3] = mesh.add_vertex(TriMesh::Point(1, -1, 0));//点D
vhandle[4] = mesh.add_vertex(TriMesh::Point(-1, -1, 0));//点E
//构造面AED并加入mesh
face_vhandles.push_back(vhandle['A' - 65]);
face_vhandles.push_back(vhandle['E' - 65]);
face_vhandles.push_back(vhandle['D' - 65]);
mesh.add_face(face_vhandles);
//构造面ACB并加入mesh
face_vhandles.clear();
face_vhandles.push_back(vhandle['A' - 65]);
face_vhandles.push_back(vhandle['C' - 65]);
face_vhandles.push_back(vhandle['B' - 65]);
mesh.add_face(face_vhandles);
//构造面ADC并加入mesh
face_vhandles.clear();
face_vhandles.push_back(vhandle['A' - 65]);
face_vhandles.push_back(vhandle['D' - 65]);
face_vhandles.push_back(vhandle['C' - 65]);
mesh.add_face(face_vhandles);
//构造面ABE并加入mesh
face_vhandles.clear();
face_vhandles.push_back(vhandle['A' - 65]);
face_vhandles.push_back(vhandle['B' - 65]);
face_vhandles.push_back(vhandle['E' - 65]);
mesh.add_face(face_vhandles);
//构造面BDE并加入mesh
face_vhandles.clear();
face_vhandles.push_back(vhandle['B' - 65]);
face_vhandles.push_back(vhandle['D' - 65]);
face_vhandles.push_back(vhandle['E' - 65]);
mesh.add_face(face_vhandles);
//构造面DBC并加入mesh
face_vhandles.clear();
face_vhandles.push_back(vhandle['D' - 65]);
face_vhandles.push_back(vhandle['B' - 65]);
face_vhandles.push_back(vhandle['C' - 65]);
mesh.add_face(face_vhandles);
return 0;
}
边栏推荐
猜你喜欢

RichView TRVDocParameters 页面参数设置

Redis installation and startup in Windows environment (background startup)

基于图的 Affinity Propagation 聚类计算公式详解和代码示例

Arduino Stepper库驱动28BYJ-48步进电机测试程序

Easycvr accesses the equipment through the national standard gb28181 protocol. What is the reason for the automatic streaming of the equipment?

EURA欧瑞E1000系列变频器使用PID实现恒压供水功能的相关参数设置及接线
![[Mysql]安装Mysql5.7](/img/c4/d7fb5ddf8e7be31f7a9ad68409e584.png)
[Mysql]安装Mysql5.7

牛客编程题--必刷101之字符串(高效刷题,举一反三)

uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理

独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作
随机推荐
8K HDR!|为 Chromium 实现 HEVC 硬解 - 原理/实测指南
Set object value changes null value object
Process steps of vibrating wire acquisition module for measuring vibrating wire sensor
On the next generation entrance of the metauniverse -- the implementation of brain computer interface
list大集合等比分割成多个小list集合
math_ Use differentiation to calculate approximate value
Simple but modern server dashboard dashdot
What if win11 can't pause the update? Win11 pause update is gray. How to solve it?
Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
STC 32位8051单片机开发实例教程 二 I/O工作模式及其配置
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
300题线性代数 第四讲 线性方程组
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
Win11怎么关闭开机自启动软件
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
EasyCVR集群视频广场页面切换时,请求流未能终止的问题优化
Wechat applet realizes keyword highlighting
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
switch 有四样写法你知道么
Bind this of the current scope for callback functions in other cases such as timers and delayers