From d015efca104ef7f3a6d3b5f96ae5867791517e69 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 26 Oct 2015 10:06:17 +0000 Subject: [PATCH] corrected small bug (!visited instead of visited) --- vcg/complex/algorithms/convex_hull.h | 70 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/vcg/complex/algorithms/convex_hull.h b/vcg/complex/algorithms/convex_hull.h index 73392353..f590f58b 100644 --- a/vcg/complex/algorithms/convex_hull.h +++ b/vcg/complex/algorithms/convex_hull.h @@ -110,7 +110,7 @@ private: for (int i = 0; i < 3; i++) { (*chVi).P().Import(v[i]->P()); - v[i]->SetV(); + v[i]->SetV(); indexInputVertex[chVi] = vcg::tri::Index(mesh, v[i]); chVi++; } @@ -145,7 +145,7 @@ private: chVi = vcg::tri::Allocator::AddVertices(convexHull, 1); (*chVi).P().Import(v4->P()); indexInputVertex[chVi] = vcg::tri::Index(mesh, v4); - v4->SetV(); + v4->SetV(); fi = vcg::tri::Allocator::AddFace(convexHull, &convexHull.vert[3], convexHull.face[0].V0(1), convexHull.face[0].V0(0)); (*fi).N() = vcg::NormalizedTriangleNormal(*fi); fi = vcg::tri::Allocator::AddFace(convexHull, &convexHull.vert[3], convexHull.face[0].V1(1), convexHull.face[0].V1(0)); @@ -175,7 +175,7 @@ public: typename CHMesh:: template PerVertexAttributeHandle indexInputVertex = Allocator::template GetPerVertexAttribute(convexHull, std::string("indexInput")); if (mesh.vert.size() < 4) return false; - vcg::tri::UpdateFlags::VertexClearV(mesh); + vcg::tri::UpdateFlags::VertexClearV(mesh); InitConvexHull(mesh, convexHull); //Build list of visible vertices for each convex hull face and find the furthest vertex for each face @@ -183,23 +183,23 @@ public: std::vector furthestVexterPerFace(convexHull.face.size(), std::make_pair((InputVertexPointer)NULL, 0.0f)); for (int i = 0; i < mesh.vert.size(); i++) { - if (!mesh.vert[i].IsV()) - { - ScalarType maxDist = 0; - for (int j = 0; j < convexHull.face.size(); j++) - { - ScalarType dist = (mesh.vert[i].P() - convexHull.face[j].P(0)).dot(convexHull.face[j].N()); - if (dist > 0) - { - listVertexPerFace[j].push_back(&mesh.vert[i]); - if (dist > furthestVexterPerFace[j].second) - { - furthestVexterPerFace[j].second = dist; - furthestVexterPerFace[j].first = &mesh.vert[i]; - } - } - } - } + if (!mesh.vert[i].IsV()) + { + ScalarType maxDist = 0; + for (int j = 0; j < convexHull.face.size(); j++) + { + ScalarType dist = (mesh.vert[i].P() - convexHull.face[j].P(0)).dot(convexHull.face[j].N()); + if (dist > 0) + { + listVertexPerFace[j].push_back(&mesh.vert[i]); + if (dist > furthestVexterPerFace[j].second) + { + furthestVexterPerFace[j].second = dist; + furthestVexterPerFace[j].first = &mesh.vert[i]; + } + } + } + } } for (int i = 0; i < listVertexPerFace.size(); i++) @@ -243,7 +243,7 @@ public: { CHVertexIterator vi = vcg::tri::Allocator::AddVertices(convexHull, 1); (*vi).P().Import((*vertex).P()); - vertex->SetV(); + vertex->SetV(); indexInputVertex[vi] = vcg::tri::Index(mesh, vertex); } @@ -293,19 +293,19 @@ public: Pair newInfo = std::make_pair((InputVertexPointer)NULL , 0.0f); for (int ii = 0; ii < vertexToTest.size(); ii++) { - if ((*vertexToTest[ii]).IsV()) - { - float dist = ((*vertexToTest[ii]).P() - (*fi).P(0)).dot((*fi).N()); - if (dist > 0) - { - tempVect.push_back(vertexToTest[ii]); - if (dist > newInfo.second) - { - newInfo.second = dist; - newInfo.first = vertexToTest[ii]; - } - } - } + if (!(*vertexToTest[ii]).IsV()) + { + float dist = ((*vertexToTest[ii]).P() - (*fi).P(0)).dot((*fi).N()); + if (dist > 0) + { + tempVect.push_back(vertexToTest[ii]); + if (dist > newInfo.second) + { + newInfo.second = dist; + newInfo.first = vertexToTest[ii]; + } + } + } } listVertexPerFace.push_back(tempVect); furthestVexterPerFace.push_back(newInfo); @@ -365,6 +365,8 @@ public: tri::RequireCompactness(m); InputMesh flipM; + printf("Input mesh m %i %i\n",m.vn,m.fn); + tri::Allocator::AddVertices(flipM,m.vn); ScalarType maxDist=0; InputVertexIterator ci=flipM.vert.begin();