Add Intersection.__iter__ and Union.__iter__ methods

This commit is contained in:
Paul Romano 2016-05-18 16:39:35 -05:00
parent 07be6306ce
commit e8d4dbd5f4

View file

@ -223,7 +223,7 @@ class Intersection(Region):
Attributes
----------
nodes : tuple of openmc.Region
nodes : list of openmc.Region
Regions to take the intersection of
bounding_box : tuple of numpy.array
Lower-left and upper-right coordinates of an axis-aligned bounding box
@ -233,6 +233,10 @@ class Intersection(Region):
def __init__(self, *nodes):
self.nodes = list(nodes)
def __iter__(self):
for n in self.nodes:
yield n
def __contains__(self, point):
"""Check whether a point is contained in the region.
@ -301,6 +305,10 @@ class Union(Region):
def __init__(self, *nodes):
self.nodes = list(nodes)
def __iter__(self):
for n in self.nodes:
yield n
def __contains__(self, point):
"""Check whether a point is contained in the region.