mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-12 10:15:51 +00:00
Simplify builder method
This commit is contained in:
parent
0817dd3c9a
commit
a7365e670e
@ -183,7 +183,7 @@ impl CycleBuilder for PartialCycle {
|
|||||||
{
|
{
|
||||||
edges.map(|other| {
|
edges.map(|other| {
|
||||||
let mut this = self.add_half_edge();
|
let mut this = self.add_half_edge();
|
||||||
this.write().update_from_other_edge(&other, &Some(*surface));
|
this.write().update_from_other_edge(&other, surface);
|
||||||
this
|
this
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ pub trait HalfEdgeBuilder {
|
|||||||
fn update_from_other_edge(
|
fn update_from_other_edge(
|
||||||
&mut self,
|
&mut self,
|
||||||
other: &Partial<HalfEdge>,
|
other: &Partial<HalfEdge>,
|
||||||
surface: &Option<SurfaceGeometry>,
|
surface: &SurfaceGeometry,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||||||
fn update_from_other_edge(
|
fn update_from_other_edge(
|
||||||
&mut self,
|
&mut self,
|
||||||
other: &Partial<HalfEdge>,
|
other: &Partial<HalfEdge>,
|
||||||
surface: &Option<SurfaceGeometry>,
|
surface: &SurfaceGeometry,
|
||||||
) {
|
) {
|
||||||
let global_curve = other.read().curve.read().global_form.clone();
|
let global_curve = other.read().curve.read().global_form.clone();
|
||||||
self.curve.write().global_form = global_curve.clone();
|
self.curve.write().global_form = global_curve.clone();
|
||||||
@ -230,66 +230,55 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||||||
|
|
||||||
self.curve.write().path =
|
self.curve.write().path =
|
||||||
other.read().curve.read().path.as_ref().and_then(|path| {
|
other.read().curve.read().path.as_ref().and_then(|path| {
|
||||||
match surface {
|
// We have information about the other edge's surface available.
|
||||||
Some(surface) => {
|
// We need to use that to interpret what the other edge's curve
|
||||||
// We have information about the other edge's surface
|
// path means for our curve path.
|
||||||
// available. We need to use that to interpret what the
|
|
||||||
// other edge's curve path means for our curve path.
|
|
||||||
match surface.u {
|
match surface.u {
|
||||||
GlobalPath::Circle(circle) => {
|
GlobalPath::Circle(circle) => {
|
||||||
// The other surface is curved. We're entering
|
// The other surface is curved. We're entering some
|
||||||
// some dodgy territory here, as only some edge
|
// dodgy territory here, as only some edge cases can be
|
||||||
// cases can be represented using our current
|
// represented using our current curve/surface
|
||||||
// curve/surface representation.
|
// representation.
|
||||||
match path {
|
match path {
|
||||||
MaybeSurfacePath::Defined(
|
MaybeSurfacePath::Defined(SurfacePath::Line(_))
|
||||||
SurfacePath::Line(_),
|
|
||||||
)
|
|
||||||
| MaybeSurfacePath::UndefinedLine => {
|
| MaybeSurfacePath::UndefinedLine => {
|
||||||
// We're dealing with a line on a
|
// We're dealing with a line on a rounded
|
||||||
// rounded surface.
|
|
||||||
//
|
|
||||||
// Based on the current uses of this
|
|
||||||
// method, we can make some assumptions:
|
|
||||||
//
|
|
||||||
// 1. The line is parallel to the u-axis
|
|
||||||
// of the other surface.
|
|
||||||
// 2. The surface that *our* edge is in
|
|
||||||
// is a plane that is parallel to the
|
|
||||||
// the plane of the circle that
|
|
||||||
// defines the curvature of the other
|
|
||||||
// surface.
|
// surface.
|
||||||
//
|
//
|
||||||
// These assumptions are necessary
|
// Based on the current uses of this method, we
|
||||||
// preconditions for the following code
|
// can make some assumptions:
|
||||||
// to work. But unfortunately, I see no
|
|
||||||
// way to check those preconditions
|
|
||||||
// here, as neither the other line nor
|
|
||||||
// our surface is necessarily defined
|
|
||||||
// yet.
|
|
||||||
//
|
//
|
||||||
// Handling this case anyway feels like
|
// 1. The line is parallel to the u-axis of the
|
||||||
// a grave sin, but I don't know what
|
// other surface.
|
||||||
// else to do. If you tracked some
|
// 2. The surface that *our* edge is in is a
|
||||||
// extremely subtle and annoying bug
|
// plane that is parallel to the the plane of
|
||||||
// back to this code, I apologize.
|
// the circle that defines the curvature of
|
||||||
|
// the other surface.
|
||||||
//
|
//
|
||||||
// I hope that I'll come up with a
|
// These assumptions are necessary preconditions
|
||||||
// better curve/surface representation
|
// for the following code to work. But
|
||||||
// before this becomes a problem.
|
// unfortunately, I see no way to check those
|
||||||
Some(
|
// preconditions here, as neither the other line
|
||||||
MaybeSurfacePath::UndefinedCircle {
|
// nor our surface is necessarily defined yet.
|
||||||
|
//
|
||||||
|
// Handling this case anyway feels like a grave
|
||||||
|
// sin, but I don't know what else to do. If you
|
||||||
|
// tracked some extremely subtle and annoying
|
||||||
|
// bug back to this code, I apologize.
|
||||||
|
//
|
||||||
|
// I hope that I'll come up with a better curve/
|
||||||
|
// surface representation before this becomes a
|
||||||
|
// problem.
|
||||||
|
Some(MaybeSurfacePath::UndefinedCircle {
|
||||||
radius: circle.radius(),
|
radius: circle.radius(),
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// The other edge is a line segment in a
|
// The other edge is a line segment in a curved
|
||||||
// curved surface. No idea how to deal
|
// surface. No idea how to deal with this.
|
||||||
// with this.
|
|
||||||
todo!(
|
todo!(
|
||||||
"Can't connect edge to circle on \
|
"Can't connect edge to circle on curved \
|
||||||
curved surface"
|
surface"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,38 +286,24 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||||||
GlobalPath::Line(_) => {
|
GlobalPath::Line(_) => {
|
||||||
// The other edge is defined on a plane.
|
// The other edge is defined on a plane.
|
||||||
match path {
|
match path {
|
||||||
MaybeSurfacePath::Defined(
|
MaybeSurfacePath::Defined(SurfacePath::Line(_))
|
||||||
SurfacePath::Line(_),
|
|
||||||
)
|
|
||||||
| MaybeSurfacePath::UndefinedLine => {
|
| MaybeSurfacePath::UndefinedLine => {
|
||||||
// The other edge is a line segment on
|
// The other edge is a line segment on a plane.
|
||||||
// a plane. That means our edge must be
|
// That means our edge must be a line segment
|
||||||
// a line segment too.
|
// too.
|
||||||
Some(MaybeSurfacePath::UndefinedLine)
|
Some(MaybeSurfacePath::UndefinedLine)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// The other edge is a circle or arc on
|
// The other edge is a circle or arc on a plane.
|
||||||
// a plane. I'm actually not sure what
|
// I'm actually not sure what that means for our
|
||||||
// that means for our edge. We might be
|
// edge. We might be able to represent it
|
||||||
// able to represent it somehow, but
|
// somehow, but let's leave that as an exercise
|
||||||
// let's leave that as an exercise for
|
// for later.
|
||||||
// later.
|
todo!("Can't connect edge to circle on plane")
|
||||||
todo!(
|
|
||||||
"Can't connect edge to circle on \
|
|
||||||
plane"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
None => {
|
|
||||||
// We know nothing about the surface the other edge is
|
|
||||||
// on. This means we can't infer anything about our
|
|
||||||
// curve from the other curve.
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (this, other) in self
|
for (this, other) in self
|
||||||
|
Loading…
Reference in New Issue
Block a user