glow.geometry_layouts package

Submodules

glow.geometry_layouts.cells module

Module containing classes providing the means for creating cells from basic geometries in SALOME.

class CartesianCell(center: Tuple[float, float, float] | None = None, width_height: Tuple[float, float] = (1.0, 1.0), rounded_corners: List[Tuple[int, float]] | None = None, base_props: Dict[PropertyType, str] | None = None, name: str = 'Cartesian_Cell')[source]

Bases: Cell

Class for representing a Cartesian cell characterised in terms of its geometry layouts and the associated properties. It is based on a rectangular shape whose corresponding Surface object is built from the geometric settings provided at its initialisation.

The cell geometry layout can be represented in terms of its technological geometry. The surfaces that constitute this layout represent the regions associated with a different material property. In fuel assemblies, a unit cell represents a fuel pin characterised by concentric circular regions. However, this class offers no limitation on the type of surfaces and their positioning, provided they are compatible with the dimensions of the cell. In addition, since it is a subclass of Cell, and consequently of Fillable, it can contain not only Region objects, but also other Fillable instances (e.g., a Lattice so to model an assembly).

In any case, the associated Region objects describe the technological geometry layout of the cell. Additionally, this geometry can be refined by subdividing it into sectors or by adding circles within a circular region. The GEOM edge objects resulting from the refinement are stored in the map associating the compound to the type of geometry.

Parameters:
  • center (Tuple[float, float, float] | None = None) – The XYZ coordinates of the centre of the cell.

  • width_height (Tuple[float, float] = (1.0, 1.0)) – A tuple providing the width and the height of the rectangle representing the shape of the cell.

  • rounded_corners (List[Tuple[int, float]] | None = None) – A list of tuples providing for each corner of the rectangle its index and the curvature radius, if any.

  • base_props (Dict[PropertyType, str] | None = None) – The mapping from PropertyType items to values associated to the characteristic rectangular shape of the cell.

  • name (str = "Cartesian_Cell") – The name of the cell when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the cell.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the cell is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the cell.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the cell’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the cell.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

sectorize(sectors_no: List[int], angles: List[float], **kwargs: Any) None[source]

Method that subdivides the technological geometry of the cell into sectors. Given the number of sectors for each region and the values of the angles to start the sectorization from, edges are built so that they propagate radially from the centre of the cell. The order of the elements in the two lists follows the outwards direction from the cell’s centre. The result of the intersection between each region and the subdivision edges is collected and stored as mapping from GeometryType.SECTORIZED to Compound object.

Parameters:
  • sectors_no (List[int]) – List of integers representing the number of subdivision for each cell region coming from the technological geometry.

  • angles (List[float]) – List of angles (in degrees) the sectorization should start from for each cell’s region coming from the technological geometry.

  • kwargs (Any) – Additional parameters specific to the cartesian cell type to be sectorized (e.g., windmill).

class Cell(shape: Surface, base_props: Dict[PropertyType, str] | None = None, name: str = 'Cell')[source]

Bases: Fillable

Class for representing any cell characterised in terms of its geometry layout made of regions and the associated properties.

The cell geometry layouts can be represented in terms of its technological geometry. The surfaces that constitute this layout represent the regions associated with a different material property. In fuel assemblies, a unit cell represents a fuel pin characterised by concentric circular regions. However, this class offers no limitation on the type of surfaces and their positioning, provided they are compatible with the dimensions of the cell. In addition, since Cell is a subclass of Fillable, it can contain not only Region objects, but also other Fillable instances (e.g., a Lattice so to model an assembly).

In any case, the associated Region objects describe the technological geometry layout of the cell. Additionally, this geometry can be refined by subdividing it into sectors or by adding circles within a circular region. The GEOM edge objects resulting from the refinement are stored in the map associating the compound to the type of geometry.

This class is intended to represent a generic cell as it is not based on a pre-defined characteristic shape, which, in turns, is provided at its initialisation. Specialisations of this class provide the shape of the cell (i.e. a rectangle for a Cartesian cell or a hexagon for a hexagonal one).

Parameters:
  • shape (Surface) – The Surface object representing the characteristic shape of the cell.

  • base_props (Dict[PropertyType, str] | None = None) – The mapping from PropertyType items to values associated to the characteristic shape of the cell.

  • name (str = "Cell") – The name of the cell when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the cell.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the cell is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the cell.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the cell’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the cell.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

sectorize(sectors_no: List[int], angles: List[float], **kwargs: Any) None[source]

Method that subdivides the technological geometry of the cell into sectors. Given the number of sectors for each region and the values of the angles to start the sectorization from, edges are built so that they propagate radially from the centre of the cell. The order of the elements in the two lists follows the outwards direction from the cell’s centre. The result of the intersection between each region and the subdivision edges is collected and stored as mapping from GeometryType.SECTORIZED to Compound object.

Parameters:
  • sectors_no (List[int]) – List of integers representing the number of subdivision for each cell region coming from the technological geometry.

  • angles (List[float]) – List of angles (in degrees) the sectorization should start from for each cell’s region coming from the technological geometry.

  • kwargs (Any) – Additional parameters specific to the type of cell to be sectorized. No parameters must be passed.

Raises:

TypeError – If additional keyword arguments are provided.

class HexCell(center: Tuple[float, float, float] | None = None, side: float = 1.0, base_props: Dict[PropertyType, str] | None = None, name: str = 'Hexagonal_Cell')[source]

Bases: Cell

Class for representing a hexagonal cell characterised in terms of its geometry layouts and the associated properties. It is based on a hexagonal shape whose corresponding Surface object is built from the geometric settings provided at its initialisation.

The cell geometry layout can be represented in terms of its technological geometry. The surfaces that constitute this layout represent the regions associated with a different material property. In fuel assemblies, a unit cell represents a fuel pin characterised by concentric circular regions. However, this class offers no limitation on the type of surfaces and their positioning, provided they are compatible with the dimensions of the cell. In addition, since it is a subclass of Cell, and consequently of Fillable, it can contain not only Region objects, but also other Fillable instances (e.g., a Lattice so to model an assembly).

In any case, the associated Region objects describe the technological geometry layout of the cell. Additionally, this geometry can be refined by subdividing it into sectors or by adding circles within a circular region. The GEOM edge objects resulting from the refinement are stored in the map associating the compound to the type of geometry.

Parameters:
  • center (Tuple[float, float, float] | None = None) – The XYZ coordinates of the centre of the cell.

  • side (float = 1.0) – The length of the side of the regular hexagon representing the shape of the cell.

  • name (str = "Hexagonal_Cell") – The name of the cell when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the cell.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the cell is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the cell.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the cell’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the cell.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

glow.geometry_layouts.fillable_layouts module

Module containing the class enabling the creation and the visualisation of geometry layouts that can be described according to a hierarchical structure.

class Fillable[source]

Bases: Compound, Layout

Class to represent any geometry layout that can be filled with regions each associated to properties, such as the material.

This class inherits from the Compound wrapper class; this guarantees that subclasses of Fillable behave like the corresponding GEOM compound object when used with GEOM functions. In addition, this class inherits from the Layout class, meaning that a proper implementation of each abstract method of Layout is included herein or in subclasses of Fillable.

This class offers to its subclasses the capability to represent their geometry layout as the superimposition of multiple layers made either of Region or Fillable objects. By relying on this layer concept, the whole layout can be represented in a tree-like structure where nodes are represented by Fillable objects, while leaves by Region ones. In addition, it enables a mapping between different geometry views, according to the GeometryType enumeration.

dimensions

The X-Y characteristic dimensions of the GEOM object.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers. It is used to switch between different visualisation types (e.g., technological, sectorized).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or nested Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the layout is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object representing the centre of the GEOM object.

Type:

Vertex

regions

A flat list of Region objects contained by the current instance. Maintained in addition to the layered layers structure to allow quick iteration or lookups over all regions.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the layout.

Type:

Surface | None = None

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Surface objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Surface]

add(layout: Region | Self, position: Tuple[float, float, float] | None = None, layer_index: int | None = None) None[source]

Method that adds a generic layout, i.e. either a Region or a Fillable object, to the technological geometry layout of this instance at the indicated layer.

The given layout object is first translated, if needed, so that the coordinates of its CDG match the indicated position. If no position is provided, the layout object is placed in the CDG of this instance. The given layout is stored at the end of the sublist of the layers attribute that is specified by the value of the indicated parameter layer_index, if any. Otherwise, a new sublist (i.e. a new layer) is created with the given layout. If the layer index value is not valid, an exception is raised. Please note that, when providing layouts on the same layer, they must not overlap.

Parameters:
  • layout (Region | Self) – The generic layout object to add.

  • position (Tuple[float, float, float] | None) – The XYZ coordinates of the layout’s centre, if any. It defaults to None, meaning that the layout is added at the current instance centre.

  • layer_index (int | None) – The index identifying the layer at which the given layout should be added. It defaults to None, meaning that the layout is stored in a new layer.

Raises:

ValueError – If the indicated layer index is not valid.

Notes

This method simply updates the list of layers of the technological geometry layout with the given layout without collapsing the layers and updating the entire GEOM compound object this instance refers to. To collapse the layers and update all the contained layouts of this instance without displaying the geometry in the 3D viewer of SALOME, call the method update_hierarchical_structure. To update and display the geometry layout with all the regions of the technological geometry, call the method show.

apply_symmetry(symmetry: SymmetryType) None[source]

Method for deriving the portion of the geometry layout that represents the given type of symmetry. According to the type, the shape that identifies the symmetry is derived and stored in the corresponding instance attribute mapping types and shapes. The state attribute, which indicates the state of the layout, is modified by properly setting the active symmetry type.

Parameters:

symmetry (SymmetryType) – The type of symmetry to handle.

Raises:

RuntimeError – If the indicated symmetry type is not supported for the current instance.

clone() Self[source]

Method that returns a copy of the current Fillable instance.

Returns:

A copy of the current instance.

Return type:

Self

get_geometry_map(geom_type: GeometryType) Compound[source]

Method that gets the Compound object associated to the given GeometryType for the current instance. It defaults to the compound made by collecting all the mappings between the given GeometryType and the corresponding Compound object for every Fillable in the hierarchy tree of this instance. If an empty object is found, an exception is raised.

Parameters:

geom_type (GeometryType) – The type of geometry to look for.

Returns:

Grouping all the mappings between the given GeometryType and the corresponding Compound object for every Fillable in the hierarchy tree of this instance.

Return type:

Compound

Raises:

RuntimeError – If no Compound object is associated to the indicated GeometryType element.

get_regions() List[Region][source]

Method that collects and returns all the Region objects from the layers of the current instance. For each layer, it iterates through its layouts and collect any Region instances directly, or recursively calls this method for each Fillable object found along the hierarchy. The result of the collection is a flat list of all the Region objects that are representative of the technological geometry layout.

Returns:

A list containing the Region objects representative of the technological geometry layout.

Return type:

List[Region]

get_regions_with_symmetry(symmetry: SymmetryType, apply_tolerance_limit: bool = False) List[Region][source]

Method that collects and returns all the Region objects from the layers of the current instance that are representative of the technological geometry layout. If any symmetry type other than SymmetryType.FULL is given, only the regions (or their portions) in common with the shape identifying the symmetry type are returned. If no shape is stored for the indicated symmetry type, an exception is raised. If indicated, the tolerances of the geometric elements of the Regions objects are limited to the 1e-6 value to avoid geometric inconsistencies on the result of the common operation.

Parameters:
  • symmetry (SymmetryType) – The type of symmetry for which the corresponding Region objects of the layout are returned.

  • apply_tolerance_limit (bool) – If True, the tolerances of the geometric elements of the Regions objects are limited to the 1e-6 value.

Returns:

A list containing the Region objects representative of the technological geometry layout according to the given type of symmetry.

Return type:

List[Region]

Raises:

RuntimeError – If no shape is stored in the current instance for the indicated symmetry type.

print_region_info(shape: Any | None = None) None[source]

Method that retrieves and prints descriptive information about the region of the layout this instance refers to according to the given GEOM face, if any, otherwise the one currently selected in the SALOME study. The printed information is related to:

  • the tree representation of the hierarchical structure up to the target Region object;

  • the values for each of the PropertyType items associated to the target Region object.

Parameters:

shape (Any | None = None) – The GEOM face indicating the region belonging to the technological geometry of the layout this instance refers to and whose information have to be retrieved and printed. When not provided, the GEOM face currently selected in the SALOME study is considered.

Raises:
  • RuntimeError – When no GEOM face, or more than one, is selected.

  • RuntimeError – If the given GEOM face does not correspond to any of the Region objects belonging to the hierarichal tree of this instance.

restore() None[source]

Method that restores the geometry layout of this instance. It removes all the layouts stored in the layers while keeping the characteristic shape intact. Any symmetry and geometry types mappings are completely cleared. The result is that the layout is set to a GEOM face built from the borders of the current layout, while the layers and regions lists are filled only by the corresponding Region without any associated property.

rotate(angle: float, axis: Edge | None = None) None[source]

Method for rotating the layout by the given angle (in degrees) around the given axis, if any is provided, otherwise around the axis perpendicular to the layout and passing through its centre.

Parameters:
  • angle (float) – The rotation angle in degrees.

  • axis (Edge | None = None) – The Edge object representing the rotation axis, if any.

scale(factor: float, origin: Vertex | None = None) None[source]

Method for scaling the layout by the given factor wrt the Vertex object, if any. If no reference vertex is provided, the scaling is performed wrt the centre of the region. The GEOM object this instance refers to, all the layout objects in each layer, and the mappings, are scaled by the same factor.

Parameters:
  • factor (float) – The scaling factor.

  • origin (Vertex | None = None) – Identifying the point wrt the scaling is performed. If None, the reference point is the region’s centre.

Raises:

ValueError – If the scaling factor is less than or equal to zero.

set_region_properties(properties: Dict[PropertyType, str], region: Any | None = None) None[source]

Method that enables setting the values of the given property types for the region of the layout whose GEOM face is passed as input. Alternatively, if no one is provided, the method gets the GEOM face currently selected in the SALOME study, if any. The whole hierarchical tree of the layout is traversed to find the Region object that matches the GEOM face and its properties updated with the given dictionary.

Parameters:
  • properties (Dict[PropertyType, str]) – The dictionary associating the PropertyType items to the corresponding values with which the properties of the region have to be updated.

  • region (Any | None = None) – The GEOM face indicating the region belonging to the technological geometry of the layout this instance refers to and whose properties have to be updated. When not provided, the GEOM face currently selected in the SALOME study is considered.

