Skip to content

test: adding test for vertex and tests based on spaceclaim tutorials #2157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/2157.test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding test for vertex and tests based on spaceclaim tutorials
13 changes: 13 additions & 0 deletions tests/_incompatible_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ backends:
- tests/integration/test_repair_tools.py::test_design_import_check_geometry
- tests/integration/test_design.py::test_import_component_named_selections
- tests/integration/test_design.py::test_component_make_independent
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
# Opening large files through streaming is only available from 25.2 onwards
- tests/integration/test_design.py::test_modeler_open_files
# Named selections elements are only consistent from 25.2 onwards
Expand All @@ -65,6 +68,7 @@ backends:
# Components and vertex only available from 26.1 onwards
- tests/integration/test_design.py::test_named_selection_contents
- tests/integration/test_design.py::test_named_selections_components
- tests/integration/test_design.py::test_vertices
# Bounding box center is only available from 25R2 onwards
- tests/integration/test_design.py::test_get_body_bounding_box
# Export to DSCO files is only available from 25R2 onwards
Expand Down Expand Up @@ -154,6 +158,9 @@ backends:
- tests/integration/test_repair_tools.py::test_design_import_check_geometry
- tests/integration/test_design.py::test_import_component_named_selections
- tests/integration/test_design.py::test_component_make_independent
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
# Opening large files through streaming is only available from 25.2 onwards
- tests/integration/test_design.py::test_modeler_open_files
# Named selections elements are only consistent from 25.2 onwards
Expand All @@ -167,6 +174,7 @@ backends:
# Components and vertex only available from 26.1 onwards
- tests/integration/test_design.py::test_named_selection_contents
- tests/integration/test_design.py::test_named_selections_components
- tests/integration/test_design.py::test_vertices
# Bounding box center is only available from 25R2 onwards
- tests/integration/test_design.py::test_get_body_bounding_box
# Export to DSCO files is only available from 25R2 onwards
Expand Down Expand Up @@ -204,6 +212,9 @@ backends:
# Model used is too new for this version
- tests/integration/test_design.py::test_import_component_named_selections
- tests/integration/test_design.py::test_component_make_independent
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
# Opening large files through streaming is only available from 25.2 onwards
- tests/integration/test_design.py::test_modeler_open_files
# Named selections elements are only consistent from 25.2 onwards
Expand All @@ -217,6 +228,7 @@ backends:
# Components and vertex only available from 26.1 onwards
- tests/integration/test_design.py::test_named_selection_contents
- tests/integration/test_design.py::test_named_selections_components
- tests/integration/test_design.py::test_vertices
# Potential problem in model/reading design for importing parameters
- tests/integration/test_design.py::test_design_parameters
# Bounding box center is only available from 25R2 onwards
Expand Down Expand Up @@ -272,6 +284,7 @@ backends:
- tests/integration/test_design.py::test_named_selection_contents
- tests/integration/test_design.py::test_named_selections_components
- tests/integration/test_design.py::test_component_make_independent
- tests/integration/test_design.py::test_vertices
# Insert/Import file operations caused problems prior to 26.1
- tests/integration/test_design_export.py::test_import_export_reimport_design_scdocx
- tests/integration/test_design_export.py::test_import_export_reimport_design_x_t
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/integration/files/Intersect.scdocx
Binary file not shown.
122 changes: 122 additions & 0 deletions tests/integration/test_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -3579,3 +3579,125 @@ def test_component_make_independent(modeler: Modeler):
comp = design.components[0].components[-1].components[-1] # stale from update-design-in-place

assert not Accuracy.length_is_equal(comp.bodies[0].volume.m, face.body.volume.m)


