读取OpenMesh文件时断言block_size == b失败

时间:2018-03-15 14:37:46

标签: c++ openmesh

通过

读取OpenMesh文件时
OpenMesh::EPropHandleT<bool> prop_feature_edge;
mesh.add_property(prop_feature_edge, "feature");
OpenMesh::IO::read_mesh(mesh, "testmesh.om");

我收到错误

Assertion failed: block_size == b, file E:\JB\workspace\OpenMesh-Windows-Gitlab-master\c9e6b25f\src\OpenMesh\Core\IO\reader\OMReader.cc, line 564

我在源代码中查找了它,但是并没有真正得到断言在那里检查的内容。问题可能与如何存储/加载网格的不同属性有关,但错误信息对于查看错误确实没有帮助。

请注意,断言中的文件路径来自openmesh二进制文件,而不是我的项目路径。断言定义为in this source source

该文件是使用

编写的
OpenMesh::EPropHandleT<bool> prop_feature_edge;
mesh.add_property(prop_feature_edge, "feature");
mesh.property(prop_feature_edge).set_persistent(true);
OpenMesh::IO::write_mesh(mesh, "testmesh.om");

在我的测试用例中,我编写网格并再次重新读取它并且失败,因此字节顺序,默认选项或库版本应该没有差异。

相关Stacktrace:

    myProgram.exe!OpenMesh::IO::_OMReader_::restore_binary_custom_data(class std::basic_istream<char,struct std::char_traits<char> > &,class OpenMesh::BaseProperty *,unsigned __int64,bool)    Unknown
    myProgram.exe!OpenMesh::IO::_OMReader_::read_binary_edge_chunk(class std::basic_istream<char,struct std::char_traits<char> > &,class OpenMesh::IO::BaseImporter &,class OpenMesh::IO::Options &,bool)   Unknown
    myProgram.exe!OpenMesh::IO::_OMReader_::read_binary(class std::basic_istream<char,struct std::char_traits<char> > &,class OpenMesh::IO::BaseImporter &,class OpenMesh::IO::Options &)   Unknown
    myProgram.exe!OpenMesh::IO::_OMReader_::read(class std::basic_istream<char,struct std::char_traits<char> > &,class OpenMesh::IO::BaseImporter &,class OpenMesh::IO::Options &)  Unknown
    myProgram.exe!OpenMesh::IO::_OMReader_::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class OpenMesh::IO::BaseImporter &,class OpenMesh::IO::Options &)  Unknown
    myProgram.exe!OpenMesh::IO::_IOManager_::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class OpenMesh::IO::BaseImporter &,class OpenMesh::IO::Options &) Unknown
    myProgram.exe!OpenMesh::IO::read_mesh<OpenMesh::TriMesh_ArrayKernelT<OpenMesh::DefaultTraits> >(OpenMesh::TriMesh_ArrayKernelT<OpenMesh::DefaultTraits> & _mesh, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _filename, OpenMesh::IO::Options & _opt, bool _clear) Line 141    C++
    myProgram.exe!main(int argc, char * * argv) Line 479    C++
    [External Code] 

所以这看起来真的是自定义属性中的一些错误的大小计算。 我复制了添加自定义属性的代码,并在读取网格之前写入网格请求现有属性(如面状态和顶点颜色),以确保具有相同的网格属性,但仍然会崩溃。

比较配置的网格的属性,它们似乎是相同的:

properties before writing
3 vprops:
  v:points
  <vprop>
  v:colors
1 hprops:
  <hprop>
2 eprops:
  <eprop>
  feature, persistent
2 fprops:
  <fprop>
  f:status
0 mprops:
#bytes written: 169006

properties before reading
3 vprops:
  v:points
  <vprop>
  v:colors
1 hprops:
  <hprop>
2 eprops:
  <eprop>
  feature, persistent
2 fprops:
  <fprop>
  f:status
0 mprops:

1 个答案:

答案 0 :(得分:1)

我找到了问题的解决方案。

在写作之前我删除了面孔。这需要在面上有一个(非透明)状态标志,需要通过request_face_status()添加。

此工作正常,collect_garbage()正确删除了面,但未删除相应的边。这导致在写入之前和加载之后边缘的数量不同,而存储的feature属性可能具有与之前相同的大小,这与加载的边缘的数量不匹配。

解决方案是添加

mesh.request_edge_status()

mesh.request_face_status()之外。根据网格上的操作,也可以使用mesh.request_vertex_status()