1+ import pyMagix3D as Mgx3D
2+ import pytest
3+ import math
4+
5+ def test_new_sphere (capfd ):
6+ ctx = Mgx3D .getStdContext ()
7+ ctx .clearSession () # Clean the session after the previous test
8+ gm = ctx .getGeomManager ()
9+ tm = ctx .getTopoManager ()
10+ mm = ctx .getMeshManager ()
11+
12+ # Création du volume Vol0000
13+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .ENTIER , "AAA" )
14+ assert gm .getNbVolumes ()== 1
15+ assert gm .getInfos ("Vol0000" , 3 ).area == pytest .approx (4 / 3 * math .pi , abs = 1e-7 )
16+
17+ # Création du volume Vol0001
18+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .TROIS_QUARTS , "AAA" )
19+ assert gm .getNbVolumes ()== 2
20+ assert gm .getInfos ("Vol0001" , 3 ).area == pytest .approx (math .pi , abs = 1e-7 )
21+
22+ # Création du volume Vol0002
23+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .DEMI , "AAA" )
24+ assert gm .getNbVolumes ()== 3
25+ assert gm .getInfos ("Vol0002" , 3 ).area == pytest .approx (2 / 3 * math .pi , abs = 1e-7 )
26+
27+ # Création du volume Vol0003
28+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .TIERS )
29+ assert gm .getNbVolumes ()== 4
30+ assert gm .getInfos ("Vol0003" , 3 ).area == pytest .approx (4 / 9 * math .pi , abs = 1e-7 )
31+
32+ # Création du volume Vol0004
33+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .QUART )
34+ assert gm .getNbVolumes ()== 5
35+ assert gm .getInfos ("Vol0004" , 3 ).area == pytest .approx (1 / 3 * math .pi , abs = 1e-7 )
36+
37+ # Création du volume Vol0005
38+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .CINQUIEME )
39+ assert gm .getNbVolumes ()== 6
40+ assert gm .getInfos ("Vol0005" , 3 ).area == pytest .approx (4 / 15 * math .pi , abs = 1e-7 )
41+
42+ # Création du volume Vol0006
43+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .SIXIEME )
44+ assert gm .getNbVolumes ()== 7
45+ assert gm .getInfos ("Vol0006" , 3 ).area == pytest .approx (2 / 9 * math .pi , abs = 1e-7 )
46+
47+ # Création du volume Vol0007
48+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , Mgx3D .Portion .SIXIEME )
49+ assert gm .getNbVolumes ()== 8
50+ assert gm .getInfos ("Vol0007" , 3 ).area == pytest .approx (2 / 9 * math .pi , abs = 1e-7 )
51+
52+ # Création du volume Vol0008
53+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , 360 )
54+ assert gm .getNbVolumes ()== 9
55+ assert gm .getInfos ("Vol0008" , 3 ).area == pytest .approx (4 / 3 * math .pi , abs = 1e-7 )
56+
57+ # Création du volume Vol0009
58+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , 180 )
59+ assert gm .getNbVolumes ()== 10
60+ assert gm .getInfos ("Vol0009" , 3 ).area == pytest .approx (2 / 3 * math .pi , abs = 1e-7 )
61+
62+ # Création du volume Vol0010
63+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , 90 )
64+ assert gm .getNbVolumes ()== 11
65+ assert gm .getInfos ("Vol0010" , 3 ).area == pytest .approx (1 / 3 * math .pi , abs = 1e-7 )
66+
67+ # Création du volume Vol0011
68+ ctx .getGeomManager ().newSphere (Mgx3D .Point (0 , 0 , 0 ), 1 , 100 )
69+ assert gm .getNbVolumes ()== 12
70+ assert gm .getInfos ("Vol0011" , 3 ).area == pytest .approx ((100 / 360 ) * (4 / 3 ) * math .pi , abs = 1e-7 )
0 commit comments