volmdlr_tools.shapes package#

Shape recognition and abstraction classes for CAD models.

Subpackages#

Submodules#

volmdlr_tools.shapes.base module#

Base classes for shape recognition and abstractions.

This module defines the base classes that all recognized shapes should inherit from, establishing a common interface for shape classification and feature extraction.

class volmdlr_tools.shapes.base.RecognizedShape(shape: Shape, aag: AttributedAdjacencyGraph, name: str = '')#

Bases: DessiaObject, ABC

Base class for all recognized shape abstractions.

A RecognizedShape represents a classified geometric shape that knows how to extract its own features based on its Attributed Adjacency Graph (AAG).

This class establishes the interface that all shape abstractions should follow: - Hold reference to the original volmdlr shape - Hold reference to the AAG for topological analysis - Implement validation logic - Implement feature extraction logic

property all_face_indices: set[int]#

The faces of the shape this reading accounts for.

A reading that accounts for every face is the whole shape; one that leaves faces out is a reading of part of it, such as the plate under a pad. Only the readings that stand for a part’s stock answer.

Returns:

The face indices the reading explains.

Raises:

NotImplementedError – For a shape type that does not say which faces it explains.

abstractmethod extract_features() → dict#

Extract all relevant features for this shape type.

This method should return a dictionary containing all the key features and parameters that characterize this shape type.

Returns:

Dictionary of features (structure depends on shape type)

get_aag() → AttributedAdjacencyGraph#

Get the AttributedAdjacencyGraph.

Returns:

The AAG used for topological analysis

get_shape() → Shape#

Get the underlying volmdlr shape.

Returns:

The original volmdlr shape

abstractmethod validate() → bool#

Validate that this shape matches expected structure.

This method should check that the classified shape has the correct topological structure for its type (e.g., sheet metal has two sides separated by thickness faces).

Returns:

True if valid, False otherwise

volmdlr_tools.shapes.sheet_metal module#

Sheet metal shape abstraction.

This module defines the SheetMetalShape class, which represents a classified sheet metal part and knows how to extract sheet-metal-specific features like thickness, sides, and contours.

class volmdlr_tools.shapes.sheet_metal.FanShapedFace(face_id: int, inner_circular_edge: Any, inner_circular_edge_index: int, outer_circular_edge: Any, outer_circular_edge_index: int, thickness_edges: list[Any], arc_center: Any, normal: Any, angle: float)#

Bases: object

Represents a fan-shaped thickness face.

A fan-shaped face is planar and has: - Two concentric circular edges (inner and outer radius) - Two straight thickness edges connecting them

can_pair_with(other: FanShapedFace, aag: AttributedAdjacencyGraph) → bool#

Check if this fan-shaped face can be paired with another.

According to Yang Yang et al., for faces fi and fj to be partners: 1. Face normals must be in opposite directions 2. Line connecting arc centers must be parallel to normals 3. Larger circular edges should be geometrically identical 4. Smaller circular edges should be geometrically identical

Parameters:
  • other – Another fan-shaped face to check pairing with

  • aag – The AttributedAdjacencyGraph for accessing face data

Returns:

True if faces can be paired

get_skin(aag: AttributedAdjacencyGraph) → FoldSkin#

Get the skin faces across the outer and the inner circular edges of this face.

Parameters:

aag – AttributedAdjacencyGraph containing the face.

Returns:

The face IDs of the outside and the inside of the fold this face ends.

Raises:

UnsupportedSheetMetalError – If no face lies across one of the circular edges.

opposite_normal(other: FanShapedFace) → bool#

Verify that two faces have the same but opposite normal vector.

Parameters:

other – other FanShapedFace.

Returns:

True if normals are opposite, False otherwise.

share_common_face(other: FanShapedFace, aag: AttributedAdjacencyGraph) → bool#

Verify that two faces have the same common face.

Parameters:
  • other – other FanShapedFace.

  • aag – AttributedAdjacencyGraph containing corresponding faces.

Returns:

True if common face was found, False otherwise.

class volmdlr_tools.shapes.sheet_metal.Flange(faces: frozenset[int], folds: tuple[frozenset[int], ...])#

Bases: object

A stretch of one side of the sheet between folds.

Parameters:
  • faces – Its skin faces on that side.

  • folds – Every fold it borders, each as that fold’s skin faces on the same side.

faces: frozenset[int]#
folds: tuple[frozenset[int], ...]#
class volmdlr_tools.shapes.sheet_metal.FoldFlanges(faces: frozenset[int], flanges: tuple[Flange, ...])#

Bases: object

One fold of the sheet, on one side, and the flanges it borders.

Parameters:
  • faces – The fold’s skin faces on that side.

  • flanges – The flanges the fold borders.

property ends_the_sheet: bool#

Whether the sheet ends on the fold: it borders a single flange.

faces: frozenset[int]#
flanges: tuple[Flange, ...]#
property free_flanges: tuple[Flange, ...]#

Get the flanges the fold borders that run out to the sheet’s edge without meeting another fold.

property has_a_free_flange: bool#

Whether a flange the fold borders runs out to the sheet’s edge without meeting another fold.

class volmdlr_tools.shapes.sheet_metal.FoldSkin(outside: int, inside: int)#

Bases: NamedTuple

The two skin faces that run along a fold, across the circular edges of one fan-shaped face.

The skin of a fold is what it shows on each side of the sheet: the face around its outer radius and the face around its inner radius.

inside: int#

Alias for field number 1

outside: int#

Alias for field number 0

class volmdlr_tools.shapes.sheet_metal.SheetMetalShape(shape: Shape, aag: AttributedAdjacencyGraph, main_face_group_1: list[int], main_face_group_2: list[int], thickness_faces: list[int], thickness_components: list[set[int]] | list[ThicknessFaceChain], seed_face_id: int, opposite_face_id: int, name: str = '')#

Bases: RecognizedShape

Sheet metal shape abstraction.

Represents a classified sheet metal part and knows how to extract sheet-metal-specific features like thickness, sides, and contours.

This class is the result of SheetMetalRecognizer.recognize() and contains all the information needed to query features and parameters of the sheet metal.

MAXIMUM_GUSSET_REGION_FACES: int = 100#

A region bridging a gap of a fold line is a gusset’s skin only when it has no more faces than this.

property boundary_chain: ThicknessFaceChain#

Get the boundary thickness face chain object.

Returns the ThicknessFaceChain classified as boundary based on range values.

Returns:

Boundary ThicknessFaceChain or None if not found.

extract_features() → dict#

Extract all sheet metal features at once.

Returns:

Dictionary containing all extracted features

get_boundary_thickness_shell() → Shell | None#

