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
And get this error,
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.
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
But both with no success.
Inspired by this Stackoverflow question how to save color using vcglib? and this answer, I add the Color4b attribute for the vertex by replace
with
in the
trimesh_clustering.cpp
file. Then compile and run the code, it works.For now I remove the color attribute of the vertex to make run, this will lost the color info of the mesh. This is just a workaround not the idal way.
Below is the process how can I get it.
remove the color attribute.
I use
g++
andgdb
to debug the issue,the issue part of gdb output,
I find this
c+=CoordType(f.cV(i)->C()[0],f.cV(i)->C()[1],f.cV(i)->C()[2]);
caused the issue. This line of code is process the color attribute of the vertex in the file. So I comment this line, then compile the sourcecode and run it. The issue gone.