Merge branch 'worktree-agent-add22047322fc40b9' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-14 05:15:07 +00:00
commit 566aaa9c8f
31 files changed
+333 -72

No files matched your search

+23 -14
View File
@@ -22,27 +22,32 @@ struct Def {
name: &'static str,
color: &'static str,
lw: f64,
/// [256] Vorgabe-Füllung der Klasse (`LayerCategory.fill`).
fill: Option<&'static str>,
}
/// [256] Nachbargebäude im Grundriss/Schnitt hellgrau mit grauem Umriss (Schweizer Praxis; schwarz nur im Schwarzplan).
pub const BUILDING_FILL: &str = "#d9d9d9";
/// [140] Kontext in Grautönen (Tusche-Standard), Farbe nur, wo der Nutzer sie setzt.
/// „05 Kontext" — Elternkategorie der Kontext-Kategorien.
const CONTEXT_PARENT: Def = Def { code: "05", name: "Kontext", color: "#707078", lw: 0.13 };
const CONTEXT_PARENT: Def = Def { code: "05", name: "Kontext", color: "#707078", lw: 0.13, fill: None };
/// „31 Dächer" bleibt oberste Ebene.
const IMPORTED_ROOF: Def = Def { code: "31", name: "Dächer", color: "#4a4a4a", lw: 0.18 };
const IMPORTED_ROOF: Def = Def { code: "31", name: "Dächer", color: "#4a4a4a", lw: 0.18, fill: None };
/// Kinder von „05 Kontext", in dieser Reihenfolge (`NESTED_CONTEXT_CATEGORIES`).
const NESTED: [Def; 11] = [
Def { code: "02", name: "Gelände", color: "#808080", lw: 0.13 },
Def { code: "03", name: "Luftbild", color: "#707078", lw: 0.13 },
Def { code: "10", name: "Situation", color: "#909090", lw: 0.18 },
Def { code: "12", name: "Gebäude", color: "#888888", lw: 0.25 },
Def { code: "11", name: "Strasse", color: "#808080", lw: 0.18 },
Def { code: "04", name: "Wald", color: "#909090", lw: 0.13 },
Def { code: "15", name: "Parkplätze", color: "#a0a0a0", lw: 0.13 },
Def { code: "16", name: "Bahn", color: "#606060", lw: 0.18 },
Def { code: "17", name: "Gewässer", color: "#909090", lw: 0.13 },
Def { code: "18", name: "Grünflächen", color: "#a0a0a0", lw: 0.13 },
Def { code: "02", name: "Gelände", color: "#808080", lw: 0.13, fill: None },
Def { code: "03", name: "Luftbild", color: "#707078", lw: 0.13, fill: None },
Def { code: "10", name: "Situation", color: "#909090", lw: 0.18, fill: None },
Def { code: "12", name: "Gebäude", color: "#888888", lw: 0.25, fill: Some(BUILDING_FILL) },
Def { code: "11", name: "Strasse", color: "#808080", lw: 0.18, fill: None },
Def { code: "04", name: "Wald", color: "#909090", lw: 0.13, fill: None },
Def { code: "15", name: "Parkplätze", color: "#a0a0a0", lw: 0.13, fill: None },
Def { code: "16", name: "Bahn", color: "#606060", lw: 0.18, fill: None },
Def { code: "17", name: "Gewässer", color: "#909090", lw: 0.13, fill: None },
Def { code: "18", name: "Grünflächen", color: "#a0a0a0", lw: 0.13, fill: None },
// [143] Baugruben eigene Kategorie: Grundrisse blenden „02 Gelände" oft aus, die Baugrube soll bleiben.
Def { code: "07", name: "Baugrube", color: "#4a4a4a", lw: 0.18 },
Def { code: "07", name: "Baugrube", color: "#4a4a4a", lw: 0.18, fill: None },
];
/// [256] Ist `code` eine Umgebungsklasse („05 Kontext" und ihre Kinder: Gelände, Situation, Gebäude, Strasse …)?
@@ -52,7 +57,11 @@ pub fn is_context_class(code: &str) -> bool {
}
fn category(d: &Def) -> Value {
json!({"code": d.code, "name": d.name, "color": d.color, "lw": d.lw, "visible": true, "locked": false})
let mut v = json!({"code": d.code, "name": d.name, "color": d.color, "lw": d.lw, "visible": true, "locked": false});
if let Some(f) = d.fill {
v["fill"] = json!(f);
}
v
}
/// [207] Bekannte Layer-Namen amtlicher Kataster-/Vermessungs-DXF auf die Kontext-Klassen: Gebäude → „12", Strassen
+6
View File
@@ -2817,6 +2817,12 @@ pub struct LayerCategory {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub hatch: Option<String>,
/// [256] Füllfarbe der Klasse (hex) für geschnittene Netzkörper ohne eigene Regel (Grundriss und Schnitt),
/// mit Umriss in Klassenfarbe und -stärke — z. B. Nachbargebäude „12 Gebäude" hellgrau statt schwarz.
/// Fehlt sie, gilt die Körper-Konvention (ab 1:100 schwarz). Situation/Schwarzplan färben selbst ([207]).
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub fill: Option<String>,
/// Unterkategorien (Baum).
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
+40
View File
@@ -83,6 +83,8 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec<Primitive>, drawing_obstacles: &
if let Some(s) = &sit {
h.extend(super::situation::own_rings(c.p));
h.extend(super::situation::context_rings(c, s));
} else {
h.extend(filled_context_rings(c));
}
h
})
@@ -179,6 +181,24 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec<Primitive>, drawing_obstacles: &
out.append(&mut late);
}
/// [256] Grundflächen der sichtbaren Netze auf Klassen mit Füllung (Nachbargebäude hellgrau, `style::class_cut_style`):
/// die Höhenlinien enden an ihnen wie am eigenen Haus, statt über die graue Fläche zu laufen.
fn filled_context_rings(c: &Ctx) -> Vec<Vec<Vec2>> {
let mut out = Vec::new();
for o in c.p.context.as_deref().unwrap_or(&[]) {
let ContextObject::ImportedMesh(m) = o else { continue };
if !c.shown(&m.category_code) || super::style::class_cut_style(c.p, &m.category_code).is_none() {
continue;
}
for poly in super::situation::mesh_polygons(&m.positions, &m.indices) {
if let Some(r) = poly.first().filter(|r| r.len() >= 3) {
out.push(r.iter().map(|q| v2(q[0], q[1])).collect());
}
}
}
out
}
/// [157] Sohle und Böschungsoberkante der Baugruben, die dieser Grundriss zeigt (Gelände sichtbar, Kategorie
/// der Baugrube gezeigt), als Strecken — Hindernisse der Aussenbemassung und der Schnittmarken-Beschriftung.
pub(super) fn excavation_segments(c: &Ctx) -> Vec<([f64; 2], [f64; 2])> {
@@ -1441,6 +1461,26 @@ mod tests {
assert!(out.is_empty(), "Gelände samt Höhenlinien und Pick-Fläche ausgeblendet");
}
/// [256] Nachbargebäude auf einer Klasse mit Füllung (hellgrau): die Höhenlinien enden an ihnen; ohne Füllung
/// (Umriss) laufen sie weiter.
#[test]
fn hoehenlinien_enden_am_gefuellten_nachbarn() {
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 30.0, 0.0, 3.0, 30.0, 10.0, 3.0, 0.0, 10.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.5), ..Default::default() };
let (positions, indices) = crate::mesh_view::tests::cube(12.0, 18.0, -2.0, 12.0, 0.0, 6.0);
let nb = ContextObject::ImportedMesh(ImportedMesh { id: "n".into(), category_code: "12".into(), positions, indices, ..Default::default() });
let mut p = Project { context: Some(vec![ContextObject::TerrainMesh(t), nb]), ..Default::default() };
p.layers = vec![LayerCategory { code: "12".into(), name: "Gebäude".into(), color: "#888888".into(), lw: 0.25, visible: true, fill: Some("#d9d9d9".into()), ..Default::default() }];
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "12"], "scale": 100}"#).unwrap();
let inside = |p: &Project| {
let mut out = Vec::new();
plan_context(&Ctx::new(p, &a), &mut out);
out.iter().any(|q| matches!(q, Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK && (a.x - 15.0).abs() < 1e-6 && (a.y + b.y) / 2.0 > 0.0 && (a.y + b.y) / 2.0 < 10.0))
};
assert!(!inside(&p), "Höhenlinie im gefüllten Nachbarn");
p.layers[0].fill = None;
assert!(inside(&p), "ohne Füllung läuft sie durch");
}
/// [140] Steile Stellen (Stützmauer, Böschung): Höhenlinien enger als 0.6 mm auf dem Papier werden
/// ausgedünnt (jede zweite, sonst nur Zähllinien); im flachen Teil bleiben alle.
#[test]
+27 -4
View File
@@ -346,11 +346,15 @@ fn draw_items(c: &Ctx, range: &ViewRange, items: &[Item], out: &mut Vec<Primitiv
if pts.len() < 3 {
continue;
}
let (fill, hatch) = match &comp {
Some((f, h)) => (f.clone(), h.clone()),
None => (ov.and_then(|o| o.fill.clone()).unwrap_or_else(|| solid_fill.clone()), ov.and_then(|o| o.hatch.clone()).map_or_else(|| solid_hatch.clone(), |h| h.unwrap_or_else(no_hatch))),
// [256] Ohne Bauteil und ohne Füllungs-Regel: Vorgabe-Stil der Klasse (Nachbargebäude hellgrau, grauer Umriss).
let class = comp.is_none().then(|| class_cut_style(c.p, &m.mesh.category_code)).flatten().filter(|_| ov.is_none_or(|o| o.fill.is_none()));
let (fill, hatch) = match (&comp, &class) {
(Some((f, h)), _) => (f.clone(), h.clone()),
(None, Some((f, _, _))) => (f.clone(), ov.and_then(|o| o.hatch.clone()).flatten().unwrap_or_else(no_hatch)),
(None, None) => (ov.and_then(|o| o.fill.clone()).unwrap_or_else(|| solid_fill.clone()), ov.and_then(|o| o.hatch.clone()).map_or_else(|| solid_hatch.clone(), |h| h.unwrap_or_else(no_hatch))),
};
let mut q = super::section::polygon(pts.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect(), &fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch);
let (stroke, stroke_mm) = class.as_ref().map_or((POCHE_STROKE, WALL_FALLBACK_MM), |(_, k, w)| (k.as_str(), *w));
let mut q = super::section::polygon(pts.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect(), &fill, stroke, stroke_mm, hatch);
if let Primitive::Polygon { context_object_id, extruded_solid_id, no_stroke_edges, greyed: g, .. } = &mut q {
match it.solid {
Some(s) => *extruded_solid_id = Some(s.id.clone()),
@@ -452,6 +456,25 @@ mod tests {
}).sum()
}
/// [256] Nachbargebäude auf einer Klasse mit Füllung („12 Gebäude"): im Grundriss hellgrau mit Umriss in Klassenfarbe
/// und -stärke statt schwarz; eine Füllungs-Regel ([33]) geht vor.
#[test]
fn nachbargebaeude_im_grundriss_nach_klassenstil() {
let m = ContextObject::ImportedMesh(ImportedMesh { id: "n".into(), name: "Nachbar".into(), category_code: "12".into(), positions: cube(0.0, 8.0, 0.0, 6.0, 0.0, 7.0).0, indices: cube(0.0, 8.0, 0.0, 6.0, 0.0, 7.0).1, ..Default::default() });
let mut p = project(vec![m]);
p.layers = vec![LayerCategory { code: "12".into(), name: "Gebäude".into(), color: "#888888".into(), lw: 0.25, visible: true, fill: Some("#d9d9d9".into()), ..Default::default() }];
let a = PlanArgs::parse(1.0, &serde_json::json!({"floor": "eg", "show": ["12"], "global": true, "scale": 100.0}).to_string()).unwrap();
let draw = |p: &Project| {
let c = Ctx::new(p, &a);
let mut out = Vec::new();
plan_meshes(&c, &mut out);
out.into_iter().find_map(|q| match q { Primitive::Polygon { fill, stroke, stroke_width_mm, context_object_id: Some(i), .. } if i == "n" && fill != "none" => Some((fill, stroke, stroke_width_mm)), _ => None }).unwrap()
};
assert_eq!(draw(&p), ("#d9d9d9".to_string(), "#888888".to_string(), 0.25));
p.layers[0].fill = None;
assert_eq!(draw(&p).0, HATCH_INK, "ohne Klassen-Füllung schwarz");
}
#[test]
fn stuetze_geschnitten_mit_poche() {
let p = project(vec![mesh("s", cube(0.0, 0.3, 0.0, 0.4, 0.0, 2.7))]);
@@ -192,3 +192,31 @@ fn geschlossenes_gelaende_als_gelaendelinie() {
assert_eq!(mesh_cuts(&o).len(), 1);
assert!(o.profiles.is_empty());
}
/// [256] Nachbargebäude (Netz auf „12 Gebäude", Klasse mit Füllung): im Schnitt hellgrau mit Umriss in Klassenfarbe
/// statt schwarz, nicht in der schweren Schnittkante; ohne Füllung der Klasse wie bisher schwarz. Über das Geländeende
/// hinaus nichts (Gelände u 1 … 12): der Nachbar rechts davon entfällt, einer über dem Rand wird beschnitten.
#[test]
fn nachbargebaeude_hellgrau_und_nur_ueber_dem_gelaende() {
let (positions, indices) = cube(-4.0, 7.0, -3.0, 3.0, -1.0, 0.0);
let terrain = ContextObject::TerrainMesh(TerrainMesh { id: "g".into(), name: "Site".into(), category_code: "02".into(), positions, indices, ..Default::default() });
let nb = |id: &str, x0: f64, x1: f64| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "12".into(), positions: cube(x0, x1, -1.0, 2.0, 0.0, 6.0).0, indices: cube(x0, x1, -1.0, 2.0, 0.0, 6.0).1, ..Default::default() });
let mut p = with(vec![terrain, nb("innen", 0.0, 2.0), nb("rand", 6.0, 9.0), nb("weg", 10.0, 12.0)]);
p.layers = vec![LayerCategory { code: "12".into(), name: "Gebäude".into(), color: "#888888".into(), lw: 0.25, visible: true, fill: Some("#d9d9d9".into()), ..Default::default() }];
let o = compute_section(&p, &lv(false), &[]).unwrap().unwrap();
let ids = |o: &Output| mesh_cuts(o).iter().filter_map(|c| c.source_id.clone()).collect::<Vec<_>>();
assert_eq!(ids(&o), ["innen", "rand"], "rechts vom Gelände kein Schnitt");
let rand = mesh_cuts(&o).into_iter().find(|c| c.source_id.as_deref() == Some("rand")).unwrap();
assert!((bbox(&rand.pts)[1] - 12.0).abs() < 1e-9, "endet am Geländeende u = 12: {:?}", rand.pts);
assert!(o.visible.iter().chain(&o.hidden).all(|e| e.kind != Kind::Mesh || (e.a[0] <= 12.0 + 1e-9 && e.b[0] <= 12.0 + 1e-9)), "Kanten enden am Gelände");
let rules = CutRules::of(&p, &o, RuleView::at(100.0, None));
let (prims, _) = section_primitives_at(&o, true, false, &Visibility::default(), 100.0, Detail::Mittel, false, &rules);
let poly = |id: &str| prims.iter().find_map(|q| match q { Primitive::Polygon { fill, stroke, stroke_width_mm, context_object_id: Some(i), .. } if i == id => Some((fill.clone(), stroke.clone(), *stroke_width_mm)), _ => None }).unwrap();
assert_eq!(poly("innen"), ("#d9d9d9".to_string(), "#888888".to_string(), 0.25));
assert!(!prims.iter().any(|q| matches!(q, Primitive::Line { cls, a, .. } if cls == "section-cut-outline" && a.x > 4.9 && a.x < 7.1)), "keine schwere Schnittkante um den Nachbarn");
// Klasse ohne Füllung: schwarz wie freie Körper.
p.layers[0].fill = None;
let rules = CutRules::of(&p, &o, RuleView::at(100.0, None));
let (prims, _) = section_primitives_at(&o, true, false, &Visibility::default(), 100.0, Detail::Mittel, false, &rules);
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, context_object_id: Some(i), .. } if i == "innen" && fill == HATCH_INK)));
}
+51
View File
@@ -126,6 +126,57 @@ pub(super) fn append_mesh_sections(cuts: &mut Vec<Cut>, lines: &mut Vec<(usize,
}
}
/// [256] Netze auf Umgebungsklassen (Nachbargebäude) nur, wo Gelände ist: Schnittflächen, offene Züge und Kanten
/// enden am Geländeende (u-Bereich der Geländelinie), sonst schweben sie neben dem Gelände. Ohne Geländelinie unverändert.
pub(super) fn clip_context_meshes_to_terrain(out: &mut Output) {
let (lo, hi) = out.profiles.iter().flat_map(|p| p.pts.iter()).fold((f64::INFINITY, f64::NEG_INFINITY), |(lo, hi), q| (lo.min(q[0]), hi.max(q[0])));
if !(lo.is_finite() && hi.is_finite() && hi > lo) {
return;
}
let ctx: Vec<bool> = out.meshes.iter().map(|m| m.category.as_deref().is_some_and(crate::import_context::is_context_class)).collect();
if !ctx.iter().any(|&c| c) {
return;
}
let is_ctx = |k: Kind, i: usize| k == Kind::Mesh && ctx.get(i).copied().unwrap_or(false);
out.cuts = std::mem::take(&mut out.cuts)
.into_iter()
.filter_map(|mut c| {
if !is_ctx(c.kind, c.index) {
return Some(c);
}
let (pts, nse) = unfold::clip_poly_u(&c.pts, c.nse.as_deref(), lo, hi)?;
(pts.len() >= 3).then(|| {
c.pts = pts;
c.nse = nse;
c
})
})
.collect();
out.mesh_lines = std::mem::take(&mut out.mesh_lines)
.into_iter()
.flat_map(|(k, pts)| if ctx.get(k).copied().unwrap_or(false) { clip_line_to_u(&pts, lo, hi) } else { vec![pts] }.into_iter().map(move |p| (k, p)))
.collect();
let clip_edges = |v: Vec<Edge>| -> Vec<Edge> {
v.into_iter()
.filter_map(|mut e| {
if !is_ctx(e.kind, e.index) {
return Some(e);
}
let (a, b) = if e.a[0] <= e.b[0] { (e.a, e.b) } else { (e.b, e.a) };
if b[0] < lo || a[0] > hi {
return None;
}
let at = |x: f64| if (b[0] - a[0]).abs() < 1e-12 { a } else { [x, a[1] + (b[1] - a[1]) * (x - a[0]) / (b[0] - a[0])] };
e.a = if a[0] < lo { at(lo) } else { a };
e.b = if b[0] > hi { at(hi) } else { b };
Some(e)
})
.collect()
};
out.visible = clip_edges(std::mem::take(&mut out.visible));
out.hidden = clip_edges(std::mem::take(&mut out.hidden));
}
/// [152] Oberkante eines Rings (u rechts, Höhe oben): Kanten, über denen aussen liegt — gegen den Uhrzeigersinn die
/// nach links laufenden —, zu Zügen verkettet (von links nach rechts).
fn upper_edge(ring: &[[f64; 2]]) -> Vec<Vec<[f64; 2]>> {
+6 -1
View File
@@ -290,6 +290,9 @@ pub struct CutRules {
pub terrain_hatch: Option<HatchRender>,
/// [152] Linien-Aktionen (Farbe, Stärke, Linienstil) je importiertem Netz (`Output::meshes`-Index).
pub mesh: HashMap<usize, MeshLineStyle>,
/// [256] Vorgabe-Stil der Klasse je importiertem Netz (`Output::meshes`-Index): Füllung, Umrissfarbe, -stärke
/// (`style::class_cut_style`, z. B. Nachbargebäude hellgrau statt schwarz).
pub class: HashMap<usize, (String, String, f64)>,
}
impl CutRules {
@@ -313,7 +316,8 @@ impl CutRules {
}
mesh = rules.into_iter().enumerate().filter_map(|(i, r)| r.filter(|r| r.0.any()).map(|r| (i, MeshLineStyle { color: r.0.color.clone(), weight: r.0.lineweight.filter(|w| w.is_finite() && *w >= 0.0), dash: super::overrides::linetype_dash(p, r.0.linetype_id.as_deref()) }))).collect();
}
CutRules { loose: loose_fill_components(p), ov, terrain, terrain_dash, terrain_hatch, mesh }
let class = out.meshes.iter().enumerate().filter_map(|(i, m)| m.category.as_deref().and_then(|k| super::style::class_cut_style(p, k)).map(|s| (i, s))).collect();
CutRules { loose: loose_fill_components(p), ov, terrain, terrain_dash, terrain_hatch, mesh, class }
}
}
@@ -649,6 +653,7 @@ pub(super) fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh],
let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: Some(m.mesh.category_code.clone()) }).collect();
let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), shoring: Vec::new(), terrain_id: None, meshes, mesh_lines, edge_cats };
append_terrain_profiles(&mut out, p, base, u);
clip_context_meshes_to_terrain(&mut out);
if let Some(s) = strip {
unfold::clip_output(&mut out, s);
}
+15 -4
View File
@@ -502,8 +502,12 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
Some(_) => false,
None => black && !loose_cut(cp, loose),
};
let black = base_black && !ov.is_some_and(|o| o.styles());
let (mut fill, mut hatch) = if black {
// [256] Netz auf einer Klasse mit Füllung (Nachbargebäude): Klassen-Stil statt schwarz, eine Füllungs-Regel geht vor.
let class = (cp.kind == Kind::Mesh).then(|| rules.class.get(&cp.index)).flatten().filter(|_| ov.is_none_or(|o| o.fill.is_none()));
let black = base_black && !ov.is_some_and(|o| o.styles()) && class.is_none();
let (mut fill, mut hatch) = if let Some((f, _, _)) = class {
(f.clone(), no_hatch())
} else if black {
(HATCH_INK.to_string(), no_hatch())
} else if cf == Some(CutFill::Empty) {
(HATCH_PAPER.to_string(), no_hatch())
@@ -543,7 +547,11 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
late_joints.push(l);
}
}
let mut pr = if stroked && dash.is_none() { polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch) } else { polygon(pts, &fill, "none", 0.0, hatch) };
let mut pr = match class {
Some((_, k, w)) if stroked && dash.is_none() => polygon(pts, &fill, k, *w, hatch),
_ if stroked && dash.is_none() => polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch),
_ => polygon(pts, &fill, "none", 0.0, hatch),
};
if let Primitive::Polygon { wall_id, ceiling_id, roof_id, stair_id, extruded_solid_id, no_stroke_edges, greyed, context_object_id, .. } = &mut pr {
// [152] Importiertes Netz: Pick über die Kontext-Id.
*context_object_id = if cp.kind == Kind::Mesh { src.clone() } else { None };
@@ -555,7 +563,10 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
*no_stroke_edges = cp.nse.clone();
*greyed = Some(cp.category.as_deref().is_some_and(|c| vis.greyed(c)));
}
cut_rings.push(vec![cp.pts.clone()]);
// [256] Klassen-Stil: eigener Umriss, nicht in der schweren Schnittkante des Gebäudes.
if class.is_none() {
cut_rings.push(vec![cp.pts.clone()]);
}
prims.push(pr);
}
prims.append(&mut late_joints);
+23 -3
View File
@@ -337,6 +337,9 @@ pub struct RunOpts {
pub rail_half: f64,
/// [G1] Untersicht: ohne Bruchlinie, alles über der Schnitthöhe gestrichelt (Schnitthöhe unter dem Treppenfuss).
pub no_break: bool,
/// [256] Meter je Papier-mm (Massstab/1000) für das Zickzack der Bruchlinie (2 mm breit, 1.5 mm hoch); 0 = feste
/// Modellgrösse (≤ 8 × 6 cm), bei 1:100 kaum sichtbar.
pub break_mm: f64,
}
/// [173] Schnittparameter des Strahls `a + t·d` mit der Geraden durch `c`–`e` (`None` = parallel).
@@ -527,8 +530,11 @@ pub fn plan_stair_run(params: &[f64], total_rise: f64, cut_rise: f64, lw_mm: f64
if w > 1e-6 {
let c = mul(d, 1.0 / w);
let m = mid(b.a, b.b);
let z = 0.08_f64.min(w * 0.15);
let h = 0.06_f64.min(b.depth * 0.8);
let (z, h) = if run.break_mm > 0.0 && run.break_mm.is_finite() {
((2.0 * run.break_mm).min(w * 0.25), (1.5 * run.break_mm).min(b.depth * 1.6))
} else {
(0.08_f64.min(w * 0.15), 0.06_f64.min(b.depth * 0.8))
};
let pts = [b.a, sub(m, mul(c, z)), add(sub(m, mul(c, z / 3.0)), mul(b.up, h)), sub(add(m, mul(c, z / 3.0)), mul(b.up, h)), add(m, mul(c, z)), b.b];
for k in 0..pts.len() - 1 {
o.line(CLS_BREAK, pts[k], pts[k + 1], w_outline, false);
@@ -816,6 +822,20 @@ mod tests {
assert!(all.iter().all(|l| !l.1) && all.iter().all(|l| l.0 != CLS_BREAK));
}
/// [256] Zickzack der Bruchlinie in Papiergrösse (`RunOpts::break_mm`): bei 1:100 gut 1 mm hoch, sonst liest sich die
/// Bruchlinie quer über den Lauf wie eine weitere Trittkante; ohne Massstab wie bisher (≤ 6 cm).
#[test]
fn bruchlinie_zickzack_in_papiergroesse() {
let x_break = 5.5 * 3.0 / 16.0;
let height = |run: &RunOpts| {
let b = plan_stair_run(&straight(), 2.8, 1.0, 0.25, false, 0.0, 3, false, &[], run);
lines_w(&b).into_iter().filter(|l| l.0 == CLS_BREAK).flat_map(|l| [l.2[0], l.3[0]]).map(|x| (x - x_break).abs()).fold(0.0, f64::max)
};
assert!(height(&RunOpts::default()) <= 0.06 + 1e-9);
let h = height(&RunOpts { break_mm: 0.1, ..Default::default() });
assert!(h >= 0.1 - 1e-9, "1:100: Zickzack {h} m");
}
/// [155] Podest über der Schnitthöhe als erstes Element: Bruchlinie auf dem Podest, Lauf 1 ganz ausgezogen.
#[test]
fn bruch_auf_dem_podest() {
@@ -988,7 +1008,7 @@ mod tests {
assert!(l(&g.run_line) >= l(&raw.run_line) - 1e-9, "{name}: nicht kürzer als vorher");
assert!(len(sub(g.arrow.head.1, g.run_line[n - 1])) < 1e-9, "{name}: Pfeil am Ende");
let mut h = stair_geometry(&sp, 2.8);
run_line_to_edges(&mut h, spiral, &RunOpts { start: 0.1, end: 0.2, start_mark: None, rail_half: 0.0, no_break: false });
run_line_to_edges(&mut h, spiral, &RunOpts { start: 0.1, end: 0.2, start_mark: None, rail_half: 0.0, no_break: false, break_mm: 0.0 });
assert!((l(&g.run_line) - l(&h.run_line) - 0.3).abs() < 1e-6, "{name}: Versatz 0.1 + 0.2");
assert!(len(sub(h.arrow.head.1, h.run_line[h.run_line.len() - 1])) < 1e-9);
}
+1 -1
View File
@@ -255,7 +255,7 @@ fn step_numbers(out: &mut Vec<Primitive>, geo: &kernel2d::StairGeometry, cut_hei
/// (Halbmesser 0.75 mm Papier, nur mit Lauflinie).
fn run_opts(o: &super::model_view::StairOpts, scale: f64, s: &Stair) -> crate::plan::stair_symbol::RunOpts {
let m = |mm: f64| if scale.is_finite() && scale > 0.0 { mm * scale / 1000.0 } else { 0.0 };
crate::plan::stair_symbol::RunOpts { start: m(o.run_start_mm), end: m(o.run_end_mm), start_mark: (o.start_mark && o.walk_line).then(|| m(0.75)).filter(|r| *r > 0.0), rail_half: rail_half(s), no_break: false }
crate::plan::stair_symbol::RunOpts { start: m(o.run_start_mm), end: m(o.run_end_mm), start_mark: (o.start_mark && o.walk_line).then(|| m(0.75)).filter(|r| *r > 0.0), rail_half: rail_half(s), no_break: false, break_mm: m(1.0) }
}
/// [T3] Halbe Handlaufbreite der Treppe (Meter).
+9
View File
@@ -92,6 +92,15 @@ pub fn solid_cut(detail: Detail, scale: f64, cut_hatch: bool) -> bool {
detail == Detail::Grob || (!cut_hatch && detail != Detail::Fein && scale.is_finite() && scale >= SOLID_CUT_FROM)
}
/// [256] Vorgabe-Stil der Klasse `code` für geschnittene Netzkörper: (Füllung, Umrissfarbe, Umrissstärke mm), wenn
/// die Klasse eine Füllung trägt (`LayerCategory.fill`, z. B. „12 Gebäude" hellgrau). Regeln ([33]) gehen vor.
pub fn class_cut_style(p: &Project, code: &str) -> Option<(String, String, f64)> {
let k = p.layer_category(code)?;
let fill = k.fill.as_deref().map(str::trim).filter(|f| !f.is_empty())?;
let lw = if k.lw.is_finite() && k.lw >= 0.0 { k.lw } else { 0.13 };
Some((fill.to_string(), k.color.clone(), lw))
}
/// [140] Ist eine Schicht der Dicke `thickness_m` (Meter) bei 1:`scale` auf dem Papier dünn
/// (unter [`THIN_LAYER_PAPER_MM`])? Nur zusammen mit [`simplify_thin_layers`] verwenden.
pub fn is_thin_layer(thickness_m: f64, scale: f64) -> bool {
+19 -6
View File
@@ -271,16 +271,16 @@ pub fn roof_types() -> Vec<Value> {
/// Alle Standard-Ressourcen je Projekt-Liste, in Abhängigkeitsreihenfolge.
/// [66] Ansichtsvorlagen für Pläne „mit einem Klick" (an Geschoss/Schnitt/Ansicht binden oder anwenden):
/// Präsentation (Tusche wie alle Pläne [140], Farbe über `mono: false` wählbar; Schatten, ohne Referenz- und
/// Konstruktionslinien), Eingabe 1:100 und Ausführung 1:50
/// Konstruktionslinien und Kameras), Eingabe 1:100 und Ausführung 1:50 (ohne Sonnenschatten und Kameras, [256])
/// (schwarz-weiss nach SIA 400).
pub fn view_templates() -> Vec<Value> {
vec![
json!({"id": "std-vt-praesentation", "name": "Präsentation", "detail": "mittel", "mono": true, "shadows": true, "hiddenLines": false,
"layerVisibility": {"90": false, "91": false, "99": false}}),
"layerVisibility": {"90": false, "91": false, "92": false, "99": false}}),
json!({"id": "std-vt-eingabe-100", "name": "Eingabeplan 1:100", "detail": "mittel", "scaleDenominator": 100, "mono": true, "shadows": false,
"layerVisibility": {"99": false}}),
"layerVisibility": {"08": false, "92": false, "99": false}}),
json!({"id": "std-vt-ausfuehrung-50", "name": "Ausführungsplan 1:50", "detail": "fein", "scaleDenominator": 50, "mono": true, "shadows": false,
"scaleLineWeights": true, "layerVisibility": {"99": false}}),
"scaleLineWeights": true, "layerVisibility": {"08": false, "92": false, "99": false}}),
// [207] Situationsplan 1:500 für Wettbewerbe: eigenes Gebäude schwarz, Kontext grau (bzw. alles schwarz im Schwarzplan);
// ohne Raster, Bauteil-Zeichnungen, Text, Bemassung, Koten und Referenzen. Parzelle, Strassen, Höhenlinien und Bäume bleiben.
json!({"id": "std-vt-situation-wbw", "name": "Situation WBW 1:500", "detail": "grob", "scaleDenominator": 500, "mono": true, "shadows": false,
@@ -291,8 +291,8 @@ pub fn view_templates() -> Vec<Value> {
}
/// [207] Klassen, die der Situationsplan ausblendet: Raster, Wände (samt Türen/Fenster, Möbel, Stützen), Decken, Dächer,
/// Träger, Treppen, Baugrube, Text, Räume, Bemassung, Auto-Bemassung, Höhenkoten, Details, Referenzen, Schnittmarken, Konstruktion.
const SITUATION_HIDDEN: [&str; 18] = ["00", "07", "20", "21", "22", "25", "30", "35", "40", "50", "60", "80", "81", "82", "85", "90", "91", "99"];
/// Träger, Treppen, Baugrube, Text, Räume, Bemassung, Auto-Bemassung, Höhenkoten, Details, Referenzen, Schnittmarken, Kameras ([256]), Konstruktion.
const SITUATION_HIDDEN: [&str; 19] = ["00", "07", "20", "21", "22", "25", "30", "35", "40", "50", "60", "80", "81", "82", "85", "90", "91", "92", "99"];
/// [173] Stufen der Modelldarstellung als Vorlagen (≙ Archicad „Modelldarstellung"): Wettbewerb 1:200 (Wände als
/// Fläche, Räume mit Name und Fläche ohne Nummer, nur das Gesamtmass, ohne Koten), Baueingabe 1:100 (SIA-Kategorie,
@@ -817,6 +817,19 @@ mod tests {
use super::*;
use crate::model::Project;
/// [256] Abgabe-Vorlagen ohne Kamera-Sichtkegel (Klasse 92); Sonnenschatten (Klasse 08) nur in der Präsentation —
/// Eingabe- und Ausführungsplan blenden ihn aus, Situation/Schwarzplan zeichnen ohnehin keinen.
#[test]
fn abgabe_vorlagen_ohne_kameras_schatten_nur_praesentation() {
let vt = view_templates();
let hidden = |id: &str, code: &str| vt.iter().find(|t| t["id"] == id).unwrap()["layerVisibility"][code] == json!(false);
for id in ["std-vt-praesentation", "std-vt-eingabe-100", "std-vt-ausfuehrung-50", "std-vt-situation-wbw", "std-vt-schwarzplan"] {
assert!(hidden(id, CAMERA_CATEGORY), "{id}: Kameras aus");
}
assert!(!hidden("std-vt-praesentation", SHADOW_CATEGORY), "Präsentation mit Schatten");
assert!(hidden("std-vt-eingabe-100", SHADOW_CATEGORY) && hidden("std-vt-ausfuehrung-50", SHADOW_CATEGORY));
}
fn empty_root() -> Map<String, Value> {
json!({"id": "p", "name": "P", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [], "drawingLevels": [],
"walls": [], "openings": []})