volmdlr_tools.features.feature_types package#

Feature type classes representing different kinds of geometric features.

Subpackages#

Submodules#

volmdlr_tools.features.feature_types.core module#

Core module for feature types.

class volmdlr_tools.features.feature_types.core.Feature(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Shape

Base class for all feature types.

category: FeatureCategory = 'unknown'#
classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Feature#

Create a Feature from a list of faces and a list of nodes.

volmdlr_tools.features.feature_types.blends module#

Blending Features module.

class volmdlr_tools.features.feature_types.blends.Blend(obj: TopoDS_Shape, node_id: int, blend_attribute: BlendAttribute, name: str = '')#

Bases: Feature

A class representing a blend.

class volmdlr_tools.features.feature_types.blends.BlendAttribute(confirmed: bool = False, length: float = 0.0, kind: BlendType = BlendType.Uncertain, cross_length: float = 0.0, name: str = '')#

Bases: DessiaObject

A class representing attributes of a blend.

classmethod dict_to_object(dict_: dict[str, Any], **kwargs) SerializableObject#

Deserialize a dictionary to a BlendAttribute object.

to_dict(use_pointers: bool = True, memo=None, path: str = '#', id_method=True, id_memo=None, **kwargs) dict[str, Any]#

Convert the BlendAttribute object to a serializable dictionary.

class volmdlr_tools.features.feature_types.blends.BlendChain(obj: TopoDS_Shape, nodes: list[int], cross_length: float, length: float, radius: float, name: str = '')#

Bases: Feature

A class representing a chain of blends.

classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Feature#

Create a BlendChain from a list of faces and a list of nodes.

Parameters:
  • faces – The faces to create the blend chain from.

  • nodes – The nodes to create the blend chain from.

  • name – The name of the blend chain.

Returns:

The BlendChain.

class volmdlr_tools.features.feature_types.blends.BlendType(*values)#

Bases: Enum

Enum representing different types of blends in a geometric model, including ordinary, vertex, and cliff.

Cliff = 3#
Ordinary = 1#
Uncertain = 0#
Vertex = 2#
class volmdlr_tools.features.feature_types.blends.BlendVexity(*values)#

Bases: Enum

Enum representing the vexity of a blend, which can be concave or convex.

Concave = 0#
Convex = 1#
Uncertain = -1#

volmdlr_tools.features.feature_types.cavities module#

Cavities Module.

class volmdlr_tools.features.feature_types.cavities.Cavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Feature

Base class for representing cavities as shell objects.

A cavity is represented as a collection of faces that form a shell structure. This class serves as the foundation for more specific cavity types like round, square, rectangular, and slotted cavities.

MIN_FACES_ROUND_HOLE = 2#
MIN_FACES_SQUARE = 4#
property axis: Vector3D#

Get the axis direction vector of the cavity.

Returns:

Unit vector representing the cavity axis direction.

classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Cavity#

Factory method to create the appropriate cavity type from a list of faces.

Analyzes the surface types of the provided faces and creates the corresponding specialized cavity instance (RoundCavity, SquareCavity, RectangularCavity, or SlottedCavity).

Parameters:
  • faces – List of faces that define the cavity geometry.

  • nodes – List of nodes that define the cavity geometry.

  • name – Optional name for the cavity, defaults to empty string.

Returns:

Appropriate Cavity subclass instance based on face geometry.

property length: float#

Get the length of cavity.

Returns:

Length dimension of the cavity

Return type:

float

property location: Vector3D#

Get the center location of the cavity based on its bounding box.

Returns:

Center point of the cavity’s bounding box.

property width: float#

Get the width of the cavity.

Returns:

Width dimension of the cavity.

Return type:

float.

class volmdlr_tools.features.feature_types.cavities.RectangularCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: SquareCavity

Represents a rectangular cavity with unequal width and length.

Inherits all functionality from SquareCavity but represents cavities where the width and length dimensions differ beyond the tolerance threshold (1e-6).

class volmdlr_tools.features.feature_types.cavities.RoundCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a circular/cylindrical cavity.

A round cavity is defined by one or two cylindrical surfaces and has properties like diameter, axis direction, and center location derived from the cylindrical geometry.

Parameters:
  • obj – TopoDS_Shape representing the shape of the round cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

property axis: Vector3D#

Get the axis direction vector of the round cavity.

Lazily calculates the axis from the cylindrical surface if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property diameter: float#

Get the diameter of the round cavity.

Lazily calculates the diameter from the cylindrical surface if not already computed.

Returns:

Diameter of the cavity

Return type:

float

property location: Point3D#

Get the center location of the round cavity.

Lazily calculates the center from the cylindrical surface axis if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

class volmdlr_tools.features.feature_types.cavities.SlottedCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a slotted cavity (obround/elongated cavity).

A slotted cavity consists of a combination of cylindrical surfaces and planar faces, typically forming a slot shape with rounded ends. Common in mechanical design for allowing adjustment along one axis.

Parameters:
  • obj – TopoDS_Shape representing the shape of the slotted cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

STANDARD_FACES_NUMBER = 4#
property axis: Vector3D#

Get the axis direction vector of the slotted cavity.

Lazily calculates the axis from the cylindrical surface if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property length: float#

Get the length of the slotted cavity.

Lazily calculates the length (distance between rounded ends) if not already computed.

Returns:

Length dimension of the cavity

Return type:

float

property location: Point3D#

Get the center location of the slotted cavity.

Lazily calculates the center from the bounding box of all faces if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

property width: float#

Get the width of the slotted cavity.

Lazily calculates the width (diameter of the rounded ends) if not already computed.

Returns:

Width dimension of the cavity

Return type:

float

class volmdlr_tools.features.feature_types.cavities.SquareCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a square cavity with equal width and length.

A square cavity is defined by four planar faces forming a square cross-section. The width and length are approximately equal (within tolerance of 1e-6).

Parameters:
  • obj – TopoDS_Shape representing the shape of the square cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

property axis: Vector3D#

Get the axis direction vector of the square cavity.

Lazily calculates the axis perpendicular to the square face if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property length: float#

Get the length of the square cavity.

Lazily calculates the length from face geometry if not already computed. For a square cavity, this should be approximately equal to the width.

Returns:

Length dimension of the cavity

Return type:

float

property location: Point3D#

Get the center location of the square cavity.

Lazily calculates the center point if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

property width: float#

Get the width of the square cavity.

Lazily calculates the width from face geometry if not already computed.

Returns:

Width dimension of the cavity

Return type:

float

volmdlr_tools.features.feature_types.sharp_edges module#

Sheet metal emboss module.

class volmdlr_tools.features.feature_types.sharp_edges.SharpEdge(obj: TopoDS_Shape, node: int, name: str = '')#

Bases: Edge

Emboss feature type.

Module contents#

Features types module.

class volmdlr_tools.features.feature_types.Blend(obj: TopoDS_Shape, node_id: int, blend_attribute: BlendAttribute, name: str = '')#

Bases: Feature

A class representing a blend.

class volmdlr_tools.features.feature_types.BlendChain(obj: TopoDS_Shape, nodes: list[int], cross_length: float, length: float, radius: float, name: str = '')#

Bases: Feature

A class representing a chain of blends.

classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Feature#

Create a BlendChain from a list of faces and a list of nodes.

Parameters:
  • faces – The faces to create the blend chain from.

  • nodes – The nodes to create the blend chain from.

  • name – The name of the blend chain.

Returns:

The BlendChain.

class volmdlr_tools.features.feature_types.Cavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Feature

Base class for representing cavities as shell objects.

A cavity is represented as a collection of faces that form a shell structure. This class serves as the foundation for more specific cavity types like round, square, rectangular, and slotted cavities.

MIN_FACES_ROUND_HOLE = 2#
MIN_FACES_SQUARE = 4#
property axis: Vector3D#

Get the axis direction vector of the cavity.

Returns:

Unit vector representing the cavity axis direction.

base_nodes: list[int]#
classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Cavity#

Factory method to create the appropriate cavity type from a list of faces.

Analyzes the surface types of the provided faces and creates the corresponding specialized cavity instance (RoundCavity, SquareCavity, RectangularCavity, or SlottedCavity).

Parameters:
  • faces – List of faces that define the cavity geometry.

  • nodes – List of nodes that define the cavity geometry.

  • name – Optional name for the cavity, defaults to empty string.

Returns:

Appropriate Cavity subclass instance based on face geometry.

property length: float#

Get the length of cavity.

Returns:

Length dimension of the cavity

Return type:

float

property location: Vector3D#

Get the center location of the cavity based on its bounding box.

Returns:

Center point of the cavity’s bounding box.

property width: float#

Get the width of the cavity.

Returns:

Width dimension of the cavity.

Return type:

float.

class volmdlr_tools.features.feature_types.CounterboreHole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Hole

Represents a counterbore hole (stepped hole).

A counterbore hole has two or more cylindrical sections with different diameters, typically used to allow a bolt head to sit flush with the surface.

The counterbore consists of: - Major section: larger diameter cylinder at the entry (for bolt head) - Minor section: smaller diameter cylinder (the bore itself) - Transition face: annular planar face connecting the two sections

property diameter: float#

Get the bore diameter (minor diameter) for compatibility with base class.

Returns:

Diameter of the bore (smaller cylindrical section).

property major_diameter: float#

Get the major (larger) diameter of the counterbore.

Returns:

Diameter of the larger cylindrical section.

property major_radius: float#

Get the major (larger) radius of the counterbore.

Returns:

Radius of the larger cylindrical section.

property minor_diameter: float#

Get the minor (smaller) diameter of the counterbore.

Returns:

Diameter of the smaller cylindrical section (the bore).

property minor_radius: float#

Get the minor (smaller) radius of the counterbore.

Returns:

Radius of the smaller cylindrical section (the bore).

property radius: float#

Get the bore radius (minor radius) for compatibility with base class.

Returns:

Radius of the bore (smaller cylindrical section).

class volmdlr_tools.features.feature_types.CounterdrillHole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Hole

Represents a counterdrill hole.

A counterdrill hole has three sections: - Entry section: small cylindrical pilot/guide at the surface - Conical section: tapered transition - Bore section: main cylindrical hole (larger than entry)

This is essentially a combination of counterbore and countersink features.

property bore_diameter: float#

Get the diameter of the main bore cylindrical section.

Returns:

Diameter of the bore.

property bore_radius: float#

Get the radius of the main bore cylindrical section.

Returns:

Radius of the bore.

property cone_angle: float#

Get the full cone angle in radians.

Returns:

Full cone angle (2 * semi-angle) in radians.

property cone_angle_degrees: float#

Get the full cone angle in degrees.

Returns:

Full cone angle in degrees.

property cone_semi_angle: float#

Get the semi-angle of the conical section in radians.

Returns:

Semi-angle of the cone in radians.

property diameter: float#

Get the bore diameter for compatibility with base class.

Returns:

Diameter of the main bore.

property entry_diameter: float#

Get the diameter of the entry (pilot) cylindrical section.

Returns:

Diameter of the entry section.

property entry_radius: float#

Get the radius of the entry (pilot) cylindrical section.

Returns:

Radius of the entry section.

property radius: float#

Get the bore radius for compatibility with base class.

Returns:

Radius of the main bore.

class volmdlr_tools.features.feature_types.CountersinkHole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Hole

Represents a countersink hole.

A countersink hole has a conical entry section combined with a cylindrical bore, typically used for flat-head screws.

The countersink consists of: - Conical section: tapered entry at the surface - Bore section: cylindrical hole below the cone

property bore_diameter: float#

Get the diameter of the cylindrical bore section.

Returns:

Diameter of the bore.

property bore_radius: float#

Get the radius of the cylindrical bore section.

Returns:

Radius of the bore.

property cone_angle: float#

Get the full cone angle in radians.

Returns:

Full cone angle (2 * semi-angle) in radians.

property cone_angle_degrees: float#

Get the full cone angle in degrees.

Returns:

Full cone angle in degrees.

property cone_semi_angle: float#

Get the semi-angle of the conical section in radians.

Returns:

Semi-angle of the cone in radians.

property diameter: float#

Get the bore diameter for compatibility with base class.

Returns:

Diameter of the bore.

property radius: float#

Get the bore radius for compatibility with base class.

Returns:

Radius of the bore.

class volmdlr_tools.features.feature_types.Feature(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Shape

Base class for all feature types.

category: FeatureCategory = 'unknown'#
classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', *args, **kwargs) Feature#

Create a Feature from a list of faces and a list of nodes.

class volmdlr_tools.features.feature_types.FeatureCategory(*values)#

Bases: str, Enum

High-level category of manufacturing features.

Attributes:

CUT: Material removal features (slots, notches, holes). FORMING: Deformation features (bends, jogs). BLEND: Fillet/chamfer features. CAVITY: Pocket/cavity features. UNKNOWN: Unclassified features.

BLEND = 'blend'#
CAVITY = 'cavity'#
CUT = 'cut'#
FORMING = 'forming'#
UNKNOWN = 'unknown'#
class volmdlr_tools.features.feature_types.Hole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Feature

Base class for representing hole features.

A hole is a cylindrical or conical cut feature typically created by drilling, boring, reaming, or similar machining operations. This class represents the geometric feature rather than the machining operation.

Attributes:

category: Feature category (CUT for material removal). base_nodes: List of face indices that form the base/entry faces.

property axis: Vector3D#

Get the axis direction vector of the hole.

Lazily calculates the axis from the cylindrical surface if not already computed.

Returns:

Unit vector representing the hole axis direction.

Return type:

Vector3D

category: FeatureCategory = 'cut'#
property depth: float#

Get the depth of the hole.

Lazily calculates the depth from the bounding box if not already computed.

Returns:

Depth of the hole along its axis.

Return type:

float

property diameter: float#

Get the diameter of the hole.

Returns:

Diameter of the hole (2 * radius).

Return type:

float

classmethod from_faces_and_nodes(faces: list[Face], nodes: list[int], name: str = '', has_entry_cone: bool = False, has_intermediate_cone: bool = False, *args, **kwargs) Hole#

Create the appropriate hole type from a list of faces.

Analyze the surface types of the provided faces and create the corresponding specialized hole instance (RoundHole, CounterboreHole, CountersinkHole, etc.).

Classification logic (based on cone position, not just cone presence): - CounterdrillHole: entry cylinder + intermediate cone + bore cylinder - CountersinkHole: entry cone (adjacent to base face) + cylindrical bore - CounterboreHole: multiple cylindrical sections with different radii (no entry/intermediate cone) - RoundHole: single radius cylindrical (may have bottom cone = drill point) - TaperHole: conical only (no cylindrical)

Note: Bottom cones (drill points at the end of blind holes) do NOT affect classification. They are distinguished from entry cones (countersinks) by not being adjacent to base faces.

Parameters:
  • faces – List of faces that define the hole geometry.

  • nodes – List of nodes that define the hole geometry.

  • name – Optional name for the hole, defaults to empty string.

  • has_entry_cone – True if hole has a cone adjacent to base face (countersink).

  • has_intermediate_cone – True if hole has a cone between cylinders of different radii (counterdrill).

Returns:

Appropriate Hole subclass instance based on face geometry.

property is_blind: bool#

Check if the hole is blind (closed at one end).

A blind hole has only one entry/base face, meaning it doesn’t pass through the material. Through holes have base faces on both ends.

Returns:

True if the hole is blind, False if it passes through.

Return type:

bool

property location: Point3D#

Get the center location of the hole.

Lazily calculates the center from the cylindrical surface axis if not already computed.

Returns:

Center point of the hole.

Return type:

Point3D

property radius: float#

Get the radius of the hole.

Lazily calculates the radius from the cylindrical surface if not already computed.

Returns:

Radius of the hole.

Return type:

float

class volmdlr_tools.features.feature_types.RectangularCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: SquareCavity

Represents a rectangular cavity with unequal width and length.

Inherits all functionality from SquareCavity but represents cavities where the width and length dimensions differ beyond the tolerance threshold (1e-6).

class volmdlr_tools.features.feature_types.RoundCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a circular/cylindrical cavity.

A round cavity is defined by one or two cylindrical surfaces and has properties like diameter, axis direction, and center location derived from the cylindrical geometry.

Parameters:
  • obj – TopoDS_Shape representing the shape of the round cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

property axis: Vector3D#

Get the axis direction vector of the round cavity.

Lazily calculates the axis from the cylindrical surface if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property diameter: float#

Get the diameter of the round cavity.

Lazily calculates the diameter from the cylindrical surface if not already computed.

Returns:

Diameter of the cavity

Return type:

float

property location: Point3D#

Get the center location of the round cavity.

Lazily calculates the center from the cylindrical surface axis if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

class volmdlr_tools.features.feature_types.RoundHole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Hole

Represents a simple cylindrical hole.

A round hole is defined by one or more cylindrical surfaces and optionally a planar bottom face for blind holes. This is the most common hole type.

class volmdlr_tools.features.feature_types.SharpEdge(obj: TopoDS_Shape, node: int, name: str = '')#

Bases: Edge

Emboss feature type.

class volmdlr_tools.features.feature_types.SlottedCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a slotted cavity (obround/elongated cavity).

A slotted cavity consists of a combination of cylindrical surfaces and planar faces, typically forming a slot shape with rounded ends. Common in mechanical design for allowing adjustment along one axis.

Parameters:
  • obj – TopoDS_Shape representing the shape of the slotted cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

STANDARD_FACES_NUMBER = 4#
property axis: Vector3D#

Get the axis direction vector of the slotted cavity.

Lazily calculates the axis from the cylindrical surface if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property length: float#

Get the length of the slotted cavity.

Lazily calculates the length (distance between rounded ends) if not already computed.

Returns:

Length dimension of the cavity

Return type:

float

property location: Point3D#

Get the center location of the slotted cavity.

Lazily calculates the center from the bounding box of all faces if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

property width: float#

Get the width of the slotted cavity.

Lazily calculates the width (diameter of the rounded ends) if not already computed.

Returns:

Width dimension of the cavity

Return type:

float

class volmdlr_tools.features.feature_types.SquareCavity(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Cavity

Represents a square cavity with equal width and length.

A square cavity is defined by four planar faces forming a square cross-section. The width and length are approximately equal (within tolerance of 1e-6).

Parameters:
  • obj – TopoDS_Shape representing the shape of the square cavity.

  • nodes – List of face indices that form the cavity.

  • name – Optional name for the cavity, defaults to empty string.

property axis: Vector3D#

Get the axis direction vector of the square cavity.

Lazily calculates the axis perpendicular to the square face if not already computed.

Returns:

Unit vector representing the cavity axis direction

Return type:

Vector3D

property length: float#

Get the length of the square cavity.

Lazily calculates the length from face geometry if not already computed. For a square cavity, this should be approximately equal to the width.

Returns:

Length dimension of the cavity

Return type:

float

property location: Point3D#

Get the center location of the square cavity.

Lazily calculates the center point if not already computed.

Returns:

Center point of the cavity

Return type:

Point3D

property width: float#

Get the width of the square cavity.

Lazily calculates the width from face geometry if not already computed.

Returns:

Width dimension of the cavity

Return type:

float

class volmdlr_tools.features.feature_types.TaperHole(obj: TopoDS_Shape, nodes: list[int], name: str = '')#

Bases: Hole

Represents a tapered/conical hole.

A taper hole is purely conical, often used for tapered pins or special fastening applications.