From 3eac5bfa8503dfcf5a96a7c159e9fe2de334aaeb Mon Sep 17 00:00:00 2001 From: Leonardo Fischer Date: Wed, 12 Dec 2012 22:42:21 -0200 Subject: [PATCH] Some warnings corrected, most are conversions between int's and unsigned int's. Thanks to @jimmyskull --- source/DCEL/DCELStream.h | 13 +++++-------- source/DCEL/Mesh.h | 17 ++++++++++------- source/main.cpp | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/source/DCEL/DCELStream.h b/source/DCEL/DCELStream.h index 5612203..d923656 100644 --- a/source/DCEL/DCELStream.h +++ b/source/DCEL/DCELStream.h @@ -41,11 +41,9 @@ public: template static void copyDcelData(const MeshT& source, MeshT2& target ) { - const MeshT::Vertex* vertex = NULL; - const unsigned int numVertices = source.getNumVertices(); const MeshT::Face* face = NULL; + const unsigned int numVertices = source.getNumVertices(); const unsigned int numFaces = source.getNumFaces(); - const MeshT::HalfEdge* edge = NULL; const unsigned int numEdges = source.getNumHalfEdges(); target.clear(); @@ -134,10 +132,9 @@ template void DCELStream::write(const MeshT& mesh, std::ostream &stream) { const MeshT::Vertex* vertex = NULL; - const unsigned int numVertices = mesh.getNumVertices(); const MeshT::Face* face = NULL; + const unsigned int numVertices = mesh.getNumVertices(); const unsigned int numFaces = mesh.getNumFaces(); - const MeshT::HalfEdge* edge = NULL; const unsigned int numEdges = mesh.getNumHalfEdges(); stream << "version 1" << std::endl; @@ -229,19 +226,19 @@ void DCELStream::read_v1(MeshT& mesh, std::istream &stream) else if( str=="vc" ) { - unsigned int vc = -1; + unsigned int vc = std::numeric_limits::max(); stream >> vc; mesh.getVertices().reserve( vc*5 ); } else if( str=="fc" ) { - unsigned int fc = -1; + unsigned int fc = std::numeric_limits::max(); stream >> fc; mesh.getFaces().reserve( fc*5 ); } else if( str=="ec" ) { - unsigned int ec = -1; + unsigned int ec = std::numeric_limits::max(); stream >> ec; mesh.getHalfEdges().reserve( ec*5 ); } diff --git a/source/DCEL/Mesh.h b/source/DCEL/Mesh.h index 75410a2..45ed55d 100644 --- a/source/DCEL/Mesh.h +++ b/source/DCEL/Mesh.h @@ -12,6 +12,7 @@ #include #include +#include #include "Vertex.h" #include "Face.h" @@ -20,6 +21,8 @@ #include "Exception.h" +#define MESH_NULL_ID (std::numeric_limits::max()) + /** A class that stores the mesh structure. It the list of the vertices, edges and faces. Also, it has some methods for simplify the mesh manipulation. @@ -250,7 +253,7 @@ private: std::vector edges; std::list unhandledTriangles; - int unhandledTrianglesCount; + unsigned int unhandledTrianglesCount; }; @@ -334,7 +337,7 @@ unsigned int Mesh::createTriangularFace(unsigned int vId1, unsigned if (e2!=NULL) readyEdges++; if (e3!=NULL) readyEdges++; - unsigned int nullFaceId = (unsigned int)-1; + unsigned int nullFaceId = MESH_NULL_ID; unsigned int faceId = nullFaceId; Face* face = NULL; @@ -734,7 +737,7 @@ unsigned int Mesh::getVertexId(const Vertex* vertex) const if( &(this->vertices[id]) == vertex ) return id; } - return -1; + return MESH_NULL_ID; } template @@ -772,7 +775,7 @@ unsigned int Mesh::getFaceId(const Face* face) const if( &(this->faces[id]) == face ) return id; } - return -1; + return MESH_NULL_ID; }; template @@ -832,7 +835,7 @@ unsigned int Mesh::getHalfEdgeId( HalfEdge* halfEdge) const if( &(this->edges[id]) == halfEdge ) return id; } - return -1; + return MESH_NULL_ID; } template @@ -960,12 +963,12 @@ void Mesh::manageUnhandledTriangles() throw cpp::Exception("The number of unhandled triangles should be equal to the number of unhandled vertices*3!"); } - int curTriangle = 0; + unsigned int curTriangle = 0; while( !this->unhandledTriangles.empty() ) { if( curTriangle==unhandledTrianglesCount ) { - int remainingTriangles = this->unhandledTriangles.size() / 3; + unsigned int remainingTriangles = this->unhandledTriangles.size() / 3; if( remainingTriangles