harmless gcc warning

This commit is contained in:
Paolo Cignoni 2014-05-16 08:43:00 +00:00
parent 48f9487eaa
commit 2b3bb02be0
1 changed files with 51 additions and 51 deletions

View File

@ -5,7 +5,7 @@ namespace vcg{namespace tri{
template <class BQ> template <class BQ>
class BitQuadOptimization{ class BitQuadOptimization{
typedef typename BQ::MeshType MeshType; typedef typename BQ::MeshType MeshType;
typedef typename BQ::Pos Pos; typedef typename BQ::Pos Pos;
@ -23,11 +23,11 @@ public:
// helper function: mark a quadface, setting Q at 0, and neight at .75, 0.5... // helper function: mark a quadface, setting Q at 0, and neight at .75, 0.5...
static void MarkFace(FaceType* f, MeshType &m){ static void MarkFace(FaceType* f, MeshType &m){
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
fi->Q() = 1; fi->Q() = 1;
} }
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) f->FFp(i)->FFp(j)->Q() = 0.75; for (int j=0; j<3; j++) f->FFp(i)->FFp(j)->Q() = 0.75;
} }
@ -35,42 +35,42 @@ static void MarkFace(FaceType* f, MeshType &m){
f->FFp(i)->Q() = 0.50; f->FFp(i)->Q() = 0.50;
} }
f->Q() = 0; f->Q() = 0;
} }
// helper function: mark a quadface, setting Q at 0, and neight at .75, 0.5... // helper function: mark a quadface, setting Q at 0, and neight at .75, 0.5...
static void MarkVertex(FaceType* f, int wedge, MeshType &m){ static void MarkVertex(FaceType* f, int wedge, MeshType &m){
VertexType *v = f->V(wedge); VertexType *v = f->V(wedge);
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
if (fi->V0(0)==v || fi->V1(0)==v ||fi->V2(0)==v ) fi->Q() = 0; if (fi->V0(0)==v || fi->V1(0)==v ||fi->V2(0)==v ) fi->Q() = 0;
// else fi->Q() = 1; // else fi->Q() = 1;
} }
} }
static bool MarkSmallestEdge(MeshType &m, bool perform) static bool MarkSmallestEdge(MeshType &m, bool perform)
{ {
ScalarType min = std::numeric_limits<ScalarType>::max(); ScalarType min = std::numeric_limits<ScalarType>::max();
FaceType *fa=NULL; int w=0; FaceType *fa=NULL; int w=0;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD())
for (int k=0; k<3; k++) { for (int k=0; k<3; k++) {
FaceType *f=&*fi; FaceType *f=&*fi;
if (f->IsF(k)) continue; if (f->IsF(k)) continue;
if (f->FFp(k) == f ) continue; // skip borders if (f->FFp(k) == f ) continue; // skip borders
ScalarType score; ScalarType score;
score = (f->P0(k) - f->P1(k)).Norm(); score = (f->P0(k) - f->P1(k)).Norm();
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
w = k; w = k;
} }
} }
if (fa) { if (fa) {
if (perform) { if (perform) {
@ -84,56 +84,56 @@ static bool MarkSmallestEdge(MeshType &m, bool perform)
return false; return false;
} }
static ScalarType Importance(const CoordType &p){ static ScalarType Importance(const CoordType &/*p*/){
//return ::proceduralImportance(p); //return ::proceduralImportance(p);
return 1; return 1;
} }
// returns: 0 if fail. 1 if edge. 2 if diag. // returns: 0 if fail. 1 if edge. 2 if diag.
static int MarkSmallestEdgeOrDiag(MeshType &m, ScalarType edgeMult, bool perform, Pos* affected=NULL) static int MarkSmallestEdgeOrDiag(MeshType &m, ScalarType edgeMult, bool perform, Pos* affected=NULL)
{ {
ScalarType min = std::numeric_limits<ScalarType>::max(); ScalarType min = std::numeric_limits<ScalarType>::max();
FaceType *fa=NULL; int w=0; bool counterDiag = false; FaceType *fa=NULL; int w=0; bool counterDiag = false;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD())
for (int k=0; k<3; k++) { for (int k=0; k<3; k++) {
FaceType *f=&*fi; FaceType *f=&*fi;
if (f->FFp(k) >= f ) continue; // skip borders (==), and do it one per edge if (f->FFp(k) >= f ) continue; // skip borders (==), and do it one per edge
ScalarType score; ScalarType score;
score = (f->P0(k) - f->P1(k)).Norm(); score = (f->P0(k) - f->P1(k)).Norm();
ScalarType imp = Importance( (f->P0(k) + f->P1(k))/2 ); ScalarType imp = Importance( (f->P0(k) + f->P1(k))/2 );
score /= imp; score /= imp;
if (!f->IsF(k)) score*=edgeMult; // edges are supposed to be smaller! if (!f->IsF(k)) score*=edgeMult; // edges are supposed to be smaller!
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
w = k; w = k;
counterDiag=false; counterDiag=false;
} }
if (f->IsF(k)) { // for diag faces, test counterdiag too if (f->IsF(k)) { // for diag faces, test counterdiag too
score = BQ::CounterDiag(f).Norm(); score = BQ::CounterDiag(f).Norm();
score /= imp; score /= imp;
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
w = k; w = k;
counterDiag=true; counterDiag=true;
} }
} }
} }
if (fa) { if (fa) {
if (perform) { if (perform) {
@ -159,25 +159,25 @@ static int MarkSmallestEdgeOrDiag(MeshType &m, ScalarType edgeMult, bool perform
static void MarkSmallestDiag(MeshType &m) static void MarkSmallestDiag(MeshType &m)
{ {
ScalarType min = std::numeric_limits<ScalarType>::max(); ScalarType min = std::numeric_limits<ScalarType>::max();
FaceType *fa=NULL; FaceType *fa=NULL;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
FaceType *f=&*fi; FaceType *f=&*fi;
ScalarType score; ScalarType score;
score = BQ::Diag(f).Norm(); score = BQ::Diag(f).Norm();
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
} }
score = BQ::CounterDiag(f).Norm(); score = BQ::CounterDiag(f).Norm();
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
} }
} }
if (fa) { if (fa) {
fa->Q()=0.0; fa->Q()=0.0;
@ -190,30 +190,30 @@ static void MarkSmallestDiag(MeshType &m)
static bool IdentifyAndCollapseSmallestDiag(MeshType &m){ static bool IdentifyAndCollapseSmallestDiag(MeshType &m){
ScalarType min = std::numeric_limits<ScalarType>::max(); ScalarType min = std::numeric_limits<ScalarType>::max();
FaceType *fa=NULL; bool flip; FaceType *fa=NULL; bool flip;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
FaceType *f=&*fi; FaceType *f=&*fi;
ScalarType score; ScalarType score;
score = BQ::Diag(f).Norm(); score = BQ::Diag(f).Norm();
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
flip = false; flip = false;
} }
score = BQ::CounterDiag(f).Norm(); score = BQ::CounterDiag(f).Norm();
if (score<min) { if (score<min) {
min=score; min=score;
fa = f; fa = f;
flip = true; flip = true;
} }
} }
if (!fa) return false; if (!fa) return false;
if (BQ::TestAndRemoveDoublet(*fa,0,m)) { return true; } if (BQ::TestAndRemoveDoublet(*fa,0,m)) { return true; }
if (BQ::TestAndRemoveDoublet(*fa,1,m)) { return true; } if (BQ::TestAndRemoveDoublet(*fa,1,m)) { return true; }
if (BQ::TestAndRemoveDoublet(*fa,2,m)) { return true; } if (BQ::TestAndRemoveDoublet(*fa,2,m)) { return true; }
@ -225,7 +225,7 @@ static bool IdentifyAndCollapseSmallestDiag(MeshType &m){
// I can't collapse (why?) // I can't collapse (why?)
MarkFace(fa,m); MarkFace(fa,m);
return false; return false;
} else } else
BQ::CollapseCounterDiag(*fa, BQ::PosOnDiag(*fa,true), m ); BQ::CollapseCounterDiag(*fa, BQ::PosOnDiag(*fa,true), m );
} }
else { else {
@ -271,7 +271,7 @@ static int MarkVertexRotations(MeshType &m, Pos *affected=NULL)
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) fi->Q()=1.0; for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) fi->Q()=1.0;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
for (int k=0; k<3; k++) { for (int k=0; k<3; k++) {
if (fi->V(k)->IsV()) continue; if (fi->V(k)->IsV()) continue;
if (BQ::TestVertexRotation(*fi,k)) { if (BQ::TestVertexRotation(*fi,k)) {
@ -296,9 +296,9 @@ template <bool perform>
static int MarkEdgeRotations(MeshType &m, Pos *p=NULL) static int MarkEdgeRotations(MeshType &m, Pos *p=NULL)
{ {
int count = 0; int count = 0;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) fi->Q()=1; for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) fi->Q()=1;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
//if (count>0) break; //if (count>0) break;
for (int k=0; k<3; k++) { for (int k=0; k<3; k++) {
@ -387,9 +387,9 @@ static ScalarType MeasureQuality(MeshType &m)
int div = 0; int div = 0;
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) { for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
if (fi->IsAnyF()) { if (fi->IsAnyF()) {
ScalarType q = BQ::quadQuality( &*fi, BQ::FauxIndex(&*fi) ); ScalarType q = BQ::quadQuality( &*fi, BQ::FauxIndex(&*fi) );
if (MeshType::HasPerFaceQuality()) fi->Q() = q; if (MeshType::HasPerFaceQuality()) fi->Q() = q;
res += q; res += q;
div++; div++;