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
#![warn(
missing_docs,
missing_debug_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unused_import_braces,
unused_qualifications
)]
extern crate truck_topology as topology;
pub mod base {
pub use truck_base::{bounding_box::*, cgmath64::*, geom_traits::*, tolerance::*};
}
pub use base::*;
#[derive(Clone, Debug, Default)]
pub struct PolygonMesh {
pub positions: Vec<Point3>,
pub uv_coords: Vec<Vector2>,
pub normals: Vec<Vector3>,
pub tri_faces: Vec<[[usize; 3]; 3]>,
pub quad_faces: Vec<[[usize; 3]; 4]>,
pub other_faces: Vec<Vec<[usize; 3]>>,
}
#[derive(Clone, Debug)]
pub struct StructuredMesh {
pub positions: Vec<Vec<Point3>>,
pub uv_division: (Vec<f64>, Vec<f64>),
pub normals: Vec<Vec<Vector3>>,
}
#[doc(hidden)]
#[derive(Clone, Debug)]
pub struct MeshHandler {
mesh: PolygonMesh,
}
pub mod errors;
mod extract_topology;
mod healing;
mod mesh_handler;
mod meshing_shape;
pub mod obj;
mod polygon_mesh;
mod smoothing;
mod splitting;
mod structured_mesh;
mod structuring;
#[inline(always)]
fn get_tri<T: Clone>(face: &[T], idx0: usize, idx1: usize, idx2: usize) -> [T; 3] {
[face[idx0].clone(), face[idx1].clone(), face[idx2].clone()]
}
trait CosAngle {
fn cos_angle(&self, other: &Self) -> f64;
}
impl CosAngle for Vector3 {
fn cos_angle(&self, other: &Self) -> f64 {
self.dot(*other) / (self.magnitude() * other.magnitude())
}
}