From f7871eed2d54bee704b9f66dc538c921602323cb Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Fri, 17 Apr 2020 16:44:23 +0200 Subject: [PATCH] bugfixes and PR template --- .github/pull_request_template.md | 14 +++++++++++ .../algorithms/create/advancing_front.h | 3 ++- vcg/complex/algorithms/refine_loop.h | 12 +++++----- vcg/complex/algorithms/update/topology.h | 2 +- vcg/complex/allocate.h | 4 ++-- vcg/math/matrix33.h | 5 ++-- vcg/simplex/tetrahedron/component.h | 14 +++++------ wrap/callback.h | 1 + wrap/dae/util_dae.h | 8 +++---- wrap/io_trimesh/export_off.h | 2 +- wrap/io_trimesh/import_dae.h | 4 ++-- wrap/io_trimesh/import_out.h | 23 +++++++++---------- wrap/io_trimesh/import_ply.h | 2 +- 13 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..e81cb6a9 --- /dev/null +++ b/.github/pull_request_template.md @@ -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. \ No newline at end of file diff --git a/vcg/complex/algorithms/create/advancing_front.h b/vcg/complex/algorithms/create/advancing_front.h index a3955f32..565762e9 100644 --- a/vcg/complex/algorithms/create/advancing_front.h +++ b/vcg/complex/algorithms/create/advancing_front.h @@ -364,7 +364,8 @@ public: protected: void AddFace(int v0, int v1, int v2) { FaceIterator fi = vcg::tri::Allocator::AddFace(mesh,v0,v1,v2); - fi->N() = TriangleNormal(*fi).Normalize(); + if (FaceType::HasNormal()) + fi->N() = TriangleNormal(*fi).Normalize(); if(tri::HasVFAdjacency(mesh)) { for(int j=0;j<3;++j) diff --git a/vcg/complex/algorithms/refine_loop.h b/vcg/complex/algorithms/refine_loop.h index 6380a49b..eab257b4 100644 --- a/vcg/complex/algorithms/refine_loop.h +++ b/vcg/complex/algorithms/refine_loop.h @@ -100,7 +100,7 @@ struct RegularLoopWeight { .69908 }; - return (k<=12)?(1.0-bkPolar[k-3])/k:LoopWeight().beta(k); + return (k<=12 && k>=3)?(1.0-bkPolar[k-3])/k:LoopWeight().beta(k); } inline SCALAR_TYPE incidentRegular(int k) { @@ -120,7 +120,7 @@ struct RegularLoopWeight { .44579 }; - return (k<=12)?bkPolar[k-3]:LoopWeight().incidentIrregular(k); + return (k<=12 && k>=3)?bkPolar[k-3]:LoopWeight().incidentIrregular(k); } inline SCALAR_TYPE opposite(int k) { static SCALAR_TYPE bkPolar[] = { @@ -136,7 +136,7 @@ struct RegularLoopWeight { .19828 }; - return (k<=12)?bkPolar[k-3]:LoopWeight().opposite(k); + return (k<=12 && k >= 3)?bkPolar[k-3]:LoopWeight().opposite(k); } }; @@ -156,7 +156,7 @@ struct ContinuityLoopWeight { .70014 }; - return (k<=12)?(1.0-bkPolar[k-3])/k:LoopWeight().beta(k); + return (k<=12 && k>= 3)?(1.0-bkPolar[k-3])/k:LoopWeight().beta(k); } inline SCALAR_TYPE incidentRegular(int k) { @@ -176,7 +176,7 @@ struct ContinuityLoopWeight { .2452 }; - return (k<=12)?bkPolar[k-3]:LoopWeight().incidentIrregular(k); + return (k<=12 && k>=3)?bkPolar[k-3]:LoopWeight().incidentIrregular(k); } inline SCALAR_TYPE opposite(int k) { static SCALAR_TYPE bkPolar[] = { @@ -192,7 +192,7 @@ struct ContinuityLoopWeight { .29934 }; - return (k<=12)?bkPolar[k-3]:LoopWeight().opposite(k); + return (k<=12 && k >= 3)?bkPolar[k-3]:LoopWeight().opposite(k); } }; diff --git a/vcg/complex/algorithms/update/topology.h b/vcg/complex/algorithms/update/topology.h index 7af633ca..3dcab7d6 100644 --- a/vcg/complex/algorithms/update/topology.h +++ b/vcg/complex/algorithms/update/topology.h @@ -211,7 +211,7 @@ static void FillUniqueEdgeVector(MeshType &m, std::vector &edgeVec, bool edgeVec[ i ].isBorder = true; for (size_t i=1; i ::iterator i; for( i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i) if( (*i)._handle == h._handle ){ - delete ((SimpleTempData*)(*i)._handle); + delete ((SimpleTempData*)(*i)._handle); m.edge_attr.erase(i); return;} } diff --git a/vcg/math/matrix33.h b/vcg/math/matrix33.h index efa797cf..5c82526d 100644 --- a/vcg/math/matrix33.h +++ b/vcg/math/matrix33.h @@ -368,9 +368,8 @@ void ExternalProduct(const Point3 &a, const Point3 &b) ScalarType Norm() { ScalarType SQsum=0; - for(int i=0;i<3;++i) - for(int j=0;j<3;++j) - SQsum += a[i]*a[i]; + for(int i=0;i<9;++i) + SQsum += a[i]*a[i]; return (math::Sqrt(SQsum)); } diff --git a/vcg/simplex/tetrahedron/component.h b/vcg/simplex/tetrahedron/component.h index 43c7ac46..d2d8c878 100644 --- a/vcg/simplex/tetrahedron/component.h +++ b/vcg/simplex/tetrahedron/component.h @@ -45,12 +45,12 @@ All the Components that can be added to a tetra should be defined in the namespa template class EmptyCore : public T { public: //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 * 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; } + 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 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; } static bool HasVertexRef() { return false; } static bool HasTVAdjacency() { return false; } @@ -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 * 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 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]; } diff --git a/wrap/callback.h b/wrap/callback.h index 61c3959f..77d12317 100644 --- a/wrap/callback.h +++ b/wrap/callback.h @@ -26,6 +26,7 @@ #include // For va_start, etc. #include // For std::unique_ptr +#include namespace vcg { /*! \brief This function allow lenghty algorithms to report progress and status. diff --git a/wrap/dae/util_dae.h b/wrap/dae/util_dae.h index 51aa400b..431dd143 100644 --- a/wrap/dae/util_dae.h +++ b/wrap/dae/util_dae.h @@ -96,7 +96,7 @@ namespace io { "The importer assumes that the OpenMeshType uses a 3D point for the vertex position", "There isn't any scene in Collada file", "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" }; @@ -108,7 +108,7 @@ namespace io { // For example // // means that you have to search in the for a node 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) { @@ -182,7 +182,7 @@ namespace io { res = nd.simplified().split(" ",QString::SkipEmptyParts); 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; } if (res.last() == "") @@ -348,7 +348,7 @@ namespace io { /* 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 */ diff --git a/wrap/io_trimesh/export_off.h b/wrap/io_trimesh/export_off.h index c3a54f99..3a9fec97 100644 --- a/wrap/io_trimesh/export_off.h +++ b/wrap/io_trimesh/export_off.h @@ -141,7 +141,7 @@ public: off_error_msg.resize(3); off_error_msg[0] = "No errors"; 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"; diff --git a/wrap/io_trimesh/import_dae.h b/wrap/io_trimesh/import_dae.h index 95881de2..00a8549d 100644 --- a/wrap/io_trimesh/import_dae.h +++ b/wrap/io_trimesh/import_dae.h @@ -637,7 +637,7 @@ namespace io { QDomElement instGeomNode= geomNodeList.at(ch).toElement(); 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)); QString 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. static Matrix44f getTransfMatrixFromNode(const QDomElement parentNode) { diff --git a/wrap/io_trimesh/import_out.h b/wrap/io_trimesh/import_out.h index 88fabb10..f2435ae3 100644 --- a/wrap/io_trimesh/import_out.h +++ b/wrap/io_trimesh/import_out.h @@ -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; readline(fp, line); 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; } @@ -108,13 +108,12 @@ static int Open( OpenMeshType &m, std::vector > & shots, float R[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1}; 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; sscanf(line, "%f %f %f", &(R[4]), &(R[5]), &(R[6])); 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; sscanf(line, "%f %f %f", &(t[0]), &(t[1]), &(t[2])); + 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; 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; 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; Matrix44x mat = Matrix44x::Construct(Matrix44f(R)); @@ -152,14 +151,14 @@ static int Open( OpenMeshType &m, std::vector > & shots, for(uint i = 0; i < num_points;++i,++vi){ double x,y,z; 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(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); - fscanf(fp,"%d ",&n_corr); + if (fscanf(fp,"%d ",&n_corr) != 1) return false; 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); ch[i].push_back(corr); } @@ -181,7 +180,7 @@ static bool ReadImagesFilenames(const char * filename,std::vector while(!feof(fp)){ readline(fp, line, 1000); 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); image_filenames.push_back(n); } diff --git a/wrap/io_trimesh/import_ply.h b/wrap/io_trimesh/import_ply.h index 2c99297e..f8d955c4 100644 --- a/wrap/io_trimesh/import_ply.h +++ b/wrap/io_trimesh/import_ply.h @@ -970,7 +970,7 @@ public: bufstr = c.substr(num_cols.length()+1); 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); RangeGridRows = atoi(bufstr.c_str());