cadlib/models.rs
1// Code generated for the SimScale cadlib Rust bindings. DO NOT EDIT.
2//! Model types generated from the cadlib JSON schemas.
3
4use serde::{Deserialize, Serialize};
5
6/// Level of faults allowed in tessellation (Supported only for Parasolid models)
7/// Used in quality checks to classify the tessellation faults in three levels: mild, moderate and serious.
8/// The default is `Mild`, which allows only minor faults that do not significantly affect the quality of the tessellation.
9/// `Moderate` allows more significant faults that may affect the quality but are still acceptable for most applications.
10/// `Serious` allows all faults, including those that may result in a poor quality tessellation, and should be used with caution.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
12pub enum AllowedFacetFaultsLevel {
13 #[serde(rename = "mild")]
14 Mild,
15 #[serde(rename = "moderate")]
16 Moderate,
17 #[serde(rename = "serious")]
18 Serious,
19}
20
21/// Parameters for bounding box info query
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct BoundingBoxParameters {
24 /// Ids of faces to measure in addition to the model and its bodies. When
25 /// given, the response also holds the box enclosing all of them and one box
26 /// per face
27 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub faces: Option<Vec<String>>,
29}
30
31/// Response for bounding box query
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct BoundingBoxResponse {
34 /// Bounding box of the entire model
35 #[serde(rename = "modelBoundingBox")]
36 pub model_bounding_box: Box,
37 /// Bounding box of each solid and sheet in the model, keyed by its entity id
38 #[serde(rename = "boundingBoxPerBody")]
39 pub bounding_box_per_body: std::collections::HashMap<String, Box>,
40 /// Single box enclosing all the requested faces. Set only when faces were
41 /// requested
42 #[serde(
43 rename = "facesBoundingBox",
44 default,
45 skip_serializing_if = "Option::is_none"
46 )]
47 pub faces_bounding_box: Option<Box>,
48 /// Bounding box of each requested face, keyed by its face id. Set only when
49 /// faces were requested
50 #[serde(
51 rename = "boundingBoxPerFace",
52 default,
53 skip_serializing_if = "Option::is_none"
54 )]
55 pub bounding_box_per_face: Option<std::collections::HashMap<String, Box>>,
56}
57
58/// 3D bounding box representation
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct Box {
61 /// Minimum X coordinate
62 #[serde(rename = "minX")]
63 pub min_x: f64,
64 /// Minimum Y coordinate
65 #[serde(rename = "minY")]
66 pub min_y: f64,
67 /// Minimum Z coordinate
68 #[serde(rename = "minZ")]
69 pub min_z: f64,
70 /// Maximum X coordinate
71 #[serde(rename = "maxX")]
72 pub max_x: f64,
73 /// Maximum Y coordinate
74 #[serde(rename = "maxY")]
75 pub max_y: f64,
76 /// Maximum Z coordinate
77 #[serde(rename = "maxZ")]
78 pub max_z: f64,
79}
80
81/// Parameters for compute center of gravity query
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct CenterOfGravityParameters {
84 /// Ids of the faces and edges to combine into a single center of gravity, as
85 /// `entities` returns them. Any other entity type fails the query.
86 /// Must not be empty
87 pub entities: Vec<String>,
88}
89
90/// Response for compute center of gravity query
91#[derive(Debug, Clone, Serialize, Deserialize)]
92pub struct CenterOfGravityResponse {
93 /// Center of gravity as a 3D vector
94 pub cog: Vector3,
95}
96
97/// Circle approximating a planar patch
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct CirclePrimitive {
100 /// Center of the circle
101 pub center: Vector3,
102 /// Radius of the circle
103 pub radius: f64,
104 /// Outward normal of the patch
105 pub normal: Vector3,
106}
107
108/// Color information for an entity
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct Color {
111 /// Id of the solid or sheet the color is defined on
112 pub entity_id: String,
113 /// Color in hex format (e.g., "#ff0000")
114 pub color: String,
115}
116
117/// Parameters for get model colors query (empty)
118#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
119pub struct ColorsParameters;
120
121/// Response for get model colors query
122/// List of colors defined on solids and sheets
123pub type ColorsResponse = Vec<Color>;
124
125/// Parameters for detect rotation query
126#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct DetectCommonRotationParameters {
128 /// Ids of the faces to check for common rotation, as `entities` returns them. The query will check if these faces are rotationally aligned and share the same rotation center and axis. Must not be empty
129 pub faces: Vec<String>,
130}
131
132/// Response for detect common rotation query
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct DetectCommonRotationResponse {
135 /// Center of common rotation
136 pub center: Vector3,
137 /// Axis of common rotation
138 pub axis: Vector3,
139}
140
141/// Parameters for detect enclosure query
142#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct DetectEnclosureParameters {
144 /// Point to check for enclosure
145 pub point: Vector3,
146}
147
148/// Response for detect enclosure query
149/// List of solids enclosing the input point
150pub type DetectEnclosureResponse = Vec<String>;
151
152/// Length metric for a single edge
153#[derive(Debug, Clone, Serialize, Deserialize)]
154pub struct EdgeMetric {
155 /// Id of the edge
156 #[serde(rename = "entityId")]
157 pub entity_id: String,
158 /// Length of the edge
159 pub length: f64,
160}
161
162/// Response for entities query — a flat list of all entities.
163///
164/// Each entity references its parents and children by their 0-based index in the list.
165/// Solids and sheets are the top-level entities.
166pub type EntitiesResponse = Vec<Entity>;
167
168/// An entity in the CAD model topology (solids, sheets, faces, edges, vertices).
169#[derive(Debug, Clone, Serialize, Deserialize)]
170pub struct Entity {
171 /// Unique entity id, e.g. `A1_I2_B3_TE4` or `B1_TE2`
172 #[serde(rename = "entityId")]
173 pub entity_id: String,
174 /// Human-readable entity name, e.g. `face_name@body_name`
175 pub name: String,
176 /// Type of the entity
177 pub r#type: EntityType,
178 /// Indices of the children of this entity in this list
179 pub children: Vec<i32>,
180 /// Indices in this list of all entities this entity is a child of.
181 /// Empty for top-level entities, i.e. solids and sheets.
182 /// An entity can have several parents: an edge is usually shared by two faces,
183 /// a vertex by several edges.
184 pub parents: Vec<i32>,
185}
186
187/// Type of entity. A body is never part of the topology, since it is
188/// represented by its top-level solids or sheets.
189#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
190pub enum EntityType {
191 #[serde(rename = "SOLID")]
192 Solid,
193 #[serde(rename = "SHEET")]
194 Sheet,
195 #[serde(rename = "FACE")]
196 Face,
197 #[serde(rename = "EDGE")]
198 Edge,
199 #[serde(rename = "VERTEX")]
200 Vertex,
201}
202
203/// Surface area metric for a single face
204#[derive(Debug, Clone, Serialize, Deserialize)]
205pub struct FaceMetric {
206 /// Id of the face
207 #[serde(rename = "entityId")]
208 pub entity_id: String,
209 /// Surface area of the face
210 pub area: f64,
211}
212
213/// Parameters for comfort maps query
214#[derive(Debug, Clone, Serialize, Deserialize)]
215pub struct GenerateComfortMapDiscParameters {
216 /// Center point of the region of interest on the ground plane. The disc will be generated in a circular region around this center point.
217 pub center: Vector2,
218 /// Height above ground of the region of interest (distance between the center point and the plane where the disc will be generated). Must not be negative
219 pub height: f64,
220 /// Radius of the region of interest on the ground plane (disc will be generated in a circular region with this radius around the center point). Must be greater than zero
221 pub floor_radius: f64,
222 /// Tessellation fineness parameter to control the size of the disc's tessellation,. Must be greater than zero, and large enough that the disc stays under the limit of 100 million triangles
223 pub fineness: f64,
224 /// Ids of the faces that make up the ground (optional)
225 #[serde(default, skip_serializing_if = "Option::is_none")]
226 pub faces: Option<Vec<String>>,
227 /// Height of the ground plane. Defaults to 0 when omitted
228 #[serde(default, skip_serializing_if = "Option::is_none")]
229 pub ground_level: Option<f64>,
230 /// Defines the encoding of the file which contains the disc (optional). With `ascii` or `binary`, or when omitted, the disc is written as a single file; with `zipped-ascii` or `zipped-binary` the result is unpacked into the directory
231 #[serde(default, skip_serializing_if = "Option::is_none")]
232 pub result_encoding: Option<ResultEncoding>,
233}
234
235/// Response for comfort maps query
236#[derive(Debug, Clone, Serialize, Deserialize)]
237pub struct GenerateComfortMapDiscResponse {
238 /// Number of triangles in the tessellated disc. Always greater than zero: a
239 /// disc with no geometry fails the query instead
240 pub number_of_triangles: i32,
241 /// Bounding box of the tessellated disc (optional)
242 #[serde(default, skip_serializing_if = "Option::is_none")]
243 pub bounding_box: Option<Box>,
244}
245
246/// Parameters for material points query
247#[derive(Debug, Clone, Serialize, Deserialize)]
248pub struct MaterialPointsParameters {
249 /// Defines whether one point is computed for the whole model or one per solid
250 /// and sheet. The response sets the matching field and leaves the other unset
251 #[serde(rename = "queryType")]
252 pub query_type: MaterialPointsQueryType,
253}
254
255/// Query type for material points
256#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
257pub enum MaterialPointsQueryType {
258 #[serde(rename = "entireModel")]
259 EntireModel,
260 #[serde(rename = "perBody")]
261 PerBody,
262}
263
264/// Response for material points query
265#[derive(Debug, Clone, Serialize, Deserialize)]
266pub struct MaterialPointsResponse {
267 /// A point inside the model's material. Set when `queryType` is `entireModel`
268 #[serde(
269 rename = "modelMaterialPoint",
270 default,
271 skip_serializing_if = "Option::is_none"
272 )]
273 pub model_material_point: Option<Vector3>,
274 /// A point inside each solid and sheet, keyed by its entity id. Set when
275 /// `queryType` is `perBody`
276 #[serde(
277 rename = "materialPointPerBody",
278 default,
279 skip_serializing_if = "Option::is_none"
280 )]
281 pub material_point_per_body: Option<std::collections::HashMap<String, Vector3>>,
282}
283
284/// Parameters for model metrics query
285// An empty object on the wire, not a null.
286#[allow(clippy::empty_structs_with_brackets)]
287#[derive(Debug, Clone, Serialize, Deserialize)]
288pub struct ModelMetricsParameters {}
289
290/// Response for model metrics query
291#[derive(Debug, Clone, Serialize, Deserialize)]
292pub struct ModelMetricsResponse {
293 /// Sum of the volumes in `solids`
294 #[serde(rename = "modelVolume")]
295 pub model_volume: f64,
296 /// Aggregated surface area of all solids and sheets
297 #[serde(rename = "modelSurfaceArea")]
298 pub model_surface_area: f64,
299 /// Volume and surface area metrics per solid
300 pub solids: Vec<VolumeMetric>,
301 /// Volume and surface area metrics per sheet
302 pub sheets: Vec<VolumeMetric>,
303 /// Surface area metrics per face
304 pub faces: Vec<FaceMetric>,
305 /// Length metrics per edge
306 pub edges: Vec<EdgeMetric>,
307}
308
309/// The kind of primitive that approximates a planar patch
310#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
311pub enum PatchType {
312 #[serde(rename = "rectangle")]
313 Rectangle,
314 #[serde(rename = "circle")]
315 Circle,
316}
317
318/// One patch of adjacent, coplanar faces, together with the primitive approximating it.
319///
320/// `patch_type` names which primitive describes the patch: exactly one of `rectangle` and
321/// `circle` is set, the one `patch_type` names.
322#[derive(Debug, Clone, Serialize, Deserialize)]
323pub struct PlanarPatch {
324 /// The faces that make up this patch
325 pub faces: Vec<String>,
326 /// The kind of primitive that approximates this patch
327 #[serde(rename = "patchType")]
328 pub patch_type: PatchType,
329 /// The rectangle approximating this patch, set when `patch_type` is `rectangle`
330 #[serde(default, skip_serializing_if = "Option::is_none")]
331 pub rectangle: Option<RectanglePrimitive>,
332 /// The circle approximating this patch, set when `patch_type` is `circle`
333 #[serde(default, skip_serializing_if = "Option::is_none")]
334 pub circle: Option<CirclePrimitive>,
335}
336
337/// Parameters for planar patch primitives query
338#[derive(Debug, Clone, Serialize, Deserialize)]
339pub struct PlanarPatchPrimitivesParameters {
340 /// Ids of the planar faces to group into patches, as `entities` returns them. The query fails if any of the given faces is not planar. Must not be empty
341 pub faces: Vec<String>,
342}
343
344/// Response for planar patch primitives query
345#[derive(Debug, Clone, Serialize, Deserialize)]
346pub struct PlanarPatchPrimitivesResponse {
347 /// The patches found among the requested faces
348 pub patches: Vec<PlanarPatch>,
349}
350
351/// Rectangle approximating a planar patch
352#[derive(Debug, Clone, Serialize, Deserialize)]
353pub struct RectanglePrimitive {
354 /// The four corners of the rectangle, counterclockwise around `normal`
355 pub corners: Vec<Vector3>,
356 /// Outward normal of the patch
357 pub normal: Vector3,
358}
359
360/// Encoding format for STL result data, used in some queries to control how the result is encoded (e.g. for comfort map disc)
361#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
362pub enum ResultEncoding {
363 #[serde(rename = "ascii")]
364 Ascii,
365 #[serde(rename = "binary")]
366 Binary,
367 #[serde(rename = "zipped-ascii")]
368 ZippedAscii,
369 #[serde(rename = "zipped-binary")]
370 ZippedBinary,
371}
372
373/// Parameters for the tessellate faces query.
374///
375/// Tessellates a chosen set of faces: each face becomes its own STL file, named
376/// after the face id. A face listed more than once is tessellated only once.
377///
378/// Supported only for Parasolid models.
379#[derive(Debug, Clone, Serialize, Deserialize)]
380pub struct TessellateFacesParameters {
381 /// Ids of the faces to tessellate, as `entities` returns them. Each face is
382 /// tessellated into its own STL file, named after the face id. A face
383 /// requested more than once is tessellated only once. Must not be empty
384 pub faces: Vec<String>,
385 /// Defines the tessellation strategy. Defaults to `chordTol` when omitted
386 #[serde(
387 rename = "tessellationType",
388 default,
389 skip_serializing_if = "Option::is_none"
390 )]
391 pub tessellation_type: Option<TessellationType>,
392 /// Maximum facet width for tessellationType=maxFacetWidth. If omitted, it is
393 /// derived from the size of the face
394 #[serde(
395 rename = "maxFacetWidth",
396 default,
397 skip_serializing_if = "Option::is_none"
398 )]
399 pub max_facet_width: Option<f64>,
400 /// Level of faults allowed in the tessellation. Used in quality checks.
401 /// Defaults to `mild` when omitted
402 #[serde(
403 rename = "allowedFacetFaultsLevel",
404 default,
405 skip_serializing_if = "Option::is_none"
406 )]
407 pub allowed_facet_faults_level: Option<AllowedFacetFaultsLevel>,
408}
409
410/// Response for the tessellate faces query
411#[derive(Debug, Clone, Serialize, Deserialize)]
412pub struct TessellateFacesResponse {
413 /// Unit normal of each requested face, evaluated at the mid point of the
414 /// face, keyed by face id
415 #[serde(rename = "faceNormals")]
416 pub face_normals: std::collections::HashMap<String, Vector3>,
417}
418
419/// Parameters for tessellate query
420#[derive(Debug, Clone, Serialize, Deserialize)]
421pub struct TessellateParameters {
422 /// If true, one STL file is written per face; if false, one per region
423 #[serde(rename = "writeOneFilePerFace")]
424 pub write_one_file_per_face: bool,
425 /// If true, computes the surface area of the tessellation and returns it as
426 /// `tess_surface_area` in the response
427 #[serde(rename = "calculateArea")]
428 pub calculate_area: bool,
429 /// Supported only for Parasolid models. Defines the tessellation strategy.
430 /// Has no default: the query fails with `invalid-parameter` if it is not set
431 #[serde(
432 rename = "tessellationType",
433 default,
434 skip_serializing_if = "Option::is_none"
435 )]
436 pub tessellation_type: Option<TessellationType>,
437 /// Supported only for Parasolid models. Maximum facet width, used when `tessellation_type`
438 /// is `maxFacetWidth`. If omitted, it is computed from the bounding box of the body
439 #[serde(
440 rename = "maxFacetWidth",
441 default,
442 skip_serializing_if = "Option::is_none"
443 )]
444 pub max_facet_width: Option<f64>,
445 /// Supported only for Parasolid models. Level of faults allowed in the tessellation.
446 /// Used in quality checks. Defaults to `mild` when omitted
447 #[serde(
448 rename = "allowedFacetFaultsLevel",
449 default,
450 skip_serializing_if = "Option::is_none"
451 )]
452 pub allowed_facet_faults_level: Option<AllowedFacetFaultsLevel>,
453 /// Supported only for nTop models. Granularity at which the solid's field is sampled.
454 /// Make this smaller to get more triangles and lower max edge length.
455 /// Must be greater than zero. Defaults to 0.0015 when omitted
456 #[serde(
457 rename = "featureSize",
458 default,
459 skip_serializing_if = "Option::is_none"
460 )]
461 pub feature_size: Option<f64>,
462 /// Supported only for nTop models. Controls how much the mesh is decimated.
463 /// Make this higher to get less triangles and higher max edge length.
464 /// Must be greater than zero. Defaults to 10 when omitted
465 #[serde(default, skip_serializing_if = "Option::is_none")]
466 pub adaptivity: Option<f64>,
467 /// Supported only for nTop models. Specifies the maximum allowable length for any edge in the tessellated
468 /// mesh. During refinement, edges longer than this value are subdivided to ensure the
469 /// mesh respects this limit. Must be greater than zero. Defaults to 10 when omitted
470 #[serde(
471 rename = "maxEdgeLength",
472 default,
473 skip_serializing_if = "Option::is_none"
474 )]
475 pub max_edge_length: Option<f64>,
476}
477
478/// Response for tessellation query
479#[derive(Debug, Clone, Serialize, Deserialize)]
480pub struct TessellateResponse {
481 /// Number of bodies in the tessellated geometry
482 #[serde(rename = "numBodies")]
483 pub num_bodies: i32,
484 /// Surface area of the tessellated geometry. Set only when `calculate_area`
485 /// was requested
486 #[serde(
487 rename = "tessSurfaceArea",
488 default,
489 skip_serializing_if = "Option::is_none"
490 )]
491 pub tess_surface_area: Option<f64>,
492}
493
494/// Tessellation strategy (Supported only for Parasolid models)
495/// `ChordTol` controls curve tolerance by specifying the maximum allowable distance between a true curved edge
496/// and the straight-line chords (facet edges) used to approximate it.
497/// The `MaxFacetWidth` strategy uses a maximum facet width to control the maximum size of the facets, which can be more intuitive in some cases.
498/// When using `MaxFacetWidth`, the `maxFacetWidth` parameter controls the maximum width of the facets.
499#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
500pub enum TessellationType {
501 #[serde(rename = "chordTol")]
502 ChordTol,
503 #[serde(rename = "maxFacetWidth")]
504 MaxFacetWidth,
505}
506
507/// 2D vector representation
508#[derive(Debug, Clone, Serialize, Deserialize)]
509pub struct Vector2 {
510 /// X coordinate
511 pub x: f64,
512 /// Y coordinate
513 pub y: f64,
514}
515
516/// 3D vector representation
517#[derive(Debug, Clone, Serialize, Deserialize)]
518pub struct Vector3 {
519 /// X coordinate
520 pub x: f64,
521 /// Y coordinate
522 pub y: f64,
523 /// Z coordinate
524 pub z: f64,
525}
526
527/// Volume and surface area metrics for a single solid or sheet
528#[derive(Debug, Clone, Serialize, Deserialize)]
529pub struct VolumeMetric {
530 /// Id of the solid or sheet
531 #[serde(rename = "entityId")]
532 pub entity_id: String,
533 /// Volume of the entity, when applicable
534 pub volume: f64,
535 /// Surface area of the entity
536 #[serde(rename = "surfaceArea")]
537 pub surface_area: f64,
538}
539
540/// Parameters for compute volume query
541#[derive(Debug, Clone, Serialize, Deserialize)]
542pub struct VolumeParameters {
543 /// Ids of the solids and sheets to measure, as `entities` returns them.
544 /// Must not be empty
545 #[serde(rename = "entityIds")]
546 pub entity_ids: Vec<String>,
547}
548
549/// Response for volume query
550#[derive(Debug, Clone, Serialize, Deserialize)]
551pub struct VolumeResponse {
552 /// Sum of the volumes in `volumes`
553 pub total: f64,
554 /// Volume of each measured entity, keyed by its entity id
555 pub volumes: std::collections::HashMap<String, f64>,
556}