mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Join intersection/union of multiple half-spaces when possible.
This commit is contained in:
parent
dc118afd2d
commit
697e3c557b
1 changed files with 16 additions and 3 deletions
|
|
@ -84,14 +84,27 @@ class Region(object):
|
|||
r2 = output.pop()
|
||||
if operator == ' ':
|
||||
r1 = output.pop()
|
||||
output.append(Intersection(r1, r2))
|
||||
if isinstance(r1, Intersection) and hasattr(r2, 'surface'):
|
||||
r1.nodes.append(r2)
|
||||
output.append(r1)
|
||||
elif isinstance(r2, Intersection) and hasattr(r1, 'surface'):
|
||||
r2.nodes.insert(0, r1)
|
||||
output.append(r2)
|
||||
else:
|
||||
output.append(Intersection(r1, r2))
|
||||
elif operator == '^':
|
||||
r1 = output.pop()
|
||||
output.append(Union(r1, r2))
|
||||
if isinstance(r1, Union) and hasattr(r2, 'surface'):
|
||||
r1.nodes.append(r2)
|
||||
output.append(r1)
|
||||
elif isinstance(r2, Union) and hasattr(r1, 'surface'):
|
||||
r2.nodes.insert(0, r1)
|
||||
output.append(r2)
|
||||
else:
|
||||
output.append(Union(r1, r2))
|
||||
elif operator == '~':
|
||||
output.append(Complement(r2))
|
||||
|
||||
|
||||
# The following is an implementation of the shunting yard algorithm to
|
||||
# generate an abstract syntax tree for the region expression.
|
||||
output = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue