Skip to main content

oxiphysics_geometry/geodesic/
types.rs

1//! Auto-generated module
2//!
3//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
4
5#[allow(unused_imports)]
6use super::functions::*;
7#[allow(unused_imports)]
8use super::functions_2::*;
9/// A single geodesic isoline segment on the mesh.
10#[derive(Debug, Clone)]
11pub struct IsolineSegment {
12    /// Start point of the segment.
13    pub start: [f64; 3],
14    /// End point of the segment.
15    pub end: [f64; 3],
16}
17/// A geodesic Voronoi cell: the set of mesh vertices closest to a given source.
18#[derive(Debug, Clone)]
19#[allow(dead_code)]
20pub struct GeoVoronoiCell {
21    /// Index into the sources array.
22    pub source_idx: usize,
23    /// Original source vertex index.
24    pub source_vertex: usize,
25    /// Vertex indices assigned to this cell.
26    pub vertices: Vec<usize>,
27    /// Total surface area of this cell (sum of proportional triangle areas).
28    pub area: f64,
29}
30/// Result of intrinsic Delaunay triangulation.
31#[derive(Debug, Clone)]
32pub struct IntrinsicDelaunay {
33    /// Edge lengths for each face edge: `edge_lengths[fi][k]` is the length of
34    /// edge opposite to local vertex `k` in face `fi`.
35    pub edge_lengths: Vec<[f64; 3]>,
36    /// Face connectivity (same as input but potentially with flipped edges).
37    pub faces: Vec<[usize; 3]>,
38    /// Vertex positions (unchanged from input).
39    pub vertices: Vec<[f64; 3]>,
40}
41/// A simple triangle mesh for geodesic computation.
42#[derive(Debug, Clone)]
43pub struct GeoMesh {
44    /// Vertex positions.
45    pub vertices: Vec<[f64; 3]>,
46    /// Triangle face indices (each entry is \[v0, v1, v2\]).
47    pub faces: Vec<[usize; 3]>,
48}
49impl GeoMesh {
50    /// Create a new geodesic mesh.
51    pub fn new(vertices: Vec<[f64; 3]>, faces: Vec<[usize; 3]>) -> Self {
52        Self { vertices, faces }
53    }
54    /// Number of vertices.
55    pub fn n_vertices(&self) -> usize {
56        self.vertices.len()
57    }
58    /// Number of faces.
59    pub fn n_faces(&self) -> usize {
60        self.faces.len()
61    }
62    /// Build an adjacency list: for each vertex, list all neighbouring vertex
63    /// indices along with the edge length.
64    pub fn build_adjacency(&self) -> Vec<Vec<(usize, f64)>> {
65        let n = self.vertices.len();
66        let mut adj: Vec<Vec<(usize, f64)>> = vec![Vec::new(); n];
67        for face in &self.faces {
68            let [a, b, c] = *face;
69            let lab = dist3(self.vertices[a], self.vertices[b]);
70            let lbc = dist3(self.vertices[b], self.vertices[c]);
71            let lca = dist3(self.vertices[c], self.vertices[a]);
72            adj[a].push((b, lab));
73            adj[b].push((a, lab));
74            adj[b].push((c, lbc));
75            adj[c].push((b, lbc));
76            adj[c].push((a, lca));
77            adj[a].push((c, lca));
78        }
79        adj
80    }
81    /// Compute the area of a triangular face.
82    pub fn face_area(&self, face_idx: usize) -> f64 {
83        let [a, b, c] = self.faces[face_idx];
84        let va = self.vertices[a];
85        let vb = self.vertices[b];
86        let vc = self.vertices[c];
87        let ab = sub3(vb, va);
88        let ac = sub3(vc, va);
89        len3(cross3(ab, ac)) * 0.5
90    }
91    /// Compute the normal of a triangular face (not normalised).
92    pub fn face_normal_raw(&self, face_idx: usize) -> [f64; 3] {
93        let [a, b, c] = self.faces[face_idx];
94        let ab = sub3(self.vertices[b], self.vertices[a]);
95        let ac = sub3(self.vertices[c], self.vertices[a]);
96        cross3(ab, ac)
97    }
98}
99/// Result of the heat method geodesic computation.
100pub struct HeatGeodesicResult {
101    /// Geodesic distances from the source vertex to all vertices.
102    pub distances: Vec<f64>,
103    /// Normalised heat gradient (per face, not per vertex) for debugging.
104    pub gradient: Vec<[f64; 3]>,
105}
106/// Entry for the Dijkstra priority queue.
107#[derive(PartialEq)]
108pub(super) struct DijkEntry {
109    pub(super) dist: f64,
110    pub(super) vertex: usize,
111}