Get boundary thickness facecc chain as a single Shell.

Creates a shell from all boundary thickness faces (outer boundary faces). Uses the cached boundary_thickness_face_chain property.

Returns:

Shell containing all boundary thickness faces, or None if creation fails

get_fold_faces(side: Literal[1, 2] | None = None) → set[int]#

Get the skin faces that run along a fold of the sheet.

Parameters:

side – Number of the side whose fold faces are wanted, numbered in that side’s graph; None for both sides, numbered in the graph of the whole part.

Returns:

The face IDs of the skin of every fold: those get_fold_skins() finds from fan-shaped faces, and the faces of every fold line of get_fold_lines(), whether a fan-shaped face ends it or not.

get_fold_flanges() → list[FoldFlanges]#

Get every fold of the sheet, side by side, with the flanges it borders.

On each side, the fold faces of get_fold_faces() that touch one another, or lie on one fold line, make one fold, and what is left of the side once every fold, and whatever bridges the gaps between the pieces of a fold line (see _read_line_gaps()), is taken away falls into flanges. A gusset joins the two flanges of its fold, so it is a border between them, like the fold, and in no flange; so is every other bridge, read as no gusset because it is too large, bridges one side only or does not lie in its gap, so that a fold the sheet goes on past never reads as one it ends on. A flange holds whatever else is on it — a deformation, a round that folds nothing — and knows every fold it borders, so whether the sheet goes on past a fold, and whether it folds again, is read from here.

Returns:

One entry per fold per side, side 1 first.

get_fold_lines() → list[CoaxialBends]#

Get the fold lines of the sheet: the coaxial bends it keeps as folds, fan-shaped ends or not.

Coaxial bends are the cylinders of a fold, one on each side of the sheet, with the other pieces of the same cylinders that join the same two plates (see CoaxialBends). The fold lines are those the sheet keeps as folds (see _kept_fold_lines()): a bend that gussets cut into pieces is one fold line of several pieces.

Returns:

Each fold line, its faces numbered in the graph of the whole part.

get_fold_skins() → dict[int, FoldSkin]#

Get the skin of every fold of the sheet that a fan-shaped face ends, keyed by that face.

A fold is a bend, a hem or a curl. Wherever one reaches an edge of the sheet, that edge shows a fan-shaped thickness face, and the faces across its two circular edges are the skin of the fold: its outside and its inside. A deformation running off the sheet edge shows one across its own rounds, so a fold counts only when one of these holds:

  • taking its skin away splits a side of the sheet into flanges;

  • it runs right across the sheet, ended by a fan-shaped face at both ends, as a curl rolled at the edge of the sheet, with no flange beyond it, does;

  • it lies on a fold line (see get_fold_lines()).

A fold that reaches no edge of the sheet shows no fan-shaped face, and is not here: a tray’s bend ending in corner reliefs, a bend drawn in one piece with its ends, or the middle piece of a bend between two gussets. Those are found from their cylinders, by get_fold_lines().

A fold ended at both edges of the sheet has one entry per end, both with the same skin when each side of the fold is a single face.

Returns:

The skin of each fold a fan-shaped face ends, keyed by the ID of that face.

Raises:

UnsupportedSheetMetalError – If a fan-shaped face has no face across a circular edge.

get_gusset_faces(side: Literal[1, 2] | None = None) → set[int]#

Get the faces of every gusset of the sheet (see get_gusset_skins()).

Parameters:

side – Number of the side whose gusset faces are wanted, numbered in that side’s graph; None for both sides, numbered in the graph of the whole part.

Returns:

The face IDs.

get_gusset_skins() → list[frozenset[int]]#

Get the skin of every gusset pressed across a fold of the sheet.

A gusset is a rib pressed across a fold from one plate into the other, to stiffen it. It cuts the fold’s cylinders into pieces that touch nowhere, still one fold line (see get_fold_lines()). Between two neighbouring pieces of a line, on each side of the sheet, the gap may hold regions that lie between the line’s two plates, touch both pieces and both plates, and lie along the axis in that gap (see _read_line_gaps()). A gap holds a gusset when it holds such regions on both sides of the sheet and none has more than MAXIMUM_GUSSET_REGION_FACES faces; the gusset’s skin is those regions, on both sides. A gap that holds no gusset still parts the flanges of its fold (see get_fold_flanges()), and its regions are left to the deformation extractors: the region-based one reads a rib too large to be a gusset as an Emboss straddling the bend, and the wire-seeded one reads nothing there.

Returns:

The faces of each gusset, on both sides, numbered in the graph of the whole part.

get_internal_thickness_shells() → list[Shell]#

Get internal thickness faces as a list of Shells.

Creates a shell for each connected component of internal thickness faces (faces around holes, cutouts, and other internal features). Uses the cached internal_thickness_faces property.

Returns:

List of shells, one for each internal thickness component

get_plates_and_bends() → PlatesAndBends#

Read the flat plates and the cylindrical bends of the sheet, pairing each face of one side with its partner.

A plate is planar faces of side 1 with their partners one thickness behind on side 2; a bend is a cylinder of each side about one axis. Faces of the sides that pair with nothing, such as those of a dimple or of a free-form panel, are in neither.

Returns:

The thickness the plates and bends agree on, the plates, and the bends with the plates each meets.

get_side_1_aag() → AttributedAdjacencyGraph | None#

Create AAG for side 1 from its shell.

Returns:

AttributedAdjacencyGraph for side 1, or None if creation fails

get_side_1_areas() → dict[int, float]#

Get areas for all faces in side 1.

Returns:

Dictionary mapping face IDs to their areas

get_side_1_contours() → dict#

Get contours for side 1.

Uses cached contours if available, otherwise computes and caches them.

Returns:

Dictionary containing outer and inner contours

get_side_1_shell() → Shell | None#

Get side 1 as a Shell.

Returns:

Shell containing all faces from side 1, or None if creation fails

get_side_1_total_area() → float#

Get total area of side 1.

Sums the areas of all faces in side 1.

Returns:

Total area of side 1

Return type:

float

get_side_2_aag() → AttributedAdjacencyGraph | None#

Create AAG for side 2 from its shell.

Returns:

AttributedAdjacencyGraph for side 2, or None if creation fails

get_side_2_areas() → dict[int, float]#

Get areas for all faces in side 2.

Returns:

Dictionary mapping face IDs to their areas

get_side_2_contours() → dict#

Get contours for side 2.

Uses cached contours if available, otherwise computes and caches them.

Returns:

Dictionary containing outer and inner contours

get_side_2_shell() → Shell | None#

Get side 2 as a Shell.