Raises:
  • RuntimeError – When no GEOM face, or more than one, is selected.

  • RuntimeError – If the given GEOM face does not correspond to any of the Region objects belonging to the hierarichal tree of this instance.

show(*args: Any) None[source]

Method for displaying the geometry layout in the 3D viewer of SALOME according to the PropertyType and GeometryType settings, provided as input regardless of their order. Regions representative of the technological geometry layout are displayed using a color map according to the values of the indicated PropertyType associated to them. If no PropertyType is specified, the regions are displayed without any color.

In addition, the displayed regions correspond to those of the last applied SymmetryType. Given the regions of the entire layout, a common operation with the shape of the symmetry provides the regions to display.

By default this method displays the regions of the technological geometry. If a different GeometryType is given, the method also displays the GEOM compound of the edges describing the layout’s refined geometry. If specified differently, this method only adds the GEOM face objects of the regions of technological geometry in the Object Browser of SALOME without triggering their visualization. This can be used to avoid overheads when layouts characterised by lots of face objects are shown in SALOME.

Parameters:

*args (Any) – Positional arguments providing the display settings.

Raises:
  • RuntimeError – If any parameter other than the expected ones in provided.

  • RuntimeError – If any displayed Region object does not declare a value for the indicated PropertyType, if any.

  • RuntimeError – If this instance does not have any Compound object associated to the given GeometryType.

Notes

Allowed arguments to this method are:

  • PropertyType, used to derive the colour map associated to the regions of the technological geometry;

  • GeometryType, used to indicate the type of geometry of this layout.

  • boolean flag, used to avoid triggering the automatic visualisation of the regions and the sectorised edges, if False.

translate(new_cntr: Tuple[float, float, float]) None[source]

Method for translating the geometric elements of the current layout, i.e. the corresponding GEOM compound, the centre and the layouts in each layer. If any of the layouts of a layer is an instance of the subclasses of Fillable, this method is applied recursively.

Parameters:

new_cntr (Tuple[float, float, float]) – The XYZ coordinates of the new center of the layout.

update(layout: Compound | Face) None[source]

Method for updating the current instance by updating the GEOM object this instance refers to, the centre of the layout and any mapping between GeometryType values and Compound objects.

Parameters:

layout (Compound | Face) – The new layout to update the current instance with.

Notes

This method does not update the layouts stored in the layers instance attribute accordingly with the GEOM object of this instance.

update_hierarchical_structure(collapse_layers: bool = False) None[source]

Method that processes the layers of the current instance object to update the entire geometric hierarchical structure which represents the technological geometry layout. This method collapses all the layers by traversing the entire tree in reverse order, and cutting the Region or the Fillable objects that are overlapped. This operation is skipped and the method exits without changes if there is no need to update the technological geometry layout (i.e. the is_update_needed value of the state attribute is False).

The operation of assembling all the layers requires that each layout is up-to-date. This means that each Fillable object in the list of layers is further processed by recursively calling this method to collapse its own layers.

Finally, the GEOM compound object representative of this instance is updated by collecting in a GEOM compound all the Region objects retrieved from the layouts in each layer.

To simplify the hierarchical tree, a True value can be provided. If so, the hierarchical tree is collapsed and the layers reduced to a sigle layer collecting all the Region objects in the tree.

Parameters:

collapse_layers (bool = False) – Flag stating whether the current hierarchical tree should be collapsed and reduced to a list of Region objects only.

find_region_path_in_tree(layers: List[List[Region | Fillable]], shape: Any, path: List[Tuple[int, int]] | None = None) List[Tuple[int, int]] | None[source]

Function that traverses the given hierarchical tree as a list of possibly nested lists to find the path to the Region object that matches the given shape. A positive match occurs either if their shapes are identical or if a vertex built within the input shape is within a Region object in the tree. If no match is found, None is returned.

For each Fillable object that contains the given GEOM face, the indices of the list of lists of its parent Fillable in which the current one is found are stored. The final result is a list of tuples of indices that helps to reconstruct the entire path from the root to the matching Region.

Parameters:
  • layers (List[List[Region | Fillable]]) – The hierarchical tree as list of nested lists of Region (leaves) and Fillable objects (nodes).

  • shape (Any) – The GEOM face whose corresponding Region has to be found.

  • path (List[Tuple[int, int]] | None = None) – The path storing the indices to progressively reach the parent of the current Fillable object. It defaults to None, indicating the beginning of the search.

Returns:

The list of tuples of indices used in each of the nested lists from the root Fillable to the matching Region. If no match is found None is returned.

Return type:

List[Tuple[int, int]] | None

follow_path_to_node(root: Fillable, path: List[Tuple[int, int]]) Region | Fillable[source]

Function that traverses the nested hierarchical trees starting from the root Fillable object up to the node that results from following the provided path.

Parameters:
  • root (Fillable) – Root node of the hierarchical tree.

  • path (List[Tuple[int, int]]) – Sequence of pairs of indices describing the path up to the node.

Returns:

The layout (either a Region or a Fillable object) at the end of the path.

Return type:

Region | Fillable

Raises:

IndexError – If a layer or element index is out of range.

get_region_in_tree(tree: List[List[Region | Fillable]], shape: Any) Region | None[source]

Function that traverses the given hierarchical tree as a list of possibly nested lists to find the Region object that matches the given shape. A positive match occurs either if their shapes are identical or if a vertex built within the input shape is within a Region object in the tree. If no match is found, None is returned.

Parameters:
  • tree (List[List[Region | Fillable]]) – The hierarchical tree as list of nested lists of Region (leaves) and Fillable objects (nodes).

  • shape (Any) – The GEOM face whose corresponding Region has to be found.

Returns:

The Region contained in the hierarchical tree matching the given shape, or None if no one is found.

Return type:

Region | None

print_subtree(root: Fillable, target: Region | Fillable, path: List[Tuple[int, int]]) None[source]

Function that prints to console the portion of the hierarchical tree from the given root Fillable object to the target (either a Region or a Fillable object) according to the path containing the list of tuples of indices allowing to traverse the tree up to the target.

Parameters:
  • root (Fillable) – The root Fillable object.

  • target (Region | Fillable) – The target (either a Region or a Fillable object) the path points to.

  • path (List[Tuple[int, int]]) – The sequence of tuples of indices that allows to traverse the tree from root to target.

glow.geometry_layouts.geometries module

Module containing classes providing the means for creating basic geometric shapes in SALOME.

class Circle(center: Tuple[float, float, float] | None = None, radius: float = 1.0, name: str = 'Circle')[source]

Bases: Surface

Class representing a circle surface in SALOME. It is built by providing its center and radius: if no center (XYZ coordinates) is provided, the circle is built in the origin, normal to the XY plane.

Parameters:
  • center (Tuple[float, float, float] | None = None) – The XYZ coordinates of the circle center.

  • radius (float = 1.0) – The radius of the circle.

  • name (str = "Circle") – The name to be assigned to the face when displayed in the current SALOME study.

borders

The list of Edge objects representing the border edges of the

Type:

List[Edge]

dimensions

The characteristic dimensions of the circle along the X-Y axes.

Type:

