bugfixes and PR template

This commit is contained in:
alemuntoni 2020-04-17 16:44:23 +02:00
parent e9ea05be02
commit f7871eed2d
13 changed files with 54 additions and 40 deletions

14
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,14 @@
## Thank you for sending a Pull Request to the VCGLib!
VCGLib is fully owned by CNR, and all the VCGLib contributors that do not work at the VCLab of CNR must first sign the contributor license agreement that you can find at the following link: https://github.com/cnr-isti-vclab/vcglib/blob/devel/docs/ContributorLicenseAgreement.pdf
If you will sign the CLA, then we will be able to merge your pull request after reviewing it.
Please send the signed document to muntoni.alessandro@gmail.com and paolo.cignoni@isti.cnr.it .
If you will not sign the CLA, we will review and then apply your changes as soon as possible.
Before opening the PR, please leave the follwing form with a check for your particluar case:
##### Check with `[x]` what is your case:
- [ ] I already signed and sent via email the CLA;
- [ ] I wil sign and send the CLA via email as soon as possible;
- [ ] I don't want to sign the CLA.

View File

@ -364,7 +364,8 @@ public:
protected: protected:
void AddFace(int v0, int v1, int v2) { void AddFace(int v0, int v1, int v2) {
FaceIterator fi = vcg::tri::Allocator<MESH>::AddFace(mesh,v0,v1,v2); FaceIterator fi = vcg::tri::Allocator<MESH>::AddFace(mesh,v0,v1,v2);
fi->N() = TriangleNormal(*fi).Normalize(); if (FaceType::HasNormal())
fi->N() = TriangleNormal(*fi).Normalize();
if(tri::HasVFAdjacency(mesh)) if(tri::HasVFAdjacency(mesh))
{ {
for(int j=0;j<3;++j) for(int j=0;j<3;++j)

View File

@ -100,7 +100,7 @@ struct RegularLoopWeight {
.69908 .69908
}; };
return (k<=12)?(1.0-bkPolar[k-3])/k:LoopWeight<SCALAR_TYPE>().beta(k); return (k<=12 && k>=3)?(1.0-bkPolar[k-3])/k:LoopWeight<SCALAR_TYPE>().beta(k);
} }
inline SCALAR_TYPE incidentRegular(int k) { inline SCALAR_TYPE incidentRegular(int k) {
@ -120,7 +120,7 @@ struct RegularLoopWeight {
.44579 .44579
}; };
return (k<=12)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().incidentIrregular(k); return (k<=12 && k>=3)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().incidentIrregular(k);
} }
inline SCALAR_TYPE opposite(int k) { inline SCALAR_TYPE opposite(int k) {
static SCALAR_TYPE bkPolar[] = { static SCALAR_TYPE bkPolar[] = {
@ -136,7 +136,7 @@ struct RegularLoopWeight {
.19828 .19828
}; };
return (k<=12)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().opposite(k); return (k<=12 && k >= 3)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().opposite(k);
} }
}; };
@ -156,7 +156,7 @@ struct ContinuityLoopWeight {
.70014 .70014
}; };
return (k<=12)?(1.0-bkPolar[k-3])/k:LoopWeight<SCALAR_TYPE>().beta(k); return (k<=12 && k>= 3)?(1.0-bkPolar[k-3])/k:LoopWeight<SCALAR_TYPE>().beta(k);
} }
inline SCALAR_TYPE incidentRegular(int k) { inline SCALAR_TYPE incidentRegular(int k) {
@ -176,7 +176,7 @@ struct ContinuityLoopWeight {
.2452 .2452
}; };
return (k<=12)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().incidentIrregular(k); return (k<=12 && k>=3)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().incidentIrregular(k);
} }
inline SCALAR_TYPE opposite(int k) { inline SCALAR_TYPE opposite(int k) {
static SCALAR_TYPE bkPolar[] = { static SCALAR_TYPE bkPolar[] = {
@ -192,7 +192,7 @@ struct ContinuityLoopWeight {
.29934 .29934
}; };
return (k<=12)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().opposite(k); return (k<=12 && k >= 3)?bkPolar[k-3]:LoopWeight<SCALAR_TYPE>().opposite(k);
} }
}; };

View File

