dxfscan 0.1.0

Binary DXF parser with typed entity data and lookup indices
Documentation
// SPDX-License-Identifier: ISC
use crate::point::Point3;
use crate::value::GroupValue;

/// A TRACE entity — a filled quadrilateral (same layout as SOLID).
#[derive(Debug, Clone, Copy, Default)]
pub struct Trace {
    /// First corner.
    pub first_corner: Point3,
    /// Second corner.
    pub second_corner: Point3,
    /// Third corner.
    pub third_corner: Point3,
    /// Fourth corner.
    pub fourth_corner: Point3,
    /// Extrusion thickness.
    pub thickness: f64,
}

impl Trace {
    pub(crate) fn feed(&mut self, code: u16, val: &GroupValue) {
        if let Some(v) = val.as_f64() {
            match code {
                10 => self.first_corner.x = v,
                20 => self.first_corner.y = v,
                30 => self.first_corner.z = v,
                11 => self.second_corner.x = v,
                21 => self.second_corner.y = v,
                31 => self.second_corner.z = v,
                12 => self.third_corner.x = v,
                22 => self.third_corner.y = v,
                32 => self.third_corner.z = v,
                13 => self.fourth_corner.x = v,
                23 => self.fourth_corner.y = v,
                33 => self.fourth_corner.z = v,
                39 => self.thickness = v,
                _ => {}
            }
        }
    }
}