CGAL:添加要素失败
CGAL: adding features fails
任务
很简单:我想创建一个四面体网格,我想为其添加几个特征。
例
作为输入,请获取可在CGAL-4.11/examples/Mesh_3/data
中找到的文件cube.off
。我想添加的功能(仅立方体的十二条边(保存在cube.edges
:
2 -1 -1 -1 -1 1 -1
2 -1 -1 -1 1 -1 -1
2 -1 -1 -1 -1 -1 1
2 -1 1 -1 1 1 -1
2 -1 1 -1 -1 1 1
2 1 1 -1 1 -1 -1
2 1 1 -1 1 1 1
2 1 -1 -1 1 -1 1
2 -1 -1 1 -1 1 1
2 -1 -1 1 1 -1 1
2 -1 1 1 1 1 1
2 1 1 1 1 -1 1
代码的 MWE:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Polyhedral_complex_mesh_domain_3.h>
#include <CGAL/make_mesh_3.h>
// From CGAL-4.11/examples/Mesh_3 but for simplicity copied to the current folder.
#include "read_polylines.h"
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Mesh_polyhedron_3<K>::type Polyhedron;
typedef CGAL::Polyhedral_complex_mesh_domain_3<K> Mesh_domain;
typedef CGAL::Sequential_tag Concurrency_tag;
typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,Concurrency_tag>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<
Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_segment_index> C3t3;
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
typedef K::Point_3 Point;
typedef std::vector<std::vector<Point> > Polylines;
int main()
{
// Read the (one) patch.
std::vector<Polyhedron> patches(1);
std::ifstream input("cube.off");
input >> patches[0];
const std::pair<int, int> incident_subdomains[] = { std::make_pair(1,0) };
Mesh_domain domain(patches.begin(), patches.end(), incident_subdomains, incident_subdomains+1);
// Read the features.
std::string feature_edges="cube.edges";
Polylines polylines;
read_polylines<Point>(feature_edges.c_str(), polylines);
domain.add_features(polylines.begin(), polylines.end());
// Create the mesh.
Mesh_criteria criteria(CGAL::parameters::edge_size = 0.25);
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria);
// Write it (if it hasn't crashed before).
std::ofstream medit_file("out.mesh");
c3t3.output_to_medit(medit_file, false, true);
}
这(使用选项-DCGAL_MESH_3_VERBOSE
编译时(崩溃并显示以下错误消息:
Start volume scan...Scanning triangulation for bad cells (sequential)... terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: patch_id > 0 && std::size_t(patch_id) < patch_id_to_polyhedron_id.size()
File: /yatmp/scr1/ya10813/cgal-install/include/CGAL/Polyhedral_complex_mesh_domain_3.h
Line: 457
Aborted
问题
我错过了什么?它一定是非常基本的东西。CGAL 是一个非常可靠的库,可以很好地处理复杂数据;我不相信一个有 12 条边的立方体足以阻止它。
我也尝试过的事情
当我将行
domain.add_features(polylines.begin(), polylines.end());
替换为domain.detect_features();
时,程序正确终止。令人困惑的是,检测到的特征正是我尝试添加的特征(我知道,因为我在Mesh_domain_with_polyline_features_3
中制作了一个为我打印边缘的功能;如有必要,我可以在这里分享(。当我使用
Polyhedral_mesh_domain_with_features_3
而不是Polyhedral_complex_mesh_domain_3
时,程序正确终止。这些特征似乎保留在生成的几何中。但是,它只是一个补丁(out.mesh
中的所有三角形都具有相同的最后一个数字,而在这种情况下我希望它们具有数字 0 到 11(。编辑:为了实现这一点,必须使用detect_features();
而不是add_features(...);
,或者将域拆分为补丁,让CGAL从中创建复合体。感谢@lrineau的澄清。我还尝试先将域拆分为几个补丁。但是,随后补丁的边界会发生变化。编辑:保留它们的一种方法是将面片边界添加为要素。
反转表面的方向(并在
incident_subdomains
中交换0
和1
(:没有明显的变化。更改特征线的顺序
cube.edges
:无可见变化。与旧版本的 Boost 链接:没有明显的变化。
类Polyhedral_complex_mesh_domain_3
是一年前在CGAL-4.11中添加的新类。你得到的问题是,它从来没有在没有调用domain.detect_features()
的情况下进行测试,并且代码有一个错误:数据成员patch_id_to_polyhedron_id
只在detect_features()
中填充。这就解释了为什么当您调用detect_features()
而不是add_features(..)
时它会起作用。
编辑:我今天修复了该错误,请参阅 CGAL 的 PR #3393。该修复将在将来的错误修复版本中发布 CGAL-4.12.2 和 CGAL-4.13.1。
- 为什么除非添加括号,否则构造函数上的模板替换会失败?
- 这个失败的测试是将零添加到空指针未定义的行为、编译器错误还是其他什么?
- CGAL:添加要素失败
- 添加类型名会导致程序编译失败
- 将 qi::lexeme 添加到灵气中的规则时编译失败
- MSBuidel - 将资源文件添加到项目后静态库编译失败
- 添加新对话框后,MFC 应用程序启动失败并"DLL Initialization Failed"
- 为什么添加静态数据成员会导致链接器失败
- 将工具提示添加到 ComboBoxEx 失败
- 在添加额外的字符时,字符串流的putback失败
- 如何在服务exe中添加失败操作
- 添加大数字C++-初始化程序失败
- 将opencv库添加到QT创建者并获取错误:链接器命令失败,退出代码为1
- C++将节点添加到链表的开头一次后失败.其他方法也有问题
- 添加参数后"模板参数推断/替换失败"
- VC++类在新构建中失败,但在添加空白后神秘地构建
- 日志含义添加PW_USER_PASSWORD属性失败
- 代码使用cmake干净地构建,当作为外部项目添加时失败
- 向size_t添加const会导致编译失败,这是标准行为吗
- c++初学者.添加函数并调用它失败