montepy.HalfSpace#
- class montepy.HalfSpace(left, operator, right=None, node=None)#
Bases:
object
Class representing a geometry half_space.
The term half-spaces in MontePy is used very loosely, and is not mathematically rigorous. In MontePy a divider is a something that splits a space (R3 ) into two half-spaces. At the simplest this would be a plane or other quadratic surface. There will always be two half-spaces, a negative, or inside (False) or positive, outside (True). This class proper is for binary trees implementing constructive solid geometry (CSG) set logic. The same logic with half-spaces still apply as the intersection will always create two half-spaces (though one may be the empty set). In this case thinking of “inside” and “outside” may be more useful.
HalfSpaces use binary operators to implement set logic.
For Intersection:
half_space = left & right half_space &= other_side
For Union:
half_space = left | right half_space |= other_side
And you can also complement a HalfSpace:
half_space = ~ other_half_space
Parantheses are allowed, and handled properly
half_space = +bottom & (-left | +right)
- Parameters:
left (HalfSpace) – The left side of the binary tree.
operator (Operator) – the operator to apply between the two branches.
right (HalfSpace) – the right side of the binary tree.
node (GeometryTree) – the node this was parsed from.
Methods:
parse_input_node
(node)Parses the given syntax node as a half_space.
remove_duplicate_surfaces
(deleting_dict)Updates old surface numbers to prepare for deleting surfaces.
update_pointers
(cells, surfaces, cell)Update pointers, and link this object to other objects in the problem.
Attributes:
The left side of the binary tree of this half_space.
The syntax node for this HalfSpace if any.
The operator for applying to this binary tree.
The right side of the binary tree of this half_space if any.
- static parse_input_node(node)#
Parses the given syntax node as a half_space.
- Parameters:
node (GeometryTree) – the Input syntax node to parse.
- Returns:
the HalfSpace properly representing the input geometry.
- Return type:
- _update_values()#
- remove_duplicate_surfaces(deleting_dict: dict[int, tuple[Surface, Surface]])#
Updates old surface numbers to prepare for deleting surfaces.
This will ensure any new surfaces or complements properly get added to the parent cell’s
surfaces()
andcomplements()
.Changed in version 1.0.0: The form of the deleting_dict was changed as
Surface
is no longer hashable.
- update_pointers(cells, surfaces, cell)#
Update pointers, and link this object to other objects in the problem.
This will:
Link this HalfSpace (and its children) to the parent cell.
Update the divider parameter to point to the relevant surface or cell.
Update the parent’s
surfaces()
, andcomplements()
.
- property left#
The left side of the binary tree of this half_space.
- Returns:
the left side of the tree.
- Return type:
- property node#
The syntax node for this HalfSpace if any.
If this was generated by
parse_input_node()
, that initial node will be given. If this was created from scratch, a new node will be generated prior as this is being written to file.- Returns:
the node for this tree.
- Return type:
- property operator#
The operator for applying to this binary tree.
- Returns:
the operator for the tree.
- Return type: