Skip to content

Commit

Permalink
new public api to query if the file is binary or ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiakopoulos committed Jan 25, 2020
1 parent fa00b8f commit 5ac4ee7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void read_ply_file(const std::string & filepath, const bool preload_into_memory
PlyFile file;
file.parse_header(*file_stream);

std::cout << "\t[ply_header] Type: " << (file.is_binary_file() ? "binary" : "ascii") << std::endl;
for (const auto & c : file.get_comments()) std::cout << "\t[ply_header] Comment: " << c << std::endl;
for (const auto & c : file.get_info()) std::cout << "\t[ply_header] Info: " << c << std::endl;

Expand Down
4 changes: 3 additions & 1 deletion source/tinyply.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,12 @@ namespace tinyply

/*
* These functions are valid after a call to `parse_header(...)`. In the case of
* writing, get_comments() may also be used to add new comments to the ply header.
* writing, get_comments() reference may also be used to add new comments to the ply header.
*/
std::vector<PlyElement> get_elements() const;
std::vector<std::string> get_info() const;
std::vector<std::string> & get_comments();
bool is_binary_file() const;

/*
* In the general case where |list_size_hint| is zero, `read` performs a two-pass
Expand Down Expand Up @@ -903,6 +904,7 @@ void PlyFile::write(std::ostream & os, bool isBinary) { return impl->write(os, i
std::vector<PlyElement> PlyFile::get_elements() const { return impl->elements; }
std::vector<std::string> & PlyFile::get_comments() { return impl->comments; }
std::vector<std::string> PlyFile::get_info() const { return impl->objInfo; }
bool PlyFile::is_binary_file() const { return impl->isBinary; }
std::shared_ptr<PlyData> PlyFile::request_properties_from_element(const std::string & elementKey,
const std::initializer_list<std::string> propertyKeys,
const uint32_t list_size_hint)
Expand Down

0 comments on commit 5ac4ee7

Please sign in to comment.