[169] Runde Formen, Reste: Ellipsenbögen in der Ansicht (SVG A mit zwei Radien, DXF ELLIPSE, fileio Satz 26), verrauschte Ringe stückweise als Ausgleichskreise, DXF/DWG-HATCH-Ränder mit Bulges (Satz 25), Bogenwände im 3D glatt (render3d arcCenter), Dachstirn gekrümmter Dachränder ohne Facettenfugen in Ansicht/Schnitt; Tests, Goldens, TODO, Doku

This commit is contained in:
Claude committed 2026-11-10 10:16:24 +00:00
1 parent 977cbee260
commit 3b0e9c6ff9
31 files changed
+1134 -115

No files matched your search

+1
View File
@@ -45,6 +45,7 @@ fn demo_walls() -> Vec<WallInput> {
cut: None,
start_cut: None,
end_cut: None,
arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
};
+9 -9
View File
@@ -73,7 +73,7 @@ mod tests {
/// Bequemer Bau einer achsparallelen Wand entlang +X.
fn wall_x(len: f32, thickness: f32, height: f32) -> WallInput {
WallInput {
WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -308,7 +308,7 @@ mod tests {
fn mehrere_waende_addieren_sich() {
let mesh = build_walls_mesh(&[
wall_x(3.0, 0.2, 2.5),
WallInput {
WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [3.0, 0.0],
@@ -394,7 +394,7 @@ mod tests {
#[test]
fn diagonale_wand_hat_gleiche_zaehlung() {
// Auch nicht-achsparallele Waende extrudieren korrekt (nur andere Ecken).
let w = WallInput {
let w = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -423,7 +423,7 @@ mod tests {
#[test]
fn degenerierte_wand_erzeugt_nichts() {
// Start == Ende -> keine Richtung -> uebersprungen (kein Absturz).
let w = WallInput {
let w = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [1.0, 1.0],
@@ -644,7 +644,7 @@ mod tests {
// anderen ueber den Knoten hinaus); MIT Gehrung muessen alle Vertices IM
// Eckbereich exakt auf der 45-Grad-Gehrungslinie |x| == |z| liegen —
// weder darueber hinaus (Ueberstand) noch darunter (Spalt).
let a = WallInput {
let a = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -662,7 +662,7 @@ mod tests {
start_cut: None,
end_cut: None,
};
let b = WallInput {
let b = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -729,7 +729,7 @@ mod tests {
// Drei Wandenden treffen sich im selben Knoten (T-Stoss) -> gemaess
// Moduldoc/`joins.ts` bewusst NICHT gehrt (mehrdeutig), alle drei bleiben
// rechtwinklig. Regressions-Absicherung: keine Panik, stabile Zaehlung.
let mk = |s: [f32; 2], e: [f32; 2]| WallInput {
let mk = |s: [f32; 2], e: [f32; 2]| WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: s,
@@ -765,7 +765,7 @@ mod tests {
// beide Geschosse zusammen liefern exakt dieselbe Gehrung wie ein
// einzelnes Geschoss fuer sich (Vertex-Zaehlung + Eck-Vertices je
// Geschoss weiterhin auf der 45-Grad-Linie relativ zu SEINER Basis).
let mk = |s: [f32; 2], e: [f32; 2], base: f32| WallInput {
let mk = |s: [f32; 2], e: [f32; 2], base: f32| WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: s,
@@ -861,7 +861,7 @@ mod tests {
WallLayer { thickness: 0.15, color: [0.6, 0.3, 0.2] },
])
};
let a = WallInput {
let a = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
+84
View File
@@ -100,6 +100,45 @@ pub fn extrude_wall(mesh: &mut Mesh, wall: &WallInput) {
/// Sturz) zerlegt, mit `layers` zusaetzlich in Schicht-Baender quer zur
/// Dicke — siehe Moduldoc.
pub(crate) fn extrude_wall_with_miters(mesh: &mut Mesh, wall: &WallInput, miters: WallMiters) {
let first = mesh.vertex_count();
extrude_wall_flat(mesh, wall, miters);
if let Some(c) = wall.arc_center {
smooth_arc_normals(mesh, first, c);
}
}
/// [169] Knickwinkel (Grad) der glatten Bogenwand: wie die runde Stütze (Kern `model3d/columns.rs`).
pub const ARC_CREASE_DEG: f32 = 30.0;
/// [169] Bogenwand glatt schattieren: Ecken ab `first` mit waagrechter Normale, die hoechstens
/// [`ARC_CREASE_DEG`] von der Radialen um `c` (Grundriss, Welt x/z) abweicht, bekommen die radiale Normale
/// (aussen bzw. innen nach ihrer Flaechennormale). Nachbar-Sehnen treffen sich so mit derselben Normale —
/// keine Facetten; Stirnen, Laibungen, Deckel und Boden bleiben kantig.
fn smooth_arc_normals(mesh: &mut Mesh, first: usize, c: Point2) {
let cos = ARC_CREASE_DEG.to_radians().cos();
let count = mesh.vertex_count();
for v in first..count {
let o = v * FLOATS_PER_VERTEX;
let (px, pz) = (mesh.verts[o], mesh.verts[o + 2]);
let (nx, ny, nz) = (mesh.verts[o + 3], mesh.verts[o + 4], mesh.verts[o + 5]);
let (rx, rz) = (px - c[0], pz - c[1]);
let rl = (rx * rx + rz * rz).sqrt();
let nl = (nx * nx + nz * nz).sqrt();
if !(rl > 1e-6) || !(nl > 1e-6) || ny.abs() > 1e-3 * nl.max(1e-3) {
continue;
}
let d = (nx * rx + nz * rz) / (nl * rl);
if d.abs() < cos {
continue;
}
let s = d.signum() / rl;
mesh.verts[o + 3] = rx * s;
mesh.verts[o + 4] = 0.0;
mesh.verts[o + 5] = rz * s;
}
}
fn extrude_wall_flat(mesh: &mut Mesh, wall: &WallInput, miters: WallMiters) {
let n = left_normal(wall.start, wall.end);
// Degenerierte Wand (Start == Ende) ueberspringen.
if n == [0.0, 0.0] {
@@ -1795,6 +1834,51 @@ mod tests {
assert_eq!(&mesh.verts[base..base + 3], &[2.0, 4.0, -3.0]);
}
/// [169] Bogenwand aus zwei Sehnen-Teilwänden (r = 4 um den Ursprung, je 7.5°): mit `arcCenter` tragen die
/// Mantelecken die radiale Normale (an der gemeinsamen Fuge beider Teile dieselbe), Deckel und Stirnen
/// bleiben kantig; ohne `arcCenter` je Sehne die flache Normale.
#[test]
fn bogenwand_glatt_schattiert() {
let p = |deg: f32| [4.0 * deg.to_radians().cos(), 4.0 * deg.to_radians().sin()];
let wall = |a: f32, b: f32, c: Option<[f32; 2]>| -> WallInput {
let mut w: WallInput = serde_json::from_str(r#"{"start":[0,0],"end":[1,0],"thickness":0.2,"height":2.5}"#).unwrap();
w.start = p(a);
w.end = p(b);
w.arc_center = c;
w
};
let normals_at = |m: &Mesh, q: [f32; 2], r: f32| -> Vec<[f32; 3]> {
(0..m.vertex_count())
.filter_map(|v| {
let o = v * FLOATS_PER_VERTEX;
let x = &m.verts[o..o + 6];
let rr = (x[0] * x[0] + x[2] * x[2]).sqrt();
((x[0] * q[1] - x[2] * q[0]).abs() < 1e-4 && (rr - r).abs() < 1e-3 && x[1] > 0.1 && x[4].abs() < 0.5 && (x[3] * q[0] + x[5] * q[1]).abs() > 0.5).then_some([x[3], x[4], x[5]])
})
.collect()
};
let smooth = build_walls_mesh(&[wall(0.0, 7.5, Some([0.0, 0.0])), wall(7.5, 15.0, Some([0.0, 0.0]))]);
let flat = build_walls_mesh(&[wall(0.0, 7.5, None), wall(7.5, 15.0, None)]);
// Fuge bei 7.5° auf der Aussenseite (r ≈ 4.1): alle Normalen radial nach aussen.
let j = p(7.5);
let dir = [j[0] / 4.0, j[1] / 4.0];
let ns = normals_at(&smooth, dir, 4.1);
assert!(ns.len() >= 2, "{ns:?}");
assert!(ns.iter().all(|n| (n[0] - dir[0]).abs() < 1e-5 && n[1] == 0.0 && (n[2] - dir[1]).abs() < 1e-5), "{ns:?}");
let nf = normals_at(&flat, dir, 4.1);
assert!(nf.iter().any(|n| (n[0] - dir[0]).abs() > 1e-3), "flach: {nf:?}");
// Deckel bleibt waagrecht, Geometrie unverändert.
assert!((0..smooth.vertex_count()).any(|v| smooth.verts[v * FLOATS_PER_VERTEX + 4] == 1.0));
assert_eq!(smooth.vertex_count(), flat.vertex_count());
for v in 0..smooth.vertex_count() {
let o = v * FLOATS_PER_VERTEX;
assert_eq!(smooth.verts[o..o + 3], flat.verts[o..o + 3]);
}
// JSON: `arcCenter` gelesen, ohne Feld `None`.
let w: WallInput = serde_json::from_str(r#"{"start":[0,0],"end":[1,0],"thickness":0.2,"height":2.5,"arcCenter":[1,2]}"#).unwrap();
assert_eq!(w.arc_center, Some([1.0, 2.0]));
}
/// [T4] Zwei Dreiecke mit 10°-Knick, Kante NICHT geteilt (eigene Punkte gleicher Lage): glatt mit
/// 30° bekommen die Kantenpunkte beider Dreiecke dieselbe Normale, mit 5° (oder ohne) die
/// Flaechennormalen; die Rueckseite traegt die Gegennormale.
+6 -6
View File
@@ -1271,7 +1271,7 @@ mod tests {
fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
let color = [0.8, 0.8, 0.8];
let walls = vec![
WallInput {
WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -1289,7 +1289,7 @@ mod tests {
start_cut: None,
end_cut: None,
},
WallInput {
WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 3.0],
@@ -1368,7 +1368,7 @@ mod tests {
/// also weggeschnitten) darf die Rueckwand dahinter NICHT verdecken.
#[test]
fn wand_vor_der_ebene_verdeckt_nichts_dahinter() {
let mk = |start: [f32; 2], end: [f32; 2]| WallInput {
let mk = |start: [f32; 2], end: [f32; 2]| WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start,
@@ -1590,7 +1590,7 @@ mod tests {
/// entlang der Achse [1.5, 2.5] (1 m breit), Bruestung 1.0 m, Fensterhoehe
/// 1.0 m (Sturz beginnt also bei 2.0, Wand-Oberkante bei 2.5 -> 0.5 m Sturz).
fn wall_with_window() -> WallInput {
WallInput {
WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -1707,7 +1707,7 @@ mod tests {
// achse (0,0)->(4,0) steht dabei u-parallel -> Elevations-Fall, siehe
// Moduldoc "Oeffnungen").
let w0 = wall_with_window();
let w1 = WallInput {
let w1 = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [2.0, 1.0],
@@ -1829,7 +1829,7 @@ mod tests {
/// UNBEEINFLUSST von einer gleichzeitig geschnittenen Wand.
#[test]
fn cut_section_mit_wand_und_dach_liefert_beide_cut_polygone() {
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [2.0, -1.0],
+6 -6
View File
@@ -339,7 +339,7 @@ mod tests {
/// Cap-Vertex an den Positionen 5/6/7 landen (Vertex-Stride = 8).
#[test]
fn hatch_muster_id_landet_in_den_cap_vertices() {
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -389,7 +389,7 @@ mod tests {
/// Ribbons aus dem Kern-Generator in den Cut-Linien — mehr Dreiecke als ohne Muster, alle in der Schnittebene.
#[test]
fn generator_muster_kommt_als_ribbons() {
let mk = |pattern: u32| WallInput {
let mk = |pattern: u32| WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -427,7 +427,7 @@ mod tests {
/// angle 0, scale 1) zurueck — das reproduziert das fruehere fixe 45°-Muster.
#[test]
fn ohne_hatch_fallback_auf_diagonale() {
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -464,7 +464,7 @@ mod tests {
#[test]
fn build_cut_caps_wendet_dominanz_an_wand_verliert_ueberlappung() {
// Wand entlang +X bei x in [0,3], Dicke 0.4, volle Hoehe [0,2.5]; Prio 50.
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -542,7 +542,7 @@ mod tests {
fn wand_schneidet_schwaechere_decken_schichten() {
// Backstein-Wand entlang +X, x in [0,3], Dicke 0.4 → u (=y) in [-0.2,0.2],
// volle Hoehe [0,2.5]; Prio 50, Muster 2 (diagonal).
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
@@ -628,7 +628,7 @@ mod tests {
#[test]
fn build_cut_cap_lines_kantenzahl_und_stil() {
let color = [0.2, 0.4, 0.9];
let wall = WallInput {
let wall = WallInput { arc_center: None,
top_drop: [0.0, 0.0],
top_plane: None,
start: [0.0, 0.0],
+5
View File
@@ -202,6 +202,11 @@ pub struct WallInput {
pub start_cut: Option<[f32; 4]>,
#[serde(default, rename = "endCut")]
pub end_cut: Option<[f32; 4]>,
/// [169] Sehnen-Teilkörper einer Bogenwand: Mittelpunkt des Bogens (Grundriss-Meter). Die Mantelflächen
/// (Normale höchstens [`crate::mesh::ARC_CREASE_DEG`] von der Radialen) tragen dann die radiale Normale je
/// Ecke — glatt schattiert wie die runde Stütze, ohne Facetten; Stirnen, Laibungen, Deckel bleiben kantig.
#[serde(default, rename = "arcCenter", skip_serializing_if = "Option::is_none")]
pub arc_center: Option<[f32; 2]>,
}
/// Ein rechteckiges Loch (Fenster/Tuer) in EINEM Wandkoerper. Siehe