| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef MESH_IO_READER_PLY_H |
| | #define MESH_IO_READER_PLY_H |
| |
|
| | #include <Mod/Mesh/App/Core/MeshKernel.h> |
| | #include <Mod/Mesh/MeshGlobal.h> |
| | #include <iosfwd> |
| |
|
| | namespace Base |
| | { |
| | class InputStream; |
| | } |
| |
|
| | namespace MeshCore |
| | { |
| |
|
| | class MeshKernel; |
| | struct Material; |
| |
|
| | |
| | class MeshExport ReaderPLY |
| | { |
| | public: |
| | |
| | |
| | |
| | explicit ReaderPLY(MeshKernel& kernel, Material* = nullptr); |
| | |
| | |
| | |
| | |
| | bool Load(std::istream& input); |
| |
|
| | private: |
| | bool CheckHeader(std::istream& input) const; |
| | bool ReadHeader(std::istream& input); |
| | bool VerifyVertexProperty(); |
| | bool VerifyColorProperty(); |
| | bool ReadFormat(std::istream& str); |
| | bool ReadElement(std::istream& str, std::string& element); |
| | bool ReadProperty(std::istream& str, const std::string& element); |
| | bool ReadVertexProperty(std::istream& str); |
| | bool ReadFaceProperty(std::istream& str); |
| | bool ReadVertexes(std::istream& input); |
| | bool ReadFaces(std::istream& input); |
| | bool ReadVertexes(Base::InputStream& is); |
| | bool ReadFaces(Base::InputStream& is); |
| | bool LoadAscii(std::istream& input); |
| | bool LoadBinary(std::istream& input); |
| | void CleanupMesh(); |
| |
|
| | private: |
| | enum Property |
| | { |
| | coord_x, |
| | coord_y, |
| | coord_z, |
| | color_r, |
| | color_g, |
| | color_b, |
| | generic, |
| | num_props |
| | }; |
| |
|
| | static Property propertyOfName(const std::string& name); |
| | using PropertyArray = std::array<float, num_props>; |
| | void addVertexProperty(const PropertyArray& prop); |
| |
|
| | enum Number |
| | { |
| | int8, |
| | uint8, |
| | int16, |
| | uint16, |
| | int32, |
| | uint32, |
| | float32, |
| | float64 |
| | }; |
| |
|
| | struct PropertyComp |
| | { |
| | using argument_type_1st = std::pair<Property, int>; |
| | using argument_type_2nd = Property; |
| | using result_type = bool; |
| |
|
| | |
| | bool operator()(const argument_type_1st& x, |
| | const argument_type_2nd& y) const |
| | { |
| | return x.first == y; |
| | } |
| | |
| | }; |
| |
|
| | enum Format |
| | { |
| | unknown, |
| | ascii, |
| | binary_little_endian, |
| | binary_big_endian |
| | } format = unknown; |
| |
|
| | std::vector<std::pair<Property, Number>> vertex_props; |
| | std::vector<Number> face_props; |
| |
|
| | std::size_t v_count = 0; |
| | std::size_t f_count = 0; |
| | MeshPointArray meshPoints; |
| | MeshFacetArray meshFacets; |
| | MeshKernel& _kernel; |
| | Material* _material; |
| | }; |
| |
|
| | } |
| |
|
| |
|
| | #endif |
| |
|