Tuple[float, float]

entry_id

The ID associated to the surface in the SALOME study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the surface this instance refers to.

Type:

Any | None

name

The name of the surface when displayed in the SALOME study.

Type:

str

o

The Vertex object representing the surface center.

Type:

Vertex

radius

The radius of the circle.

Type:

float

rot_angle

The rotation angle (in degrees) of the geometric surface wrt the X-axis.

Type:

float

update(layout: Face) None[source]

Method for updating the geometrical characteristics of the surface from the given GEOM face object.

Parameters:

face (Face) – The new Face object to substitute the current with.

Raises:

RuntimeError – If the provided shape type is not ShapeType.FACE or does not represent a circle.

class Hexagon(center: Tuple[float, float, float] | None = None, edge_length: float = 1.0, name: str = 'Hexagon')[source]

Bases: Surface

Class representing a 2D hexagon surface in SALOME. It is built by providing its center and the length of edge: if no center (XYZ coordinates) is provided, the hexagon is built centered in the XYZ origin.

The hexagon is built by means of a construction circle the hexagon is inscribed into. The convention for numbering the vertices of the hexagon is the following:

     3       2
     + ————— +
    /         \
   /           \
4 +             + 1
   \           /
    \         /
     + ————— +
     5       6

By default, the hexagon orientation is zero, i.e. the vertices 1 and 4 are horizontally aligned.

Parameters:
  • center (Union[Tuple[float, float, float], None] = None) – The XYZ coordinates of the center of the hexagon.

  • edge_length (float = 1.0) – The lenght of the edge of the hexagon.

  • name (str = "Hexagon") – The name to be assigned to the face when displayed in the current SALOME study.

borders

The list of edge objects representing the border edges of the surface.

Type:

List[Any]

dimensions

The characteristic dimensions of the hexagon along the X-Y axes (i.e. the edge and the apothem).

Type:

Tuple[float, float]

entry_id

The ID associated to the surface in the SALOME study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the surface this instance refers to.

Type:

Any | None

name

The name of the surface when displayed in the SALOME study.

Type:

str

o

The Vertex object representing the surface center.

Type:

Vertex

rot_angle

The rotation angle (in degrees) of the geometric surface.

Type:

float

update(layout: Face) None[source]

Method for updating the geometrical characteristics of the surface from the given GEOM face object.

Parameters:

layout (Face) – The new face object to substitute the current face with.

Raises:
  • RuntimeError – If the provided shape type is not ShapeType.FACE.

  • RuntimeError – If the provided shape does not represent a hexagon.

class Rectangle(center: Tuple[float, float, float] | None = None, height: float = 1.0, width: float = 1.0, rounded_corners: List[Tuple[int, float]] | None = None, name: str = 'Rectangle')[source]

Bases: Surface

Class representing a 2D rectangle surface in SALOME. It is built by providing its center, height and width: if no center (XYZ coordinates) is provided, the rectangle is built centered in the XYZ origin. By default, its height and width have the same value, thus allowing to represent a square surface. In addition, it supports the construction of rounded corners by the input list of tuples. Each tuple has as first element the ID of the corner and as second element the radius of the rounded corner.

The convention for numbering the vertices and edges of the rectangle is the following:

3    (2)    2
+ <———————— +
|           ^
| (3)       |
|           | (1)
v           |
+ ————————> +
0    (0)    1
Parameters:
  • center (Union[Tuple[float, float, float], None] = None) – The XYZ coordinates of the surface center.

  • height (float = 1.0) – The height of the rectangle.

  • width (float = 1.0) – The width of the rectangle.

  • rounded_corners (List[Tuple[int, float]] | None = None) – List of tuples with corner ID and corresponding curvature radius. The numbering convention for ID is presented above.

  • name (str = "Rectangle") – The name to be assigned to the face when displayed in the current SALOME study.

borders

The list of Edge objects representing the border edges of the surface.

Type:

List[Edge]

dimensions

The characteristic dimensions of the rectangle along the X-Y axes ( i.e. the width and the height).

Type:

Tuple[float, float]

entry_id

The ID associated to the surface in the SALOME study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the surface this instance refers to.

Type:

Any | None

name

The name of the surface when displayed in the SALOME study.

Type:

str

o

The Vertex object representing the surface center.

Type:

Vertex

rot_angle

The rotation angle (in degrees) of the geometric surface.

Type:

float

update(layout: Face) None[source]

Method for updating the geometrical characteristics of the surface from the given GEOM face object.

Parameters:

layout (Face) – The new face object to substitute the current face with.

Raises:
  • RuntimeError – If the provided shape type is not ShapeType.FACE.

  • RuntimeError – If the provided shape does not represent a rectangle.

class Surface(geom_obj: Face | None, center: Tuple[float, float, float] | None = None)[source]

Bases: Face, Layout

Abstract class for representing any geometric surface.

Parameters:
  • geom_obj (Face | None) – The Face object (or the GEOM face directly) the surface corresponds to.

  • center (Union[Tuple[float, float, float], None] = None) – The XYZ coordinates of the generic geometric surface center.

borders

A list of edge objects representing the border edges of the surface.

Type:

List[Any]

dimensions

The X-Y characteristic dimensions of the geometric surface.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the geometric surface is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the surface this instance refers to.

Type:

Any | None

name

The name assigned to the geometric surface when added to the study.

Type:

str

o

The Vertex object representing the centre of the geometric surface.

Type:

Vertex

rot_angle

The rotation angle (in degrees) of the geometric surface wrt the X-axis.

Type:

float

rotate(angle: float, axis: Edge | None = None) None[source]

Method that rotates the surface geometry. The face, its border edges, vertices and construction circle are rotated by the given angle expressed in degrees around the given axis, if any is provided, otherwise around the axis perpendicular to the surface and passing through its centre.

Parameters:
  • angle (float) – The rotation angle in degrees.

  • axis (Edge | None = None) – The Edge object representing the rotation axis, if any.

scale(factor: float, origin: Vertex | None = None) None[source]

Method for scaling the surface by the given factor wrt the Vertex object, if any. If no reference vertex is provided, the scaling is performed wrt the centre of the surface.

Parameters:
  • factor (float) – The scaling factor.

  • origin (Vertex | None = None) – Identifying the point wrt the scaling is performed. If None, the reference point is the surface’s centre.

Raises:

ValueError – If the scaling factor is less than or equal to zero.

show(*args: Any) None[source]

Method for displaying the layout in the 3D viewer of SALOME according to the given settings.

Parameters:

*args (Any) – Positional arguments. Must be empty.

Raises:

ValueError – If any positional arguments are provided.

translate(new_cntr: Tuple[float, float, float]) None[source]

Method that translates the surface geometry to the given position. All the geometrical elements (center, face, its borders, vertices and construction circle) needed to describe the shape are moved accordingly.

Parameters:

new_cntr (Tuple[float, float, float]) – The XYZ coordinates of the new center of the shape.

update(layout: Face) None[source]

Method for updating the geometric characteristics of the surface from the given GEOM face object.

Parameters:

layout (Face) – The new face object to substitute the current face with.

Raises:

RuntimeError – If the provided shape type is not ShapeType.FACE or ShapeType.COMPOUND.

build_hexagon_from_apothem(apothem: float, center: Tuple[float, float, float] | None = None) Hexagon[source]

