diff --git a/tests/sample_assemblies.py b/tests/sample_assemblies.py index 0c06115..7c69b61 100644 --- a/tests/sample_assemblies.py +++ b/tests/sample_assemblies.py @@ -1,6 +1,36 @@ import cadquery as cq +def generate_nested_boxes(): + """ + Generates a simple assembly of two cubes where one is nested inside the other. + """ + + # Cube that is nested completely inside the other one + inside_cube = cq.Workplane().box(5, 5, 5) + + # Use the inside cube to make a void inside the outside cube + outside_cube = cq.Workplane().box(10, 10, 10) + outside_cube = outside_cube.cut(inside_cube) + + # Create the assembly + assy = cq.Assembly() + assy.add( + outside_cube, + name="outside_cube", + loc=cq.Location(cq.Vector(0, 0, 0)), + color=cq.Color("blue"), + ) + assy.add( + inside_cube, + name="inside_cube", + loc=cq.Location(cq.Vector(0, 0, 0)), + color=cq.Color("red"), + ) + + return assy + + def generate_simple_nested_boxes(): """ Generates the simplest assembly case where two boxes are nested inside each other. diff --git a/tests/smoke_test.py b/tests/smoke_test.py index eb36f75..51426bb 100644 --- a/tests/smoke_test.py +++ b/tests/smoke_test.py @@ -1,11 +1,29 @@ import assembly_mesh_plugin.plugin from tests.sample_assemblies import ( + generate_nested_boxes, generate_simple_nested_boxes, generate_test_cross_section, generate_assembly, ) +def test_nested_cubes(): + """ + Tests to make sure that the nested cubes do not cause the correct number of surfaces + in the mesh. + """ + + # Create the basic assembly + assy = generate_nested_boxes() + + # Convert the assembly to a GMSH mesh + gmsh = assy.getTaggedGmsh() + + # Make sure we have the correct number of surfaces + surfaces = gmsh.model.getEntities(2) + assert len(surfaces) == 18 + + def test_basic_assembly(): """ Tests to make sure that the most basic assembly works correctly with tagging.