PLY: convert readInteger into a template
This commit is contained in:
@@ -971,8 +971,10 @@ void _PLYReader_::readValue(ValueType _type, std::istream& _in, int& _value) con
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, T& _value) const {
|
||||||
|
|
||||||
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) const {
|
static_assert(std::is_integral<T>::value, "Integral required.");
|
||||||
|
|
||||||
int32_t tmp_int32_t;
|
int32_t tmp_int32_t;
|
||||||
uint32_t tmp_uint32_t;
|
uint32_t tmp_uint32_t;
|
||||||
@@ -1020,71 +1022,12 @@ void _PLYReader_::readInteger(ValueType _type, std::istream& _in, int& _value) c
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
_value = 0;
|
_value = 0;
|
||||||
std::cerr << "unsupported conversion type to int: " << _type << std::endl;
|
std::cerr << "unsupported conversion type to integral: " << _type << std::endl;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
void _PLYReader_::readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const {
|
|
||||||
|
|
||||||
int32_t tmp_int32_t;
|
|
||||||
uint32_t tmp_uint32_t;
|
|
||||||
int8_t tmp_char;
|
|
||||||
uint8_t tmp_uchar;
|
|
||||||
|
|
||||||
switch (_type) {
|
|
||||||
|
|
||||||
case ValueTypeUINT:
|
|
||||||
|
|
||||||
case ValueTypeUINT32:
|
|
||||||
|
|
||||||
restore(_in, tmp_uint32_t, options_.check(Options::MSB));
|
|
||||||
_value = tmp_uint32_t;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ValueTypeINT:
|
|
||||||
|
|
||||||
case ValueTypeINT32:
|
|
||||||
|
|
||||||
restore(_in, tmp_int32_t, options_.check(Options::MSB));
|
|
||||||
_value = tmp_int32_t;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ValueTypeUCHAR:
|
|
||||||
|
|
||||||
case ValueTypeUINT8:
|
|
||||||
|
|
||||||
restore(_in, tmp_uchar, options_.check(Options::MSB));
|
|
||||||
_value = tmp_uchar;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ValueTypeCHAR:
|
|
||||||
|
|
||||||
case ValueTypeINT8:
|
|
||||||
|
|
||||||
restore(_in, tmp_char, options_.check(Options::MSB));
|
|
||||||
_value = tmp_char;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
_value = 0;
|
|
||||||
std::cerr << "unsupported conversion type to unsigned int: " << _type << std::endl;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1501
src/OpenMesh/Core/IO/reader/PLYReader.cc.orig
Normal file
1501
src/OpenMesh/Core/IO/reader/PLYReader.cc.orig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -139,8 +139,8 @@ private:
|
|||||||
void readValue(ValueType _type , std::istream& _in, short& _value) const;
|
void readValue(ValueType _type , std::istream& _in, short& _value) const;
|
||||||
void readValue(ValueType _type , std::istream& _in, signed char& _value) const;
|
void readValue(ValueType _type , std::istream& _in, signed char& _value) const;
|
||||||
|
|
||||||
void readInteger(ValueType _type, std::istream& _in, int& _value) const;
|
template<typename T>
|
||||||
void readInteger(ValueType _type, std::istream& _in, unsigned int& _value) const;
|
void readInteger(ValueType _type, std::istream& _in, T& _value) const;
|
||||||
|
|
||||||
/// Read unsupported properties in PLY file
|
/// Read unsupported properties in PLY file
|
||||||
void consume_input(std::istream& _in, int _count) const {
|
void consume_input(std::istream& _in, int _count) const {
|
||||||
@@ -223,7 +223,7 @@ private:
|
|||||||
{
|
{
|
||||||
_in >> _value;
|
_in >> _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//read and assign custom properties with the given type. Also creates property, if not exist
|
//read and assign custom properties with the given type. Also creates property, if not exist
|
||||||
template<bool binary, typename T, typename Handle>
|
template<bool binary, typename T, typename Handle>
|
||||||
void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h, const std::string& _propName, const ValueType _valueType, const ValueType _listType) const;
|
void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h, const std::string& _propName, const ValueType _valueType, const ValueType _listType) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user