Function that builds an instance of the Hexagon class from the value of the apothem. The resulting face is placed at the indicated center, if any, otherwise it is centered in the XYZ space origin.

Parameters:
  • apothem (float) – The value of the hexagon apothem.

  • center (Tuple[float, float, float] | None = None) – The XYZ coordinates of the hexagon center, if any.

Returns:

A Hexagon object with dimensions and center as indicated.

Return type:

Hexagon

build_parallelogram(side_x: float, side_y: float, left_corner_angle: float, left_corner: Tuple[float, float, float] | None = None) Surface[source]

Function that builds a Surface instance representing a parallelogram from the given values for its sides and the angle (in degrees) of the left-most corner wrt the X-axis. The resulting face is placed with its left corner that coincides with the given coordinates, if any, otherwise the corner is the XYZ space origin.

Parameters:
  • side_x (float) – The length of the side parallel to the X-axis.

  • side_y (float) – The length of the side parallel to the Y-axis.

  • left_corner_angle (float) – The value of the angle (in degrees) of the left-most corner wrt the X-axis.

  • left_corner (Tuple[float, float, float] | None = None) – The XYZ coordinates of the left corner, if any.

Returns:

The Surface instance representing a parallelogram.

Return type:

Surface

build_regular_triangle(side_length: float, left_corner: Tuple[float, float, float] | None = None) Surface[source]

Function that builds a Surface instance representing a regular triangle from the given length of its side. The resulting face is placed with its left corner that coincides with the given coordinates, if any, otherwise the corner is the XYZ space origin.

Parameters:
  • side_length (float) – The length of the side of the regular triangle.

  • left_corner (Tuple[float, float, float] | None = None) – The XYZ coordinates of the left corner, if any.

Returns:

The Surface instance representing a regular triangle.

Return type:

Surface

build_right_triangle(hypotenuse: float, cathetus: float, left_corner: Tuple[float, float, float] | None = None) Surface[source]

Function that builds a Surface instance representing a right triangle from the given values for the hypotenuse and its left cathetus. The resulting face is placed with its left corner that coincides with the given coordinates, if any, otherwise the corner is the XYZ space origin. The hypotenuse of the right triangle is considered to be parallel to the X-axis.

Parameters:
  • hypotenuse (float) – The length of the hypotenuse.

  • cathetus (float) – The length of the left cathetus.

  • left_corner (Tuple[float, float, float] | None = None) – The XYZ coordinates of the left corner, if any.

Returns:

The Surface instance representing a right triangle.

Return type:

Surface

build_right_triangle_from_catheti(cathetus_x: float, cathetus_y: float, left_corner: Tuple[float, float, float] | None = None) Surface[source]

Function that builds a Surface instance representing a right triangle from the given values for the two catheti, one parallel to the X-axis, the other to the Y-axis. The resulting face is placed with its left corner that coincides with the given coordinates, if any, otherwise the corner is the XYZ space origin.

Parameters:
  • cathetus_x (float) – The length of the cathetus parallel to the X-axis.

  • cathetus_y (float) – The length of the cathetus parallel to the Y-axis.

  • left_corner (Tuple[float, float, float] | None = None) – The XYZ coordinates of the left corner, if any.

Returns:

The Surface instance representing a right triangle.

Return type:

Surface

glow.geometry_layouts.lattices module

Module containing classes providing the means for creating lattices from base cells types in SALOME.

class CartesianLattice(cells: List[Cell] = [], centre: Tuple[float, float, float] | None = None, name: str = 'CartesianLattice')[source]

Bases: Lattice

Class for representing a Cartesian lattice characterised in terms of its geometry layout made of cells arranged according to a rectangular grid. This class can be used to model a full Cartesian lattice assembled either by providing its cells directly or successively calling the methods for adding one or more cells to the layout.

Parameters:
  • cells (List[Cell] = []) – The list of cells that constitute the lattice, as objects of the class Cell or of its subclasses.

  • centre (Tuple[float, float, float] | None = None) – The coordinates of the lattice centre, if any.

  • name (str = "CartesianLattice") – The name of the lattice when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the lattice.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the lattice is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the lattice.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the lattice’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the lattice.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

add_ring_of_cells(cell: Cell, ring_index: int, layer_index: int | None = None) None[source]

Method that adds a ring of Cell objects to the lattice at the positions that correspond to the given ring index and layer. This method iteratively adds the provided Cell object at specific construction points determined by the ring_index parameter, which indicates the ring where the cells should be placed. Optionally, a layer_index can be provided to specify the layer to which the ring of cells is added; if not provided, the cells are added to a new layer.

Parameters:
  • cell (Cell) – The Cell instance to be added repeatedly to form a ring.

  • ring_index (int) – The index indicating which ring to add the cells to.

  • layer_index (int | None = None) – The index of the layer to which the cells are added. If None, a new layer is created.

Raises:
  • ValueError – If indicating 0 as the ring index where cells should be added.

  • ValueError – If indicating a layer index not falling within the valid range of existing layers.

Notes

Index 0 refers to the lattice centre (for lattices with an even number of cells on one if the sides) or the central cell (valid for lattices with an odd number of cells on both sides); indices greater than 0 refer to rings around the centre.

add_rings_of_cells(cell: Cell, no_rings: int, ring_index: int = 1, layer_index: int | None = None) None[source]

Method that adds several rings of Cell objects to the lattice at the positions calculated for each ring indicated by the total number of rings, starting from the ring_index parameter. Optionally, a layer_index can be provided to specify the layer to which the ring of cells is added; if not provided, the cells are added to a new layer.

Parameters:
  • cell (Cell) – The Cell instance to be iteratively added in order to build the rings of cells.

  • no_rings (int) – The number of rings to add starting from the indicated ring index.

  • ring_index (int = 1) – The index indicating the starting ring index. Default value is 1.

  • layer_index (int | None = None) – The index of the layer to which the cells are added. If None, a new layer is created.

Raises:
  • ValueError – If indicating a value less than 1 for the total number of rings to add.

  • ValueError – If indicating 0 as the ring index from which the rings of cells should be added.

  • ValueError – If indicating a layer index not falling within the valid range of existing layers.

Notes

Index 0 refers to the lattice centre (for lattices with an even number of cells on one if the sides) or the central cell (valid for lattices with an odd number of cells on both sides); indices greater than 0 refer to rings around the centre.

class HexLattice(cells: List[Cell] = [], centre: Tuple[float, float, float] | None = None, name: str = 'HexLattice')[source]

Bases: Lattice

Class for representing a hexagonal lattice characterised in terms of its geometry layout made of cells arranged according to a hexagonal grid. This class can be used to model a full hexagonal lattice assembled either by providing its cells directly or successively calling the methods for adding one or more cells to the layout. By default, the hexagonal lattice expects cells are provided so that the characteristic shape of the lattice follows a X-oriented hexagon. This means that cells should be rotated by 90° before being added.

Parameters:
  • cells (List[Cell] = []) – The list of cells that constitute the lattice, as objects of the class Cell or of its subclasses. Considered if no setup is provided.

  • centre (Tuple[float, float, float] | None = None) – The coordinates of the lattice centre, if any.

  • name (str = "HexLattice") – The name of the lattice when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the lattice.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the lattice is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the lattice.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the lattice’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the lattice.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