Returns:

Shell containing all faces from side 2, or None if creation fails

get_side_2_total_area() → float#

Get total area of side 2.

Sums the areas of all faces in side 2.

Returns:

Total area of side 2

Return type:

float

get_side_aag(side: Literal[1, 2]) → AttributedAdjacencyGraph | None#

Get the graph of one side of the sheet: its skin faces alone.

Parameters:

side – 1 or 2.

Returns:

The graph of that side, as get_side_1_aag() or get_side_2_aag() gives it.

Raises:

ValueError – If side is neither 1 nor 2.

get_thickness() → float | None#

Calculate sheet metal thickness.

The rigorous method identifies boundary thickness faces (those connected to the outer contour) and measures the length of edges shared between them, which represents the actual sheet metal thickness. Falls back to seed-opposite distance if needed.

Returns:

Thickness value or None if calculation fails

get_thickness_aag() → AttributedAdjacencyGraph | None#

Create AAG for thickness faces.

Returns:

AttributedAdjacencyGraph for thickness faces, or None if creation fails

get_thickness_faces_areas() → dict[int, float]#

Get areas for all thickness faces.

Returns:

Dictionary mapping face IDs to their areas

get_thickness_faces_compound() → Compound | None#

Get thickness faces as a Compound of shells.

Creates a compound containing the boundary thickness shell and all internal thickness shells.

Returns:

Compound of shells, or None if creation fails

property internal_chains: list[ThicknessFaceChain]#

Get all internal thickness face chain objects.

Returns list of ThicknessFaceChain objects classified as internal based on range values.

Returns:

List of internal ThicknessFaceChain objects

property main_faces: list[int]#

Get all main face IDs from both sides.

Combines face IDs from main_face_group_1 and main_face_group_2.

Returns:

List of all main face IDs

Return type:

list[int]

property outer_contour_faces: frozenset[int]#

Get the thickness faces round the outer edge of the sheet.

The walls of a cut inside the sheet are not among them.

Returns:

The face IDs of the boundary thickness face chain, numbered in the graph of the whole part; empty when the sheet has no thickness face.

static sheet_metal_structure_refusal(aag: AttributedAdjacencyGraph, thickness_faces: list[int], main_faces: list[int]) → str | None#

Say why faces split into sides and walls do not make a sheet, if they do not.

Parameters:
  • aag – The attributed adjacency graph

  • thickness_faces – List of thickness face IDs

  • main_faces – List of main face IDs

Returns:

What keeps them from being the two sides of a sheet and the walls between them, or None if nothing

side_of(node: int) → Literal[1, 2] | None#

Tell which side of the sheet a face lies on.

Parameters:

node – A face ID in the graph of the whole part.

Returns:

1 or 2 for a skin face, None for a thickness face.

Raises:

ValueError – If the part has no face node.

property sides: tuple[frozenset[int], frozenset[int]]#

Get the skin faces of each side of the sheet.

Returns:

The face IDs of side 1, then of side 2, numbered in the graph of the whole part.

property skin_faces: frozenset[int]#

Get the skin faces of both sides of the sheet.

Returns:

The face IDs of both sides, numbered in the graph of the whole part.

to_part_node(side: Literal[1, 2], side_node: int) → int#

Find a face of the graph of one side in the graph of the whole part.

Parameters:
  • side – 1 or 2.

  • side_node – The face ID in the graph of that side (see get_side_aag()).

Returns:

The ID of the same face in the graph of the whole part.

Raises:

ValueError – If that face is not a skin face of the part on that side.

to_side_node(side: Literal[1, 2], node: int) → int#

Find a skin face of the part in the graph of its side.

Parameters:
  • side – 1 or 2.

  • node – The face ID in the graph of the whole part.

Returns:

The ID of the same face in the graph of that side (see get_side_aag()).

Raises:

ValueError – If the face is not a skin face of that side, or is missing from its graph.

validate() → bool#

Validate sheet metal structure.

Checks that removing thickness faces creates exactly two connected components (the two main sides).

Returns:

True if valid sheet metal structure, False otherwise

static validate_sheet_metal_structure(aag: AttributedAdjacencyGraph, thickness_faces: list[int], main_faces: list[int]) → bool#

Validate sheet metal structure (static validation logic).

Checks that removing thickness faces creates exactly two connected components (the two main sides).

Parameters:
  • aag – The attributed adjacency graph

  • thickness_faces – List of thickness face IDs

  • main_faces – List of main face IDs

Returns:

True if valid sheet metal structure, False otherwise

class volmdlr_tools.shapes.sheet_metal.TFCGroup(thickness_face_chains: list[ThicknessFaceChain], name: str = '')#

Bases: DessiaObject

Group of ThicknessFaceChain objects for feature analysis.

A TFCGroup represents a collection of ThicknessFaceChain objects that are grouped together for feature recognition and property extraction. This class provides methods to aggregate fan-shaped faces, count parallel planar pairs, and extract properties for matching against feature classification rules (cut features, composite features, etc.).

extract_composite_feature_properties() → dict[str, Any]#

Extract properties for matching against composite feature rules.

Properties correspond to Table 2 from Yang Yang et al. (2021): - internal_chains: Number of internal thickness face chains - boundary_subchains: Number of boundary sub-chains - fan_shaped_faces: Number of fan-shaped faces - fan_shaped_pairs: Number of fan-shaped face pairs - share_common_face: Do fan-shaped pairs share a common face? - opposite_normals: Are normals in opposite directions? - d1_greater_d2: Is flat part width > deformed part width?

Returns:

Dictionary of properties

Return type:

dict[str, Any]

extract_cut_feature_properties() → dict[str, Any]#

Extract properties for matching against cut feature rules.

Properties correspond to Table 1 from Yang Yang et al. (2021): - type_of_chain: “Closed” or “Open” - total_faces: Total number of faces in chain - cylindrical_surfaces: Count of cylindrical faces - different_radius_values: Number of distinct radii in cylindrical faces - planar_surfaces: Count of planar faces - parallel_planar_pairs: Number of parallel planar face pairs

Returns:

Dictionary of properties

Return type:

dict

get_fan_shaped_faces() → list[FanShapedFace]#

Get all fan-shaped faces from all thickness face chains in the group.

Aggregates fan-shaped faces from each ThicknessFaceChain in the group.

Returns:

List of all FanShapedFace objects from all chains

Return type:

list[FanShapedFace]

get_fan_shaped_pairs() → list[tuple[FanShapedFace, FanShapedFace]]#

Get all fan-shaped face pairs from the group.

