Skip to main content

SurfaceModel

Trait SurfaceModel 

Source
pub trait SurfaceModel: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn prepare(&self, config: &Config) -> Result<Arc<dyn SurfaceInstance>>;

    // Provided methods
    fn doc(&self) -> String { ... }
    fn params(&self) -> Vec<ParamSpec> { ... }
    fn example_config(&self) -> Option<Config> { ... }
    fn flip(&self, config: &Config, how: Flip) -> Result<Option<Config>> { ... }
}
Expand description

利用者定義の面のモデル(設定から SurfaceInstance を作る)

Required Methods§

Source

fn name(&self) -> &str

登録の名前

Source

fn prepare(&self, config: &Config) -> Result<Arc<dyn SurfaceInstance>>

設定を確かめて面を作る

Provided Methods§

Source

fn doc(&self) -> String

1 行の説明

Source

fn params(&self) -> Vec<ParamSpec>

設定の項目(GUI の欄・一覧用)

Source

fn example_config(&self) -> Option<Config>

試しの設定(拡張の検査で check_flip に渡す)。既定は SurfaceModel::params の既定値を並べたもの (既定値の無い項目があれば None。そのときは自分で返す)

Source

fn flip(&self, config: &Config, how: Flip) -> Result<Option<Config>>

面を裏返した面の設定(鏡の後に置く・玉を反転するときに使う)。None は「対応しない」で、そのとき鏡の後や 反転では誤りになる(既定)。

約束(check_flip で確かめられる):

  • 2 回裏返すと元の設定に戻る(flip(flip(c, how), how) == c)
  • 裏返した面の SurfaceInstance::deflect は元の面を映したものと一致する: 映す行列 M(Flip::Z は z → −z、Flip::X は x → −x)で、裏返した面の deflect(p, k) の方向は M · (元の deflect(M p, M k) の方向)、 OPD に足す光路長は同じ
  • SurfaceInstance::paraxial_power は同じ(近軸の屈折力は理想レンズの焦点距離と同じく光の向きによらない)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§