Updated many vcg files to do not use anymore the vcg::Max(a,b) and vcg::Min(a,b). Use the std version instead.

This commit is contained in:
Paolo Cignoni 2010-09-21 22:09:13 +00:00
parent 47138fce2f
commit 349e9869cf
13 changed files with 39 additions and 43 deletions

View File

@ -170,8 +170,8 @@ public:
bool IsUpToDate()
{
int lastMark = _pos.F()->V(0)->IMark();
lastMark = vcg::math::Max<int>(lastMark, _pos.F()->V(1)->IMark());
lastMark = vcg::math::Max<int>(lastMark, _pos.F()->V(2)->IMark());
lastMark = std::max<int>(lastMark, _pos.F()->V(1)->IMark());
lastMark = std::max<int>(lastMark, _pos.F()->V(2)->IMark());
return ( _localMark >= lastMark );
}
@ -606,4 +606,4 @@ public:
} // end of namespace tri
} // end of namespace vcg
#endif
#endif

View File

@ -291,7 +291,7 @@ namespace vcg
for (i=0; i<vertices_num; i++)
{
points[i] = _mesh->vert[ vertices_idx[i] ].P();
normals[i] = _mesh->vert[ vertices_idx[i] ].N();
normals[i].Import(_mesh->vert[ vertices_idx[i] ].N());
}
// move barycenter of points into (0, 0, 0)
@ -329,7 +329,7 @@ namespace vcg
if (c < minC) minC = c;
if (c > maxC) maxC = c;
}
c = vcg::math::Max< double >(fabs(minC), fabs(maxC));
c = std::max< double >(fabs(minC), fabs(maxC));
c = sqrt(1.0-c*c);
rank = (c > cos(_featureAngle) ? 2 : 3);
@ -354,7 +354,7 @@ namespace vcg
{
double smin = DBL_MAX; // the max value, as defined in <float.h>
unsigned int sminid = 0;
unsigned int srank = vcg::math::Min< unsigned int >(vertices_num, 3u);
unsigned int srank = std::min< unsigned int >(vertices_num, 3u);
for (i=0; i<srank; ++i)
{

View File

@ -143,13 +143,13 @@ class Geo{
s = (d_curr + d_pw1+ec_w1)/2;
a = s/ec_w1;
b = a*s;
alpha_ = 2*acos ( math::Min<ScalarType>(1.0,sqrt( (b- a* d_pw1)/d_curr)));
alpha_ = 2*acos ( std::min<ScalarType>(1.0,sqrt( (b- a* d_pw1)/d_curr)));
if ( alpha+alpha_ > M_PI){
curr_d = d_curr + ew_c;
}else
{
beta_ = 2*acos ( math::Min<ScalarType>(1.0,sqrt( (b- a* d_curr)/d_pw1)));
beta_ = 2*acos ( std::min<ScalarType>(1.0,sqrt( (b- a* d_curr)/d_pw1)));
beta = acos((w_w1).dot(-w1_c)/(ew_w1*ec_w1));
if ( beta+beta_ > M_PI)

View File

@ -1169,9 +1169,9 @@ static void PoissonDiskPruning(MetroMesh &origMesh, VertexSampler &ps, MetroMesh
// inflating
origMesh.bbox.Offset(cellsize);
int sizeX = vcg::math::Max(1.0f,origMesh.bbox.DimX() / cellsize);
int sizeY = vcg::math::Max(1.0f,origMesh.bbox.DimY() / cellsize);
int sizeZ = vcg::math::Max(1.0f,origMesh.bbox.DimZ() / cellsize);
int sizeX = std::max(1.0f,origMesh.bbox.DimX() / cellsize);
int sizeY = std::max(1.0f,origMesh.bbox.DimY() / cellsize);
int sizeZ = std::max(1.0f,origMesh.bbox.DimZ() / cellsize);
Point3i gridsize(sizeX, sizeY, sizeZ);
#ifdef QT_VERSION
qDebug("PDS: radius %f Grid:(%i %i %i) ",diskRadius,sizeX,sizeY,sizeZ);
@ -1256,9 +1256,9 @@ static void PoissonDisk(MetroMesh &origMesh, VertexSampler &ps, MetroMesh &monte
// inflating
origMesh.bbox.Offset(cellsize);
int sizeX = vcg::math::Max(1.0f,origMesh.bbox.DimX() / cellsize);
int sizeY = vcg::math::Max(1.0f,origMesh.bbox.DimY() / cellsize);
int sizeZ = vcg::math::Max(1.0f,origMesh.bbox.DimZ() / cellsize);
int sizeX = std::max(1.0f,origMesh.bbox.DimX() / cellsize);
int sizeY = std::max(1.0f,origMesh.bbox.DimY() / cellsize);
int sizeZ = std::max(1.0f,origMesh.bbox.DimZ() / cellsize);
Point3i gridsize(sizeX, sizeY, sizeZ);
#ifdef QT_VERSION
qDebug("PDS: radius %f Grid:(%i %i %i) ",diskRadius,sizeX,sizeY,sizeZ);

View File

@ -435,10 +435,8 @@ static int Thresholding(UpdateMeshType &m, float threshold, Color4b c1 = Color4<
//Computes the lightness value for a specified color. lightness = 0.5*(Max(R,G,B)+Min(R,G,B))
static float ComputeLightness(Color4b c)
{
float min_rgb = math::Min((float)c[0],(float)c[1]);
min_rgb = math::Min(min_rgb,(float)c[2]);
float max_rgb = math::Max((float)c[0],(float)c[1]);
max_rgb = math::Max(max_rgb,(float)c[2]);
float min_rgb = (float)math::Min(c[0],c[1],c[2]);
float max_rgb = (float)math::Max(c[0],c[1],c[2]);
return (max_rgb + min_rgb)/2;
}
@ -749,8 +747,8 @@ static int Equalize(UpdateMeshType &m, unsigned int rgbMask, const bool ProcessS
{
if(!ProcessSelected || (*vi).IsS()) //if this vertex has been selected, put it in the histograms
{
int v = (int)(ComputeLightness((*vi).C())+0.5); //compute and round lightness value
Hl.Add(v); Hr.Add((*vi).C()[0]); Hg.Add((*vi).C()[1]); Hb.Add((*vi).C()[2]);
float v = ComputeLightness((*vi).C())+0.5; //compute and round lightness value
Hl.Add(v); Hr.Add((float)(*vi).C()[0]); Hg.Add((float)(*vi).C()[1]); Hb.Add((float)(*vi).C()[2]);
}
}
}

View File

@ -634,7 +634,7 @@ public:
Point3<ScalarType> n1 = p.F()->cN();n1.Normalize();
Point3<ScalarType> n2 = p.FFlip()->cN();n2.Normalize();
ScalarType n1n2 = (n1 ^ n2).dot(normalized_edge);
n1n2 = math::Max<ScalarType >(math::Min<ScalarType> ( 1.0,n1n2),-1.0);
n1n2 = std::max(std::min( ScalarType(1.0),n1n2),ScalarType(-1.0));
ScalarType beta = math::Asin(n1n2);
m33[0][0] += beta*edge_length*normalized_edge[0]*normalized_edge[0];
m33[0][1] += beta*edge_length*normalized_edge[1]*normalized_edge[0];

View File

@ -336,7 +336,7 @@ namespace vcg
A[i][k] *= scale;
}
}
anorm=math::Max( anorm, (math::Abs(W[i])+math::Abs(rv1[i])) );
anorm=std::max( anorm, (math::Abs(W[i])+math::Abs(rv1[i])) );
}
// Accumulation of right-hand transformations.
for (i=(n-1); i>=0; i--)
@ -364,7 +364,7 @@ namespace vcg
l = i;
}
// Accumulation of left-hand transformations.
for (i=math::Min(m,n)-1; i>=0; i--)
for (i=std::min(m,n)-1; i>=0; i--)
{
l = i+1;
g = W[i];

View File

@ -184,7 +184,7 @@ namespace vcg {
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,vcg::math::Min<ScalarType>(b1,b2))) < EPS*DoubleArea(f))
if( (b=math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
@ -220,7 +220,7 @@ namespace vcg {
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,vcg::math::Min<ScalarType>(b1,b2))) < EPS*DoubleArea(f))
if( (b=math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
@ -406,7 +406,7 @@ namespace vcg {
// vicini (come prodotto vettore)
// Nota: si potrebbe rendere un pochino piu' veloce sostituendo Area()
// con il prodotto vettore dei due edge in 2d lungo il piano migliore.
if( (b=vcg::math::Min<ScalarType>(b0,vcg::math::Min<ScalarType>(b1,b2))) < EPS*DoubleArea(f))
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
@ -443,7 +443,7 @@ namespace vcg {
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,vcg::math::Min<ScalarType>(b1,b2))) < EPS*DoubleArea(f))
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);
@ -480,7 +480,7 @@ namespace vcg {
if(dist>b2) { dist = b2; return true; }
else return false;
}
if( (b=vcg::math::Min<ScalarType>(b0,vcg::math::Min<ScalarType>(b1,b2))) < EPS*DoubleArea(f))
if( (b=vcg::math::Min<ScalarType>(b0,b1,b2)) < EPS*DoubleArea(f))
{
ScalarType bt;
if(b==b0) bt = PSDist(q,f.V(1)->cP(),f.V(2)->cP(),p);

View File

@ -287,9 +287,9 @@ void BestDim( const Box3<scalar_type> box, const scalar_type voxel_size, Point3i
else if(size[2]>eps)
dim[2] = int(ncell);
}
dim[0] = math::Max(dim[0],1);
dim[1] = math::Max(dim[1],1);
dim[2] = math::Max(dim[2],1);
dim[0] = std::max(dim[0],1);
dim[1] = std::max(dim[1],1);
dim[2] = std::max(dim[2],1);
}
}
#endif

View File

@ -249,7 +249,7 @@ public:
CoordType offset = bounding_box.Dim()*Octree::EXPANSION_FACTOR;
CoordType center = bounding_box.Center();
resulting_bb.Offset(offset);
ScalarType longest_side = vcg::math::Max( resulting_bb.DimX(), vcg::math::Max(resulting_bb.DimY(), resulting_bb.DimZ()) )/2.0f;
ScalarType longest_side = vcg::math::Max( resulting_bb.DimX(), resulting_bb.DimY(), resulting_bb.DimZ())/2.0f;
resulting_bb.Set(center);
resulting_bb.Offset(longest_side);
TemplatedOctree::boundingBox = resulting_bb;
@ -428,7 +428,7 @@ OBJECT_RETRIEVER:
NeighbourIterator first = neighbors.begin();
NeighbourIterator last = neighbors.end();
object_count = vcg::math::Min(k, object_count);
object_count = std::min(k, object_count);
if (sort_per_distance) std::partial_sort< NeighbourIterator >(first, first+object_count, last );
else std::nth_element < NeighbourIterator >(first, first+object_count, last );

View File

@ -224,7 +224,7 @@ namespace vcg {
int solution_count = 0;
if (ScalarType(0.0)<=lambda1 && lambda1<=ScalarType(1.0))
{
ScalarType t_enter = vcg::math::Max< ScalarType >(lambda1, ScalarType(0.0));
ScalarType t_enter = std::max< ScalarType >(lambda1, ScalarType(0.0));
t0 = segment.P0() + r*t_enter;
solution_count++;
}
@ -232,7 +232,7 @@ namespace vcg {
if (ScalarType(0.0)<=lambda2 && lambda2<=ScalarType(1.0))
{
Point3t *pt = (solution_count>0) ? &t1 : &t0;
ScalarType t_exit = vcg::math::Min< ScalarType >(lambda2, ScalarType(1.0));
ScalarType t_exit = std::min< ScalarType >(lambda2, ScalarType(1.0));
*pt = segment.P0() + r*t_exit;
solution_count++;
}
@ -325,8 +325,8 @@ namespace vcg {
if (res!=NULL)
{
ScalarType witness_norm = witness.Norm();
res->first = vcg::math::Max< ScalarType >( witness_norm-radius, ScalarType(0.0) );
res->second = vcg::math::Max< ScalarType >( radius-witness_norm, ScalarType(0.0) );
res->first = std::max< ScalarType >( witness_norm-radius, ScalarType(0.0) );
res->second = std::max< ScalarType >( radius-witness_norm, ScalarType(0.0) );
}
penetration_detected = (witness.SquaredNorm() <= (radius*radius));
witness += center;

View File

@ -316,7 +316,7 @@ namespace vcg
//std::advance((iSonVertex=begin), *iSon);//retrieve the pointer to the Vertex associated to son
border.push( *iSon );
}
maxSize = vcg::math::Max<int>(maxSize, queueSize);
maxSize = std::max<int>(maxSize, queueSize);
}
}
}
@ -341,7 +341,7 @@ namespace vcg
if (current_node->vertex->N().dot(current_node->sons[s]->vertex->N())<ScalarType(0.0f))
current_node->sons[s]->vertex->N() *= ScalarType(-1.0f);
border.push( current_node->sons[s] );
maxSize = vcg::math::Max<int>(maxSize, queueSize);
maxSize = std::max<int>(maxSize, queueSize);
}
}
}

View File

@ -188,10 +188,8 @@ float CoordinateFrame::calcSlope(const Point3d &a,const Point3d &b,float dim,int
float tickNum = spacing/Distance(p2,p1);// pxl spacing
float slope = dim*tickNum;
float nslope = math::Min(
math::Min(niceRound(slope), 0.5f*niceRound(2.0f*slope)),
0.2f*niceRound(5.0f*slope));
nslope = math::Max<float>(niceRound(dim*.001f),nslope); // prevent too small slope
float nslope = math::Min(niceRound(slope), 0.5f*niceRound(2.0f*slope), 0.2f*niceRound(5.0f*slope));
nslope = std::max(niceRound(dim*.001f),nslope); // prevent too small slope
return nslope;
}