Skip to main content

lensbench_core/param/
kind_preds.rs

1//! パラメータの種類の分類([`Kind`] の is_* など)
2
3use super::Kind;
4
5impl Kind {
6    /// ピックアップの量([`crate::pickup::Pickup::what`] と元)になる種類
7    pub fn is_pick(&self) -> bool {
8        matches!(
9            self,
10            Kind::Curv
11                | Kind::Radius
12                | Kind::Conic
13                | Kind::Thick
14                | Kind::Dn
15                | Kind::Disp
16                | Kind::Semi
17                | Kind::MechSemi
18                | Kind::Parm(_)
19                | Kind::Before(_)
20                | Kind::After(_)
21                | Kind::Coating
22        )
23    }
24
25    /// ピックアップ・マクロのソルブだけの量(パラメータには使えない)
26    pub fn is_pick_only(&self) -> bool {
27        matches!(
28            self,
29            Kind::Semi | Kind::Parm(_) | Kind::Before(_) | Kind::After(_) | Kind::Coating
30        )
31    }
32
33    /// 多重構成の表の行にだけ使う面の値(半直径・面の無視・開口・面の前後の傾き偏心の値と順序)。最適化の変数・微分には
34    /// 使えない
35    pub fn is_table_only(&self) -> bool {
36        matches!(
37            self,
38            Kind::Semi
39                | Kind::Ignore
40                | Kind::ApMax
41                | Kind::ApMin
42                | Kind::ApDx
43                | Kind::ApDy
44                | Kind::ApType
45                | Kind::Before(_)
46                | Kind::After(_)
47                | Kind::BeforeOrder
48                | Kind::AfterOrder
49                | Kind::ModelNd
50                | Kind::ModelVd
51                | Kind::ModelDpgf
52                | Kind::Tce
53                | Kind::MechSemi
54                | Kind::ChipZone
55                | Kind::CoordRet
56                | Kind::CoordRetSurf
57                | Kind::Material
58                | Kind::Coating
59        ) || self.is_solve_value()
60    }
61
62    /// 座標の戻りの行([`Kind::CoordRet`]・[`Kind::CoordRetSurf`])
63    pub fn is_coord_return(&self) -> bool {
64        matches!(self, Kind::CoordRet | Kind::CoordRetSurf)
65    }
66
67    /// ソルブ・ピックアップの条件の値([`Kind::CurvSolve`]・[`Kind::ThickSolve`]・[`Kind::ParmSolve`])
68    pub fn is_solve_value(&self) -> bool {
69        matches!(
70            self,
71            Kind::CurvSolve(_) | Kind::ThickSolve(_) | Kind::ParmSolve(..)
72        )
73    }
74
75    /// 傾き偏心の値の位置(dx dy tx ty tz)
76    pub fn tilt_index(&self) -> Option<usize> {
77        match self {
78            Kind::Dx => Some(0),
79            Kind::Dy => Some(1),
80            Kind::Tx => Some(2),
81            Kind::Ty => Some(3),
82            Kind::Tz => Some(4),
83            _ => None,
84        }
85    }
86
87    /// 物点の移動(面のパラメータではない)
88    pub fn is_object(&self) -> bool {
89        matches!(self, Kind::ObjX | Kind::ObjY)
90    }
91
92    /// 系の波長
93    pub fn is_wave(&self) -> bool {
94        matches!(self, Kind::Wave(_))
95    }
96
97    /// 面・玉・群に付かない系全体のパラメータ(物点の移動・波長)。[`Param::surf`] は使わない
98    pub fn is_global(&self) -> bool {
99        self.is_object() || self.is_system_value()
100    }
101
102    /// 系の値(波長・重み・主波長・開口・開口の種類・絞りの面・視野)。公差・多重構成の行に使い、最適化の変数・微分には使えない
103    pub fn is_system_value(&self) -> bool {
104        matches!(
105            self,
106            Kind::Wave(_)
107                | Kind::WaveW(_)
108                | Kind::Primary
109                | Kind::Aper
110                | Kind::ApertureType
111                | Kind::Stop
112                | Kind::FieldType
113                | Kind::Temp
114                | Kind::Pres
115                | Kind::Afocal
116                | Kind::ApodType
117                | Kind::Apod
118                | Kind::Aiming
119                | Kind::Ropd
120                | Kind::AimPupil(_)
121                | Kind::InputPol(_)
122                | Kind::FieldX(_)
123                | Kind::FieldY(_)
124                | Kind::FieldW(_)
125                | Kind::FieldVig(..)
126        )
127    }
128
129    /// 玉・群のパラメータ
130    pub fn is_unit(&self) -> bool {
131        matches!(self, Kind::Unit(_))
132    }
133
134    /// 玉・群の剛体の動き(座標系を動かす。面のパラメータの組合せにならない)
135    pub fn is_unit_motion(&self) -> bool {
136        matches!(self, Kind::Unit(u) if u.motion_index().is_some())
137    }
138}