Skip to content

Commit 958974b

Browse files
Clean geom docs
1 parent 187d041 commit 958974b

File tree

2 files changed

+45
-44
lines changed

2 files changed

+45
-44
lines changed

docs/source/rst/geom_mesh.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ Various limitations and assumptions need to be acknowledged:
157157

158158
See the keyword arguments below that are used to search and simplify the Rhino geometry.
159159

160-
Rhino files are read via the class methods :attr:`sectionproperties.pre.geometry.Geometry.from_3dm()` and
161-
:attr:`sectionproperties.pre.geometry.CompoundGeometry.from_3dm()`.
160+
Rhino files are read via the class methods :func:`sectionproperties.pre.geometry.Geometry.from_3dm()` and
161+
:func:`sectionproperties.pre.geometry.CompoundGeometry.from_3dm()`.
162162
Each class method returns the respective objects.
163163

164164
.. autofunction:: sectionproperties.pre.geometry.Geometry.from_3dm
@@ -173,8 +173,8 @@ Geometry objects can also be created from encodings of Rhino BREP.
173173
:noindex:
174174

175175
More advanced filtering can be achieved by working with the Shapely geometries directly.
176-
These can be accessed by :attr:`sectionproperties.pre.rhino.load_3dm()` and
177-
:attr:`sectionproperties.pre.rhino.load_rhino_brep_encoding()`.
176+
These can be accessed by :func:`~sectionproperties.pre.rhino.load_3dm()` and
177+
:func:`~sectionproperties.pre.rhino.load_rhino_brep_encoding()`.
178178

179179
.. autofunction:: sectionproperties.pre.rhino.load_3dm
180180
:noindex:
@@ -283,7 +283,7 @@ There are generally two ways to visualise geometry objects:
283283
#. In the Jupyter computing environment, geometry objects utilise their underlying
284284
``shapely.geometry.Polygon`` object's ``_repr_svg_`` method to show the geometry
285285
as it's own representation.
286-
#. By using the :attr:`~sectionproperties.pre.geometry.Geometry.plot_geometry()` method
286+
#. By using the :func:`~sectionproperties.pre.geometry.Geometry.plot_geometry()` method
287287

288288
.. automethod:: sectionproperties.pre.geometry.Geometry.plot_geometry
289289
:noindex:

