mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-25 16:45:52 +00:00
Convert Topology::triangles
into free function
This commit is contained in:
parent
7a7eca5788
commit
b483a5dd4a
@ -11,6 +11,7 @@ use std::{collections::HashMap, time::Instant};
|
|||||||
|
|
||||||
use fj_debug::DebugInfo;
|
use fj_debug::DebugInfo;
|
||||||
use fj_host::Model;
|
use fj_host::Model;
|
||||||
|
use fj_kernel::algorithms::triangulate;
|
||||||
use fj_math::{Aabb, Scalar, Triangle};
|
use fj_math::{Aabb, Scalar, Triangle};
|
||||||
use fj_operations::ToShape as _;
|
use fj_operations::ToShape as _;
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
@ -296,10 +297,12 @@ impl ShapeProcessor {
|
|||||||
|
|
||||||
let mut debug_info = DebugInfo::new();
|
let mut debug_info = DebugInfo::new();
|
||||||
let mut triangles = Vec::new();
|
let mut triangles = Vec::new();
|
||||||
shape
|
triangulate(
|
||||||
.to_shape(tolerance, &mut debug_info)
|
shape.to_shape(tolerance, &mut debug_info),
|
||||||
.topology()
|
tolerance,
|
||||||
.triangles(tolerance, &mut triangles, &mut debug_info);
|
&mut triangles,
|
||||||
|
&mut debug_info,
|
||||||
|
);
|
||||||
|
|
||||||
ProcessedShape {
|
ProcessedShape {
|
||||||
aabb,
|
aabb,
|
||||||
|
@ -8,6 +8,7 @@ mod sweep;
|
|||||||
mod triangulation;
|
mod triangulation;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
approximation::Approximation, sweep::sweep_shape,
|
approximation::Approximation,
|
||||||
triangulation::delaunay,
|
sweep::sweep_shape,
|
||||||
|
triangulation::{delaunay, triangulate},
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
use fj_math::Scalar;
|
use fj_debug::DebugInfo;
|
||||||
|
use fj_math::{Scalar, Triangle};
|
||||||
use parry2d_f64::utils::point_in_triangle::{corner_direction, Orientation};
|
use parry2d_f64::utils::point_in_triangle::{corner_direction, Orientation};
|
||||||
use spade::HasPosition;
|
use spade::HasPosition;
|
||||||
|
|
||||||
use crate::geometry;
|
use crate::{geometry, shape::Shape};
|
||||||
|
|
||||||
|
/// Triangulate a shape
|
||||||
|
pub fn triangulate(
|
||||||
|
mut shape: Shape,
|
||||||
|
tolerance: Scalar,
|
||||||
|
out: &mut Vec<Triangle<3>>,
|
||||||
|
debug_info: &mut DebugInfo,
|
||||||
|
) {
|
||||||
|
for face in shape.topology().faces() {
|
||||||
|
face.get().triangles(tolerance, out, debug_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a Delaunay triangulation of all points
|
/// Create a Delaunay triangulation of all points
|
||||||
pub fn delaunay(
|
pub fn delaunay(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use fj_debug::DebugInfo;
|
use fj_math::{Point, Scalar, Vector};
|
||||||
use fj_math::{Point, Scalar, Triangle, Vector};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{Circle, Curve, Line},
|
geometry::{Circle, Curve, Line},
|
||||||
@ -238,18 +237,6 @@ impl Topology<'_> {
|
|||||||
pub fn faces(&self) -> Iter<Face> {
|
pub fn faces(&self) -> Iter<Face> {
|
||||||
Iter::new(self.geometry.faces)
|
Iter::new(self.geometry.faces)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Triangulate the shape
|
|
||||||
pub fn triangles(
|
|
||||||
&self,
|
|
||||||
tolerance: Scalar,
|
|
||||||
out: &mut Vec<Triangle<3>>,
|
|
||||||
debug_info: &mut DebugInfo,
|
|
||||||
) {
|
|
||||||
for face in &*self.geometry.faces {
|
|
||||||
face.get().triangles(tolerance, out, debug_info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user