Skip to content

Commit 320f3c2

Browse files
committed
remove float_types.rs
1 parent 4367930 commit 320f3c2

File tree

4 files changed

+24
-68
lines changed

4 files changed

+24
-68
lines changed

src/aabb.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@ pub struct Aabb<T: Scalar> {
66
pub maxs: Point3<T>,
77
}
88

9-
impl<T> Aabb<T> {
9+
impl<T: Scalar + PartialOrd> Aabb<T> {
1010
#[inline]
1111
pub const fn new(mins: Point3<T>, maxs: Point3<T>) -> Self {
1212
Self { mins, maxs }
1313
}
1414

15-
pub fn intersects(&self, other: &Aabb<T>) -> bool {
16-
self.max.x >= other.min.x && self.min.x <= other.max.x &&
17-
self.max.y >= other.min.y && self.min.y <= other.max.y &&
18-
self.max.z >= other.min.z && self.min.z <= other.max.z
15+
#[inline]
16+
pub fn intersects(&self, other: &Self) -> bool {
17+
self.maxs.x >= other.mins.x
18+
&& self.mins.x <= other.maxs.x
19+
&& self.maxs.y >= other.mins.y
20+
&& self.mins.y <= other.maxs.y
21+
&& self.maxs.z >= other.mins.z
22+
&& self.mins.z <= other.maxs.z
23+
}
24+
25+
#[inline]
26+
pub fn center(&self) -> Point3<T> {
27+
Point3::new(
28+
(self.mins.x + self.maxs.x) / T::mixed_from(2.0),
29+
(self.mins.y + self.maxs.y) / T::mixed_from(2.0),
30+
(self.mins.z + self.maxs.z) / T::mixed_from(2.0),
31+
)
1932
}
2033
}

src/float_types.rs

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/io/svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub trait FromSVG: Sized {
383383
fn from_svg(doc: &str) -> Result<Self, IoError>;
384384
}
385385

386-
impl FromSVG for Sketch<()> {
386+
impl<T> FromSVG for Sketch<(), T> {
387387
fn from_svg(doc: &str) -> Result<Self, IoError> {
388388
use svg::node::element::tag::{self, Type::*};
389389
use svg::parser::Event;

src/mesh/bsp_parallel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::mesh::Vertex;
1818
#[cfg(feature = "parallel")]
1919
use crate::math_ndsp::consts::EPSILON;
2020

21-
impl<S: Clone + Send + Sync + Debug> Node<S> {
21+
impl<S: Clone + Send + Sync + Debug, T> Node<S, T> {
2222
/// Invert all polygons in the BSP tree using iterative approach to avoid stack overflow
2323
#[cfg(feature = "parallel")]
2424
pub fn invert(&mut self) {
@@ -47,7 +47,7 @@ impl<S: Clone + Send + Sync + Debug> Node<S> {
4747

4848
/// Parallel version of clip Polygons
4949
#[cfg(feature = "parallel")]
50-
pub fn clip_polygons(&self, polygons: &[Polygon<S>]) -> Vec<Polygon<S>> {
50+
pub fn clip_polygons(&self, polygons: &[Polygon<S, T>]) -> Vec<Polygon<S, T>> {
5151
// If this node has no plane, just return the original set
5252
if self.plane.is_none() {
5353
return polygons.to_vec();
@@ -102,7 +102,7 @@ impl<S: Clone + Send + Sync + Debug> Node<S> {
102102

103103
/// Parallel version of `clip_to` using iterative approach to avoid stack overflow
104104
#[cfg(feature = "parallel")]
105-
pub fn clip_to(&mut self, bsp: &Node<S>) {
105+
pub fn clip_to(&mut self, bsp: &Node<S, T>) {
106106
// Use iterative approach with a stack to avoid recursive stack overflow
107107
let mut stack = vec![self];
108108

@@ -122,7 +122,7 @@ impl<S: Clone + Send + Sync + Debug> Node<S> {
122122

123123
/// Parallel version of `build`.
124124
#[cfg(feature = "parallel")]
125-
pub fn build(&mut self, polygons: &[Polygon<S>]) {
125+
pub fn build(&mut self, polygons: &[Polygon<S, T>]) {
126126
if polygons.is_empty() {
127127
return;
128128
}
@@ -167,7 +167,7 @@ impl<S: Clone + Send + Sync + Debug> Node<S> {
167167

168168
// Parallel slice
169169
#[cfg(feature = "parallel")]
170-
pub fn slice(&self, slicing_plane: &Plane) -> (Vec<Polygon<S>>, Vec<[Vertex; 2]>) {
170+
pub fn slice(&self, slicing_plane: &Plane<T>) -> (Vec<Polygon<S, T>>, Vec<[Vertex; 2]>) {
171171
// Collect all polygons (this can be expensive, but let's do it).
172172
let all_polys = self.all_polygons();
173173

0 commit comments

Comments
 (0)