[英]CGAL boolean operation on 3d mesh with color
我想做的是在每个顶点具有RGB颜色的2个模型上执行CGAL布尔运算符(联合运算符)。 但是结果不保留颜色信息。 也许您有一个解决此问题的想法。
以下是进行布尔运算(coff格式)的模型:
这是我正在使用的代码:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K, CGAL::Polyhedron_items_with_id_3> Mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/b1.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/b2.off";
std::ifstream input(filename1);
Mesh mesh1, mesh2;
if (!input || !(input >> mesh1))
{
std::cerr << "First mesh is not a valid off file." << std::endl;
return 1;
}
input.close();
input.open(filename2);
if (!input || !(input >> mesh2))
{
std::cerr << "Second mesh is not a valid off file." << std::endl;
return 1;
}
Mesh out;
bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out);
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库中有一个命令可以加载包含彩色RGB的“ coff”格式。 但是我不知道如何使用它。 我的第一个尝试是如何定义数据类型。
据我所知,只有Surface_mesh数据结构能够使用COFF文件。 您可以在Polyhedron / demo / Polyhedron中查看Surface_mesh_io_plugin的代码。 COFF格式是一个有据可查的标准。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.