add_ring_of_cells(cell: Cell, ring_index: int, layer_index: int | None = None) None[source]

Method that adds a ring of Cell objects to the lattice at the positions that correspond to the given ring index and layer. This method iteratively adds the provided Cell object at specific construction points determined by the ring_index parameter, which indicates the ring where the cells should be placed. Optionally, a layer_index can be provided to specify the layer to which the ring of cells is added; if not provided, the cells are added to a new layer.

Parameters:
  • cell (Cell) – The Cell instance to be added repeatedly to form a ring.

  • ring_index (int) – The index indicating which ring to add the cells to.

  • layer_index (int | None = None) – The index of the layer to which the cells are added. If None, a new layer is created.

Raises:
  • ValueError – If indicating 0 as the ring index where cells should be added.

  • ValueError – If indicating a layer index not falling within the valid range of existing layers.

Notes

Index 0 refers to the central cell of the lattice; indices greater than 0 refer to rings around the centre.

add_rings_of_cells(cell: Cell, no_rings: int, ring_index: int = 1, layer_index: int | None = None) None[source]

Method that adds several rings of Cell objects to the lattice at the positions calculated for each ring indicated by the total number of rings, starting from the ring_index parameter. Optionally, a layer_index can be provided to specify the layer to which the ring of cells is added; if not provided, the cells are added to a new layer.

Parameters:
  • cell (Cell) – The Cell instance to be iteratively added in order to build the rings of cells.

  • no_rings (int) – The number of rings to add starting from the indicated ring index.

  • ring_index (int = 1) – The index indicating the starting ring index. Default value is 1.

  • layer_index (int | None = None) – The index of the layer to which the cells are added. If None, a new layer is created.

Raises:
  • ValueError – If indicating a value less than 1 for the total number of rings to add.

  • ValueError – If indicating 0 as the ring index from which the rings of cells should be added.

  • ValueError – If indicating a layer index not falling within the valid range of existing layers.

Notes

Index 0 refers to the central cell of the lattice; indices greater than 0 refer to rings around the centre.

class Lattice(cells: List[Cell] = [], centre: Tuple[float, float, float] | None = None, name: str = 'Lattice')[source]

Bases: Fillable

Class for representing any lattice characterised in terms of its geometry layout made of cells that do not follow a specific pattern. This class can be used to model a portion of a generic lattice assembled by simply positioning the cells one by one. In this sense, it could be useful to represent a portion of a colorset without the need to build all the assemblies around the central one. This class does not support the placement of one or several rings of the same cell as it serves to describe a generic pattern. Subclasses of Lattice provide specialised methods to address this need according to the type of pattern, i.e. either Cartesian or hexagonal.

Parameters:
  • cells (List[Cell] = []) – The list of cells that constitute the lattice, as objects of the class Cell or of its subclasses.

  • centre (Tuple[float, float, float] | None = None) – The coordinates of the lattice centre, if any.

  • shape (Surface | None = None) – The Surface object representing the characteristic shape of the lattice.

  • base_props (Dict[PropertyType, str] | None = None) – The mapping from PropertyType items to values associated to the characteristic shape of the lattice.

  • name (str = "Lattice") – The name of the lattice when added to the current SALOME study.

dimensions

The X-Y characteristic dimensions of the shape of the lattice.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the layout this instance refers to.

Type:

Any | None

geometry_maps

A mapping from GeometryType values to Compound objects. Each entry provides a different representation for the geometry layout this instance refers to. It is used to switch between different visualisation types (e.g., technological, refined).

Type:

Dict[GeometryType, Compound]

layers

A list of layers, each layer itself being a list of Region objects or Fillable instances. Layers represent the hierarchical structure of the geometry layout.

Type:

List[List[Region | Self]]

name

The name of the GEOM object identifying the layout this instance refers to. It is used when the lattice is added to the current SALOME study.

Type:

str | None = None

o

The Vertex object being the centre of the GEOM object which represents the geometry layout of the lattice.

Type:

Vertex

regions

A flat list of Region objects obtained by collapsing all the layers. Maintained in addition to the layers structure to allow the visualization of the layout with a property colour map.

Type:

List[Region]

rot_angle

The rotation angle (in degrees) of the lattice’s GEOM object wrt the X-axis.

Type:

float

shape

The Surface object representing the characteristic shape of the lattice.

Type:

Surface

state

Providing the state of the layout in the SALOME study.

Type:

LayoutState

symmetry_map

A mapping from SymmetryType values to Face objects. Each entry provides the characteristic shape of the corresponding symmetry type.

Type:

Dict[SymmetryType, Face]

add(layout: Region | Fillable, position: Tuple[float, float, float] | None = None, layer_index: int | None = None) None[source]

Method that adds a generic layout, i.e. either a Region or a Fillable object, to the technological geometry layout of this instance at the indicated layer.

The given layout object is first translated, if needed, so that the coordinates of its CDG match the indicated position. If no position is provided, the layout object is placed in the CDG of this instance. The given layout is stored at the end of the sublist of the layers attribute that is specified by the value of the indicated parameter layer_index, if any. Otherwise, a new sublist (i.e. a new layer) is created with the given layout. If the layer index value is not valid, an exception is raised. Please note that, when providing layouts on the same layer, they must not overlap.

Parameters:
  • layout (Region | Self) – The generic layout object to add.

  • position (Tuple[float, float, float] | None) – The XYZ coordinates of the layout’s centre, if any. It defaults to None, meaning that the layout is added at the current instance centre.

  • layer_index (int | None) – The index identifying the layer at which the given layout should be added. It defaults to None, meaning that the layout is stored in a new layer.

Raises:

ValueError – If the indicated layer index is not valid.

Notes

This method simply updates the list of layers of the technological geometry layout with the given layout without collapsing the layers and updating the entire GEOM compound object this instance refers to. To collapse the layers and update all the contained layouts of this instance without displaying the geometry in the 3D viewer of SALOME, call the method update_hierarchical_structure. To update the and display the geometry layout with all the regions of the technological geometry, call the method show.

compute_subdivision_points_on_borders(no_vrtcs: int, surface: Surface) List[Tuple[float, float, float]][source]

Function that loops through the borders of the given Surface object and builds a list of evenly spaced vertices for each. For each border, the vertices start from the starting point of the edge, which is included.

Parameters:
  • no_vrtcs (int) – The number of evenly spaced vertices to subdivide the edge into.

  • surface (Surface) – The geometric surface on which borders vertices are built.

Returns:

The list of XYZ coordinates for the vertices built on the borders of the given Surface object.

Return type:

List[Tuple[float, float, float]]

ensure_not_zero(value: int, message='Value must not be zero.') None[source]

Function that raises a ValueError exception if the given value is zero.

Parameters:
  • value (int) – The value to validate.

  • message (str) – Error message to raise if value is zero.

Raises:

ValueError – If value is equal to zero.

get_cell_at_centres(cell: Cell, centres: List[Tuple[float, float, float]], rot_angle: float, rot_axis: Edge) List[Cell][source]

Function that builds a list of the same given Cell instance where every element is placed according to the XYZ coordinates indicated by the elements of the input list. The Cell object is first cloned and rotated, then for each point in the list, the copied instance is cloned, translated and stored in the returned list.

