Skip to content

Commit 5bf5f74

Browse files
syscordanpyansys-ci-botRobPasMue
authored
test: adding test for vertex and tests based on spaceclaim tutorials (#2157)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent fd2ddc6 commit 5bf5f74

File tree

8 files changed

+940
-0
lines changed

8 files changed

+940
-0
lines changed

doc/changelog.d/2157.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding test for vertex and tests based on spaceclaim tutorials

tests/_incompatible_tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ backends:
5454
- tests/integration/test_repair_tools.py::test_design_import_check_geometry
5555
- tests/integration/test_design.py::test_import_component_named_selections
5656
- tests/integration/test_design.py::test_component_make_independent
57+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
58+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
59+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
5760
# Opening large files through streaming is only available from 25.2 onwards
5861
- tests/integration/test_design.py::test_modeler_open_files
5962
# Named selections elements are only consistent from 25.2 onwards
@@ -65,6 +68,7 @@ backends:
6568
# Components and vertex only available from 26.1 onwards
6669
- tests/integration/test_design.py::test_named_selection_contents
6770
- tests/integration/test_design.py::test_named_selections_components
71+
- tests/integration/test_design.py::test_vertices
6872
# Bounding box center is only available from 25R2 onwards
6973
- tests/integration/test_design.py::test_get_body_bounding_box
7074
# Export to DSCO files is only available from 25R2 onwards
@@ -159,6 +163,9 @@ backends:
159163
- tests/integration/test_repair_tools.py::test_design_import_check_geometry
160164
- tests/integration/test_design.py::test_import_component_named_selections
161165
- tests/integration/test_design.py::test_component_make_independent
166+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
167+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
168+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
162169
# Opening large files through streaming is only available from 25.2 onwards
163170
- tests/integration/test_design.py::test_modeler_open_files
164171
# Named selections elements are only consistent from 25.2 onwards
@@ -173,6 +180,7 @@ backends:
173180
# Components and vertex only available from 26.1 onwards
174181
- tests/integration/test_design.py::test_named_selection_contents
175182
- tests/integration/test_design.py::test_named_selections_components
183+
- tests/integration/test_design.py::test_vertices
176184
# Bounding box center is only available from 25R2 onwards
177185
- tests/integration/test_design.py::test_get_body_bounding_box
178186
# Export to DSCO files is only available from 25R2 onwards
@@ -214,6 +222,9 @@ backends:
214222
# Model used is too new for this version
215223
- tests/integration/test_design.py::test_import_component_named_selections
216224
- tests/integration/test_design.py::test_component_make_independent
225+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_combine_example
226+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_pull_example
227+
- tests/integration/test_spaceclaim_tutorial_examples.py::test_intersect_example
217228
# Opening large files through streaming is only available from 25.2 onwards
218229
- tests/integration/test_design.py::test_modeler_open_files
219230
# Named selections elements are only consistent from 25.2 onwards
@@ -228,6 +239,7 @@ backends:
228239
# Components and vertex only available from 26.1 onwards
229240
- tests/integration/test_design.py::test_named_selection_contents
230241
- tests/integration/test_design.py::test_named_selections_components
242+
- tests/integration/test_design.py::test_vertices
231243
# Potential problem in model/reading design for importing parameters
232244
- tests/integration/test_design.py::test_design_parameters
233245
# Bounding box center is only available from 25R2 onwards
@@ -287,6 +299,7 @@ backends:
287299
- tests/integration/test_design.py::test_named_selection_contents
288300
- tests/integration/test_design.py::test_named_selections_components
289301
- tests/integration/test_design.py::test_component_make_independent
302+
- tests/integration/test_design.py::test_vertices
290303
# Insert/Import file operations caused problems prior to 26.1
291304
- tests/integration/test_design_export.py::test_import_export_reimport_design_scdocx
292305
- tests/integration/test_design_export.py::test_import_export_reimport_design_x_t
121 KB
Binary file not shown.
3.89 MB
Binary file not shown.
225 KB
Binary file not shown.
5.61 MB
Binary file not shown.

tests/integration/test_design.py

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,6 +3665,128 @@ def test_component_make_independent(modeler: Modeler):
36653665
assert not Accuracy.length_is_equal(comp.bodies[0].volume.m, face.body.volume.m)
36663666

36673667

3668+
def test_vertices(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
3669+
design = modeler.open_file(Path(FILES_DIR, "DifferentShapes.scdocx"))
3670+
3671+
assert len(design.named_selections) == 4
3672+
3673+
edgevertex = design._named_selections["EdgeVertex"]
3674+
assert len(edgevertex.vertices) == 3
3675+
3676+
surfacevertex = design._named_selections["SurfaceVertex"]
3677+
assert len(surfacevertex.vertices) == 4
3678+
3679+
justedge = design._named_selections["JustEdge"]
3680+
assert len(justedge.vertices) == 0
3681+
3682+
spherefacevertex = design._named_selections["SphereFaceVertex"]
3683+
assert len(spherefacevertex.vertices) == 2
3684+
3685+
assert design.bodies[1].vertices[0].x.magnitude == pytest.approx(0.028, 1e-6, 1e-6)
3686+
assert design.bodies[1].vertices[0].y.magnitude == pytest.approx(-0.00288675, 1e-6, 1e-6)
3687+
assert design.bodies[1].vertices[0].z.magnitude == pytest.approx(0.01, 1e-6, 1e-6)
3688+
3689+
print(design.bodies[1].vertices[0].id == "S,~sEbf61ff70-bc08-477a-8a5e-a7c7dc955f40.853__")
3690+
3691+
assert design.bodies[0].vertices == []
3692+
assert design.bodies[1].vertices[1].position == pytest.approx(
3693+
Point3D([0.033, -0.0057735, 0.01]), 1e-6, 1e-6
3694+
)
3695+
assert design.bodies[1].vertices[2].position == pytest.approx(
3696+
Point3D([0.028, -0.00288675, 0.0]), 1e-6, 1e-6
3697+
)
3698+
assert design.bodies[1].vertices[3].position == pytest.approx(
3699+
Point3D([0.028, 0.00288675, 0.01]), 1e-6, 1e-6
3700+
)
3701+
assert design.bodies[1].vertices[4].position == pytest.approx(
3702+
Point3D([0.028, 0.00288675, 0.0]), 1e-6, 1e-6
3703+
)
3704+
assert design.bodies[1].vertices[5].position == pytest.approx(
3705+
Point3D([0.033, 0.0057735, 0.01]), 1e-6, 1e-6
3706+
)
3707+
assert design.bodies[1].vertices[6].position == pytest.approx(
3708+
Point3D([0.033, 0.0057735, 0.0]), 1e-6, 1e-6
3709+
)
3710+
assert design.bodies[1].vertices[7].position == pytest.approx(
3711+
Point3D([0.038, 0.00288675, 0.01]), 1e-6, 1e-6
3712+
)
3713+
assert design.bodies[1].vertices[8].position == pytest.approx(
3714+
Point3D([0.038, 0.00288675, 0.0]), 1e-6, 1e-6
3715+
)
3716+
assert design.bodies[1].vertices[9].position == pytest.approx(
3717+
Point3D([0.038, -0.00288675, 0.01]), 1e-6, 1e-6
3718+
)
3719+
assert design.bodies[1].vertices[10].position == pytest.approx(
3720+
Point3D([0.038, -0.00288675, 0.0]), 1e-6, 1e-6
3721+
)
3722+
assert design.bodies[1].vertices[11].position == pytest.approx(
3723+
Point3D([0.033, -0.0057735, 0.0]), 1e-6, 1e-6
3724+
)
3725+
assert design.bodies[2].vertices[0].position == pytest.approx(
3726+
Point3D([1.60966008e-02, -9.90374453e-04, 4.87404356e-19]), 1e-6, 1e-6
3727+
)
3728+
assert design.bodies[2].vertices[1].position == pytest.approx(
3729+
Point3D([0.00580814, 0.00425186, 0.02]), 1e-6, 1e-6
3730+
)
3731+
assert design.bodies[2].vertices[2].position == pytest.approx(
3732+
Point3D([0.00580814, 0.01579886, 0.0]), 1e-6, 1e-6
3733+
)
3734+
assert design.bodies[2].vertices[3].position == pytest.approx(
3735+
Point3D([5.80814371e-03, 4.25185629e-03, -7.12805714e-20]), 1e-6, 1e-6
3736+
)
3737+
assert design.bodies[3].vertices == []
3738+
assert design.bodies[4].vertices[0].position == pytest.approx(
3739+
Point3D([-0.03, 0.001, 0.0]), 1e-6, 1e-6
3740+
)
3741+
assert design.bodies[4].vertices[1].position == pytest.approx(
3742+
Point3D([-0.03, 0.02, 0.0]), 1e-6, 1e-6
3743+
)
3744+
assert design.bodies[4].vertices[2].position == pytest.approx(
3745+
Point3D([-0.011, 0.001, 0.0]), 1e-6, 1e-6
3746+
)
3747+
assert design.bodies[4].vertices[3].position == pytest.approx(
3748+
Point3D([-0.011, 0.02, 0.0]), 1e-6, 1e-6
3749+
)
3750+
assert design.bodies[5].vertices == []
3751+
assert design.components[0].bodies[0].vertices[0].position == pytest.approx(
3752+
Point3D([0.00711, 0.03182325, 0.0]), 1e-6, 1e-6
3753+
)
3754+
assert design.components[0].bodies[0].vertices[1].position == pytest.approx(
3755+
Point3D([0.00711, 0.03759675, 0]), 1e-6, 1e-6
3756+
)
3757+
assert design.components[0].bodies[0].vertices[2].position == pytest.approx(
3758+
Point3D([0.00211, 0.0404835, 0]), 1e-6, 1e-6
3759+
)
3760+
assert design.components[0].bodies[0].vertices[3].position == pytest.approx(
3761+
Point3D([-0.00289, 0.03759675, 0]), 1e-6, 1e-6
3762+
)
3763+
assert design.components[0].bodies[0].vertices[4].position == pytest.approx(
3764+
Point3D([-0.00289, 0.03182325, 0]), 1e-6, 1e-6
3765+
)
3766+
assert design.components[0].bodies[0].vertices[5].position == pytest.approx(
3767+
Point3D([0.00211, 0.0289365, 0]), 1e-6, 1e-6
3768+
)
3769+
3770+
vert = [design.bodies[1].vertices[0], design.bodies[2].vertices[3]]
3771+
edg = [design.bodies[1].edges[0], design.bodies[2].edges[0]]
3772+
fac = [design.bodies[1].faces[0], design.bodies[2].faces[1]]
3773+
design.create_named_selection("Test", vertices=vert, edges=edg, faces=fac)
3774+
assert len(design.named_selections) == 5
3775+
3776+
testns = design._named_selections["Test"]
3777+
assert len(testns.vertices) == 2
3778+
3779+
location = tmp_path_factory.mktemp("test_export_to_scdocx")
3780+
file_location = location / f"{design.name}.scdocx"
3781+
design.export_to_scdocx(location)
3782+
assert file_location.exists()
3783+
design_read = modeler.open_file(file_location)
3784+
assert len(design_read.named_selections) == 5
3785+
3786+
exportedtestns = design_read._named_selections["Test"]
3787+
assert len(exportedtestns.vertices) == 2
3788+
3789+
36683790
@pytest.mark.parametrize(
36693791
"file_extension, design_format",
36703792
[

0 commit comments

Comments
 (0)