Skip to content

Commit

Permalink
Split colored face in model
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jan 17, 2024
1 parent 2ad4085 commit 5a9f2ea
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions models/color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use fj::core::{
operations::{
insert::Insert,
presentation::SetColor,
split::SplitFace,
update::{UpdateFace, UpdateShell, UpdateSolid},
},
services::Services,
Expand All @@ -15,14 +16,31 @@ pub fn model(services: &mut Services) -> Handle<Solid> {

cuboid
.update_shell(cuboid.shells().only(), |shell| {
shell
.update_face(shell.faces().first(), |face| {
face.update_region(|region| {
region.set_color([0., 1., 0.]).insert(services)
})
.insert(services)
let shell = shell.update_face(shell.faces().first(), |face| {
face.update_region(|region| {
region.set_color([0., 1., 0.]).insert(services)
})
.insert(services)
});

// Split colored face, to make sure the same color is applied to the
// two derived faces.
let shell = {
let face = shell.faces().first();
let line = {
let cycle = face.region().exterior();

[
(cycle.half_edges().nth(0).unwrap(), [0.2]),
(cycle.half_edges().nth(2).unwrap(), [0.2]),
]
};

let (shell, _) = shell.split_face(face, line, services);
shell
};

shell.insert(services)
})
.insert(services)
}

0 comments on commit 5a9f2ea

Please sign in to comment.