49#include <OpenMesh/Core/IO/reader/PLYReader.hh>
50#include <OpenMesh/Core/IO/IOManager.hh>
51#include <OpenMesh/Core/Utils/color_cast.hh>
81_PLYReader_::_PLYReader_() {
109 std::fstream in(_filename.c_str(), (std::ios_base::binary | std::ios_base::in) );
111 if (!in.is_open() || !in.good()) {
112 omerr() <<
"[PLYReader] : cannot not open file " << _filename << std::endl;
116 bool result =
read(in, _bi, _opt);
128 omerr() <<
"[PLYReader] : cannot not use stream" << std::endl;
134 omerr() <<
"[PLYReader] : Unable to parse header\n";
139 int texture_index = 0;
140 for(
auto const & texture_file : texture_files_) {
141 _bi.add_texture_information(texture_index++, texture_file);
181 return (
options_.is_binary() ? read_binary(_in, _bi, swap_required, _opt) : read_ascii(_in, _bi, _opt));
185template<
typename T,
typename Handle>
201template<
bool binary,
typename T,
typename Handle>
202void _PLYReader_::readCreateCustomProperty(std::istream& _in,
BaseImporter& _bi, Handle _h,
const std::string& _propName,
const _PLYReader_::ValueType _valueType,
const _PLYReader_::ValueType _listType)
const
204 if (_listType == Unsupported)
211 _bi.kernel()->
property(prop).set_persistent(
true);
216 read(_valueType, _in, in, OpenMesh::GenProg::Bool2Type<binary>());
217 _bi.kernel()->
property(prop,_h) = in;
222 typename Handle2Prop<std::vector<T>,Handle>::PropT prop;
226 _bi.kernel()->
property(prop).set_persistent(
true);
230 unsigned int numberOfValues;
231 readInteger(_listType, _in, numberOfValues, OpenMesh::GenProg::Bool2Type<binary>());
232 std::vector<T> vec(numberOfValues);
234 for (
unsigned int i = 0; i < numberOfValues; ++i)
236 read(_valueType, _in, vec[i], OpenMesh::GenProg::Bool2Type<binary>());
238 _bi.kernel()->
property(prop,_h) = vec;
242template<
bool binary,
typename Handle>
243void _PLYReader_::readCustomProperty(std::istream& _in,
BaseImporter& _bi, Handle _h,
const std::string& _propName,
const _PLYReader_::ValueType _valueType,
const _PLYReader_::ValueType _listIndexType)
const
249 readCreateCustomProperty<binary,signed char>(_in,_bi,_h,_propName,_valueType,_listIndexType);
253 readCreateCustomProperty<binary,unsigned char>(_in,_bi,_h,_propName,_valueType,_listIndexType);
257 readCreateCustomProperty<binary,short>(_in,_bi,_h,_propName,_valueType,_listIndexType);
259 case ValueTypeUINT16:
260 case ValueTypeUSHORT:
261 readCreateCustomProperty<binary,unsigned short>(_in,_bi,_h,_propName,_valueType,_listIndexType);
265 readCreateCustomProperty<binary,int>(_in,_bi,_h,_propName,_valueType,_listIndexType);
267 case ValueTypeUINT32:
269 readCreateCustomProperty<binary,unsigned int>(_in,_bi,_h,_propName,_valueType,_listIndexType);
271 case ValueTypeFLOAT32:
273 readCreateCustomProperty<binary,float>(_in,_bi,_h,_propName,_valueType,_listIndexType);
275 case ValueTypeFLOAT64:
276 case ValueTypeDOUBLE:
277 readCreateCustomProperty<binary,double>(_in,_bi,_h,_propName,_valueType,_listIndexType);
280 std::cerr <<
"unsupported type" << std::endl;
288bool _PLYReader_::read_ascii(std::istream& _in,
BaseImporter& _bi,
const Options& _opt)
const {
290 unsigned int i, j, k, l, idx;
297 BaseImporter::VHandles vhandles;
298 std::vector<Vec3f> face_texcoords3d;
299 std::vector<Vec2f> face_texcoords;
302 _bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_);
304 if (vertexDimension_ != 3) {
305 omerr() <<
"[PLYReader] : Only vertex dimension 3 is supported." << std::endl;
309 const bool err_enabled = omerr().is_enabled();
310 size_t complex_faces = 0;
314 for (std::vector<ElementInfo>::iterator e_it = elements_.begin(); e_it != elements_.end(); ++e_it)
320 omerr() <<
"Unexpected end of file while reading." << std::endl;
324 if (e_it->element_== VERTEX)
327 for (i = 0; i < e_it->count_ && !_in.eof(); ++i) {
328 vh = _bi.add_vertex();
346 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex) {
348 switch (prop.property) {
374 if (prop.value == ValueTypeFLOAT32 ||
375 prop.value == ValueTypeFLOAT) {
383 if (prop.value == ValueTypeFLOAT32 ||
384 prop.value == ValueTypeFLOAT) {
392 if (prop.value == ValueTypeFLOAT32 ||
393 prop.value == ValueTypeFLOAT) {
401 if (prop.value == ValueTypeFLOAT32 ||
402 prop.value == ValueTypeFLOAT) {
411 readCustomProperty<false>(_in, _bi, vh, prop.name, prop.value, prop.listIndexType);
421 _bi.set_point(vh, v);
422 if (_opt.vertex_has_normal())
423 _bi.set_normal(vh, n);
424 if (_opt.vertex_has_texcoord())
425 _bi.set_texcoord(vh, t);
426 if (_opt.vertex_has_color())
427 _bi.set_color(vh,
Vec4uc(c));
430 else if (e_it->element_ == FACE)
433 for (i = 0; i < faceCount_ && !_in.eof(); ++i) {
441 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex) {
443 switch (prop.property) {
455 vhandles[0] = VertexHandle(j);
456 vhandles[1] = VertexHandle(k);
457 vhandles[2] = VertexHandle(l);
461 for (j = 0; j < nV; ++j) {
463 vhandles.push_back(VertexHandle(idx));
467 fh = _bi.add_face(vhandles);
476 if (_opt.face_has_texcoord()) {
479 assert(!vhandles.empty());
481 if (nV == 2 * vhandles.size()) {
483 face_texcoords.clear();
484 face_texcoords.reserve(vhandles.size());
486 for (j = 0; j < vhandles.size(); j++) {
490 face_texcoords.push_back(t);
493 _bi.add_face_texcoords(fh, vhandles[0], face_texcoords);
495 }
else if (nV == 3 * vhandles.size()) {
497 face_texcoords3d.clear();
498 face_texcoords3d.reserve(vhandles.size());
500 for (j = 0; j < vhandles.size(); j++) {
505 face_texcoords3d.push_back(t3d);
508 _bi.add_face_texcoords(fh, vhandles[0], face_texcoords3d);
511 for (j = 0; j < nV; j++) {
516 for (j = 0; j < nV; j++) {
524 _bi.set_face_texindex(fh, idx);
528 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
536 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
544 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
552 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
561 readCustomProperty<false>(_in, _bi, fh, prop.name, prop.value, prop.listIndexType);
571 if (_opt.face_has_color())
572 _bi.set_color(fh,
Vec4uc(c));
578 for (i = 0; i < e_it->count_ && !_in.eof(); ++i) {
579 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex)
587 if(e_it->element_== FACE)
596 omerr() << complex_faces <<
"The reader encountered invalid faces, that could not be added.\n";
604bool _PLYReader_::read_binary(std::istream& _in,
BaseImporter& _bi,
bool ,
const Options& _opt)
const {
608 BaseImporter::VHandles vhandles;
609 std::vector<Vec3f> face_texcoords3d;
610 std::vector<Vec2f> face_texcoords;
615 _bi.reserve(vertexCount_, 3* vertexCount_ , faceCount_);
617 const bool err_enabled = omerr().is_enabled();
618 size_t complex_faces = 0;
622 for (std::vector<ElementInfo>::iterator e_it = elements_.begin(); e_it != elements_.end(); ++e_it)
624 if (e_it->element_ == VERTEX)
627 for (
unsigned int i = 0; i < e_it->count_ && !_in.eof(); ++i) {
628 vh = _bi.add_vertex();
646 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex) {
648 switch (prop.property) {
650 readValue(prop.value, _in, v[0]);
653 readValue(prop.value, _in, v[1]);
656 readValue(prop.value, _in, v[2]);
659 readValue(prop.value, _in, n[0]);
662 readValue(prop.value, _in, n[1]);
665 readValue(prop.value, _in, n[2]);
668 readValue(prop.value, _in, t[0]);
671 readValue(prop.value, _in, t[1]);
674 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
675 readValue(prop.value, _in, tmp);
680 readInteger(prop.value, _in, c[0]);
684 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
685 readValue(prop.value, _in, tmp);
689 readInteger(prop.value, _in, c[1]);
693 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
694 readValue(prop.value, _in, tmp);
698 readInteger(prop.value, _in, c[2]);
702 if (prop.value == ValueTypeFLOAT32 || prop.value == ValueTypeFLOAT) {
703 readValue(prop.value, _in, tmp);
707 readInteger(prop.value, _in, c[3]);
712 readCustomProperty<true>(_in, _bi, vh, prop.name, prop.value, prop.listIndexType);
724 _bi.set_point(vh, v);
725 if (_opt.vertex_has_normal())
726 _bi.set_normal(vh, n);
727 if (_opt.vertex_has_texcoord())
728 _bi.set_texcoord(vh, t);
729 if (_opt.vertex_has_color())
730 _bi.set_color(vh,
Vec4uc(c));
733 else if (e_it->element_ == FACE) {
734 for (
unsigned i = 0; i < e_it->count_ && !_in.eof(); ++i) {
742 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex)
745 switch (prop.property) {
750 readInteger(prop.listIndexType, _in, nV);
754 unsigned int j, k, l;
755 readInteger(prop.value, _in, j);
756 readInteger(prop.value, _in, k);
757 readInteger(prop.value, _in, l);
759 vhandles[0] = VertexHandle(j);
760 vhandles[1] = VertexHandle(k);
761 vhandles[2] = VertexHandle(l);
765 for (
unsigned j = 0; j < nV; ++j) {
767 readInteger(prop.value, _in, idx);
768 vhandles.push_back(VertexHandle(idx));
772 fh = _bi.add_face(vhandles);
778 readInteger(prop.listIndexType, _in, nV);
780 if (_opt.face_has_texcoord()) {
783 assert(!vhandles.empty());
785 if (nV == 2 * vhandles.size()) {
787 face_texcoords.clear();
788 face_texcoords.reserve(vhandles.size());
790 for (std::size_t j = 0; j < vhandles.size(); j++) {
791 readValue(prop.value, _in, t[0]);
792 readValue(prop.value, _in, t[1]);
794 face_texcoords.push_back(t);
797 _bi.add_face_texcoords(fh, vhandles[0], face_texcoords);
799 }
else if (nV == 3 * vhandles.size()) {
801 face_texcoords3d.clear();
802 face_texcoords3d.reserve(vhandles.size());
804 for (std::size_t j = 0; j < vhandles.size(); j++) {
805 readValue(prop.value, _in, t3d[0]);
806 readValue(prop.value, _in, t3d[1]);
807 readValue(prop.value, _in, t3d[2]);
809 face_texcoords3d.push_back(t3d);
812 _bi.add_face_texcoords(fh, vhandles[0], face_texcoords3d);
823 readInteger(prop.value, _in, idx);
824 _bi.set_face_texindex(fh, idx);
827 if (prop.value == ValueTypeFLOAT32 ||
828 prop.value == ValueTypeFLOAT) {
829 readValue(prop.value, _in, tmp);
832 readInteger(prop.value, _in, c[0]);
835 if (prop.value == ValueTypeFLOAT32 ||
836 prop.value == ValueTypeFLOAT) {
837 readValue(prop.value, _in, tmp);
840 readInteger(prop.value, _in, c[1]);
843 if (prop.value == ValueTypeFLOAT32 ||
844 prop.value == ValueTypeFLOAT) {
845 readValue(prop.value, _in, tmp);
848 readInteger(prop.value, _in, c[2]);
851 if (prop.value == ValueTypeFLOAT32 ||
852 prop.value == ValueTypeFLOAT) {
853 readValue(prop.value, _in, tmp);
856 readInteger(prop.value, _in, c[3]);
860 readCustomProperty<true>(_in, _bi, fh, prop.name, prop.value, prop.listIndexType);
870 if (_opt.face_has_color())
871 _bi.set_color(fh,
Vec4uc(c));
875 for (
unsigned int i = 0; i < e_it->count_ && !_in.eof(); ++i)
877 for (
size_t propertyIndex = 0; propertyIndex < e_it->properties_.size(); ++propertyIndex)
890 omerr() <<
"Unexpected end of file while reading." << std::endl;
894 if (e_it->element_ == FACE)
902 omerr() << complex_faces <<
"The reader encountered invalid faces, that could not be added.\n";
912void _PLYReader_::readValue(ValueType _type, std::istream& _in,
float& _value)
const {
915 case ValueTypeFLOAT32:
921 case ValueTypeDOUBLE:
922 case ValueTypeFLOAT64:
924 readValue(_type, _in, dtmp);
925 _value =
static_cast<float>(dtmp);
929 std::cerr <<
"unsupported conversion type to float: " << _type << std::endl;
938void _PLYReader_::readValue(ValueType _type, std::istream& _in,
double& _value)
const {
942 case ValueTypeFLOAT64:
944 case ValueTypeDOUBLE:
955 std::cerr <<
"unsupported conversion type to double: " << _type << std::endl;
964void _PLYReader_::readValue(ValueType _type, std::istream& _in,
unsigned char& _value)
const{
966 readValue(_type,_in,tmp);
972void _PLYReader_::readValue(ValueType _type, std::istream& _in,
unsigned short& _value)
const{
974 readValue(_type,_in,tmp);
980void _PLYReader_::readValue(ValueType _type, std::istream& _in,
signed char& _value)
const{
982 readValue(_type,_in,tmp);
988void _PLYReader_::readValue(ValueType _type, std::istream& _in,
short& _value)
const{
990 readValue(_type,_in,tmp);
996void _PLYReader_::readValue(ValueType _type, std::istream& _in,
unsigned int& _value)
const {
1006 case ValueTypeUINT32:
1009 _value = tmp_uint32_t;
1013 case ValueTypeUSHORT:
1015 case ValueTypeUINT16:
1018 _value = tmp_uint16_t;
1022 case ValueTypeUCHAR:
1024 case ValueTypeUINT8:
1034 std::cerr <<
"unsupported conversion type to unsigned int: " << _type << std::endl;
1044void _PLYReader_::readValue(ValueType _type, std::istream& _in,
int& _value)
const {
1054 case ValueTypeINT32:
1057 _value = tmp_int32_t;
1061 case ValueTypeSHORT:
1063 case ValueTypeINT16:
1066 _value = tmp_int16_t;
1082 std::cerr <<
"unsupported conversion type to int: " << _type << std::endl;
1092void _PLYReader_::readInteger(ValueType _type, std::istream& _in, T& _value)
const {
1094 static_assert(std::is_integral<T>::value,
"Integral required.");
1105 case ValueTypeINT16:
1107 case ValueTypeSHORT:
1109 _value = tmp_int16_t;
1113 case ValueTypeUINT16:
1115 case ValueTypeUSHORT:
1117 _value = tmp_uint16_t;
1123 case ValueTypeINT32:
1126 _value = tmp_int32_t;
1132 case ValueTypeUINT32:
1135 _value = tmp_uint32_t;
1148 case ValueTypeUCHAR:
1150 case ValueTypeUINT8:
1160 std::cerr <<
"unsupported conversion type to integral: " << _type << std::endl;
1175 std::ifstream ifs(_filename.c_str());
1188std::string get_property_name(std::string _string1, std::string _string2) {
1190 if (_string1 ==
"float32" || _string1 ==
"float64" || _string1 ==
"float" || _string1 ==
"double" ||
1191 _string1 ==
"int8" || _string1 ==
"uint8" || _string1 ==
"char" || _string1 ==
"uchar" ||
1192 _string1 ==
"int32" || _string1 ==
"uint32" || _string1 ==
"int" || _string1 ==
"uint" ||
1193 _string1 ==
"int16" || _string1 ==
"uint16" || _string1 ==
"short" || _string1 ==
"ushort")
1196 if (_string2 ==
"float32" || _string2 ==
"float64" || _string2 ==
"float" || _string2 ==
"double" ||
1197 _string2 ==
"int8" || _string2 ==
"uint8" || _string2 ==
"char" || _string2 ==
"uchar" ||
1198 _string2 ==
"int32" || _string2 ==
"uint32" || _string2 ==
"int" || _string2 ==
"uint" ||
1199 _string2 ==
"int16" || _string2 ==
"uint16" || _string2 ==
"short" || _string2 ==
"ushort")
1203 std::cerr <<
"Unsupported entry type" << std::endl;
1204 return "Unsupported";
1209_PLYReader_::ValueType get_property_type(
const std::string& _string1,
const std::string& _string2) {
1211 if (_string1 ==
"float32" || _string2 ==
"float32")
1213 return _PLYReader_::ValueTypeFLOAT32;
1215 else if (_string1 ==
"float64" || _string2 ==
"float64")
1217 return _PLYReader_::ValueTypeFLOAT64;
1219 else if (_string1 ==
"float" || _string2 ==
"float")
1221 return _PLYReader_::ValueTypeFLOAT;
1223 else if (_string1 ==
"double" || _string2 ==
"double")
1225 return _PLYReader_::ValueTypeDOUBLE;
1227 else if (_string1 ==
"int8" || _string2 ==
"int8")
1229 return _PLYReader_::ValueTypeINT8;
1231 else if (_string1 ==
"uint8" || _string2 ==
"uint8")
1233 return _PLYReader_::ValueTypeUINT8;
1235 else if (_string1 ==
"char" || _string2 ==
"char")
1237 return _PLYReader_::ValueTypeCHAR;
1239 else if (_string1 ==
"uchar" || _string2 ==
"uchar")
1241 return _PLYReader_::ValueTypeUCHAR;
1243 else if (_string1 ==
"int32" || _string2 ==
"int32")
1245 return _PLYReader_::ValueTypeINT32;
1247 else if (_string1 ==
"uint32" || _string2 ==
"uint32")
1249 return _PLYReader_::ValueTypeUINT32;
1251 else if (_string1 ==
"int" || _string2 ==
"int")
1253 return _PLYReader_::ValueTypeINT;
1255 else if (_string1 ==
"uint" || _string2 ==
"uint")
1257 return _PLYReader_::ValueTypeUINT;
1259 else if (_string1 ==
"int16" || _string2 ==
"int16")
1261 return _PLYReader_::ValueTypeINT16;
1263 else if (_string1 ==
"uint16" || _string2 ==
"uint16")
1265 return _PLYReader_::ValueTypeUINT16;
1267 else if (_string1 ==
"short" || _string2 ==
"short")
1269 return _PLYReader_::ValueTypeSHORT;
1271 else if (_string1 ==
"ushort" || _string2 ==
"ushort")
1273 return _PLYReader_::ValueTypeUSHORT;
1275 return _PLYReader_::Unsupported;
1290 texture_files_.clear();
1294 std::getline(_is, line);
1298 const size_t s = line.size();
1299 if( s > 0 && line[s - 1] ==
'\r') line.resize(s - 1);
1302 if (line !=
"PLY" && line !=
"ply")
1307 vertexDimension_ = 0;
1309 unsigned int elementCount = 0;
1311 std::string keyword;
1312 std::string fileType;
1313 std::string elementName =
"";
1314 std::string propertyName;
1315 std::string listIndexType;
1316 std::string listEntryType;
1324 omerr() <<
"Defect PLY header detected" << std::endl;
1328 if (fileType ==
"ascii") {
1330 }
else if (fileType ==
"binary_little_endian") {
1336 }
else if (fileType ==
"binary_big_endian") {
1343 omerr() <<
"Unsupported PLY format: " << fileType << std::endl;
1347 std::streamoff streamPos = _is.tellg();
1349 while (keyword !=
"end_header") {
1351 if (keyword ==
"comment") {
1352 std::getline(_is, line);
1357 if (line.rfind(
" TextureFile ", 0) == 0) {
1358 std::string filename = line.substr(13);
1364 texture_files_.push_back(filename);
1366 }
else if (keyword ==
"element") {
1368 _is >> elementCount;
1370 ElementInfo element;
1371 element.name_ = elementName;
1372 element.count_ = elementCount;
1374 if (elementName ==
"vertex") {
1375 vertexCount_ = elementCount;
1376 element.element_ = VERTEX;
1377 }
else if (elementName ==
"face") {
1378 faceCount_ = elementCount;
1379 element.element_ = FACE;
1381 omerr() <<
"PLY header unsupported element type: " << elementName << std::endl;
1382 element.element_ = UNKNOWN;
1385 elements_.push_back(element);
1386 }
else if (keyword ==
"property") {
1392 if (tmp1 ==
"list") {
1393 _is >> listIndexType;
1394 _is >> listEntryType;
1395 _is >> propertyName;
1397 ValueType indexType = Unsupported;
1398 ValueType entryType = Unsupported;
1400 if (listIndexType ==
"uint8") {
1401 indexType = ValueTypeUINT8;
1402 }
else if (listIndexType ==
"uint16") {
1403 indexType = ValueTypeUINT16;
1404 }
else if (listIndexType ==
"uchar") {
1405 indexType = ValueTypeUCHAR;
1406 }
else if (listIndexType ==
"int") {
1407 indexType = ValueTypeINT;
1409 omerr() <<
"Unsupported Index type for property list: " << listIndexType << std::endl;
1413 entryType = get_property_type(listEntryType, listEntryType);
1415 if (entryType == Unsupported) {
1416 omerr() <<
"Unsupported Entry type for property list: " << listEntryType << std::endl;
1419 PropertyInfo property(CUSTOM_PROP, entryType, propertyName);
1420 property.listIndexType = indexType;
1422 if (elementName ==
"face")
1425 if (propertyName ==
"vertex_index" || propertyName ==
"vertex_indices")
1427 property.property = VERTEX_INDICES;
1429 if (!elements_.back().properties_.empty())
1431 omerr() <<
"Custom face Properties defined, before 'vertex_indices' property was defined. They will be skipped" << std::endl;
1432 elements_.back().properties_.clear();
1434 }
else if (propertyName ==
"texcoord")
1436 property.property = TEXCOORD;
1445 omerr() <<
"property " << propertyName <<
" belongs to unsupported element " << elementName << std::endl;
1447 elements_.back().properties_.push_back(property);
1459 ValueType valueType = get_property_type(tmp1, tmp2);
1460 propertyName = get_property_name(tmp1, tmp2);
1465 if (elementName ==
"vertex") {
1466 if (propertyName ==
"x") {
1469 }
else if (propertyName ==
"y") {
1472 }
else if (propertyName ==
"z") {
1475 }
else if (propertyName ==
"nx") {
1478 }
else if (propertyName ==
"ny") {
1481 }
else if (propertyName ==
"nz") {
1484 }
else if (propertyName ==
"u" || propertyName ==
"s") {
1487 }
else if (propertyName ==
"v" || propertyName ==
"t") {
1490 }
else if (propertyName ==
"red") {
1493 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1495 }
else if (propertyName ==
"green") {
1498 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1500 }
else if (propertyName ==
"blue") {
1503 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1505 }
else if (propertyName ==
"diffuse_red") {
1508 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1510 }
else if (propertyName ==
"diffuse_green") {
1513 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1515 }
else if (propertyName ==
"diffuse_blue") {
1518 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1520 }
else if (propertyName ==
"alpha") {
1524 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1528 else if (elementName ==
"face") {
1529 if (propertyName ==
"red") {
1532 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1534 }
else if (propertyName ==
"green") {
1537 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1539 }
else if (propertyName ==
"blue") {
1542 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1544 }
else if (propertyName ==
"alpha") {
1548 if (valueType == ValueTypeFLOAT || valueType == ValueTypeFLOAT32)
1550 }
else if (propertyName ==
"texnumber") {
1557 if (entry.value == Unsupported){
1558 Property prop = CUSTOM_PROP;
1563 if (entry.property != UNSUPPORTED)
1565 elements_.back().properties_.push_back(entry);
1570 omlog() <<
"Unsupported keyword : " << keyword << std::endl;
1573 streamPos = _is.tellg();
1576 omerr() <<
"Error while reading PLY file header" << std::endl;
1584 _is.seekg(streamPos);
1591 if (c1 == 0x0D && c2 == 0x0A) {
1592 _is.seekg(streamPos + 14);
1595 _is.seekg(streamPos + 12);
PropertyT< T > & property(VPropHandleT< T > _ph)
void add_property(VPropHandleT< T > &_ph, const std::string &_name="<vprop>")
bool get_property_handle(VPropHandleT< T > &_ph, const std::string &_name) const
virtual bool can_u_read(const std::string &_filename) const
Returns true if writer can parse _filename (checks extension). _filename can also provide an extensio...
Set options for reader/writer modules.
void cleanup(void)
Restore state after default constructor.
void clear(void)
Clear all bits.
@ ColorFloat
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files)
@ Swap
Swap byte order in binary mode.
@ FaceColor
Has (r) / store (w) face colors.
@ FaceTexCoord
Has (r) / store (w) face texture coordinates.
@ MSB
Assume big endian byte ordering.
@ Binary
Set binary mode for r/w.
@ ColorAlpha
Has (r) / store (w) alpha values for colors.
@ LSB
Assume little endian byte ordering.
@ VertexNormal
Has (r) / store (w) vertex normals.
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
@ VertexColor
Has (r) / store (w) vertex colors.
@ Custom
Has (r) / store (w) custom properties marked persistent (currently PLY only supports reading and only...
bool register_module(BaseReader *_bl)
std::map< ValueType, int > scalar_size_
Stores sizes of property types.
Options options_
Available per file options for reading.
bool read(const std::string &_filename, BaseImporter &_bi, Options &_opt) override
bool can_u_read(const std::string &_filename) const override
Returns true if writer can parse _filename (checks extension). _filename can also provide an extensio...
Options userOptions_
Options that the user wants to read.
void consume_input(std::istream &_in, int _count) const
Read unsupported properties in PLY file.
Scalar value_type
the type of the scalar used in this template
Cellection of information about a property.
_PLYReader_ __PLYReaderInstance
Declare the single entity of the PLY reader.
_IOManager_ & IOManager()
VectorT< unsigned char, 4 > Vec4uc
Handle for a face entity.
Handle for a vertex entity.