added SplitNonFlatQuads method

This commit is contained in:
mtarini 2012-07-17 19:21:46 +00:00
parent 5380a6f7f6
commit 36d9030955
1 changed files with 25 additions and 6 deletions

View File

@ -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 _MeshType,
class Interpolator = GeometricInterpolator<typename _MeshType::VertexType> >
class Interpolator = GeometricInterpolator<typename _MeshType::VertexType> >
class BitQuadCreation{
public:
@ -71,7 +73,6 @@ typedef typename MeshType::VertexIterator VertexIterator;
typedef BitQuad<MeshType> BQ; // static class to make basic quad operations
// helper function:
// given a triangle, merge it with its best neightboord to form a quad
template <bool override>
@ -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()<th) {
fi->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;