emarf_path_json/
pathjson.rs

1// Example code that deserializes and serializes the model.
2// extern crate serde;
3// #[macro_use]
4// extern crate serde_derive;
5// extern crate serde_json;
6//
7// use generated_module::pathjson;
8//
9// fn main() {
10//     let json = r#"{"answer": 42}"#;
11//     let model: pathjson = serde_json::from_str(&json).unwrap();
12// }
13
14use serde::{Serialize, Deserialize};
15
16/// pathjsonのスキーマ
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct Pathjson {
19    /// 材料の幅と奥行きのリスト ¥n 対応した板サイズのbinがないとCAM側でエラーが出る
20    pub bins: Vec<Bin>,
21
22    /// コスト情報
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub cost: Option<Cost>,
25
26    /// 材料を半分にカットするパスを生成するか (true/false)
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub cut_sheet: Option<bool>,
29
30    /// 仕上げ情報
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub finish: Option<Finish>,
33
34    /// 材料情報
35    pub material: Material,
36
37    /// ミル径
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub mill: Option<f64>,
40
41    /// 部材のバウンディングボックスでネスティングを行うか (true/false)
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub nest_bbox: Option<bool>,
44
45    /// ネスティングの有無 (true/false)
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub nesting: Option<bool>,
48
49    /// 塗装情報
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub paint: Option<Paint>,
52
53    /// 部材ごとのパス情報
54    pub paths: Vec<Path>,
55
56    pub plugin: Plugin,
57
58    /// ビス生成の有無 (true/false)
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub screw: Option<bool>,
61
62    /// ビスの位置
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub screws: Option<Vec<Screw>>,
65
66    /// CAMでタブをつけるか
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub tab: Option<bool>,
69
70    /// 材料の厚さ
71    pub thickness: f64,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct Bin {
76    /// 材料奥行き
77    pub depth: f64,
78
79    /// 材料幅
80    pub width: f64,
81}
82
83/// コスト情報
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct Cost {
86    /// 時間あたりの切削コスト
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub cutting_cost_per_hour: Option<f64>,
89}
90
91/// 仕上げ情報
92#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct Finish {
94    /// バリ取りの有無
95    pub burr: bool,
96
97    /// サンディングの有無
98    pub sanding: bool,
99}
100
101/// 材料情報
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct Material {
104    /// 許容量
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub allowance: Option<f64>,
107
108    /// ジョグ移動速度
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub jog_speed: Option<f64>,
111
112    /// 荒削りミル径
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub mill_ara: Option<f64>,
115
116    /// 仕上げ削りミル径
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub mill_shiage: Option<f64>,
119
120    /// 加工高さ
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub path_height: Option<f64>,
123
124    /// ポケット加工ステップ
125    #[serde(skip_serializing_if = "Option::is_none")]
126    pub pocket_step: Option<f64>,
127
128    /// 材料価格
129    #[serde(skip_serializing_if = "Option::is_none")]
130    pub price: Option<f64>,
131
132    /// 回転速度
133    #[serde(skip_serializing_if = "Option::is_none")]
134    pub rotation_speed: Option<f64>,
135
136    /// 3D加工時の回転速度
137    #[serde(rename = "rotation_speed_3d")]
138    #[serde(skip_serializing_if = "Option::is_none")]
139    pub rotation_speed_3_d: Option<f64>,
140
141    /// タブ設定
142    #[serde(skip_serializing_if = "Option::is_none")]
143    pub tab: Option<Tab>,
144
145    /// Vビット加工高さ
146    #[serde(skip_serializing_if = "Option::is_none")]
147    pub v_bit_path_height: Option<f64>,
148
149    /// XY軸移動速度
150    #[serde(skip_serializing_if = "Option::is_none")]
151    pub xy_speed: Option<f64>,
152
153    /// Z軸移動速度
154    #[serde(skip_serializing_if = "Option::is_none")]
155    pub z_speed: Option<f64>,
156}
157
158/// タブ設定
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct Tab {
161    /// タブ高さ
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub height: Option<f64>,
164
165    /// タブ幅
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub width: Option<f64>,
168}
169
170/// 塗装情報
171#[derive(Debug, Clone, Serialize, Deserialize)]
172pub struct Paint {
173    /// 塗装単価
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub unit_cost: Option<f64>,
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize)]
179pub struct Path {
180    /// 外周パスの頂点リスト
181    pub ex_path: Vec<Point2D>,
182
183    /// 印字角度
184    #[serde(skip_serializing_if = "Option::is_none")]
185    pub font_angle: Option<f64>,
186
187    /// 印字サイズ
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub font_size: Option<f64>,
190
191    /// 内周パスの頂点リスト
192    pub in_paths: Vec<Vec<Point2D>>,
193
194    /// 部材ラベル ¥n
195    /// https://github.com/vuildjp/gh_webgl_interpreter/blob/9c71514760682f4c3ef12045ff6fbf57a45058ac/src/assets/javascripts/sbp/SBPVisualizer.js#L524
196    /// で使用するからrequiredにしている
197    pub label: String,
198
199    /// 部材名 ¥n CAMのparserではNoneの処理をしているのに、これがないと謎のエラーが出るっぽいのでrequiredにしている
200    #[serde(skip_serializing_if = "Option::is_none")]
201    pub name: Option<String>,
202
203    /// 部材数
204    pub num: i64,
205
206    /// ポケット深さのリスト
207    pub po_deepness: Vec<f64>,
208
209    /// ポケットパスの情報
210    pub pocket: Vec<Pocket>,
211
212    /// 配置されるシート番号
213    #[serde(skip_serializing_if = "Option::is_none")]
214    pub sheet: Option<i64>,
215
216    /// 3D単一パスの頂点リスト
217    #[serde(rename = "single_3d")]
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub single_3_d: Option<Vec<Vec<Point3D>>>,
220
221    /// 単一パス深さのリスト
222    #[serde(skip_serializing_if = "Option::is_none")]
223    pub single_deepness: Option<Vec<f64>>,
224
225    /// 単一パスの頂点リスト ¥n
226    /// https://github.com/vuildjp/gh_webgl_interpreter/blob/9c71514760682f4c3ef12045ff6fbf57a45058ac/src/assets/javascripts/nesting/part.js#L274
227    /// で使用するからrequiredにしている
228    pub single_paths: Vec<Vec<Point2D>>,
229
230    /// 印字開始点
231    #[serde(skip_serializing_if = "Option::is_none")]
232    pub start_point: Option<Vec<f64>>,
233
234    /// STLデータ
235    #[serde(skip_serializing_if = "Option::is_none")]
236    pub stl: Option<Vec<Stl>>,
237
238    #[serde(skip_serializing_if = "Option::is_none")]
239    pub tabs: Option<Tabs>,
240}
241
242#[derive(Debug, Clone, Serialize, Deserialize)]
243pub struct Point2D {
244    /// X座標
245    pub x: f64,
246
247    /// Y座標
248    pub y: f64,
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize)]
252pub struct Pocket {
253    /// 外側ポケットの頂点リスト
254    pub ex_pocket: Vec<Point2D>,
255
256    /// 内側ポケットの頂点リスト
257    pub in_pocket: Vec<Vec<Point2D>>,
258}
259
260#[derive(Debug, Clone, Serialize, Deserialize)]
261pub struct Point3D {
262    /// X座標
263    pub x: f64,
264
265    /// Y座標
266    pub y: f64,
267
268    /// Z座標
269    pub z: f64,
270}
271
272#[derive(Debug, Clone, Serialize, Deserialize)]
273pub struct Stl {
274    /// STLデータのBase64エンコード
275    pub data: String,
276}
277
278#[derive(Debug, Clone, Serialize, Deserialize)]
279pub struct Tabs {
280    pub result: Result,
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize)]
284pub struct Result {
285    pub exterior: Vec<Point2D>,
286
287    pub interior: Vec<Vec<Point2D>>,
288}
289
290#[derive(Debug, Clone, Serialize, Deserialize)]
291pub struct Plugin {
292    /// プラットフォーム
293    pub platform: String,
294
295    /// バージョン
296    pub version: String,
297}
298
299#[derive(Debug, Clone, Serialize, Deserialize)]
300pub struct Screw {
301    pub position: Vec<Point2D>,
302
303    pub sheet: i64,
304}