@@ -2,8 +2,10 @@ use parse_display_derive::{Display, FromStr};
22use schemars:: JsonSchema ;
33use serde:: { Deserialize , Serialize } ;
44
5- use crate :: shared:: { FileExportFormat , FileImportFormat } ;
5+ use crate :: shared:: { FileExportFormat , FileExportFormat2d , FileImportFormat } ;
66
7+ /// AutoCAD drawing interchange format.
8+ pub mod dxf;
79/// Autodesk Filmbox (FBX) format.
810pub mod fbx;
911/// glTF 2.0.
@@ -23,13 +25,29 @@ pub mod stl;
2325/// SolidWorks part (SLDPRT) format.
2426pub mod sldprt;
2527
26- /// Output format specifier.
28+ /// Output 2D format specifier.
2729#[ derive( Clone , Debug , Eq , Hash , PartialEq , Serialize , Deserialize , JsonSchema , Display , FromStr ) ]
2830#[ serde( tag = "type" , rename_all = "snake_case" ) ]
2931#[ display( style = "snake_case" ) ]
3032#[ cfg_attr( feature = "ts-rs" , derive( ts_rs:: TS ) ) ]
3133#[ cfg_attr( feature = "ts-rs" , ts( export_to = "ModelingCmd.ts" ) ) ]
32- pub enum OutputFormat {
34+ pub enum OutputFormat2d {
35+ /// AutoCAD drawing interchange format.
36+ #[ display( "{}: {0}" ) ]
37+ Dxf ( dxf:: export:: Options ) ,
38+ }
39+
40+ /// Alias for backward compatibility.
41+ #[ deprecated( since = "0.2.96" , note = "use `OutputFormat3d` instead" ) ]
42+ pub type OutputFormat = OutputFormat3d ;
43+
44+ /// Output 3D format specifier.
45+ #[ derive( Clone , Debug , Eq , Hash , PartialEq , Serialize , Deserialize , JsonSchema , Display , FromStr ) ]
46+ #[ serde( tag = "type" , rename_all = "snake_case" ) ]
47+ #[ display( style = "snake_case" ) ]
48+ #[ cfg_attr( feature = "ts-rs" , derive( ts_rs:: TS ) ) ]
49+ #[ cfg_attr( feature = "ts-rs" , ts( export_to = "ModelingCmd.ts" ) ) ]
50+ pub enum OutputFormat3d {
3351 /// Autodesk Filmbox (FBX) format.
3452 #[ display( "{}: {0}" ) ]
3553 Fbx ( fbx:: export:: Options ) ,
@@ -53,13 +71,17 @@ pub enum OutputFormat {
5371 Stl ( stl:: export:: Options ) ,
5472}
5573
74+ /// Alias for backward compatibility.
75+ #[ deprecated( since = "0.2.96" , note = "use `InputFormat3d` instead" ) ]
76+ pub type InputFormat = InputFormat3d ;
77+
5678/// Input format specifier.
5779#[ derive( Clone , Debug , Eq , Hash , PartialEq , Serialize , Deserialize , JsonSchema , Display , FromStr ) ]
5880#[ serde( tag = "type" , rename_all = "snake_case" ) ]
5981#[ display( style = "snake_case" ) ]
6082#[ cfg_attr( feature = "ts-rs" , derive( ts_rs:: TS ) ) ]
6183#[ cfg_attr( feature = "ts-rs" , ts( export_to = "ModelingCmd.ts" ) ) ]
62- pub enum InputFormat {
84+ pub enum InputFormat3d {
6385 /// Autodesk Filmbox (FBX) format.
6486 #[ display( "{}: {0}" ) ]
6587 Fbx ( fbx:: import:: Options ) ,
@@ -158,66 +180,82 @@ impl VirtualFile {
158180 }
159181}
160182
161- impl From < OutputFormat > for FileExportFormat {
162- fn from ( output_format : OutputFormat ) -> Self {
183+ impl From < OutputFormat3d > for FileExportFormat {
184+ fn from ( output_format : OutputFormat3d ) -> Self {
163185 match output_format {
164- OutputFormat :: Fbx ( _) => Self :: Fbx ,
165- OutputFormat :: Gltf ( _) => Self :: Gltf ,
166- OutputFormat :: Obj ( _) => Self :: Obj ,
167- OutputFormat :: Ply ( _) => Self :: Ply ,
168- OutputFormat :: Step ( _) => Self :: Step ,
169- OutputFormat :: Stl ( _) => Self :: Stl ,
186+ OutputFormat3d :: Fbx ( _) => Self :: Fbx ,
187+ OutputFormat3d :: Gltf ( _) => Self :: Gltf ,
188+ OutputFormat3d :: Obj ( _) => Self :: Obj ,
189+ OutputFormat3d :: Ply ( _) => Self :: Ply ,
190+ OutputFormat3d :: Step ( _) => Self :: Step ,
191+ OutputFormat3d :: Stl ( _) => Self :: Stl ,
192+ }
193+ }
194+ }
195+
196+ impl From < OutputFormat2d > for FileExportFormat2d {
197+ fn from ( output_format : OutputFormat2d ) -> Self {
198+ match output_format {
199+ OutputFormat2d :: Dxf ( _) => Self :: Dxf ,
200+ }
201+ }
202+ }
203+
204+ impl From < FileExportFormat2d > for OutputFormat2d {
205+ fn from ( export_format : FileExportFormat2d ) -> Self {
206+ match export_format {
207+ FileExportFormat2d :: Dxf => OutputFormat2d :: Dxf ( Default :: default ( ) ) ,
170208 }
171209 }
172210}
173211
174- impl From < FileExportFormat > for OutputFormat {
212+ impl From < FileExportFormat > for OutputFormat3d {
175213 fn from ( export_format : FileExportFormat ) -> Self {
176214 match export_format {
177- FileExportFormat :: Fbx => OutputFormat :: Fbx ( Default :: default ( ) ) ,
178- FileExportFormat :: Glb => OutputFormat :: Gltf ( gltf:: export:: Options {
215+ FileExportFormat :: Fbx => OutputFormat3d :: Fbx ( Default :: default ( ) ) ,
216+ FileExportFormat :: Glb => OutputFormat3d :: Gltf ( gltf:: export:: Options {
179217 storage : gltf:: export:: Storage :: Binary ,
180218 ..Default :: default ( )
181219 } ) ,
182- FileExportFormat :: Gltf => OutputFormat :: Gltf ( gltf:: export:: Options {
220+ FileExportFormat :: Gltf => OutputFormat3d :: Gltf ( gltf:: export:: Options {
183221 storage : gltf:: export:: Storage :: Embedded ,
184222 presentation : gltf:: export:: Presentation :: Pretty ,
185223 } ) ,
186- FileExportFormat :: Obj => OutputFormat :: Obj ( Default :: default ( ) ) ,
187- FileExportFormat :: Ply => OutputFormat :: Ply ( Default :: default ( ) ) ,
188- FileExportFormat :: Step => OutputFormat :: Step ( Default :: default ( ) ) ,
189- FileExportFormat :: Stl => OutputFormat :: Stl ( stl:: export:: Options {
224+ FileExportFormat :: Obj => OutputFormat3d :: Obj ( Default :: default ( ) ) ,
225+ FileExportFormat :: Ply => OutputFormat3d :: Ply ( Default :: default ( ) ) ,
226+ FileExportFormat :: Step => OutputFormat3d :: Step ( Default :: default ( ) ) ,
227+ FileExportFormat :: Stl => OutputFormat3d :: Stl ( stl:: export:: Options {
190228 storage : stl:: export:: Storage :: Ascii ,
191229 ..Default :: default ( )
192230 } ) ,
193231 }
194232 }
195233}
196234
197- impl From < InputFormat > for FileImportFormat {
198- fn from ( input_format : InputFormat ) -> Self {
235+ impl From < InputFormat3d > for FileImportFormat {
236+ fn from ( input_format : InputFormat3d ) -> Self {
199237 match input_format {
200- InputFormat :: Fbx ( _) => Self :: Fbx ,
201- InputFormat :: Gltf ( _) => Self :: Gltf ,
202- InputFormat :: Obj ( _) => Self :: Obj ,
203- InputFormat :: Ply ( _) => Self :: Ply ,
204- InputFormat :: Sldprt ( _) => Self :: Sldprt ,
205- InputFormat :: Step ( _) => Self :: Step ,
206- InputFormat :: Stl ( _) => Self :: Stl ,
238+ InputFormat3d :: Fbx ( _) => Self :: Fbx ,
239+ InputFormat3d :: Gltf ( _) => Self :: Gltf ,
240+ InputFormat3d :: Obj ( _) => Self :: Obj ,
241+ InputFormat3d :: Ply ( _) => Self :: Ply ,
242+ InputFormat3d :: Sldprt ( _) => Self :: Sldprt ,
243+ InputFormat3d :: Step ( _) => Self :: Step ,
244+ InputFormat3d :: Stl ( _) => Self :: Stl ,
207245 }
208246 }
209247}
210248
211- impl From < FileImportFormat > for InputFormat {
249+ impl From < FileImportFormat > for InputFormat3d {
212250 fn from ( import_format : FileImportFormat ) -> Self {
213251 match import_format {
214- FileImportFormat :: Fbx => InputFormat :: Fbx ( Default :: default ( ) ) ,
215- FileImportFormat :: Gltf => InputFormat :: Gltf ( Default :: default ( ) ) ,
216- FileImportFormat :: Obj => InputFormat :: Obj ( Default :: default ( ) ) ,
217- FileImportFormat :: Ply => InputFormat :: Ply ( Default :: default ( ) ) ,
218- FileImportFormat :: Sldprt => InputFormat :: Sldprt ( Default :: default ( ) ) ,
219- FileImportFormat :: Step => InputFormat :: Step ( Default :: default ( ) ) ,
220- FileImportFormat :: Stl => InputFormat :: Stl ( Default :: default ( ) ) ,
252+ FileImportFormat :: Fbx => InputFormat3d :: Fbx ( Default :: default ( ) ) ,
253+ FileImportFormat :: Gltf => InputFormat3d :: Gltf ( Default :: default ( ) ) ,
254+ FileImportFormat :: Obj => InputFormat3d :: Obj ( Default :: default ( ) ) ,
255+ FileImportFormat :: Ply => InputFormat3d :: Ply ( Default :: default ( ) ) ,
256+ FileImportFormat :: Sldprt => InputFormat3d :: Sldprt ( Default :: default ( ) ) ,
257+ FileImportFormat :: Step => InputFormat3d :: Step ( Default :: default ( ) ) ,
258+ FileImportFormat :: Stl => InputFormat3d :: Stl ( Default :: default ( ) ) ,
221259 }
222260 }
223261}
0 commit comments