Skip to content

Commit 86b6e01

Browse files
committed
Added a test for nested cubes
1 parent a47ce50 commit 86b6e01

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/sample_assemblies.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
import cadquery as cq
22

33

4+
def generate_nested_boxes():
5+
"""
6+
Generates a simple assembly of two cubes where one is nested inside the other.
7+
"""
8+
9+
# Cube that is nested completely inside the other one
10+
inside_cube = cq.Workplane().box(5, 5, 5)
11+
12+
# Use the inside cube to make a void inside the outside cube
13+
outside_cube = cq.Workplane().box(10, 10, 10)
14+
outside_cube = outside_cube.cut(inside_cube)
15+
16+
# Create the assembly
17+
assy = cq.Assembly()
18+
assy.add(
19+
outside_cube,
20+
name="outside_cube",
21+
loc=cq.Location(cq.Vector(0, 0, 0)),
22+
color=cq.Color("blue")
23+
)
24+
assy.add(
25+
inside_cube,
26+
name="inside_cube",
27+
loc=cq.Location(cq.Vector(0, 0, 0)),
28+
color=cq.Color("red")
29+
)
30+
31+
return assy
32+
33+
434
def generate_simple_nested_boxes():
535
"""
636
Generates the simplest assembly case where two boxes are nested inside each other.

tests/smoke_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import assembly_mesh_plugin.plugin
22
from tests.sample_assemblies import (
3+
generate_nested_boxes,
34
generate_simple_nested_boxes,
45
generate_test_cross_section,
56
generate_assembly,
67
)
78

89

10+
def test_nested_cubes():
11+
"""
12+
Tests to make sure that the nested cubes do not cause the correct number of surfaces
13+
in the mesh.
14+
"""
15+
16+
# Create the basic assembly
17+
assy = generate_nested_boxes()
18+
19+
# Create a mesh that has all the faces tagged as physical groups
20+
assy.saveToGmsh(mesh_path="tagged_nested_boxes.msh")
21+
22+
923
def test_basic_assembly():
1024
"""
1125
Tests to make sure that the most basic assembly works correctly with tagging.

0 commit comments

Comments
 (0)