Commit c0fa8fcd authored by Max Lyon's avatar Max Lyon

store status slightly better

parent bc2fe37a
Pipeline #7439 failed with stage
in 44 minutes and 38 seconds
......@@ -115,7 +115,8 @@ 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) custom properties (currently only implemented in PLY Reader ASCII version)
Status = 0x4000 ///< Has (r) / store (w) status properties
};
public:
......@@ -206,10 +207,14 @@ public:
bool vertex_has_normal() const { return check(VertexNormal); }
bool vertex_has_color() const { return check(VertexColor); }
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_status() const { return check(Status); }
bool halfedge_has_status() const { return check(Status); }
bool face_has_normal() const { return check(FaceNormal); }
bool face_has_color() const { return check(FaceColor); }
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_is_float() const { return check(ColorFloat); }
......
......@@ -158,10 +158,14 @@ public:
virtual bool is_triangle_mesh() const { return false; }
virtual bool has_vertex_normals() 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_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_colors() const { return false; }
virtual bool has_face_status() const { return false; }
};
......
......@@ -345,9 +345,13 @@ public:
bool has_vertex_normals() const { return mesh_.has_vertex_normals(); }
bool has_vertex_colors() const { return mesh_.has_vertex_colors(); }
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_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_colors() const { return mesh_.has_face_colors(); }
bool has_face_status() const { return mesh_.has_face_status(); }
private:
......
......@@ -417,6 +417,58 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
#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
......@@ -426,7 +478,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->vprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "v:status")) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Vertex, swap );
}
......@@ -434,7 +486,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->fprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "f:status")) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Face, swap );
}
......@@ -442,7 +494,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->eprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "e:status")) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Edge, swap );
}
......@@ -450,7 +502,7 @@ bool _OMWriter_::write_binary(std::ostream& _os, BaseExporter& _be,
prop != _be.kernel()->hprops_end(); ++prop)
{
if ( !*prop ) continue;
if ( ((*prop)->name()[1]==':') && ((*prop)->name() != "h:status")) continue;
if ( (*prop)->name()[1]==':') continue;
bytes += store_binary_custom_chunk(_os, **prop,
OMFormat::Chunk::Entity_Halfedge, swap );
}
......
......@@ -723,8 +723,8 @@ TEST_F(OpenMeshReadWriteOM, WriteSplitTriangleStatusProperties) {
}
// save
OpenMesh::IO::Options options;
bool ok = OpenMesh::IO::write_mesh(mesh,filename);
OpenMesh::IO::Options options = OpenMesh::IO::Options::Status;
bool ok = OpenMesh::IO::write_mesh(mesh,filename, options);
EXPECT_TRUE(ok) << "Unable to write "<<filename;
// load
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment