当前位置:网站首页>如何用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;
}
边栏推荐
- 独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作
- 今日群里分享的面试题
- 使用Zadig从0到1搭建持续交付平台
- PowerDesigner design name and comment replacement
- Optimization of the problem that the request flow fails to terminate during page switching of easycvr cluster video Plaza
- Items in richview documents
- 优质笔记软件综合评测和详细盘点(一) Notion、Obsidian、RemNote、FlowUs
- C#联合halcon应用——大华相机采集类
- Solve the problem of slow or failed vscode download
- Win11 how to hide the taskbar? Win11 method to hide the taskbar
猜你喜欢

STC 32-bit 8051 single chip microcomputer development example tutorial II i/o working mode and its configuration

What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond

Win11暂停更新点不了怎么办?Win11暂停更新是灰色的如何解决?

Win11怎么关闭开机自启动软件

Simple but modern server dashboard dashdot

Hls4ml entry method

渗透工具-TrustedSec 公司的渗透测试框架 (PTF)

Items in richview documents

Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road

fastDFS入门
随机推荐
【let var const】
[exercise] HashSet
Difference between redo and undo
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
PowerDesigner设计Name和Comment 替换
[research materials] national second-hand housing market monthly report January 2022 - Download attached
STC 32位8051单片机开发实例教程 二 I/O工作模式及其配置
Develop those things: easycvr cluster device management page function display optimization
Use of common built-in classes of JS
Wechat applet realizes keyword highlighting
fastDFS入门
Items in richview documents
Error in installing sharp
uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理
Arduino stepper library drive 28byj-48 stepper motor test program
Win11快捷键切换输入法无反应怎么办?快捷键切换输入法没有反应
C # joint Halcon application - Dahua camera acquisition class
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
上大学后明白了哪些坑人的事?
Flask 常用组件