Skip to content

Commit 1d39475

Browse files
committed
Add tests and rename file
1 parent 2a25347 commit 1d39475

File tree

2 files changed

+141
-41
lines changed

2 files changed

+141
-41
lines changed

test_link/test_glue.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

test_link/test_join_and_glue.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import pyMagix3D as Mgx3D
2+
3+
def test_join_surfaces():
4+
ctx = Mgx3D.getStdContext()
5+
ctx.clearSession()
6+
gm = ctx.getGeomManager()
7+
tm = ctx.getTopoManager()
8+
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+
# Création d'une boite avec une topologie
12+
tm.newBoxWithTopo (Mgx3D.Point(1, 0, 0), Mgx3D.Point(2.1, 1, 1), 10, 10, 10)
13+
# Fusion booléenne entre géométries avec topologies
14+
ctx.getGeomManager().fuse (["Vol0000","Vol0001"])
15+
# Collage entre blocs Bl0000 et Bl0001
16+
tm.fuse2Blocks ("Bl0000","Bl0001")
17+
# Fusion de surfaces avec maj de la topologie
18+
gm.joinSurfaces (["Surf0003","Surf0009"])
19+
assert "Surf0003" not in gm.getSurfaces()
20+
assert "Surf0009" not in gm.getSurfaces()
21+
assert "Surf0012" in gm.getSurfaces()
22+
assert "Surf0012" == tm.getInfos("Fa0003", 2).geomEntity()
23+
assert "Surf0012" == tm.getInfos("Fa0009", 2).geomEntity()
24+
25+
def test_glue_with_joined_surfaces(capfd):
26+
ctx = Mgx3D.getStdContext()
27+
ctx.clearSession()
28+
gm = ctx.getGeomManager()
29+
30+
# Création du volume Vol0000
31+
gm.newSphere (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Portion.DEMI, "A")
32+
# Création du volume Vol0001
33+
gm.newSphere (Mgx3D.Point(0, 0, 0), 2, Mgx3D.Portion.DEMI, "B")
34+
# Fusion de surfaces Surf0005 Surf0004
35+
gm.joinSurfaces (["Surf0005","Surf0004"])
36+
# Collage entre Vol0000 Vol0001
37+
gm.glue (["Vol0000","Vol0001"])
38+
39+
assert gm.getNbSurfaces() == 6
40+
assert gm.getNbVolumes() == 2
41+
out, err = capfd.readouterr()
42+
assert len(err) == 0
43+
44+
def test_glue_cylinder():
45+
ctx = Mgx3D.getStdContext()
46+
ctx.clearSession()
47+
gm = ctx.getGeomManager()
48+
tm = ctx.getTopoManager()
49+
50+
# Création d'un cylindre avec une topologie
51+
tm.newCylinderWithTopo (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Vector(10, 0, 0), 360, True, .5, 10, 10, 10)
52+
# Création d'un cylindre creux avec une topologie
53+
tm.newHollowCylinderWithTopo (Mgx3D.Point(0, 0, 0), 1, 1.2, Mgx3D.Vector(10, 0, 0), 360, True, 10, 10, 10)
54+
55+
assert gm.getNbVolumes() == 2
56+
assert gm.getNbSurfaces() == 7
57+
assert tm.getNbBlocks() == 9
58+
assert tm.getNbFaces() == 42
59+
ctx.getGeomManager ( ).glue (["Vol0000","Vol0001"])
60+
assert gm.getNbVolumes() == 2
61+
assert gm.getNbSurfaces() == 6
62+
assert tm.getNbBlocks() == 9
63+
assert tm.getNbFaces() == 38
64+
65+
def pre_glue(tm):
66+
# Création d'une boite avec une topologie
67+
tm.newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(10, 1, 2), 10, 20, 10)
68+
# Création d'une boite avec une topologie
69+
tm.newBoxWithTopo (Mgx3D.Point(10, 0, 0), Mgx3D.Point(12, 1, 2), 10, 20, 10)
70+
# Découpage de la face Fa0001
71+
tm.splitFace ("Fa0001", "Ar0005", .5, True)
72+
# Suppression des projections pour les entités topologiques Fa0013 Fa0012 Ar0025 Ar0027 Ar0028 ...
73+
tm.setGeomAssociation (["Fa0013","Fa0012","Ar0025","Ar0027","Ar0028","Ar0026","Ar0024","Som0017","Som0016"], "", True)
74+
# Modification de la position des sommets topologiques Som0017 Som0016 en coordonnées cartésiennes
75+
tm.setVertexLocation (["Som0017","Som0016"], True, 9.5, False, 0, False, 0)
76+
# Découpage suivant Ar0023 des blocs Bl0001
77+
tm.splitBlocks (["Bl0001"],"Ar0023", .5)
78+
# Fusion de sommets Som0010 Som0011 avec Som0008 Som0009
79+
tm.snapVertices ("Ar0014", "Ar0012", False)
80+
# Modification de la position des sommets topologiques Som0010 Som0011 en coordonnées cartésiennes
81+
tm.setVertexLocation (["Som0010","Som0011"], True, 9.5, False, 0, False, 0)
82+
# Modification de la position des sommets topologiques Som0020 Som0021 Som0018 Som0019 en coordonnées cartésiennes
83+
tm.setVertexLocation (["Som0020","Som0021","Som0018","Som0019"], True, 10, False, 0, False, 0)
84+
# Projection automatique pour les sommets topologiques Som0020 Som0021 Som0018 Som0019
85+
tm.projectVerticesOnNearestGeomEntities (["Som0020","Som0021","Som0018","Som0019"], ["Pt0010","Pt0011","Pt0009","Pt0008"], True)
86+
# Projection automatique pour les faces topologiques Fa0022
87+
tm.projectFacesOnSurfaces (["Fa0022"])
88+
# Changement de discrétisation pour Ar0036
89+
emp = Mgx3D.EdgeMeshingPropertyUniform(10)
90+
tm.setParallelMeshingProperty (emp,"Ar0036")
91+
92+
def post_glue(tm, mm):
93+
# Affectation d'une projection vers Vol0000 pour les entités topologiques Bl0002
94+
tm.setGeomAssociation (["Bl0002"], "Vol0000", False)
95+
# Découpage de l'arête Ar0003
96+
tm.splitEdge ("Ar0003", .5)
97+
# Découpage de l'arête Ar0001
98+
tm.splitEdge ("Ar0001", .5)
99+
# Changement de discrétisation pour Ar0044
100+
emp = Mgx3D.EdgeMeshingPropertyGeometric(10, 1.2, False)
101+
tm.setParallelMeshingProperty (emp,"Ar0044")
102+
# Création du maillage pour tous les blocs
103+
mm.newAllBlocksMesh()
104+
105+
def test_glue_topo1():
106+
ctx = Mgx3D.getStdContext()
107+
ctx.clearSession()
108+
tm = ctx.getTopoManager()
109+
mm = ctx.getMeshManager()
110+
pre_glue(tm)
111+
# on ne fait rien
112+
post_glue(tm, mm)
113+
assert tm.getNbFaces() == 17
114+
assert mm.getNbFaces() == 2300
115+
assert mm.getNbNodes() == 6017
116+
117+
def test_glue_topo2():
118+
ctx = Mgx3D.getStdContext()
119+
ctx.clearSession()
120+
tm = ctx.getTopoManager()
121+
mm = ctx.getMeshManager()
122+
pre_glue(tm)
123+
tm.fuse2Faces ("Fa0012","Fa0014")
124+
tm.fuse2Faces ("Fa0013","Fa0016")
125+
post_glue(tm, mm)
126+
assert tm.getNbFaces() == 15
127+
assert mm.getNbFaces() == 2100
128+
assert mm.getNbNodes() == 5786
129+
130+
def test_glue_topo3():
131+
ctx = Mgx3D.getStdContext()
132+
ctx.clearSession()
133+
tm = ctx.getTopoManager()
134+
mm = ctx.getMeshManager()
135+
pre_glue(tm)
136+
tm.glue2Topo ("Vol0000","Vol0001")
137+
post_glue(tm, mm)
138+
assert tm.getNbFaces() == 15
139+
assert mm.getNbFaces() == 2100
140+
assert mm.getNbNodes() == 5786
141+

0 commit comments

Comments
 (0)