Skip to content

Commit

Permalink
Experimental big-endian support, handle obj_info (#13)
Browse files Browse the repository at this point in the history
* Introduce big endian parsing and writing

* Added and skipped parsing of old obj_info command

* minor changes for formatting and silence errors

* add tests for endianness

* minor cleanup

* change convention to denote little endian rather than swapping

* update readme for endianness

* update tests for new enum

* store obj_info comments, update README

* add change to byteswap strategy
  • Loading branch information
nmwsharp committed Aug 12, 2019
1 parent 826c5ab commit f196c50
Show file tree
Hide file tree
Showing 4 changed files with 568 additions and 25 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Generally speaking, hapPLY uses C++ exceptions to communicate errors-- most of t

- `PLYData::validate()` Perform some basic sanity checks on the object, throwing if any fail. Called internally before writing.

- `PLYData::write(std::string filename, DataFormat format = DataFormat::ASCII)` Write the object to file. Specifying `DataFormat::ASCII` or `DataFormat::Binary` controls the kind of output file.
- `PLYData::write(std::string filename, DataFormat format = DataFormat::ASCII)` Write the object to file. Specifying `DataFormat::ASCII`, `DataFormat::Binary`, or `DataFormat::BinaryBigEndian` controls the kind of output file.

**Accessing and adding data to an object**:

Expand All @@ -137,6 +137,11 @@ Generally speaking, hapPLY uses C++ exceptions to communicate errors-- most of t

- `void addListProperty(std::string propertyName, std::vector<std::vector<T>>& data)` Add a new list property to an element type. `data` must be the same length as the number of elements of that type.

**Misc object options**:

- `std::vector<std::string> PLYData::comments` Comments included in the .ply file, one string per line. These are populated after reading and written when writing.

- `std::vector<std::string> PLYData::objInfoComments` Lines prefaced with `obj_info` included in the .ply file, which are effectively a different kind of comment, one string per line. These seem to be an ad-hoc extension to .ply, but they are pretty common, so we support them.

**Common-case helpers for mesh data**:

Expand All @@ -157,7 +162,7 @@ Generally speaking, hapPLY uses C++ exceptions to communicate errors-- most of t

## Known issues:
- Writing floating-point values of `inf` or `nan` in ASCII mode is not supported, because the .ply format does not specify how they should be written (C++'s ofstream and ifstream don't even treat them consistently). These values work just fine in binary mode.
- The `.ply` file format allows binary files to be big-endian or little-endian; hapPLY only explicitly supports little-endian files, and basically just assumes your machine is little-endian.
- The `.ply` file format allows binary files to be big-endian or little-endian; hapPLY supports both, but the code assumes the platform is little-endian. The codebase is very close to working on big-endian machines, but I don't have one to test on!
- Currently hapPLY does not allow the user to specify a type for the variable which indicates how many elements are in a list; it always uses `uchar` (and throws and error if the data does not fit in a uchar). Note that at least for mesh-like data, popular software only accepts `uchar`.


Expand Down
Loading

0 comments on commit f196c50

Please sign in to comment.