-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1828 from A-Walrus/sketch_face_v2
Rework Sketches v2
- Loading branch information
Showing
8 changed files
with
109 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ mod cycle; | |
mod edge; | ||
mod face; | ||
mod shell; | ||
mod sketch; | ||
mod solid; | ||
mod surface; | ||
mod vertex; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! Types that are tied to objects, but aren't objects themselves | ||
pub mod curve; | ||
pub mod region; | ||
pub mod surface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//! A single, continues 2d region | ||
use fj_interop::mesh::Color; | ||
|
||
use crate::{ | ||
objects::{Cycle, Face, Surface}, | ||
operations::Insert, | ||
services::Services, | ||
storage::Handle, | ||
}; | ||
|
||
/// A single, continuous 2d region, may contain holes. Once applied to a | ||
/// [`Surface`] becomes a [`Face`] | ||
/// | ||
/// Interior cycles must have the opposite winding of the exterior cycle, | ||
/// meaning on the front side of the region, they must appear clockwise. This | ||
/// means that all [`HalfEdge`]s that bound a `Region` have the interior of the | ||
/// region on their left side (on the region's front side). | ||
/// | ||
/// [`HalfEdge`]: crate::objects::HalfEdge | ||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] | ||
pub struct Region { | ||
exterior: Handle<Cycle>, | ||
interiors: Vec<Handle<Cycle>>, | ||
color: Option<Color>, | ||
} | ||
|
||
impl Region { | ||
/// Construct an instance of `Region` | ||
pub fn new( | ||
exterior: Handle<Cycle>, | ||
interiors: Vec<Handle<Cycle>>, | ||
color: Option<Color>, | ||
) -> Self { | ||
Self { | ||
exterior, | ||
interiors, | ||
color, | ||
} | ||
} | ||
|
||
/// Access the cycle that bounds the region on the outside | ||
pub fn exterior(&self) -> &Handle<Cycle> { | ||
&self.exterior | ||
} | ||
|
||
/// Access the cycles that bound the region on the inside | ||
/// | ||
/// Each of these cycles defines a hole in the region . | ||
pub fn interiors(&self) -> impl Iterator<Item = &Handle<Cycle>> + '_ { | ||
self.interiors.iter() | ||
} | ||
|
||
/// Access all cycles of the region (both exterior and interior) | ||
pub fn all_cycles(&self) -> impl Iterator<Item = &Handle<Cycle>> + '_ { | ||
[self.exterior()].into_iter().chain(self.interiors()) | ||
} | ||
|
||
/// Access the color of the region | ||
pub fn color(&self) -> Option<Color> { | ||
self.color | ||
} | ||
|
||
/// Convert the 2D region to a 3D face, by applying it to a surface. | ||
pub fn face( | ||
&self, | ||
surface: Handle<Surface>, | ||
services: &mut Services, | ||
) -> Handle<Face> { | ||
let face: Face = Face::new( | ||
surface, | ||
self.exterior().clone(), | ||
self.interiors().cloned(), | ||
self.color, | ||
); | ||
face.insert(services) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters