VS2010下配置OpenMesh
从www.openmesh.org下载最新版的安装包或者源代码,注意下载与自己系统匹配的版本,我下的是VS2010预编译版的,下载源码自己编译是一样的。安装好Visual Studio。
安装OpenMesh,预编译版的是一个安装包,直接打开下一步安装就行。
配置VS,以VS2010为例,打开 项目 —> 项目属性 —> 配置属性 —> VC++目录,在包含目录和库目录中依次添加 C:\Program Files (x86)\OpenMesh 3.2\include 和 C:\Program Files (x86)\OpenMesh 3.2\lib 目录,具体由自己的OpenMesh安装目录决定。
在 配置属性下,打开 C/C++ —> 预处理器定义,添加_USE_MATH_DEFINES,再打开链接器 —> 输入, 在附加依赖项中输入OpenMeshCored.lib 和 OpenMeshToolsd.lib。
从OpenMesh官网提供的code examples (First Steps-Building a cube) 中拷贝cube的测试代码,如下,放到工程中编译执行即可。
运行后会在当前目录下生成一个 output.off 文件。说明执行成功,用OpenMesh目录下自带的 QTviewer 可以打开生成的off文件。
//=============================================================================
//
// OpenMesh
// Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen
// www.openmesh.org
//
//-----------------------------------------------------------------------------
//
// License
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Library General Public License as published
// by the Free Software Foundation, version 2.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//-----------------------------------------------------------------------------
//
// $Revision: 83 $
// $Date: 2009-02-27 17:31:45 +0100 (Fri, 27 Feb 2009) $
//
//=============================================================================
#include <iostream>
// -------------------- OpenMesh
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
// ----------------------------------------------------------------------------
typedef OpenMesh::PolyMesh_ArrayKernelT<> MyMesh;
// ----------------------------------------------------------------------------
// Build a simple cube and write it to std::cout
int main()
{
MyMesh mesh;
// generate vertices
MyMesh::VertexHandle vhandle[8];
vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, -1, 1));
vhandle[1] = mesh.add_vertex(MyMesh::Point( 1, -1, 1));
vhandle[2] = mesh.add_vertex(MyMesh::Point( 1, 1, 1));
vhandle[3] = mesh.add_vertex(MyMesh::Point(-1, 1, 1));
vhandle[4] = mesh.add_vertex(MyMesh::Point(-1, -1, -1));
vhandle[5] = mesh.add_vertex(MyMesh::Point( 1, -1, -1));
vhandle[6] = mesh.add_vertex(MyMesh::Point( 1, 1, -1));
vhandle[7] = mesh.add_vertex(MyMesh::Point(-1, 1, -1));
// generate (quadrilateral) faces
std::vector<MyMesh::VertexHandle> face_vhandles;
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[3]);
mesh.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[7]);
face_vhandles.push_back(vhandle[6]);
face_vhandles.push_back(vhandle[5]);
face_vhandles.push_back(vhandle[4]);
mesh.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[4]);
face_vhandles.push_back(vhandle[5]);
mesh.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[5]);
face_vhandles.push_back(vhandle[6]);
mesh.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[6]);
face_vhandles.push_back(vhandle[7]);
mesh.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[7]);
face_vhandles.push_back(vhandle[4]);
mesh.add_face(face_vhandles);
// write mesh to output.obj
try
{
if ( !OpenMesh::IO::write_mesh(mesh, "output.off") )
{
std::cerr << "Cannot write mesh to file 'output.off'" << std::endl;
return 1;
}
}
catch( std::exception& x )
{
std::cerr << x.what() << std::endl;
return 1;
}
return 0;
}
运行结果(经QTviewer打开)
文章修改自 leomass 的文档。
VS2010下配置OpenMesh的更多相关文章
- VS2010下配置Opencv2.4.3 .
VS2008下OpenCV的配置过程在OpenCV论坛上写的很详细,具体过程可以见如下链接http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B ...
- HalconMFC(二)之VS2010下配置Halcon11教程
现在halcon最新版本是halcon11.0.3,所以在此说说halcon11.0.3的配置方法(至今还不知道halcon11怎么破解...halcon10早都可以破解了) 我们可以把相应的文件(头 ...
- 在VS2010下配置OpenCV 2.3
一.下载OpenCV 2.3: http://www.opencv.org.cn/download/OpenCV-2.3.0-win-superpack.exe 二.解压 将下载的Op ...
- win7&win8.1 x64位系统下在VS2010下配置MPICH2&测试&解决scanf不能输入
1. Mpich下载地址http://www.mpich.org/downloads/,下载mpich2-1.4.1p1-win-x86-64(32位系统请下载mpich2-1.4.1p1 ...
- VS2010下配置使用OpenGL的glut库
我已在我机上测试成功,机装VS2010! 在win7(windows7 ultimate SP1)下成功安装VS2010(Visual Studio 2010 ultimate x86). 下载glu ...
- MOGRE学习笔记(1) - OGRE简介及在vs2010下配置
由于工作需要,花费了一段时间研究OGRE,但是研究的目的是要在vs2010平台下用c#进行MOGRE的开发,不得已才转到MGRE,步骤是首选熟悉MOGRE的一些基础知识,做到在winform下能用MO ...
- VS2010下配置OCI编程
OCI是Oracle官方出品的用于C/C++语言连接.操作Oracle数据库的API.在windows操作系统下使用VS等IDE编写.编译C++程序十分方便.简单,不需要使用Makefile.使用OC ...
- Google Protocol Buffer在vs2010下配置
1.从这里下载protobuf-2.6.1.tar.gz到桌面,并解压,解压后的文件夹为protobuf-2.6.1.(我的桌面为C:\Users\mcl\Desktop) 2 .进入文件夹proto ...
- vs2010下配置CUDA出现kernel launch failed问题,内核无效
首先, 推荐一篇不错的配置文档~手把手教你 CUDA 5.5与VS2010编译环境的搭建.笔者就是在这篇文章的指导下成功地在VS2010上搭建了CUDA 6.5~ 其次. 文末给出的执行演示样例不好使 ...
随机推荐
- 《oracle每天一练》Merge Into 语句代替Insert/Update在Oracle中的应用实战
转载自窃破天道 动机: 想在Oracle中用一条SQL语句直接进行Insert/Update的操作. 说明: 在进行SQL语句编写时,我们经常会遇到大量的同时进行Insert/Update的语句 ,也 ...
- Word Search I & II
Word Search I Given a 2D board and a word, find if the word exists in the grid. The word can be cons ...
- 7.31 签到,js 全局预处理笔记
js 解析与执行过程: 一.全局: 1.预处理阶段 : 1.LexicalEnviroment === window {1.预处理 var | 2.function xxx //预处理申明的 ...
- C#之Windows消息处理
public enum WindowsMessage:int { /// <summary> /// /// </summary> WM_NULL = 0x0000, /// ...
- Java web 开发环境搭建
1.下载jdk-8u60-windows-i586.exe;安装过程会让指定jre的安装路径,此处最好指定和jdk安装一个目录下(D:\Program Files\Java\jdk1.8.0_60,D ...
- Python处理JSON数据
python解析json时为了方便,我们首先安装json模块,这里选择demjson,官方网址是:http://deron.meranda.us/python/demjson/ 访问之后点击页面的的D ...
- SQL Server的“错误:9004”
客户的一台现场采集电脑崩溃,无法启动.用PE引导后,将MDF和LDF数据复制出来,往正常的数据库附加时,报如下错误: 处理数据库 'databasename' 的日志时出错.如果可能,请从备份还原.如 ...
- ffmpeg-20160525-git-bin
ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 f ...
- 3.kvm的基本管理
1.查看KVM虚拟机配置文件 #KVM虚拟机默认配置文件位置 [root@kvm qemu]# pwd /etc/libvirt/qemu [root@kvm qemu]# ll total 12 # ...
- 【leetcode】Shortest Palindrome(hard)★
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...