Utility functions for triangles meshes
| 121 | |
| 122 | /// Utility functions for triangles meshes |
| 123 | pub trait TriMesh3dExt<R: Real> { |
| 124 | /// Returns the slice of all triangle vertices of the mesh |
| 125 | fn tri_vertices(&self) -> &[Vector3<R>]; |
| 126 | |
| 127 | /// Computes the area of the triangle with the given vertices |
| 128 | fn tri_area_ijk<RComp: Real>(&self, ijk: &[usize; 3]) -> RComp { |
| 129 | let v = self.tri_vertices(); |
| 130 | tri_area(&v[ijk[0]], &v[ijk[1]], &v[ijk[2]]) |
| 131 | } |
| 132 | |
| 133 | /// Computes the face normal of the triangle with the given vertices |
| 134 | fn tri_normal_ijk<RComp: Real>(&self, ijk: &[usize; 3]) -> Vector3<RComp> { |
| 135 | let v = self.tri_vertices(); |
| 136 | tri_normal(&v[ijk[0]], &v[ijk[1]], &v[ijk[2]]) |
| 137 | } |
| 138 | |
| 139 | /// Computes the minimum and maximum angle in the triangle with the given vertices |
| 140 | fn tri_min_max_angles_ijk<RComp: Real>(&self, ijk: &[usize; 3]) -> (RComp, RComp) { |
| 141 | let v = self.tri_vertices(); |
| 142 | tri_min_max_angles(&v[ijk[0]], &v[ijk[1]], &v[ijk[2]]) |
| 143 | } |
| 144 | |
| 145 | /// Computes the aspect ratio of the triangle with the given vertices |
| 146 | fn tri_aspect_ratio<RComp: Real>(&self, ijk: &[usize; 3]) -> RComp { |
| 147 | let v = self.tri_vertices(); |
| 148 | tri_aspect_ratio(&v[ijk[0]], &v[ijk[1]], &v[ijk[2]]) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | impl<R: Real> TriMesh3dExt<R> for TriMesh3d<R> { |
| 153 | fn tri_vertices(&self) -> &[Vector3<R>] { |
nothing calls this directly
no outgoing calls
no test coverage detected