diff --git a/wrap/igl/arap_parametrization.h b/wrap/igl/arap_parametrization.h index 159bc58c..e1952704 100644 --- a/wrap/igl/arap_parametrization.h +++ b/wrap/igl/arap_parametrization.h @@ -143,27 +143,35 @@ void InitializeArapWithLSCM(MeshType & m, unsigned int fixedMask = 0) if (fixedMask == 0) { - // manually select fixed vertices + // automatically select 2 vertices to fix vcg::tri::UpdateFlags::Clear(m); int fixed0, fixed1 = -1; - ScalarType minD0 = std::numeric_limits::max(); - ScalarType minD1 = std::numeric_limits::max(); + auto p = m.bbox.Center(); + ScalarType maxDist = -1; for (size_t i=0; i maxDist) { fixed0 = i; - minD0 = testD0; - } - if (testD1 < minD1) - { - fixed1 = i; - minD1 = testD1; + maxDist = dist; } } + maxDist = -1; + p = m.vert[fixed0].cP(); + for (size_t i=0; i maxDist) + { + fixed1 = i; + maxDist = dist; + } + } + assert(fixed0 >= 0); assert(fixed1 >= 0); assert(fixed0 != fixed1);