如何在CGAL中复制曲面网格

问题描述

我想使用功能copy_face_graph(source,target)复制网格。但是目标网格是不同的(它具有相同数量的顶点和面,但是坐标和顺序完全不同)。

代码:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <iostream>
#include <fstream>
#include <CGAL/boost/graph/copy_face_graph.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel   Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3>                   Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;

int main(int argc,char* argv[]) {
    const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
    std::cout << ".off loaded" << std::endl;
    std::ifstream input(filename1);
    Mesh mesh_orig;
    if (!input || !(input >> mesh_orig))
    {
        std::cerr << "First mesh is not a valid off file." << std::endl;
        return 1;
    }
    input.close();

    // ========================================================
    Mesh mesh_copy;
    CGAL::copy_face_graph(mesh_orig,mesh_copy);
    
    // ========================================================

    std::ofstream mesh_cpy("CPY_ANYLYZE/mesh_copy.off");
    mesh_cpy << mesh_copy;
    mesh_cpy.close();


    return 0;
}

有人知道如何从原始网格物体中获得一个完全相同的网格物体吗?我需要添加命名参数,还是使用其他函数?

非常感谢

解决方法

除非您打算编写一些使用不同数据结构的代码,否则可以使用Surface_meshMesh mesh_copy(mesh_orig)中的复制构造函数。 copy_face_graph不会进行原始复制,因为如果输入和输出的类型不同,它也会起作用。但是,输出应与简单顺序相同。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...