Skip to content

Commit 149b46d

Browse files
committed
Merge branch 'fix/import_body_locally' into feat/download_stride
2 parents 3b24631 + 89ceb99 commit 149b46d

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

doc/changelog.d/1683.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add unit tests for 3 repair tools

src/ansys/geometry/core/tools/repair_tools.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ def find_and_fix_short_edges(
465465
RepairToolMessage
466466
Message containing created and/or modified bodies.
467467
"""
468+
from ansys.geometry.core.designer.body import Body
469+
468470
check_type_all_elements_in_iterable(bodies, Body)
469471
check_type(length, Real)
470472

@@ -481,17 +483,15 @@ def find_and_fix_short_edges(
481483
parent_design = get_design_from_body(bodies[0])
482484
parent_design._update_design_inplace()
483485
message = RepairToolMessage(
484-
response.result.success,
485-
response.result.created_bodies_monikers,
486-
response.result.modified_bodies_monikers,
486+
response.success,
487+
response.created_bodies_monikers,
488+
response.modified_bodies_monikers,
487489
)
488490
return message
489491

490492
@protect_grpc
491493
@min_backend_version(25, 2, 0)
492-
def find_and_fix_extra_edges(
493-
self, bodies: list["Body"], length: Real = 0.0
494-
) -> RepairToolMessage:
494+
def find_and_fix_extra_edges(self, bodies: list["Body"]) -> RepairToolMessage:
495495
"""Find and fix the extra edge problem areas.
496496
497497
This method finds the extra edges in the bodies and fixes them.
@@ -508,25 +508,25 @@ def find_and_fix_extra_edges(
508508
RepairToolMessage
509509
Message containing created and/or modified bodies.
510510
"""
511+
from ansys.geometry.core.designer.body import Body
512+
511513
check_type_all_elements_in_iterable(bodies, Body)
512-
check_type(length, Real)
513514

514515
if not bodies:
515516
return RepairToolMessage(False, [], [])
516517

517518
response = self._repair_stub.FindAndFixExtraEdges(
518519
FindExtraEdgesRequest(
519520
selection=[body.id for body in bodies],
520-
max_edge_length=DoubleValue(value=length),
521521
)
522522
)
523523

524524
parent_design = get_design_from_body(bodies[0])
525525
parent_design._update_design_inplace()
526526
message = RepairToolMessage(
527-
response.result.success,
528-
response.result.created_bodies_monikers,
529-
response.result.modified_bodies_monikers,
527+
response.success,
528+
response.created_bodies_monikers,
529+
response.modified_bodies_monikers,
530530
)
531531
return message
532532

@@ -553,6 +553,8 @@ def find_and_fix_split_edges(
553553
RepairToolMessage
554554
Message containing created and/or modified bodies.
555555
"""
556+
from ansys.geometry.core.designer.body import Body
557+
556558
check_type_all_elements_in_iterable(bodies, Body)
557559
check_type(length, Real)
558560

@@ -572,8 +574,8 @@ def find_and_fix_split_edges(
572574
parent_design = get_design_from_body(bodies[0])
573575
parent_design._update_design_inplace()
574576
message = RepairToolMessage(
575-
response.result.success,
576-
response.result.created_bodies_monikers,
577-
response.result.modified_bodies_monikers,
577+
response.success,
578+
response.created_bodies_monikers,
579+
response.modified_bodies_monikers,
578580
)
579581
return message

tests/integration/test_repair_tools.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_find_and_fix_duplicate_faces(modeler: Modeler):
293293
assert len(design.bodies) == 1
294294

295295

296-
def test_find_and_fix_extra_edges(modeler: Modeler):
296+
def test_find_and_fix_extra_edges_problem_areas(modeler: Modeler):
297297
"""Test to read geometry, find and fix extra edges and validate they are removed."""
298298
design = modeler.open_file(FILES_DIR / "ExtraEdges_NoComponents.scdocx")
299299
assert len(design.bodies) == 3
@@ -365,7 +365,7 @@ def test_find_and_fix_missing_faces(modeler: Modeler):
365365
assert not comp.bodies[0].is_surface
366366

367367

368-
def test_find_and_fix_short_edges(modeler: Modeler):
368+
def test_find_and_fix_short_edges_problem_areas(modeler: Modeler):
369369
"""Test to read geometry, find and fix short edges and validate they are fixed removed."""
370370
design = modeler.open_file(FILES_DIR / "ShortEdges.scdocx")
371371
assert len(design.bodies[0].edges) == 685
@@ -376,11 +376,11 @@ def test_find_and_fix_short_edges(modeler: Modeler):
376376
assert len(design.bodies[0].edges) == 675 ##We get 673 edges if we repair all in one go
377377

378378

379-
def test_find_and_fix_split_edges(modeler: Modeler):
379+
def test_find_and_fix_split_edges_problem_areas(modeler: Modeler):
380380
"""Test to read geometry, find and fix split edges and validate they are fixed removed."""
381381
design = modeler.open_file(FILES_DIR / "bracket-with-split-edges.scdocx")
382382
assert len(design.bodies[0].edges) == 304
383-
split_edges = modeler.repair_tools.find_split_edges(design.bodies, 0.0001, 150)
383+
split_edges = modeler.repair_tools.find_split_edges(design.bodies, 2.61799, 0.01)
384384
assert len(split_edges) == 166
385385
for i in split_edges:
386386
try: # Try/Except is a workaround. Having .alive would be better
@@ -419,3 +419,34 @@ def test_fix_simplify(modeler: Modeler):
419419
design = modeler.open_file(FILES_DIR / "SOBracket2.scdocx")
420420
problem_areas = modeler.repair_tools.find_simplify(design.bodies)
421421
assert problem_areas[0].fix().success is True
422+
423+
424+
def test_find_and_fix_short_edges(modeler: Modeler):
425+
"""Test to read geometry, find and fix short edges and validate they are fixed removed."""
426+
design = modeler.open_file(FILES_DIR / "ShortEdges.scdocx")
427+
assert len(design.bodies[0].edges) == 685
428+
modeler.repair_tools.find_and_fix_short_edges(design.bodies, 0.000127)
429+
assert len(design.bodies[0].edges) == 673 ##We get 673 edges if we repair all in one go
430+
431+
432+
def test_find_and_fix_split_edges(modeler: Modeler):
433+
"""Test to read geometry, find and fix split edges and validate they are fixed removed."""
434+
design = modeler.open_file(FILES_DIR / "bracket-with-split-edges.scdocx")
435+
assert len(design.bodies[0].edges) == 304
436+
modeler.repair_tools.find_and_fix_split_edges(design.bodies, 2.61799, 0.01)
437+
assert len(design.bodies[0].edges) == 138
438+
439+
440+
def test_find_and_fix_extra_edges(modeler: Modeler):
441+
"""Test to read geometry, find and fix extra edges and validate they are removed."""
442+
design = modeler.open_file(FILES_DIR / "ExtraEdges_NoComponents.scdocx")
443+
assert len(design.bodies) == 3
444+
starting_edge_count = 0
445+
for body in design.bodies:
446+
starting_edge_count += len(body.edges)
447+
assert starting_edge_count == 69
448+
modeler.repair_tools.find_and_fix_extra_edges(design.bodies)
449+
final_edge_count = 0
450+
for body in design.bodies:
451+
final_edge_count += len(body.edges)
452+
assert final_edge_count == 36

0 commit comments

Comments
 (0)