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
mod bench;

pub mod topology;
pub mod transform_impl;
pub mod builder;

/// Attribute module. This specifies the interface required to read/write attributes
/// from/to different mesh components.
pub mod attrib;

pub mod pointcloud;
pub mod polymesh;
/// Macro to implement constant size slice iterator.
/// This can be used to create an iterator over cells of size 4 for instance like in TetMesh.
//macro_rules! impl_const_slice_iter {
//    ($iter:ident, $iter_mut:ident, [$type:ty;$n:expr]) => {
//        pub struct $iter<'a> {
//            data: &'a [$type],
//        }
//
//        impl<'a> $iter<'a> {
//            pub fn new(data: &'a [$type]) -> Self {
//                $iter {
//                    data
//                }
//            }
//        }
//
//        pub struct $iter_mut<'a> {
//            data: &'a mut [$type],
//        }
//
//        impl<'a> $iter_mut<'a> {
//            pub fn new(data: &'a mut [$type]) -> Self {
//                $iter_mut {
//                    data
//                }
//            }
//        }
//
//        impl<'a> Iterator for $iter<'a> {
//            type Item = &'a [$type;$n];
//
//            #[inline]
//            fn next(&mut self) -> Option<&'a [$type;$n]> {
//                if self.data.is_empty() {
//                    return None;
//                }
//                let (l, r) = self.data.split_at($n);
//                // Convert a slice reference to an array reference.
//                let l_arr = unsafe { &*(l.as_ptr() as *const [$type;$n]) };
//                self.data = r;
//                Some(l_arr)
//            }
//        }
//
//        impl<'a> Iterator for $iter_mut<'a> {
//            type Item = &'a mut [$type;$n];
//
//            #[inline]
//            fn next(&mut self) -> Option<&'a mut [$type;$n]> {
//                use std::mem;
//                if self.data.is_empty() {
//                    return None;
//                }
//
//                // Get a unique mutable reference for data.
//                let slice = mem::replace(&mut self.data, &mut []);
//                let (l, r) = slice.split_at_mut($n);
//                // Convert a slice reference to an array reference.
//                let l_arr = unsafe { &mut *(l.as_mut_ptr() as *mut [$type;$n]) };
//                self.data = r;
//                Some(l_arr)
//            }
//        }
//    }
//}
pub mod tetmesh;
pub mod uniform_poly_mesh;
pub mod vertex_positions;

// Re-export meshes and traits
pub use self::attrib::Attrib;
pub use self::pointcloud::*;
pub use self::polymesh::*;
pub use self::tetmesh::*;
pub use self::uniform_poly_mesh::*;
pub use self::vertex_positions::*; // reexport intrinsic attribute

/*
 * Below we define common mesh classes that can be useful in generic code.
 */

use self::attrib::VertexAttrib;
use self::topology::NumVertices;
use crate::Real;

/// VertexMesh is a marker trait to allow user code to be generic over vertex centric meshes with
/// intrinsic vertex positions attributes.
pub trait VertexMesh<T: Real>:
    Attrib + VertexAttrib + NumVertices + VertexPositions<Element = [T; 3]>
{
}
impl<M, T: Real> VertexMesh<T> for M where
    M: Attrib + VertexAttrib + NumVertices + VertexPositions<Element = [T; 3]>
{
}