diff --git a/src/OpenMesh/Core/IO/Options.hh b/src/OpenMesh/Core/IO/Options.hh index 3b5967a2..cac16812 100644 --- a/src/OpenMesh/Core/IO/Options.hh +++ b/src/OpenMesh/Core/IO/Options.hh @@ -110,7 +110,7 @@ public: FaceTexCoord = 0x0400, ///< Has (r) / store (w) face texture coordinates ColorAlpha = 0x0800, ///< Has (r) / store (w) alpha values for colors ColorFloat = 0x1000, ///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files) - Custom = 0x2000, ///< Has (r) custom properties (currently only implemented in PLY Reader ASCII version) + Custom = 0x2000, ///< Has (r) / store (w) custom properties (currently PLY only supports reading and only ASCII version. OM supports reading and writing) Status = 0x4000, ///< Has (r) / store (w) status properties TexCoordST = 0x8000 ///< Write texture coordinates as ST instead of UV }; diff --git a/src/OpenMesh/Core/IO/writer/OMWriter.cc b/src/OpenMesh/Core/IO/writer/OMWriter.cc index 9526c05a..cfe60603 100644 --- a/src/OpenMesh/Core/IO/writer/OMWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OMWriter.cc @@ -562,34 +562,35 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be, // -------------------- write custom properties - - - const auto store_property = [this, &_os, swap, &bytes]( - const BaseKernel::const_prop_iterator _it_begin, - const BaseKernel::const_prop_iterator _it_end, - const OMFormat::Chunk::Entity _ent) + if (_opt.check(Options::Custom)) { - for (auto prop = _it_begin; prop != _it_end; ++prop) + const auto store_property = [this, &_os, swap, &bytes]( + const BaseKernel::const_prop_iterator _it_begin, + const BaseKernel::const_prop_iterator _it_end, + const OMFormat::Chunk::Entity _ent) { - if (!*prop || (*prop)->name().empty() || - ((*prop)->name().size() > 1 && (*prop)->name()[1] == ':')) - { // skip dead and "private" properties (no name or name matches "?:*") - continue; + for (auto prop = _it_begin; prop != _it_end; ++prop) + { + if (!*prop || (*prop)->name().empty() || + ((*prop)->name().size() > 1 && (*prop)->name()[1] == ':')) + { // skip dead and "private" properties (no name or name matches "?:*") + continue; + } + bytes += store_binary_custom_chunk(_os, **prop, _ent, swap); } - bytes += store_binary_custom_chunk(_os, **prop, _ent, swap); - } - }; + }; - store_property(_be.kernel()->vprops_begin(), _be.kernel()->vprops_end(), - OMFormat::Chunk::Entity_Vertex); - store_property(_be.kernel()->fprops_begin(), _be.kernel()->fprops_end(), - OMFormat::Chunk::Entity_Face); - store_property(_be.kernel()->eprops_begin(), _be.kernel()->eprops_end(), - OMFormat::Chunk::Entity_Edge); - store_property(_be.kernel()->hprops_begin(), _be.kernel()->hprops_end(), - OMFormat::Chunk::Entity_Halfedge); - store_property(_be.kernel()->mprops_begin(), _be.kernel()->mprops_end(), - OMFormat::Chunk::Entity_Mesh); + store_property(_be.kernel()->vprops_begin(), _be.kernel()->vprops_end(), + OMFormat::Chunk::Entity_Vertex); + store_property(_be.kernel()->fprops_begin(), _be.kernel()->fprops_end(), + OMFormat::Chunk::Entity_Face); + store_property(_be.kernel()->eprops_begin(), _be.kernel()->eprops_end(), + OMFormat::Chunk::Entity_Edge); + store_property(_be.kernel()->hprops_begin(), _be.kernel()->hprops_end(), + OMFormat::Chunk::Entity_Halfedge); + store_property(_be.kernel()->mprops_begin(), _be.kernel()->mprops_end(), + OMFormat::Chunk::Entity_Mesh); + } memset(&chunk_header, 0, sizeof(chunk_header)); chunk_header.name_ = false;