use super::{FacetInfo, FacetMap};
use indicatrix::geometry::meet_solver::SolvedTier;
use indicatrix_cut_core::Design;
impl FacetMap {
#[must_use]
pub fn from_design_cut(
design: &Design,
solved: &[SolvedTier],
placements: &[(usize, usize)],
visible_tiers: Option<&[bool]>,
) -> Self {
let Some(visible) = visible_tiers else {
return Self::from_design_with_tools(design, solved, placements);
};
Self::from_design(design, solved)
.restricted_to(visible)
.with_tools(design, placements)
}
fn restricted_to(&self, visible: &[bool]) -> Self {
let shown = |info: &FacetInfo| {
info.tier_index
.is_none_or(|tier| visible.get(tier).copied().unwrap_or(true))
};
let mut facets: Vec<FacetInfo> = Vec::with_capacity(self.flat_facet_count);
let mut orbits: Vec<Vec<u32>> = vec![Vec::new(); self.orbits.len()];
for info in self.facets.iter().take(self.flat_facet_count) {
if !shown(info) {
continue;
}
if let Some(orbit) = info.tier_index.and_then(|tier| orbits.get_mut(tier)) {
orbit.push(facets.len() as u32);
}
facets.push(info.clone());
}
Self {
preform_plane_count: self.preform_plane_count,
flat_facet_count: facets.len(),
facets,
orbits,
concave_hover: Vec::new(),
}
}
}