From 280245b70bfa5dc7cea4565349d170cdfe58c87e Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 28 Jan 2021 12:46:13 +0100 Subject: [PATCH] hardcoded floats to Scalar; fix some warnings (#158) --- vcg/complex/algorithms/create/plymc/plymc.h | 2 +- vcg/complex/algorithms/pointcloud_normal.h | 10 ++++---- vcg/space/index/kdtree/kdtree.h | 26 ++++++++++----------- wrap/io_trimesh/import_asc.h | 2 +- wrap/io_trimesh/import_dae.h | 14 +++++------ 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/vcg/complex/algorithms/create/plymc/plymc.h b/vcg/complex/algorithms/create/plymc/plymc.h index ae268ef5..d01ed870 100644 --- a/vcg/complex/algorithms/create/plymc/plymc.h +++ b/vcg/complex/algorithms/create/plymc/plymc.h @@ -340,7 +340,7 @@ public: bool Process(vcg::CallBackPos *cb=0) { - sprintf(errorMessage,""); + sprintf(errorMessage,"%s", ""); printf("bbox scanning...\n"); fflush(stdout); Matrix44f Id; Id.SetIdentity(); MP.InitBBox(); diff --git a/vcg/complex/algorithms/pointcloud_normal.h b/vcg/complex/algorithms/pointcloud_normal.h index 87a748e2..2be75193 100644 --- a/vcg/complex/algorithms/pointcloud_normal.h +++ b/vcg/complex/algorithms/pointcloud_normal.h @@ -49,11 +49,11 @@ public: class WArc { public: - WArc(VertexPointer _s,VertexPointer _t):src(_s),trg(_t),w(fabs(_s->cN()*_t->cN())){} + WArc(VertexPointer _s,VertexPointer _t):src(_s),trg(_t),w(std::abs(_s->cN()*_t->cN())){} VertexPointer src; VertexPointer trg; - float w; + ScalarType w; bool operator< (const WArc &a) const {return wN().dot(p.viewPoint- vi->P())<0.0f) + if ( vi->N().dot(p.viewPoint- vi->P())<0.0) vi->N()=-(*vi).N(); } return; @@ -175,7 +175,7 @@ public: if(!a.trg->IsV()) { a.trg->SetV(); - if(a.src->cN()*a.trg->cN()<0.0f) + if(a.src->cN()*a.trg->cN()<0.0) a.trg->N()=-a.trg->N(); AddNeighboursToHeap(m,a.trg,p.coherentAdjNum,tree,heap); } diff --git a/vcg/space/index/kdtree/kdtree.h b/vcg/space/index/kdtree/kdtree.h index 51ddc574..a143fe9d 100755 --- a/vcg/space/index/kdtree/kdtree.h +++ b/vcg/space/index/kdtree/kdtree.h @@ -123,7 +123,7 @@ namespace vcg { void doQueryK(const VectorType& queryPoint, int k, PriorityQueue& mNeighborQueue); - void doQueryDist(const VectorType& queryPoint, float dist, std::vector& points, std::vector& sqrareDists); + void doQueryDist(const VectorType& queryPoint, Scalar dist, std::vector& points, std::vector& sqrareDists); void doQueryClosest(const VectorType& queryPoint, unsigned int& index, Scalar& dist); @@ -140,7 +140,7 @@ namespace vcg { // used to build the tree: split the subset [start..end[ according to dim and splitValue, // and returns the index of the first element of the second subset - unsigned int split(int start, int end, unsigned int dim, float splitValue); + unsigned int split(int start, int end, unsigned int dim, Scalar splitValue); int createTree(unsigned int nodeId, unsigned int start, unsigned int end, unsigned int level); @@ -211,7 +211,7 @@ namespace vcg { std::vector mNodeStack(numLevel + 1); mNodeStack[0].nodeId = 0; - mNodeStack[0].sq = 0.f; + mNodeStack[0].sq = 0.; unsigned int count = 1; while (count) @@ -242,7 +242,7 @@ namespace vcg { else { // the new offset is the distance between the searched point and the actual split coordinate - float new_off = queryPoint[node.dim] - node.splitValue; + Scalar new_off = queryPoint[node.dim] - node.splitValue; //left sub-tree if (new_off < 0.) @@ -279,14 +279,14 @@ namespace vcg { * and the vector of the squared distances from the query point. */ template - void KdTree::doQueryDist(const VectorType& queryPoint, float dist, std::vector& points, std::vector& sqrareDists) + void KdTree::doQueryDist(const VectorType& queryPoint, Scalar dist, std::vector& points, std::vector& sqrareDists) { std::vector mNodeStack(numLevel + 1); mNodeStack[0].nodeId = 0; - mNodeStack[0].sq = 0.f; + mNodeStack[0].sq = 0.; unsigned int count = 1; - float sqrareDist = dist*dist; + Scalar sqrareDist = dist*dist; while (count) { QueryNode& qnode = mNodeStack[count - 1]; @@ -300,7 +300,7 @@ namespace vcg { unsigned int end = node.start + node.size; for (unsigned int i = node.start; i < end; ++i) { - float pointSquareDist = vcg::SquaredNorm(queryPoint - mPoints[i]); + Scalar pointSquareDist = vcg::SquaredNorm(queryPoint - mPoints[i]); if (pointSquareDist < sqrareDist) { points.push_back(mIndices[i]); @@ -311,7 +311,7 @@ namespace vcg { else { // replace the stack top by the farthest and push the closest - float new_off = queryPoint[node.dim] - node.splitValue; + Scalar new_off = queryPoint[node.dim] - node.splitValue; if (new_off < 0.) { mNodeStack[count].nodeId = node.firstChildId; @@ -346,7 +346,7 @@ namespace vcg { { std::vector mNodeStack(numLevel + 1); mNodeStack[0].nodeId = 0; - mNodeStack[0].sq = 0.f; + mNodeStack[0].sq = 0.; unsigned int count = 1; int minIndex = mIndices.size() / 2; @@ -366,7 +366,7 @@ namespace vcg { unsigned int end = node.start + node.size; for (unsigned int i = node.start; i < end; ++i) { - float pointSquareDist = vcg::SquaredNorm(queryPoint - mPoints[i]); + Scalar pointSquareDist = vcg::SquaredNorm(queryPoint - mPoints[i]); if (pointSquareDist < minDist) { minDist = pointSquareDist; @@ -377,7 +377,7 @@ namespace vcg { else { // replace the stack top by the farthest and push the closest - float new_off = queryPoint[node.dim] - node.splitValue; + Scalar new_off = queryPoint[node.dim] - node.splitValue; if (new_off < 0.) { mNodeStack[count].nodeId = node.firstChildId; @@ -411,7 +411,7 @@ namespace vcg { * using the "dim" coordinate [0 = x, 1 = y, 2 = z]. */ template - unsigned int KdTree::split(int start, int end, unsigned int dim, float splitValue) + unsigned int KdTree::split(int start, int end, unsigned int dim, Scalar splitValue) { int l(start), r(end - 1); for (; l < r; ++l, --r) diff --git a/wrap/io_trimesh/import_asc.h b/wrap/io_trimesh/import_asc.h index e72bec86..b480bfb5 100644 --- a/wrap/io_trimesh/import_asc.h +++ b/wrap/io_trimesh/import_asc.h @@ -139,7 +139,7 @@ static int Open( MESH_TYPE &m, const char * filename, CallBackPos *cb=0, bool tr 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); + qDebug("Grid is %i x %li = %li (%zu) ",i,cnt/i,i* (cnt/i),cnt); tri::FaceGrid(m,i,int(cnt/i)); tri::Clean::FlipMesh(m); return E_NOERROR; diff --git a/wrap/io_trimesh/import_dae.h b/wrap/io_trimesh/import_dae.h index 00a8549d..b4e0e09b 100644 --- a/wrap/io_trimesh/import_dae.h +++ b/wrap/io_trimesh/import_dae.h @@ -186,7 +186,7 @@ namespace io { static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,ColladaMesh& m,const size_t offset,InfoDAE& info,QMap &materialBinding) { if(polylist.isEmpty()) return E_NOERROR; - QDEBUG("****** LoadPolygonalListMesh (initial mesh size %i %i)",m.vert.size(),m.fn); + QDEBUG("****** LoadPolygonalListMesh (initial mesh size %li %i)",m.vert.size(),m.fn); for(int tript = 0; tript < polylist.size();++tript) { QString materialId = polylist.at(tript).toElement().attribute(QString("material")); @@ -271,7 +271,7 @@ namespace io { } } - QDEBUG("****** LoadPolygonalListMesh (final mesh size vn %i vertsize %i - fn %i facesize %i)",m.vn,m.vert.size(),m.fn,m.face.size()); + QDEBUG("****** LoadPolygonalListMesh (final mesh size vn %i vertsize %li - fn %i facesize %li)",m.vn,m.vert.size(),m.fn,m.face.size()); return E_NOERROR; } @@ -435,12 +435,12 @@ namespace io { if( ! ( (m.face[ff].V(0) != m.face[ff].V(1)) && (m.face[ff].V(0) != m.face[ff].V(2)) && (m.face[ff].V(1) != m.face[ff].V(2)) ) ) - QDEBUG("********* WARNING face %i, (%i %i %i) is a DEGENERATE FACE!",ff, m.face[ff].V(0) - &m.vert.front(), m.face[ff].V(1) - &m.vert.front(), m.face[ff].V(2) - &m.vert.front()); + QDEBUG("********* WARNING face %i, (%li %li %li) is a DEGENERATE FACE!",ff, m.face[ff].V(0) - &m.vert.front(), m.face[ff].V(1) - &m.vert.front(), m.face[ff].V(2) - &m.vert.front()); } } } - QDEBUG("****** LoadTriangularMesh (final mesh size %i %i - %i %i)",m.vn,m.vert.size(),m.fn,m.face.size()); + QDEBUG("****** LoadTriangularMesh (final mesh size %i %li - %i %li)",m.vn,m.vert.size(),m.fn,m.face.size()); return E_NOERROR; } @@ -602,7 +602,7 @@ namespace io { if (err != E_NOERROR) return err; } - QDEBUG("**** Loading a Geometry Mesh **** (final mesh size %i %i - %i %i)",m.vn,m.vert.size(),m.fn,m.face.size()); + QDEBUG("**** Loading a Geometry Mesh **** (final mesh size %i %li - %i %li)",m.vn,m.vert.size(),m.fn,m.face.size()); return E_NOERROR; } @@ -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 (initial 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 = %li)",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); @@ -654,7 +654,7 @@ namespace io { LoadGeometry(newMesh, info, refNode.toElement(),materialBindingMap); tri::UpdatePosition::Matrix(newMesh,curTr); tri::Append::Mesh(m,newMesh); - QDEBUG("** instance_geometry with url %s (final mesh size %i %i - %i %i)",qPrintable(instGeomNode.attribute("url")),m.vn,m.vert.size(),m.fn,m.face.size()); + QDEBUG("** instance_geometry with url %s (final mesh size %i %li - %i %li)",qPrintable(instGeomNode.attribute("url")),m.vn,m.vert.size(),m.fn,m.face.size()); } }