min/max selector will return all objects within a tolerance
This commit is contained in:
parent
36c75f2c55
commit
89b109b956
|
@ -291,13 +291,13 @@ class DirectionMinMaxSelector(Selector):
|
||||||
allow '>(0,0,1)' to work.
|
allow '>(0,0,1)' to work.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self,vector,directionMax=True):
|
def __init__(self, vector, directionMax=True, tolerance=0.0001):
|
||||||
self.vector = vector
|
self.vector = vector
|
||||||
self.max = max
|
self.max = max
|
||||||
self.directionMax = directionMax
|
self.directionMax = directionMax
|
||||||
|
self.TOLERANCE = tolerance
|
||||||
def filter(self,objectList):
|
def filter(self,objectList):
|
||||||
|
|
||||||
#then sort by distance from origin, along direction specified
|
|
||||||
def distance(tShape):
|
def distance(tShape):
|
||||||
return tShape.Center().dot(self.vector)
|
return tShape.Center().dot(self.vector)
|
||||||
#if tShape.ShapeType == 'Vertex':
|
#if tShape.ShapeType == 'Vertex':
|
||||||
|
@ -306,10 +306,14 @@ class DirectionMinMaxSelector(Selector):
|
||||||
# pnt = tShape.Center()
|
# pnt = tShape.Center()
|
||||||
#return pnt.dot(self.vector)
|
#return pnt.dot(self.vector)
|
||||||
|
|
||||||
|
# find out the max/min distance
|
||||||
if self.directionMax:
|
if self.directionMax:
|
||||||
return [ max(objectList,key=distance) ]
|
d = max(map(distance, objectList))
|
||||||
else:
|
else:
|
||||||
return [ min(objectList,key=distance) ]
|
d = min(map(distance, objectList))
|
||||||
|
|
||||||
|
# return all objects at the max/min distance (within a tolerance)
|
||||||
|
return filter(lambda o: abs(d - distance(o)) < self.TOLERANCE, objectList)
|
||||||
|
|
||||||
class BinarySelector(Selector):
|
class BinarySelector(Selector):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user