If the group contains only one ThicknessFaceChain, returns pairs from that chain. Otherwise, aggregates all fan-shaped faces from all chains and pairs them according to the pairing criteria (opposite normals, common face, etc.).

Returns:

List of tuples containing paired FanShapedFace objects

Return type:

list[tuple[FanShapedFace, FanShapedFace]]

property parallel_count: tuple[int, set[float]]#

Get the count of parallel planar pairs and their distances.

Returns a tuple containing: - The number of parallel planar face pairs - A set of distances between parallel pairs

Returns:

Tuple of (pair_count, distances_set)

Return type:

tuple[int, set[float]]

class volmdlr_tools.shapes.sheet_metal.ThicknessFaceChain(face_ids: list[int], aag: AttributedAdjacencyGraph, is_closed: bool | None = True, is_internal_chain: bool | None = False, cut_into_edge: bool = False, fold_directions: int = 0, mouth: tuple[Point3D, Point3D] | None = None, name: str | None = None)#

Bases: DessiaObject

Base class representing a chain of thickness faces.

A thickness face chain is a group of connected thickness faces. According to Yang Yang et al. (2021), thickness face chains are the fundamental building blocks for sheet metal feature recognition.

property adjacency_map: dict[int, list[int]]#

Get adjacency relationships between faces in the chain.

Returns:

Dictionary mapping face_id -> list of adjacent face_ids in chain

all_angles_concave() → bool#

Check if all angles between consecutive faces are concave.

Returns:

True if all angles are concave

Return type:

bool

all_angles_convex() → bool#

Check if all angles between consecutive faces are convex.

Returns:

True if all angles are convex

Return type:

bool

property angles: dict#

Extract angle data between consecutive faces.

Returns:

Dictionary mapping (face_id1, face_id2) -> angle data

Return type:

dict

binary_pattern_contains(pattern: list[int]) → bool#

Check if binary pattern contains the given pattern as a subsequence.

Parameters:

pattern (list[int]) – Pattern to find (e.g., [0, 1])

Returns:

True if pattern is found

Return type:

bool

static extract_deform_feature_properties(termination_criterion: int, inner_loop_shape: str) → dict#

Extract properties for matching against deform feature rules.

Properties correspond to Table 3 from Yang Yang et al. (2021): - has_interconnected_faces: Are faces interconnected? - termination_criterion: Which criterion terminated extraction (1 or 2) - inner_loop_shape: Shape of the inner loop (e.g., “Circular”, “Rectangular”)

Parameters:
  • termination_criterion (int) – Termination criterion used (1 or 2)

  • inner_loop_shape (str) – Shape of the inner loop

Returns:

Dictionary of properties

Return type:

dict

extract_fsf_subchains() → list[ThicknessFaceChain]#

Extract feature sub-chains running between paired fan-shaped faces.

The fan-shaped faces are read in chain order, each one either the starting face of a pair or the partner closing it. A sub-chain runs from a starting face to its own partner. Pairs nest like brackets, so a sub-chain is an outermost pair with every pair it encloses (see outermost_pair_spans()): on a b c c' d d' b' a' that is the whole run, not the stretch a b c c', whose ends belong to different pairs.

Returns:

One sub-chain per outermost pair, holding every face (fan-shaped or not) from its starting face to its partner

Return type:

list[ThicknessFaceChain]

property fan_shaped_faces_paths: dict[tuple[int, int], tuple[list[int], list[int]]]#

Get the fan-shaped faces paths dictionary.

Returns a copy of the paths dictionary to prevent external modification.

Returns:

Dictionary mapping face ID tuples to path tuples (shortest_path, longest_path)

Return type:

dict[tuple[int, int], tuple[list[int], list[int]]]

property fsf_binary_representation: list[list[int]]#

Generate binary representation matrices for fan shaped faces.

According to Yang Yang et al., the algorithm: 1. For each fan-shaped pair, find faces between them in both directions 2. Keep the shorter list for each pair 3. Select the longest of these shorter lists (ensures not starting in middle) 4. Create second list from remaining faces by traversing in opposite direction 5. Assign binary values: 0 for starting face, 1 for partner face

The binary patterns are used to classify bend/jog/lance features. Example patterns from paper (Fig. 6): - Matrix 1: [0 0 0 1 1 1 1] (contains pairs 1, 2, 3, 4) - Matrix 2: [0 0 1 1 0 1] (contains remaining pairs)

Returns:

List of binary matrices (typically 2, one for each direction)

get_concave_subchains() → list[ThicknessFaceChain]#

Extract sub-chains with concave angles using the concavity method.

According to Yang Yang et al. (Section 3.2.2), concave angles indicate features like slots, notches, and corner reliefs. This method identifies consecutive faces connected by concave angles.

Returns:

List of ThicknessFaceChain sub-chains with concave angles

Return type:

list[ThicknessFaceChain]

get_convex_subchains() → list[list[int]]#

Extract clip sub-chains using the convexity method.

Example from paper:

fi – fj – fk Where fj is a clip if both angles (fi-fj and fj-fk) are convex and within the range (π/2, π).

Returns:

List of clip sub-chains, where each sub-chain contains a single face ID

Return type:

list[list[int]]

get_fan_shaped_faces() → list[FanShapedFace]#

Identify all fan-shaped faces in the chain.

According to Yang Yang et al., a fan-shaped thickness face: - Must be planar - Must have two concentric circular edges - Must have two thickness edges - Solid angles between edges must be < 180°

Returns:

List of FanShapedFace objects

get_fan_shaped_faces_path(key: tuple[int, int]) → tuple[list[int], list[int]]#

Get the fan-shaped faces path for a given key, in either direction.

A path between two fan-shaped faces is the same walk read from either end, but it is stored under one of the two orderings (verify_fan_shaped_pair_order() decides which) while callers derive their key from a chain traversal that has its own direction. So the reversed key is looked up as well, and its paths come back reversed — without that, a part whose two orders disagree raises KeyError out of the middle of extraction and yields no bends at all.

Parameters:

key (tuple[int, int]) – Tuple of (start_face_id, end_face_id) identifying the path

Returns:

Tuple containing (shortest_path, longest_path) as lists of face IDs

Return type:

tuple[list]

Raises:

KeyError – If no path exists for the given key in either direction

get_fan_shaped_pairs(max_angle: float = 3.141592653589793) → list[tuple[FanShapedFace, FanShapedFace]]#

Identify pairs of fan-shaped faces.

According to Yang Yang et al., fan-shaped faces form pairs that represent bend features. The pairing algorithm checks: 1. Normals in opposite directions 2. Arc centers connected by line parallel to normals 3. Circular edges are geometrically identical

