Commit 68770073 by Jan Möbius

Merge branch 'ply_handle_extra_elements' into 'master'

adding support for additional elements in PLY files

See merge request !121
2 parents 7aee8c61 2f70e9a6
Pipeline #4270 for 68770073 passed in 67 minutes 2 seconds
......@@ -165,7 +165,6 @@ private:
mutable unsigned int vertexCount_;
mutable unsigned int faceCount_;
mutable ValueType vertexType_;
mutable uint vertexDimension_;
enum Property {
......@@ -190,8 +189,23 @@ private:
PropertyInfo(Property _p, ValueType _v):property(_p),value(_v),name(""),listIndexType(Unsupported){}
PropertyInfo(Property _p, ValueType _v, const std::string& _n):property(_p),value(_v),name(_n),listIndexType(Unsupported){}
};
mutable std::vector< PropertyInfo > vertexProperties_;
mutable std::vector< PropertyInfo > faceProperties_;
enum Element {
VERTEX,
FACE,
UNKNOWN
};
// Information on the elements
struct ElementInfo
{
Element element_;
std::string name_;
unsigned int count_;
std::vector< PropertyInfo > properties_;
};
mutable std::vector< ElementInfo > elements_;
template<typename T>
inline void read(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::TrueType /*_binary*/) const
......
ply
format ascii 1.0
element vertex 8
property float32 x
property float32 y
property float32 z
element edge 12
property int32 vertex1
property int32 vertex2
element face 6
property list uint8 int32 vertex_indices
end_header
-1 -1 -1
1 -1 -1
1 1 -1
-1 1 -1
-1 -1 1
1 -1 1
1 1 1
-1 1 1
0 1
1 2
2 3
3 0
4 5
5 6
6 7
7 4
6 2
1 5
3 7
4 0
4 0 1 2 3
4 5 4 7 6
4 6 2 1 5
4 3 7 4 0
4 7 3 2 6
4 5 1 0 4
......@@ -692,4 +692,40 @@ TEST_F(OpenMeshReadWritePLY, WriteReadBinaryPLYWithCustomProps) {
//remove(outFilename);
}
/*
* Just load a ply with extra elements
*/
TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithExtraElements) {
mesh_.clear();
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-extra-elements.ply");
EXPECT_TRUE(ok) << "Unable to load cube-minimal-extra-elements.ply";
EXPECT_EQ(8u, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(18u, mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(12u, mesh_.n_faces()) << "The number of loaded faces is not correct!";
}
/*
* Just load a binary ply with extra elements
*/
TEST_F(OpenMeshReadWritePLY, LoadSimpleBinaryPLYWithExtraElements) {
mesh_.clear();
OpenMesh::IO::Options options = OpenMesh::IO::Options::Binary;
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-extra-elements-binary.ply", options);
EXPECT_TRUE(ok) << "Unable to load cube-minimal-extra-elements-binary.ply";
EXPECT_EQ(8u, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(18u, mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(12u, mesh_.n_faces()) << "The number of loaded faces is not correct!";
}
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!