Struct ply_rs::writer::Writer
[−]
[src]
pub struct Writer<E: PropertyAccess> { /* fields omitted */ }
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();
Methods
impl<E: PropertyAccess> Writer<E>
[src]
fn new() -> Self
[src]
Create a new Writer<E>
where E
is the element type. To get started quickly use DefaultElement
.
fn write_ply<T: Write>(&self, out: &mut T, ply: &mut Ply<E>) -> Result<usize>
[src]
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.
fn write_ply_unchecked<T: Write>(
&self,
out: &mut T,
ply: &Ply<E>
) -> Result<usize>
[src]
&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.
impl<E: PropertyAccess> Writer<E>
[src]
fn write_line_magic_number<T: Write>(&self, out: &mut T) -> Result<usize>
[src]
Writes the magic number "ply" and a new line.
Each PLY file must start with "ply\n".
fn write_line_format<T: Write>(
&self,
out: &mut T,
encoding: &Encoding,
version: &Version
) -> Result<usize>
[src]
&self,
out: &mut T,
encoding: &Encoding,
version: &Version
) -> Result<usize>
Writes "format
Each PLY file must define its format.
fn write_line_comment<T: Write>(
&self,
out: &mut T,
comment: &Comment
) -> Result<usize>
[src]
&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.
fn write_line_obj_info<T: Write>(
&self,
out: &mut T,
obj_info: &ObjInfo
) -> Result<usize>
[src]
&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.
fn write_line_element_definition<T: Write>(
&self,
out: &mut T,
element: &ElementDef
) -> Result<usize>
[src]
&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.
fn write_line_property_definition<T: Write>(
&self,
out: &mut T,
property: &PropertyDef
) -> Result<usize>
[src]
&self,
out: &mut T,
property: &PropertyDef
) -> Result<usize>
Writes a property line form the header: "property [list
Make sure the property definition is consistent with the payload.
fn write_element_definition<T: Write>(
&self,
out: &mut T,
element: &ElementDef
) -> Result<usize>
[src]
&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.
fn write_line_end_header<T: Write>(&self, out: &mut T) -> Result<usize>
[src]
Writes end_header\n
. This terminates the header. Each following byte belongs to the payload.
fn write_header<T: Write>(&self, out: &mut T, header: &Header) -> Result<usize>
[src]
Convenience method to write all header elements.
It starts with writing the magic number "ply\n" and ends with "end_header".
Make sure the header is consistent with the payload.
impl<E: PropertyAccess> Writer<E>
[src]
fn write_payload<T: Write>(
&self,
out: &mut T,
payload: &Payload<E>,
header: &Header
) -> Result<usize>
[src]
&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.
fn write_payload_of_element<T: Write>(
&self,
out: &mut T,
element_list: &Vec<E>,
element_def: &ElementDef,
header: &Header
) -> Result<usize>
[src]
&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.
impl<E: PropertyAccess> Writer<E>
[src]
fn write_ascii_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
[src]
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
Write a single ascii formatted element.
impl<E: PropertyAccess> Writer<E>
[src]
fn write_big_endian_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
[src]
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
Write a single binary formatted element in big endian.
fn write_little_endian_element<T: Write>(
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
[src]
&self,
out: &mut T,
element: &E,
element_def: &ElementDef
) -> Result<usize>
Write a single binary formatted element in little endian.