|
1 | 1 | import pyMagix3D as Mgx3D |
2 | 2 | import math |
| 3 | +import pytest |
3 | 4 |
|
| 5 | +def test_extend_split_face(): |
| 6 | + ctx = Mgx3D.getStdContext() |
| 7 | + ctx.clearSession() # Clean the session after the previous test |
| 8 | + tm = ctx.getTopoManager() |
| 9 | + # Création d'une boite avec une topologie |
| 10 | + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) |
| 11 | + # Découpage de la face Fa0003 |
| 12 | + tm.splitFace ("Fa0003", "Ar0002", .3, True) |
| 13 | + assert tm.getNbFaces() == 7 |
| 14 | + with pytest.raises(RuntimeError) as excinfo: |
| 15 | + # Découpage de la face Fa0001 par prolongation |
| 16 | + tm.extendSplitFace ("Fa0001", "Som0007") |
| 17 | + expected = "La face ne peut être découpée avec un sommet au sommet de la face (en prendre un sur un côté)" |
| 18 | + assert expected in str(excinfo.value) |
| 19 | + with pytest.raises(RuntimeError) as excinfo: |
| 20 | + # Découpage de la face Fa0002 par prolongation |
| 21 | + tm.extendSplitFace ("Fa0002", "Som0009") |
| 22 | + expected = "La face ne peut être découpée avec ce sommet, on ne trouve pas d'arête contenant ce sommet" |
| 23 | + assert expected in str(excinfo.value) |
| 24 | + # Découpage de la face Fa0001 par prolongation |
| 25 | + tm.extendSplitFace ("Fa0001", "Som0009") |
| 26 | + assert tm.getNbFaces() == 8 |
| 27 | + |
| 28 | +def test_extend_split_face_with_degenerated_face(): |
| 29 | + ctx = Mgx3D.getStdContext() |
| 30 | + ctx.clearSession() # Clean the session after the previous test |
| 31 | + tm = ctx.getTopoManager() |
| 32 | + # Création d'une boite avec une topologie |
| 33 | + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) |
| 34 | + # Suppression d'entités géométriques et suppression des liens topologiques |
| 35 | + ctx.getGeomManager().destroy(["Vol0000"], True) |
| 36 | + # Destruction des entités topologiques Bl0000 |
| 37 | + tm.destroy(["Bl0000"], False) |
| 38 | + # Découpage de la face Fa0000 |
| 39 | + tm.splitFace ("Fa0000", "Ar0000", .5, True) |
| 40 | + assert tm.getNbFaces() == 7 |
| 41 | + # Fusion de sommets Som0007 avec Som0006 |
| 42 | + tm.snapVertices ("Som0007", "Som0006", True) |
| 43 | + # Découpage de la face Fa0003 par prolongation |
| 44 | + # On est en face de la dégénérescence |
| 45 | + tm.extendSplitFace ("Fa0003", "Som0009") |
| 46 | + assert tm.getNbFaces() == 8 |
| 47 | + # Découpage de la face Fa0009 |
| 48 | + # On n'est pas en face de la dégénérescence mais coupe OK |
| 49 | + tm.splitFace ("Fa0009", "Ar0010", .5, True) |
| 50 | + assert tm.getNbFaces() == 9 |
| 51 | + |
| 52 | +def test_no_more_infinite_loop(): |
| 53 | + ctx = Mgx3D.getStdContext() |
| 54 | + ctx.clearSession() # Clean the session after the previous test |
| 55 | + gm = ctx.getGeomManager() |
| 56 | + tm = ctx.getTopoManager() |
| 57 | + # Création d'une boite avec une topologie |
| 58 | + tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) |
| 59 | + # Suppression d'entités géométriques et suppression des liens topologiques |
| 60 | + gm.destroy(["Vol0000"], True) |
| 61 | + # Destruction des entités topologiques Bl0000 |
| 62 | + tm.destroy(["Bl0000"], False) |
| 63 | + tm.splitFaces (["Fa0005", "Fa0001", "Fa0004", "Fa0000"], "Ar0005", .5, .5) |
| 64 | + assert tm.getNbFaces() == 10 |
| 65 | + |
| 66 | +def test_split_adjacent_faces_with_common_edge(): |
| 67 | + ctx = Mgx3D.getStdContext() |
| 68 | + ctx.clearSession() # Clean the session after the previous test |
| 69 | + tm = ctx.getTopoManager() |
| 70 | + # Création d'une boite avec une topologie |
| 71 | + ctx.getTopoManager().newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10) |
| 72 | + # Suppression d'entités géométriques et suppression des entités topologiques dépendantes |
| 73 | + ctx.getGeomManager().destroyWithTopo(["Vol0000"], False) |
| 74 | + assert tm.getNbFaces() == 6 |
| 75 | + # Découpage des faces 2D structurées Fa0005 Fa0001 suivant l'arête Ar0005 avec comme ratio 5.000000e-01 |
| 76 | + ctx.getTopoManager().splitFaces (["Fa0005","Fa0001"], "Ar0005", .5, .5) |
| 77 | + assert tm.getNbFaces() == 8 |
| 78 | + |
4 | 79 | def test_split_faces2D_1(capfd): |
5 | 80 | ctx = Mgx3D.getStdContext() |
6 | 81 | gm = ctx.getGeomManager() |
@@ -77,7 +152,7 @@ def test_split_faces2D_4(capfd): |
77 | 152 | # Suppression d'entités géométriques et suppression des liens topologiques |
78 | 153 | gm.destroy(["Vol0000"], True) |
79 | 154 | # Destruction des entités topologiques Bl0000 |
80 | | - ctx.getTopoManager ( ).destroy (["Bl0000"], False) |
| 155 | + tm.destroy(["Bl0000"], False) |
81 | 156 | # Découpage de la face Fa0000 |
82 | 157 | tm.splitFaces (["Fa0000"], "Ar0000", .5, 0, True) |
83 | 158 | assert tm.getNbFaces() == 7 |
|
0 commit comments