-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBoundingBoxVolume.py
50 lines (41 loc) · 1.34 KB
/
BoundingBoxVolume.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from PythonMetricsCalculator import PerkEvaluatorMetric
class BoundingBoxVolume( PerkEvaluatorMetric ):
# Static methods
@staticmethod
def GetMetricName():
return "Bounding Box Volume"
@staticmethod
def GetMetricUnit():
return "mm^3"
# Instance methods
def __init__( self ):
PerkEvaluatorMetric.__init__( self )
self.minX = None
self.minY = None
self.minZ = None
self.maxX = None
self.maxY = None
self.maxZ = None
def AddTimestamp( self, time, matrix, point, role ):
if ( self.minX == None or self.minY == None or self.minZ == None
or self.maxX == None or self.maxY == None or self.maxZ == None ):
self.minX = point[ 0 ]
self.minY = point[ 1 ]
self.minZ = point[ 2 ]
self.maxX = point[ 0 ]
self.maxY = point[ 1 ]
self.maxZ = point[ 2 ]
if ( point[ 0 ] < self.minX ):
self.minX = point[ 0 ]
if ( point[ 1 ] < self.minY ):
self.minY = point[ 1 ]
if ( point[ 2 ] < self.minZ ):
self.minZ = point[ 2 ]
if ( point[ 0 ] > self.maxX ):
self.maxX = point[ 0 ]
if ( point[ 1 ] > self.maxY ):
self.maxY = point[ 1 ]
if ( point[ 2 ] > self.maxZ ):
self.maxZ = point[ 2 ]
def GetMetric( self ):
return ( self.maxX - self.minX ) * ( self.maxY - self.minY ) * ( self.maxZ - self.minZ )