|
| 1 | +import os |
| 2 | +import pyMagix3D as Mgx3D |
| 3 | + |
| 4 | +def test_section_box1(capfd): |
| 5 | + ctx = Mgx3D.getStdContext() |
| 6 | + gm = ctx.getGeomManager() |
| 7 | + tm = ctx.getTopoManager() |
| 8 | + mm = ctx.getMeshManager() |
| 9 | + ctx.clearSession() # Clean the session after the previous test |
| 10 | + |
| 11 | + # Création de la boite Vol0000 |
| 12 | + gm.newBox (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), "A") |
| 13 | + # Création de la boite Vol0001 |
| 14 | + gm.newBox (Mgx3D.Point(1, 0, 0), Mgx3D.Point(2, 1, 1), "B") |
| 15 | + # Collage entre Vol0000 Vol0001 |
| 16 | + gm.glue (["Vol0000","Vol0001"]) |
| 17 | + # Création d'un bloc topologique structuré sur une géométrie (Vol0000) |
| 18 | + ctx.getTopoManager().newStructuredTopoOnGeometry ("Vol0000") |
| 19 | + # Création d'un bloc topologique structuré sur une géométrie (Vol0001) |
| 20 | + ctx.getTopoManager().newStructuredTopoOnGeometry ("Vol0001") |
| 21 | + |
| 22 | + # Création du sommet Pt0016 sur la courbe Crb0001 |
| 23 | + gm.newVertex ("Crb0001", 5.000000e-01, "C") |
| 24 | + # Création du sommet Pt0017 sur la courbe Crb0003 |
| 25 | + gm.newVertex ("Crb0003", 5.000000e-01, "C") |
| 26 | + # Création du sommet Pt0018 sur la courbe Crb0007 |
| 27 | + gm.newVertex ("Crb0007", 5.000000e-01, "C") |
| 28 | + # Création du sommet Pt0019 sur la courbe Crb0005 |
| 29 | + gm.newVertex ("Crb0005", 5.000000e-01, "C") |
| 30 | + |
| 31 | + # Création du segment Crb0024 |
| 32 | + gm.newSegment("Pt0016", "Pt0017", "C") |
| 33 | + # Création du segment Crb0025 |
| 34 | + gm.newSegment("Pt0018", "Pt0017", "C") |
| 35 | + # Création du segment Crb0026 |
| 36 | + gm.newSegment("Pt0019", "Pt0018", "C") |
| 37 | + # Création du segment Crb0027 |
| 38 | + gm.newSegment("Pt0016", "Pt0019", "C") |
| 39 | + # Création de la surface Surf0012 |
| 40 | + gm.newPlanarSurface (["Crb0024","Crb0025","Crb0026","Crb0027"], "C") |
| 41 | + |
| 42 | + # Découpage suivant Ar0008 des blocs Bl0000 |
| 43 | + tm.splitBlocks (["Bl0000"],"Ar0008", .5) |
| 44 | + # Section par un plan entre géométries avec topologies |
| 45 | + gm.section (["Vol0000"], "Surf0012") |
| 46 | + # Création du maillage pour tous les blocs |
| 47 | + mm.newAllBlocksMesh() |
| 48 | + # Sauvegarde du maillage (mli) |
| 49 | + filename = "section.mli2" |
| 50 | + mm.writeMli(filename) |
| 51 | + |
| 52 | + assert os.path.exists(filename) |
| 53 | + assert os.path.getsize(filename) > 0 |
| 54 | + assert gm.getNbVolumes() == 3 |
| 55 | + assert gm.getNbSurfaces() == 17 |
| 56 | + assert tm.getNbBlocks() == 3 |
| 57 | + assert tm.getNbFaces() == 16 |
| 58 | + assert mm.getNbFaces() == 1200 |
| 59 | + |
| 60 | + out, err = capfd.readouterr() |
| 61 | + assert len(err) == 0 |
| 62 | + |
| 63 | + |
| 64 | +def test_section_box2(capfd): |
| 65 | + ctx = Mgx3D.getStdContext() |
| 66 | + gm = ctx.getGeomManager() |
| 67 | + ctx.clearSession() # Clean the session after the previous test |
| 68 | + |
| 69 | + # Création de la boite Vol0000 |
| 70 | + gm.newBox (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), "A") |
| 71 | + # Création de la boite Vol0001 |
| 72 | + gm.newBox (Mgx3D.Point(1, 0, 0), Mgx3D.Point(2, 1, 1), "B") |
| 73 | + # Collage entre Vol0000 Vol0001 |
| 74 | + gm.glue (["Vol0000","Vol0001"]) |
| 75 | + # Création de la boite Vol0002 |
| 76 | + gm.newBox (Mgx3D.Point(0, .9, 0), Mgx3D.Point(2, 1.3, 1), "C") |
| 77 | + # Section entre géométries |
| 78 | + gm.section (["Vol0000","Vol0001"], "Surf0014") |
| 79 | + |
| 80 | + assert gm.getNbVolumes() == 5 |
| 81 | + assert gm.getNbSurfaces() == 26 |
| 82 | + |
| 83 | + out, err = capfd.readouterr() |
| 84 | + assert len(err) == 0 |
| 85 | + |
| 86 | + |
| 87 | +def test_section_box_by_cylinder(capfd): |
| 88 | + ctx = Mgx3D.getStdContext() |
| 89 | + gm = ctx.getGeomManager() |
| 90 | + ctx.clearSession() # Clean the session after the previous test |
| 91 | + |
| 92 | + # Création de la boite Vol0000 |
| 93 | + gm.newBox (Mgx3D.Point(-.1, -.25, -.1), Mgx3D.Point(.1, .25, .1), "A") |
| 94 | + # Création du cylindre Vol0001 |
| 95 | + gm.newCylinder (Mgx3D.Point(-.25, 0, 0), 0.05, Mgx3D.Vector(.5, 0, 0), 3.600000e+02, "B") |
| 96 | + # Section suivant Surf0006 des entités Vol0000 |
| 97 | + gm.section (["Vol0000"], "Surf0006") |
| 98 | + |
| 99 | + assert gm.getNbVolumes() == 3 |
| 100 | + assert gm.getNbSurfaces() == 12 |
| 101 | + |
| 102 | + out, err = capfd.readouterr() |
| 103 | + assert len(err) == 0 |
0 commit comments