Open Lishen1 opened 5 years ago
sure https://dropmefiles.com/fkDFn
void Generators::buildPrimalSpanningTree(Mesh& mesh,
VertexData<VertexCIter>& primalParent)
{
// mark each vertex as its own parent
for (VertexCIter v = mesh.vertices.begin(); v != mesh.vertices.end(); v++) {
primalParent[v] = v;
}
// build primal spanning tree
VertexCIter root = mesh.vertices.begin();
std::queue<VertexCIter> q;
q.push(root);
int cnt = 0;
while (!q.empty()) {
VertexCIter u = q.front();
q.pop();
HalfEdgeCIter he = u->he;
do {
HalfEdgeCIter flip = he->flip;
EdgeCIter e = he->edge;
if (e->isCuttable) {
VertexCIter v = flip->vertex;
if (primalParent[v] == v && v != root) {
primalParent[v] = u;
q.push(v);
}
}
if (cnt == 4077)
{
std::cout << "he " << he->index << std::endl;
std::cout << "he->onBoundary " << he->onBoundary << std::endl;
std::cout << "he->face " << he->face->index << std::endl;
std::cout << "vertex idx " << he->vertex->index << std::endl;
std::cout << "vertex pos " << he->vertex->position.x << " " << he->vertex->position.y << " " << he->vertex->position.z << std::endl;
}
he = flip->next;
} while (he != u->he);
//std::cout << "iter " << cnt << std::endl;
cnt++;
}
}
in my case in function void HoleFiller::fill(FaceIter b, const std::vector
// inserting halfedges, edges, faces and corners *should* not invalidate iterators as
// extra space was reserved in the preallocateElements function in MeshIO
for (int i = 0; i < n - 3; i++) {
do nothing and here
// update connectivity
VertexIter rootVertex = boundaryHalfEdges[0]->vertex;
for (int i = 0; i < (int)boundaryHalfEdges.size(); i++) {
HalfEdgeIter he = boundaryHalfEdges[i];
if (i == 0) {
HalfEdgeIter next = he->next;
HalfEdgeIter newHe = mesh.halfEdges.begin() + nHalfEdges; // <-- here
HalfEdgeIter newHe is iterator to unexisted half edge. btw. i think you shoul use assert to check are we have enouh preserved memory in vector to do not trig reallocation.
Thanks @Lishen1, this bug will be fixed in the next release.
@rohan-sawhney this problem can be solved by handle special case like:
if (n == 3)
{
if (i == 0) {
HalfEdgeIter next = he->next;
FaceIter newF = mesh.faces.begin() + nFaces;
CornerIter newC1 = mesh.corners.begin() + nCorners;
CornerIter newC2 = mesh.corners.begin() + nCorners + 1;
CornerIter newC3 = mesh.corners.begin() + nCorners + 2;
he->onBoundary = false;
next->onBoundary = false;
next->next->onBoundary = false;
newF->he = he;
he->face = newF;
next->face = newF;
next->next->face = newF;
newC3->he = he;
newC1->he = next;
newC2->he = next->next;
he->corner = newC3;
next->corner = newC1;
next->next->corner = newC2;
}
}
but, what fillAll flag in HoleFiller::fill do ? if i set it to false, and commen if (loopLength < 0.5*mesh.diameter()) fillAll = true; i get inifinite loop in BFF procedure, even in on face.obj. for my mesh it looks like it close main border of my mesh and produce bad result.
do you have a mesh you could share where this happens?