volmdlr_tools.features.extractors package#

Feature extractors for identifying specific features in BRep models.

Submodules#

volmdlr_tools.features.extractors.core module#

Module for the base feature extractor class.

class volmdlr_tools.features.extractors.core.FeatureExtractor(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: DessiaObject

Base class for feature extractors.

perform() bool#

Perform the feature extraction.

property result: list[Feature]#

Get the recognition result as Feature.

This property provides access to the shape abstraction after recognition. Automatically calls perform() if not yet executed.

Returns:

SheetMetalShape if recognized, None otherwise

class volmdlr_tools.features.extractors.core.InnerFeaturesExtractor(aag: AttributedAdjacencyGraph, max_number_feature_faces: float = 20, name: str = '')#

Bases: FeatureExtractor

Base class for inner features extractors.

This class provides a base implementation for extracting inner features from a CAD model. Subclasses must implement the is_invalid_base_neighbor and recognize methods.

Inner features are features that are inside a shape’s face, connected to its inner wires.

Parameters:
  • aag – The Attributed Adjacency Graph (AAG) representation of the CAD model.

  • name (str) – The name of the Extractor.

Returns:

The Extractor.

Return type:

InnerFeaturesExtractor

extract() list[list[int]]#

Recognize feature faces in BRep model.

The method first identifies seed faces by finding inner wires (loops of edges inside a face). Each seed is checked for convexity/smoothness based on the angle between adjacent faces. If the inner wire is convex or smooth, the method propagates to neighboring faces, ensuring the identified feature doesn’t exceed the maximum allowable number of faces (max_number_feature_faces).

The algorithm proceeds as follows: 1. For each inner wire in a seed face, find adjacent faces through common edges and check whether the adjacency

relationships between each pair of faces are classified as convex.

  1. Propagate through adjacent faces to form a feature, ensuring the feature is valid.

  2. Return the recognized features as collections of faces and their corresponding indices.

Note: This method accumulates all valid feature faces. The post-processing step (e.g., _collect_cavities) should handle grouping by connected components.

get_features_faces(nodes: list[int]) list[Face]#

Get features faces for a set of nodes.

is_angle_type_valid(angle_validator: callable, face_index: int, wire: TopoDS_Shape) bool#

Check whether the edges of a wire are of a given type, based on the angles between adjacent faces.

This method iterates over the edges of a given wire (which can represent part of a face) and evaluates the type of the edges based on the angles between the current face and its neighboring faces. If all angles are of the given type, the method returns True, indicating that the wire forms a feature boundary of the given type.

Parameters:
  • angle_validator – A function that validates the angle type.

  • face_index – The index of the face being evaluated for the angle type.

  • wire – The wire (loop of edges) to check for the angle type.

Returns:

Returns True if all edges in the wire are of the given type; otherwise, False.

is_concave_through(face_index: int, wire: TopoDS_Shape) bool#

Check whether the edges of a wire are concave, based on the angles between adjacent faces.

This method iterates over the edges of a given wire (which can represent part of a face) and evaluates the concavity of the edges based on the angles between the current face and its neighboring faces. If all angles are concave, the method returns True, indicating that the wire forms a concave feature boundary.

Parameters:
  • face_index – The index of the face being evaluated for concavity.

  • wire – The wire (loop of edges) to check for concavity.

Returns:

Returns True if all edges in the wire are concave; otherwise, False.

is_convex_through(face_index: int, wire: TopoDS_Shape) bool#

Check whether the edges of a wire are convex, based on the angles between adjacent faces.

This method iterates over the edges of a given wire (which can represent part of a face) and evaluates the convexity of the edges based on the angles between the current face and its neighboring faces. If all angles are convex, the method returns True, indicating that the wire forms a convex feature boundary.

Parameters:
  • face_index – The index of the face being evaluated for convexity.

  • wire – The wire (loop of edges) to check for convexity.

Returns:

Returns True if all edges in the wire are convex; otherwise, False.

is_feature_valid(new_feature_faces: list[TopoDS_Shape], new_feature_indices: list[int], seed_face_id: int) bool#

Check if the feature is valid.

is_invalid_base_neighbor(start_id: int, neighbor_id: int) bool#

Check if the base neighbor is invalid.

is_not_entire_shape(new_feature_faces: list[TopoDS_Shape], new_feature_indices: list[int]) bool#

Validate whether the recognized feature is a subset of the entire CAD model.

This method ensures that the newly identified feature does not encompass the entire model, which would indicate that the feature recognition failed to isolate a distinct feature. The method compares the size of the feature to the total number of faces in the AAG.

Parameters:
  • new_feature_faces – A list of faces belonging to the newly recognized feature.

  • new_feature_indices – A list of indices for the faces in the recognized feature.

Returns:

Returns True if the recognized feature is smaller than the entire CAD model, indicating successful isolation of a distinct feature.

propagate(start_id: int, seed_neighbors_ids: list[int], feature_faces: list[TopoDS_Shape], feature_indices: list[int], is_ok: bool = True) bool#

Propagates through the AAG starting from a seed face, identifying adjacent faces that form a feature.

This method is a recursive traversal that collects neighboring faces into a feature. For each seed face, the method checks whether its adjacent faces meet the necessary geometric conditions (e.g., sharing common edges on the outer wire and having convexity in the adjacent angles).

The propagation continues until no more valid adjacent faces can be added to the feature, or the maximum allowable number of faces is reached.

Parameters:
  • start_id – The index of the starting face for the propagation.

  • seed_neighbors_ids – List of neighboring face indices to be evaluated.

  • feature_faces – A list to collect faces that are part of the recognized feature.

  • feature_indices – A list to collect indices of faces that form the feature.

  • is_ok – (optional) A flag indicating whether the feature remains valid throughout propagation (default is True).

Returns:

Returns True if the propagation is successful and the feature remains valid.

volmdlr_tools.features.extractors.blend module#

A module for recognition of fillets in a BRep model.

class volmdlr_tools.features.extractors.blend.BlendExtractor(aag: AttributedAdjacencyGraph, max_radius: float = 0.5)#

Bases: FeatureExtractor

Extract blend/fillet features from AAG.

A class for recognizing and analyzing blends in a geometric model using an adjacency attribute graph (AAG). Supports recognition of edge-based and vertex-based blends.

calculate_chain_length(feature: list[int]) float#

Compute the total length of a blend chain based on the blend candidate attributes of each face.

The total length is the sum of the lengths of each blend face in the chain, as stored in their blend candidate attributes.

Parameters:

feature – A list of face IDs representing the blend chain.

Returns:

The computed total length of the blend chain.

compute_blend_length(edges_indices: list[int]) float#

Compute the total length of the blend chain.

Parameters:

edges_indices – A list of edges indexes from the belnd chain

Returns:

The sum of the lengths of all edges in edges_indeces list.

display_result#

Implementation of a tag for displays.

dye_blending_faces(color: tuple = (0, 1, 1)) None#

Change the colors of blending faces.

Parameters:

color – Derired color

find_cross_edges(face_id: int, smooth_edges_ids: list[int], spring_edges_ids: list[int], candidate_radius: float) tuple#

Identify and return cross edges on a given face, based on curvature evaluation and a specified candidate radius.

Cross edges are those that satisfy certain curvature conditions compared to the provided radius and are not in the excluded categories (smooth or spring edges).

  • The method evaluates curvature at the midpoint of each remaining edge, which is neither a smooth nor spring edge.

  • The edge is classified as a cross edge if its curvature-derived radius matches the candidate radius within a tolerance threshold.

Parameters:
  • face_id – The index or ID of the face for which to find cross edges.

  • smooth_edges_ids – A list of edge IDs that represent “smooth” edges to be excluded.

  • spring_edges_ids – A list of edge IDs that represent “spring” edges to be excluded.

  • candidate_radius – The target radius value used to compare the curvature of the edges.

Returns:

  • cross_edges: A list of edge objects that qualify as cross edges based on the curvature evaluation.

  • cross_edges_ids: A list of IDs corresponding to the cross edges.

Raises:

Issues a warning if the curvature cannot be evaluated along the edge.

find_smooth_edges() tuple[list[TopoDS_Shape], list[int]]#

Find all smooth edges across all faces in the adjacency attribute graph (AAG).

Returns:

A tuple containing the list of all smooth edges and their corresponding indices.

find_smooth_edges_for_face(face_id: int) tuple[list[TopoDS_Shape], list[int]]#

Find smooth edges for a given face based on adjacent faces in the graph.

Parameters:

face_id – The ID of the face to analyze.

Returns:

A tuple containing the list of smooth edges and their corresponding indices.

find_spring_edges(face_id: int, smooth_edge_ids: TColStd_PackedMapOfInteger) tuple[list[TopoDS_Shape], list[int], bool, float]#

Find the spring edges for a given face, considering the smooth edge indices.

Parameters:
  • face_id – The ID of the face to analyze.

  • smooth_edge_ids – The indices of the smooth edges.

Returns:

A tuple containing the spring edges, their indices, whether it’s a candidate blend, and the candidate radius.

find_terminating_edges(face_id: int, smooth_edges_ids: list[int], spring_edges_ids: list[int], cross_edges_ids: list[int]) tuple#

Identify and return the terminating edges of a given face, excluding edges that belong to specified categories.

A terminating edge is one that does not belong to any of the provided exclusion lists.

Parameters:
  • face_id – The index or ID of the face for which to find terminating edges.

  • smooth_edges_ids – A list of edge IDs that represent “smooth” edges to be excluded.

  • spring_edges_ids – A list of edge IDs that represent “spring” edges to be excluded.

  • cross_edges_ids – A list of edge IDs that represent “cross” edges to be excluded.

Returns:

A list of edge objects that are considered terminating edges. A list of IDs corresponding to the terminating edges.

get_blending_chains_faces() list[list[Face]]#

Return a list containing all identified faces grouped by connectivity and radius.

get_blending_faces() list[Face]#

Return a list containing all identified faces.

get_blends() list[Blend]#

Return a list containing all blends.

get_chains(r_dev_perc: float = 5.0) list[BlendChain]#

Identify and return chains of blend faces.

Chains are grouped by their fillet radii and cross-edge length. The method first extracts connected components from the adjacency graph based on recognized blend candidates. It then distributes faces into groups based on their fillet radii and evaluates connected components within each group. Afterward, it normalizes these chains by removing any dangling vertex blends.

Parameters:

r_dev_perc – The allowed percentage deviation when comparing fillet radii. This value controls the tolerance for how close radii need to be considered part of the same chain. A typical default value is 5.0%.

Returns:

A list of BlendChain objects, each containing faces, properties, and spring edges.

property ids: list[int]#

Return the ids of blend faces.

Returns:

Ids of blend faces.

perform() None#

Execute the blend recognition process over all faces in the adjacency attribute graph (AAG).

property shape: Shape#

Return the shape.

terminating_edges_to_cross_edges() None#

Convert terminating edges to cross edges if the terminating edges connect blend candidate faces.

class volmdlr_tools.features.extractors.blend.RecognizeBlends(aag: AttributedAdjacencyGraph, max_radius: float = 0.5)#

Bases: BlendExtractor

Deprecated: Use BlendExtractor instead.

This class is maintained for backward compatibility and will be removed in version 1.0.0. Please update your code to use BlendExtractor.

volmdlr_tools.features.extractors.cavity module#

Module for recognizing geometric features, specifically cavities and pockets, in a B-Rep CAD model.

This module operates on a CAD model’s Attributed Adjacency Graph (AAG), an extension of B-Rep that encodes adjacency information and feature semantics. The main class, CavityExtractor, provides methods to traverse the AAG and recognize features like cavities and pockets, leveraging graph algorithms and geometric queries.

class volmdlr_tools.features.extractors.cavity.CavityExtractor(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: InnerFeaturesExtractor

Extract cavity and pocket features from AAG.

A class for recognizing cavities and pockets in a CAD model using an Attributed Adjacency Graph (AAG). The AAG is traversed to find “seed” faces that are part of these features. From the seeds, the algorithm propagates to identify connected faces that share specific geometric characteristics such as convexity of edges and angles.

Parameters:
  • aag (AttributedAdjacencyGraph) – The Attributed Adjacency Graph (AAG) representation of the CAD model

  • max_number_feature_faces (int) – Maximum allowable number of faces in a recognized feature (used to filter overly large features), defaults to 20

display_result#

Implementation of a tag for displays.

find_seeds() list[int]#

Find potential seed faces in the CAD model that can be used to start the feature recognition process.

This method scans the faces in the Attributed Adjacency Graph (AAG) to locate candidate seed faces. For a cavity, a seed face is typically a face with inner wires, where the neighboring faces, adjacent to this seed face through the inner wires, have a convex relationship with respect to the seed face.

Returns:

A list of face indices that are valid seed candidates for further feature recognition.

get_cavities() list[Cavity]#

Return a list containing all identified cavities with their base faces.

property ids_pockets: list[list[int]]#

Return the ids of blend faces.

Returns:

Ids of blend faces.

is_angle_valid(seed_id: int, neighbor_id: int) bool#

Check if the angle is valid.

is_feature_valid(new_feature_faces: list[TopoDS_Shape], new_feature_indices: list[int], seed_face_neighbors: list[int]) bool#

Check if the feature is valid.

is_invalid_base_neighbor(start_id: int, neighbor_id: int) bool#

Check if the base neighbor is invalid.

is_seed_valid(face_index: int, wire: TopoDS_Shape) bool#

Check if the seed node is valid.

perform() bool#

Perform the cavity feature extraction.

recognize_cavities() None#

Recognize cavity features in the CAD model by analyzing the Attributed Adjacency Graph (AAG).

(Under construction)

property shape: Shape#

Return the shape.

class volmdlr_tools.features.extractors.cavity.RecognizeCavities(aag: AttributedAdjacencyGraph)#

Bases: CavityExtractor

Deprecated: Use CavityExtractor instead.

This class is maintained for backward compatibility and will be removed in version 1.0.0. Please update your code to use CavityExtractor.

volmdlr_tools.features.extractors.sharp_edge module#

A module for sharp edges identification.

class volmdlr_tools.features.extractors.sharp_edge.SharpEdgeExtractor(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: FeatureExtractor

Extract sharp edge features from AAG.

A class for recognizing and analyzing sharp edges in a geometric model using an adjacency attribute graph. Sharp edges are identified by analyzing convex angles between adjacent faces along linear edges.

display_result#

Implementation of a tag for displays.

get_edges() list[SharpEdge]#

Return a list containing all identified edges.

get_edges_shapes() list[Edge]#

Return a list containing all identified edges shapes.

property ids: list[int]#

Return the ids of sharp edges.

Returns:

Ids of sharp edges.

perform() None#

Perform sharp edge identification and cache the result.

property shape: Shape#

Return the shape.

class volmdlr_tools.features.extractors.sharp_edge.SharpEdgeRecognizer(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: SharpEdgeExtractor

Deprecated: Use SharpEdgeExtractor instead.

This class is maintained for backward compatibility and will be removed in version 1.0.0. Please update your code to use SharpEdgeExtractor.

volmdlr_tools.features.extractors.deformation module#

Deformation extractor module.

class volmdlr_tools.features.extractors.deformation.DeformationExtractionHelper(aag: AttributedAdjacencyGraph, max_number_feature_faces: float = 100, name: str = '')#

Bases: InnerFeaturesExtractor

Helper class for recognizing deformation features in a sheet metal.

extract() tuple[list[list[int]], list[list[int]]]#

Recognize deformation feature faces in BRep model.

The method first identifies seed faces by finding inner wires (loops of edges inside a face). Each seed is checked for smoothness based on the angle between adjacent faces. If the inner wire has smooth transitions, the method propagates to neighboring faces, ensuring the identified feature doesn’t exceed the maximum allowable number of faces (max_number_feature_faces).

The algorithm proceeds as follows: 1. For each inner wire in a seed face, find adjacent faces through common edges and check whether

the adjacency relationships are classified as smooth.

  1. Propagate through adjacent faces to form a feature, ensuring the feature is valid.

  2. Separate features into those with closing faces (embosses) and those without (flanged cutouts).

Returns:

A tuple of two lists: - no_cutout: List of feature face indices for closed deformations (embosses). - has_cutout: List of feature face indices for open deformations (flanged cutouts).

find_seeds() list[int]#

Get the seed faces of the AAG.

is_angle_valid(seed_id: int, neighbor_id: int) bool#

Check if the angle is valid.

is_feature_valid(new_feature_faces: list[TopoDS_Shape], new_feature_indices: list[int], seed_face_id: int) bool#

Check if the feature is valid.

is_invalid_base_neighbor(start_id: int, neighbor_id: int) bool#

Check if the base neighbor is invalid.

is_seed_valid(face_index: int, wire: TopoDS_Shape) bool#

Check if the seed is valid.

propagate(start_id: int, seed_neighbors_ids: list[int], feature_faces: list[TopoDS_Shape], feature_indices: list[int], previous_level_indices: list[int], is_ok: bool = True, has_closing_face: bool = False) tuple[bool, bool]#

Propagate through the AAG starting from a seed face, identifying adjacent faces that form a feature.

This method is a recursive traversal that collects neighboring faces into a feature. For each seed face, the method checks whether its adjacent faces meet the necessary geometric conditions (e.g., sharing common edges on the outer wire and having smooth angles).

The propagation continues until no more valid adjacent faces can be added to the feature, or the maximum allowable number of faces is reached. It also detects whether the feature has a closing face (indicating a closed deformation like an emboss).

Parameters:
  • start_id – The index of the starting face for the propagation.

  • seed_neighbors_ids – List of neighboring face indices to be evaluated.

  • feature_faces – A list to collect faces that are part of the recognized feature.

  • feature_indices – A list to collect indices of faces that form the feature.

  • previous_level_indices – List of face indices from the previous recursion level, used to detect closing faces.

  • is_ok – A flag indicating whether the feature remains valid throughout propagation (default is True).

  • has_closing_face – A flag indicating whether a closing face was found (default is False).

Returns:

A tuple (is_ok, has_closing_face) where is_ok indicates propagation success and has_closing_face indicates whether the feature is closed.

class volmdlr_tools.features.extractors.deformation.DeformationExtractor(sheet_metal: SheetMetalShape, name: str = '')#

Bases: FeatureExtractor

Extractor for recognizing deformation features in a B-Rep CAD model.

static get_entire_set_center_of_mass(deformation_set: list[int], aag_side: AttributedAdjacencyGraph) ndarray#

Compute the center of mass for an entire deformation set by averaging face centers.

Parameters:
  • deformation_set – List of node indices in the deformation set.

  • aag_side – The AAG representation of one side.

Returns:

The averaged center of mass as a numpy array.

perform() bool#

Perform deformation recognition by matching deformations from both sides of the sheet metal.

Returns:

True if found any deformation matches. False otherwise.

volmdlr_tools.features.extractors.sheet_metal module#

Sheet metal feature extractor implementing Yang Yang et al. (2021) algorithm.

class volmdlr_tools.features.extractors.sheet_metal.SheetMetalFeatureExtractor(sheet_metal: SheetMetalShape, name: str = '')#

Bases: FeatureExtractor

Extractor for sheet metal features using Yang Yang et al. (2021) algorithm.

This extractor orchestrates the feature extraction process: 1. Extracts sub-chains from ThicknessFaceChains 2. Delegates classification to SheetMetalFeatureClassifier

Responsibilities: - Extraction: Get sub-chains using three methods (binary, concavity, convexity) - Orchestration: Use classifier for feature identification

The classifier handles all pattern matching and feature creation logic.

CURL_ANGLE_THRESHOLD = 1.5707963267948966#
MIN_FACES_FOR_MIRRORING = 5#
NUM_FACES_CURL = 3#
NUM_FACES_HEM = 5#
property boundary_features: list[Feature]#

Get the boundary features extracted from the sheet.

extract_all_bendings(chain: ThicknessFaceChain) list[Bend]#

Extract all bend features from a thickness face chain.

Identifies fan-shaped faces and pairs, creating Bend features for each. Bends with angle > 90° are labeled as “Curl”.

Parameters:

chain (ThicknessFaceChain) – The thickness face chain to extract bends from

Returns:

List of Bend features

Return type:

list[Bend]

extract_boundary_features() list#

Extract and classify features from boundary thickness face chains.

Returns:

List of classified boundary features

Return type:

list[Feature]

extract_internal_features() list#

Extract and classify features from internal thickness face chains.

Returns:

List of classified internal features

Return type:

list[Feature]

static get_connected_concave_subchains(fan_shaped_faces_subchains: list[ThicknessFaceChain], concave_subchains: list[ThicknessFaceChain], main_chain: ThicknessFaceChain) list[TFCGroup]#

Group fan-shaped face subchains with their connected concave subchains.

For each fan-shaped face subchain, finds adjacent concave subchains of equal length and groups them together. Unpaired subchains are returned as single-element groups.

Parameters:
Returns:

List of TFCGroup objects

Return type:

list[TFCGroup]

get_external_subchains_groups() list[TFCGroup]#

Extract and group subchains from the boundary thickness face chain.

Combines fan-shaped face subchains with connected concave subchains, and adds convex/concave subchains as individual groups.

Returns:

List of TFCGroup objects representing boundary feature candidates

Return type:

list[TFCGroup]

get_internal_subchains_groups() list[TFCGroup]#

Extract and group subchains from internal thickness face chains.

Returns:

List of TFCGroup objects representing internal feature candidates

Return type:

list[TFCGroup]

get_mirror_internal_subchains(internal_chains: list[ThicknessFaceChain]) list[TFCGroup]#

Group internal thickness face chains into mirror pairs or individual groups.

Chains with < 5 faces are always treated as individual groups. Chains with >= 5 faces are paired if their neighbors intersect (indicating mirror relationship). Unpaired chains are added as individual groups.

Parameters:

internal_chains – List of internal thickness face chains

Returns:

List of chain groups (pairs or singles)

property internal_features: list[Feature]#

Get the internal features extracted from the sheet metal.

perform() bool#

Perform feature extraction using Yang Yang algorithm.

Extracts sub-chains from boundary and internal thickness face chains and classifies features using the classifier.

Returns:

True if any features were found

Return type:

bool

volmdlr_tools.features.extractors.feature_classifier module#

Feature classifier for sheet metal features based on thickness face chains.

class volmdlr_tools.features.extractors.feature_classifier.SheetMetalFeatureClassifier(aag: AttributedAdjacencyGraph)#

Bases: object

Classifier for sheet metal features using thickness face chains.

This class implements the classification logic from Yang Yang et al. (2021), using the Characteristics Matrix approach with rule-based pattern matching.

Classification uses three rule tables: - CUT_RULES: For cut features (Slot, Notch, CornerRelief) - COMPOSITE_RULES: For bend/composite features (Bend, Jog, Lance, Clip) - DEFORM_RULES: For deform features (Emboss)

classify(tfc_group: TFCGroup) Feature#

Classify a thickness face chain group into a specific feature type.

Uses the Characteristics Matrix approach from Yang Yang et al. (2021): 1. Extract properties from the TFC group 2. Match against rules in order of priority 3. Return first matching feature type or UnknownFeature

Parameters:

tfc_group (TFCGroup) – The thickness face chain group to classify

Returns:

Classified Feature object or UnknownFeature

Return type:

Feature

Module contents#

Feature extractors.

class volmdlr_tools.features.extractors.BlendExtractor(aag: AttributedAdjacencyGraph, max_radius: float = 0.5)#

Bases: FeatureExtractor

Extract blend/fillet features from AAG.

A class for recognizing and analyzing blends in a geometric model using an adjacency attribute graph (AAG). Supports recognition of edge-based and vertex-based blends.

calculate_chain_length(feature: list[int]) float#

Compute the total length of a blend chain based on the blend candidate attributes of each face.

The total length is the sum of the lengths of each blend face in the chain, as stored in their blend candidate attributes.

Parameters:

feature – A list of face IDs representing the blend chain.

Returns:

The computed total length of the blend chain.

compute_blend_length(edges_indices: list[int]) float#

Compute the total length of the blend chain.

Parameters:

edges_indices – A list of edges indexes from the belnd chain

Returns:

The sum of the lengths of all edges in edges_indeces list.

display_result#

Implementation of a tag for displays.

dye_blending_faces(color: tuple = (0, 1, 1)) None#

Change the colors of blending faces.

Parameters:

color – Derired color

find_cross_edges(face_id: int, smooth_edges_ids: list[int], spring_edges_ids: list[int], candidate_radius: float) tuple#

Identify and return cross edges on a given face, based on curvature evaluation and a specified candidate radius.

Cross edges are those that satisfy certain curvature conditions compared to the provided radius and are not in the excluded categories (smooth or spring edges).

  • The method evaluates curvature at the midpoint of each remaining edge, which is neither a smooth nor spring edge.

  • The edge is classified as a cross edge if its curvature-derived radius matches the candidate radius within a tolerance threshold.

Parameters:
  • face_id – The index or ID of the face for which to find cross edges.

  • smooth_edges_ids – A list of edge IDs that represent “smooth” edges to be excluded.

  • spring_edges_ids – A list of edge IDs that represent “spring” edges to be excluded.

  • candidate_radius – The target radius value used to compare the curvature of the edges.

Returns:

  • cross_edges: A list of edge objects that qualify as cross edges based on the curvature evaluation.

  • cross_edges_ids: A list of IDs corresponding to the cross edges.

Raises:

Issues a warning if the curvature cannot be evaluated along the edge.

find_smooth_edges() tuple[list[TopoDS_Shape], list[int]]#

Find all smooth edges across all faces in the adjacency attribute graph (AAG).

Returns:

A tuple containing the list of all smooth edges and their corresponding indices.

find_smooth_edges_for_face(face_id: int) tuple[list[TopoDS_Shape], list[int]]#

Find smooth edges for a given face based on adjacent faces in the graph.

Parameters:

face_id – The ID of the face to analyze.

Returns:

A tuple containing the list of smooth edges and their corresponding indices.

find_spring_edges(face_id: int, smooth_edge_ids: TColStd_PackedMapOfInteger) tuple[list[TopoDS_Shape], list[int], bool, float]#

Find the spring edges for a given face, considering the smooth edge indices.

Parameters:
  • face_id – The ID of the face to analyze.

  • smooth_edge_ids – The indices of the smooth edges.

Returns:

A tuple containing the spring edges, their indices, whether it’s a candidate blend, and the candidate radius.

find_terminating_edges(face_id: int, smooth_edges_ids: list[int], spring_edges_ids: list[int], cross_edges_ids: list[int]) tuple#

Identify and return the terminating edges of a given face, excluding edges that belong to specified categories.

A terminating edge is one that does not belong to any of the provided exclusion lists.

Parameters:
  • face_id – The index or ID of the face for which to find terminating edges.

  • smooth_edges_ids – A list of edge IDs that represent “smooth” edges to be excluded.

  • spring_edges_ids – A list of edge IDs that represent “spring” edges to be excluded.

  • cross_edges_ids – A list of edge IDs that represent “cross” edges to be excluded.

Returns:

A list of edge objects that are considered terminating edges. A list of IDs corresponding to the terminating edges.

get_blending_chains_faces() list[list[Face]]#

Return a list containing all identified faces grouped by connectivity and radius.

get_blending_faces() list[Face]#

Return a list containing all identified faces.

get_blends() list[Blend]#

Return a list containing all blends.

get_chains(r_dev_perc: float = 5.0) list[BlendChain]#

Identify and return chains of blend faces.

Chains are grouped by their fillet radii and cross-edge length. The method first extracts connected components from the adjacency graph based on recognized blend candidates. It then distributes faces into groups based on their fillet radii and evaluates connected components within each group. Afterward, it normalizes these chains by removing any dangling vertex blends.

Parameters:

r_dev_perc – The allowed percentage deviation when comparing fillet radii. This value controls the tolerance for how close radii need to be considered part of the same chain. A typical default value is 5.0%.

Returns:

A list of BlendChain objects, each containing faces, properties, and spring edges.

property ids: list[int]#

Return the ids of blend faces.

Returns:

Ids of blend faces.

perform() None#

Execute the blend recognition process over all faces in the adjacency attribute graph (AAG).

property shape: Shape#

Return the shape.

terminating_edges_to_cross_edges() None#

Convert terminating edges to cross edges if the terminating edges connect blend candidate faces.

class volmdlr_tools.features.extractors.CavityExtractor(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: InnerFeaturesExtractor

Extract cavity and pocket features from AAG.

A class for recognizing cavities and pockets in a CAD model using an Attributed Adjacency Graph (AAG). The AAG is traversed to find “seed” faces that are part of these features. From the seeds, the algorithm propagates to identify connected faces that share specific geometric characteristics such as convexity of edges and angles.

Parameters:
  • aag (AttributedAdjacencyGraph) – The Attributed Adjacency Graph (AAG) representation of the CAD model

  • max_number_feature_faces (int) – Maximum allowable number of faces in a recognized feature (used to filter overly large features), defaults to 20

display_result#

Implementation of a tag for displays.

find_seeds() list[int]#

Find potential seed faces in the CAD model that can be used to start the feature recognition process.

This method scans the faces in the Attributed Adjacency Graph (AAG) to locate candidate seed faces. For a cavity, a seed face is typically a face with inner wires, where the neighboring faces, adjacent to this seed face through the inner wires, have a convex relationship with respect to the seed face.

Returns:

A list of face indices that are valid seed candidates for further feature recognition.

get_cavities() list[Cavity]#

Return a list containing all identified cavities with their base faces.

property ids_pockets: list[list[int]]#

Return the ids of blend faces.

Returns:

Ids of blend faces.

is_angle_valid(seed_id: int, neighbor_id: int) bool#

Check if the angle is valid.

is_feature_valid(new_feature_faces: list[TopoDS_Shape], new_feature_indices: list[int], seed_face_neighbors: list[int]) bool#

Check if the feature is valid.

is_invalid_base_neighbor(start_id: int, neighbor_id: int) bool#

Check if the base neighbor is invalid.

is_seed_valid(face_index: int, wire: TopoDS_Shape) bool#

Check if the seed node is valid.

perform() bool#

Perform the cavity feature extraction.

recognize_cavities() None#

Recognize cavity features in the CAD model by analyzing the Attributed Adjacency Graph (AAG).

(Under construction)

property shape: Shape#

Return the shape.

class volmdlr_tools.features.extractors.DeformationExtractor(sheet_metal: SheetMetalShape, name: str = '')#

Bases: FeatureExtractor

Extractor for recognizing deformation features in a B-Rep CAD model.

static get_entire_set_center_of_mass(deformation_set: list[int], aag_side: AttributedAdjacencyGraph) ndarray#

Compute the center of mass for an entire deformation set by averaging face centers.

Parameters:
  • deformation_set – List of node indices in the deformation set.

  • aag_side – The AAG representation of one side.

Returns:

The averaged center of mass as a numpy array.

perform() bool#

Perform deformation recognition by matching deformations from both sides of the sheet metal.

Returns:

True if found any deformation matches. False otherwise.

class volmdlr_tools.features.extractors.HoleExtractor(aag: AttributedAdjacencyGraph, max_radius: float = inf, linear_tolerance: float = 0.0001, angular_tolerance: float = 0.0175, name: str = '')#

Bases: FeatureExtractor

Extract hole features from an Attributed Adjacency Graph (AAG).

This class recognizes holes by identifying cylindrical bore faces (internal cylindrical surfaces) and propagating to collect all coaxial cylindrical neighbors. The algorithm validates that the collected faces form a complete hole (360 degree angular coverage) and includes ending faces (bottoms).

Key differences from CavityExtractor: - Seed type: Cylindrical bore faces (vs. faces with inner wires) - Angle validation: Concave edges (vs. convex) - Propagation: Through coaxial cylinders (vs. outer wire neighbors) - Validation: Angular coverage (vs. connected components)

Parameters:
  • aag – The Attributed Adjacency Graph (AAG) representation of the CAD model.

  • max_radius – Maximum radius for hole recognition (filters large cylinders).

  • linear_tolerance – Tolerance for radius and position comparisons.

  • angular_tolerance – Tolerance for axis direction comparisons (radians).

  • name (str) – Name for the extractor instance.

get_holes() list[Hole]#

Create Hole objects from extracted face groups.

Returns:

List of Hole feature objects.

property ids_holes: list[list[int]]#

Return the face IDs of identified holes.

Returns:

List of face ID lists, one per hole.

perform() bool#

Perform the hole feature extraction.

Main entry point for hole recognition. Iterates through faces, identifies cylindrical bore faces, propagates to collect coaxial neighbors, validates angular coverage, and processes floating isolations.

Returns:

True if extraction completed successfully.

class volmdlr_tools.features.extractors.SharpEdgeExtractor(aag: AttributedAdjacencyGraph, name: str = '')#

Bases: FeatureExtractor

Extract sharp edge features from AAG.

A class for recognizing and analyzing sharp edges in a geometric model using an adjacency attribute graph. Sharp edges are identified by analyzing convex angles between adjacent faces along linear edges.

display_result#

Implementation of a tag for displays.

get_edges() list[SharpEdge]#

Return a list containing all identified edges.

get_edges_shapes() list[Edge]#

Return a list containing all identified edges shapes.

property ids: list[int]#

Return the ids of sharp edges.

Returns:

Ids of sharp edges.

perform() None#

Perform sharp edge identification and cache the result.

property shape: Shape#

Return the shape.