From 36d9030955f1a1e2c6f905eb127179263af67bd1 Mon Sep 17 00:00:00 2001 From: mtarini Date: Tue, 17 Jul 2012 19:21:46 +0000 Subject: [PATCH] added SplitNonFlatQuads method --- vcg/complex/algorithms/bitquad_creation.h | 31 ++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/vcg/complex/algorithms/bitquad_creation.h b/vcg/complex/algorithms/bitquad_creation.h index 5d5cfde3..ad908e83 100644 --- a/vcg/complex/algorithms/bitquad_creation.h +++ b/vcg/complex/algorithms/bitquad_creation.h @@ -45,7 +45,9 @@ void MakeDominant(MeshType &m, int level) void MakeBitTriOnly(MeshType &m) - inverse process: returns to tri-only mesh - +int SplitNonFlatQuads(MeshType &m, ScalarType toleranceDeg=0){ + - as above, but splits only non flat quads + (more info in comments before each method) */ @@ -55,7 +57,7 @@ void MakeBitTriOnly(MeshType &m) namespace vcg{namespace tri{ template > + class Interpolator = GeometricInterpolator > class BitQuadCreation{ public: @@ -71,7 +73,6 @@ typedef typename MeshType::VertexIterator VertexIterator; typedef BitQuad BQ; // static class to make basic quad operations - // helper function: // given a triangle, merge it with its best neightboord to form a quad template @@ -275,6 +276,27 @@ static bool MakeTriEvenByDelete(MeshType& m) } +/* + Splits any quad that makes an angle steeper than given degrees +*/ +static int SplitNonFlatQuads(MeshType &m, ScalarType deg=0){ + int res=0; + float th = math::Cos(math::ToRad(deg)); + for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { + if (fi->IsAnyF()) { + int faux = BQ::FauxIndex(&*fi); + FaceType *fb = fi->FFp(faux); + if (fb->N()*fi->N()ClearF(faux); + fb->ClearF(fi->FFi(faux)); + res++; + } + } + } + return res; +} + + /** Given a mesh, makes it bit trianglular (makes all edges NOT faux) */ @@ -769,9 +791,6 @@ static bool MakePureByFlip(MeshType &m, int maxdist=10000) */ static void MakeDominant(MeshType &m, int level){ - assert(MeshType::HasPerFaceQuality()); - assert(MeshType::HasPerFaceFlags()); - for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) { fi->ClearAllF(); fi->Q() = 0;