Geometry creation¶
- class structuralcodes.geometry.Geometry(name: str | None = None, group_label: str | None = None)[source]¶
Base class for a geometry object.
- __init__(name: str | None = None, group_label: str | None = None) None [source]¶
Initializes a geometry object.
The name and grouplabel serve for filtering in a compound object. By default it creates a new name each time.
- Parameters:
name (Optional(str)) – The name to be given to the object.
group_label (Optional(str)) – A label for grouping several objects.
- property name¶
Returns the name of the Geometry.
- property group_label¶
Returns the group_label fo the Geometry.
- class structuralcodes.geometry.PointGeometry(point: Point | ArrayLike, diameter: float, material: Material | ConstitutiveLaw, density: float | None = None, name: str | None = None, group_label: str | None = None)[source]¶
Class for a point geometry with material.
Basically it is a wrapper for shapely Point including the material (and other parameters that may be needed).
- __init__(point: Point | ArrayLike, diameter: float, material: Material | ConstitutiveLaw, density: float | None = None, name: str | None = None, group_label: str | None = None)[source]¶
Initializes a PointGeometry object.
The name and group_label serve for filtering in a compound object. By default it creates a new name each time.
- Parameters:
point (Union(Point, ArrayLike)) – A couple of coordinates or a shapely Point object.
diameter (float) – The diameter of the point.
material (Union(Material, ConstitutiveLaw)) – The material for the point (this can be a Material or a ConstitutiveLaw).
density (Optional(float)) – When a ConstitutiveLaw is passed as material, the density can be providen by this argument. When the material is a Material object the density is taken from the material.
name (Optional(str)) – The name to be given to the object.
group_label (Optional(str)) – A label for grouping several objects (default is None).
- property diameter: float¶
Returns the point diameter.
- property area: float¶
Returns the point area.
- property material: ConstitutiveLaw¶
Returns the point material.
- property density: float¶
Returns the density.
- property x: float¶
Returns the x coordinate of the point.
- property y: float¶
Returns the y coordinate of the point.
- translate(dx: float = 0.0, dy: float = 0.0) PointGeometry [source]¶
Returns a new PointGeometry that is translated by dx, dy.
- Parameters:
dx (float) – Translation in x direction.
dy (float) – Translation in y direction.
- Returns:
A new, translated point.
- Return type:
- rotate(angle: float = 0.0, point: Tuple[float, float] | Point = (0.0, 0.0), use_radians: bool = True) PointGeometry [source]¶
Returns a new PointGeometry that is rotated by angle.
- Parameters:
angle (float) – Rotation angle in radians (if use_radians = True), or degress (if use_radians = False).
point (Union(Point, Tuple(float, float))) – The origin of the rotation.
use_radians (bool) – True if angle is in radians, and False if angle is in degrees.
- static from_geometry(geo: PointGeometry, new_material: Material | ConstitutiveLaw | None = None) PointGeometry [source]¶
Create a new PointGeometry with a different material.
- Parameters:
geo (PointGeometry) – The geometry.
new_material (Optional(Union(Material, ConstitutiveLaw))) – A new material to be applied to the geometry. If new_material is None an Elastic material with same stiffness as the original material is created.
- Returns:
The new PointGeometry.
- Return type:
Note
The polygon is not copied, but just referenced in the returned PointGeometry object.
- class structuralcodes.geometry.SurfaceGeometry(poly: Polygon, material: Material | ConstitutiveLaw, density: float | None = None, concrete: bool = False)[source]¶
Class for a surface geometry with material.
Basically it is a wrapper for shapely polygon including the material (and other parameters needed). As a shapely polygon it can contain one or more holes.
- __init__(poly: Polygon, material: Material | ConstitutiveLaw, density: float | None = None, concrete: bool = False) None [source]¶
Initializes a SurfaceGeometry object.
- Parameters:
poly (shapely.Polygon) – A Shapely polygon.
material (Union(Material, ConstitutiveLaw)) – A Material or ConsitutiveLaw class applied to the geometry.
density (Optional(float)) – When a ConstitutiveLaw is passed as mat, the density can be provided by this argument. When mat is a Material object the density is taken from the material.
concrete (bool) – Flag to indicate if the geometry is concrete.
- property area: float¶
Returns the area of the geometry.
- Returns:
The area of the geometry.
- Return type:
float
- property centroid: Tuple[float, float]¶
Returns the centroid of the geometry.
- Returns:
x and y coordinates of the centroid.
- Return type:
Tuple(float, float)
- property density: float¶
Returns the density.
- calculate_extents() Tuple[float, float, float, float] [source]¶
Calculate extents of SurfaceGeometry.
Calculates the minimum and maximum x and y values.
- Returns:
Minimum and maximum x and y values (
x_min
,x_max
,y_min
,y_max
).- Return type:
Tuple(float, float, float, float)
- split(line: LineString | Tuple[Tuple[float, float], float]) Tuple[List[SurfaceGeometry], List[SurfaceGeometry]] [source]¶
Splits the geometry using a line.
- Parameters:
line (Union(LineString, Tuple(Tuple(float, float), float))) – A line either represented by a LineString shapely object, or a tuple (point, theta) where point is a coordinate pair and theta is the angle respect the horizontal axis in radians.
- Returns:
The SurfaceGeometries above and below the line.
- Return type:
Tuple(List(SurfaceGeometry), List(SurfaceGeometry))
- split_two_lines(lines: Tuple[LineString, LineString] | MultiLineString) Polygon | MultiPolygon [source]¶
Splits the geometry using two lines.
- Parameters:
lines (Union(Tuple(LineString, Linestring)), MultiLineString) – Two lines either represented by a tuple of two LineString shapely objects, or a MultiLineString shapely object.
- Returns:
The polygon or multipolygon obtained by splitting the SurfaceGeometry with the two lines.
- Return type:
Union(Polygon, Multipolygon)
- translate(dx: float = 0.0, dy: float = 0.0) SurfaceGeometry [source]¶
Returns a new SurfaceGeometry that is translated by dx, dy.
- Parameters:
dx (float) – Translation in x direction.
dy (float) – Translation in y direction.
- Returns:
The translated SurfaceGeometry.
- Return type:
- rotate(angle: float = 0.0, point: Tuple[float, float] = (0.0, 0.0), use_radians: bool = True) SurfaceGeometry [source]¶
Returns a new SurfaceGeometry that is rotated by angle.
- Parameters:
angle (float) – Rotation angle in radians (if use_radians = True), or degress (if use_radians = False).
point (Union(Point, Tuple(float, float))) – The origin of the rotation.
use_radians (bool) – True if angle is in radians, and False if angle is in degrees.
- Returns:
The rotated SurfaceGeometry.
- Return type:
- static from_geometry(geo: SurfaceGeometry, new_material: Material | ConstitutiveLaw | None = None) SurfaceGeometry [source]¶
Create a new SurfaceGeometry with a different material.
- Parameters:
geo (SurfaceGeometry) – The geometry.
new_material – (Optional(Union(Material, ConstitutiveLaw))): A new material to be applied to the geometry. If new_material is None an Elastic material with same stiffness of the original material is created.
- Returns:
The new SurfaceGeometry.
- Return type:
Note
The polygon is not copied, but just referenced in the returned SurfaceGeometry object.
- class structuralcodes.geometry.CompoundGeometry(geometries: List[Geometry] | MultiPolygon, materials: List[Material] | Material | None = None)[source]¶
Class for a compound geometry.
It is basicaly a set of geometries, each one with its own materials and properties.
- __init__(geometries: List[Geometry] | MultiPolygon, materials: List[Material] | Material | None = None) None [source]¶
Creates a compound geometry.
- Parameters:
geometries (Union(List(Geometry), MultiPolygon)) – A list of Geometry objects (i.e. PointGeometry or SurfaceGeometry) or a shapely MultiPolygon object (in this latter case also a list of materials should be given).
materials (Optional(List(Material), Material)) – A material (applied to all polygons) or a list of materials. In this case the number of polygons should match the number of materials.
- property reinforced_concrete: bool¶
Returns True if it is a Reinforced Concrete section.
- property area: float¶
Return the area of the compound geometry.
- calculate_extents() Tuple[float, float, float, float] [source]¶
Calculate extents of CompundGeometry.
Calculates the minimum and maximum x and y-values.
- Returns:
Minimum and maximum x and y values (
x_min
,x_max
,y_min
,y_max
).- Return type:
Tuple(float, float, float, float)
Note
Considers only SurfaceGeometries and not PointGeometries!
- translate(dx: float = 0.0, dy: float = 0.0) CompoundGeometry [source]¶
Returns a new CompountGeometry that is translated by dx, dy.
- Parameters:
dx (float) – Translation in x direction.
dy (float) – Translation in y direction.
- Returns:
The translated CompoundGeometry.
- Return type:
- rotate(angle: float = 0.0, point: Tuple[float, float] = (0.0, 0.0), use_radians: bool = True) CompoundGeometry [source]¶
Returns a new CompoundGeometry that is rotated by angle.
- Parameters:
angle (float) – Rotation angle in radians (if use_radians = True), or degress (if use_radians = False).
point (Union(Point, Tuple(float, float))) – The origin of the rotation.
use_radians (bool) – True if angle is in radians, and False if angle is in degrees.
- Returns:
The rotated CompoundGeometry.
- Return type:
- static from_geometry(geo: CompoundGeometry, new_material: Material | ConstitutiveLaw | None = None) CompoundGeometry [source]¶
Create a new CompoundGeometry with a different material.
- Parameters:
geo (CompoundGeometry) – The geometry.
new_material (Optional(Union(Material, ConstitutiveLaw))) – A new material to be applied to the geometry. If new_material is None an Elastic material with same stiffness of the original material is created.
- Returns:
The new CompoundGeometry.
- Return type:
- structuralcodes.geometry.create_line_point_angle(point: Point | Tuple[float, float], theta: float, bbox: Tuple[float, float, float, float]) LineString [source]¶
Creates a line from point and angle within the bounding box.
- Parameters:
point (Union(Point, Tuple(float, float))) – A Point or a coordinate the line should pass through.
theta (float) – The angle of the line in radians.
bbox (Tuple(float, float, float, float)) – Bounds for the created line.
- Returns:
The created line.
- Return type:
Functions for adding reinforcement¶
- structuralcodes.geometry.add_reinforcement(geo: SurfaceGeometry | CompoundGeometry, coords: Tuple[float, float], diameter: float, material: Material | ConstitutiveLaw, group_label: str | None = None) CompoundGeometry [source]¶
Add a single bar given coordinate.
- Parameters:
geo (Union(SurfaceGeometry, CompoundGeometry)) – A geometry to which add reinforcement.
coords (Tuple(float, float)) – A tuple with cordinates of bar.
diameter (float) – The diameter of the reinforcement.
material (Union(Material, ConstitutiveLaw)) – A material or a constitutive law for the behavior of the reinforcement.
group_label (Optional(str)) – A label for grouping several objects (default is None).
- Returns:
A compound geometry with the original geometry and the reinforcement.
- Return type:
- structuralcodes.geometry.add_reinforcement_line(geo: SurfaceGeometry | CompoundGeometry, coords_i: Tuple[float, float], coords_j: Tuple[float, float], diameter: float, material: Material | ConstitutiveLaw, n: int = 0, s: float = 0.0, first: bool = True, last: bool = True, group_label: str | None = None) CompoundGeometry [source]¶
Adds a set of bars distributed in a line.
- Parameters:
geo (Union(SurfaceGeometry, CompoundGeometry)) – The geometry used as input.
coords_i (Tuple(float, float)) – Coordinates of the initial point of line.
coords_j (Tuple(float, float)) – Coordinates of the final point of line.
diamter (float) – The diameter of the bars.
material (Union(Material, ConstitutiveLaw)) – A valid material or constitutive law.
n (int) – The number of bars to be distributed inside the line (default = 0).
s (float) – The distance between the bars (default = 0).
first (bool) – Boolean indicating if placing the first bar (default = True).
last (bool) – Boolean indicating if placing the last bar (default = True).
group_label (Optional(str)) – A label for grouping several objects (default is None).
Note
At least n or s should be greater than zero.
- Returns:
A compound geometry with the original geometry and the reinforcement.
- Return type: