fix some gcc warnings

This commit is contained in:
alemuntoni 2020-02-27 16:31:39 +01:00
parent 5fa560e9e6
commit 3285c6b1e5
8 changed files with 130 additions and 108 deletions

View File

@ -218,16 +218,18 @@ public:
// get the adjacent face
const FaceType * fp = f.cFFp(edge);
// v0
// /|\
// / | \
// / | \
// / | \
// va\ | /vb
// \ | /
// \ | /
// \|/
// v1
/*
* v0
* /|\
* / | \
* / | \
* / | \
* va\ | /vb
* \ | /
* \ | /
* \|/
* v1
*/
ScalarT cotA = 0;
ScalarT cotB = 0;
@ -255,16 +257,17 @@ public:
template <typename ScalarT>
static ScalarT ComputeAngle(const VertexType * a, const VertexType * b, const VertexType * c)
{
// a
// /
// /
// /
// / ___ compute the angle in b
// b \
// \
// \
// \
// c
/* a
* /
* /
* /
* / ___ compute the angle in b
* b \
* \
* \
* \
* c
*/
assert(a != NULL && b != NULL && c != NULL);
Point3<ScalarT> A,B,C;
A.Import(a->P());

View File

@ -959,20 +959,22 @@ private:
return true;
}
//Choose the best way to collapse a cross based on the (external) cross vertices valence
//and resulting face quality
// +0 -1
// v1 v1 v1
// /| \ /|\ / \
// / | \ / | \ / \
// / | \ / | \ / \
// / *p| \ -1/ | \ -1 +0/ \+0
// v0-------- v2 ========> v0 | v2 OR v0-------v2
// \ | / \ | / \ /
// \ | / \ | / \ /
// \ | / \ | / \ /
// \ | / \|/ +0 \ / -1
// v3 v3 v3
/*
*Choose the best way to collapse a cross based on the (external) cross vertices valence
*and resulting face quality
* +0 -1
* v1 v1 v1
* /| \ /|\ / \
* / | \ / | \ / \
* / | \ / | \ / \
* / *p| \ -1/ | \ -1 +0/ \+0
* v0-------- v2 ========> v0 | v2 OR v0-------v2
* \ | / \ | / \ /
* \ | / \ | / \ /
* \ | / \ | / \ /
* \ | / \|/ +0 \ / -1
* v3 v3 v3
*/
static bool chooseBestCrossCollapse(PosType &p, VertexPair& bp, vector<FaceType*> &ff)
{
vector<VertexType*> vv0, vv1, vv2, vv3;

View File

@ -47,7 +47,7 @@ public:
//Empty vertexref
inline typename T::VertexType * & V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const & V( const int ) const { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * const cV( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::VertexType * cV( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; }
inline typename T::CoordType & P( const int ) { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType & P( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
@ -177,8 +177,8 @@ public:
typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType;
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline typename T::VertexType * const cV( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline typename T::VertexType * & V( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline typename T::VertexType * cV( const int j ) { assert(j>=0 && j<4); return v[j]; }
inline size_t cFtoVi (const int f, const int j) const { assert(f >= 0 && f < 4); assert(j >= 0 && j < 3); return findices[f][j]; }

View File

@ -232,23 +232,30 @@ namespace vcg{
{
int ix,iy,iz;
for (ix=ibbox.min[0]; ix<=ibbox.max[0]; ix++)
{
for (iy=ibbox.min[1]; iy<=ibbox.max[1]; iy++)
{
for (iz=ibbox.min[2]; iz<=ibbox.max[2]; iz++)
{
_Si.Grid( ix, iy, iz, first, last );
for(l=first;l!=last;++l)
{
if (!(**l).IsD())
{
typename SPATIALINDEXING::ObjPtr elem=&(**l);
vcg::Box3<typename SPATIALINDEXING::ScalarType> box_elem;
elem->GetBBox(box_elem);
if(( ! _marker.IsMarked(elem))&&(box_elem.Collide(_bbox))){
if(( ! _marker.IsMarked(elem))&&(box_elem.Collide(_bbox)))
{
_objectPtrs.push_back(elem);
_marker.Mark(elem);
}
}
}
}
return (static_cast<unsigned int>(_objectPtrs.size()));
}
}
return (static_cast<unsigned int>(_objectPtrs.size()));
}
}

View File

@ -401,7 +401,9 @@ namespace vcg{
{
int ix,iy,iz;
for( iz = to_explore.min.Z();iz <= to_explore.max.Z(); ++iz)
{
for(iy =to_explore.min.Y(); iy <=to_explore.max.Y(); ++iy)
{
for(ix =to_explore.min.X(); ix <= to_explore.max.X();++ix)
{
// this test is to avoid to re-process already analyzed cells.
@ -427,12 +429,13 @@ namespace vcg{
}
}
}
}
}
}
////sort the elements in Elems and take a iterator to the last one
std::sort(Elems.begin(),Elems.end());
CurrentElem=Elems.rbegin();
////sort the elements in Elems and take a iterator to the last one
std::sort(Elems.begin(),Elems.end());
CurrentElem=Elems.rbegin();
return((Elems.size()==0)||(Dist()>radius));
}

View File

@ -84,66 +84,66 @@ static const char *ErrorMsg(int error)
*/
static int Open( MESH_TYPE &m, const char * filename, CallBackPos *cb=0, bool triangulate=false, int lineskip=0)
{
FILE *fp;
fp = fopen(filename, "r");
if(fp == NULL)
{
qDebug("Failed opening of %s",filename);
return E_CANTOPEN;
}
long currentPos = ftell(fp);
fseek(fp,0L,SEEK_END);
long fileLen = ftell(fp);
fseek(fp,currentPos,SEEK_SET);
FILE *fp;
fp = fopen(filename, "r");
if(fp == NULL)
{
qDebug("Failed opening of %s",filename);
return E_CANTOPEN;
}
long currentPos = ftell(fp);
fseek(fp,0L,SEEK_END);
long fileLen = ftell(fp);
fseek(fp,currentPos,SEEK_SET);
m.Clear();
Point3f pp;
float q;
size_t cnt=0;
int ret;
char buf[1024];
m.Clear();
// skip the first <lineskip> lines
for(int i=0;i<lineskip;++i)
fgets(buf,1024,fp);
Point3f pp;
float q;
size_t cnt=0;
int ret;
char buf[1024];
/* Read a single triplet of coords from an ASCII file of coords*/
while(!feof(fp))
{
if(cb && (++cnt)%1000) cb( (ftell(fp)*100)/fileLen, "ASC Mesh Loading");
if(feof(fp)) break;
bool fgetOut=fgets(buf,1024,fp);
if( fgetOut == 0 ) continue;
ret=sscanf(buf, "%f, %f, %f, %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
if(ret==1) // lets try also non comma separated values
ret=sscanf(buf, "%f %f %f %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
// skip the first <lineskip> lines
for(int i=0;i<lineskip;++i)
fgets(buf,1024,fp);
/* Read a single triplet of coords from an ASCII file of coords*/
while(!feof(fp))
{
if(cb && (++cnt)%1000) cb( (ftell(fp)*100)/fileLen, "ASC Mesh Loading");
if(feof(fp)) break;
bool fgetOut=fgets(buf,1024,fp);
if( fgetOut == 0 ) continue;
ret=sscanf(buf, "%f, %f, %f, %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
if(ret==1) // lets try also non comma separated values
ret=sscanf(buf, "%f %f %f %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
if(ret>=3)
{
VertexIterator vi=Allocator<MESH_TYPE>::AddVertices(m,1);
(*vi).P().Import(pp);
if(ret==4) (*vi).Q()=q;
}
}
fclose(fp);
if(m.vn==0) return E_NO_POINTS;
if(!triangulate) return E_NOERROR;
// now try to triangulate.
// search for the first jump
float baseY = m.vert[0].P().Y();
int i;
for(i=1;i<m.vert.size();++i)
{
if(m.vert[i].P().Y()!= baseY) break;
}
cnt=m.vert.size();
qDebug("Grid is %i x %i = %i (%i) ",i,cnt/i,i* (cnt/i),cnt);
tri::FaceGrid(m,i,int(cnt/i));
tri::Clean<MESH_TYPE>::FlipMesh(m);
return E_NOERROR;
}
if(ret>=3)
{
VertexIterator vi=Allocator<MESH_TYPE>::AddVertices(m,1);
(*vi).P().Import(pp);
if(ret==4) (*vi).Q()=q;
}
}
fclose(fp);
if(m.vn==0) return E_NO_POINTS;
if(!triangulate) return E_NOERROR;
// now try to triangulate.
// search for the first jump
float baseY = m.vert[0].P().Y();
unsigned int i;
for(i=1;i<m.vert.size();++i)
{
if(m.vert[i].P().Y()!= baseY) break;
}
cnt=m.vert.size();
qDebug("Grid is %i x %i = %i (%zu) ",i,cnt/i,i* (cnt/i),cnt);
tri::FaceGrid(m,i,int(cnt/i));
tri::Clean<MESH_TYPE>::FlipMesh(m);
return E_NOERROR;
}
}; // end class
} // end Namespace tri

View File

@ -166,8 +166,9 @@ public:
char buf[1024];
if (tex) {
tex->getRelativeFileName().toString(buf); buf[1023] = 0;
if (std::string(buf) == "")
tex->getFileName().toString(buf); buf[1023] = 0;
if (std::string(buf) == "") {
tex->getFileName().toString(buf); buf[1023] = 0;
}
printf("Texture %s\n", buf);
m.textures.push_back(buf);
}

View File

@ -67,10 +67,12 @@ typedef typename OpenMeshType::EdgeIterator EdgeIterator;
static void readline(FILE *fp, char *line, int max=1000){
int i=0;
char c;
fscanf(fp, "%c", &c);
unsigned int rc = 0;
rc = fscanf(fp, "%c", &c);
while( (c!=10) && (c!=13) && (i<max-1) ){
line[i++] = c;
fscanf(fp, "%c", &c);
if (rc == 1)
line[i++] = c;
rc = fscanf(fp, "%c", &c);
}
line[i] = '\0'; //end of string
}
@ -163,14 +165,18 @@ static int Open( OpenMeshType &m, std::vector<Shot<ScalarType> > & shots,
for(uint i = 0; i < num_points;++i,++vi){
float x,y,z;
unsigned int r,g,b,i_cam, key_sift,n_corr;
fscanf(fp,"%f %f %f ",&x,&y,&z);
uint readValues = fscanf(fp,"%f %f %f ",&x,&y,&z);
if (readValues < 3) qDebug() << "Point " << i << ": only " << readValues << " coordinates read!";
(*vi).P() = vcg::Point3<typename OpenMeshType::ScalarType>(x,y,z);
fscanf(fp,"%d %d %d ",&r,&g,&b);
readValues = fscanf(fp,"%d %d %d ",&r,&g,&b);
if (readValues < 3) qDebug() << "Point " << i << ": only " << readValues << " color values read!";
(*vi).C() = vcg::Color4b(r,g,b,255);
fscanf(fp,"%d ",&n_corr);
readValues = fscanf(fp,"%d ",&n_corr);
if (readValues < 1) qDebug() << "Point " << i << ": no n correspondences read!";
for(uint j = 0; j < n_corr; ++j){
fscanf(fp,"%d %d %f %f ",&i_cam,&key_sift,&x,&y);
readValues = fscanf(fp,"%d %d %f %f ",&i_cam,&key_sift,&x,&y);
if (readValues != 3) qDebug() << "Point " << i << "; Corresp: " << j << ": only " << readValues << " values read!";
Correspondence corr(i_cam,key_sift,x,y);
ch[i].push_back(corr);
}