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
#![cfg_attr(feature = "unstable", feature(test, core_intrinsics, trace_macros))]

#[macro_use]
extern crate gut_derive;

#[macro_use]
pub mod index;

pub mod bbox;
pub mod interval;
pub mod ops;
pub mod prim;

pub mod algo;
pub mod mesh;

#[cfg(feature = "io")]
pub mod io;

pub(crate) mod utils {
    #[cfg(feature = "rayon")]
    pub mod chashset;
    pub mod math;
}

// public re-exports
pub use self::index::Index;
pub use crate::mesh::topology::*;

/// Plain old data trait. Types that implement this trait contain no references and can be copied
/// with `memcpy`. The additional `Any` trait lets us inspect the type more easily.
pub trait Pod: 'static + Copy + Sized + Send + Sync + std::any::Any {}
impl<T> Pod for T where T: 'static + Copy + Sized + Send + Sync + std::any::Any {}

pub trait Real: math::BaseNum + math::BaseFloat + num_traits::Float + ::std::fmt::Debug + std::iter::Sum + Pod {}
impl<T> Real for T where T: math::BaseNum + math::BaseFloat + num_traits::Float + ::std::fmt::Debug + std::iter::Sum + Pod {}

// Temporary utils to wrap unsafe reinterpret casts into a safe API.
pub(crate) fn index_vec_into_usize(vec: Vec<Index>) -> Vec<usize> {
    unsafe { reinterpret::reinterpret_vec(vec) }
}

pub(crate) fn into_flat_vec3(vec: Vec<[usize; 3]>) -> Vec<usize> {
    unsafe { reinterpret::reinterpret_vec(vec) }
}

pub(crate) fn into_flat_vec4(vec: Vec<[usize; 4]>) -> Vec<usize> {
    unsafe { reinterpret::reinterpret_vec(vec) }
}

pub(crate) fn into_chunked_vec3(vec: Vec<usize>) -> Vec<[usize; 3]> {
    unsafe { reinterpret::reinterpret_vec(vec) }
}

pub(crate) fn into_chunked_vec4(vec: Vec<usize>) -> Vec<[usize; 4]> {
    unsafe { reinterpret::reinterpret_vec(vec) }
}

pub(crate) fn into_flat_slice3(slice: &[[usize; 3]]) -> &[usize] {
    unsafe { reinterpret::reinterpret_slice(slice) }
}

pub(crate) fn into_flat_slice4(slice: &[[usize; 4]]) -> &[usize] {
    unsafe { reinterpret::reinterpret_slice(slice) }
}