我想使用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和msvc2017。我尝试在PMP :: corefine_and_compute_union(mesh1,mesh2,out)上运行msvc调试器,但无济于事...
有什么想法为什么会发生这种情况以及如何使其在MSVC 2017上运行?
答案 0 :(得分:1)
如果您阅读documention,将会看到必须满足一些先决条件。您的输入网格之一很可能具有一些自相交。在同一文档页面上,您还将找到命名参数throw_on_self_intersection
,如果将其设置为true
,则在输入在交点附近具有自交点的情况下,该函数将引发异常。