glow.interface package

Submodules

glow.interface.geom_interface module

Module containing functions providing an interface towards the GEOM functions of SALOME.

class ShapeType(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enumeration for defining the GEOM topological types of shapes.

COMPOUND: int

Indicating a compound shape type.

COMPSOLID: int

Indicating a compound solid shape type.

EDGE: int

Indicating an edge shape type.

FACE: int

Indicating a face shape type.

FLAT: int

Indicating a flat shape type.

SHAPE: int

Indicating a generic shape type.

SHELL: int

Indicating a shell shape type.

SOLID: int

Indicating a solid shape type.

VERTEX: int

Indicating a vertex shape type.

WIRE: int

Indicating a wire shape type

add_to_study(shape: Any, name: str) str[source]

Function that adds the given shape in the current SALOME study and returns its ID entry assigned by SALOME.

Parameters:
  • shape (Any) – The shape to be added to the study.

  • name (str) – The name of the shape to be visualized in the SALOME object browser.

Returns:

A string representing the ID entry assigned by SALOME to the shape when added to the current study.

Return type:

str

add_to_study_in_father(father_shape: Any, shape: Any, name: str) str[source]

Function that adds the given shape in the current SALOME study and returns its ID entry assigned by SALOME.

Parameters:
  • father_shape (Any) – The father shape in the object browser of the study.

  • shape (Any) – The shape to be added to the study.

  • name (str) – The name of the shape to be visualized in the SALOME object browser.

Returns:

A string representing the ID entry assigned by SALOME to the shape when added to the current study under the given father shape.

Return type:

str

clear_view() None[source]

Function that clears out any geometrical shape currently displayed in the SALOME 3D viewer.

display_shape(entry_id: str) None[source]

Function that displays the geometrical shape, whose entry ID is provided as input, in the SALOME 3D viewer.

Parameters:

id (str) – The entry ID of the shape to display in the SALOME 3D viewer.

extract_sorted_sub_shapes(shape: Any, sub_shapes_type: ShapeType) List[Any][source]

Function that explodes a shape on its sub-shapes of the given type. Sub-shapes are sorted by taking into account their gravity centers.

Parameters:
  • shape (Any) – The shape object to explode.

  • sub_shapes_type (ShapeType) – The type of the sub-shapes to extract as value of the ShapeType enumeration.

Returns:

A list of the sub-shapes of the given type that are contained in the provided shape.

Return type:

List[Any]

extract_sub_shapes(shape: Any, sub_shapes_type: ShapeType) List[Any][source]

Function that explodes a shape on its sub-shapes of the given type without applying any sorting algorithm.

Parameters:
  • shape (Any) – The shape object to explode.

  • sub_shapes_type (ShapeType) – The type of the sub-shapes to extract as item of the ShapeType enumeration.

Returns:

A list of the sub-shapes of the given type that are contained in the provided shape.

Return type:

List[Any]

fuse_edges_in_wire(wire: Any) Any[source]

Function that modifies the given wire object by suppressing all the vertices in the C1 continuous adjacent edges of the wire.

Parameters:

wire (Any) – The wire object whose vertices to suppress.

Returns:

A modified wire obtained by suppressing vertices in C1 continuous adjacent edges in the wire.

Return type:

Any

get_angle_between_shapes(shape1: Any, shape2: Any) float[source]

Function that computes the angle in degrees between two EDGE-type shapes, which must both be linear edges, i.e. their type name in SALOME is SEGMENT.

Parameters:
  • shape1 (Any) – The first shape object, expected to be a linear edge.

  • shape2 (Any) – The second shape object, expected to be a linear edge.

Returns:

The angle in degrees between the two segment-type shapes.

Return type:

float

Raises:

RuntimeError – If either shape1 or shape2 is not of type SEGMENT.

get_basic_properties(shape: Any) List[float][source]

Function that returns the sum of the lengths of all the wires, the area and volume of the given shape.

Parameters:

shape (Any) – The shape whose geometrical properties to extract.

Returns:

A list providing the sum of the lengths of all the wires, the area and volume of the given shape.

Return type:

List[float]

get_bounding_box(shape: Any) List[float][source]

Function that returns the bounding box extension of the given shape.

Parameters:

shape (Any) – The shape whose bounding box to extract.

Returns:

The [Xmin, Xmax, Ymin, Ymax] values representing the shape bounding box extension. Values are rounded to the 6th decimal digit to remove floating-point precision errors SALOME could introduce.

Return type:

List[float]

get_closed_free_boundary(compound: Any) List[Any][source]

Function that evaluates the closed free boundaries of the given compound object. An exception is raised if any error occurred during the operation.

Parameters:

compound (Any) – The compound object to extract the closed boundary from.

Returns:

A list of the wire objects each one forming a closed boundary within the given compound.

Return type:

List[Any]

Raises:

RuntimeError – If no closed boundaries could be extracted from the given compound object.

get_id_from_object(shape: Any) str[source]

Function that retrieves the unique SALOME ID associated with a given shape object, if shown in the current SALOME study.

Parameters:

shape (Any) – The shape object for which to retrieve the SALOME ID.

Returns:

The unique SALOME ID corresponding to the provided shape.

Return type:

str

Raises:

RuntimeError – If the shape is not present in the current SALOME study.

get_in_place(shape1: Any, shape2: Any) Any[source]

Function that extracts the sub-shape(s) of first shape, which are coincident with, or could be a part of, the second shape.

Parameters:
  • shape1 (Any) – The shape to find sub-shapes of.

  • shape2 (Any) – The shape specifying what to find in the first one.

Returns:

A compound object including all the found sub-shapes in the first given shape.

Return type:

Any

get_inertia_matrix(shape: Any) List[float][source]

Function that returns the inertia matrix of the given shape.

Parameters:

shape (Any) – The shape whose inertia matrix to extract.

Returns:

A list providing, for the given shape, the components of its inertia matrix and the moments of inertia in the XYZ directions.

Return type:

List[float]

get_kind_of_shape(shape: Any) List[Any][source]

Function that returns the list of geometrical information about the given shape which depends on the kind of shape. Shapes of interest returns the following information:

  • CIRCLE xc yc zc dx dy dz R (X-Y-Z center coordinates, X-Y-Z normal vector elements, circle radius).

  • ARC_CIRCLE xc yc zc dx dy dz R x1 y1 z1 x2 y2 z2 (X-Y-Z center coordinates, X-Y-Z normal vector elements, arc radius, X-Y-Z coordinates of arc starting and ending points).

  • SEGMENT x1 y1 z1 x2 y2 z2 (X-Y-Z coordinates of segment starting and ending points).

Notes

Values lesser than the tolerance of 1e-10 are substituted with 0 in the returned list.

Parameters:

shape (Any) – The shape whose geometrical information to extract.

Returns:

A list providing, for the given shape, its geometrical information.

Return type:

List[Any]

get_min_distance(shape1: Any, shape2: Any) float[source]

Function that returns the minimum distance between the given shapes.

Parameters:
  • shape1 (Any) – The first shape to get the minimum distance.

  • shape2 (Any) – The second shape to get the minimum distance.

Returns:

The minimum distance between the two given shapes.

Return type:

float

get_object_from_id(entry_id: str) Any | None[source]

Function that returns the geometrical object associated to the entry ID declared in the current SALOME study.

Parameters:

entry_id (str) – The value of the entry ID associated to the geometrical object in the current SALOME study.

Returns:

The geometrical object associated with the given entry ID in the current SALOME study or None, if no object could be found.

Return type:

Any | None

get_point_coordinates(point: Any) Tuple[float, float, float][source]

Function that returns the XYZ coordinates of the given vertex object.

Parameters:

point (Any) – The vertex object whose coordinates are returned.

Returns:

The XYZ coordinates of the given vertex object.

Return type:

Tuple[float, float, float]

get_selected_object() Any[source]

Function that returns the geometrical object being currently selected in the study.

Returns:

The selected geometrical object in the study.

Return type:

Any

get_shape_name(shape: Any) str[source]

Function that returns the name attribute assigned to the given shape.

Parameters:

shape (Any) – The geometrical shape whose name to retrieve.

Returns:

The value of the name attribute assigned to the given shape.

Return type:

str

get_shape_type(shape: Any) ShapeType[source]

Function that returns the type of the given shape as value of the ShapeType enumeration.

Parameters:

shape (Any) – The shape whose type to determine.

Returns:

The shape type as value of the ShapeType enumeration.

Return type:

ShapeType

get_subshape_id(shape: Any, subshape: Any) str[source]

Function that returns the entry ID of a given subshape contained in the parent shape.

Parameters:
  • shape (Any) – The parent shape.

  • subshape (Any) – The subshape contained in the parent shape.

Returns:

A string representing the entry ID associated to the subshape in the current study.

Return type:

str

is_gui_available() None[source]

Function that returns a boolean flag indicating whether the SALOME GUI is available when running a script.

Returns:

True if the SALOME GUI is available, False otherwise.

Return type:

bool

is_point_inside_shape(point: Any, shape: Any) bool[source]

Function that checks if the given point object is within the boundaries of the given geometrical shape.

Parameters:
  • point (Any) – The point object to check if inside the shape.

  • shape (Any) – The shape object the point position has to be evaluated.

Returns:

True, if the point is inside the shape, False otherwise.

Return type:

bool

make_arc_edge(point1: Any, point2: Any, point3: Any) Any[source]

Function that returns the arc edge object built from the given three vertex objects.

Parameters:
  • point1 (Any) – The vertex object being the arc’s center.

  • point2 (Any) – The vertex object being the arc’s start point.

  • point3 (Any) – The vertex object being the arc’s end point.

Returns:

The arc edge built from the given three construction points.

Return type:

Any

make_cdg(shape: Any) Any[source]

Function that returns the vertex object of the given shape CDG.

Parameters:

shape (Any) – The geometric shape whose CDG is returned.

Returns:

The shape CDG as a vertex object.

Return type:

Any

make_circle(center: Any, axis: Any | None, radius: float) Any[source]

Function that returns a circle object, given its center, axis and radius.

Parameters:
  • center (Any) – The vertex object being the center of the circle.

  • axis (Any) – The vector object being the normal axis of the circle.

  • radius (float) – The value of the circle radius.

Returns:

The circle object from the given center, axis and radius.

Return type:

Any

make_common(shape1: Any, shape2: Any) Any[source]

Function that performs the common boolean operation between the two given shapes.

Parameters:
  • shape1 (Any) – The first shape of the common operation.

  • shape2 (Any) – The second shape of the common operation.

Returns:

A shape object resulting from the common operation.

Return type:

Any

make_compound(shapes: List[Any]) Any[source]

Function that creates a compound object from the given list of shapes.

Parameters:

shapes (List[Any]) – The list of shapes to be put into the returned compound object.

Returns:

A compound object made from the given list of shapes.

Return type:

Any

make_cut(shape1: Any, shape2: Any) Any[source]

Function that performs the cut boolean operation between the two given shapes.

Parameters:
  • shape1 (Any) – The first shape of the cut operation.

  • shape2 (Any) – The second shape of the cut operation.

Returns:

A shape object resulting from the cut operation.

Return type:

Any

make_edge(vertex1: Any, vertex2: Any) Any[source]

Function that returns an edge object, given the vertex objects being its start-end points.

Parameters:
  • vertex1 (Any) – The vertex object being the edge start point.

  • vertex2 (Any) – The vertex object being the edge end point.

Returns:

The edge object built from the given start-end points.

Return type:

Any

make_face(borders: List[Any]) Any[source]

Function that returns a 2D face object, given the list of its edge objects being the face borders.

Parameters:

borders (List[Any]) – The list of edge objects being the face borders.

Returns:

The face object built on the given borders.

Return type:

Any

make_fuse(shapes: List[Any]) Any[source]

Function that performs a fuse boolean operation on the given list of shapes.

Parameters:

shapes (List[Any]) – The list of geometrical shapes to be fused into a single one.

Returns:

The face object resulting from fusing all the given shapes.

Return type:

Any

make_line(point1: Any, point2: Any) Any[source]

Function that returns a line object (i.e. a straight edge), given the point objects being its start-end points.

Parameters:
  • point1 (Any) – The point object being the line start point.

  • point2 (Any) – The point object being the line end point.

Returns:

The line object built from the given start-end points.

Return type:

Any

make_partition(shapes: List[Any], tools: List[Any], shape_type: ShapeType) Any[source]

Function that performs a partition operation on the given list of shapes by means of the tool shapes intersecting the first ones. The result is a shape made by the intersection of all the provided ones with type given as input.

Parameters:
  • shapes (List[Any]) – The list of shapes to be intersected.

  • tools (List[Any]) – The list of shapes intersecting.

  • shape_type (ShapeType) – The type of the shape resulting from the partition operation.

Returns:

A shape made by the intersection of all the provided ones with the type specified as input.

Return type:

Any

make_rotation(shape: Any, axis: Any, angle: float) Any[source]

Function that rotates the given shape by the given angle in radians.

Parameters:
  • shape (Any) – The generic shape object the rotation should be applied to.

  • axis (Any) – The vector object representing the rotation axis.

  • angle (float) – The rotation angle in radians.

Returns:

The rotated shape object.

Return type:

Any

make_scale(shape: Any, center: Any, factor: float) Any[source]

Function that scales the given shape by the specified factor, wrt the indicated center point.

Parameters:
  • shape (Any) – The generic shape object the scaling should be applied to.

  • center (Any) – The vertex object wrt the scaling is performed.

  • factor (float) – The scaling factor.

Returns:

The scaled shape object.

Return type:

Any

make_translation(shape: Any, vector: Any) Any[source]

Function that translates the given shape along the vector object.

Parameters:
  • shape (Any) – The generic shape object the translation should be applied to.

  • vector (Any) – The translation vector object.

Returns:

The translated shape object.

Return type:

Any

make_vector(vect_elem: Tuple[float, float, float]) Any[source]

Function that returns a vector object, given its XYZ components.

Parameters:

vect_elem (Tuple[float, float, float]) – The XYZ components of the vector to build.

Returns:

The vector object built on the given XYZ components.

Return type:

Any

make_vector_from_points(point1: Any, point2: Any) Any[source]

Function that returns a vector object, given its start-end points.

Parameters:
  • point1 (Any) – The start point object of the vector to build.

  • point2 (Any) – The end point object of the vector to build.

Returns:

The vector object built on the given XYZ components.

Return type:

Any

make_vertex(coords: Tuple[float, float, float]) Any[source]

Function that returns a vertex object, given its XYZ coordinates.

Parameters:

coords (Tuple[float, float, float]) – The XYZ coordinates of the vertex to build.

Returns:

The vertex object positioned at the given XYZ coordinates.

Return type:

Any

make_vertex_inside_face(face: Any) Any[source]

Function that returns a vertex object which lays on the given face, in an arbitrary position with the only condition of having a non-zero distance to the face boundary.

Parameters:

face (Any) – The reference face object to put a vertex into.

Returns:

The vertex object positioned within the given face object.

Return type:

Any

make_vertex_on_curve(curve: Any, u_param: float) Any[source]

Function that returns a vertex object built on the given edge object (being a circle, an arc or a segment) and placed at a position identified by the adimensional parameter u_param, which expresses the scaled position wrt the edge length.

Parameters:
  • curve (Any) – The reference edge object along which the vertex should be placed.

  • u_param (float) – Identifying the position of the vertex along the edge, expressed in the range [0-1] as it is scaled to the length of the edge.

Returns:

The vertex object positioned along the edge length.

Return type:

Any

make_vertex_on_lines_intersection(line1: Any, line2: Any) Any[source]

Function that returns a vertex object built on the intersection of the two given line objects.

Parameters:
  • line1 (Any) – The first reference line object.

  • line2 (Any) – The second reference line object.

Returns:

The vertex object being the intersection point of the two given lines.

Return type:

Any

make_wire(edges: List[Any]) Any[source]

Function that builds a wire object from the given list of connected edge objects.

Parameters:

edges (List[Any]) – The list of edge objects to build a wire from.

Returns:

A wire object build from the given edges.

Return type:

Any

remove_from_study(entry_id: str) None[source]

Function that removes the geometrical object whose ID is provided as input.

Parameters:

entry_id (str) – The ID of the geometrical object to be removed from the study.

set_color_face(face: Any, color: Tuple[int, int, int]) None[source]

Function that assigns a color to the given face object. When displayed in the 3D viewer, the face will be shown with the assigned color.

Parameters:
  • face (Any) – The face object to which a color is assigned when displayed in the 3D viewer.

  • color (Tuple[int, int, int]) – The RGB code of the color to assign to the face.

set_shape_name(shape: Any, name: str) None[source]

Function that assigns a value to the name attribute for the given shape.

Parameters:
  • shape (Any) – The geometrical shape whose name to set.

  • name (str) – The name to assign to the shape.

update_salome_study() None[source]

Function that updates the current SALOME study by updating the 3D viewer and the object browser with the shapes currently added to the study.