Pairs set with set_fan_shaped_pairs() are final, an empty list included: a chain cut short of a pair’s partner pairs nothing anew.

Returns:

List of (face1, face2) pairs

get_main_fan_shaped_pair_lists() → tuple[list[int], list[int]]#

Get the two main lists of fan-shaped faces for binary representation.

According to Yang Yang et al.: 1. For each pair, find the shorter path between them 2. Select the longest of these shorter paths (ensures not starting in middle) 3. Create second list from remaining faces in opposite direction

Returns:

Tuple of (first_list, second_list) of face IDs

get_range_values() → tuple[float, float, float]#

Calculate range values for the chain.

Returns (X_range, Y_range, Z_range) where: X_range = X_max - X_min for all faces in chain

Used to classify boundary vs internal chains.

Returns:

Tuple of (x_range, y_range, z_range)

has_binary_pattern(pattern: list[int]) → bool#

Check if binary pattern matches exactly.

Parameters:

pattern (list[int]) – Pattern to match (e.g., [0, 1] for bend)

Returns:

True if pattern matches

Return type:

bool

is_open_ended() → bool#

Check if chain is open (not closed).

Returns:

True if open

Return type:

bool

is_single_face() → bool#

Check if chain contains only a single face.

Returns:

True if only one face

Return type:

bool

is_small(max_faces: int = 3) → bool#

Check if chain is small (few faces).

Parameters:

max_faces (int) – Maximum number of faces to be considered small

Returns:

True if face count <= max_faces

Return type:

bool

neighbor_along_chain(face_id: int, step: int) → int | None#

Return the face step places away from face_id along the chain.

A closed chain wraps around; an open chain has no face beyond its ends.

Parameters:
  • face_id – Face of the chain to start from.

  • step – Signed number of places to move along the chain.

Returns:

The face found there, or None past the end of an open chain.

open_subchain(face_ids: list[int], name: str, cut_into_edge: bool = False, fold_directions: int = 0, mouth: tuple[Point3D, Point3D] | None = None) → ThicknessFaceChain#

Return an open chain of some faces of this one, inside the sheet or on its outer contour as this one is.

Parameters:
  • face_ids – The faces, consecutive along this chain; the new chain orders them itself.

  • name – What the faces are, as a repr or a debugger shows it.

  • cut_into_edge – Whether the faces are a cut into the outer edge of the sheet.

  • fold_directions – For a cut into the edge, how many bends it sits at the end of.

  • mouth – For a cut into the edge, a point at each end of its mouth.

Returns:

The open chain.

set_fan_shaped_faces(faces: list[FanShapedFace]) → None#

Set the fan-shaped faces for this chain.

Parameters:

faces (list[FanShapedFace]) – List of FanShapedFace objects

Returns:

None

Return type:

None

set_fan_shaped_faces_path(key: tuple[int, int], value: tuple[list[int], list[int]]) → None#

Set the fan-shaped faces path for a given key.

Parameters:
  • key (tuple[int, int]) – Tuple of (start_face_id, end_face_id) identifying the path

  • value (tuple[list[int], list[int]]) – Tuple containing (shortest_path, longest_path) as lists of face IDs

Returns:

None

Return type:

None

set_fan_shaped_pairs(face_pairs: list[tuple[FanShapedFace, FanShapedFace]]) → None#

Set the fan-shaped face pairs for this chain.

Parameters:

face_pairs (list[tuple[FanShapedFace, FanShapedFace]]) – List of tuples containing paired FanShapedFace objects

Returns:

None

Return type:

None

property thickness: float | None#

Get thickness value for validating fan-shaped faces.

Calculates thickness by finding the length of common edges between neighboring faces in the chain. Returns the first non-zero edge length found.

Returns:

Thickness value or None if calculation fails

Return type:

Optional[float]

property thickness_shell: Shell#

Get the thickness shell for this chain.

Creates a Shell object from all faces in the chain. Caches the result for subsequent calls.

Returns:

Shell containing all faces in the chain

Return type:

shapes.Shell

verify_fan_shaped_pair_order(face1: FanShapedFace, face2: FanShapedFace) → tuple[FanShapedFace, FanShapedFace]#

Verify and correct the order of fan-shaped face pairs.

Computes paths between the two faces and ensures they are ordered correctly based on their position in the chain. Stores the paths for later use.

Parameters:
Returns:

Tuple of (ordered_face1, ordered_face2)

Return type:

tuple[FanShapedFace, FanShapedFace]

Raises:

UnsupportedSheetMetalError – If the chain is not a single loop of faces, so that the two faces are not joined by exactly two routes around it.

without_ends(faces: Collection[int]) → ThicknessFaceChain | None#

Return this sub-chain between paired fan-shaped faces without the given faces where they lie at its ends.

The rest keeps the fan-shaped faces it still holds, the pairs among them and the paths between them, read round the same loop as this sub-chain’s (see extract_fsf_subchains()).

Parameters:

faces – Faces to leave out, such as those a cut into the edge holds.

Returns:

This sub-chain when neither of its ends is among the faces; the rest of it when that still pairs two fan-shaped faces; None when it pairs none.

volmdlr_tools.shapes.sheet_metal.are_faces_parallel(face1: Face, face2: Face, tolerance: float = 1e-06) → bool#

Check if two faces are parallel.

Two faces are considered parallel if the vector connecting their centers is parallel to the normal of the first face (i.e., the dot product is approximately ±1).

Parameters:
  • face1 – First face to check

  • face2 – Second face to check

  • tolerance – Tolerance for parallel checks

Returns:

True if faces are parallel, False otherwise

Return type:

bool

volmdlr_tools.shapes.sheet_metal.get_face_normal(face: Shape) → Vector3D#

Extract normal vector from a planar face.

Parameters:

face – Face object to extract normal from

Returns:

Normal vector as tuple (x, y, z) or None if extraction fails

Return type:

Optional[tuple[float, float, float]]

volmdlr_tools.shapes.sheet_metal.hollows_into_material(aag: AttributedAdjacencyGraph, node: int) → bool#

Whether a face is a round wall curving away from the material: a wall hollowed out of the sheet.

Parameters:
  • aag – The graph the face belongs to.

  • node – The face.

Returns:

True for the wall of a round bite or a round hole.

volmdlr_tools.shapes.sheet_metal.is_free_form(aag: AttributedAdjacencyGraph, node: int) → bool#

Whether a face lies on a surface that is none of the plane, cylinder, cone, sphere and torus.

Parameters:
  • aag – The graph the face belongs to.

  • node – The face.

Returns:

True for a B-spline face and the like, whose walls an exporter may write for what is a round or a straight cut.

volmdlr_tools.shapes.sheet_metal.order_nodes_by_graph(nodes: list[int], subgraph: Graph) → list[int]#

Orders a list of nodes according to their connectivity in the graph.

Works for both open paths and closed cycles.

Parameters:
  • nodes (list) – List of nodes to order

  • subgraph (networkx.Graph) – The graph containing the nodes

Returns:

Ordered list of nodes following the graph structure

Return type:

list

volmdlr_tools.shapes.sheet_metal.outermost_pair_spans(face_ids: list[int], partner: dict[int, int]) → list[tuple[int, int]]#

Split a run of paired faces into its outermost pairs, nested pairs kept inside them.

Fan-shaped faces met along a thickness chain nest like brackets: a bend that encloses two sibling bends reads a ( b c ) ( d e ) a'. Each outermost pair opens on one face and closes on its own partner, so every span returned starts and ends on two partners. A face whose partner is absent from the run, or comes before it, opens nothing.

Parameters:
  • face_ids – Paired face ids in chain order.

  • partner – Partner of each paired face, in both directions.

Returns:

(start, end) positions in face_ids of each outermost pair, in order.

volmdlr_tools.shapes.sheet_metal.rounds_off_a_corner(aag: AttributedAdjacencyGraph, node: int) → bool#

Whether a face is a round wall bulging out of the material and turning through less than half a turn.

That is how a rounded corner of an outline looks, whether its wall is a cylinder or a free-form surface. A tab with a fully rounded end turns through half a turn, and is no corner.

Parameters:
  • aag – The graph the face belongs to.

  • node – The face.

Returns:

True for a rounded corner.

volmdlr_tools.shapes.bearing module#

Module dedicated to identifying bearings within an assembly.

class volmdlr_tools.shapes.bearing.Bearing(primitives: list[Shape], graph_assembly_repeating_elements_ids: list[int], graph_assembly_rings_ids: list[int], name: str = '')#

Bases: Compound

Bearing class.

class volmdlr_tools.shapes.bearing.BearingFinder(graph_assembly: GraphAssembly)#

Bases: object

Class to identify bearings within an assembly graph.

find_bearings(number_elements_define_bearing: int = 5) → list[list[int]]#

Find all bearings in the assembly.

Returns:

list[list[str]]: List of bearing groups, where each group contains node IDs

of components that form a bearing.

volmdlr_tools.shapes.gear module#

Gear shape definition.

A gear is a ring of identical teeth around an axis, carried by a body. The teeth are described by the parameters a gear is specified with (tooth count, module, pressure angle, tip and root circles, face width, helix) plus the tooth blends, and the body by its own recognised shape.

class volmdlr_tools.shapes.gear.GearShape(shape: Shape, aag: AttributedAdjacencyGraph, axis_origin: Point3D, axis_direction: Vector3D, tooth_count: int, module: float, pressure_angle: float, tip_radius: float, root_radius: float, face_width: float, internal: bool, helix_angle: float, phase: float, root_fillet: float | None, tip_round: float | None, tip_chamfers: tuple[ToothChamfer, ...], measured_pressure_angle: float, tooth_face_ids: tuple[int, ...], body_face_ids: tuple[int, ...], body: RecognizedShape | None = None, name: str = '')#

Bases: RecognizedShape

A recognised gear: a ring of identical involute teeth about an axis, and the body carrying them.

Lengths are in the part’s units and angles in degrees. Angles about the axis are measured from the reference direction reference_direction() gives, positive by the right hand about the axis direction.

Parameters:
  • shape – The part.

  • aag – The adjacency graph of the part.

  • axis_origin – The point of the axis level with the end of the teeth the axis direction leaves from.

  • axis_direction – The unit axis direction.

  • tooth_count – The number of teeth.

  • module – The pitch diameter divided by the tooth count.

  • pressure_angle – The angle of the flanks to the radius at the pitch circle.

  • tip_radius – The radius of the tip circle, inside the root circle for an internal gear.

  • root_radius – The radius of the root circle.

  • face_width – The length of the teeth along the axis.

  • internal – Whether the teeth point at the axis.

  • helix_angle – The angle of the teeth to the axis at the pitch circle; positive when a tooth turns positively about the axis as it runs along the axis direction.

  • phase – The angle of the tooth centre nearest the reference direction at the start of the face width, in degrees: within half a tooth spacing either side of it.

  • root_fillet – The radius of the blend between flank and root, None when there is none.

  • tip_round – The radius of the blend between flank and tip, None when there is none.

  • tip_chamfers – The chamfers on the tips at either end.

  • measured_pressure_angle – The pressure angle the flanks show at the pitch circle, before it is rounded to a standard value.

  • tooth_face_ids – The faces of the teeth.

  • body_face_ids – The other faces, in the order the body’s own graph numbers them.

  • body – The recognised body, None when the body is not recognised.

  • name – Optional name.

property addendum: float#

Return the tooth height from the pitch circle to the tip circle.

property base_radius: float#

Return the radius of the base circle of the flanks.

property dedendum: float#

Return the tooth depth from the pitch circle to the root circle.

extract_features() → dict#

Return the gear’s parameters.

Returns:

A dictionary of the parameters, the body under "body".

property hand: Literal['right', 'left'] | None#

Return the hand of the helix, None for straight teeth.

property pitch_radius: float#

Return the radius of the pitch circle.

property reference_direction: Vector3D#

Return the direction square to the axis from which angles about it are measured.

teeth_code(length_scale: float = 1000.0, *, tip_fillet: bool = False) → str#

Return code that builds the teeth with a gear library, placed as in the part.

The code binds teeth: the gear for an external gear, and the toothed band between the tip and root circles for an internal one. Blends, chamfers and helices the code does not build are written as comments.

Parameters:
  • length_scale – The factor turning the part’s lengths into the code’s; the default turns metres into millimetres.

  • tip_fillet – Whether the tooth tips are rounded by the code; without it the blend on the tips is written as a comment.

Returns:

Python source.

validate() → bool#

Check that the parameters describe a gear.

Returns:

True when there are teeth, the tip and root circles are on the right sides of each other and the teeth have a width.

class volmdlr_tools.shapes.gear.ToothChamfer(end: Literal['start', 'end'], length: float, depth: float)#

Bases: object

A chamfer on the tips of the teeth at one end of the face width.

Parameters:
  • end – "start" at the end the axis direction leaves from, "end" at the other.

  • length – How far the chamfer runs along the axis.

  • depth – How far it cuts into the tips, radially.

property angle: float#

Return the chamfer’s angle to the axis, in degrees.

depth: float#
end: Literal['start', 'end']#
length: float#

volmdlr_tools.shapes.revolved.turned module#

