Skip to content

Commit

Permalink
Merge pull request #1940 from hannobraun/cleanup
Browse files Browse the repository at this point in the history
Some minor cleanup
  • Loading branch information
hannobraun authored Jul 14, 2023
2 parents f415bde + 5fbfb2a commit 234d8d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 0 additions & 4 deletions crates/fj-core/src/objects/kinds/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ pub struct GlobalEdge {}

impl GlobalEdge {
/// Create a new instance
///
/// The order of `vertices` is irrelevant. Two `GlobalEdge`s with the same
/// `curve` and `vertices` will end up being equal, regardless of the order
/// of `vertices` here.
pub fn new() -> Self {
Self::default()
}
Expand Down
1 change: 1 addition & 0 deletions crates/fj-core/src/validate/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum CycleValidationError {
/// The half-edge
half_edges: Box<(HalfEdge, HalfEdge)>,
},

/// [`Cycle`]'s should have at least one `HalfEdge`
#[error("Expected at least one `HalfEdge`\n")]
NotEnoughHalfEdges,
Expand Down
16 changes: 10 additions & 6 deletions crates/fj-core/src/validate/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ impl Validate for Shell {
/// [`Shell`] validation failed
#[derive(Clone, Debug, thiserror::Error)]
pub enum ShellValidationError {
/// [`Shell`] contains global_edges not referred to by two half_edges
/// [`Shell`] contains global_edges not referred to by two half-edges
#[error("Shell is not watertight")]
NotWatertight,

/// [`Shell`] contains half_edges that are coincident, but refer to different global_edges
/// [`Shell`] contains half-edges that are coincident, but refer to
/// different global_edges
#[error(
"`Shell` contains `HalfEdge`s that are coincident but refer to \
different `GlobalEdge`s\n\
Expand All @@ -37,7 +38,7 @@ pub enum ShellValidationError {
)]
CoincidentEdgesNotIdentical(Handle<HalfEdge>, Handle<HalfEdge>),

/// [`Shell`] contains half_edges that are identical, but do not coincide
/// [`Shell`] contains half-edges that are identical, but do not coincide
#[error(
"Shell contains HalfEdges that are identical but do not coincide\n\
Edge 1: {edge_1:#?}\n\
Expand Down Expand Up @@ -126,7 +127,9 @@ impl ShellValidationError {
for other_edge in &edges_and_surfaces {
let id = edge.0.global_form().id();
let other_id = other_edge.0.global_form().id();

let identical = id == other_id;

match identical {
true => {
// All points on identical curves should be within
Expand Down Expand Up @@ -171,9 +174,9 @@ impl ShellValidationError {
_: &ValidationConfig,
errors: &mut Vec<ValidationError>,
) {
let faces = shell.faces();
let mut half_edge_to_faces: HashMap<ObjectId, usize> = HashMap::new();
for face in faces {

for face in shell.faces() {
for cycle in face.region().all_cycles() {
for half_edge in cycle.half_edges() {
let id = half_edge.global_form().id();
Expand All @@ -183,7 +186,8 @@ impl ShellValidationError {
}
}

// Each global edge should have exactly two half edges that are part of the shell
// Each global edge should have exactly two half edges that are part of
// the shell
if half_edge_to_faces.iter().any(|(_, c)| *c != 2) {
errors.push(Self::NotWatertight.into())
}
Expand Down

0 comments on commit 234d8d2

Please sign in to comment.