Skip to content

Commit

Permalink
Add Face::brep
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed May 17, 2022
1 parent 54917b5 commit a7a176e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
24 changes: 4 additions & 20 deletions crates/fj-kernel/src/algorithms/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,32 +256,16 @@ impl Relation {
}

fn exteriors_for_face(&self, face: &Face) -> Vec<Handle<Cycle<3>>> {
let exteriors = match face {
Face::Face(face) => &face.exteriors,
_ => {
// Sketches are created using boundary representation, so this
// case can't happen.
unreachable!()
}
};

exteriors
face.brep()
.exteriors
.as_handle()
.map(|cycle| self.cycles.get(cycle).unwrap().clone())
.collect()
}

fn interiors_for_face(&self, face: &Face) -> Vec<Handle<Cycle<3>>> {
let interiors = match face {
Face::Face(face) => &face.interiors,
_ => {
// Sketches are created using boundary representation, so this
// case can't happen.
unreachable!()
}
};

interiors
face.brep()
.interiors
.as_handle()
.map(|cycle| self.cycles.get(cycle).unwrap().clone())
.collect()
Expand Down
35 changes: 13 additions & 22 deletions crates/fj-kernel/src/topology/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ impl Face {
FaceBuilder::new(surface, shape)
}

/// Access the surface that the face refers to
///
/// This is a convenience method that saves the caller from dealing with the
/// [`Handle`].
pub fn surface(&self) -> Surface {
/// Access the boundary representation of the face
pub fn brep(&self) -> &FaceBRep {
match self {
Self::Face(face) => face.surface(),
Self::Face(face) => face,
_ => {
// No code that still uses triangle representation is calling
// this method.
Expand All @@ -76,34 +73,28 @@ impl Face {
}
}

/// Access the surface that the face refers to
///
/// This is a convenience method that saves the caller from dealing with the
/// [`Handle`].
pub fn surface(&self) -> Surface {
self.brep().surface()
}

/// Access the exterior cycles that the face refers to
///
/// This is a convenience method that saves the caller from dealing with the
/// [`Handle`]s.
pub fn exteriors(&self) -> impl Iterator<Item = Cycle<3>> + '_ {
match self {
Self::Face(face) => face.exteriors(),
_ => {
// No code that still uses triangle representation is calling
// this method.
unreachable!()
}
}
self.brep().exteriors()
}

/// Access the interior cycles that the face refers to
///
/// This is a convenience method that saves the caller from dealing with the
/// [`Handle`]s.
pub fn interiors(&self) -> impl Iterator<Item = Cycle<3>> + '_ {
match self {
Self::Face(face) => face.interiors(),
_ => {
// No code that still uses triangle representation is calling
// this method.
unreachable!()
}
}
self.brep().interiors()
}

/// Access all cycles that the face refers to
Expand Down

0 comments on commit a7a176e

Please sign in to comment.