[63]+[77] Merge: Profilverstösse im Grundriss, Fläche in der Objekt-Info
This commit is contained in:
8 files changed
+109
-3
No files matched your search
@@ -1773,8 +1773,9 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
Punkte (Wandkronen, Körper-Deckel, Dachflächen/Giebel, Kanten ≤ 1 m abgetastet), Verstoss = ganzes Bauteil
|
||||
(`profileExceeded`/`profileViolations`, im 3D rot vom tiefsten Profilpunkt bis Oberkante — Näherung, kein Volumen);
|
||||
Hülle im 3D mit Profil-Oberseite (adaptiv verfeinert, Knicke auf ≤ 0.25 m genähert), gedeckelt durch Gesamthöhe.
|
||||
Wände als Vorsprung markierbar (`Wall.siteProjection`, Erker; Tiefe + Anteil). Offen: Hülle im 3D nur im
|
||||
Linux-Container gebaut, nicht angesehen (WebGPU/macOS); Profilverstösse nicht im Grundriss gezeichnet; Profil gilt
|
||||
Wände als Vorsprung markierbar (`Wall.siteProjection`, Erker; Tiefe + Anteil). 5.11.: Profilverstösse im Grundriss
|
||||
(`plan/extras.rs`, wie Grenzabstands-Verstösse in der Verstoss-Gruppe, gleiches Rot, schwächer gefüllt; Test). Offen: Hülle im 3D nur im
|
||||
Linux-Container gebaut, nicht angesehen (WebGPU/macOS); Profil gilt
|
||||
an allen Kanten (nicht je Kante wählbar), Fassaden-/Gesamthöhe nach IVHB nicht getrennt; Höhenkurven fehlen;
|
||||
Anteil grob über Ausdehnung längs der Grenze.
|
||||
- ◐ **[64]+[59] Sonnenstand und Schatten.** (27.10.) Schatten im Grundriss mit Zeitregler (Lage-Panel),
|
||||
@@ -1873,7 +1874,9 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
verschieben", Geo-Verschiebung und Wand-Begrenzung nehmen `holes` mit. 4.11. Griffe: Loch-Ecken sind Eckgriffe (Index ab 2n, hinter den Bogen-Griffen; bestehende Indizes unverändert).
|
||||
Auflösen liefert zusätzlich die Lochkanten als Linien. Verrunden/Fasen behalten die Löcher; Versetzen, Bruch,
|
||||
Teilen, Trimmen/Verlängern und Verbinden bauen neue Ketten und lassen `holes` bewusst weg (Kopie ohne Löcher, kein
|
||||
Panic). Offen: Fläche in der Objekt-Info (gibt es für Polylinien nicht); nicht in der App geklickt.
|
||||
Panic). 5.11. Objekt-Info zeigt die Fläche (m², nur lesen) geschlossener Rechtecke, Kreise, Ellipsen und Polylinien
|
||||
(Bögen aus `bulge` exakt als Kreissegmente, abzüglich `holes`; `selection_info.rs::geom_area`, Tests Rust + vitest;
|
||||
Splines ohne). Offen: nicht in der App geklickt.
|
||||
- ✅ **[78] Autotext im Plankopf.** Titelblock löst Projekt/Blatt/Massstab/Datum auf; Plannummer laufend
|
||||
oder `Layout.planNumber` (27.10.).
|
||||
- ◐ **[79] Publikationssätze.** (30.10.) Modell (Rust, optional): `Project.publishSets` (`PublishSet`: Layouts in Reihenfolge,
|
||||
|
||||
@@ -19,6 +19,8 @@ pub const SITE_PARCEL_CLS: &str = "site-parcel";
|
||||
pub const SITE_ALLOWED_CLS: &str = "site-allowed";
|
||||
pub const SITE_VIOLATION_FILL: &str = "#d0342c";
|
||||
const SITE_VIOLATION_OPACITY: f64 = 0.45;
|
||||
/// Profilverstösse ([63]): gleiches Rot, schwächer gefüllt (Bauteil ragt über das Gebäudeprofil).
|
||||
const SITE_PROFILE_OPACITY: f64 = 0.25;
|
||||
const PARCEL_COLOR: &str = "#1f6f3f";
|
||||
const ALLOWED_COLOR: &str = "#2b5fae";
|
||||
const PARCEL_DASH: [f64; 4] = [6.0, 1.5, 0.5, 1.5];
|
||||
@@ -150,6 +152,12 @@ pub fn site_and_shadow(p: &Project, floor: &str, when_ms: Option<f64>) -> (Vec<(
|
||||
violations.push(flat_polygon(ring_pts(&ring), SITE_VIOLATION_FILL, SITE_VIOLATION_OPACITY));
|
||||
}
|
||||
}
|
||||
for poly in &check.profile_violations {
|
||||
let rings: Vec<Vec<[f64; 2]>> = poly.iter().map(|r| r.iter().map(|q| [q.x, q.y]).collect()).collect();
|
||||
for ring in crate::sun::without_holes(&rings) {
|
||||
violations.push(flat_polygon(ring_pts(&ring), SITE_VIOLATION_FILL, SITE_PROFILE_OPACITY));
|
||||
}
|
||||
}
|
||||
}
|
||||
(under, violations)
|
||||
}
|
||||
@@ -508,6 +516,25 @@ mod tests {
|
||||
serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap()
|
||||
}
|
||||
|
||||
/// [63] Profilverstösse erscheinen im Grundriss (schwächeres Rot); ohne Profil nichts.
|
||||
#[test]
|
||||
fn profilverstoesse_im_grundriss() {
|
||||
let mut p = sample();
|
||||
let floor = ground_floor_id(&p).unwrap().to_string();
|
||||
let rules = |extra: serde_json::Value| {
|
||||
let mut v = serde_json::json!({"parcel": [{"x": -1, "y": -1}, {"x": 6, "y": -1}, {"x": 6, "y": 5}, {"x": -1, "y": 5}], "defaultSetback": 0.0});
|
||||
v.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone());
|
||||
serde_json::from_value(v).unwrap()
|
||||
};
|
||||
p.site_rules = Some(rules(serde_json::json!({})));
|
||||
let n0 = site_and_shadow(&p, &floor, None).1.len();
|
||||
p.site_rules = Some(rules(serde_json::json!({"profileAngle": 10.0, "profileHeight": 0.01})));
|
||||
let c = crate::site_rules::check_project(&p).unwrap();
|
||||
assert!(c.profile_exceeded);
|
||||
let n1 = site_and_shadow(&p, &floor, None).1.len();
|
||||
assert!(n1 > n0, "{n0} {n1}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strichstaerken_faktor() {
|
||||
let mut on = sample();
|
||||
|
||||
@@ -1106,6 +1106,48 @@ fn is_closed_geom(g: &Value) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Fläche einer geschlossenen 2D-Form in m² ([77]): Rechteck, Kreis, Ellipse, Polylinie (Bögen aus
|
||||
/// `bulge` exakt als Kreissegmente, abzüglich `holes`); sonst `None` (Spline u. a.).
|
||||
fn geom_area(g: &Value) -> Option<f64> {
|
||||
let p = |k: &str| xy(g.get(k).unwrap_or(&Value::Null));
|
||||
let shoelace = |pts: &[(f64, f64)]| -> f64 {
|
||||
let n = pts.len();
|
||||
(0..n).map(|i| (pts[i].0 * pts[(i + 1) % n].1 - pts[(i + 1) % n].0 * pts[i].1) / 2.0).sum()
|
||||
};
|
||||
let a = match str_of(field(g, "shape"))? {
|
||||
"rect" => {
|
||||
let (a, b) = (p("min"), p("max"));
|
||||
((b.0 - a.0) * (b.1 - a.1)).abs()
|
||||
}
|
||||
"circle" => std::f64::consts::PI * num_of(field(g, "r")).powi(2),
|
||||
"ellipse" => std::f64::consts::PI * (num_of(field(g, "rx")) * num_of(field(g, "ry"))).abs(),
|
||||
"polyline" if truthy(field(g, "closed")) => {
|
||||
let pts = pts_of(field(g, "pts"));
|
||||
if pts.len() < 3 {
|
||||
return None;
|
||||
}
|
||||
let bulge = arr(field(g, "bulge")).iter().map(|v| num_of(Some(v))).collect::<Vec<_>>();
|
||||
let mut signed = shoelace(&pts);
|
||||
for (i, b) in bulge.iter().enumerate().take(pts.len()) {
|
||||
if b.abs() < 1e-9 {
|
||||
continue;
|
||||
}
|
||||
let (u, v) = (pts[i], pts[(i + 1) % pts.len()]);
|
||||
let c = hypot2(v.0 - u.0, v.1 - u.1);
|
||||
let theta: f64 = 4.0 * jsnum::atan2(*b, 1.0);
|
||||
let r = c / (2.0 * jsnum::sin(theta / 2.0).abs());
|
||||
// Kreissegment zwischen Sehne und Bogen; Bogen links der Sehne (b > 0) ergibt eine im Uhrzeigersinn
|
||||
// durchlaufene Schleife, wirkt also gegen die Ring-Orientierung (CCW positiv).
|
||||
signed -= (r * r / 2.0) * (theta.abs() - jsnum::sin(theta.abs())) * b.signum();
|
||||
}
|
||||
let holes: f64 = arr(field(g, "holes")).iter().map(|h| shoelace(&pts_of(Some(h))).abs()).sum();
|
||||
signed.abs() - holes
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
(a.is_finite() && a >= 0.0).then_some(a)
|
||||
}
|
||||
|
||||
/// Bounding-Box einer 2D-Form (`geomBBox`, auch für Ausrichten/Verteilen).
|
||||
pub fn geom_bbox(g: &Value) -> [f64; 4] {
|
||||
let p = |k: &str| xy(g.get(k).unwrap_or(&Value::Null));
|
||||
@@ -1223,6 +1265,7 @@ fn drawing_selection(root: &Map<String, Value>, d: &Value) -> J {
|
||||
.raw("strokeWeightSource", d, "strokeWeightSource")
|
||||
.o("hatchSource", pick("hatchSource"))
|
||||
.v("closed", Value::Bool(closed))
|
||||
.o("area", geom_area(g).map(js_num))
|
||||
.v("isImage", Value::Bool(is_image))
|
||||
.o("opacity", if is_image { Some(nn(field(g, "opacity")).cloned().unwrap_or_else(|| Value::from(1u64))) } else { field(d, "opacity").cloned() })
|
||||
.v("bbox", bbox_value(geom_bbox(g)))
|
||||
@@ -1265,6 +1308,27 @@ mod tests {
|
||||
derive(&Lookup::plain(r), &serde_json::from_value(a).unwrap()).map(|j| serde_json::from_str(&j.into_string()).unwrap())
|
||||
}
|
||||
|
||||
/// [77] Fläche geschlossener 2D-Formen: Bögen exakt, Löcher abgezogen, offene Formen ohne Wert.
|
||||
#[test]
|
||||
fn flaeche_geschlossener_formen() {
|
||||
let sq = json!([{"x": 0, "y": 0}, {"x": 4, "y": 0}, {"x": 4, "y": 4}, {"x": 0, "y": 4}]);
|
||||
let a = |g: Value| geom_area(&g);
|
||||
assert_eq!(a(json!({"shape": "rect", "min": {"x": 1, "y": 1}, "max": {"x": 3, "y": 4}})), Some(6.0));
|
||||
assert!((a(json!({"shape": "circle", "center": {"x": 0, "y": 0}, "r": 2})).unwrap() - 4.0 * std::f64::consts::PI).abs() < 1e-12);
|
||||
assert!((a(json!({"shape": "ellipse", "center": {"x": 0, "y": 0}, "rx": 2, "ry": 1, "rotation": 0})).unwrap() - 2.0 * std::f64::consts::PI).abs() < 1e-12);
|
||||
assert_eq!(a(json!({"shape": "polyline", "closed": true, "pts": sq})), Some(16.0));
|
||||
assert_eq!(a(json!({"shape": "polyline", "closed": false, "pts": sq})), None);
|
||||
let hole = json!([{"x": 1, "y": 1}, {"x": 1, "y": 3}, {"x": 3, "y": 3}, {"x": 3, "y": 1}]);
|
||||
assert_eq!(a(json!({"shape": "polyline", "closed": true, "pts": sq, "holes": [hole]})), Some(12.0));
|
||||
// Halbkreis-Bogen (bulge 1) über der Sehne (0,0)-(2,0) + Gegenseite gerade: Fläche = Dreieck + Halbkreis.
|
||||
let tri = json!([{"x": 0, "y": 0}, {"x": 2, "y": 0}, {"x": 1, "y": -1}]);
|
||||
let g = json!({"shape": "polyline", "closed": true, "pts": tri, "bulge": [1.0, 0.0, 0.0]});
|
||||
// Dreieck ist CW (Fläche 1); Bogen links der Sehne a→b liegt ausserhalb ⇒ 1 + π/2 (r = 1); gleiches CCW mit bulge -1.
|
||||
assert!((a(g.clone()).unwrap() - (1.0 + std::f64::consts::FRAC_PI_2)).abs() < 1e-9);
|
||||
let ccw = json!({"shape": "polyline", "closed": true, "pts": [{"x": 0, "y": 0}, {"x": 2, "y": 0}, {"x": 1, "y": 1}], "bulge": [-1.0, 0.0, 0.0]});
|
||||
assert!((a(ccw).unwrap() - (1.0 + std::f64::consts::FRAC_PI_2)).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wand_mit_typ_volumen_und_fuge() {
|
||||
let r = root(json!({
|
||||
|
||||
@@ -591,6 +591,7 @@ export const de = {
|
||||
"objinfo.ceiling.openings": "Aussparungen",
|
||||
"objinfo.ceiling.removeOpening": "Aussparung entfernen",
|
||||
"objinfo.ceiling.area": "Fläche",
|
||||
"objinfo.drawing.area": "Fläche",
|
||||
"objinfo.ceiling.anchorFloor": "Gebunden",
|
||||
"objinfo.ceiling.anchorCustom": "Eigene",
|
||||
// ── Öffnungs-Attribute (Object-Info-Panel) ──────────────────────────────
|
||||
|
||||
@@ -590,6 +590,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.ceiling.openings": "Openings",
|
||||
"objinfo.ceiling.removeOpening": "Remove opening",
|
||||
"objinfo.ceiling.area": "Area",
|
||||
"objinfo.drawing.area": "Area",
|
||||
"objinfo.ceiling.anchorFloor": "Bound",
|
||||
"objinfo.ceiling.anchorCustom": "Custom",
|
||||
// ── Opening attributes (object info panel) ──────────────────────────────
|
||||
|
||||
@@ -287,6 +287,12 @@ export function ObjectInfoPanel() {
|
||||
onCommit={(v) => host.onSetDrawingTextPaperHeight(v)}
|
||||
/>
|
||||
)}
|
||||
{sel.kind === "drawing2d" && sel.area !== undefined && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.drawing.area")}</span>
|
||||
<span className="objinfo-fval">{sel.area.toFixed(2)} m²</span>
|
||||
</div>
|
||||
)}
|
||||
{drawingShape === "circle" && (
|
||||
<DimensionField
|
||||
label={t("objinfo.drawing.radius")}
|
||||
|
||||
@@ -42,6 +42,8 @@ describe("deriveSelection (Kern)", () => {
|
||||
expect(l.bbox).toEqual({ minX: 0, minY: -2, maxX: 3, maxY: 0 });
|
||||
const r = deriveSelection(p, { drawings: ["r"] })!;
|
||||
expect(r.closed).toBe(true);
|
||||
expect(r.area).toBe(3);
|
||||
expect(l.area).toBeUndefined();
|
||||
expect(r.fillHatchId).toBe("h");
|
||||
expect(r.effectiveHatchId).toBe("h");
|
||||
expect(deriveSelection(p, { drawings: ["nix"] })).toBeNull();
|
||||
|
||||
@@ -457,6 +457,8 @@ export interface SelectionInfo {
|
||||
effectiveHatchId?: string | null;
|
||||
/** Ob die Form geschlossen ist (rect/circle/closed polyline) — nur Drawing2D. */
|
||||
closed?: boolean;
|
||||
/** Fläche in m² (geschlossene Form: rect/circle/ellipse/Polylinie inkl. Bögen, netto ohne Löcher) — nur Drawing2D. */
|
||||
area?: number;
|
||||
/**
|
||||
* Ob das Element ein Bild ist (Drawing2D `{shape:"image"}`, Layout-
|
||||
* Annotation `kind:"image"` ODER Kontext-Objekt `type:"image"`) — steuert
|
||||
|
||||
Reference in new issue
Block a user