Hi all,
still working on the retopology plugin, i needed to use the "Refine"
method (in refine.h) to subdivide
an auto-generated surface.
To do so i've looked in the "meshfilter" plugin code, and then i've
tryed using it with
my fresh allocated mesh. Here's an example of my code (the point3f
coords are debug values;
"out" is my mesh, and the rest of the code is the standard mesh
generation code):
...
out.cm.Clear();
vcg::tri::Allocator<CMeshO>::AddVertices(out.cm, 6);
vcg::tri::Allocator<CMeshO>::AddFaces(out.cm, 5);
QVector<CMeshO::VertexPointer> ivp(6);
CMeshO::VertexIterator vi=out.cm.vert.begin();
ivp[0] = &*vi; (*vi).P() = Point3f(-0.053, 0.104, 0.040); ++vi;
ivp[1] = &*vi; (*vi).P() = Point3f(-0.031, 0.113, 0.034); ++vi;
ivp[2] = &*vi; (*vi).P() = Point3f(-0.031, 0.094, 0.044); ++vi;
ivp[3] = &*vi; (*vi).P() = Point3f(-0.012, 0.105, 0.043); ++vi;
ivp[4] = &*vi; (*vi).P() = Point3f(-0.046, 0.082, 0.043); ++vi;
ivp[5] = &*vi; (*vi).P() = Point3f(-0.017, 0.084, 0.057);
CMeshO::FaceIterator fi=out.cm.face.begin();
(*fi).V(0) = ivp[0]; (*fi).V(1) = ivp[2]; (*fi).V(2) = ivp[4]; fi++;
(*fi).V(0) = ivp[0]; (*fi).V(1) = ivp[2]; (*fi).V(2) = ivp[1]; fi++;
(*fi).V(0) = ivp[3]; (*fi).V(1) = ivp[2]; (*fi).V(2) = ivp[1]; fi++;
(*fi).V(0) = ivp[3]; (*fi).V(1) = ivp[2]; (*fi).V(2) = ivp[5]; fi++;
(*fi).V(0) = ivp[4]; (*fi).V(1) = ivp[2]; (*fi).V(2) = ivp[5];
out.updateDataMask(MeshModel::MM_FACETOPO | MeshModel::MM_BORDERFLAG);
Refine<CMeshO,MidPoint<CMeshO>>(out.cm, MidPoint<CMeshO>(), 0, false, 0);
out.clearDataMask( MeshModel::MM_VERTFACETOPO);
out.fileName = "Retopology.ply";
tri::UpdateBounding<CMeshO>::Box(out.cm);
vcg::tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(out.cm);
...
Well, the initial mesh is allocated correctly, but after that, the
method "Refine" causes an assertion failure:
[...] Assertion failed! ... File: .../refine.h - Line: 495 -
Expression: lastf==m.face.end()
I've done more and more tests, and the only thing i've noticed is that
this failure occours often (but not for every mesh), and coocurs
expecially when the mesh i'm going to generate has an high number of
vertices and faces (for 2 faces and 4 vertices, for example,
the same code goes well and no assertion failures).
Of course it's higliy probable that the problem should be only on my
mesh allocation code, but where?
Is there any relation with the order of faces allocation?
I've searched for some complex examples in
vcg/complex/trimesh/create/platonic.h,
but, in relation of the methods in that file, i didn't find any
problem in my code.
Any suggestion on where am i going wrong?
Thanks in advance,
D.
|