Reasonable but harmless clang warning cleanup

This commit is contained in:
Paolo Cignoni 2014-07-01 10:07:36 +00:00
parent aa63261fae
commit 073e07a309
1 changed files with 41 additions and 73 deletions

View File

@ -25,7 +25,6 @@
#ifndef __VCGLIB__SMOOTH #ifndef __VCGLIB__SMOOTH
#define __VCGLIB__SMOOTH #define __VCGLIB__SMOOTH
#include <cmath>
#include <vcg/space/ray3.h> #include <vcg/space/ray3.h>
#include <vcg/complex/algorithms/update/normal.h> #include <vcg/complex/algorithms/update/normal.h>
#include <vcg/complex/algorithms/update/halfedge_topology.h> #include <vcg/complex/algorithms/update/halfedge_topology.h>
@ -985,7 +984,7 @@ static void FaceNormalLaplacianFF(MeshType &m, int step=1, bool SmoothSelected=f
// VF Topology // VF Topology
// Normalized Face Normals // Normalized Face Normals
// //
// This is the Normal Smoothing approach bsased on a angle thresholded weighting // This is the Normal Smoothing approach based on a angle thresholded weighting
// sigma is in the 0 .. 1 range, it represent the cosine of a threshold angle. // sigma is in the 0 .. 1 range, it represent the cosine of a threshold angle.
// sigma == 0 All the normals are averaged // sigma == 0 All the normals are averaged
// sigma == 1 Nothing is averaged. // sigma == 1 Nothing is averaged.
@ -993,57 +992,51 @@ static void FaceNormalLaplacianFF(MeshType &m, int step=1, bool SmoothSelected=f
static void FaceNormalAngleThreshold(MeshType &m, static void FaceNormalAngleThreshold(MeshType &m,
SimpleTempData<typename MeshType::FaceContainer,PDFaceInfo> &TD, SimpleTempData<typename MeshType::FaceContainer,PDFaceInfo> &TD,
ScalarType sigma) ScalarType sigma)
{ {
int i; for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
{
FaceIterator fi;
for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD())
{
CoordType bc=Barycenter<FaceType>(*fi);
// 1) Clear all the visited flag of faces that are vertex-adjacent to fi // 1) Clear all the visited flag of faces that are vertex-adjacent to fi
for(i=0;i<3;++i) for(int i=0;i<3;++i)
{ {
VFLocalIterator ep(&*fi,i); VFLocalIterator ep(&*fi,i);
for (;!ep.End();++ep) for (;!ep.End();++ep)
ep.f->ClearV(); ep.f->ClearV();
} }
// 1) Effectively average the normals weighting them with the squared difference of the angle similarity // 1) Effectively average the normals weighting them with the squared difference of the angle similarity
// sigma is the cosine of a threshold angle. sigma \in 0..1 // sigma is the cosine of a threshold angle. sigma \in 0..1
// sigma == 0 All the normals are averaged // sigma == 0 All the normals are averaged
// sigma == 1 Nothing is averaged. // sigma == 1 Nothing is averaged.
// The averaging is weighted with the difference between normals. more similar the normal more important they are. // The averaging is weighted with the difference between normals. more similar the normal more important they are.
CoordType normalSum=CoordType(0,0,0); CoordType normalSum=CoordType(0,0,0);
for(i=0;i<3;++i) for(int i=0;i<3;++i)
{
VFLocalIterator ep(&*fi,i);
for (;!ep.End();++ep)
{
if(! (*ep.f).IsV() )
{ {
VFLocalIterator ep(&*fi,i);
for (;!ep.End();++ep)
{
if(! (*ep.f).IsV() )
{
ScalarType cosang=ep.f->N().dot((*fi).N()); ScalarType cosang=ep.f->N().dot((*fi).N());
// Note that if two faces form an angle larger than 90 deg, their contribution should be very very small. // Note that if two faces form an angle larger than 90 deg, their contribution should be very very small.
// Without this clamping // Without this clamping
cosang = math::Clamp(cosang,ScalarType(0.0001),ScalarType(1.f)); cosang = math::Clamp(cosang,ScalarType(0.0001),ScalarType(1.f));
if(cosang >= sigma) if(cosang >= sigma)
{ {
ScalarType w = cosang-sigma; ScalarType w = cosang-sigma;
normalSum += ep.f->N()*(w*w); // similar normals have a cosang very close to 1 so cosang - sigma is maximized normalSum += ep.f->N()*(w*w); // similar normals have a cosang very close to 1 so cosang - sigma is maximized
} }
(*ep.f).SetV(); (*ep.f).SetV();
}
}
} }
normalSum.Normalize(); }
TD[*fi].m=normalSum;
} }
normalSum.Normalize();
TD[*fi].m=normalSum;
}
for(fi=m.face.begin();fi!=m.face.end();++fi) for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
(*fi).N()=TD[*fi].m; (*fi).N()=TD[*fi].m;
} }
@ -1111,7 +1104,6 @@ static void FitMesh(MeshType &m,
SimpleTempData<typename MeshType::FaceContainer, PDFaceInfo> &TDF, SimpleTempData<typename MeshType::FaceContainer, PDFaceInfo> &TDF,
float lambda) float lambda)
{ {
//vcg::face::Pos<FaceType> ep;
vcg::face::VFIterator<FaceType> ep; vcg::face::VFIterator<FaceType> ep;
VertexIterator vi; VertexIterator vi;
for(vi=m.vert.begin();vi!=m.vert.end();++vi) for(vi=m.vert.begin();vi!=m.vert.end();++vi)
@ -1173,46 +1165,22 @@ static void FastFitMesh(MeshType &m,
static void VertexCoordPasoDoble(MeshType &m, int step, typename MeshType::ScalarType Sigma=0, int FitStep=10, typename MeshType::ScalarType FitLambda=0.05)
{
SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert);
SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo> TDF(m.face);
PDVertInfo lpzv;
lpzv.np=CoordType(0,0,0);
PDFaceInfo lpzf(CoordType(0,0,0));
assert(m.HasVFTopology());
m.HasVFTopology();
TDV.Start(lpzv);
TDF.Start(lpzf);
for(int j=0;j<step;++j)
{
vcg::tri::UpdateNormal<MeshType>::PerFace(m);
FaceNormalAngleThreshold(m,TDF,Sigma);
for(int k=0;k<FitStep;k++)
FitMesh(m,TDV,TDF,FitLambda);
}
TDF.Stop();
TDV.Stop();
}
// The sigma parameter affect the normal smoothing step // The sigma parameter affect the normal smoothing step
static void VertexCoordPasoDobleFast(MeshType &m, int NormalSmoothStep, typename MeshType::ScalarType Sigma=0, int FitStep=50, bool SmoothSelected =false) static void VertexCoordPasoDoble(MeshType &m, int NormalSmoothStep, typename MeshType::ScalarType Sigma=0, int FitStep=50, bool SmoothSelected =false)
{ {
PDVertInfo lpzv; tri::RequireCompactness(m);
lpzv.np=CoordType(0,0,0); tri::RequireVFAdjacency(m);
PDFaceInfo lpzf(CoordType(0,0,0)); PDVertInfo lpzv;
lpzv.np=CoordType(0,0,0);
PDFaceInfo lpzf(CoordType(0,0,0));
assert(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m)); assert(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m));
SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert,lpzv); SimpleTempData< typename MeshType::VertContainer, PDVertInfo> TDV(m.vert,lpzv);
SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo> TDF(m.face,lpzf); SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo> TDF(m.face,lpzf);
for(int j=0;j<NormalSmoothStep;++j) for(int j=0;j<NormalSmoothStep;++j)
FaceNormalAngleThreshold(m,TDF,Sigma); FaceNormalAngleThreshold(m,TDF,Sigma);
for(int j=0;j<FitStep;++j) for(int j=0;j<FitStep;++j)
FastFitMesh(m,TDV,SmoothSelected); FastFitMesh(m,TDV,SmoothSelected);