[157] Grundriss: Aussenbemassung rückt beim Zeichnen hinter die sichtbare Böschung, Schnittmarken-Beschriftung nicht auf der Baugrube
Ketten der automatischen Aussenbemassung (autodim-<Geschoss>-<Seite>-<Kette>, gerade): zeigt der Grundriss die Baugrube (Gelände sichtbar, Kategorie gezeigt) und erreicht Sohle oder Böschungsoberkante eine Kette der Seite, rücken alle Ketten der Seite gleich weit hinaus, die innerste 4 mm Papier hinter die Böschung (drawings::autodim_shift, context::excavation_segments). Im Modell bleiben sie, wo sie sind (Präsentationsplan-Massstab unverändert); der Zeichnungs-Cache liest dafür das Feld context. Sohle, Böschungsoberkante und -schraffur sind Hindernisse der Schnittmarken-Beschriftung; Kandidaten bis 6 Schrifthöhen hinaus. Tests: aussenbemassung_rueckt_hinter_die_boeschung, schnittmarke_nicht_auf_der_boeschung.
This commit is contained in:
3 files changed
+183
-2
No files matched your search
@@ -31,7 +31,7 @@ pub const NOT_FOR_DRAWINGS: &[&str] = &[
|
||||
"columns",
|
||||
"trees",
|
||||
"extrudedSolids",
|
||||
"context",
|
||||
// [157] `context` lesen die Zeichnungen: die Aussenbemassung rückt hinter die sichtbare Baugrube.
|
||||
"groups",
|
||||
"parametricWalls",
|
||||
"viewSnapshots",
|
||||
|
||||
@@ -171,6 +171,32 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec<Primitive>, drawing_obstacles: &
|
||||
out.append(&mut late);
|
||||
}
|
||||
|
||||
/// [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])> {
|
||||
let pits: Vec<&Excavation> = crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))).collect();
|
||||
if pits.is_empty() || !terrain_shown(c) {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for e in pits {
|
||||
let ring: Vec<[f64; 2]> = e.outline.iter().filter(|q| q.x.is_finite() && q.y.is_finite()).map(|q| [q.x, q.y]).collect();
|
||||
for i in 0..ring.len() {
|
||||
out.push((ring[i], ring[(i + 1) % ring.len()]));
|
||||
}
|
||||
for t in crate::excavation::terrains(c.p) {
|
||||
let st = crate::excavation::site_terrain(c.p, t);
|
||||
if let Some((_, _, daylight)) = st.items.iter().find(|(id, ..)| *id == e.id) {
|
||||
for l in daylight {
|
||||
out.extend(l.windows(2).map(|w| (w[0], w[1])));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// [157] Gelände, Höhenlinien und Baugruben in diesem Grundriss: Feld `showTerrain` der Ebene, sonst nur im
|
||||
/// Geschoss nächst ±0.00 (`extras::ground_floor_id`) und in der Situation (ab 1:500). Ohne Geschoss-Ebenen
|
||||
/// bzw. für eine unbekannte Ebene immer (Ausschnitte, Tests).
|
||||
@@ -761,9 +787,21 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
for q in super::drawings::stamp_obstacle_prims(c).iter().chain(super::drawings::grid_bubble_prims(c).iter()) {
|
||||
obst.add_prim(q);
|
||||
}
|
||||
// [157] Sohle, Böschungsoberkante und Böschungsschraffur der sichtbaren Baugruben.
|
||||
if !excavation_segments(c).is_empty() {
|
||||
let house = terrain_footprint(c.p, &c.a.floor);
|
||||
let (mut pit, mut bands) = (Vec::new(), Vec::new());
|
||||
for e in crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))) {
|
||||
excavation_lines(c, e, &mut pit, &mut bands, &house);
|
||||
}
|
||||
for q in &pit {
|
||||
obst.add_prim(q);
|
||||
}
|
||||
}
|
||||
let h = SECTION_LABEL_H * k;
|
||||
// Kandidaten (Vielfache der Schrifthöhe): vor der Spitze, weiter hinaus entlang der Linie bzw. des Pfeils.
|
||||
const STEPS: [(f64, f64); 13] = [(0.0, 0.0), (1.0, 0.0), (0.0, 1.0), (2.0, 0.0), (1.0, 1.0), (0.0, 2.0), (3.0, 0.0), (2.0, 1.0), (1.0, 2.0), (4.0, 0.0), (0.0, 3.0), (3.0, 2.0), (-1.0, 0.0)];
|
||||
// [157] Weiter hinaus (5–6 Schrifthöhen) für Marken hinter Massketten und Böschung.
|
||||
const STEPS: [(f64, f64); 17] = [(0.0, 0.0), (1.0, 0.0), (0.0, 1.0), (2.0, 0.0), (1.0, 1.0), (0.0, 2.0), (3.0, 0.0), (2.0, 1.0), (1.0, 2.0), (4.0, 0.0), (0.0, 3.0), (3.0, 2.0), (5.0, 0.0), (5.0, 1.0), (6.0, 0.0), (6.0, 1.0), (-1.0, 0.0)];
|
||||
for (at, tag, bn, outward) in labels {
|
||||
let w = crate::text_layout::text_width_em(&tag, false) * h;
|
||||
let rect = |a: Vec2| -> Vec<[f64; 2]> {
|
||||
@@ -1146,6 +1184,83 @@ mod tests {
|
||||
assert_eq!(sohle.iter().filter(|(a, b)| (a.x - 12.0).abs() < 1e-9 && (b.x - 12.0).abs() < 1e-9).count(), 1, "Westrand ganz");
|
||||
}
|
||||
|
||||
/// [157] Schnittmarken-Beschriftung nicht auf der Böschungsschraffur: Sohle, Böschungsoberkante und Schraffur
|
||||
/// der sichtbaren Baugrube sind Hindernisse („B-B“ lag im Musterhaus komplex in der Böschung).
|
||||
#[test]
|
||||
fn schnittmarke_nicht_auf_der_boeschung() {
|
||||
let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]]));
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]);
|
||||
// Schnittlinie mit den Enden in der West- und Ostböschung.
|
||||
p.drawing_levels.push(serde_json::from_value(serde_json::json!({ "id": "s", "name": "Schnitt B-B", "kind": "section", "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 10.5, "y": 4.0 }, { "x": 29.5, "y": 4.0 }] })).unwrap());
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["90", "80", "02"], "scale": 100}"#).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&c, &mut out);
|
||||
let mut ctx = Vec::new();
|
||||
plan_context(&c, &mut ctx);
|
||||
let pit_lines: Vec<(Vec2, Vec2)> = ctx.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(k), .. } if k == EXCAVATION_INK => Some((*a, *b)), _ => None }).collect();
|
||||
assert!(!pit_lines.is_empty());
|
||||
let mut n = 0;
|
||||
for q in &out {
|
||||
let Primitive::DrawingText { at, text, height_m, .. } = q else { continue };
|
||||
if text != "B-B" {
|
||||
continue;
|
||||
}
|
||||
n += 1;
|
||||
let w = crate::text_layout::text_width_em(text, false) * height_m;
|
||||
let flat = [at.x, at.y, at.x + w, at.y, at.x + w, at.y + 0.75 * height_m, at.x, at.y + 0.75 * height_m];
|
||||
for (a, b) in &pit_lines {
|
||||
for k in 0..=20 {
|
||||
let f = k as f64 / 20.0;
|
||||
assert!(!crate::plan::pick::point_in_polygon(a.x + (b.x - a.x) * f, a.y + (b.y - a.y) * f, &flat), "{text} auf der Böschung bei {at:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(n, 2);
|
||||
}
|
||||
|
||||
/// [157] Aussenbemassung und Böschung: zeigt der Grundriss die Baugrube und schneidet eine Kette der
|
||||
/// automatischen Aussenbemassung sie, rücken beim Zeichnen alle Ketten dieser Seite hinter die
|
||||
/// Böschungsoberkante (Abstände bleiben); ohne Gelände im Grundriss stehen sie wie im Modell.
|
||||
#[test]
|
||||
fn aussenbemassung_rueckt_hinter_die_boeschung() {
|
||||
let mut p = sample_with_walls(serde_json::json!([
|
||||
["h1", "eg", 14.0, 0.0, 26.0, 0.0], ["h2", "eg", 26.0, 0.0, 26.0, 8.0], ["h3", "eg", 26.0, 8.0, 14.0, 8.0], ["h4", "eg", 14.0, 8.0, 14.0, 0.0]
|
||||
]));
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
// Sohle 2 m ausserhalb, 3 m tief, 45°: Böschungsoberkante West bei x ≈ 9.
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]);
|
||||
let dim = |id: &str, off: f64| serde_json::from_value::<Drawing2D>(serde_json::json!({"id": id, "type": "drawing2d", "levelId": "eg", "categoryCode": "20", "geom": {"shape": "dimension", "pts": [{"x": 13.8, "y": 0}, {"x": 13.8, "y": 8}], "offset": off}})).unwrap();
|
||||
p.drawings2d = vec![dim("autodim-eg-west-openings", 1.0), dim("autodim-eg-west-total", 2.4), dim("eigene", 1.5)];
|
||||
// Masslinien (senkrecht, über die ganze Kette) je Zeichnung.
|
||||
let lines = |p: &Project| -> Vec<(String, f64)> {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100, "show": ["20"]}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
for q in super::super::drawings::stamp_obstacle_prims(&Ctx::new(p, &a)) {
|
||||
if let Primitive::Line { a, b, drawing_id: Some(id), .. } = q {
|
||||
if (a.x - b.x).abs() < 1e-9 && (a.y - b.y).abs() > 7.9 {
|
||||
out.push((id, a.x));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
};
|
||||
let x = |l: &[(String, f64)], id: &str| l.iter().find(|(i, _)| i == id).map(|(_, x)| *x).unwrap();
|
||||
let l = lines(&p);
|
||||
let daylight = 9.0;
|
||||
assert!(x(&l, "autodim-eg-west-openings") < daylight - 0.3, "{l:?}");
|
||||
assert!((x(&l, "autodim-eg-west-openings") - x(&l, "autodim-eg-west-total") - 1.4).abs() < 1e-9, "Abstand bleibt: {l:?}");
|
||||
assert!((x(&l, "eigene") - 12.3).abs() < 1e-9, "eigene Masse bleiben: {l:?}");
|
||||
// Ohne Gelände im Grundriss: wie im Modell.
|
||||
p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().show_terrain = Some(false);
|
||||
let l = lines(&p);
|
||||
assert!((x(&l, "autodim-eg-west-openings") - 12.8).abs() < 1e-9 && (x(&l, "autodim-eg-west-total") - 11.4).abs() < 1e-9, "{l:?}");
|
||||
}
|
||||
|
||||
/// [157] Gelände, Höhenlinien und Baugrube erscheinen standardmässig nur im Geschoss nächst ±0.00 (und in der
|
||||
/// Situation ab 1:500), nicht im Obergeschoss; das Feld `showTerrain` der Ebene übersteuert beides.
|
||||
#[test]
|
||||
|
||||
@@ -780,6 +780,9 @@ fn emit_inner(c: &Ctx, d: &Drawing2D, attrs: Attrs, geom: &Drawing2DGeom, greyed
|
||||
Drawing2DGeom::Dimension { .. } if c.a.auto_coarse && c.a.scale >= super::domains::OVERVIEW_FROM => {}
|
||||
Drawing2DGeom::Dimension { pts, offset, gap_mm, overshoot_mm, tick_len_mm, text_height_mm, line_weight_mm, ext_weight_mm, tick_weight_mm, text_offsets_mm, refs, kind, arc_center } => {
|
||||
let mm = |x: f64| mm_to_model(x, scale);
|
||||
// [157] Aussenbemassung hinter der sichtbaren Böschung (nur beim Zeichnen).
|
||||
let shifted = if arc_center.is_none() && kind.is_none() { *offset + autodim_shift(c, d, scale) } else { *offset };
|
||||
let offset = &shifted;
|
||||
if let Some(k) = kind {
|
||||
let st = DimStyle {
|
||||
gap: mm(gap_mm.unwrap_or(DIM_GAP_MM)),
|
||||
@@ -1465,6 +1468,69 @@ fn acc_bounds(g: &Drawing2DGeom, b: &mut Bounds) {
|
||||
}
|
||||
|
||||
/// Liegt die Zeichnung auf dem Geschoss (und ist sie im Druck nicht ausgenommen, `noPrint`)?
|
||||
/// [157] Zusätzlicher Abstand einer Kette der automatischen Aussenbemassung (`autodim-<Geschoss>-<Seite>-<Kette>`,
|
||||
/// gerade) beim Zeichnen: zeigt der Grundriss die Baugrube und schneidet eine Kette dieser Seite Sohle oder
|
||||
/// Böschung (bis zur Böschungsoberkante), rücken alle Ketten der Seite gleich weit hinaus — die innerste mit
|
||||
/// 4 mm Papier Luft hinter die Böschung. Im Modell bleiben die Ketten, wo sie sind (Geschosse ohne Gelände,
|
||||
/// Ausmass des Präsentationsplans).
|
||||
fn autodim_shift(c: &Ctx, d: &Drawing2D, scale: f64) -> f64 {
|
||||
let prefix = format!("autodim-{}-", d.level_id);
|
||||
let Some(rest) = d.id.strip_prefix(&prefix) else { return 0.0 };
|
||||
let Some((side, _)) = rest.rsplit_once('-') else { return 0.0 };
|
||||
if side == "arc" || side.starts_with("arc-") {
|
||||
return 0.0;
|
||||
}
|
||||
let obst = super::context::excavation_segments(c);
|
||||
if obst.is_empty() {
|
||||
return 0.0;
|
||||
}
|
||||
let group = format!("{prefix}{side}-");
|
||||
let margin = mm_to_model(4.0, scale);
|
||||
let mut need: f64 = 0.0;
|
||||
for g in c.p.drawings2d.iter().filter(|g| g.id.starts_with(&group)) {
|
||||
let Drawing2DGeom::Dimension { pts, offset, arc_center: None, kind: None, .. } = &g.geom else { continue };
|
||||
let (Some(a), Some(b)) = (pts.first(), pts.last()) else { continue };
|
||||
let len = hypot2(b.x - a.x, b.y - a.y);
|
||||
if !(len > 1e-6) || !offset.is_finite() || offset.abs() < 1e-9 {
|
||||
continue;
|
||||
}
|
||||
let u = ((b.x - a.x) / len, (b.y - a.y) / len);
|
||||
// Aussen = Seite des Versatzes (wie `dimension_segment`).
|
||||
let sg = offset.signum();
|
||||
let n = (-u.1 * sg, u.0 * sg);
|
||||
let (t0, t1) = (-margin, len + margin);
|
||||
let mut s_max = f64::NEG_INFINITY;
|
||||
for &(p, q) in &obst {
|
||||
let (tp, tq) = ((p[0] - a.x) * u.0 + (p[1] - a.y) * u.1, (q[0] - a.x) * u.0 + (q[1] - a.y) * u.1);
|
||||
let (sp, sq) = ((p[0] - a.x) * n.0 + (p[1] - a.y) * n.1, (q[0] - a.x) * n.0 + (q[1] - a.y) * n.1);
|
||||
// Teilstück im Streifen der Kette.
|
||||
let (lo, hi) = if (tq - tp).abs() < 1e-12 {
|
||||
if tp < t0 || tp > t1 { continue } else { (0.0, 1.0) }
|
||||
} else {
|
||||
let (f0, f1) = ((t0 - tp) / (tq - tp), (t1 - tp) / (tq - tp));
|
||||
(f0.min(f1).max(0.0), f0.max(f1).min(1.0))
|
||||
};
|
||||
if lo > hi {
|
||||
continue;
|
||||
}
|
||||
s_max = s_max.max(sp + (sq - sp) * lo).max(sp + (sq - sp) * hi);
|
||||
}
|
||||
// Nur was aussen vor der Kette liegt und sie erreicht.
|
||||
if s_max > 0.0 && s_max + margin > offset.abs() {
|
||||
need = need.max(s_max + margin - offset.abs());
|
||||
}
|
||||
}
|
||||
need * d_sign(d)
|
||||
}
|
||||
|
||||
/// Vorzeichen des Versatzes einer Masskette (der Abstand wächst in seiner Richtung).
|
||||
fn d_sign(d: &Drawing2D) -> f64 {
|
||||
match &d.geom {
|
||||
Drawing2DGeom::Dimension { offset, .. } if *offset < 0.0 => -1.0,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
fn on_floor(c: &Ctx, d: &Drawing2D) -> bool {
|
||||
crate::grid::visible_on(d, &c.a.floor) && !(c.a.for_print && d.no_print == Some(true))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user