无法使用vcglib简化3D模型,断言“ 0”失败 [英] Failed to to simplify 3D models with vcglib, Assertion `0' failed
问题描述
我使用了 vcglib 来简化3D模型文件。我使用了master_a8e87662 git repo。我运行示例trimesh_clustering 来简化plf文件格式的3D模型,
I used vcglib to simplify 3D model file. I used the master_a8e87662 git repo. I run the sample trimesh_clustering to simplify a plf file format 3D model with this,
./trimesh_clustering ./Zeus.ply out.ply -k 1000
并得到此错误,
Input mesh vn:152059 fn:304114
Clustering to 95472 cells
Grid of 51 x 26 x 72 cells
with cells size of 0.48 x 0.49 x 0.48 units
trimesh_clustering: vcglib/vcg/simplex/vertex/component.h:75: vcg::vertex::EmptyCore<TT>::ColorType& vcg::vertex::EmptyCore<TT>::C() [with TT = MyUsedTypes; vcg::vertex::EmptyCore<TT>::ColorType = vcg::Color4<unsigned char>]: Assertion `0' failed.
形成问题,我想它可能是由ply文件中的Color引起的,所以我使用了ply像这样没有颜色的文件,
Form the issue, I guess it may caused by the Color in the ply file, So I use ply file without color like this,
ply
format ascii 1.0
comment VCGLIB generated
element vertex 152059
property float x
property float y
property float z
element face 304114
property list uchar int vertex_indices
end_header
-6.17266 0.227923 17.2279
-6.21338 0.633413 26.6069
2.48586 -2.95844 27.9508
1.00704 -3.94445 24.3854
和带有这样颜色的层文件,
and ply file with color like this,
ply
format ascii 1.0
comment VCGLIB generated
element vertex 152059
property float x
property float y
property float z
property int flags
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 304114
property list uchar int vertex_indices
end_header
-6.17266 0.227923 17.2279 0 192 192 192 255
-6.21338 0.633413 26.6069 0 192 192 192 255
2.48586 -2.95844 27.9508 0 192 192 192 255
1.00704 -3.94445 24.3854 0 192 192 192 255
-0.337305 -4.75996 27.4304 0 192 192 192 255
但两者均未成功。
推荐答案
受此Stackoverflow问题启发如何使用颜色保存颜色vcglib?和此答案,我通过替换为顶点添加了Color4b属性
Inspired by this Stackoverflow question how to save color using vcglib? and this answer, I add the Color4b attribute for the vertex by replace
class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
有
class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags, vcg::vertex::Color4b >{};
。然后编译并运行代码,即可正常工作。
in the trimesh_clustering.cpp
file. Then compile and run the code, it works.
这篇关于无法使用vcglib简化3D模型,断言“ 0”失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!