|
30 | 30 | import bonsai.tool as tool |
31 | 31 | import numpy as np |
32 | 32 | import json |
| 33 | +from typing import Any |
33 | 34 | from test.bim.bootstrap import NewFile |
34 | 35 | from bonsai.tool.model import Model as subject |
35 | 36 | from ifcopenshell.util.shape_builder import V, ShapeBuilder |
@@ -222,18 +223,20 @@ def compare_data(self, generated_profile, expected_profile): |
222 | 223 | for vert, vert_gen in zip(verts, verts_gen, strict=True): |
223 | 224 | assert np.allclose(vert, V(vert_gen), atol=0.01) |
224 | 225 |
|
| 226 | + CONCRETE_STAIR_KWARGS: dict[str, Any] = { |
| 227 | + "base_slab_depth": 0.25, |
| 228 | + "has_top_nib": False, |
| 229 | + "height": 1.0, |
| 230 | + "number_of_treads": 3, |
| 231 | + "stair_type": "CONCRETE", |
| 232 | + "top_slab_depth": 0.25, |
| 233 | + "tread_depth": 0.25, |
| 234 | + "tread_run": 0.3, |
| 235 | + "width": 1.2, |
| 236 | + } |
| 237 | + |
225 | 238 | def test_create_concrete_stair(self): |
226 | | - kwargs = { |
227 | | - "base_slab_depth": 0.25, |
228 | | - "has_top_nib": False, |
229 | | - "height": 1.0, |
230 | | - "number_of_treads": 3, |
231 | | - "stair_type": "CONCRETE", |
232 | | - "top_slab_depth": 0.25, |
233 | | - "tread_depth": 0.25, |
234 | | - "tread_run": 0.3, |
235 | | - "width": 1.2, |
236 | | - } |
| 239 | + kwargs = self.CONCRETE_STAIR_KWARGS.copy() |
237 | 240 | verts_data = ( |
238 | 241 | V(0.0, 0, 0.0), |
239 | 242 | V(0.0, 0, 0.25), |
@@ -269,17 +272,8 @@ def test_create_concrete_stair(self): |
269 | 272 | self.compare_data(generated_profile, expected_profile) |
270 | 273 |
|
271 | 274 | def test_create_concrete_stair_nib(self): |
272 | | - kwargs = { |
273 | | - "base_slab_depth": 0.25, |
274 | | - "has_top_nib": True, |
275 | | - "height": 1.0, |
276 | | - "number_of_treads": 3, |
277 | | - "stair_type": "CONCRETE", |
278 | | - "top_slab_depth": 0.25, |
279 | | - "tread_depth": 0.25, |
280 | | - "tread_run": 0.3, |
281 | | - "width": 1.2, |
282 | | - } |
| 275 | + kwargs = self.CONCRETE_STAIR_KWARGS.copy() |
| 276 | + kwargs["has_top_nib"] = True |
283 | 277 | verts_data = ( |
284 | 278 | V(0.0, 0, 0.0), |
285 | 279 | V(0.0, 0, 0.25), |
@@ -318,19 +312,8 @@ def test_create_concrete_stair_nib(self): |
318 | 312 | self.compare_data(generated_profile, expected_profile) |
319 | 313 |
|
320 | 314 | def test_create_concrete_stair_zero_width_first_tread(self): |
321 | | - """Test concrete stair with zero-width first tread""" |
322 | | - kwargs = { |
323 | | - "base_slab_depth": 0.25, |
324 | | - "has_top_nib": False, |
325 | | - "height": 1.0, |
326 | | - "number_of_treads": 3, |
327 | | - "stair_type": "CONCRETE", |
328 | | - "top_slab_depth": 0.25, |
329 | | - "tread_depth": 0.25, |
330 | | - "tread_run": 0.3, |
331 | | - "width": 1.2, |
332 | | - "custom_first_last_tread_run": (0.0, 0.0), |
333 | | - } |
| 315 | + kwargs = self.CONCRETE_STAIR_KWARGS.copy() |
| 316 | + kwargs["custom_first_last_tread_run"] = (0.0, None) |
334 | 317 | verts_data = ( |
335 | 318 | V(0.0, 0, 0.0), |
336 | 319 | # First tread skipped - goes straight to second tread |
@@ -361,19 +344,8 @@ def test_create_concrete_stair_zero_width_first_tread(self): |
361 | 344 | self.compare_data(generated_profile, expected_profile) |
362 | 345 |
|
363 | 346 | def test_create_concrete_stair_zero_width_last_tread(self): |
364 | | - """Test concrete stair with zero-width last tread""" |
365 | | - kwargs = { |
366 | | - "base_slab_depth": 0.25, |
367 | | - "has_top_nib": False, |
368 | | - "height": 1.0, |
369 | | - "number_of_treads": 3, |
370 | | - "stair_type": "CONCRETE", |
371 | | - "top_slab_depth": 0.25, |
372 | | - "tread_depth": 0.25, |
373 | | - "tread_run": 0.3, |
374 | | - "width": 1.2, |
375 | | - "custom_first_last_tread_run": (0.0, 0.0), |
376 | | - } |
| 347 | + kwargs = self.CONCRETE_STAIR_KWARGS.copy() |
| 348 | + kwargs["custom_first_last_tread_run"] = (None, 0.0) |
377 | 349 | verts_data = ( |
378 | 350 | V(0.0, 0, 0.0), |
379 | 351 | V(0.0, 0, 0.25), |
@@ -405,15 +377,17 @@ def test_create_concrete_stair_zero_width_last_tread(self): |
405 | 377 | generated_profile = subject.generate_stair_2d_profile(**kwargs) |
406 | 378 | self.compare_data(generated_profile, expected_profile) |
407 | 379 |
|
| 380 | + WOOD_STEEL_STAIR_KWARGS: dict[str, Any] = { |
| 381 | + "height": 1.0, |
| 382 | + "number_of_treads": 3, |
| 383 | + "stair_type": "WOOD/STEEL", |
| 384 | + "tread_depth": 0.25, |
| 385 | + "tread_run": 0.3, |
| 386 | + "width": 1.2, |
| 387 | + } |
| 388 | + |
408 | 389 | def test_create_wood_steel_stair(self): |
409 | | - kwargs = { |
410 | | - "height": 1.0, |
411 | | - "number_of_treads": 3, |
412 | | - "stair_type": "WOOD/STEEL", |
413 | | - "tread_depth": 0.25, |
414 | | - "tread_run": 0.3, |
415 | | - "width": 1.2, |
416 | | - } |
| 390 | + kwargs = self.WOOD_STEEL_STAIR_KWARGS.copy() |
417 | 391 | verts_data = ( |
418 | 392 | V(0.0, 0, 0.0), |
419 | 393 | V(0.3, 0, 0.0), |
@@ -458,16 +432,8 @@ def test_create_wood_steel_stair(self): |
458 | 432 | self.compare_data(generated_profile, expected_profile) |
459 | 433 |
|
460 | 434 | def test_create_wood_steel_stair_zero_width_first_tread(self): |
461 | | - """Test wood/steel stair with zero-width first tread""" |
462 | | - kwargs = { |
463 | | - "height": 1.0, |
464 | | - "number_of_treads": 3, |
465 | | - "stair_type": "WOOD/STEEL", |
466 | | - "tread_depth": 0.25, |
467 | | - "tread_run": 0.3, |
468 | | - "width": 1.2, |
469 | | - "custom_first_last_tread_run": (0.0, 0.0), |
470 | | - } |
| 435 | + kwargs = self.WOOD_STEEL_STAIR_KWARGS.copy() |
| 436 | + kwargs["custom_first_last_tread_run"] = (0.0, None) |
471 | 437 | verts_data = ( |
472 | 438 | # First tread skipped - start at second tread |
473 | 439 | V(0.0, 0, 0.25), |
@@ -506,15 +472,9 @@ def test_create_wood_steel_stair_zero_width_first_tread(self): |
506 | 472 |
|
507 | 473 | def test_create_wood_steel_stair_zero_width_last_tread(self): |
508 | 474 | """Test wood/steel stair with zero-width last tread""" |
509 | | - kwargs = { |
510 | | - "height": 1.0, |
511 | | - "number_of_treads": 3, |
512 | | - "stair_type": "WOOD/STEEL", |
513 | | - "tread_depth": 0.25, |
514 | | - "tread_run": 0.3, |
515 | | - "width": 1.2, |
516 | | - "custom_first_last_tread_run": (0.0, 0.0), |
517 | | - } |
| 475 | + kwargs = self.WOOD_STEEL_STAIR_KWARGS.copy() |
| 476 | + kwargs["custom_first_last_tread_run"] = (None, 0.0) |
| 477 | + |
518 | 478 | verts_data = ( |
519 | 479 | V(0.0, 0, 0.0), |
520 | 480 | V(0.3, 0, 0.0), |
@@ -551,8 +511,16 @@ def test_create_wood_steel_stair_zero_width_last_tread(self): |
551 | 511 | generated_profile = subject.generate_stair_2d_profile(**kwargs) |
552 | 512 | self.compare_data(generated_profile, expected_profile) |
553 | 513 |
|
| 514 | + GENERIC_STAIR_KWARGS: dict[str, Any] = { |
| 515 | + "height": 1.0, |
| 516 | + "number_of_treads": 3, |
| 517 | + "stair_type": "GENERIC", |
| 518 | + "tread_run": 0.3, |
| 519 | + "width": 1.2, |
| 520 | + } |
| 521 | + |
554 | 522 | def test_create_generic_stair(self): |
555 | | - kwargs = {"height": 1.0, "number_of_treads": 3, "stair_type": "GENERIC", "tread_run": 0.3, "width": 1.2} |
| 523 | + kwargs = self.GENERIC_STAIR_KWARGS.copy() |
556 | 524 | verts_data = ( |
557 | 525 | V(0.0, 0, 0.0), |
558 | 526 | V(0.0, 0, 0.25), |
@@ -585,15 +553,8 @@ def test_create_generic_stair(self): |
585 | 553 | self.compare_data(generated_profile, expected_profile) |
586 | 554 |
|
587 | 555 | def test_create_generic_stair_zero_width_treads(self): |
588 | | - """Test generic stair with zero-width first and last treads""" |
589 | | - kwargs = { |
590 | | - "height": 1.0, |
591 | | - "number_of_treads": 3, |
592 | | - "stair_type": "GENERIC", |
593 | | - "tread_run": 0.3, |
594 | | - "width": 1.2, |
595 | | - "custom_first_last_tread_run": (0.0, 0.0), |
596 | | - } |
| 556 | + kwargs = self.GENERIC_STAIR_KWARGS.copy() |
| 557 | + kwargs["custom_first_last_tread_run"] = (0.0, 0.0) |
597 | 558 | verts_data = ( |
598 | 559 | V(0.0, 0, 0.0), |
599 | 560 | # First tread skipped |
|
0 commit comments