cgal - CGAL 多边形网格处理布尔运算崩溃
问题描述
我想使用 CGAL 的多边形网格处理包对两个网格执行布尔运算。问题是 corefinement_and_union 示例崩溃:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "eight.off";
std::ifstream input1(filename1);
std::ifstream input2(filename2);
Mesh mesh1, mesh2;
input1 >> mesh1;
std::cout << mesh1.number_of_vertices() << std::endl; //mesh1 input OK
input1.close();
input2 >> mesh2;
input2.close();
std::cout << mesh2.number_of_vertices() << std::endl; //mesh2 input OK
Mesh out;
bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out); //crashes
if (valid_union)
{
std::cout << "Union was successfully computed\n";
std::ofstream output("union.off");
output << out;
return 0;
}
std::cout << "Union could not be computed\n";
return 1;
}
我使用 cgal 5.0 作为仅标头库,带有 boost 1.71.0 v14.1、Eigen 3.3.7 和 msvc 2017。我尝试在 PMP::corefine_and_compute_union(mesh1,mesh2, out) 上运行 msvc 调试器,但是徒劳无功...
任何想法为什么会发生这种情况以及如何让它在 MSVC 2017 上运行?
解决方案
如果您阅读文档,您会看到必须满足一些先决条件。很可能您的一个输入网格有一些自相交。在同一文档页面上,您还将找到命名参数throw_on_self_intersection
,如果设置为该参数true
将使函数抛出异常,以防您的输入在交叉点附近有自交叉点。
推荐阅读
- android - Continually Running Background Service
- bash - Fill empty fields - awk
- android - Load a single field of the object in realm
- angular - Firefox 控制台中的异常跟踪不使用源映射
- c# - 在多个线程上执行一个函数
- c# - 在 C# 中复制 Webbrowser 将页面另存为函数
- python - Python创建exe文件错误
- laravel - 仅当值不可用时才需要验证
- java - How to pass class by Interface to AsyncTask?
- javascript - Babel 不会从 'node_modules' 转译导入的模块