From 499822bc17b3699031fac95e7274ec39604c37f9 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 25 Mar 2009 08:13:07 +0000 Subject: [PATCH] NO_QT defines to explicitly disable qt dependant behavior --- vcg/complex/trimesh/create/resampler.h | 144 +++++++++++++------------ 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/vcg/complex/trimesh/create/resampler.h b/vcg/complex/trimesh/create/resampler.h index f3c1b9d8..9f6a1310 100644 --- a/vcg/complex/trimesh/create/resampler.h +++ b/vcg/complex/trimesh/create/resampler.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -69,13 +69,13 @@ template MarkerFace; MarkerFace markerFunctor; - - + + VertexIndex *_x_cs; // indici dell'intersezioni della superficie lungo gli Xedge della fetta corrente VertexIndex *_y_cs; // indici dell'intersezioni della superficie lungo gli Yedge della fetta corrente VertexIndex *_z_cs; // indici dell'intersezioni della superficie lungo gli Zedge della fetta corrente - VertexIndex *_x_ns; // indici dell'intersezioni della superficie lungo gli Xedge della prossima fetta - VertexIndex *_z_ns; // indici dell'intersezioni della superficie lungo gli Zedge della prossima fetta + VertexIndex *_x_ns; // indici dell'intersezioni della superficie lungo gli Xedge della prossima fetta + VertexIndex *_z_ns; // indici dell'intersezioni della superficie lungo gli Zedge della prossima fetta //float *_v_cs;///values of distance fields for each direction in current slice //float *_v_ns;///values of distance fields for each direction in next slice @@ -87,19 +87,19 @@ template bbox= _bbox; this->siz=_siz; ComputeDimAndVoxel(); - + SliceSize = (this->siz.X()+1)*(this->siz.Z()+1); CurrentSlice = 0; offset=0; @@ -115,33 +115,33 @@ template siz.X()+1)*(this->siz.Z()+1)]; _v_ns= new field_value[(this->siz.X()+1)*(this->siz.Z()+1)]; - + }; ~Walker() {} - + float V(const Point3i &p) { return V(p.V(0),p.V(1),p.V(2)); } - + std::pair VV(int x,int y,int z) { assert ((y==CurrentSlice)||(y==(CurrentSlice+1))); - + //test if it is outside the bb of the mesh //vcg::Point3f test=vcg::Point3f((float)x,(float)y,(float)z); /*if (!_oldM->bbox.IsIn(test)) return (1.f);*/ int index=GetSliceIndex(x,z); - + if (y==CurrentSlice) return _v_cs[index]; - else return _v_ns[index]; + else return _v_ns[index]; } - + float V(int x,int y,int z) { if(DiscretizeFlag) return VV(x,y,z).second+offset<0?-1:1; @@ -161,22 +161,22 @@ template IsD()); bool retIP; - - // To compute the interpolated normal we use the more robust function that require to know what is the most orhogonal direction of the face. + + // To compute the interpolated normal we use the more robust function that require to know what is the most orhogonal direction of the face. if((*f).Flags() & Old_Mesh::FaceType::NORMX) retIP=InterpolationParameters(*f,0,closestPt, pip); else if((*f).Flags() & Old_Mesh::FaceType::NORMY) retIP=InterpolationParameters(*f,1,closestPt, pip); else if((*f).Flags() & Old_Mesh::FaceType::NORMZ) retIP=InterpolationParameters(*f,2,closestPt, pip); else assert(0); assert(retIP); // this should happen only if the starting mesh has degenerate faces. - + closestNormV = (f->V(0)->cN())*pip[0] + (f->V(1)->cN())*pip[1] + (f->V(2)->cN())*pip[2] ; closestNormF = f->cN() ; @@ -186,15 +186,15 @@ template fabs(signF)) signBest = signV; else signBest = signF; - + if(signBest<0) dist=-dist; - + return field_value(true,dist); } @@ -205,21 +205,21 @@ template 0) positiveCnt ++; } - if(positiveCnt<=MultiSample/2) distSum = -distSum; + if(positiveCnt<=MultiSample/2) distSum = -distSum; return field_value(true, distSum/MultiSample); } @@ -239,9 +239,9 @@ template siz.X() ) index_r=GetSliceIndex(i+1,k); else index_r = index; if(k > 0 ) index_d=GetSliceIndex(i,k-1); else index_d = index; if(k < this->siz.Z() ) index_u=GetSliceIndex(i,k+1); else index_u = index; - + if(slice_values[index_l].first) { goodCnt++; if(fabs(slice_values[index_l].second - curVal) > max_dist) badCnt++; } if(slice_values[index_r].first) { goodCnt++; if(fabs(slice_values[index_r].second - curVal) > max_dist) badCnt++; } if(slice_values[index_u].first) { goodCnt++; if(fabs(slice_values[index_u].second - curVal) > max_dist) badCnt++; } if(slice_values[index_d].first) { goodCnt++; if(fabs(slice_values[index_d].second - curVal) > max_dist) badCnt++; } - + if(badCnt >= goodCnt) { slice_values[index].second *=-1.0f; //slice_values[index].first = false; flippedCnt++; - } + } } } } flippedTot+=flippedCnt; flippedTimes++; } while(flippedCnt>0); - - if(flippedTot>0) - qDebug("Flipped %i values in %i times",flippedTot,flippedTimes); - } + + +#ifndef NO_QT + if(flippedTot>0) + qDebug("Flipped %i values in %i times",flippedTot,flippedTimes); +#endif + } template void ProcessSlice(EXTRACTOR_TYPE &extractor) { @@ -303,7 +306,7 @@ template ::PerVertexNormalizedPerFaceNormalized(old_mesh); tri::UpdateFlags::FaceProjection(old_mesh); int _size=(int)old_mesh.fn*100; - + _g.Set(_oldM->face.begin(),_oldM->face.end(),_size); markerFunctor.SetMesh(&old_mesh); @@ -335,7 +338,7 @@ template siz.Y(),"Marching "); t0 = clock(); - ProcessSlice(extractor);//find cells where there is the isosurface and examine it + ProcessSlice(extractor);//find cells where there is the isosurface and examine it t1 = clock(); NextSlice(); t2 = clock(); @@ -343,31 +346,32 @@ template siz.X()+1); return (index); } - + //swap slices , the initial value of distance fields ids set as double of bbox of space - void NextSlice() + void NextSlice() { - + memset(_x_cs, -1, SliceSize*sizeof(VertexIndex)); memset(_y_cs, -1, SliceSize*sizeof(VertexIndex)); memset(_z_cs, -1, SliceSize*sizeof(VertexIndex)); - + std::swap(_x_cs, _x_ns); std::swap(_z_cs, _z_ns); @@ -375,10 +379,10 @@ template siz.X(); @@ -479,9 +483,9 @@ template siz.X(); @@ -527,14 +531,14 @@ template vert[pos]; } - + ///if there is a vertex in y axis of a cell return the vertex or create it - void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointer &v) + void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointer &v) { assert(p1.X() == p2.X()); assert(p1.Y()+1 == p2.Y()); assert(p1.Z() == p2.Z()); - + int i = p1.X(); // (p1.X() - _bbox.min.X())/_cell_size.X(); int z = p1.Z(); // (p1.Z() - _bbox.min.Z())/_cell_size.Z(); VertexIndex index = i+z*this->siz.X(); @@ -549,14 +553,14 @@ template vert[pos]; } - + ///if there is a vertex in z axis of a cell return the vertex or create it - void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointer &v) + void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointer &v) { assert(p1.X() == p2.X()); assert(p1.Y() == p2.Y()); assert(p1.Z()+1 == p2.Z()); - + int i = p1.X(); //(p1.X() - _bbox.min.X())/_cell_size.X(); int z = p1.Z(); //(p1.Z() - _bbox.min.Z())/_cell_size.Z(); VertexIndex index = i+z*this->siz.X(); @@ -602,18 +606,18 @@ static void Resample(Old_Mesh &old_mesh,New_Mesh &new_mesh, Box3f volumeBox, vc { ///be sure that the bounding box is updated vcg::tri::UpdateBounding::Box(old_mesh); - + MyWalker walker(volumeBox,accuracy); walker.max_dim=max_dist+fabs(thr); - walker.offset = - thr; + walker.offset = - thr; walker.DiscretizeFlag = DiscretizeFlag; walker.MultiSampleFlag = MultiSampleFlag; walker.AbsDistFlag = AbsDistFlag; MyMarchingCubes mc(new_mesh, walker); walker.BuildMesh(old_mesh,new_mesh,mc,cb); } - + };//end class resampler