Parameters:
  • cell (Cell) – The Cell instance to position according to the provided centres.

  • centres (List[Tuple[float, float, float]]) – The list of the XYZ coordinates of the centres each cell should be placed at.

  • rot_angle (float) – The rotation angle by which each cell should be rotated.

  • rot_axis (Edge) – The rotation axis.

Returns:

A list of Cell instances each positioned according to the provided centres.

Return type:

List[Cell]

glow.geometry_layouts.layouts module

Module containing the classes enabling the creation and the visualisation of geometry layouts built in GLOW.

class Layout[source]

Bases: ABC

Abstract class that provides characteristic data and behaviour a generic layout object should have. Attributes are common to all subclasses of Layout; they provide geometric data and the ID used by SALOME when displaying the GEOM object the layout refers to. The GEOM object of the layout is provided by subclasses of Layout. Methods herein declared are abstract, meaning only their signature is provided. Subclasses must provide dedicated implementations for each of them. These methods enable the application of Euclidean transformations to generic layouts, as well as the capability to display and update the layout.

dimensions

The X-Y characteristic dimensions of the GEOM object.

Type:

Tuple[float, float]

entry_id

The ID attributed by SALOME when the GEOM object is added to the study.

Type:

str | None

o

The Vertex object representing the centre of the GEOM object.

Type:

Vertex

rot_angle

The rotation angle (in degrees) of the GEOM object wrt the X-axis.

Type:

float

abstractmethod rotate(angle: float, axis: Edge | None = None) None[source]

Abstract method for rotating the layout by the given angle (in degrees) around the given axis, if any is provided, otherwise the axis perpendicular to the layout and passing through its centre.

Parameters:
  • angle (float) – The rotation angle in degrees.

  • axis (Edge | None = None) – The Edge object representing the rotation axis, if any.

abstractmethod scale(factor: float, origin: Vertex | None = None) None[source]

Abstract method for scaling the layout by the given factor wrt the Vertex object, if any. If no reference vertex is provided, the scaling is performed wrt the centre of the layout.

Parameters:
  • factor (float) – The scaling factor.

  • origin (Vertex | None = None) – Identifying the point wrt the scaling is performed. If None, the reference point is the layout’s centre.

abstractmethod show(*args: Any) None[source]

Abstract method for displaying the layout in the 3D viewer of SALOME according to the given settings.

Parameters:

*args (Any) – Positional arguments providing the display settings.

abstractmethod translate(new_cntr: Tuple[float, float, float]) None[source]

Abstract method for translating the layout so that its centre is positioned at the given coordinates.

Parameters:

new_cntr (Tuple[float, float, float]) – The XYZ coordinates the layout centre should be placed at.

abstractmethod update(layout: Compound | Face) None[source]

Abstract method for updating the GEOM object the layout refers to.

Parameters:

layout (Compound | Face) – The new layout to update the current with.

dimensions: Tuple[float, float]
entry_id: str | None
o: Vertex
rot_angle: float
class LayoutState(displayed_geom: GeometryType = GeometryType.TECHNOLOGICAL, is_update_needed: bool = False, symmetry_type: SymmetryType = SymmetryType.FULL)[source]

Bases: object

Dataclass storing the state of the layout in the SALOME study according to the geometry displayed, the need to update the layout, the type of applied symmetry and the index identifing the layout in DRAGON5.

displayed_geom: GeometryType = 0

Identifying the type of geometry of the elements of the layout currently displayed in the SALOME 3D viewer.

is_update_needed: bool = False

Indicating whether the layout needs to be updated (e.g., rebuilding the entire geometry layout).

symmetry_type: SymmetryType = 0

Identifying the currently applied type of symmetry.

class Region(geom_obj: Any, name: str | None = None, properties: Dict[PropertyType, str] | None = None)[source]

Bases: Face, Layout

Class that groups information regarding a generic region of the geometry layout. A Region instance represents any 2D surface bounded by one or two edges that is filled by properties, e.g. the material. Properties are expressed as a dictionary of items of the PropertyType enumeration vs the corresponding names.

This class inherits from the Face wrapper class; this guarantees a Region instance behaves like the corresponding GEOM face object when used with GEOM functions.

Parameters:
  • geom_obj (Any) – The GEOM face object the region represent.

  • name (str) – The name of the region used in the current SALOME study.

  • properties (Dict[PropertyType, str] | None = None) – A dictionary of items of the PropertyType enumeration and the corresponding values. They indicate the properties associated to the region (e.g. the material).

color

The tuple whose values represent the RGB color code associated to the region when displayed in the SALOME viewer according to a property map.

Type:

Tuple[int, int, int]

dimensions

The X-Y characteristic dimensions of the GEOM object.

Type:

Tuple[float, float]

entry_id

The ID of the region used in the current SALOME study.

Type:

str | None

geom_obj

The internal GEOM_Object representative of the region’s surface.

Type:

Any | None

name

The name associated to the region used in the current SALOME study.

Type:

str | None = None

o

The Vertex object representing the centre of the GEOM object.

Type:

Vertex

properties

The dictionary of property types and value names associated to the region.

Type:

Dict[PropertyType, str] | None = None

region_id

The ID used to globally identify a Region object.

Type:

int

rot_angle

The rotation angle (in degrees) of the GEOM object wrt the X-axis.

Type:

float

clone() Self[source]

Method that returns a copy of the current Region instance with the same ID, properties and color.

Returns:

A copy of the current instance sharing the same ID, properties and color.

Return type:

Self

reset_region_color() None[source]

Method for resetting the region color to the (167, 167, 167) RGB value, which corresponds to light grey.

rotate(angle: float, axis: Edge | None = None) None[source]

Method for rotating the region by the given angle (in degrees) around the given axis, if any is provided, otherwise around the axis perpendicular to the region and passing through its centre.

Parameters:
  • angle (float) – The rotation angle in degrees.

  • axis (Edge | None = None) – The Edge object representing the rotation axis, if any.

scale(factor: float, origin: Vertex | None = None) None[source]

Method for scaling the region by the given factor wrt the Vertex object, if any. If no reference vertex is provided, the scaling is performed wrt the centre of the region.

Parameters:
  • factor (float) – The scaling factor.

  • origin (Vertex | None = None) – Identifying the point wrt the scaling is performed. If None, the reference point is the region’s centre.

Raises:

ValueError – If the scaling factor is less than or equal to zero.

set_region_color(color: Tuple[int, int, int]) None[source]

Method for associating a specific RGB color to the region.

Parameters:

color (Tuple[int, int, int]) – RGB values identifying the color to associate the region with.

show(*args: Any) None[source]

Method for displaying the region in the 3D viewer of SALOME according to the given settings.

Parameters:

*args (Any) – Positional arguments providing the display settings. Must not be provided.

translate(new_cntr: Tuple[float, float, float]) None[source]

Method for translating the region so that its centre is positioned at the given coordinates.

Parameters:

new_cntr (Tuple[float, float, float]) – The XYZ coordinates the region centre should be placed at.

update(layout: Face) None[source]

Method for updating the GEOM object the region refers to.

Parameters:

layout (Face) – The new layout to update the current region with.

color: Tuple[int, int, int]
properties: Dict[PropertyType, str] | None
region_id: int
associate_colors_to_regions(property_type: PropertyType | None, regions: List[Region]) None[source]

Function that assigns the same color to all the regions having the same value for the given property type.

