hardcoded floats to Scalar; fix some warnings (#158)

This commit is contained in:
alemuntoni 2021-01-28 12:46:13 +01:00
parent 4b387c3f67
commit 280245b70b
5 changed files with 27 additions and 27 deletions

View File

@ -340,7 +340,7 @@ public:
bool Process(vcg::CallBackPos *cb=0) bool Process(vcg::CallBackPos *cb=0)
{ {
sprintf(errorMessage,""); sprintf(errorMessage,"%s", "");
printf("bbox scanning...\n"); fflush(stdout); printf("bbox scanning...\n"); fflush(stdout);
Matrix44f Id; Id.SetIdentity(); Matrix44f Id; Id.SetIdentity();
MP.InitBBox(); MP.InitBBox();

View File

@ -49,11 +49,11 @@ public:
class WArc class WArc
{ {
public: 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 src;
VertexPointer trg; VertexPointer trg;
float w; ScalarType w;
bool operator< (const WArc &a) const {return w<a.w;} bool operator< (const WArc &a) const {return w<a.w;}
}; };
@ -101,7 +101,7 @@ public:
{ {
heap.push_back(WArc(vp,&(m.vert[neightId]))); heap.push_back(WArc(vp,&(m.vert[neightId])));
//std::push_heap(heap.begin(),heap.end()); //std::push_heap(heap.begin(),heap.end());
if(heap.back().w < 0.3f) if(heap.back().w < 0.3)
heap.pop_back(); heap.pop_back();
else else
std::push_heap(heap.begin(),heap.end()); std::push_heap(heap.begin(),heap.end());
@ -147,7 +147,7 @@ public:
{ {
for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
{ {
if ( vi->N().dot(p.viewPoint- vi->P())<0.0f) if ( vi->N().dot(p.viewPoint- vi->P())<0.0)
vi->N()=-(*vi).N(); vi->N()=-(*vi).N();
} }
return; return;
@ -175,7 +175,7 @@ public:
if(!a.trg->IsV()) if(!a.trg->IsV())
{ {
a.trg->SetV(); 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(); a.trg->N()=-a.trg->N();
AddNeighboursToHeap(m,a.trg,p.coherentAdjNum,tree,heap); AddNeighboursToHeap(m,a.trg,p.coherentAdjNum,tree,heap);
} }

View File

@ -123,7 +123,7 @@ namespace vcg {
void doQueryK(const VectorType& queryPoint, int k, PriorityQueue& mNeighborQueue); void doQueryK(const VectorType& queryPoint, int k, PriorityQueue& mNeighborQueue);
void doQueryDist(const VectorType& queryPoint, float dist, std::vector<unsigned int>& points, std::vector<Scalar>& sqrareDists); void doQueryDist(const VectorType& queryPoint, Scalar dist, std::vector<unsigned int>& points, std::vector<Scalar>& sqrareDists);
void doQueryClosest(const VectorType& queryPoint, unsigned int& index, Scalar& dist); 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, // 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 // 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); int createTree(unsigned int nodeId, unsigned int start, unsigned int end, unsigned int level);
@ -211,7 +211,7 @@ namespace vcg {
std::vector<QueryNode> mNodeStack(numLevel + 1); std::vector<QueryNode> mNodeStack(numLevel + 1);
mNodeStack[0].nodeId = 0; mNodeStack[0].nodeId = 0;
mNodeStack[0].sq = 0.f; mNodeStack[0].sq = 0.;
unsigned int count = 1; unsigned int count = 1;
while (count) while (count)
@ -242,7 +242,7 @@ namespace vcg {
else else
{ {
// the new offset is the distance between the searched point and the actual split coordinate // 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 //left sub-tree
if (new_off < 0.) if (new_off < 0.)
@ -279,14 +279,14 @@ namespace vcg {
* and the vector of the squared distances from the query point. * and the vector of the squared distances from the query point.
*/ */
template<typename Scalar> template<typename Scalar>
void KdTree<Scalar>::doQueryDist(const VectorType& queryPoint, float dist, std::vector<unsigned int>& points, std::vector<Scalar>& sqrareDists) void KdTree<Scalar>::doQueryDist(const VectorType& queryPoint, Scalar dist, std::vector<unsigned int>& points, std::vector<Scalar>& sqrareDists)
{ {
std::vector<QueryNode> mNodeStack(numLevel + 1); std::vector<QueryNode> mNodeStack(numLevel + 1);
mNodeStack[0].nodeId = 0; mNodeStack[0].nodeId = 0;
mNodeStack[0].sq = 0.f; mNodeStack[0].sq = 0.;
unsigned int count = 1; unsigned int count = 1;
float sqrareDist = dist*dist; Scalar sqrareDist = dist*dist;
while (count) while (count)
{ {
QueryNode& qnode = mNodeStack[count - 1]; QueryNode& qnode = mNodeStack[count - 1];
@ -300,7 +300,7 @@ namespace vcg {
unsigned int end = node.start + node.size; unsigned int end = node.start + node.size;
for (unsigned int i = node.start; i < end; ++i) 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) if (pointSquareDist < sqrareDist)
{ {
points.push_back(mIndices[i]); points.push_back(mIndices[i]);
@ -311,7 +311,7 @@ namespace vcg {
else else
{ {
// replace the stack top by the farthest and push the closest // 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.) if (new_off < 0.)
{ {
mNodeStack[count].nodeId = node.firstChildId; mNodeStack[count].nodeId = node.firstChildId;
@ -346,7 +346,7 @@ namespace vcg {
{ {
std::vector<QueryNode> mNodeStack(numLevel + 1); std::vector<QueryNode> mNodeStack(numLevel + 1);
mNodeStack[0].nodeId = 0; mNodeStack[0].nodeId = 0;
mNodeStack[0].sq = 0.f; mNodeStack[0].sq = 0.;
unsigned int count = 1; unsigned int count = 1;
int minIndex = mIndices.size() / 2; int minIndex = mIndices.size() / 2;
@ -366,7 +366,7 @@ namespace vcg {
unsigned int end = node.start + node.size; unsigned int end = node.start + node.size;
for (unsigned int i = node.start; i < end; ++i) 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) if (pointSquareDist < minDist)
{ {
minDist = pointSquareDist; minDist = pointSquareDist;
@ -377,7 +377,7 @@ namespace vcg {
else else
{ {
// replace the stack top by the farthest and push the closest // 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.) if (new_off < 0.)
{ {
mNodeStack[count].nodeId = node.firstChildId; mNodeStack[count].nodeId = node.firstChildId;
@ -411,7 +411,7 @@ namespace vcg {
* using the "dim" coordinate [0 = x, 1 = y, 2 = z]. * using the "dim" coordinate [0 = x, 1 = y, 2 = z].
*/ */
template<typename Scalar> template<typename Scalar>
unsigned int KdTree<Scalar>::split(int start, int end, unsigned int dim, float splitValue) unsigned int KdTree<Scalar>::split(int start, int end, unsigned int dim, Scalar splitValue)
{ {
int l(start), r(end - 1); int l(start), r(end - 1);
for (; l < r; ++l, --r) for (; l < r; ++l, --r)

View File

@ -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; if(m.vert[i].P().Y()!= baseY) break;
} }
cnt=m.vert.size(); 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::FaceGrid(m,i,int(cnt/i));
tri::Clean<MESH_TYPE>::FlipMesh(m); tri::Clean<MESH_TYPE>::FlipMesh(m);
return E_NOERROR; return E_NOERROR;

View File

@ -186,7 +186,7 @@ namespace io {
static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,ColladaMesh& m,const size_t offset,InfoDAE& info,QMap<QString,QString> &materialBinding) static DAEError LoadPolygonalListMesh(QDomNodeList& polylist,ColladaMesh& m,const size_t offset,InfoDAE& info,QMap<QString,QString> &materialBinding)
{ {
if(polylist.isEmpty()) return E_NOERROR; 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) for(int tript = 0; tript < polylist.size();++tript)
{ {
QString materialId = polylist.at(tript).toElement().attribute(QString("material")); 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; return E_NOERROR;
} }
@ -435,12 +435,12 @@ namespace io {
if( ! ( (m.face[ff].V(0) != m.face[ff].V(1)) && 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(0) != m.face[ff].V(2)) &&
(m.face[ff].V(1) != 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; return E_NOERROR;
} }
@ -602,7 +602,7 @@ namespace io {
if (err != E_NOERROR) if (err != E_NOERROR)
return err; 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; return E_NOERROR;
} }
@ -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 (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)); //assert(m.textures.size()>0 == HasPerWedgeTexCoord(m));
QString geomNode_url; QString geomNode_url;
referenceToANodeAttribute(instGeomNode,"url",geomNode_url); referenceToANodeAttribute(instGeomNode,"url",geomNode_url);
@ -654,7 +654,7 @@ namespace io {
LoadGeometry(newMesh, info, refNode.toElement(),materialBindingMap); LoadGeometry(newMesh, info, refNode.toElement(),materialBindingMap);
tri::UpdatePosition<ColladaMesh>::Matrix(newMesh,curTr); tri::UpdatePosition<ColladaMesh>::Matrix(newMesh,curTr);
tri::Append<ColladaMesh,ColladaMesh>::Mesh(m,newMesh); tri::Append<ColladaMesh,ColladaMesh>::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());
} }
} }