Grit-Walker

 

如何将OpenMesh中的网格结构转化为CGAL中的网格结构(精简版)

本来准备封装一个函数,用来把OpenMesh中的网格结构转化为CGAL中的网格结构,然后发现没必要,大家可以看看下面这三个没必要的文件

mian.cpp

 1 #include <iostream>
 2 #include <OpenMesh/Core/IO/MeshIO.hh>
 3 #include "OMmeshToCGALmesh.h"
 4 
 5 
 6 int main() {
 7 
 8     //测试函数 rans_ommesh_to_cgalmesh(OMMesh& _ommesh, CGALMesh& _cgalmesh)
 9     OMMesh ommesh;
10     CGALMesh cgalmesh;
11 
12     if (OpenMesh::IO::read_mesh(ommesh, "E:\\3d_model_files\\sphere0.stl")) {
13         std::clog << "顺利读入模型文件到OM_mesh中" << std::endl;
14     }
15 
16     trans_ommesh_to_cgalmesh(ommesh,cgalmesh);
17 
18     std::clog << vertices(cgalmesh).size() << std::endl;
19     std::clog << halfedges(cgalmesh).size() << std::endl;
20     std::clog << faces(cgalmesh).size() << std::endl;
21 
22     return 0;
23 }

OMmeshToCGALmesh.h

 1 #pragma once
 2 #ifndef OMMESHTOCGALMESH_H
 3 #define OMMESHTOCGALMESH_H
 4 
 5 #include <OpenMesh/Core/Mesh/DefaultTriMesh.hh>
 6 
 7 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
 8 #include <CGAL/Surface_mesh.h>
 9 #include <CGAL/boost/graph/copy_face_graph.h>
10 #include <CGAL/boost/graph/graph_traits_TriMesh_ArrayKernelT.h>
11 
12 typedef OpenMesh::TriMesh OMMesh;
13 
14 typedef CGAL::Exact_predicates_inexact_constructions_kernel        K;
15 typedef K::Point_3                                                 Point_3;
16 typedef CGAL::Surface_mesh<Point_3>                                CGALMesh;
17 
18 void trans_ommesh_to_cgalmesh(OMMesh& _ommesh, CGALMesh& _cgalmesh);
19 
20 #endif

OMmeshToCGALmesh.cpp

1 #include "OMmeshToCGALmesh.h"
2 
3 
4 void trans_ommesh_to_cgalmesh(OMMesh& _ommesh, CGALMesh& _cgalmesh) {
5 
6     CGAL::copy_face_graph(_ommesh, _cgalmesh);
7 
8     return;
9 }

 

 

 

posted on 2022-07-11 15:29  禾八  阅读(221)  评论(0)    收藏  举报

导航