Skip to main content

GerberLayerData

Struct GerberLayerData 

Source
pub struct GerberLayerData {
    pub layer_type: LayerType,
    pub coordinate_format: CoordinateFormat,
    pub commands: Vec<Command>,
    pub macros: HashMap<String, Vec<MacroContent>>,
    pub apertures: HashMap<i32, Aperture>,
    /* private fields */
}
Expand description

A parsed RS-274X (Extended Gerber) layer, split into its logical components.

Constructed via GerberLayerData::from_type, GerberLayerData::from_commands, or GerberLayerData::empty. Written back with GerberLayerData::write_to.

The internal unit is always millimetres; GerberLayerData::to_unit performs conversion if the source file uses inches.

Fields§

§layer_type: LayerType

Logical role of this layer (copper top, silkscreen bottom, …).

§coordinate_format: CoordinateFormat

Integer/decimal digit counts used to encode coordinates in the file.

§commands: Vec<Command>

Draw commands stripped of header/footer boilerplate.

§macros: HashMap<String, Vec<MacroContent>>

Aperture macros keyed by name.

§apertures: HashMap<i32, Aperture>

Aperture definitions keyed by D-code number.

Implementations§

Source§

impl GerberLayerData

Source

pub fn new(ty: LayerType, data: GerberDoc) -> Result<Self, ParseError>

Creates a new layer from already loaded gerber doc and its layer type

Source

pub fn from_type<R>( ty: LayerType, reader: BufReader<R>, ) -> Result<Self, ParseError>
where R: Read,

Parses GerberLayer from reader with given type

Source

pub fn from_commands<R>(reader: BufReader<R>) -> Result<Self, ParseError>
where R: Read,

Parses GerberLayer from reader, type will load from FileAttribute

Source

pub fn empty(layer_type: LayerType) -> Self

Creates an empty gerber layer

Source

pub fn is_empty(&self) -> bool

Checks if layer is empty

Source

pub fn to_unit(self, unit: &Unit) -> Self

Converts all commands to given Unit

Source

pub fn write_to<T>(&self, writer: &mut BufWriter<T>) -> GerberResult<()>
where T: Write,

Writes to given output

Trait Implementations§

Source§

impl Clone for GerberLayerData

Source§

fn clone(&self) -> GerberLayerData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GerberLayerData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<GerberLayerData> for Board

Source§

fn from(data: GerberLayerData) -> Self

Creates a board containing a single Gerber layer.

Source§

impl From<GerberLayerData> for Layer

Source§

fn from(data: GerberLayerData) -> Self

Wraps a GerberLayerData in a Layer.

The name is set to the default file extension for the layer type (e.g. "gto" for SilkScreenTop). Override layer.name afterwards if a specific filename is needed.

Source§

impl From<GerberLayerData> for LayerData

Source§

fn from(value: GerberLayerData) -> Self

Converts to this type from the input type.
Source§

impl LayerCorners for GerberLayerData

Source§

fn get_corners(&self) -> (Pos, Pos)

Returns the axis-aligned bounding box as (min, max). Read more
Source§

fn get_size(&self) -> Size

Returns the bounding-box dimensions derived from get_corners.
Source§

impl LayerMerge for GerberLayerData

Source§

fn merge(&mut self, other: &Self)

Appends other into self. Read more
Source§

fn merge_from(&mut self, other: impl Into<Self>)

Converts other into Self and merges it. Read more
Source§

impl LayerScale for GerberLayerData

Source§

fn scale(&mut self, x: f64, y: f64)

Multiplies every X coordinate by x and every Y coordinate by y.
Source§

impl LayerStepAndRepeat for GerberLayerData

Source§

fn step_and_repeat( &mut self, x_repetitions: u32, y_repetitions: u32, offset: &Pos, )

Tiles the layer x_repetitions × y_repetitions times. Read more
Source§

impl LayerTransform for GerberLayerData

Source§

fn transform(&mut self, pos: &Pos)

Shifts all coordinates by transform (mm).
Source§

impl PartialEq for GerberLayerData

Source§

fn eq(&self, other: &GerberLayerData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for GerberLayerData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.