store status slightly better

This commit is contained in:
Max Lyon
2018-08-08 13:58:02 +02:00
parent bc2fe37aeb
commit c0fa8fcdb0
5 changed files with 72 additions and 7 deletions

View File

@@ -115,7 +115,8 @@ public:
FaceTexCoord = 0x0400, ///< Has (r) / store (w) face texture coordinates FaceTexCoord = 0x0400, ///< Has (r) / store (w) face texture coordinates
ColorAlpha = 0x0800, ///< Has (r) / store (w) alpha values for colors 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) 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) custom properties (currently only implemented in PLY Reader ASCII version)
Status = 0x4000 ///< Has (r) / store (w) status properties
}; };
public: public:
@@ -206,10 +207,14 @@ public:
bool vertex_has_normal() const { return check(VertexNormal); } bool vertex_has_normal() const { return check(VertexNormal); }
bool vertex_has_color() const { return check(VertexColor); } bool vertex_has_color() const { return check(VertexColor); }
bool vertex_has_texcoord() const { return check(VertexTexCoord); } bool vertex_has_texcoord() const { return check(VertexTexCoord); }
bool vertex_has_status() const { return check(Status); }
bool edge_has_color() const { return check(EdgeColor); } bool edge_has_color() const { return check(EdgeColor); }
bool edge_has_status() const { return check(Status); }
bool halfedge_has_status() const { return check(Status); }
bool face_has_normal() const { return check(FaceNormal); } bool face_has_normal() const { return check(FaceNormal); }
bool face_has_color() const { return check(FaceColor); } bool face_has_color() const { return check(FaceColor); }
bool face_has_texcoord() const { return check(FaceTexCoord); } bool face_has_texcoord() const { return check(FaceTexCoord); }
bool face_has_status() const { return check(Status); }
bool color_has_alpha() const { return check(ColorAlpha); } bool color_has_alpha() const { return check(ColorAlpha); }
bool color_is_float() const { return check(ColorFloat); } bool color_is_float() const { return check(ColorFloat); }

View File

@@ -158,10 +158,14 @@ public:
virtual bool is_triangle_mesh() const { return false; } virtual bool is_triangle_mesh() const { return false; }
virtual bool has_vertex_normals() const { return false; } virtual bool has_vertex_normals() const { return false; }
virtual bool has_vertex_colors() const { return false; } virtual bool has_vertex_colors() const { return false; }
virtual bool has_vertex_status() const { return false; }
virtual bool has_vertex_texcoords() const { return false; } virtual bool has_vertex_texcoords() const { return false; }
virtual bool has_edge_colors() const { return false; } virtual bool has_edge_colors() const { return false; }
virtual bool has_edge_status() const { return false; }
virtual bool has_halfedge_status() const { return false; }
virtual bool has_face_normals() const { return false; } virtual bool has_face_normals() const { return false; }
virtual bool has_face_colors() const { return false; } virtual bool has_face_colors() const { return false; }
virtual bool has_face_status() const { return false; }
}; };

View File

@@ -345,9 +345,13 @@ public:
bool has_vertex_normals() const { return mesh_.has_vertex_normals(); } bool has_vertex_normals() const { return mesh_.has_vertex_normals(); }
bool has_vertex_colors() const { return mesh_.has_vertex_colors(); } bool has_vertex_colors() const { return mesh_.has_vertex_colors(); }
bool has_vertex_texcoords() const { return mesh_.has_vertex_texcoords2D(); } bool has_vertex_texcoords() const { return mesh_.has_vertex_texcoords2D(); }
bool has_vertex_status() const { return mesh_.has_vertex_status(); }
bool has_edge_colors() const { return mesh_.has_edge_colors(); } bool has_edge_colors() const { return mesh_.has_edge_colors(); }
bool has_edge_status() const { return mesh_.has_edge_status(); }
bool has_halfedge_status() const { return mesh_.has_halfedge_status(); }
bool has_face_normals() const { return mesh_.has_face_normals(); } bool has_face_normals() const { return mesh_.has_face_normals(); }
bool has_face_colors() const { return mesh_.has_face_colors(); } bool has_face_colors() const { return mesh_.has_face_colors(); }
bool has_face_status() const { return mesh_.has_face_status(); }
private: private:

