mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-25 16:45:52 +00:00
Replace Topology::add_cycle
with Shape::insert
This commit is contained in:
parent
69409a6210
commit
d657ecec4a
@ -176,7 +176,7 @@ mod tests {
|
||||
let da =
|
||||
Edge::build(&mut shape).line_segment_from_vertices([v4, v1])?;
|
||||
|
||||
let abcd = shape.topology().add_cycle(Cycle {
|
||||
let abcd = shape.insert(Cycle {
|
||||
edges: vec![ab, bc, cd, da],
|
||||
})?;
|
||||
|
||||
|
@ -77,15 +77,11 @@ pub fn sweep_shape(
|
||||
let edges_top = source_to_top.edges_for_cycle(&cycle_source);
|
||||
|
||||
let cycle_bottom = target
|
||||
.topology()
|
||||
.add_cycle(Cycle {
|
||||
.insert(Cycle {
|
||||
edges: edges_bottom,
|
||||
})
|
||||
.unwrap();
|
||||
let cycle_top = target
|
||||
.topology()
|
||||
.add_cycle(Cycle { edges: edges_top })
|
||||
.unwrap();
|
||||
let cycle_top = target.insert(Cycle { edges: edges_top }).unwrap();
|
||||
|
||||
source_to_bottom
|
||||
.cycles
|
||||
@ -237,8 +233,7 @@ pub fn sweep_shape(
|
||||
.unwrap();
|
||||
|
||||
let cycle = target
|
||||
.topology()
|
||||
.add_cycle(Cycle {
|
||||
.insert(Cycle {
|
||||
edges: vec![
|
||||
bottom_edge,
|
||||
top_edge,
|
||||
@ -406,7 +401,7 @@ mod tests {
|
||||
let ca = Edge::build(&mut shape)
|
||||
.line_segment_from_vertices([c.clone(), a.clone()])?;
|
||||
|
||||
let cycles = shape.topology().add_cycle(Cycle {
|
||||
let cycles = shape.insert(Cycle {
|
||||
edges: vec![ab, bc, ca],
|
||||
})?;
|
||||
|
||||
|
@ -14,23 +14,6 @@ pub struct Topology<'r> {
|
||||
}
|
||||
|
||||
impl Topology<'_> {
|
||||
/// Add a cycle to the shape
|
||||
///
|
||||
/// Validates that the cycle is structurally sound (i.e. the edges it refers
|
||||
/// to are part of the shape). Returns an error, if that is not the case.
|
||||
///
|
||||
/// # Implementation note
|
||||
///
|
||||
/// The validation of the cycle should be extended to cover more cases:
|
||||
/// - That those edges form a cycle.
|
||||
/// - That the cycle is not self-overlapping.
|
||||
/// - That there exists no duplicate cycle, with the same edges.
|
||||
pub fn add_cycle(&mut self, cycle: Cycle) -> ValidationResult<Cycle> {
|
||||
cycle.validate(self.min_distance, &self.stores)?;
|
||||
let handle = self.stores.cycles.insert(cycle);
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
/// Add a face to the shape
|
||||
///
|
||||
/// Validates that the face is structurally sound (i.e. the surface and
|
||||
@ -153,8 +136,7 @@ mod tests {
|
||||
// Trying to refer to edge that is not from the same shape. Should fail.
|
||||
let edge = other.add_edge()?;
|
||||
let err = shape
|
||||
.topology()
|
||||
.add_cycle(Cycle {
|
||||
.insert(Cycle {
|
||||
edges: vec![edge.clone()],
|
||||
})
|
||||
.unwrap_err();
|
||||
@ -162,7 +144,7 @@ mod tests {
|
||||
|
||||
// Referring to edge that *is* from the same shape. Should work.
|
||||
let edge = shape.add_edge()?;
|
||||
shape.topology().add_cycle(Cycle { edges: vec![edge] })?;
|
||||
shape.insert(Cycle { edges: vec![edge] })?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -239,8 +221,7 @@ mod tests {
|
||||
|
||||
fn add_cycle(&mut self) -> anyhow::Result<Handle<Cycle>> {
|
||||
let edge = self.add_edge()?;
|
||||
let cycle =
|
||||
self.topology().add_cycle(Cycle { edges: vec![edge] })?;
|
||||
let cycle = self.insert(Cycle { edges: vec![edge] })?;
|
||||
Ok(cycle)
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,7 @@ impl ToShape for fj::Circle {
|
||||
let edge = Edge::build(&mut shape)
|
||||
.circle(Scalar::from_f64(self.radius()))
|
||||
.unwrap();
|
||||
shape
|
||||
.topology()
|
||||
.add_cycle(Cycle { edges: vec![edge] })
|
||||
.unwrap();
|
||||
shape.insert(Cycle { edges: vec![edge] }).unwrap();
|
||||
|
||||
let cycles = shape.topology().cycles().collect();
|
||||
let surface = shape.insert(Surface::x_y_plane()).unwrap();
|
||||
|
@ -109,5 +109,5 @@ fn add_cycle(
|
||||
edges.push(edge);
|
||||
}
|
||||
|
||||
shape.topology().add_cycle(Cycle { edges }).unwrap()
|
||||
shape.insert(Cycle { edges }).unwrap()
|
||||
}
|
||||
|
@ -73,8 +73,7 @@ fn copy_shape(mut orig: Shape, target: &mut Shape) {
|
||||
}
|
||||
for cycle_orig in orig.topology().cycles() {
|
||||
let cycle = target
|
||||
.topology()
|
||||
.add_cycle(Cycle {
|
||||
.insert(Cycle {
|
||||
edges: cycle_orig
|
||||
.get()
|
||||
.edges
|
||||
|
@ -42,7 +42,7 @@ impl ToShape for fj::Sketch {
|
||||
edges.push(edge);
|
||||
}
|
||||
|
||||
shape.topology().add_cycle(Cycle { edges }).unwrap();
|
||||
shape.insert(Cycle { edges }).unwrap();
|
||||
};
|
||||
|
||||
let surface = shape.insert(Surface::x_y_plane()).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user