Expand description

Parser for the Common Layer Interface (.cli) file format

The parser is written according to the spec provided here.

This library works by examining the data in place and collecting pointers to the geometry sections. The CLI object consists of a Vec of layers. Each layer in turn contains a Vec of loops and hatches respectively.

Note: In keeping with the performance oriented nature of the library, conversions to real units using the UNITS portion of the header file is not done automatically. Remember to perform the conversion if necessary.

Note: This library does not yet support parsing of ASCII formated files. Nor has it been tested extensively since .cli files are hard to come by. Please feel free to submit bug reports or .cli files for testing.

Examples

Loading and parsing a file

use std::fs::File;
use std::io::prelude::*;
use colain::{
   	CLI,
   	clitype::{LongCLI, ShortCLI}
   };

let mut buf: Vec<u8> = Vec::new();
File::open("example.cli").unwrap().read_to_end(&mut buf).unwrap();

let model = CLI::<LongCLI>::new(&buf).unwrap();

println!("{:?}", model.header());

Iterating on each point of each loop in each layer

See above for how to initialize model

 use colain::Point; // import the Point trait to provide access via .x() and .y()
 for layer in model.iter() {
     for a_loop in layer.iter_loops() {
         for point in a_loop.iter() {
             let x = point.x();
             let y = point.y();
         }
     }
 }

Re-exports

pub use util::*;

Modules

A CLIType must be specified when creating a CLI object.

Produces copies of N elements from the array Yields a ~10% performance bump over returning pointers

Structs

Light abstraction over a CLI file

Collection of hatches inside a Layer

Contains all available CLI header information

Represents a layer of a 3D object

Object representing a loop inside of a Layer

Enums

Errors encountered when parsing a CLI file

Traits

Reinterpret [T; 2] as a point

Reinterpret [T; 4] as two points