A turned part read as the profile it is turned from and the features that stand on that body.

The coaxial surfaces of a turned part, with the flat faces that close them, are its skin: the profile that is turned to make the body, once each face the features cut into is taken whole. Every other face belongs to a feature that stands on the skin: a hole, a pocket, a flange plate, each a straight prism along one direction with, perhaps, its edges broken; or a body turned about an axis of its own, the eye of an eye bolt. Reading a part this way says which faces are explained and which are not, and why.

class volmdlr_tools.shapes.revolved.turned.TurnedFeature(face_ids: frozenset[int], revolution: Revolution)#

Bases: object

A body turned about an axis of its own that stands on the part, as the eye of an eye bolt does.

Parameters:
  • face_ids – The faces it explains, as numbered by the part’s adjacency graph.

  • revolution – Its axis and the profile turned about it, read as the part’s own profile is.

face_ids: frozenset[int]#
revolution: Revolution#
class volmdlr_tools.shapes.revolved.turned.TurnedPart(revolution: Revolution, skin_face_ids: frozenset[int], bands: tuple[MeridianBand, ...], features: tuple[BossParameters | PocketParameters | HoleStack, ...], refusals: tuple[FaceRefusal, ...], profile_refusal: FaceRefusal | None = None, turned_features: tuple[TurnedFeature, ...] = (), end_face_ids: frozenset[int] = frozenset({}))#

Bases: object

A part read as a body of revolution with prisms standing on it.

Parameters:
  • revolution – The body of revolution: its axis, and the profile that is turned about it, in the axes (t, r). The profile’s chains are empty when the bands do not close. The reading goes face by face and samples no half planes, so meridians_checked is 0 and deviation 0.0; revolved_share and explained_area_share are the share of the part’s surface that is skin, and unexplained_faces the faces that are not.

  • skin_face_ids – The faces of the skin.

  • bands – What each skin face contributes to the profile, by face id.

  • features – The prisms, parents before the features that stand on them.

  • refusals – The face groups that are not features, each with its reason (see FaceRefusal).

  • profile_refusal – Why the bands do not close into a profile, with its faces; None when they do.

  • turned_features – The bodies turned about axes of their own that stand on the part.

  • end_face_ids – The faces of the skin that end a turn of less than a whole one: the flat faces holding the axis where it starts and where it stops. Empty for a part turned whole.

property axis_direction: Vector3D#

Unit direction of the axis.

property axis_origin: Point3D#

A point of the axis.

bands: tuple[MeridianBand, ...]#
property chains: tuple[MeridianChain, ...]#

The profile: closed chains in the axes (t, r), none when the bands do not close.

end_face_ids: frozenset[int] = frozenset({})#
property explains_every_face: bool#

Whether the skin closes into a profile and every other face is a feature’s.

features: tuple[BossParameters | PocketParameters | HoleStack, ...]#
property operation_count: int#

How many operations rebuild the part: the profile’s turn, then each feature.

profile_refusal: FaceRefusal | None = None#
refusals: tuple[FaceRefusal, ...]#
revolution: Revolution#
skin_face_ids: frozenset[int]#
turned_features: tuple[TurnedFeature, ...] = ()#

volmdlr_tools.shapes.solid_groups module#

Which solids of an assembly are one solid in several places, and which are prisms standing on common planes.

A designer who models a row of identical brackets draws one and places it again; one who models a plate of different pegs draws their outlines in a sketch and extrudes them together. Both statements can be read back from the solids themselves.

Two readings are offered:

  • congruent_groups() finds solids that are the same solid moved by a rigid motion or mirrored, and the motion that carries the first of a group onto each of the others, as a Motion.

  • prism_groups() finds solids that are prisms — an outline carried straight along an axis, between two flat ends — and gathers those that can be read along one common axis, with the outline of each drawn on its own plane.

Neither reads how a solid is made beyond that; the solids are left for whatever reconstructs them.

class volmdlr_tools.shapes.solid_groups.CircleProfile(center: tuple[float, float], radius: float)#

Bases: object

A whole circle drawn on a sketch plane.

Parameters:
  • center – (cx, cy) in the sketch plane.

  • radius – Radius of the circle.

center: tuple[float, float]#
radius: float#
class volmdlr_tools.shapes.solid_groups.CongruentGroup(members: tuple[int, ...], motions: tuple[Motion, ...])#

Bases: object

Solids that are one solid in several places.

Parameters:
  • members – Indices of the solids, the first being the one the others are copies of.

  • motions – For each member, the motion that carries the first member onto it; the first carries it onto itself.

members: tuple[int, ...]#
motions: tuple[Motion, ...]#
class volmdlr_tools.shapes.solid_groups.Motion(matrix: tuple[tuple[float, float, float], tuple[float, float, float], tuple[float, float, float]], translation: Vector3D)#

Bases: object

A map from a solid onto its copy: a turn and a shift, with a mirroring when the copy is a mirror image.

A point p goes to matrix @ p + translation.

Parameters:
  • matrix – Rows of the 3x3 orthogonal matrix. Its determinant is -1 for a mirror image.

  • translation – The shift applied after the matrix.

inverse() → Motion#

Return the motion that carries a copy back onto its original.

property kind: Literal['identity', 'translation', 'rotation', 'reflection', 'general']#

What the motion is, in the simplest terms that say it all.

"identity" moves nothing; "translation" only shifts; "rotation" turns about an axis in space, with no shift along it; "reflection" is a mirroring across a plane; "general" is anything else — a screw, a turn that mirrors, a mirroring that slides.

matrix: tuple[tuple[float, float, float], tuple[float, float, float], tuple[float, float, float]]#
property mirrored: bool#

Whether the copy is a mirror image of the original.

reflection_plane() → tuple[Point3D, Vector3D] | None#

Return a point and the unit normal of the plane a mirroring reflects across.

Returns:

None when the motion is not a pure reflection.

rotation_axis() → tuple[Point3D, Vector3D, float] | None#

Return a point on the axis a pure rotation turns about, its unit direction and the angle in degrees.

Returns:

None when the motion is not a rotation about an axis, which includes one that also shifts along the axis.

then(other: Motion) → Motion#

Return the motion that does this one and then other.

translation: Vector3D#
without_reflection(normal: Vector3D) → Motion#

Return the proper motion that, applied to the original reflected across a plane, gives the copy.

A mirror image is a mirroring followed by a turn and a shift. This splits the mirroring off, so that a copy can be written as a reflection of the original and then a move.

Parameters:

normal – Unit normal of the plane through the origin that the original is reflected across.