@ -211,7 +211,7 @@ static void FillUniqueEdgeVector(MeshType &m, std::vector<PEdge> &edgeVec, bool
edgeVec[ i ].isBorder = true; edgeVec[ i ].isBorder = true;
for (size_t i=1; i<edgeVec.size(); i++) { for (size_t i=1; i<edgeVec.size(); i++) {
if (edgeVec[i]==edgeVec[i-1]) if (edgeVec[i]==edgeVec[i-1])
edgeVec[i-1].isBorder = edgeVec[i-1].isBorder = false; edgeVec[i].isBorder = edgeVec[i-1].isBorder = false;
} }
} }

View File

@ -1330,7 +1330,7 @@ public:
m.tetra[pos].ImportData(m.tetra[i]); m.tetra[pos].ImportData(m.tetra[i]);
//import vertex refs //import vertex refs
for (int j = 0; j < 4; ++j) for (int j = 0; j < 4; ++j)
m.tetra[pos].V(j) = m.tetra[i].cV(j); m.tetra[pos].V(j) = m.tetra[i].V(j);
//import VT adj //import VT adj
if (HasVTAdjacency(m)) if (HasVTAdjacency(m))
for (int j = 0; j < 4; ++j) for (int j = 0; j < 4; ++j)
@ -1675,7 +1675,7 @@ public:
typename std::set<PointerToAttribute > ::iterator i; typename std::set<PointerToAttribute > ::iterator i;
for( i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i) for( i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i)
if( (*i)._handle == h._handle ){ if( (*i)._handle == h._handle ){
delete ((SimpleTempData<FaceContainer,ATTR_TYPE>*)(*i)._handle); delete ((SimpleTempData<EdgeContainer,ATTR_TYPE>*)(*i)._handle);
m.edge_attr.erase(i); m.edge_attr.erase(i);
return;} return;}
} }

View File

@ -368,9 +368,8 @@ void ExternalProduct(const Point3<S> &a, const Point3<S> &b)
ScalarType Norm() ScalarType Norm()
{ {
ScalarType SQsum=0; ScalarType SQsum=0;
for(int i=0;i<3;++i) for(int i=0;i<9;++i)
for(int j=0;j<3;++j) SQsum += a[i]*a[i];
SQsum += a[i]*a[i];
return (math::Sqrt(SQsum)); return (math::Sqrt(SQsum));
} }

View File

@ -45,12 +45,12 @@ All the Components that can be added to a tetra should be defined in the namespa
template <class T> class EmptyCore : public T { template <class T> class EmptyCore : public T {
public: public:
//Empty vertexref //Empty vertexref
inline typename T::VertexType * & V( const int ) { assert(0); static typename T::VertexType *vp=0; return vp; } 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 & V( const int ) const { 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 const 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 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 & 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; } inline const typename T::CoordType &cP( const int ) const { assert(0); static typename T::CoordType coord(0, 0, 0); return coord; }
static bool HasVertexRef() { return false; } static bool HasVertexRef() { return false; }
static bool HasTVAdjacency() { return false; } static bool HasTVAdjacency() { return false; }
@ -177,8 +177,8 @@ public:
typedef typename T::VertexType::CoordType CoordType; typedef typename T::VertexType::CoordType CoordType;
typedef typename T::VertexType::ScalarType ScalarType; 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 * & 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 const 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]; } 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

