From d91986fc30375cd13119b3c308829978da9a6dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 3 Sep 2019 08:15:16 +0200 Subject: [PATCH] PLY: add support for unsigned custom property length --- src/OpenMesh/Core/IO/reader/PLYReader.cc | 6 +++--- src/OpenMesh/Core/IO/reader/PLYReader.hh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.cc b/src/OpenMesh/Core/IO/reader/PLYReader.cc index 62ea180b..b14bfdf7 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.cc +++ b/src/OpenMesh/Core/IO/reader/PLYReader.cc @@ -219,11 +219,11 @@ void _PLYReader_::readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, } //init vector - int numberOfValues; - read(_listType, _in, numberOfValues, OpenMesh::GenProg::Bool2Type()); + unsigned int numberOfValues; + readInteger(_listType, _in, numberOfValues, OpenMesh::GenProg::Bool2Type()); std::vector vec(numberOfValues); //read and assign - for (int i = 0; i < numberOfValues; ++i) + for (unsigned int i = 0; i < numberOfValues; ++i) { read(_valueType, _in, vec[i], OpenMesh::GenProg::Bool2Type()); } diff --git a/src/OpenMesh/Core/IO/reader/PLYReader.hh b/src/OpenMesh/Core/IO/reader/PLYReader.hh index 95f90ca7..3f855ac4 100644 --- a/src/OpenMesh/Core/IO/reader/PLYReader.hh +++ b/src/OpenMesh/Core/IO/reader/PLYReader.hh @@ -212,6 +212,18 @@ private: _in >> _value; } + template + inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::TrueType /*_binary*/) const + { + readInteger(_type, _in, _value); + } + + template + inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::FalseType /*_binary*/) const + { + _in >> _value; + } + //read and assign custom properties with the given type. Also creates property, if not exist template void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h, const std::string& _propName, const ValueType _valueType, const ValueType _listType) const;