nbis/
minutia.rs

1#[derive(Debug, Clone, PartialEq, uniffi::Enum)]
2pub enum MinutiaKind {
3    RidgeEnding = 1, // 1 = ridge ending
4    Bifurcation = 2, // 0 = bifurcation
5}
6
7#[derive(uniffi::Record)]
8pub struct Position {
9    pub x: i32,
10    pub y: i32,
11}
12
13/// A lightweight, fully-safe copy of one minutia.
14/// (Add more fields if you need them.)
15#[derive(Debug, Clone, uniffi::Object)]
16pub struct Minutia {
17    pub(crate) x: i32,
18    pub(crate) y: i32,
19    pub(crate) direction: i32,
20    pub(crate) reliability: f64, // 0.0 to 1.0
21    pub(crate) kind: MinutiaKind,
22}
23
24#[uniffi::export]
25impl Minutia {
26    /// Get the angle in degrees (0-360) for this minutia starting from the X axis (east).
27    pub fn angle(&self) -> f64 {
28        let angle = 90.0 - self.direction as f64 * 11.25;
29        (angle % 360.0 + 360.0) % 360.0 // Ensures result is in [0, 360)
30    }
31
32    pub fn x(&self) -> i32 {
33        self.x
34    }
35
36    pub fn y(&self) -> i32 {
37        self.y
38    }
39
40    /// Get the position as a tuple (x, y).
41    pub fn position(&self) -> Position {
42        Position {
43            x: self.x,
44            y: self.y,
45        }
46    }
47
48    /// Get the reliability score (0.0 to 1.0).
49    pub fn reliability(&self) -> f64 {
50        self.reliability
51    }
52
53    /// Get the kind of minutia (ridge ending or bifurcation).
54    pub fn kind(&self) -> MinutiaKind {
55        self.kind.clone()
56    }
57}