1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#![cfg_attr(not(debug_assertions), deny(warnings))]
#![deny(clippy::all, rust_2018_idioms)]
#![warn(
missing_docs,
missing_debug_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces,
unused_qualifications
)]
use serde::{Deserialize, Serialize};
pub mod base {
pub use truck_base::{bounding_box::*, cgmath64::*, hash, hash::HashGen, tolerance::*};
pub use truck_geotrait::*;
}
pub use base::*;
pub trait Attributes<V> {
type Output;
fn get(&self, vertex: V) -> Option<Self::Output>;
}
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct StandardAttributes {
pub positions: Vec<Point3>,
pub uv_coords: Vec<Vector2>,
pub normals: Vec<Vector3>,
}
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub struct StandardAttribute {
pub position: Point3,
pub uv_coord: Option<Vector2>,
pub normal: Option<Vector3>,
}
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct StandardVertex {
pub pos: usize,
pub uv: Option<usize>,
pub nor: Option<usize>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Faces<V = StandardVertex> {
tri_faces: Vec<[V; 3]>,
quad_faces: Vec<[V; 4]>,
other_faces: Vec<Vec<V>>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pub struct PolygonMesh<V = StandardVertex, A = StandardAttributes> {
attributes: A,
faces: Faces<V>,
}
#[derive(Clone, Debug, Serialize)]
pub struct StructuredMesh {
positions: Vec<Vec<Point3>>,
uv_division: Option<(Vec<f64>, Vec<f64>)>,
normals: Option<Vec<Vec<Vector3>>>,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct PolylineCurve<P>(pub Vec<P>);
mod attributes;
pub mod errors;
mod expand;
pub mod faces;
mod meshing_shape;
pub mod obj;
pub mod polygon_mesh;
pub mod polyline_curve;
pub mod stl;
mod structured_mesh;