Code Monkey home page Code Monkey logo

Comments (5)

rohan-sawhney avatar rohan-sawhney commented on August 16, 2024

do you have a mesh you could share where this happens?

from boundary-first-flattening.

Lishen1 avatar Lishen1 commented on August 16, 2024

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++;
  }
}

from boundary-first-flattening.

Lishen1 avatar Lishen1 commented on August 16, 2024

in my case in function void HoleFiller::fill(FaceIter b, const std::vector& boundaryHalfEdges, Mesh& mesh)
int n = (int)boundaryHalfEdges.size();// n == 3
so, this

// 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.

from boundary-first-flattening.

rohan-sawhney avatar rohan-sawhney commented on August 16, 2024

Thanks @Lishen1, this bug will be fixed in the next release.

from boundary-first-flattening.

Lishen1 avatar Lishen1 commented on August 16, 2024

@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.

from boundary-first-flattening.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.