44
55class BoundingBox ():
66 edges : Dict [str , float ]
7- def __init__ (self , listOfCoordinates :Tuple [int , int , int , int , int , int ]):
7+ def __init__ (self , listOfCoordinates :Tuple [float , float , float , float , float , float ]):
88 self .edges = {
9- 'xmin ' : listOfCoordinates [0 ],
10- 'ymin ' : listOfCoordinates [1 ],
11- 'zmin ' : listOfCoordinates [2 ],
12- 'xmax ' : listOfCoordinates [3 ],
13- 'ymax ' : listOfCoordinates [4 ],
14- 'zmax ' : listOfCoordinates [5 ],
9+ 'XMin ' : listOfCoordinates [0 ],
10+ 'YMin ' : listOfCoordinates [1 ],
11+ 'ZMin ' : listOfCoordinates [2 ],
12+ 'XMax ' : listOfCoordinates [3 ],
13+ 'YMax ' : listOfCoordinates [4 ],
14+ 'ZMax ' : listOfCoordinates [5 ],
1515 }
1616
17+ def getOrigin (self ) -> Tuple [float ,float ,float ]:
18+ return (
19+ self .edges ['XMin' ],
20+ self .edges ['YMin' ],
21+ self .edges ['ZMin' ]
22+ )
23+
1724 def getCenter (self ) -> Tuple [float ,float ,float ]:
1825 return (
19- (self .edges ['xmax ' ] + self .edges ['xmin ' ]) / 2 ,
20- (self .edges ['ymax ' ] + self .edges ['ymin ' ]) / 2 ,
21- (self .edges ['zmax ' ] + self .edges ['zmin ' ]) / 2
26+ (self .edges ['XMax ' ] + self .edges ['XMin ' ]) / 2 ,
27+ (self .edges ['YMax ' ] + self .edges ['YMin ' ]) / 2 ,
28+ (self .edges ['ZMax ' ] + self .edges ['ZMin ' ]) / 2
2229 )
2330 def getDiagonal (self ) -> float :
24- dx = self .edges ['xmax ' ] - self .edges ['xmin ' ]
25- dy = self .edges ['ymax ' ] - self .edges ['ymin ' ]
26- dz = self .edges ['zmax ' ] - self .edges ['zmin ' ]
31+ dx = self .edges ['XMax ' ] - self .edges ['XMin ' ]
32+ dy = self .edges ['YMax ' ] - self .edges ['YMin ' ]
33+ dz = self .edges ['ZMax ' ] - self .edges ['ZMin ' ]
2734 return (dx ** 2 + dy ** 2 + dz ** 2 ) ** 0.5
2835
36+ def getLengths (self ) -> Tuple [float , float , float ]:
37+ return (
38+ self .edges ['XMax' ] - self .edges ['XMin' ],
39+ self .edges ['YMax' ] - self .edges ['YMin' ],
40+ self .edges ['ZMax' ] - self .edges ['ZMin' ]
41+ )
42+
2943 @staticmethod
3044 def _getBoundingBox (element :Tuple [int ,int ]) -> 'BoundingBox' :
3145 boundingBox :BoundingBox = BoundingBox (gmsh .model .occ .get_bounding_box (* element ))
@@ -39,25 +53,25 @@ def getBoundingBoxFromGroup(elements:List[Tuple[int,int]]) -> 'BoundingBox':
3953
4054 if len (boundingBoxs ) != 0 :
4155 edges : Dict [str , List [float ]] = {
42- 'xmin ' : [],
43- 'ymin ' : [],
44- 'zmin ' : [],
45- 'xmax ' : [],
46- 'ymax ' : [],
47- 'zmax ' : [],
56+ 'XMin ' : [],
57+ 'YMin ' : [],
58+ 'ZMin ' : [],
59+ 'XMax ' : [],
60+ 'YMax ' : [],
61+ 'ZMax ' : [],
4862 }
4963 for boundingBox in boundingBoxs :
5064 for key in edges .keys ():
5165 edges [key ].append (boundingBox .edges [key ])
5266
5367 return BoundingBox (
5468 (
55- utils .getMinFromList (edges ['xmin ' ]),
56- utils .getMinFromList (edges ['ymin ' ]),
57- utils .getMinFromList (edges ['zmin ' ]),
58- utils .getMaxFromList (edges ['xmax ' ]),
59- utils .getMaxFromList (edges ['ymax ' ]),
60- utils .getMaxFromList (edges ['zmax ' ])
69+ utils .getMinFromList (edges ['XMin ' ]),
70+ utils .getMinFromList (edges ['YMin ' ]),
71+ utils .getMinFromList (edges ['ZMin ' ]),
72+ utils .getMaxFromList (edges ['XMax ' ]),
73+ utils .getMaxFromList (edges ['YMax ' ]),
74+ utils .getMaxFromList (edges ['ZMax ' ])
6175 )
6276 )
6377 else :
0 commit comments