Parameters:
  • property_type (PropertyType | None) – The type of property for which colors must be assigned to regions having the same property type value. If None, the regions color is reset to its default value.

  • regions (List[Region]) – The list of Region objects to colour according to the value of the associated property type.

Raises:

RuntimeError – Showing the coordinates of the points of the regions having any issue with their properties.

build_compound_regions(compound: Any, layout_regions: List[Region]) List[Region][source]

Function that builds a Region object for each face of the given compound. Properties are assigned by identifying the corresponding Region object from the given list.

Parameters:
  • compound (Any) – The compound object for whose faces Region objects are built.

  • layout_regions (List[Region]) – The list of Region objects to use as reference.

Returns:

A list of Region objects for each of the faces contained in the input compound. The faces correspond to the given regions.

Return type:

List[Region]

Raises:

RuntimeError – If any of the face objects of the compound does not have a corresponding Region object among the given ones.

get_unique_values_for_property(property_type: PropertyType, regions: List[Region]) List[str][source]

Function that gets the unique values of the given property type for the given regions. If any Region object does not have any property or the given property type is missing, a reference point for the region is stored for logging purposes. An exception showing the coordinates of the points of the problematic regions is raised.

Parameters:
  • property_type (PropertyType) – The type of property whose unique values to collect.

  • regions (List[Region]) – The list of Region objects to select the unique values associated to the indicated PropertyType.

Returns:

A list of the unique names for the given property type that have been associated to the given regions.

Return type:

List[str]

Raises:

RuntimeError – Showing the coordinates of the points of the regions having any issue with their properties.

is_layout_contained(container: Compound | Face, candidate: Compound | Face, tolerance: float = 1e-6) bool[source]

Function that checks whether a candidate planar shape is entirely contained within a container planar shape.

This containment check is based on three successive steps:

  • areas comparison;

  • bounding box comparison;

  • exact geometric intersection area check.

The candidate is considered contained if the candidate passes all the checks with the last one verifying if the area of the geometric intersection equals the candidate’s area within the given relative tolerance.

Parameters:
  • container (Compound | Face) – The outer planar shape that is expected to contain the candidate.

  • candidate (Compound | Face) – The inner planar shape to be tested for containment.

  • tolerance (float = 1e-6) – Relative tolerance used for area comparisons and bounding-box guards. Its default value is 1e-6.

Returns:

True if the candidate is fully contained in the container (within the specified tolerance), otherwise False.

Return type:

bool

DEFAULT_REGION_COLOR: Tuple[int, int, int] = (167, 167, 167)

Default RGB color for a Region object when displayed in the SALOME viewer. The code corresponds to light grey.

glow.geometry_layouts.symmetry_management module

Module containing the class and functions for handling the construction of the shape of the symmetry that corresponds to the type of layout (i.e. generic, Cartesian and hexagonal).

class SymmetryDomain(origin: Tuple[float, float, float], full_layout_shape: Surface)[source]

Bases: object

Dataclass that represents the geometric domain required to build the characteristic shape that is associated to a given symmetry type.

This class stores the 2D shape identifying the full layout, its centre, and automatically computes the X-Y bounding extents of the layout shape.

full_layout_shape: Surface

The Surface instance representing the 2D shape of the full layout.

origin: Tuple[float, float, float]

The XYZ coordinates of the full layout centre.

x_bounds: Tuple[float, float]

The min-max values of the X-bounding extent of the full layout shape.

y_bounds: Tuple[float, float]

The min-max values of the Y-bounding extent of the full layout shape.

build_cartesian_symmetry_shape(symmetry: SymmetryType, context: SymmetryDomain) Surface[source]

Function that builds the geometric shape that corresponds to the given symmetry type and domain for a Cartesian-type layout. In addition to the symmetry types available for all the geometry layouts, this function supports those symmetries specific for geometry layouts based on a rectangular characteristic shape.

Supported symmetries are:

  • FULL: returns the characteristic shape of the layout.

  • HALF: builds a rectangle representing half of the layout.

  • QUARTER: builds a rectangle representing one quarter of the layout.

  • EIGHTH: builds a right triangle representing one eighth of the layout.

  • DIAG: builds a right triangle representing the diagonal symmetry of the layout.

Parameters:
  • symmetry (SymmetryType) – The symmetry type for which the characteristic shape is built.

  • domain (SymmetryDomain) – Instance providing the domain of the full layout in terms of XY-bounding extents, full shape and its centre.

Returns:

A geometric shape representing the requested symmetry.

Return type:

Surface

Raises:

RuntimeError – If the indicated symmetry type is not among the supported ones for a Cartesian-type layout.

build_common_symmetry_shape(symmetry: SymmetryType, domain: SymmetryDomain) Surface[source]

Function that builds the geometric shape that corresponds to the given symmetry type and domain for a generic layout. This function supports only the symmetry types that are common to all layouts, indipendently from their characteristic shape.

Supported symmetries are:

  • FULL: returns the characteristic shape of the layout.

  • HALF: builds a rectangle representing half of the layout.

  • QUARTER: builds a rectangle representing one quarter of the layout.

Parameters:
  • symmetry (SymmetryType) – The symmetry type for which the characteristic shape is built.

  • domain (SymmetryDomain) – Instance providing the domain of the full layout in terms of XY-bounding extents, full shape and its centre.

Returns:

A geometric shape representing the requested symmetry.

Return type:

Surface

Raises:

RuntimeError – If the indicated symmetry type is not supported.

build_hex_symmetry_shape(symmetry: SymmetryType, domain: SymmetryDomain) Surface[source]

Function that builds the geometric shape that corresponds to the given symmetry type and domain for a hexagonal-type layout. In addition to the symmetry types available for all the geometry layouts, this function supports those symmetries specific for geometry layouts based on a hexagonal characteristic shape.

Supported symmetries are:

  • FULL: returns the characteristic shape of the layout.

  • HALF: builds a rectangle representing half of the layout.

  • QUARTER: builds a rectangle representing one quarter of the layout.

  • THIRD: builds a parallelogram representing one third of the layout.

  • SIXTH: builds a regular triangle representing one sixth of the layout.

  • TWELFTH: builds a right triangle representing one twelfth of the layout.

Parameters:
  • symmetry (SymmetryType) – The symmetry type for which the characteristic shape is built.

  • domain (SymmetryDomain) – Instance providing the domain of the full layout in terms of XY-bounding extents, full shape and its centre.

Returns:

A geometric shape representing the requested symmetry.

Return type:

Surface

Raises:

RuntimeError – If the indicated symmetry type is not among the supported ones for a hexagonal layout.

use_symmetry_logic(symmetry_logic: Callable)[source]

Decorator that replaces the method for building the characteristic shape of the symmetry for the Fillable class and its subclasses. Depending on the nature of the layout (i.e. generic, Cartesian, hexagonal ), the method is decorated with this function which calls the specific function providing the desired behaviour.

Parameters:

symmetry_logic (Callable) – Function implementing the logic for building the shape of the symmetry according to the layout type. Admitted functions must receive the type of symmetry (as SymmetryType element) and the instance of SymmetryDomain providing the characteristics of the layout. They must return the shape of the symmetry as a Surface object.

Returns:

A decorator that overrides the method for building the shape of the symmetry in the Fillable class and in its subclasses.

Return type:

Callable