[K3c] Schnitt: Besitzer aus dem Schnitt-Modell statt gezählt (mehrschichtige Decken, Treppen, Dächer)
RSlab trägt seine Herkunft (Decke + Schicht bzw. Treppe), Wände gehen über wall_id. Jede Deckenschicht wird ihr eigenes Band mit ihrem Bauteil; Treppentritte tragen Treppe und Kategorie. Dächer nicht mehr doppelt über render3d; beschnittene Stücke behalten Kategorie und Treppe.
This commit is contained in:
4 files changed
+201
-186
No files matched your search
@@ -41,6 +41,21 @@ pub struct RSlab {
|
||||
pub cut: Option<RCutMeta>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub monolith: Option<String>,
|
||||
/// Herkunft der Platte (nur im Kern, nicht serialisiert): der Schnitt ordnet seine Bänder darüber
|
||||
/// der Decke bzw. Deckenschicht oder der Treppe zu, statt die Platten abzuzählen.
|
||||
#[serde(skip)]
|
||||
pub source: SlabSource,
|
||||
}
|
||||
|
||||
/// Herkunft einer `RSlab`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SlabSource {
|
||||
#[default]
|
||||
None,
|
||||
/// Index in `Project::ceilings`; `layer` = Schicht des Deckentyps (`None` = ungeschichtet).
|
||||
Ceiling { index: usize, layer: Option<usize> },
|
||||
/// Index in `Project::stairs`.
|
||||
Stair { index: usize },
|
||||
}
|
||||
|
||||
/// Ein rohes Dreiecks-Mesh (`RMesh`).
|
||||
@@ -80,11 +95,11 @@ fn ceiling_layers<'a>(p: &'a Project, c: &Ceiling) -> Option<&'a [Layer]> {
|
||||
|
||||
/// Deckenplatten (`emitSlabs`): eine Platte je Materiallage, oben→unten gestapelt.
|
||||
pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
|
||||
let mut ceilings: Vec<&Ceiling> = Vec::new();
|
||||
let mut ceilings: Vec<(usize, &Ceiling)> = Vec::new();
|
||||
let mut layers_of: Vec<Option<&[Layer]>> = Vec::new();
|
||||
let mut w = FlatWriter::new();
|
||||
let count = w.slot();
|
||||
for c in p.ceilings.as_deref().unwrap_or(&[]) {
|
||||
for (ci, c) in p.ceilings.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
if c.outline.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
@@ -100,7 +115,7 @@ pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
|
||||
for l in layers.unwrap_or(&[]) {
|
||||
w.num(l.thickness);
|
||||
}
|
||||
ceilings.push(c);
|
||||
ceilings.push((ci, c));
|
||||
layers_of.push(layers);
|
||||
}
|
||||
if ceilings.is_empty() {
|
||||
@@ -109,12 +124,12 @@ pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
|
||||
w.set(count, ceilings.len() as f64);
|
||||
let mut out = Vec::new();
|
||||
for d in crate::ceilings3d::ceilings(&w.done()) {
|
||||
let c = ceilings[d.ceiling];
|
||||
let (ci, c) = ceilings[d.ceiling];
|
||||
let layers = layers_of[d.ceiling];
|
||||
let outline: Vec<RVec2> = d.ring.clone();
|
||||
for (layer_idx, z_bottom, z_top) in d.slabs {
|
||||
let Some(layers) = layers.filter(|_| layer_idx >= 0) else {
|
||||
out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None });
|
||||
out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Ceiling { index: ci, layer: None } });
|
||||
continue;
|
||||
};
|
||||
let l = &layers[layer_idx as usize];
|
||||
@@ -142,6 +157,7 @@ pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
|
||||
hatch: resolve_component_hatch(p, &l.component_id, None),
|
||||
cut,
|
||||
monolith: None,
|
||||
source: SlabSource::Ceiling { index: ci, layer: Some(layer_idx as usize) },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -729,22 +745,22 @@ fn rail_rgb() -> Rgb {
|
||||
}
|
||||
|
||||
/// Flache Eingabe der Treppen für `stairs3d` (23 Zahlen je Treppe); `wanted` wählt vor.
|
||||
fn stair_input<'a>(p: &'a Project, wanted: impl Fn(&Stair, Option<&StairType>) -> bool) -> Option<(Vec<&'a Stair>, Vec<f64>)> {
|
||||
let mut stairs: Vec<&Stair> = Vec::new();
|
||||
fn stair_input<'a>(p: &'a Project, wanted: impl Fn(&Stair, Option<&StairType>) -> bool) -> Option<(Vec<(usize, &'a Stair)>, Vec<f64>)> {
|
||||
let mut stairs: Vec<(usize, &Stair)> = Vec::new();
|
||||
let mut types: Vec<Option<&StairType>> = Vec::new();
|
||||
for s in p.stairs.as_deref().unwrap_or(&[]) {
|
||||
for (si, s) in p.stairs.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
let st = p.stair_type(s);
|
||||
if !wanted(s, st) {
|
||||
continue;
|
||||
}
|
||||
stairs.push(s);
|
||||
stairs.push((si, s));
|
||||
types.push(st);
|
||||
}
|
||||
if stairs.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let mut buf = vec![stairs.len() as f64];
|
||||
for (s, st) in stairs.iter().zip(&types) {
|
||||
for (&(_, s), st) in stairs.iter().zip(&types) {
|
||||
let (z_bottom, z_top) = p.stair_vertical_extent(s);
|
||||
buf.extend(s.encode());
|
||||
buf.push(z_bottom);
|
||||
@@ -773,7 +789,7 @@ pub fn emit_stairs(p: &Project, for_section: bool) -> Vec<RSlab> {
|
||||
crate::stairs3d::slabs(&buf, for_section)
|
||||
.into_iter()
|
||||
.map(|s| {
|
||||
let stair = stairs[s.src];
|
||||
let (si, stair) = stairs[s.src];
|
||||
RSlab {
|
||||
outline: s.pts,
|
||||
z_bottom: s.z_bottom,
|
||||
@@ -783,6 +799,7 @@ pub fn emit_stairs(p: &Project, for_section: bool) -> Vec<RSlab> {
|
||||
hatch: None,
|
||||
cut: None,
|
||||
monolith: s.monolith.then(|| stair.id.clone()),
|
||||
source: SlabSource::Stair { index: si },
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
||||
Reference in new issue
Block a user