def test_vertices(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
design = modeler.open_file(Path(FILES_DIR, "DifferentShapes.scdocx"))

assert len(design.named_selections) == 4

edgevertex = design._named_selections["EdgeVertex"]
assert len(edgevertex.vertices) == 3

surfacevertex = design._named_selections["SurfaceVertex"]
assert len(surfacevertex.vertices) == 4

justedge = design._named_selections["JustEdge"]
assert len(justedge.vertices) == 0

spherefacevertex = design._named_selections["SphereFaceVertex"]
assert len(spherefacevertex.vertices) == 2

assert design.bodies[1].vertices[0].x.magnitude == pytest.approx(0.028, 1e-6, 1e-6)
assert design.bodies[1].vertices[0].y.magnitude == pytest.approx(-0.00288675, 1e-6, 1e-6)
assert design.bodies[1].vertices[0].z.magnitude == pytest.approx(0.01, 1e-6, 1e-6)

print(design.bodies[1].vertices[0].id == "S,~sEbf61ff70-bc08-477a-8a5e-a7c7dc955f40.853__")

assert design.bodies[0].vertices == []
assert design.bodies[1].vertices[1].position == pytest.approx(
Point3D([0.033, -0.0057735, 0.01]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[2].position == pytest.approx(
Point3D([0.028, -0.00288675, 0.0]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[3].position == pytest.approx(
Point3D([0.028, 0.00288675, 0.01]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[4].position == pytest.approx(
Point3D([0.028, 0.00288675, 0.0]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[5].position == pytest.approx(
Point3D([0.033, 0.0057735, 0.01]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[6].position == pytest.approx(
Point3D([0.033, 0.0057735, 0.0]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[7].position == pytest.approx(
Point3D([0.038, 0.00288675, 0.01]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[8].position == pytest.approx(
Point3D([0.038, 0.00288675, 0.0]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[9].position == pytest.approx(
Point3D([0.038, -0.00288675, 0.01]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[10].position == pytest.approx(
Point3D([0.038, -0.00288675, 0.0]), 1e-6, 1e-6
)
assert design.bodies[1].vertices[11].position == pytest.approx(
Point3D([0.033, -0.0057735, 0.0]), 1e-6, 1e-6
)
assert design.bodies[2].vertices[0].position == pytest.approx(
Point3D([1.60966008e-02, -9.90374453e-04, 4.87404356e-19]), 1e-6, 1e-6
)
assert design.bodies[2].vertices[1].position == pytest.approx(
Point3D([0.00580814, 0.00425186, 0.02]), 1e-6, 1e-6
)
assert design.bodies[2].vertices[2].position == pytest.approx(
Point3D([0.00580814, 0.01579886, 0.0]), 1e-6, 1e-6
)
assert design.bodies[2].vertices[3].position == pytest.approx(
Point3D([5.80814371e-03, 4.25185629e-03, -7.12805714e-20]), 1e-6, 1e-6
)
assert design.bodies[3].vertices == []
assert design.bodies[4].vertices[0].position == pytest.approx(
Point3D([-0.03, 0.001, 0.0]), 1e-6, 1e-6
)
assert design.bodies[4].vertices[1].position == pytest.approx(
Point3D([-0.03, 0.02, 0.0]), 1e-6, 1e-6
)
assert design.bodies[4].vertices[2].position == pytest.approx(
Point3D([-0.011, 0.001, 0.0]), 1e-6, 1e-6
)
assert design.bodies[4].vertices[3].position == pytest.approx(
Point3D([-0.011, 0.02, 0.0]), 1e-6, 1e-6
)
assert design.bodies[5].vertices == []
assert design.components[0].bodies[0].vertices[0].position == pytest.approx(
Point3D([0.00711, 0.03182325, 0.0]), 1e-6, 1e-6
)
assert design.components[0].bodies[0].vertices[1].position == pytest.approx(
Point3D([0.00711, 0.03759675, 0]), 1e-6, 1e-6
)
assert design.components[0].bodies[0].vertices[2].position == pytest.approx(
Point3D([0.00211, 0.0404835, 0]), 1e-6, 1e-6
)
assert design.components[0].bodies[0].vertices[3].position == pytest.approx(
Point3D([-0.00289, 0.03759675, 0]), 1e-6, 1e-6
)
assert design.components[0].bodies[0].vertices[4].position == pytest.approx(
Point3D([-0.00289, 0.03182325, 0]), 1e-6, 1e-6
)
assert design.components[0].bodies[0].vertices[5].position == pytest.approx(
Point3D([0.00211, 0.0289365, 0]), 1e-6, 1e-6
)

vert = [design.bodies[1].vertices[0], design.bodies[2].vertices[3]]
edg = [design.bodies[1].edges[0], design.bodies[2].edges[0]]
fac = [design.bodies[1].faces[0], design.bodies[2].faces[1]]
design.create_named_selection("Test", vertices=vert, edges=edg, faces=fac)
assert len(design.named_selections) == 5

testns = design._named_selections["Test"]
assert len(testns.vertices) == 2

location = tmp_path_factory.mktemp("test_export_to_scdocx")
file_location = location / f"{design.name}.scdocx"
design.export_to_scdocx(location)
assert file_location.exists()
design_read = modeler.open_file(file_location)
assert len(design_read.named_selections) == 5

exportedtestns = design_read._named_selections["Test"]
assert len(exportedtestns.vertices) == 2
Loading
Loading