1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Optical surface structure.

use crate::{
    err::Error,
    file::Build,
    geom::{MeshBuilder, SurfaceLinker},
};
use arctk_attr::load;
use std::path::Path;

/// Optical surface.
#[load]
pub struct SurfaceBuilder {
    /// Mesh.
    mesh: MeshBuilder,
    /// Attribute name.
    attr: String,
}

impl Build for SurfaceBuilder {
    type Inst = SurfaceLinker;

    #[inline]
    fn build(self, in_dir: &Path) -> Result<Self::Inst, Error> {
        let mesh = self.mesh.build(in_dir)?;
        Ok(Self::Inst::new(mesh, self.attr))
    }
}