sectionproperties/pre/geometry.py

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class Geometry:
3434
designating stress recovery points.
3535
3636
:cvar geom: a Polygon object that defines the geometry
37-
:vartype geom: shapely.geometry.Polygon
37+
:vartype geom: :class:`shapely.geometry.Polygon`
3838
3939
:cvar material: Optional, a Material to associate with this geometry
40-
:vartype material: Optional[sectionproperties.pre.Material]
40+
:vartype material: Optional[:class:`~sectionproperties.pre.Material`]
4141
4242
:cvar control_point: Optional, an *(x, y)* coordinate within the geometry that
4343
represents a pre-assigned control point (aka, a region identification point)
4444
to be used instead of the automatically assigned control point generated
45-
with shapely.geometry.Polygon.representative_point.
45+
with :func:`shapely.geometry.Polygon.representative_point`.
4646
4747
:cvar tol: Optional, default is 12. Number of decimal places to round the geometry vertices
4848
to. A lower value may reduce accuracy of geometry but increases precision when aligning
@@ -144,10 +144,10 @@ def from_points(
144144
being holes or voids. The point can be located anywhere within the hole region.
145145
Only one point is required per hole region.
146146
:vartype holes: list[list[float, float]]
147-
:cvar materials: Optional. A list of sectionproperties.pre.pre.Material objects that are to be
147+
:cvar materials: Optional. A list of :class:`~sectionproperties.pre.pre.Material` objects that are to be
148148
assigned, in order, to the regions defined by the given control_points. If not given, then
149-
the sectionproperties.pre.pre.DEFAULT_MATERIAL will be used for each region.
150-
:vartype materials: list[sectionproperties.pre.pre.Material]
149+
the :class:`~sectionproperties.pre.pre.DEFAULT_MATERIAL` will be used for each region.
150+
:vartype materials: list[:class:`~sectionproperties.pre.pre.Material`]
151151
"""
152152
if len(control_points) != 1:
153153
raise ValueError(
@@ -233,7 +233,7 @@ def from_3dm(cls, filepath: Union[str, pathlib.Path], **kwargs) -> Geometry:
233233
Try adjusting the keyword arguments if this error is raised.
234234
:return:
235235
A Geometry object.
236-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
236+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
237237
238238
:Keyword Arguments:
239239
* *refine_num* (``int, optional``) --
@@ -284,7 +284,7 @@ def from_rhino_encoding(cls, r3dm_brep: str, **kwargs) -> Geometry:
284284
See below.
285285
:return:
286286
A Geometry object found in the encoded string.
287-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
287+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
288288
289289
:Keyword Arguments:
290290
* *refine_num* (``int, optional``) --
@@ -348,7 +348,7 @@ def create_mesh(self, mesh_sizes: Union[float, List[float]]):
348348
349349
:return: Geometry-object with mesh data stored in .mesh attribute. Returned
350350
Geometry-object is self, not a new instance.
351-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
351+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
352352
353353
The following example creates a circular cross-section with a diameter of 50 with 64
354354
points, and generates a mesh with a maximum triangular area of 2.5::
@@ -394,7 +394,7 @@ def align_to(
394394
395395
:param other: Either another Geometry or a tuple representing an
396396
*(x,y)* coordinate point that 'self' should align to.
397-
:type other: Union[sectionproperties.pre.geometry.Geometry, Tuple[float, float]]
397+
:type other: Union[:class:`~sectionproperties.pre.geometry.Geometry`, Tuple[float, float]]
398398
399399
:param on: A str of either "left", "right", "bottom", or "top" indicating which
400400
side of 'other' that self should be aligned to.
@@ -405,7 +405,7 @@ def align_to(
405405
:type inner: bool
406406
407407
:return: Geometry object translated to alignment location
408-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
408+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
409409
"""
410410
# Mappings are for indexes in the list of bbox extents of both
411411
# 'self' and 'align_to'. i.e. a mapping of which "word" corresponds
@@ -466,10 +466,10 @@ def align_center(self, align_to: Optional[Geometry] = None):
466466
object will be aligned with it's centroid at the origin.
467467
468468
:param align_to: Another Geometry to align to or None (default is None)
469-
:type align_to: Optional[sectionproperties.pre.geometry.Geometry]
469+
:type align_to: Optional[:class:`~sectionproperties.pre.geometry.Geometry`]
470470
471471
:return: Geometry object translated to new alignment
472-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
472+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
473473
"""
474474
cx, cy = list(self.geom.centroid.coords)[0]
475475
# Suggested by Agent 6-6-6: Hard-rounding of cx and cy allows
@@ -500,7 +500,7 @@ def shift_section(
500500
:type y_offset: float
501501
502502
:return: New Geometry-object shifted by 'x_offset' and 'y_offset'
503-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
503+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
504504
"""
505505
# Move assigned control point
506506
new_ctrl_point = None
@@ -532,7 +532,7 @@ def rotate_section(
532532
:param use_radians: Boolean to indicate whether 'angle' is in degrees or radians. If True, 'angle' is interpreted as radians.
533533
534534
:return: New Geometry-object rotated by 'angle' about 'rot_point'
535-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
535+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
536536
537537
The following example rotates a 200UB25 section clockwise by 30 degrees::
538538
@@ -568,7 +568,7 @@ def mirror_section(
568568
:type mirror_point: Union[list[float, float], str]
569569
570570
:return: New Geometry-object mirrored on 'axis' about 'mirror_point'
571-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
571+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
572572
573573
The following example mirrors a 200PFC section about the y-axis and the point (0, 0)::
574574
@@ -609,8 +609,8 @@ def split_section(
609609
vector: Union[Optional[Tuple[float, float]], np.ndarray] = None,
610610
) -> Tuple[List[Geometry], List[Geometry]]:
611611
"""Splits, or bisects, the geometry about a line, as defined by two points
612-
on the line or by one point on the line and a vector. Either 'point_j' or 'vector'
613-
must be given. If 'point_j' is given, 'vector' is ignored.
612+
on the line or by one point on the line and a vector. Either ``point_j`` or ``vector``
613+
must be given. If ``point_j`` is given, ``vector`` is ignored.
614614
615615
Returns a tuple of two lists each containing new Geometry instances representing the
616616
"top" and "bottom" portions, respectively, of the bisected geometry.
@@ -686,7 +686,7 @@ def offset_perimeter(
686686
:type resolution: float
687687
688688
:return: Geometry object translated to new alignment
689-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
689+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
690690
691691
The following example erodes a 200PFC section by 2 mm::
692692
@@ -771,7 +771,7 @@ def shift_points(
771771
with the selected point(s) shifted to the new location.
772772
773773
Points are identified by their index, their relative location within the points
774-
list found in self.points. You can call self.plot_geometry(labels="points") to
774+
list found in ``self.points``. You can call ``self.plot_geometry(labels="points")`` to
775775
see a plot with the points labeled to find the appropriate point indexes.
776776
777777
:param point_idxs: An integer representing an index location or a list of integer
@@ -791,7 +791,7 @@ def shift_points(
791791
:type abs_y: Optional[float]
792792
793793
:return: Geometry object with selected points translated to the new location.
794-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
794+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
795795
796796
The following example expands the sides of a rectangle, one point at a time,
797797
to make it a square::
@@ -979,7 +979,7 @@ def calculate_centroid(self):
979979
def recovery_points(self):
980980
"""
981981
Returns four stress recovery points for the section geometry. If the Geometry instance was
982-
created by a NASTRAN geometry function, e.g. sectionproperties.pre.nastran_sections.nastran_bar(),
982+
created by a NASTRAN geometry function, e.g. :func:`~sectionproperties.pre.nastran_sections.nastran_bar()`,
983983
then the recovery points will be pre-set on the Geometry instance.
984984
"""
985985
return self._recovery_points
@@ -1100,9 +1100,10 @@ class CompoundGeometry(Geometry):
11001100
CompoundGeometry objects can be created directly between two or more Geometry
11011101
objects by using the + operator.
11021102
1103-
:cvar geoms: either a list of Geometry objects or a shapely.geometry.MultiPolygon
1103+
:cvar geoms: either a list of Geometry objects or a :class:`shapely.geometry.MultiPolygon`
11041104
instance.
1105-
:vartype geoms: Union[shapely.geometry.MultiPolygon, List[sectionproperties.pre.geometry.Geometry]]
1105+
:vartype geoms: Union[:class:`shapely.geometry.MultiPolygon`,
1106+
List[:class:`~sectionproperties.pre.geometry.Geometry`]]
11061107
"""
11071108

11081109
def __init__(self, geoms: Union[MultiPolygon, List[Geometry]]):
@@ -1135,8 +1136,8 @@ def __init__(self, geoms: Union[MultiPolygon, List[Geometry]]):
11351136
def _repr_svg_(self):
11361137
"""
11371138
Returns an svg representation of the CompoundGeometry.
1138-
Wraps shapely.geometry.MultiPolygon._repr_svg_() by returning
1139-
self.geom._repr_svg_()
1139+
Wraps :func:`shapely.geometry.MultiPolygon._repr_svg_()` by returning
1140+
``self.geom._repr_svg_()``
11401141
"""
11411142
materials_list = [geom.material.name for geom in self.geoms]
11421143
print("sectionproperties.pre.geometry.CompoundGeometry")
@@ -1178,10 +1179,10 @@ def from_points(
11781179
being holes or voids. The point can be located anywhere within the hole region.
11791180
Only one point is required per hole region.
11801181
:vartype holes: list[list[float]]
1181-
:cvar materials: Optional. A list of sectionproperties.pre.pre.Material objects that are to be
1182+
:cvar materials: Optional. A list of :class:`~sectionproperties.pre.pre.Material` objects that are to be
11821183
assigned, in order, to the regions defined by the given control_points. If not given, then
1183-
the sectionproperties.pre.pre.DEFAULT_MATERIAL will be used for each region.
1184-
:vartype materials: list[sectionproperties.pre.pre.Material]
1184+
the :class:`~sectionproperties.pre.pre.DEFAULT_MATERIAL` will be used for each region.
1185+
:vartype materials: list[:class:`~sectionproperties.pre.pre.Material`]
11851186
"""
11861187
if materials and not control_points:
11871188
raise ValueError(
@@ -1288,7 +1289,7 @@ def from_3dm(cls, filepath: Union[str, pathlib.Path], **kwargs) -> CompoundGeome
12881289
See below.
12891290
:return:
12901291
A `CompoundGeometry` object.
1291-
:rtype: :class:`sectionproperties.pre.geometry.CompoundGeometry`
1292+
:rtype: :class:`~sectionproperties.pre.geometry.CompoundGeometry`
12921293
12931294
:Keyword Arguments:
12941295
* *refine_num* (``int, optional``) --
@@ -1331,7 +1332,7 @@ def create_mesh(self, mesh_sizes: List[float]):
13311332
13321333
:return: Geometry-object with mesh data stored in .mesh attribute. Returned
13331334
Geometry-object is self, not a new instance.
1334-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
1335+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
13351336
13361337
The following example creates a circular cross-section with a diameter of 50 with 64
13371338
points, and generates a mesh with a maximum triangular area of 2.5::
@@ -1366,7 +1367,7 @@ def shift_section(self, x_offset: float = 0, y_offset: float = 0):
13661367
:type y_offset: float
13671368
13681369
:return: CompoundGeometry object shifted by 'x_offset' and 'y_offset'
1369-
:rtype: :class:`sectionproperties.pre.geometry.CompoundGeometry`
1370+
:rtype: :class:`~sectionproperties.pre.geometry.CompoundGeometry`
13701371
"""
13711372
geoms_acc = []
13721373
for geom in self.geoms:
@@ -1391,7 +1392,7 @@ def rotate_section(
13911392
:param use_radians: Boolean to indicate whether 'angle' is in degrees or radians. If True, 'angle' is interpreted as radians.
13921393
13931394
:return: CompoundGeometry object rotated by 'angle' about 'rot_point'
1394-
:rtype: :class:`sectionproperties.pre.geometry.CompoundGeometry`
1395+
:rtype: :class:`~sectionproperties.pre.geometry.CompoundGeometry`
13951396
13961397
The following example rotates a 200UB25 section with a plate clockwise by 30 degrees::
13971398
@@ -1423,7 +1424,7 @@ def mirror_section(
14231424
:type mirror_point: Union[list[float, float], str]
14241425
14251426
:return: Geometry object mirrored on 'axis' about 'mirror_point'
1426-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
1427+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
14271428
14281429
The following example mirrors a 200PFC section with a plate about the y-axis and the point (0, 0)::
14291430
@@ -1454,10 +1455,10 @@ def align_center(self, align_to: Optional[Geometry] = None):
14541455
geometry's assigned material.
14551456
14561457
:param align_to: Another Geometry to align to or None (default is None)
1457-
:type align_to: Optional[sectionproperties.pre.geometry.Geometry]
1458+
:type align_to: Optional[:class:`~sectionproperties.pre.geometry.Geometry`]
14581459
14591460
:return: Geometry object translated to new alignment
1460-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
1461+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
14611462
"""
14621463
EA_sum = sum(
14631464
[
@@ -1497,8 +1498,8 @@ def split_section(
14971498
vector: Union[Optional[Tuple[float, float]], np.ndarray] = None,
14981499
) -> Tuple[List[Geometry], List[Geometry]]:
14991500
"""Splits, or bisects, the geometry about an infinite line, as defined by two points
1500-
on the line or by one point on the line and a vector. Either 'point_j' or 'vector'
1501-
must be given. If 'point_j' is given, 'vector' is ignored.
1501+
on the line or by one point on the line and a vector. Either ``point_j`` or ``vector``
1502+
must be given. If ``point_j`` is given, ``vector`` is ignored.
15021503
15031504
Returns a tuple of two lists each containing new Geometry instances representing the
15041505
"top" and "bottom" portions, respectively, of the bisected geometry.
@@ -1554,7 +1555,7 @@ def offset_perimeter(
15541555
:param resolution: Number of segments used to approximate a quarter circle around a point
15551556
:type resolution: float
15561557
:return: Geometry object translated to new alignment
1557-
:rtype: :class:`sectionproperties.pre.geometry.Geometry`
1558+
:rtype: :class:`~sectionproperties.pre.geometry.Geometry`
15581559
15591560
The following example erodes a 200UB25 with a 12 plate stiffener section by 2 mm::
15601561

0 commit comments

Comments
 (0)