View File

@@ -417,6 +417,58 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
#endif #endif
} }
// ---------- write vertex status
if (_be.n_vertices() && _be.has_vertex_status() && _opt.check(Options::Status))
{
//store status as costum property because that already works
auto prop = _be.kernel()->_get_vprop("v:status");
assert(prop != nullptr);
bool persistent = prop->persistent();
const_cast<BaseProperty*>(prop)->set_persistent(true);
bytes += store_binary_custom_chunk(_os, *prop,
OMFormat::Chunk::Entity_Vertex, swap );
const_cast<BaseProperty*>(prop)->set_persistent(persistent);
}
// ---------- write edge status
if (_be.n_edges() && _be.has_edge_status() && _opt.check(Options::Status))
{
//store status as costum property because that already works
auto prop = _be.kernel()->_get_eprop("e:status");
assert(prop != nullptr);
bool persistent = prop->persistent();
const_cast<BaseProperty*>(prop)->set_persistent(true);
bytes += store_binary_custom_chunk(_os, *prop,
OMFormat::Chunk::Entity_Edge, swap );
const_cast<BaseProperty*>(prop)->set_persistent(persistent);
}
// ---------- write halfedge status
if (_be.n_edges() && _be.has_halfedge_status() && _opt.check(Options::Status))
{
//store status as costum property because that already works
auto prop = _be.kernel()->_get_hprop("h:status");
assert(prop != nullptr);
bool persistent = prop->persistent();
const_cast<BaseProperty*>(prop)->set_persistent(true);
bytes += store_binary_custom_chunk(_os, *prop,
OMFormat::Chunk::Entity_Halfedge, swap );
const_cast<BaseProperty*>(prop)->set_persistent(persistent);
}
// ---------- write face status
if (_be.n_faces() && _be.has_face_status() && _opt.check(Options::Status))
{
//store status as costum property because that already works
auto prop = _be.kernel()->_get_fprop("f:status");
assert(prop != nullptr);
bool persistent = prop->persistent();
const_cast<BaseProperty*>(prop)->set_persistent(true);
bytes += store_binary_custom_chunk(_os, *prop,
OMFormat::Chunk::Entity_Face, swap );
const_cast<BaseProperty*>(prop)->set_persistent(persistent);
}
// -------------------- write custom properties // -------------------- write custom properties
@@ -426,7 +478,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->vprops_end(); ++prop) prop != _be.kernel()->vprops_end(); ++prop)
{ {
if ( !*prop ) continue; if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "v:status")) continue; if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop, bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Vertex, swap ); OMFormat::Chunk::Entity_Vertex, swap );
} }
@@ -434,7 +486,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->fprops_end(); ++prop) prop != _be.kernel()->fprops_end(); ++prop)
{ {
if ( !*prop ) continue; if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "f:status")) continue; if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop, bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Face, swap ); OMFormat::Chunk::Entity_Face, swap );
} }
@@ -442,7 +494,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->eprops_end(); ++prop) prop != _be.kernel()->eprops_end(); ++prop)
{ {
if ( !*prop ) continue; if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "e:status")) continue; if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop, bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Edge, swap ); OMFormat::Chunk::Entity_Edge, swap );
} }
@@ -450,7 +502,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->hprops_end(); ++prop) prop != _be.kernel()->hprops_end(); ++prop)
{ {
if ( !*prop ) continue; if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "h:status")) continue; if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop, bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Halfedge, swap ); OMFormat::Chunk::Entity_Halfedge, swap );
} }

View File

@@ -723,8 +723,8 @@ TEST_F(OpenMeshReadWriteOM, WriteSplitTriangleStatusProperties) {
} }
// save // save
OpenMesh::IO::Options options; OpenMesh::IO::Options options = OpenMesh::IO::Options::Status;
bool ok = OpenMesh::IO::write_mesh(mesh,filename); bool ok = OpenMesh::IO::write_mesh(mesh,filename, options);
EXPECT_TRUE(ok) << "Unable to write "<<filename; EXPECT_TRUE(ok) << "Unable to write "<<filename;
// load // load