From 358c8e5e4427e0211cc8a1efdac9afe64ba021eb Mon Sep 17 00:00:00 2001 From: "T.Alderighi" Date: Thu, 10 May 2018 18:25:55 +0200 Subject: [PATCH] quality by aspect ratio --- vcg/complex/algorithms/update/quality.h | 33 +++++++++++++++++++++++++ vcg/space/tetra3.h | 12 ++++----- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/vcg/complex/algorithms/update/quality.h b/vcg/complex/algorithms/update/quality.h index c8572aa0..450ac3a7 100644 --- a/vcg/complex/algorithms/update/quality.h +++ b/vcg/complex/algorithms/update/quality.h @@ -156,6 +156,14 @@ static void TetraFromVolume(MeshType & m) }); } +static void TetraFromAspectRatio(MeshType & m) +{ + tri::RequirePerTetraQuality(m); + ForEachTetra(m, [] (MeshType::TetraType & t) { + t.Q() = TetraQualityType(vcg::Tetra::AspectRatio(t)); + }); +} + static void VertexFromFace( MeshType &m, bool areaWeighted=true) { tri::RequirePerFaceQuality(m); @@ -182,6 +190,31 @@ static void VertexFromFace( MeshType &m, bool areaWeighted=true) } } +static void VertexFromTetra(MeshType & m, bool volumeWeighted = true) +{ + tri::RequirePerTetraQuality(m); + tri::RequirePerVertexQuality(m); + + SimpleTempData TQ(m.vert, 0); + SimpleTempData TCnt(m.vert, 0); + + ForEachTetra(m, [&] (TetraType & t) { + TetraQualityType w = 1.; + if (volumeWeighted) + w = vcg::Tetra::ComputeVolume(t); + + for (int i = 0; i < 4; ++i) + { + TQ[t.V(i)] += t.Q() * w; + TCnt[t.V(i)] += w; + } + }); + + ForEachVertex(m, [&] (VertexType & v) { + v.Q() = TQ[v] / TCnt[v]; + }); +} + template static void VertexFromAttributeHandle(MeshType &m, typename MeshType::template PerVertexAttributeHandle &h) { diff --git a/vcg/space/tetra3.h b/vcg/space/tetra3.h index 3aaa4db5..3447d016 100644 --- a/vcg/space/tetra3.h +++ b/vcg/space/tetra3.h @@ -327,15 +327,15 @@ static typename TetraType::ScalarType DihedralAngle (const TetraType & t, const int f0 = Tetra::FofE(eidx, 0); int f1 = Tetra::FofE(eidx, 1); - CoordType p0 = t.P(Tetra::VofF(f0, 0)); - CoordType p1 = t.P(Tetra::VofF(f0, 1)); - CoordType p2 = t.P(Tetra::VofF(f0, 2)); + CoordType p0 = t.cP(Tetra::VofF(f0, 0)); + CoordType p1 = t.cP(Tetra::VofF(f0, 1)); + CoordType p2 = t.cP(Tetra::VofF(f0, 2)); CoordType n0 = ((p2 - p0) ^ (p1 - p0)).normalized(); - p0 = t.P(Tetra::VofF(f1, 0)); - p1 = t.P(Tetra::VofF(f1, 1)); - p2 = t.P(Tetra::VofF(f1, 2)); + p0 = t.cP(Tetra::VofF(f1, 0)); + p1 = t.cP(Tetra::VofF(f1, 1)); + p2 = t.cP(Tetra::VofF(f1, 2)); CoordType n1 = ((p2 - p0) ^ (p1 - p0)).normalized();