@ -26,6 +26,7 @@
#include <stdarg.h> // For va_start, etc. #include <stdarg.h> // For va_start, etc.
#include <memory> // For std::unique_ptr #include <memory> // For std::unique_ptr
#include <iostream>
namespace vcg { namespace vcg {
/*! \brief This function allow lenghty algorithms to report progress and status. /*! \brief This function allow lenghty algorithms to report progress and status.

View File

@ -96,7 +96,7 @@ namespace io {
"The importer assumes that the OpenMeshType uses a 3D point for the vertex position", "The importer assumes that the OpenMeshType uses a 3D point for the vertex position",
"There isn't any scene in Collada file", "There isn't any scene in Collada file",
"The input file is not compatible with COLLADA 1.41 standard format", "The input file is not compatible with COLLADA 1.41 standard format",
"Collada file is trying to referece an attribute that is not in the file", "Collada file is trying to reference an attribute that is not in the file",
"This version of Collada Importer support only triangular and polygonal mesh file" "This version of Collada Importer support only triangular and polygonal mesh file"
}; };
@ -108,7 +108,7 @@ namespace io {
// For example // For example
// <instance_geometry url="#shape0-lib"> // <instance_geometry url="#shape0-lib">
// means that you have to search in the <library_geometries> for a node <geometry> with id = "shape0-lib" // means that you have to search in the <library_geometries> for a node <geometry> with id = "shape0-lib"
// you have to call this function to get ther right refernece name // you have to call this function to get the right reference name
inline static void referenceToANodeAttribute(const QDomNode n,const QString& attr,QString& url_st) inline static void referenceToANodeAttribute(const QDomNode n,const QString& attr,QString& url_st)
{ {
@ -182,7 +182,7 @@ namespace io {
res = nd.simplified().split(" ",QString::SkipEmptyParts); res = nd.simplified().split(" ",QString::SkipEmptyParts);
if(res.empty()) if(res.empty())
{ {
qDebug("Warning valueStringList returned and emtpy list. nothing inside element with tag '%s'", qPrintable(tag)); qDebug("Warning valueStringList returned and empty list. nothing inside element with tag '%s'", qPrintable(tag));
return; return;
} }
if (res.last() == "") if (res.last() == "")
@ -348,7 +348,7 @@ namespace io {
/* Very important procedure /* Very important procedure
it has the task to finde the name of the image node corresponding to a given material id, it has the task to find the name of the image node corresponding to a given material id,
it assuemes that the material name that is passed have already been bound with the current bindings it assuemes that the material name that is passed have already been bound with the current bindings
*/ */

View File

@ -141,7 +141,7 @@ public:
off_error_msg.resize(3); off_error_msg.resize(3);
off_error_msg[0] = "No errors"; off_error_msg[0] = "No errors";
off_error_msg[1] = "Can't open file"; off_error_msg[1] = "Can't open file";
off_error_msg[1] = "Output Stream error"; off_error_msg[2] = "Output Stream error";
} }
if (error>2 || error<0) return "Unknown error"; if (error>2 || error<0) return "Unknown error";

View File

