1+ import pyMagix3D as Mgx3D
2+
3+ def test_command_join_entities (capfd ):
4+ ctx = Mgx3D .getStdContext ()
5+ ctx .clearSession () # Clean the session after the previous test
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 ), 10 , 10 , 10 )
13+ # Création d'une boite avec une topologie
14+ tm .newBoxWithTopo (Mgx3D .Point (2 , 0 , 0 ), Mgx3D .Point (3 , 1 , 1 ), 10 , 10 , 10 )
15+ assert gm .getNbSurfaces ()== 18
16+ assert gm .getNbCurves ()== 36
17+
18+ # Fusion booléenne entre géométries avec topologies
19+ gm .fuse (["Vol0000" ,"Vol0001" , "Vol0002" ])
20+ assert gm .getNbSurfaces ()== 14
21+ assert gm .getNbCurves ()== 28
22+
23+ # Fusion de surfaces avec maj de la topologie
24+ gm .joinSurfaces (["Surf0005" ,"Surf0011" ])
25+ assert gm .getNbSurfaces ()== 13
26+ assert gm .getNbCurves ()== 27
27+ # Annulation de : Fusion de surfaces avec maj de la topologie
28+ ctx .undo ()
29+ assert gm .getNbSurfaces ()== 14
30+ assert gm .getNbCurves ()== 28
31+ # Rejeu de : Fusion de surfaces avec maj de la topologie
32+ ctx .redo ()
33+ assert gm .getNbSurfaces ()== 13
34+ assert gm .getNbCurves ()== 27
35+
36+ # Fusion de surfaces avec maj de la topologie
37+ gm .joinSurfaces (["Surf0009" ,"Surf0003" ])
38+ assert gm .getNbSurfaces ()== 12
39+ assert gm .getNbCurves ()== 26
40+ # Annulation de : Fusion de surfaces avec maj de la topologie
41+ ctx .undo ()
42+ assert gm .getNbSurfaces ()== 13
43+ assert gm .getNbCurves ()== 27
44+ # Rejeu de : Fusion de surfaces avec maj de la topologie
45+ ctx .redo ()
46+ assert gm .getNbSurfaces ()== 12
47+ assert gm .getNbCurves ()== 26
48+
49+ # Fusion de courbes avec maj de la topologie
50+ gm .joinCurves (["Crb0011" ,"Crb0023" ])
51+ assert gm .getNbCurves ()== 25
52+ # Annulation de : Fusion de courbes avec maj de la topologie
53+ ctx .undo ()
54+ assert gm .getNbCurves ()== 26
55+ # Rejeu de : Fusion de courbes avec maj de la topologie
56+ ctx .redo ()
57+ assert gm .getNbCurves ()== 25
58+
59+ def test_command_scaling (capfd ):
60+ ctx = Mgx3D .getStdContext ()
61+ ctx .clearSession () # Clean the session after the previous test
62+ gm = ctx .getGeomManager ()
63+ tm = ctx .getTopoManager ()
64+
65+ # Création d'une boite avec une topologie
66+ tm .newBoxWithTopo (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Point (1 , 1 , 1 ), 10 , 10 , 10 )
67+ assertPoint (gm , "Pt0001" , 0 , 0 , 0 )
68+ assertPoint (gm , "Pt0006" , 1 , 1 , 1 )
69+ # Création d'une boite avec une topologie
70+ tm .newBoxWithTopo (Mgx3D .Point (.2 , .2 , .2 ), Mgx3D .Point (.8 , .8 , .8 ), 10 , 10 , 10 )
71+ assertPoint (gm , "Pt0014" , 0.8 , 0.8 , 0.8 )
72+
73+ # Homothétie d'une géométrie avec sa topologie
74+ gm .scale (["Vol0000" ,"Vol0001" ], 2.000000e+00 )
75+ assertPoint (gm , "Pt0006" , 2 , 2 , 2 )
76+ assertPoint (gm , "Pt0014" , 1.6 , 1.6 , 1.6 )
77+ # Annulation de : Homothétie d'une géométrie avec sa topologie
78+ ctx .undo ()
79+ assertPoint (gm , "Pt0006" , 1 , 1 , 1 )
80+ assertPoint (gm , "Pt0014" , 0.8 , 0.8 , 0.8 )
81+ # Rejeu de : Homothétie d'une géométrie avec sa topologie
82+ ctx .redo ()
83+ assertPoint (gm , "Pt0006" , 2 , 2 , 2 )
84+ assertPoint (gm , "Pt0014" , 1.6 , 1.6 , 1.6 )
85+
86+ # Homothétie de tout
87+ gm .scaleAll (5.000000e-01 , Mgx3D .Point (2 , 2 , 2 ))
88+ assertPoint (gm , "Pt0001" , 1 , 1 , 1 )
89+ # Annulation de : Homothétie de tout
90+ ctx .undo ()
91+ assertPoint (gm , "Pt0001" , 0 , 0 , 0 )
92+ # Rejeu de : Homothétie de tout
93+ ctx .redo ()
94+ assertPoint (gm , "Pt0001" , 1 , 1 , 1 )
95+
96+ def test_command_remove (capfd ):
97+ ctx = Mgx3D .getStdContext ()
98+ ctx .clearSession () # Clean the session after the previous test
99+ gm = ctx .getGeomManager ()
100+ tm = ctx .getTopoManager ()
101+
102+ # Création d'une boite avec une topologie
103+ tm .newBoxWithTopo (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Point (1 , 1 , 1 ), 10 , 10 , 10 )
104+ assert gm .getNbSurfaces ()== 6
105+ assert gm .getNbCurves ()== 12
106+
107+ # Suppression d'entités géométriques et suppression des liens topologiques
108+ gm .destroy (["Crb0000" ], True )
109+ assert gm .getNbSurfaces ()== 4
110+ assert gm .getNbCurves ()== 11
111+ # Annulation de : Suppression d'entités géométriques et suppression des liens topologiques
112+ ctx .undo ()
113+ assert gm .getNbSurfaces ()== 6
114+ assert gm .getNbCurves ()== 12
115+ # Rejeu de : Suppression d'entités géométriques et suppression des liens topologiques
116+ ctx .redo ()
117+ assert gm .getNbSurfaces ()== 4
118+ assert gm .getNbCurves ()== 11
119+
120+ # Suppression d'entités géométriques et suppression des liens topologiques
121+ gm .destroy (["Surf0001" ], True )
122+ assert gm .getNbSurfaces ()== 3
123+ assert gm .getNbCurves ()== 10
124+ # Annulation de : Suppression d'entités géométriques et suppression des liens topologiques
125+ ctx .undo ()
126+ assert gm .getNbSurfaces ()== 4
127+ assert gm .getNbCurves ()== 11
128+ # Rejeu de : Suppression d'entités géométriques et suppression des liens topologiques
129+ ctx .redo ()
130+ assert gm .getNbSurfaces ()== 3
131+ assert gm .getNbCurves ()== 10
132+
133+ def test_command_mirroring (capfd ):
134+ #Ce test prend aussi en charge l'appel à CommandGeomCopy
135+ ctx = Mgx3D .getStdContext ()
136+ ctx .clearSession () # Clean the session after the previous test
137+ gm = ctx .getGeomManager ()
138+ tm = ctx .getTopoManager ()
139+
140+ # Création d'une boite avec une topologie
141+ tm .newBoxWithTopo (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Point (1 , 1 , 1 ), 10 , 10 , 10 )
142+ # Création d'une boite avec une topologie
143+ tm .newBoxWithTopo (Mgx3D .Point (1 , 0 , 0 ), Mgx3D .Point (2 , 1 , 1 ), 10 , 10 , 10 )
144+ # Collage entre géométries avec topologies
145+ gm .glue (["Vol0000" ,"Vol0001" ])
146+ assert gm .getNbSurfaces ()== 11
147+ assert gm .getNbCurves ()== 20
148+
149+ # Symétrie d'une copie d'une géométrie
150+ gm .copyAndMirror (["Vol0001" ], Mgx3D .Plane (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Vector (0 , 0 , 1 )), False ,"" )
151+
152+ assert gm .getNbSurfaces ()== 17
153+ assert gm .getNbCurves ()== 32
154+ # Annulation de : Symétrie d'une copie d'une géométrie
155+ ctx .undo ()
156+ assert gm .getNbSurfaces ()== 11
157+ assert gm .getNbCurves ()== 20
158+ # Rejeu de : Symétrie d'une copie d'une géométrie
159+ ctx .redo ()
160+ assert gm .getNbSurfaces ()== 17
161+ assert gm .getNbCurves ()== 32
162+
163+ def test_command_common (capfd ):
164+ ctx = Mgx3D .getStdContext ()
165+ ctx .clearSession () # Clean the session after the previous test
166+ gm = ctx .getGeomManager ()
167+ tm = ctx .getTopoManager ()
168+
169+ # Création d'une boite avec une topologie
170+ tm .newBoxWithTopo (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Point (1 , 1 , 1 ), 10 , 10 , 10 )
171+ # Création d'une boite avec une topologie
172+ tm .newBoxWithTopo (Mgx3D .Point (.2 , .2 , .2 ), Mgx3D .Point (.8 , .8 , .8 ), 10 , 10 , 10 )
173+ # Création d'une boite avec une topologie
174+ tm .newBoxWithTopo (Mgx3D .Point (.2 , .8 , .2 ), Mgx3D .Point (.8 , 1.4 , .8 ), 10 , 10 , 10 )
175+ # Collage entre géométries avec topologies
176+ gm .glue (["Vol0001" ,"Vol0002" ])
177+ assert gm .getNbSurfaces ()== 17
178+ assert gm .getNbCurves ()== 32
179+
180+ # Intersection booléenne entre géométries avec topologies
181+ gm .common (["Vol0000" ,"Vol0001" ])
182+ assert gm .getNbSurfaces ()== 11
183+ assert gm .getNbCurves ()== 20
184+ # Annulation de : Intersection booléenne entre géométries avec topologies
185+ ctx .undo ()
186+ assert gm .getNbSurfaces ()== 17
187+ assert gm .getNbCurves ()== 32
188+ # Rejeu de : Intersection booléenne entre géométries avec topologies
189+ ctx .redo ()
190+ assert gm .getNbSurfaces ()== 11
191+ assert gm .getNbCurves ()== 20
192+
193+ def test_command_common2d (capfd ):
194+ ctx = Mgx3D .getStdContext ()
195+ ctx .clearSession () # Clean the session after the previous test
196+ gm = ctx .getGeomManager ()
197+ tm = ctx .getTopoManager ()
198+
199+ # Création d'une boite avec une topologie
200+ tm .newBoxWithTopo (Mgx3D .Point (0 , 0 , 0 ), Mgx3D .Point (1 , 1 , 1 ), 10 , 10 , 10 )
201+ # Création d'une boite avec une topologie
202+ tm .newBoxWithTopo (Mgx3D .Point (.2 , .2 , .2 ), Mgx3D .Point (.8 , .8 , .8 ), 10 , 10 , 10 )
203+ # Création d'une boite avec une topologie
204+ tm .newBoxWithTopo (Mgx3D .Point (.2 , .8 , .2 ), Mgx3D .Point (.8 , 1.4 , .8 ), 10 , 10 , 10 )
205+ # Collage entre géométries avec topologies
206+ gm .glue (["Vol0001" ,"Vol0002" ])
207+ assert gm .getNbSurfaces ()== 17
208+ assert gm .getNbCurves ()== 32
209+
210+ # Intersection booléenne entre 2 géométries 1D ou 2D avec topologies
211+ gm .common2D ("Surf0003" , "Surf0016" , "" )
212+ assert gm .getNbSurfaces ()== 15
213+ assert gm .getNbCurves ()== 25
214+ # Annulation de : Intersection booléenne entre 2 géométries 1D ou 2D, sans destruction
215+ ctx .undo ()
216+ assert gm .getNbSurfaces ()== 17
217+ assert gm .getNbCurves ()== 32
218+ # Rejeu de : Intersection booléenne entre 2 géométries 1D ou 2D, sans destruction
219+ ctx .redo ()
220+ assert gm .getNbSurfaces ()== 15
221+ assert gm .getNbCurves ()== 25
222+
223+ def assertPoint (gm , point , x , y , z ):
224+ p = gm .getCoord (point )
225+ assert p .getX () == x
226+ assert p .getY () == y
227+ assert p .getZ () == z
0 commit comments