pub struct Writer<E: PropertyAccess> { /* private fields */ }
Expand description
Writes a Ply
to a Write
trait.
The simplest function to start with is write_ply()
.
It performs all necessary checks and writes a complete PLY file.
Sometimes you might want to have better control over how much is written.
All other write_
functions are for those cases.
The trade-off is, that then you get responsible to write consistent data.
See Ply::make_consistent()
.
For further information on the PLY file format, consult the official reference.
§Examples
Simplest case of writing an entire PLY file en bloc:
// Get a Ply from somewhere
// let mut ply = ...;
// Get a buffer with `Write` trait.
// For example a file: let buf = std::io::File(".../your.ply").unwrap();
// Create a writer
let w = Writer::new();
// Write your data:
let written = w.write_ply(&mut buf, &mut ply).unwrap();
Implementations§
Source§impl<E: PropertyAccess> Writer<E>
impl<E: PropertyAccess> Writer<E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new Writer<E>
where E
is the element type. To get started quickly use DefaultElement
.
Sourcepub fn write_ply<T: Write>(
&self,
out: &mut T,
ply: &mut Ply<E>,
) -> Result<usize>
pub fn write_ply<T: Write>( &self, out: &mut T, ply: &mut Ply<E>, ) -> Result<usize>
Writes an entire PLY file modeled by ply
to out
, performs consistency chekc.
ply
must be mutable since a consistency check is performed.
If problems can be corrected automatically, ply
will be modified accordingly.
Returns number of bytes written.
Sourcepub fn write_ply_unchecked<T: Write>(
&self,
out: &mut T,
ply: &Ply<E>,
) -> Result<usize>
pub fn write_ply_unchecked<T: Write>( &self, out: &mut T, ply: &Ply<E>, ) -> Result<usize>
Writes an entire PLY file modeled by ply
to out
, performes no consistency check.
Like write_ply
but doesn’t check the input for inconsistency.
The user is responsible to provide a consistent Ply
,
if not, behaviour is undefined and might result
in a corrupted output.
Source§impl<E: PropertyAccess> Writer<E>
impl<E: PropertyAccess> Writer<E>
§Header
Sourcepub fn write_line_magic_number<T: Write>(&self, out: &mut T) -> Result<usize>
pub fn write_line_magic_number<T: Write>(&self, out: &mut T) -> Result<usize>
Writes the magic number “ply” and a new line.
Each PLY file must start with “ply\n”.
Sourcepub fn write_line_format<T: Write>(
&self,
out: &mut T,
encoding: &Encoding,
version: &Version,
) -> Result<usize>
pub fn write_line_format<T: Write>( &self, out: &mut T, encoding: &Encoding, version: &Version, ) -> Result<usize>
Writes “format
Each PLY file must define its format.
Sourcepub fn write_line_comment<T: Write>(
&self,
out: &mut T,
comment: &Comment,
) -> Result<usize>
pub fn write_line_comment<T: Write>( &self, out: &mut T, comment: &Comment, ) -> Result<usize>
Writes a comment line.
A comment must not contain a line break and only consist of ascii characters.
Sourcepub fn write_line_obj_info<T: Write>(
&self,
out: &mut T,
obj_info: &ObjInfo,
) -> Result<usize>
pub fn write_line_obj_info<T: Write>( &self, out: &mut T, obj_info: &ObjInfo, ) -> Result<usize>
Writes an object information line.
An object informatio line must not contain a line break an only consist of ascii characters.
Sourcepub fn write_line_element_definition<T: Write>(
&self,
out: &mut T,
element: &ElementDef,
) -> Result<usize>
pub fn write_line_element_definition<T: Write>( &self, out: &mut T, element: &ElementDef, ) -> Result<usize>
Writes an element line from the header: “element
This line is part of the header. It defines the format of an element. It is directly followed by its property definitions.
Make sure the header is consistent with the payload.
Sourcepub fn write_line_property_definition<T: Write>(
&self,
out: &mut T,
property: &PropertyDef,
) -> Result<usize>
pub fn write_line_property_definition<T: Write>( &self, out: &mut T, property: &PropertyDef, ) -> Result<usize>
Writes a property line form the header: “property [list <index_type> <scalar_type> | <scalar_type> ]”
Make sure the property definition is consistent with the payload.
Sourcepub fn write_element_definition<T: Write>(
&self,
out: &mut T,
element: &ElementDef,
) -> Result<usize>
pub fn write_element_definition<T: Write>( &self, out: &mut T, element: &ElementDef, ) -> Result<usize>
Writes the element line and all the property definitions
Convenience method to call write_line_element_definition
and write_line_property_definition
in the correct way.
Make sure the element definition is consistent with the payload.
Source§impl<E: PropertyAccess> Writer<E>
impl<E: PropertyAccess> Writer<E>
§Payload
Sourcepub fn write_payload<T: Write>(
&self,
out: &mut T,
payload: &Payload<E>,
header: &Header,
) -> Result<usize>
pub fn write_payload<T: Write>( &self, out: &mut T, payload: &Payload<E>, header: &Header, ) -> Result<usize>
Writes the payload of a ply
(ply.playload
).
Make sure the Header is consistent with the payload.
Sourcepub fn write_payload_of_element<T: Write>(
&self,
out: &mut T,
element_list: &Vec<E>,
element_def: &ElementDef,
header: &Header,
) -> Result<usize>
pub fn write_payload_of_element<T: Write>( &self, out: &mut T, element_list: &Vec<E>, element_def: &ElementDef, header: &Header, ) -> Result<usize>
Write all elments as stored in the element_list
.
Make sure the header and the element definition is consistent with the payload.
Source§impl<E: PropertyAccess> Writer<E>
impl<E: PropertyAccess> Writer<E>
§Ascii
Sourcepub fn write_ascii_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef,
) -> Result<usize>
pub fn write_ascii_element<T: Write>( &self, out: &mut T, element: &E, element_def: &ElementDef, ) -> Result<usize>
Write a single ascii formatted element.
Source§impl<E: PropertyAccess> Writer<E>
impl<E: PropertyAccess> Writer<E>
§Binary
Sourcepub fn write_big_endian_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef,
) -> Result<usize>
pub fn write_big_endian_element<T: Write>( &self, out: &mut T, element: &E, element_def: &ElementDef, ) -> Result<usize>
Write a single binary formatted element in big endian.
Sourcepub fn write_little_endian_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef,
) -> Result<usize>
pub fn write_little_endian_element<T: Write>( &self, out: &mut T, element: &E, element_def: &ElementDef, ) -> Result<usize>
Write a single binary formatted element in little endian.