From e097a50a6e8ac267aadd8d0d4bd3b099b9f1b46b Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 6 Feb 2023 10:10:59 +0100 Subject: [PATCH 1/9] only write custom properties if the Custom option is set --- src/OpenMesh/Core/IO/Options.hh | 2 +- src/OpenMesh/Core/IO/writer/OMWriter.cc | 49 +++++++++++++------------ 2 files changed, 26 insertions(+), 25 deletions(-) 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; From 1f096271290d2d94453a266a839a167bd9135dd8 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 6 Feb 2023 16:50:05 +0100 Subject: [PATCH 2/9] only read custom properties if the option includes Option::Custom --- src/OpenMesh/Core/IO/reader/OMReader.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OMReader.cc b/src/OpenMesh/Core/IO/reader/OMReader.cc index b9b9cb4d..f782b641 100644 --- a/src/OpenMesh/Core/IO/reader/OMReader.cc +++ b/src/OpenMesh/Core/IO/reader/OMReader.cc @@ -406,7 +406,8 @@ bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, { Chunk::PropertyName property_type; bytes_ += restore(_is, property_type, _swap); - add_generic_property(property_type, _bi); + if (_opt.check(Options::Custom)) + add_generic_property(property_type, _bi); } bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_vprop(property_name_), header_.n_vertices_, _swap); @@ -563,7 +564,8 @@ bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Op { Chunk::PropertyName property_type; bytes_ += restore(_is, property_type, _swap); - add_generic_property(property_type, _bi); + if (_opt.check(Options::Custom)) + add_generic_property(property_type, _bi); } bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_fprop(property_name_), header_.n_faces_, _swap); @@ -604,7 +606,8 @@ bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Op { Chunk::PropertyName property_type; bytes_ += restore(_is, property_type, _swap); - add_generic_property(property_type, _bi); + if (_opt.check(Options::Custom)) + add_generic_property(property_type, _bi); } bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_eprop(property_name_), header_.n_edges_, _swap); @@ -654,7 +657,8 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi { Chunk::PropertyName property_type; bytes_ += restore(_is, property_type, _swap); - add_generic_property(property_type, _bi); + if (_opt.check(Options::Custom)) + add_generic_property(property_type, _bi); } bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_hprop(property_name_), 2 * header_.n_edges_, _swap); @@ -689,7 +693,7 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi { int next_id_0 = -1; int to_vertex_id_0 = -1; - int face_id_0 = -1; + int face_id_0 = -1; bytes_ += restore( _is, next_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap ); bytes_ += restore( _is, to_vertex_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap ); bytes_ += restore( _is, face_id_0, OMFormat::Chunk::Integer_Size(chunk_header_.bits_), _swap ); @@ -745,7 +749,7 @@ bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi //----------------------------------------------------------------------------- -bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Options & /* _opt */, bool _swap) const +bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Options& _opt , bool _swap) const { using OMFormat::Chunk; @@ -760,7 +764,8 @@ bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Op { Chunk::PropertyName property_type; bytes_ += restore(_is, property_type, _swap); - add_generic_property(property_type, _bi); + if (_opt.check(Options::Custom)) + add_generic_property(property_type, _bi); } bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_mprop(property_name_), 1, _swap); From 0cdab1cade68d3a0aa2e49c010720619dfdc76bb Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 6 Feb 2023 16:50:23 +0100 Subject: [PATCH 3/9] adapt unit tests to require specifying Options::Custom when writing and reading custom properties --- src/Unittests/unittests_read_write_OM.cc | 48 +++++++++++++++--------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/Unittests/unittests_read_write_OM.cc b/src/Unittests/unittests_read_write_OM.cc index 6ba3b741..e18e47b0 100644 --- a/src/Unittests/unittests_read_write_OM.cc +++ b/src/Unittests/unittests_read_write_OM.cc @@ -365,7 +365,9 @@ TEST_F(OpenMeshReadWriteOM, WriteTriangleVertexBoolProperty) { mesh.property(prop,v3) = true; // save - bool ok = OpenMesh::IO::write_mesh(mesh,filename); + OpenMesh::IO::Options opts = OpenMesh::IO::Options::Custom; + + bool ok = OpenMesh::IO::write_mesh(mesh, filename, opts); EXPECT_TRUE(ok) << "Unable to write "<idx() != mesh.property(vertexProp,*vIter)); - EXPECT_FALSE(wrong) << "min one vertex has worng vertex property"; + EXPECT_FALSE(wrong) << "min one vertex has wrong vertex property"; } From ebb000e1670547e7bb42e132512b260a5abe26e4 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 8 Feb 2023 10:25:15 +0100 Subject: [PATCH 4/9] add IO::Options::Custom to reading and writing in unittests_tutorials.cc --- src/Unittests/unittests_tutorials.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index 01881b0f..309d354e 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -781,14 +781,15 @@ TEST_F(OpenMeshTutorials, storing_custom_properties) { EXPECT_TRUE(mesh.mproperty(mprop_map).persistent()) << "property should be persistent"; // write mesh - bool ok = OpenMesh::IO::write_mesh( mesh, "persistence-check.om" ); + IO::Options opts(IO::Options::Custom); + bool ok = OpenMesh::IO::write_mesh(mesh, "persistence-check.om", opts); EXPECT_TRUE(ok) << "Cannot write mesh to file 'persistent-check.om'"; // clear mesh mesh.clear(); //Read back mesh - ok = OpenMesh::IO::read_mesh( mesh, "persistence-check.om" ); + ok = OpenMesh::IO::read_mesh(mesh, "persistence-check.om", opts); EXPECT_TRUE(ok) << "Cannot read mesh from file 'persistence-check.om'"; // check props From 7f3e219b31842ff923e7dd7df36b09d9b01b1d3c Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 8 Feb 2023 13:56:05 +0100 Subject: [PATCH 5/9] add missing OpenMesh:: namespace --- src/Unittests/unittests_tutorials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index 309d354e..fab485ac 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -781,7 +781,7 @@ TEST_F(OpenMeshTutorials, storing_custom_properties) { EXPECT_TRUE(mesh.mproperty(mprop_map).persistent()) << "property should be persistent"; // write mesh - IO::Options opts(IO::Options::Custom); + OpenMesh::IO::Options opts(OpenMesh::IO::Options::Custom); bool ok = OpenMesh::IO::write_mesh(mesh, "persistence-check.om", opts); EXPECT_TRUE(ok) << "Cannot write mesh to file 'persistent-check.om'"; From 133edfb51731d50d1f8740a7f7f6f58dc5ebbc69 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 22 Feb 2023 11:58:55 +0100 Subject: [PATCH 6/9] clarify comment for Custom Option --- src/OpenMesh/Core/IO/Options.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/IO/Options.hh b/src/OpenMesh/Core/IO/Options.hh index cac16812..ab8a498a 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) / store (w) custom properties (currently PLY only supports reading and only ASCII version. OM supports reading and writing) + Custom = 0x2000, ///< Has (r) / store (w) custom properties marked persistent (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 }; From 14c973f44b5f63dc0ca09321b78106e1ddf799f0 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Wed, 22 Feb 2023 13:12:31 +0100 Subject: [PATCH 7/9] Write custom properties to file by default --- src/OpenMesh/Core/IO/Options.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/Options.hh b/src/OpenMesh/Core/IO/Options.hh index 01ae5fee..af1e0ed8 100644 --- a/src/OpenMesh/Core/IO/Options.hh +++ b/src/OpenMesh/Core/IO/Options.hh @@ -97,7 +97,7 @@ public: /// Definitions of %Options for reading and writing. The options can be /// or'ed. enum Flag { - Default = 0x0000, ///< No options + None = 0x0000, ///< No options Binary = 0x0001, ///< Set binary mode for r/w MSB = 0x0002, ///< Assume big endian byte ordering LSB = 0x0004, ///< Assume little endian byte ordering @@ -113,7 +113,8 @@ public: ColorFloat = 0x1000, ///< Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files) Custom = 0x2000, ///< Has (r) / store (w) custom properties marked persistent (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 + TexCoordST = 0x8000, ///< Write texture coordinates as ST instead of UV + Default = Custom, ///< By default write persistent custom properties }; /// Texture filename. This will be written as From c9ab87053ce9f146700ff5bee75050a09ae55b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 27 Feb 2023 13:37:42 +0100 Subject: [PATCH 8/9] MOve to version 10.0 --- CI/ci-linux-build.sh | 4 ++-- CMakeLists.txt | 2 +- README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CI/ci-linux-build.sh b/CI/ci-linux-build.sh index 9cf501a2..48d8173f 100755 --- a/CI/ci-linux-build.sh +++ b/CI/ci-linux-build.sh @@ -69,9 +69,9 @@ else echo "Copying all required libraries of OpenMesh to the systemlib directory" if [ "$BUILD_TYPE" == "release" ]; then - ldd Build/lib/libOpenMeshCore.so.9.1 | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' systemlib + ldd Build/lib/libOpenMeshCore.so.10.0 | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' systemlib else - ldd Build/lib/libOpenMeshCored.so.9.1 | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' systemlib + ldd Build/lib/libOpenMeshCored.so.10.0 | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' systemlib fi fi diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4cb591..e087cb5b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ enable_testing() project (OpenMesh - VERSION 9.1.0 + VERSION 10.0.0 LANGUAGES C CXX ) # Set AUTO UIC/MOC Policy to new for CMAKE 3.17 or higher diff --git a/README.md b/README.md index 11155d6f..faf497ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OpenMesh, 9.1 +# OpenMesh, 10.0 [![](https://gitlab.vci.wth-aachen.de:9000/OpenMesh/OpenMesh/badges/master/pipeline.svg)](https://gitlab.vci.rwth-aachen.de:9000/OpenMesh/OpenMesh/commits/master) From e6e44fcc21148f446921d8ef94e65d63e49d9da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 27 Feb 2023 14:19:58 +0100 Subject: [PATCH 9/9] Updated changelog --- Doc/changelog.docu | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index a3c9b1fa..4ea0a4aa 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -6,7 +6,13 @@ -9.1 (?/?/?) +10.0 (?/?/?) + +Breaking Changes +
    +
  • OM Reader/Writer: Only rad and write custom properties if the Custom option is set (The default option contains this flag).
  • +
+ Tools