From 87f8ba9b337bd8d101ab4597f95a667823a1ecda Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Fri, 17 Jan 2020 10:54:37 +0100 Subject: [PATCH] fixed bugs and compilation errors in nanoply --- wrap/nanoply/include/nanoply.hpp | 84 +++++++------- wrap/nanoply/include/nanoplyWrapper.hpp | 141 +++++++++++++----------- wrap/nanoply/nanoply_vcg/main.cpp | 8 +- 3 files changed, 122 insertions(+), 111 deletions(-) diff --git a/wrap/nanoply/include/nanoply.hpp b/wrap/nanoply/include/nanoply.hpp index b76b11ac..2205bf2a 100644 --- a/wrap/nanoply/include/nanoply.hpp +++ b/wrap/nanoply/include/nanoply.hpp @@ -256,7 +256,7 @@ namespace nanoply /* Names used for the PlyElement */ static ElementMap mapElem({ - { PlyElemEntity::NNP_UNKNOWN_ELEM, NameVector({ "unknonw" }) }, + { PlyElemEntity::NNP_UNKNOWN_ELEM, NameVector({ "unknown" }) }, { PlyElemEntity::NNP_VERTEX_ELEM, NameVector({ "vertex" }) }, { PlyElemEntity::NNP_EDGE_ELEM, NameVector({ "edge" }) }, { PlyElemEntity::NNP_FACE_ELEM, NameVector({ "face" }) }, @@ -594,7 +594,7 @@ namespace nanoply * @param _t Property type. * @param _e Property entity. */ - inline PlyProperty(PlyType _t, PlyEntity _e) :type(_t), elem(_e), name(PlyPropertyName(_e)[0]), validToWrite(false){} + inline PlyProperty(PlyType _t, PlyEntity _e) : name(PlyPropertyName(_e)[0]), type(_t), elem(_e), validToWrite(false){} /** * Constructor that sets the type, the entity and the name of a standard PLY property. @@ -603,7 +603,7 @@ namespace nanoply * @param _e Property entity. * @param _n Property name. */ - inline PlyProperty(PlyType _t, PlyEntity _e, std::string _n) :type(_t), elem(_e), name(_n), validToWrite(false){} + inline PlyProperty(PlyType _t, PlyEntity _e, std::string _n) : name(_n), type(_t), elem(_e), validToWrite(false){} /** * Constructor that sets the type and the name of a custom PLY property. @@ -611,7 +611,7 @@ namespace nanoply * @param _t Property type. * @param _n Property name. */ - inline PlyProperty(PlyType _t, std::string _n) :type(_t), elem(PlyEntity::NNP_UNKNOWN_ENTITY), name(_n), validToWrite(false){} + inline PlyProperty(PlyType _t, std::string _n) :name(_n), type(_t), elem(PlyEntity::NNP_UNKNOWN_ENTITY), validToWrite(false){} /** * Get the description string of the property entity. @@ -947,6 +947,7 @@ namespace nanoply delete[] temp; break; } + default: assert(0); } return true; } @@ -1036,7 +1037,7 @@ namespace nanoply v.push_back(name); } - for (int i = 0; i < v.size(); i++) + for (size_t i = 0; i < v.size(); i++) { std::stringstream s; s << "property " << type << " " << v[i] << "\n"; @@ -1255,7 +1256,7 @@ namespace nanoply temp << "element " << name << " " << cnt << "\n"; if (file.WriteHeaderLine(temp.str())) { - for (int i = 0; i < propVec.size(); i++) + for (size_t i = 0; i < propVec.size(); i++) ok = propVec[i].WriteHeader(file); } else @@ -1266,8 +1267,8 @@ namespace nanoply inline bool PlyElement::SkipAsciiElementsInFile(PlyFile &file) { - for (int i = 0; i < this->cnt; ++i) - for (int j = 0; j < this->propVec.size(); ++j) + for (size_t i = 0; i < this->cnt; ++i) + for (size_t j = 0; j < this->propVec.size(); ++j) this->propVec[j].SkipAsciiPropertyInFile(file); return true; } @@ -1275,8 +1276,8 @@ namespace nanoply inline bool PlyElement::SkipBinaryElementsInFile(PlyFile &file) { - for (int i = 0; i < this->cnt; ++i) - for (int j = 0; j < this->propVec.size(); ++j) + for (size_t i = 0; i < this->cnt; ++i) + for (size_t j = 0; j < this->propVec.size(); ++j) this->propVec[j].SkipBinaryPropertyInFile(file); return true; } @@ -1357,7 +1358,7 @@ namespace nanoply inline bool PlyElement::Contains(PlyEntity entity) { - for (int i = 0; i < propVec.size(); i++) + for (size_t i = 0; i < propVec.size(); i++) { if (propVec[i].elem == entity) return true; @@ -1615,9 +1616,9 @@ namespace nanoply else ok = file.WriteHeaderLine(std::string("format ascii 1.0\n")); ok = file.WriteHeaderLine(std::string("comment nanoply generated\n")); - for (int i = 0; i < this->textureFile.size(); i++) + for (size_t i = 0; i < this->textureFile.size(); i++) ok = file.WriteHeaderLine(std::string("comment TextureFile ") + this->textureFile[i] + "\n"); - for (int i = 0; i < this->elemVec.size(); i++) + for (size_t i = 0; i < this->elemVec.size(); i++) ok = this->elemVec[i].WriteHeader(file); ok = file.WriteHeaderLine(std::string("end_header\n")); return ok; @@ -1668,7 +1669,7 @@ namespace nanoply inline PlyElement* Info::GetElement(const std::string& name) { - for (int i = 0; i < elemVec.size(); i++) + for (size_t i = 0; i < elemVec.size(); i++) { if (elemVec[i].name == name) return &elemVec[i]; @@ -1679,7 +1680,7 @@ namespace nanoply inline PlyElement* Info::GetElement(PlyElemEntity e) { - for (int i = 0; i < elemVec.size(); i++) + for (size_t i = 0; i < elemVec.size(); i++) { if (elemVec[i].plyElem == e) return &elemVec[i]; @@ -1872,10 +1873,10 @@ namespace nanoply inline void ElementDescriptor::ExtractDescriptor(PropertyDescriptor& descr, PlyElement &elem) { - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { PlyProperty& prop = elem.propVec[j]; - int i = 0; + size_t i = 0; for (; i < dataDescriptor.size(); i++) { if (dataDescriptor[i]->elem == prop.elem) @@ -1915,9 +1916,9 @@ namespace nanoply { PropertyDescriptor descr; ExtractDescriptor(descr, elem); - for (int i = 0; i < elem.cnt; i++) + for (size_t i = 0; i < elem.cnt; i++) { - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { PlyProperty& prop = elem.propVec[j]; if (descr[j] != NULL) @@ -1934,9 +1935,9 @@ namespace nanoply { PropertyDescriptor descr; ExtractDescriptor(descr, elem); - for (int i = 0; i < elem.cnt; i++) + for (size_t i = 0; i < elem.cnt; i++) { - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { PlyProperty& prop = elem.propVec[j]; if (descr[j] != NULL) @@ -1952,9 +1953,9 @@ namespace nanoply { PropertyDescriptor descr; ExtractDescriptor(descr, elem); - for (int i = 0; i < elem.cnt; i++) + for (size_t i = 0; i < elem.cnt; i++) { - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { if (descr[j] != NULL) (*descr[j]).WriteElemBinary(file, elem.propVec[j], fixEndian); @@ -1967,10 +1968,10 @@ namespace nanoply { PropertyDescriptor descr; ExtractDescriptor(descr, elem); - for (int i = 0; i < elem.cnt; i++) + for (size_t i = 0; i < elem.cnt; i++) { bool first = true; - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { if (descr[j] != NULL) { @@ -1997,7 +1998,7 @@ namespace nanoply elem.validToWrite = true; PropertyDescriptor descr; ExtractDescriptor(descr, elem); - for (int j = 0; j < elem.propVec.size(); j++) + for (size_t j = 0; j < elem.propVec.size(); j++) { if (descr[j] != NULL) elem.propVec[j].validToWrite = true; @@ -2267,7 +2268,7 @@ namespace nanoply std::vector data(count); - for (int i = 0; i < std::min(count, list->size()); i++) + for (size_t i = 0; i < std::min(count, list->size()); i++) data[i] = (C)((*list)[i]); if (sizeof(C) > 1 && fixEndian) @@ -2275,7 +2276,7 @@ namespace nanoply file.WriteBinaryData(data.data(), sizeof(C)*std::min(count, list->size())); C temp = 0; - for (int i = 0; i < (count - list->size()); i++) + for (size_t i = 0; i < (count - list->size()); i++) file.WriteBinaryData(&temp, sizeof(C)); ++(descr.curPos); } @@ -2303,13 +2304,13 @@ namespace nanoply } std::vector data(count); - for (int i = 0; i < std::min(count, list->size()); i++) + for (size_t i = 0; i < std::min(count, list->size()); i++) data[i] = (C)((*list)[i]); - for (int i = 0; i < (count - list->size()); i++) + for (size_t i = 0; i < (count - list->size()); i++) data[i] = 0; - for (int i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) { file.WriteAsciiData(data[i]); if (i < count - 1) @@ -2617,10 +2618,10 @@ namespace nanoply if (info.binary) { - for (int i = 0; i < info.elemVec.size(); ++i) + for (size_t i = 0; i < info.elemVec.size(); ++i) { PlyElement& pe = info.elemVec[i]; - int j = 0; + size_t j = 0; for (; j < meshElements.size(); j++) if (ElemProcessing<0>(*meshElements[j], pe, file, fixEndian)) break; @@ -2632,10 +2633,10 @@ namespace nanoply } else { - for (int i = 0; i < info.elemVec.size(); ++i) + for (size_t i = 0; i < info.elemVec.size(); ++i) { PlyElement& pe = info.elemVec[i]; - int j = 0; + size_t j = 0; for (; j < meshElements.size(); j++) if (ElemProcessing<1>(*meshElements[j], pe, file, false)) break; @@ -2665,10 +2666,10 @@ namespace nanoply info.errInfo = NNP_UNABLE_TO_OPEN; return false; } - for (int i = 0; i < info.elemVec.size(); ++i) + for (size_t i = 0; i < info.elemVec.size(); ++i) { PlyElement& pe = info.elemVec[i]; - for (int j = 0; j < meshElements.size(); j++) + for (size_t j = 0; j < meshElements.size(); j++) if (ElemProcessing<4>(*meshElements[j], pe, file, false)) break; } @@ -2687,12 +2688,12 @@ namespace nanoply if (info.binary) { - for (int i = 0; i < info.elemVec.size(); ++i) + for (size_t i = 0; i < info.elemVec.size(); ++i) { PlyElement& pe = info.elemVec[i]; if (pe.validToWrite) { - for (int j = 0; j < meshElements.size(); j++) + for (size_t j = 0; j < meshElements.size(); j++) if (ElemProcessing<2>(*meshElements[j], pe, file, false)) break; } @@ -2700,12 +2701,12 @@ namespace nanoply } else { - for (int i = 0; i < info.elemVec.size(); ++i) + for (size_t i = 0; i < info.elemVec.size(); ++i) { PlyElement& pe = info.elemVec[i]; if (pe.validToWrite) { - for (int j = 0; j < meshElements.size(); j++) + for (size_t j = 0; j < meshElements.size(); j++) if (ElemProcessing<3>(*meshElements[j], pe, file, false)) break; } @@ -2732,6 +2733,7 @@ namespace nanoply template < typename TupleType, size_t N, size_t ActionType> inline bool TupleForEach(TupleType &tuple, PlyElement &elem, PlyFile& file, bool fixEndian, SizeT t, SizeT a) { + (void)t; typename std::tuple_element::type &elemDescr = std::get(tuple); if ((elemDescr.elem != PlyElemEntity::NNP_UNKNOWN_ELEM && elemDescr.elem == elem.plyElem) || (elemDescr.elem == PlyElemEntity::NNP_UNKNOWN_ELEM && elemDescr.name == elem.name)) diff --git a/wrap/nanoply/include/nanoplyWrapper.hpp b/wrap/nanoply/include/nanoplyWrapper.hpp index 84c8fb0d..ebef9398 100644 --- a/wrap/nanoply/include/nanoplyWrapper.hpp +++ b/wrap/nanoply/include/nanoplyWrapper.hpp @@ -16,6 +16,7 @@ #define NANOPLY_WRAPPER_VCG_H #include +#include #include #include @@ -74,7 +75,7 @@ namespace nanoply typedef typename MeshType::FaceIterator FaceIterator; - template static PlyType getEntity() { return NNP_UNKNOWN_TYPE }; + template static PlyType getEntity() { return NNP_UNKNOWN_TYPE; }; template<> static PlyType getEntity(){ return NNP_UINT8; }; template<> static PlyType getEntity(){ return NNP_INT8; }; template<> static PlyType getEntity(){ return NNP_UINT16; }; @@ -114,7 +115,7 @@ namespace nanoply template - inline static void PushDescriport(std::vector& prop, ElementDescriptor& elem, std::string& name, void* ptr) + inline static void PushDescriport(std::vector& prop, ElementDescriptor& elem, const std::string& name, void* ptr) { prop.push_back(PlyProperty(getEntity(), name)); DescriptorInterface* di = new DataDescriptor(name, ptr); @@ -123,7 +124,7 @@ namespace nanoply template - inline static void PushDescriportList(std::vector& prop, ElementDescriptor& elem, std::string& name, void* ptr) + inline static void PushDescriportList(std::vector& prop, ElementDescriptor& elem, const std::string& name, void* ptr) { prop.push_back(PlyProperty(getEntityList(), name)); DescriptorInterface* di = new DataDescriptor(name, ptr); @@ -201,17 +202,17 @@ namespace nanoply std::map meshAttribCnt; - CustomAttributeDescriptor::~CustomAttributeDescriptor() + ~CustomAttributeDescriptor() { - for (int i = 0; i < vertexAttrib.size(); i++) + for (size_t i = 0; i < vertexAttrib.size(); i++) delete vertexAttrib[i]; - for (int i = 0; i < edgeAttrib.size(); i++) + for (size_t i = 0; i < edgeAttrib.size(); i++) delete edgeAttrib[i]; - for (int i = 0; i < faceAttrib.size(); i++) + for (size_t i = 0; i < faceAttrib.size(); i++) delete faceAttrib[i]; CustomAttributeDescriptor::MapMeshAttribIter iter = meshAttrib.begin(); for (; iter != meshAttrib.end(); iter++) - for (int i = 0; i < (*iter).second.size(); i++) + for (size_t i = 0; i < (*iter).second.size(); i++) delete (*iter).second[i]; } @@ -235,13 +236,13 @@ namespace nanoply } template - void AddMeshAttribDescriptor(const std::string& nameAttrib, std::string& nameProp, PlyType type, void* ptr) + void AddMeshAttribDescriptor(const std::string& nameAttrib, const std::string& nameProp, PlyType type, void* ptr) { meshAttrib[nameAttrib].push_back(new DataDescriptor(nameProp, ptr)); meshAttribProp[nameAttrib].push_back(PlyProperty(type, nameProp)); } - void AddMeshAttrib(std::string& name, int cnt) + void AddMeshAttrib(const std::string& name, int cnt) { meshAttribCnt[name] = cnt; } @@ -251,7 +252,7 @@ namespace nanoply nanoply::Info info(filename); if (info.errInfo == nanoply::NNP_OK) { - for (int i = 0; i < info.elemVec.size(); i++) + for (size_t i = 0; i < info.elemVec.size(); i++) { if (info.elemVec[i].plyElem == NNP_UNKNOWN_ELEM && info.elemVec[i].name != "camera") meshAttribCnt[info.elemVec[i].name] = info.elemVec[i].cnt; @@ -281,12 +282,12 @@ namespace nanoply bool AddEdgeAttrib(MeshType& m, std::set& ptrAttrib, PlyElement* elem) { - return AddCustomAttrib<1>(m, ptrAttrib, elem, vertexAttrib); + return AddCustomAttrib<1>(m, ptrAttrib, elem, edgeAttrib); } bool AddFaceAttrib(MeshType& m, std::set& ptrAttrib, PlyElement* elem) { - return AddCustomAttrib<2>(m, ptrAttrib, elem, vertexAttrib); + return AddCustomAttrib<2>(m, ptrAttrib, elem, faceAttrib); } @@ -315,7 +316,7 @@ namespace nanoply template void AddPointAttribDescriptor(const PointerToAttribute* ptr, ElementDescriptor::PropertyDescriptor& attrib, std::vector& attribProp) { - int size = typename Container::Dimension; + int size = int(Container::Dimension); std::string name(ptr->_name); Container* tmpPtr = (Container*)ptr->_handle->DataBegin(); for (int i = 0 ; i < size; i++) @@ -325,7 +326,7 @@ namespace nanoply template void AddColorAttribDescriptor(const PointerToAttribute* ptr, ElementDescriptor::PropertyDescriptor& attrib, std::vector& attribProp) { - int size = typename Container::Dimension; + int size = int(Container::Dimension); std::string name(ptr->_name); Container* tmpPtr = (Container*)ptr->_handle->DataBegin(); for (int i = 0; i < size; i++) @@ -415,17 +416,17 @@ namespace nanoply { if (ActionType == 0) //vertex { - auto h = vcg::tri::Allocator::GetPerVertexAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerVertexAttribute(m, name); AddVertexAttribDescriptor(name, type, h._handle->DataBegin()); } else if (ActionType == 1) //Edge { - auto h = vcg::tri::Allocator::GetPerEdgeAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerEdgeAttribute(m, name); AddEdgeAttribDescriptor(name, type, h._handle->DataBegin()); } else if (ActionType == 2) //Face { - auto h = vcg::tri::Allocator::GetPerFaceAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerFaceAttribute(m, name); AddFaceAttribDescriptor(name, type, h._handle->DataBegin()); } } @@ -435,20 +436,20 @@ namespace nanoply { if (ActionType == 0) //vertex { - auto h = vcg::tri::Allocator::GetPerVertexAttribute(m, name); - for (int i = 0; i < prop.size(); i++) + auto h = vcg::tri::Allocator::template GetPerVertexAttribute(m, name); + for (size_t i = 0; i < prop.size(); i++) AddVertexAttribDescriptor(prop[i].name, prop[i].type, &h[0][i]); } else if (ActionType == 1) //Edge { - auto h = vcg::tri::Allocator::GetPerEdgeAttribute(m, name); - for (int i = 0; i < prop.size(); i++) + auto h = vcg::tri::Allocator::template GetPerEdgeAttribute(m, name); + for (size_t i = 0; i < prop.size(); i++) AddEdgeAttribDescriptor(prop[i].name, prop[i].type, &h[0][i]); } else if (ActionType == 2) //Face { - auto h = vcg::tri::Allocator::GetPerFaceAttribute(m, name); - for (int i = 0; i < prop.size(); i++) + auto h = vcg::tri::Allocator::template GetPerFaceAttribute(m, name); + for (size_t i = 0; i < prop.size(); i++) AddFaceAttribDescriptor(prop[i].name, prop[i].type, &h[0][i]); } } @@ -459,17 +460,17 @@ namespace nanoply { if (ActionType == 0) //vertex { - auto h = vcg::tri::Allocator::GetPerVertexAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerVertexAttribute(m, name); AddVertexAttribDescriptor(name, type, h._handle->DataBegin()); } else if (ActionType == 1) //Edge { - auto h = vcg::tri::Allocator::GetPerEdgeAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerEdgeAttribute(m, name); AddEdgeAttribDescriptor(name, type, h._handle->DataBegin()); } else if (ActionType == 2) //Face { - auto h = vcg::tri::Allocator::GetPerFaceAttribute(m, name); + auto h = vcg::tri::Allocator::template GetPerFaceAttribute(m, name); AddFaceAttribDescriptor(name, type, h._handle->DataBegin()); } } @@ -480,11 +481,11 @@ namespace nanoply { //Custom attribute with already a data descriptor std::set validCustomAttrib; - for (int i = 0; i < attrib.size(); i++) + for (size_t i = 0; i < attrib.size(); i++) { if (attrib[i]->base == NULL) { - std::set::iterator ai; + typename std::set::iterator ai; for (ai = ptrAttrib.begin(); ai != ptrAttrib.end(); ++ai) { if (attrib[i]->name == (*ai)._name) @@ -501,7 +502,7 @@ namespace nanoply //Get custom properties without a data descriptor std::map, int>> customAttribName; std::vector attribName((*elem).propVec.size()); - for (int i = 0; i < (*elem).propVec.size(); i++) + for (size_t i = 0; i < (*elem).propVec.size(); i++) { if ((*elem).propVec[i].elem == NNP_UNKNOWN_ENTITY) { @@ -534,7 +535,7 @@ namespace nanoply unsigned int bitType = 0; std::vector tempProp((*mapIter).second.first.size()); int checkMask = (1 << (*mapIter).second.first.size()) - 1; - for (int i = 0; i < (*mapIter).second.first.size(); i++) + for (size_t i = 0; i < (*mapIter).second.first.size(); i++) { PlyProperty& p = (*mapIter).second.first[i]; bitType |= p.type; @@ -567,6 +568,7 @@ namespace nanoply case NNP_UINT8: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT16: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT32: AddPointAttrib>(m, (*mapIter).first, tempProp); break; + default: assert(0); } } else if (tempProp.size() == 3) @@ -581,6 +583,7 @@ namespace nanoply case NNP_UINT8: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT16: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT32: AddPointAttrib>(m, (*mapIter).first, tempProp); break; + default: assert(0); } } else if (tempProp.size() == 4 && (*mapIter).second.second != (checkMask << 4)) @@ -595,6 +598,7 @@ namespace nanoply case NNP_UINT8: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT16: AddPointAttrib>(m, (*mapIter).first, tempProp); break; case NNP_UINT32: AddPointAttrib>(m, (*mapIter).first, tempProp); break; + default: assert(0); } } else if (tempProp.size() == 4) @@ -609,12 +613,13 @@ namespace nanoply case NNP_FLOAT32: AddPointAttrib(m, (*mapIter).first, tempProp); break; case NNP_FLOAT64: AddPointAttrib(m, (*mapIter).first, tempProp); break; case NNP_UINT8: AddPointAttrib(m, (*mapIter).first, tempProp); break; + default: assert(0); } } } else { - for (int i = 0; i < tempProp.size(); i++) + for (size_t i = 0; i < tempProp.size(); i++) { switch (tempProp[i].type) { @@ -642,6 +647,7 @@ namespace nanoply case NNP_LIST_INT8_UINT16: AddListAttrib, unsigned short>(m, tempProp[i].name, tempProp[i].type); break; case NNP_LIST_UINT8_INT16: case NNP_LIST_INT8_INT16: AddListAttrib, short>(m, tempProp[i].name, tempProp[i].type); break; + default: assert(0); } } } @@ -828,12 +834,12 @@ namespace nanoply static unsigned int GetFileBitMask(nanoply::Info& info) { unsigned int mask = 0; - for (int j = 0; j < info.elemVec.size(); j++) + for (size_t j = 0; j < info.elemVec.size(); j++) { PlyElement& elem = info.elemVec[j]; if (elem.plyElem == PlyElemEntity::NNP_VERTEX_ELEM) { - for (int i = 0; i < elem.propVec.size(); i++) + for (size_t i = 0; i < elem.propVec.size(); i++) { switch (elem.propVec[i].elem) { @@ -853,12 +859,13 @@ namespace nanoply case NNP_K1DIR: case NNP_K2DIR: mask |= BitMask::IO_VERTCURVDIR; break; case NNP_UNKNOWN_ENTITY: mask |= BitMask::IO_VERTATTRIB; break; + default: assert(0); } } } else if (elem.plyElem == PlyElemEntity::NNP_EDGE_ELEM) { - for (int i = 0; i < elem.propVec.size(); i++) + for (size_t i = 0; i < elem.propVec.size(); i++) { switch (elem.propVec[i].elem) { @@ -869,12 +876,13 @@ namespace nanoply case NNP_BITFLAG: mask |= BitMask::IO_EDGEFLAGS; break; case NNP_QUALITY: mask |= BitMask::IO_EDGEQUALITY; break; case NNP_UNKNOWN_ENTITY: mask |= BitMask::IO_EDGEATTRIB; break; + default: assert(0); } } } else if (elem.plyElem == PlyElemEntity::NNP_FACE_ELEM) { - for (int i = 0; i < elem.propVec.size(); i++) + for (size_t i = 0; i < elem.propVec.size(); i++) { switch (elem.propVec[i].elem) { @@ -893,6 +901,7 @@ namespace nanoply case NNP_FACE_WEDGE_TEX: mask |= BitMask::IO_WEDGTEXCOORD; break; case NNP_TEXTUREINDEX: mask |= BitMask::IO_WEDGTEXMULTI; break; case NNP_UNKNOWN_ENTITY: mask |= BitMask::IO_FACEATTRIB; break; + default: assert(0); } } } @@ -1032,7 +1041,7 @@ namespace nanoply if (bitMask & BitMask::IO_VERTATTRIB) { custom.AddVertexAttrib(mesh, mesh.vert_attr, info.GetVertexElement()); - for (int i = 0; i < custom.vertexAttrib.size(); i++) + for (size_t i = 0; i < custom.vertexAttrib.size(); i++) { if ((*custom.vertexAttrib[i]).base != NULL) vertexDescr.dataDescriptor.push_back(custom.vertexAttrib[i]); @@ -1064,7 +1073,7 @@ namespace nanoply if (bitMask & BitMask::IO_EDGEATTRIB) { custom.AddEdgeAttrib(mesh, mesh.edge_attr, info.GetEdgeElement()); - for (int i = 0; i < custom.edgeAttrib.size(); i++) + for (size_t i = 0; i < custom.edgeAttrib.size(); i++) { if ((*custom.edgeAttrib[i]).base != NULL) edgeDescr.dataDescriptor.push_back(custom.edgeAttrib[i]); @@ -1156,7 +1165,7 @@ namespace nanoply if (bitMask & BitMask::IO_FACEATTRIB) { custom.AddFaceAttrib(mesh, mesh.face_attr, info.GetFaceElement()); - for (int i = 0; i < custom.faceAttrib.size(); i++) + for (size_t i = 0; i < custom.faceAttrib.size(); i++) { if ((*custom.faceAttrib[i]).base != NULL) faceDescr.dataDescriptor.push_back(custom.faceAttrib[i]); @@ -1173,7 +1182,7 @@ namespace nanoply //Mesh attribute if ((bitMask & BitMask::IO_MESHATTRIB)) { - CustomAttributeDescriptor::MapMeshAttribIter iter = custom.meshAttrib.begin(); + typename CustomAttributeDescriptor::MapMeshAttribIter iter = custom.meshAttrib.begin(); for (; iter != custom.meshAttrib.end(); iter++) { std::string name((*iter).first); @@ -1192,7 +1201,7 @@ namespace nanoply mesh.shot.SetViewPoint(tra); mesh.shot.Extrinsics.SetRot(rot); bool triangleMesh = true; - for (int i = 0; i < faceIndex.size(); i++) + for (size_t i = 0; i < faceIndex.size(); i++) if (faceIndex[i].size() > 3) triangleMesh = false; @@ -1202,7 +1211,7 @@ namespace nanoply bool hasFaceColor = (bitMask & BitMask::IO_FACECOLOR) && vcg::tri::HasPerFaceColor(mesh); bool hasFaceQuality = (bitMask & BitMask::IO_FACEQUALITY) && vcg::tri::HasPerFaceQuality(mesh); bool hasFaceNormal = (bitMask & BitMask::IO_FACENORMAL) && vcg::tri::HasPerFaceNormal(mesh); - for (int i = 0; i < faceIndex.size(); i++) + for (size_t i = 0; i < faceIndex.size(); i++) { if (faceIndex[i].size() >= 3) { @@ -1211,7 +1220,7 @@ namespace nanoply if (hasFaceFlags) mesh.face[i].SetF(2); FaceIterator fi = vcg::tri::Allocator::AddFaces(mesh, faceIndex[i].size() - 3); - for (int j = 3; j < faceIndex[i].size(); j++) + for (size_t j = 3; j < faceIndex[i].size(); j++) { (*fi).V(0) = &mesh.vert[faceIndex[i][0]]; (*fi).V(1) = &mesh.vert[faceIndex[i][j - 1]]; @@ -1238,13 +1247,13 @@ namespace nanoply } else { - for (int i = 0; i < faceIndex.size(); i++) + for (size_t i = 0; i < faceIndex.size(); i++) { mesh.face[i].Alloc(faceIndex[i].size()); - for (int j = 0; j < faceIndex[i].size(); j++) + for (size_t j = 0; j < faceIndex[i].size(); j++) mesh.face[i].V(j) = &mesh.vert[faceIndex[i][j]]; } - for (int i = 0; i < wedgeTexCoord.size(); i++) + for (size_t i = 0; i < wedgeTexCoord.size(); i++) { for (int j = 0; j < 3; j++) { @@ -1255,21 +1264,21 @@ namespace nanoply } } - for (int i = 0; i < edgeIndex.size(); i++) + for (size_t i = 0; i < edgeIndex.size(); i++) { mesh.edge[i].V(0) = &mesh.vert[edgeIndex[i].X()]; mesh.edge[i].V(1) = &mesh.vert[edgeIndex[i].Y()]; } - for (int i = 0; i < cameraDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < cameraDescr.dataDescriptor.size(); i++) delete cameraDescr.dataDescriptor[i]; - for (int i = 0; i < vertexDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < vertexDescr.dataDescriptor.size(); i++) if (vertexDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete vertexDescr.dataDescriptor[i]; - for (int i = 0; i < edgeDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < edgeDescr.dataDescriptor.size(); i++) if (edgeDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete edgeDescr.dataDescriptor[i]; - for (int i = 0; i < faceDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < faceDescr.dataDescriptor.size(); i++) if (faceDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete faceDescr.dataDescriptor[i]; mesh.textures = info.textureFile; @@ -1399,7 +1408,7 @@ namespace nanoply } if ((bitMask & BitMask::IO_VERTATTRIB)) { - std::set::iterator ai; + typename std::set::iterator ai; int userSize = custom.vertexAttrib.size(); for (ai = mesh.vert_attr.begin(); ai != mesh.vert_attr.end(); ++ai) { @@ -1415,7 +1424,7 @@ namespace nanoply if (!userDescr) custom.CreateVertexAttribDescriptor(&(*ai)); } - for (int i = 0; i < custom.vertexAttrib.size(); i++) + for (size_t i = 0; i < custom.vertexAttrib.size(); i++) { vertexProp.push_back(custom.vertexAttribProp[i]); vertexDescr.dataDescriptor.push_back(custom.vertexAttrib[i]); @@ -1429,7 +1438,7 @@ namespace nanoply std::vector edgeProp; ElementDescriptor edgeDescr(NNP_EDGE_ELEM); std::vector edgeIndex; - for (int i = 0; i < mesh.edge.size(); i++) + for (size_t i = 0; i < mesh.edge.size(); i++) edgeIndex.push_back(vcg::Point2i(vcg::tri::Index(mesh, mesh.edge[i].V(0)), vcg::tri::Index(mesh, mesh.edge[i].V(1)))); if (nameList.size() > 0 && mesh.edge.size() > 0) { @@ -1447,7 +1456,7 @@ namespace nanoply if ((bitMask & BitMask::IO_EDGEATTRIB)) { - std::set::iterator ai; + typename std::set::iterator ai; int userSize = custom.edgeAttrib.size(); for (ai = mesh.edge_attr.begin(); ai != mesh.edge_attr.end(); ++ai) { @@ -1463,7 +1472,7 @@ namespace nanoply if (!userDescr) custom.CreateEdgeAttribDescriptor(&(*ai)); } - for (int i = 0; i < custom.edgeAttrib.size(); i++) + for (size_t i = 0; i < custom.edgeAttrib.size(); i++) { edgeProp.push_back(custom.edgeAttribProp[i]); edgeDescr.dataDescriptor.push_back(custom.edgeAttrib[i]); @@ -1478,7 +1487,7 @@ namespace nanoply ElementDescriptor faceDescr(NNP_FACE_ELEM); std::vector> faceIndex; std::vector> wedgeTexCoord; - for (int i = 0; i < mesh.face.size(); i++) + for (size_t i = 0; i < mesh.face.size(); i++) { faceIndex.push_back(std::vector()); for (int j = 0; j < mesh.face[i].VN(); j++) @@ -1486,7 +1495,7 @@ namespace nanoply } if (((bitMask & BitMask::IO_WEDGTEXCOORD) || (bitMask & BitMask::IO_WEDGTEXMULTI)) && vcg::tri::HasPerWedgeTexCoord(mesh)) { - for (int i = 0; i < mesh.face.size(); i++) + for (size_t i = 0; i < mesh.face.size(); i++) { wedgeTexCoord.push_back(vcg::ndim::Point<6, FaceTexScalar>()); for (int j = 0; j < 3; j++) @@ -1565,7 +1574,7 @@ namespace nanoply } if ((bitMask & BitMask::IO_FACEATTRIB)) { - std::set::iterator ai; + typename std::set::iterator ai; int userSize = custom.faceAttrib.size(); for (ai = mesh.face_attr.begin(); ai != mesh.face_attr.end(); ++ai) { @@ -1610,8 +1619,8 @@ namespace nanoply //Mesh attribute if ((bitMask & BitMask::IO_MESHATTRIB)) { - CustomAttributeDescriptor::MapMeshAttribIter iter = custom.meshAttrib.begin(); - CustomAttributeDescriptor::MapMeshAttribPropIter iterProp = custom.meshAttribProp.begin(); + typename CustomAttributeDescriptor::MapMeshAttribIter iter = custom.meshAttrib.begin(); + typename CustomAttributeDescriptor::MapMeshAttribPropIter iterProp = custom.meshAttribProp.begin(); for (; iter != custom.meshAttrib.end(); iter++, iterProp++) { std::string name((*iter).first); @@ -1624,15 +1633,15 @@ namespace nanoply bool flag = nanoply::SaveModel(infoSave.filename, meshDescr, infoSave); - for (int i = 0; i < cameraDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < cameraDescr.dataDescriptor.size(); i++) delete cameraDescr.dataDescriptor[i]; - for (int i = 0; i < vertexDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < vertexDescr.dataDescriptor.size(); i++) if (vertexDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete vertexDescr.dataDescriptor[i]; - for (int i = 0; i < edgeDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < edgeDescr.dataDescriptor.size(); i++) if (edgeDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete edgeDescr.dataDescriptor[i]; - for (int i = 0; i < faceDescr.dataDescriptor.size(); i++) + for (size_t i = 0; i < faceDescr.dataDescriptor.size(); i++) if (faceDescr.dataDescriptor[i]->elem != NNP_UNKNOWN_ENTITY) delete faceDescr.dataDescriptor[i]; @@ -1651,4 +1660,4 @@ namespace nanoply } -#endif \ No newline at end of file +#endif diff --git a/wrap/nanoply/nanoply_vcg/main.cpp b/wrap/nanoply/nanoply_vcg/main.cpp index 62a95b41..37005bac 100644 --- a/wrap/nanoply/nanoply_vcg/main.cpp +++ b/wrap/nanoply/nanoply_vcg/main.cpp @@ -45,7 +45,7 @@ public: { vertexMaterial = vcg::tri::Allocator::AddPerVertexAttribute(*this, std::string("materialId")); faceBarycenter = vcg::tri::Allocator::AddPerFaceAttribute(*this, std::string("barycenter")); - material = vcg::tri::Allocator::AddPerMeshAttribute>(*this, std::string("material")); + material = vcg::tri::Allocator::AddPerMeshAttribute >(*this, std::string("material")); } void FillMesh() @@ -55,7 +55,7 @@ public: vcg::tri::UpdateNormal::PerVertexNormalized(*this); int tempC = 255 / vert.size(); - for (int i = 0; i < vert.size(); i++) + for (size_t i = 0; i < vert.size(); i++) { if (i < 2) vertexMaterial[i] = -1; @@ -67,7 +67,7 @@ public: vert[i].C() = vcg::Color4b(tempC*i, tempC*i, tempC*i, 255); } - for (int i = 0; i < face.size(); i++) + for (size_t i = 0; i < face.size(); i++) faceBarycenter[i] = vcg::Barycenter(face[i]); material().resize(2); @@ -149,5 +149,5 @@ int main() MyMesh mesh2, mesh3; Load("example_ascii.ply", mesh2); Load("example_binary.ply", mesh3); - return true; + return 0; }