class volmdlr_tools.shapes.solid_groups.PrismGroup(axis: Vector3D, frame: Frame3D, members: tuple[PrismMember, ...])#

Bases: object

Prisms that all run along one axis.

Parameters:
  • axis – Unit direction they are extruded along. It points the way its largest component grows, so a prism along the vertical is extruded upward.

  • frame – A frame whose third axis is axis, with its origin at the origin of the space; a profile is drawn in the frame’s first two axes, on a plane shifted by the member’s start along axis.

  • members – The prisms, in the order of the solids given.

axis: Vector3D#
frame: Frame3D#
members: tuple[PrismMember, ...]#
class volmdlr_tools.shapes.solid_groups.PrismMember(index: int, start: float, depth: float, profile: ProfileShape | CircleProfile)#

Bases: object

One prism of a group, read along the group’s axis.

Parameters:
  • index – Index of the solid among those given.

  • start – Where the prism begins along the axis, measured from the origin.

  • depth – How far it runs along the axis.

  • profile – Its outline drawn on the plane it begins on.

depth: float#
index: int#
profile: ProfileShape | CircleProfile#
start: float#
class volmdlr_tools.shapes.solid_groups.RotationSeries(point: Point3D, axis: Vector3D, step: float, order: tuple[int, ...])#

Bases: object

Copies turned by equal steps about one axis from the original.

Parameters:
  • point – A point of the axis.

  • axis – Unit direction of the axis.

  • step – The turn from one copy to the next, and from the original to the first copy, in degrees.

  • order – Indices into the motions given, in the order the copies follow one another.

axis: Vector3D#
order: tuple[int, ...]#
point: Point3D#
step: float#
class volmdlr_tools.shapes.solid_groups.TranslationSeries(step: Vector3D, order: tuple[int, ...])#

Bases: object

Copies at equal steps along a line from the original.

Parameters:
  • step – The shift from one copy to the next, and from the original to the first copy.

  • order – Indices into the motions given, in the order the copies stand along the line: the first copy is one step from the original.

order: tuple[int, ...]#
step: Vector3D#
class volmdlr_tools.shapes.solid_groups.TurnedCopies(members: tuple[int, ...], series: RotationSeries)#

Bases: object

Solids that are one solid turned about one axis by equal steps: a polar pattern of it.

Parameters:
  • members – Indices of the solids, the original first: the copy that stands first, turning about the axis, from the reference direction of reference_direction().

  • series – The turns that carry the original onto the other members, series.order indexing members[1:].

property closes_the_turn: bool#

Whether the copies go all the way round the axis, one step past the last landing on the original.

property count: int#

How many solids the pattern places, the original included.

members: tuple[int, ...]#
series: RotationSeries#
volmdlr_tools.shapes.solid_groups.congruent_groups(solids: Sequence[shapes.Solid], relative_tolerance: float = 1e-06) → tuple[CongruentGroup, ...]#

Find the solids that are copies of one another, moved or mirrored.

Two solids are copies when a rigid motion, with or without a mirroring, carries every face, edge and corner of the one onto a face, edge or corner of the other that has the same size. Solids that are alone in their kind are not returned.

A solid with symmetries of its own is carried onto its copy by several motions. The group is described by as few kinds of motion as it takes — if every copy is also a mirror image across some plane, the group is mirrors — and then by the plainest kind.

Parameters:
  • solids – The solids to compare, in a common frame.

  • relative_tolerance – Share of its size by which a measure of a copy, such as its volume or a face’s area, may differ from the original’s.

Returns:

The groups of two or more copies, each led by the first of its members in the order given.

volmdlr_tools.shapes.solid_groups.copy_mismatch(solid: Solid, other: Solid, relative_tolerance: float = 1e-06) → str | None#

Say why one solid is not a copy of another, moved or mirrored.

Parameters:
  • solid – The original.

  • other – The solid that may be its copy.

  • relative_tolerance – Share of its size by which a measure of the copy may differ from the original’s.

Returns:

None when it is a copy, else what differs: the number of faces, edges and corners, the volume, the area, or the placement of its faces, edges and corners.

volmdlr_tools.shapes.solid_groups.copy_series(motions: Sequence[Motion], extent: float | None = None) → TranslationSeries | RotationSeries | None#

Read the copies of one original as a series, when they are placed at equal steps.

How far a copy may stand from where the series places it is a share of the size of the solids, so a part reads the same in whatever unit it is measured in when that size is given.

Parameters:
  • motions – What carries the original onto each copy, the original itself excluded.

  • extent – How far the solids reach. Omitted, the share is of how far the copies are carried, or the axis they turn about stands, from the origin.

Returns:

The series, or None when the copies are fewer than three, are not all shifts or all turns about one axis, or do not stand at equal steps with the first one step from the original.

volmdlr_tools.shapes.solid_groups.prism_groups(solids: Sequence[shapes.Solid]) → tuple[PrismGroup, ...]#

Gather the prisms among the solids that can be read along a common axis.

A solid is a prism along an axis when its two ends are flat, whole and perpendicular to it, and every other face is a plane parallel to it or a cylinder about an axis parallel to it. A box is a prism along three axes; a cylinder along one. Axes are taken by the number of solids they read, the vertical, then the other axes of the frame, winning ties, and each solid is read along the first axis chosen that reads it.

Only prisms whose outline is a recognised sketch shape or a circle are gathered, and an axis that reads only one solid gathers nothing.

Parameters:

solids – The solids, in a common frame.

Returns:

The groups of two or more prisms, led by the one the axis is chosen for first.

volmdlr_tools.shapes.solid_groups.reference_direction(axis: ndarray) → ndarray#

Return the direction turns about an axis are counted from: the frame’s axis lying most across it.

Parameters:

axis – Unit direction of the axis.

Returns:

That frame axis with its part along axis removed, as a unit vector.

volmdlr_tools.shapes.solid_groups.turned_copies(solids: Sequence[shapes.Solid], relative_tolerance: float = 1e-06) → tuple[TurnedCopies, ...]#

Find the solids that are one solid turned by equal steps about one axis.

Solids are copies of one another as congruent_groups() reads them, and among all the motions that carry one onto another only the turns are kept, so that copies which are also mirror images of each other, as symmetric ribs are, still read as turned. The copies must stand at equal steps about one axis, and be at least three, or two closing the turn with the original.

Parameters:
  • solids – The solids to compare, in a common frame.

  • relative_tolerance – Share of its size by which a measure of a copy, such as its volume or a face’s area, may differ from the original’s. Solids built from figures written to a few decimals differ by more than the default allows.

Returns:

One pattern per set of turned copies, each led by its original.

Module contents#

Shape recognition and abstractions.