Skip to content

Commit

Permalink
Added a test for nested cubes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwright committed Jan 29, 2025
1 parent a47ce50 commit 86b6e01
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/sample_assemblies.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 14 additions & 0 deletions tests/smoke_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
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()

# Create a mesh that has all the faces tagged as physical groups
assy.saveToGmsh(mesh_path="tagged_nested_boxes.msh")


def test_basic_assembly():
"""
Tests to make sure that the most basic assembly works correctly with tagging.
Expand Down

0 comments on commit 86b6e01

Please sign in to comment.