问题
I want to use vcglib for reconstructing a surface based on a point cloud. But whenever I run my program (also with the provided examples, e.g. /vcglib/apps/sample/trimesh_allocate) I get the following output:
trimesh_allocate: ../../../vcg/simplex/vertex/component.h:50: int vcg::vertex::EmptyCore::cFlags() const [with TT = MyUsedTypes]: Assertion `0' failed.
Any ideas how to solve this? I am using QT-Creator 2.4.1 on Ubuntu 12.04. I do net get any compiler or linker errors.
Thanks a lot in advance, Mirco
回答1:
In order to get rid of such an error you typically need to change the definition of the vertex, edge, face, mesh definition. I could get this example to work using:
class MyFace;
class MyVertex;
struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::VFAdj, vcg::vertex::BitFlags, vcg::vertex::Mark>{};
class MyFace : public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::FFAdj, vcg::face::Mark, vcg::face::VFAdj, vcg::face::BitFlags > {};
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
I believe the vcg::xx::BitFlags
are the ones that you need to add for both vertex and face. This can be seen from the error you have that is about cFlags().
Furthermore in the trimesh_allocate.cpp
example, you need to comment out the following section:
// WRONG WAY of iterating: FN() != m.face.size() if there are deleted elements
/*for(int i=0;i<m.FN();++i)
{
if(!fi->IsD())
{
MyMesh::CoordType b = vcg::Barycenter(*fi);
}
}*/
来源:https://stackoverflow.com/questions/13586957/assertion-failure-when-using-vcglib-examples