@ -637,7 +637,7 @@ namespace io {
QDomElement instGeomNode= geomNodeList.at(ch).toElement(); QDomElement instGeomNode= geomNodeList.at(ch).toElement();
if(instGeomNode.parentNode()==node) // process only direct child if(instGeomNode.parentNode()==node) // process only direct child
{ {
QDEBUG("** instance_geometry with url %s (intial mesh size %i %i T = %i)",qPrintable(instGeomNode.attribute("url")),m.vn,m.fn,m.textures.size()); QDEBUG("** instance_geometry with url %s (initial mesh size %i %i T = %i)",qPrintable(instGeomNode.attribute("url")),m.vn,m.fn,m.textures.size());
//assert(m.textures.size()>0 == HasPerWedgeTexCoord(m)); //assert(m.textures.size()>0 == HasPerWedgeTexCoord(m));
QString geomNode_url; QString geomNode_url;
referenceToANodeAttribute(instGeomNode,"url",geomNode_url); referenceToANodeAttribute(instGeomNode,"url",geomNode_url);
@ -711,7 +711,7 @@ namespace io {
} }
// Retrieve the transformation matrix that is defined in the childs of a node. // Retrieve the transformation matrix that is defined in the children of a node.
// used during the recursive descent. // used during the recursive descent.
static Matrix44f getTransfMatrixFromNode(const QDomElement parentNode) static Matrix44f getTransfMatrixFromNode(const QDomElement parentNode)
{ {

View File

@ -81,7 +81,7 @@ static bool ReadHeader(FILE *fp,unsigned int &num_cams, unsigned int &num_points
if(0!=strcmp("# Bundle file v0.3", line)) return false; if(0!=strcmp("# Bundle file v0.3", line)) return false;
readline(fp, line); readline(fp, line);
if(line[0]=='\0') return false; if(line[0]=='\0') return false;
sscanf(line, "%d %d", &num_cams, &num_points); if (sscanf(line, "%d %d", &num_cams, &num_points) != 2) return false;
return true; return true;
} }
@ -108,13 +108,12 @@ static int Open( OpenMeshType &m, std::vector<Shot<ScalarType> > & shots,
float R[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1}; float R[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};
vcg::Point3f t; vcg::Point3f t;
readline(fp, line); if(line[0]=='\0') return false; sscanf(line, "%f %f %f", &f, &k1, &k2); readline(fp, line); if(line[0]=='\0') return false; if (sscanf(line, "%f %f %f", &f, &k1, &k2) != 3) return false;
readline(fp, line); if(line[0]=='\0') return false; sscanf(line, "%f %f %f", &(R[0]), &(R[1]), &(R[2])); R[3] = 0; readline(fp, line); if(line[0]=='\0') return false; if (sscanf(line, "%f %f %f", &(R[0]), &(R[1]), &(R[2])) != 3) return false; R[3] = 0;
readline(fp, line); if(line[0]=='\0') return false; sscanf(line, "%f %f %f", &(R[4]), &(R[5]), &(R[6])); R[7] = 0; readline(fp, line); if(line[0]=='\0') return false; if (sscanf(line, "%f %f %f", &(R[4]), &(R[5]), &(R[6])) != 3) return false; R[7] = 0;
readline(fp, line); if(line[0]=='\0') return false; sscanf(line, "%f %f %f", &(R[8]), &(R[9]), &(R[10])); R[11] = 0; readline(fp, line); if(line[0]=='\0') return false; if (sscanf(line, "%f %f %f", &(R[8]), &(R[9]), &(R[10])) != 3) return false; R[11] = 0;
readline(fp, line); if(line[0]=='\0') return false; if (sscanf(line, "%f %f %f", &(t[0]), &(t[1]), &(t[2])) != 3) return false;
readline(fp, line); if(line[0]=='\0') return false; sscanf(line, "%f %f %f", &(t[0]), &(t[1]), &(t[2]));
Matrix44x mat = Matrix44x::Construct(Matrix44f(R)); Matrix44x mat = Matrix44x::Construct(Matrix44f(R));
@ -152,14 +151,14 @@ static int Open( OpenMeshType &m, std::vector<Shot<ScalarType> > & shots,
for(uint i = 0; i < num_points;++i,++vi){ for(uint i = 0; i < num_points;++i,++vi){
double x,y,z; double x,y,z;
unsigned int r,g,b,i_cam, key_sift,n_corr; unsigned int r,g,b,i_cam, key_sift,n_corr;
fscanf(fp,"%lf %lf %lf ",&x,&y,&z); if (fscanf(fp,"%lf %lf %lf ",&x,&y,&z) != 3) return false;
(*vi).P() = vcg::Point3<typename OpenMeshType::ScalarType>(x,y,z); (*vi).P() = vcg::Point3<typename OpenMeshType::ScalarType>(x,y,z);
fscanf(fp,"%d %d %d ",&r,&g,&b); if (fscanf(fp,"%d %d %d ",&r,&g,&b) != 3) return false;
(*vi).C() = vcg::Color4b(r,g,b,255); (*vi).C() = vcg::Color4b(r,g,b,255);
fscanf(fp,"%d ",&n_corr); if (fscanf(fp,"%d ",&n_corr) != 1) return false;
for(uint j = 0; j < n_corr; ++j){ for(uint j = 0; j < n_corr; ++j){
fscanf(fp,"%d %d %lf %lf ",&i_cam,&key_sift,&x,&y); if (fscanf(fp,"%d %d %lf %lf ",&i_cam,&key_sift,&x,&y) != 4) return false;
Correspondence corr(i_cam,key_sift,x,y); Correspondence corr(i_cam,key_sift,x,y);
ch[i].push_back(corr); ch[i].push_back(corr);
} }
@ -181,7 +180,7 @@ static bool ReadImagesFilenames(const char * filename,std::vector<std::string>
while(!feof(fp)){ while(!feof(fp)){
readline(fp, line, 1000); readline(fp, line, 1000);
if(line[0] == '\0') continue; //ignore empty lines (in theory, might happen only at end of file) if(line[0] == '\0') continue; //ignore empty lines (in theory, might happen only at end of file)
sscanf(line, "%s", name); if (sscanf(line, "%s", name) != 1) return false;
std::string n(name); std::string n(name);
image_filenames.push_back(n); image_filenames.push_back(n);
} }

View File

@ -970,7 +970,7 @@ public:
bufstr = c.substr(num_cols.length()+1); bufstr = c.substr(num_cols.length()+1);
RangeGridCols = atoi(bufstr.c_str()); RangeGridCols = atoi(bufstr.c_str());
} }
if( num_rows == c.substr(0,num_cols.length()) ) if( num_rows == c.substr(0,num_rows.length()) )
{ {
bufstr = c.substr(num_rows.length()+1); bufstr = c.substr(num_rows.length()+1);
RangeGridRows = atoi(bufstr.c_str()); RangeGridRows = atoi(bufstr.c_str());