volmdlr_tools.features package#
The features package provides tools for feature recognition and extraction from BRep models.
Subpackages#
- volmdlr_tools.features.extractors package
- Submodules
- volmdlr_tools.features.extractors.core module
FeatureExtractorInnerFeaturesExtractorInnerFeaturesExtractor.extract()InnerFeaturesExtractor.get_features_faces()InnerFeaturesExtractor.is_angle_type_valid()InnerFeaturesExtractor.is_concave_through()InnerFeaturesExtractor.is_convex_through()InnerFeaturesExtractor.is_feature_valid()InnerFeaturesExtractor.is_invalid_base_neighbor()InnerFeaturesExtractor.propagate()
- volmdlr_tools.features.extractors.blend module
BlendExtractorBlendExtractor.calculate_chain_length()BlendExtractor.compute_blend_length()BlendExtractor.display_result()BlendExtractor.dye_blending_faces()BlendExtractor.find_cross_edges()BlendExtractor.find_smooth_edges()BlendExtractor.find_smooth_edges_for_face()BlendExtractor.find_spring_edges()BlendExtractor.find_terminating_edges()BlendExtractor.get_blend()BlendExtractor.get_blending_chains_faces()BlendExtractor.get_blending_faces()BlendExtractor.get_blends()BlendExtractor.get_chains()BlendExtractor.idsBlendExtractor.of_reading()BlendExtractor.perform()BlendExtractor.shapeBlendExtractor.terminating_edges_to_cross_edges()
BlendReadingRecognizeBlendsfaces_beyond_blends()fills_the_foot()is_blend_face()is_tangent_to()read_blends()rim_blends_among_faces()tangent_blends()tangent_chains()tangent_neighbors()
- volmdlr_tools.features.extractors.blend_roots module
- volmdlr_tools.features.extractors.blend_roles module
- volmdlr_tools.features.extractors.virtual_loops module
FaceGroupLoopRecognitionLoopRecognition.blend_face_idsLoopRecognition.blend_rolesLoopRecognition.blend_sidesLoopRecognition.face_groupsLoopRecognition.faces_beyond()LoopRecognition.graphLoopRecognition.group_of()LoopRecognition.groupsLoopRecognition.inner_loops()LoopRecognition.length_of()LoopRecognition.loopsLoopRecognition.loops_along()LoopRecognition.loops_of_group()LoopRecognition.open_junctionsLoopRecognition.outer_loops()LoopRecognition.root_blends()LoopRecognition.sense()LoopRecognition.sense_and_faces_beyond()
LoopRecognitionErrorOpenJunctionRecognisedLoopTrimTrimIndexboundary_chains()chain_loop()loop_turning()loops_met()recognise_loops()
- volmdlr_tools.features.extractors.depression_protrusion module
DepressionProtrusionDepressionProtrusion.base_face_idsDepressionProtrusion.blend_face_idsDepressionProtrusion.circularDepressionProtrusion.enclosed_face_idsDepressionProtrusion.end_face_idsDepressionProtrusion.interruption_face_idsDepressionProtrusion.junction_edge_idsDepressionProtrusion.kindDepressionProtrusion.loopDepressionProtrusion.parentDepressionProtrusion.rim_chamfer_face_idsDepressionProtrusion.side_face_idsDepressionProtrusion.stepsDepressionProtrusion.subtypeDepressionProtrusion.through
recognise_depressions_and_protrusions()
- volmdlr_tools.features.extractors.hole_steps module
HoleGeometryHoleGeometry.axis()HoleGeometry.common_axis()HoleGeometry.edge_points()HoleGeometry.face_points()HoleGeometry.gap_faces()HoleGeometry.hole_wall()HoleGeometry.is_torus()HoleGeometry.one_hole()HoleGeometry.radius_range()HoleGeometry.same_axis()HoleGeometry.span()HoleGeometry.step_shape()HoleGeometry.steps()HoleGeometry.surface()HoleGeometry.trims
HoleSpanHoleStepname_steps()
- volmdlr_tools.features.extractors.isolated_boss_splitter module
ShapeIsolatedBossSplitterShapeIsolatedBossSplitter.aagShapeIsolatedBossSplitter.blendsShapeIsolatedBossSplitter.face_mapShapeIsolatedBossSplitter.get_extruded_features()ShapeIsolatedBossSplitter.get_shape()ShapeIsolatedBossSplitter.get_shapes()ShapeIsolatedBossSplitter.loopsShapeIsolatedBossSplitter.merge_into_parent()ShapeIsolatedBossSplitter.open_junctions_cutShapeIsolatedBossSplitter.perform()ShapeIsolatedBossSplitter.resultShapeIsolatedBossSplitter.seam_face_ids
SplitBoundarySplitSet
- volmdlr_tools.features.extractors.cavity module
CavityExtractorCavityExtractor.display_result()CavityExtractor.find_seeds()CavityExtractor.get_cavities()CavityExtractor.ids_pocketsCavityExtractor.is_angle_valid()CavityExtractor.is_feature_valid()CavityExtractor.is_invalid_base_neighbor()CavityExtractor.is_seed_valid()CavityExtractor.perform()CavityExtractor.recognize_cavities()CavityExtractor.shape
RecognizeCavities
- volmdlr_tools.features.extractors.sharp_edge module
- volmdlr_tools.features.extractors.deformation module
- volmdlr_tools.features.extractors.sheet_metal module
DeformationExtractorRegionDeformationExtractorSheetMetalFeatureClassifierSheetMetalFeatureExtractorSheetMetalFeatureExtractor.FLAT_HEM_GAP_RATIOSheetMetalFeatureExtractor.FOLD_END_TOLERANCE_RATIOSheetMetalFeatureExtractor.FOLD_READINGSSheetMetalFeatureExtractor.FOLD_SKINSSheetMetalFeatureExtractor.HEM_ANGLE_TOLERANCESheetMetalFeatureExtractor.MINIMUM_CURL_ANGLESheetMetalFeatureExtractor.MIN_FACES_FOR_MIRRORINGSheetMetalFeatureExtractor.boundary_featuresSheetMetalFeatureExtractor.extract_all_bendings()SheetMetalFeatureExtractor.extract_boundary_features()SheetMetalFeatureExtractor.extract_internal_features()SheetMetalFeatureExtractor.get_connected_concave_subchains()SheetMetalFeatureExtractor.get_external_subchains_groups()SheetMetalFeatureExtractor.get_internal_subchains_groups()SheetMetalFeatureExtractor.get_mirror_internal_subchains()SheetMetalFeatureExtractor.internal_featuresSheetMetalFeatureExtractor.perform()
- volmdlr_tools.features.extractors.feature_classifier module
- volmdlr_tools.features.extractors.ribs module
- volmdlr_tools.features.extractors.rib_edge_pairs module
- Module contents
BlendExtractorBlendExtractor.calculate_chain_length()BlendExtractor.compute_blend_length()BlendExtractor.display_result()BlendExtractor.dye_blending_faces()BlendExtractor.find_cross_edges()BlendExtractor.find_smooth_edges()BlendExtractor.find_smooth_edges_for_face()BlendExtractor.find_spring_edges()BlendExtractor.find_terminating_edges()BlendExtractor.get_blend()BlendExtractor.get_blending_chains_faces()BlendExtractor.get_blending_faces()BlendExtractor.get_blends()BlendExtractor.get_chains()BlendExtractor.idsBlendExtractor.of_reading()BlendExtractor.perform()BlendExtractor.shapeBlendExtractor.terminating_edges_to_cross_edges()
CavityExtractorCavityExtractor.display_result()CavityExtractor.find_seeds()CavityExtractor.get_cavities()CavityExtractor.ids_pocketsCavityExtractor.is_angle_valid()CavityExtractor.is_feature_valid()CavityExtractor.is_invalid_base_neighbor()CavityExtractor.is_seed_valid()CavityExtractor.perform()CavityExtractor.recognize_cavities()CavityExtractor.shape
ChamferExtractorCoaxialFeatureExtractorMixinConeExtractorCylinderExtractorDeformationExtractorExtractionModeHoleExtractorInteractingFeatureExtractorInteractingFeatureExtractor.befg_classificationsInteractingFeatureExtractor.befgsInteractingFeatureExtractor.blend_extractorInteractingFeatureExtractor.blend_node_idsInteractingFeatureExtractor.chamfer_node_idsInteractingFeatureExtractor.feature_nodesInteractingFeatureExtractor.hierarchyInteractingFeatureExtractor.hole_featuresInteractingFeatureExtractor.interactionsInteractingFeatureExtractor.nefg_classificationsInteractingFeatureExtractor.nefgsInteractingFeatureExtractor.perform()InteractingFeatureExtractor.resultInteractingFeatureExtractor.shapeInteractingFeatureExtractor.stock_end_facesInteractingFeatureExtractor.stock_faces
IsolatedFeatureExtractorIsolatedFeatureExtractor.check_inner_boundary_inclusion()IsolatedFeatureExtractor.extract_contours()IsolatedFeatureExtractor.extract_contours_multi_seed()IsolatedFeatureExtractor.extract_contours_single_seed()IsolatedFeatureExtractor.get_boundary_wires_from_seeds()IsolatedFeatureExtractor.get_components_if_separable()IsolatedFeatureExtractor.get_edge_vertices()IsolatedFeatureExtractor.get_face_wires()IsolatedFeatureExtractor.get_forbidden_neighbors()IsolatedFeatureExtractor.get_inner_wires()IsolatedFeatureExtractor.get_wire_vertices()IsolatedFeatureExtractor.recognize()
PlanarTrimExtractorRegionDeformationExtractorRevolutionFacesExtractorRibExtractorShapeIsolatedBossSplitterShapeIsolatedBossSplitter.aagShapeIsolatedBossSplitter.blendsShapeIsolatedBossSplitter.face_mapShapeIsolatedBossSplitter.get_extruded_features()ShapeIsolatedBossSplitter.get_shape()ShapeIsolatedBossSplitter.get_shapes()ShapeIsolatedBossSplitter.loopsShapeIsolatedBossSplitter.merge_into_parent()ShapeIsolatedBossSplitter.open_junctions_cutShapeIsolatedBossSplitter.perform()ShapeIsolatedBossSplitter.resultShapeIsolatedBossSplitter.seam_face_ids
SharpEdgeExtractorSplitAdjacencyExtractorSplitSetTorusExtractor
- volmdlr_tools.features.feature_types package
- Subpackages
- volmdlr_tools.features.feature_types.sheet_metal package
- Submodules
- volmdlr_tools.features.feature_types.sheet_metal.bends module
- volmdlr_tools.features.feature_types.sheet_metal.corners module
- volmdlr_tools.features.feature_types.sheet_metal.hooks module
- volmdlr_tools.features.feature_types.sheet_metal.jogs module
- volmdlr_tools.features.feature_types.sheet_metal.notches module
- volmdlr_tools.features.feature_types.sheet_metal.perforations module
- volmdlr_tools.features.feature_types.sheet_metal.reliefs module
- volmdlr_tools.features.feature_types.sheet_metal.lances module
- volmdlr_tools.features.feature_types.sheet_metal.louvres module
- volmdlr_tools.features.feature_types.sheet_metal.deformations module
- volmdlr_tools.features.feature_types.sheet_metal.gussets module
- volmdlr_tools.features.feature_types.sheet_metal.unknown module
- Module contents
- volmdlr_tools.features.feature_types.sheet_metal package
- Submodules
- volmdlr_tools.features.feature_types.core module
FeatureFeature.base_nodesFeature.categoryFeature.copy()Feature.crossing_passagesFeature.dict_to_object()Feature.feature_typeFeature.floor_nodeFeature.floor_piecesFeature.from_aag()Feature.from_faces_and_nodes()Feature.groups_member_featuresFeature.inside_bevel_nodesFeature.merged_partsFeature.nodesFeature.placementFeature.rim_blend_nodesFeature.to_dict()Feature.topology
InnerFeatureREPR_LENGTH_LIMITREPR_NODES_LIMITREPR_UNCOMPUTABLEREPR_VALUE_LENGTH_LIMITRoundInnerFeatureSquareInnerFeature
- volmdlr_tools.features.feature_types.blends module
- volmdlr_tools.features.feature_types.cavities module
CavityCavity.BENT_SIDE_WALL_PLANESCavity.MIN_BENT_END_CAPSCavity.MIN_FACES_ROUND_HOLECavity.MIN_FACES_SQUARECavity.MIN_SLOT_END_CYLINDERSCavity.SLOT_WALL_DIRECTION_COUNTCavity.SQUARE_WALL_DIRECTION_COUNTCavity.bent_cutout_type()Cavity.categoryCavity.cavity_axis()Cavity.corner_radiusCavity.depthCavity.feature_typeCavity.from_faces_and_nodes()Cavity.topology
EndCirclePolygonalCavityRectangularCavityRoundCavitySectorCavitySectorShapeSlottedCavitySquareCavitycavity_axis_from_faces()prismatic_axis()regular_polygon_outline()sector_shape()
- volmdlr_tools.features.feature_types.sharp_edges module
- volmdlr_tools.features.feature_types.ribs module
- Module contents
AnnularGrooveBlendBlendChainBlindSlotBlindStepCavityCavity.BENT_SIDE_WALL_PLANESCavity.MIN_BENT_END_CAPSCavity.MIN_FACES_ROUND_HOLECavity.MIN_FACES_SQUARECavity.MIN_SLOT_END_CYLINDERSCavity.SLOT_WALL_DIRECTION_COUNTCavity.SQUARE_WALL_DIRECTION_COUNTCavity.bent_cutout_type()Cavity.categoryCavity.cavity_axis()Cavity.corner_radiusCavity.depthCavity.feature_typeCavity.from_faces_and_nodes()Cavity.topology
ChamferChamferAttributeChamferChainCounterboreHoleCounterdrillHoleCounterdrillHole.bore_diameterCounterdrillHole.bore_radiusCounterdrillHole.cone_angleCounterdrillHole.cone_angle_degreesCounterdrillHole.cone_semi_angleCounterdrillHole.diameterCounterdrillHole.entry_diameterCounterdrillHole.entry_radiusCounterdrillHole.feature_typeCounterdrillHole.intermediate_cone_angleCounterdrillHole.radius
CountersinkHoleCylinderEndCircleExtrusionExtrusionParametersFeatureFeature.base_nodesFeature.categoryFeature.copy()Feature.crossing_passagesFeature.dict_to_object()Feature.feature_typeFeature.floor_nodeFeature.floor_piecesFeature.from_aag()Feature.from_faces_and_nodes()Feature.groups_member_featuresFeature.inside_bevel_nodesFeature.merged_partsFeature.nodesFeature.placementFeature.rim_blend_nodesFeature.to_dict()Feature.topology
FeatureCategoryHoleHole.access_directionHole.axisHole.categoryHole.depthHole.diameterHole.drill_pointHole.entry_blend_radiusHole.extrusion_heightHole.face_type_countsHole.feature_typeHole.floor_blend_radiusHole.from_faces_and_nodes()Hole.is_blindHole.locationHole.originHole.radiusHole.revolution_frameHole.revolution_profileHole.revolved_solid()Hole.set_cached_properties()Hole.topology
MultiRadiusHoleOpenPocketOutlineCutPlanarTrimPocketPolygonalCavityRectangularCavityRevolutionFeatureRibRibStructureRoundCavityRoundHoleSectorCavitySharpEdgeSlotSlottedCavitySquareCavityStepSteppedHoleTaperHoleThroughSlotTorusUnknownFeature
- Subpackages
- volmdlr_tools.features.classification package
- Submodules
- volmdlr_tools.features.classification.registry module
- volmdlr_tools.features.classification.matcher module
- volmdlr_tools.features.classification.rules module
CompositeFeatureRuleCompositeFeatureRule.boundary_subchainsCompositeFeatureRule.d1_greater_d2CompositeFeatureRule.descriptionCompositeFeatureRule.fan_shaped_facesCompositeFeatureRule.fan_shaped_pairsCompositeFeatureRule.feature_classCompositeFeatureRule.internal_chainsCompositeFeatureRule.nameCompositeFeatureRule.opposite_normalsCompositeFeatureRule.share_common_face
CutFeatureRuleCutFeatureRule.all_angles_concaveCutFeatureRule.cut_into_edgeCutFeatureRule.cylindrical_surfacesCutFeatureRule.descriptionCutFeatureRule.different_radius_valuesCutFeatureRule.feature_classCutFeatureRule.fold_directionsCutFeatureRule.nameCutFeatureRule.parallel_planar_pairsCutFeatureRule.planar_surfacesCutFeatureRule.total_facesCutFeatureRule.type_of_chain
DeformFeatureRule
- Module contents
CompositeFeatureRuleCompositeFeatureRule.boundary_subchainsCompositeFeatureRule.d1_greater_d2CompositeFeatureRule.descriptionCompositeFeatureRule.fan_shaped_facesCompositeFeatureRule.fan_shaped_pairsCompositeFeatureRule.feature_classCompositeFeatureRule.internal_chainsCompositeFeatureRule.nameCompositeFeatureRule.opposite_normalsCompositeFeatureRule.share_common_face
CutFeatureRuleCutFeatureRule.all_angles_concaveCutFeatureRule.cut_into_edgeCutFeatureRule.cylindrical_surfacesCutFeatureRule.descriptionCutFeatureRule.different_radius_valuesCutFeatureRule.feature_classCutFeatureRule.fold_directionsCutFeatureRule.nameCutFeatureRule.parallel_planar_pairsCutFeatureRule.planar_surfacesCutFeatureRule.total_facesCutFeatureRule.type_of_chain
DeformFeatureRuleFeatureRuleRegistryRuleMatcher
- volmdlr_tools.features.measurements package
- Submodules
- volmdlr_tools.features.measurements.ribs module
- volmdlr_tools.features.measurements.distances module
- volmdlr_tools.features.measurements.flat_pattern module
- volmdlr_tools.features.rules package
- Submodules
- volmdlr_tools.features.rules.core module
- volmdlr_tools.features.rules.stamping module
- volmdlr_tools.features.reverse_engineering package
- Compute engines
BlendClassificationClassifiedProfileOutlineChainProfileExtractorProfileModeVentingblends_drawn_by_arcs_about()blends_drawn_on_profile()classify_blends()classify_profile_wire()classify_venting()clearance_for()compute_access_direction()compute_axis()compute_depth()compute_sweep_axis()compute_sweep_length()extract_profile()profile_frame()profile_origin()round_axis()rounds_turning_about()sweep_is_prismatic()synthesize_entry_face()trace_walls()venting_and_clearance()walls_stand_along()
- Profile extraction and shape recognition
- Compute engines
Submodules#
volmdlr_tools.features.part_reading module#
One reading of a part, made once and handed to every reader of the part.
Each way of recognising how a part was built starts from the same facts about it: which faces
touch which and along which edges, which faces are blends, which closed loops of edges bound
its regions, how large the part is and which directions it was built along. A PartReading
reads each of those facts the first time a reader asks for it and keeps it, so that a part is read
once however many readers try it, and every reader numbers faces and edges the way the part’s
adjacency graph does.
- class volmdlr_tools.features.part_reading.PartReading(shape: Shape, *, aag: AttributedAdjacencyGraph | None = None, blends: BlendReading | None = None)#
Bases:
objectWhat every reader reads off one part, each fact read the first time it is asked for.
Faces and edges are numbered as the part’s adjacency graph numbers them, face
ibeing nodei. A reading belongs to the copy of the part it was made from, at that copy’s scale, and to the process that made it: it cannot be pickled, so a part handed to another process is read again there.What the package’s readers keep of it between calls (
_memo,_memo_for) is package-internal; each module keys its caches by a key it owns.- Parameters:
shape – The part: one solid with faces, alone or as the only thing in a compound.
aag – The part’s adjacency graph, when the caller has one already: read with every edge convex or concave, it is
sharp_aag; read with tangent edges smooth, it isaag. Faces and edges are numbered alike either way.blends – The part’s blends, when the caller has read them already; see
blends.
- Raises:
ShapeTypeError – When shape is not a shape, or holds no solid, several, or faces beside its solid.
ValueError – When the solid has no faces, or aag is the graph of another part.
- property aag: AttributedAdjacencyGraph#
The part’s adjacency graph, every edge of it carrying the angle at which its two faces meet.
The graph belongs to the reading and is shared by every reader handed it: a reader reads it and marks nothing on it, and nothing in the reading marks it either. A reader that reads blends off a graph’s nodes, or leaves marks of its own, works on
BlendReading.marked(), a copy of its own.
- area_of(faces: Iterable[int]) float#
Return the area of faces added up in the order given.
- Raises:
IndexError – When a face is no face of the part.
- property axis_candidates: tuple[AxisCandidate, ...]#
The lines the part’s rotational faces turn about, largest turning area first; see
axis_candidates().
- property blends: BlendReading#
The faces that are blends, each with what it blends, read once and the same for every reader.
Free-form faces are read by their curvature over their whole extent, so that the blends of a moulded part are found as well as those of a machined one. Reading them marks nothing on
aag; a reader that wants fewer counts them up to a smaller radius withBlendReading.within(). They are read offsharp_aag, whichever graph was read first.
- property dominant_axes: tuple[AxisCluster, ...]#
The directions the part’s faces were built along, strongest first; see
dominant_axes().
- property face_areas: tuple[float, ...]#
The area of every face of the part, face
iat indexi, measured once and shared by every reader.A face whose area cannot be evaluated reads as zero, with a warning. A face’s area here is the area either adjacency graph of the part gives it.
- property face_count: int#
How many faces the part has.
- property face_tolerance: float#
How far apart two faces, surfaces or thicknesses of the part may be and count as one.
A fixed multiple of
tolerance: their lengths come from exact geometry read in different ways.
- property fitted_size: float#
The diagonal of the box fitted tightly to the part’s faces, whether or how finely the part was meshed.
- property loops: LoopRecognition#
The closed loops of edges bounding regions of the part, read once with the part’s blends.
Each loop is a single loop of one face, a virtual loop over several faces joined tangentially, or a multivirtual loop over several groups of faces; the recognition says which way each one bounds a feature, the faces across it and the blends rounding its root, and lists the open junctions between bodies of the part. They are read off a copy of
sharp_aagmarked with exactlyblendsand are numbered as the faces and edges ofaagare; reading them marks nothing onaagorsharp_aag.- Raises:
LoopRecognitionError – When the boundary of a group of faces does not close, which happens only on a part whose faces are not oriented consistently.
- neighbours(face: int) frozenset[int]#
Return the faces sharing an edge with face; none for a face that touches no other.
- Raises:
IndexError – When face is no face of the part.
- pieces(faces: Iterable[int], *, joins: Callable[[int, int], bool] | None = None) tuple[frozenset[int], ...]#
Split faces into the pieces they make, two faces being in one piece when an edge joins them.
Pieces come in the order of their smallest face.
- Parameters:
faces – The faces to split.
joins – Whether two faces sharing an edge are in one piece; every such pair is when not given.
- Raises:
IndexError – When a face is no face of the part.
- region_scope(region: Iterable[int] | None) tuple[frozenset[int], frozenset[int]]#
Return the faces of a region to read and the faces to look at to read them: the region and its neighbours.
- Parameters:
region – Faces of the part, numbered as
aagnumbers them; the whole part whenNone.- Returns:
The faces of the region, and the faces of the region with every face next to one of them; both the whole part for no region.
- Raises:
ValueError – When region holds no face.
IndexError – When a face of region is no face of the part.
- property shape: Shape#
The part read.
- property sharp_aag: AttributedAdjacencyGraph#
The part’s adjacency graph with every edge read as convex or concave, even where two faces meet tangent.
It is the graph the feature readers read: a fillet’s edges then say which way the fillet turns. Its faces and edges are numbered as
aagnumbers them, and it is shared asaagis: a reader writes nothing on it, and reads blends only off a copy of it whose blend marks are exactlyblends, whatever blend marks a caller left on this graph. Handed one, the reading reads its faces and edges off it and builds no graph of its own untilaagis asked for.
- property size: float#
The diagonal of a box holding the part, not fitted tightly to its faces.
It is the length the techniques that measure the part by such a box take their tolerances and reaches from. The techniques that measure it by the box fitted tightly to its faces read that box themselves.
- property tolerance: float#
How far apart two points of the part may be and count as one, when a curve is fitted to its sections.
A fixed fraction of
fitted_size, so that the same reading suits a part modelled in millimetres and one modelled in metres.
- volmdlr_tools.features.part_reading.shape_index(reading: PartReading) ShapeIndex#
Return the part’s own faces, edges and vertices, numbered as its adjacency graph numbers them.
The reading names faces only by their number. This is for the code that measures the part’s faces and edges themselves, such as the reconstruction techniques; it is not part of what the package offers its callers.
volmdlr_tools.features.axes module#
The directions a part was built along, read from the axes and normals of its analytic faces.
A part built by sweeping, revolving or extruding leaves its construction direction on its faces: rotational faces
share an axis, extruded faces share a direction, and the flat faces capping them are perpendicular to it.
dominant_axes() clusters those directions, and axis_candidates() the lines the rotational faces turn
about, so that a reader knows which planes are worth cutting the part with and which lines it may turn about.
- volmdlr_tools.features.axes.AXIS_ANGLE_TOLERANCE = 0.008726646259971648#
Largest angle, in radians, between two directions that count as one axis.
- class volmdlr_tools.features.axes.AxisCandidate(origin: tuple[float, float, float], direction: tuple[float, float, float], face_count: int, area: float, tolerance: float = 0.0)#
Bases:
objectA line about which several faces of the part turn.
directionis a unit vector whose largest component is positive andoriginthe point of the line nearest the centre of the part’s bounding box.areais the area of theface_countfaces that turn about it.toleranceis how far a point may be from the line and count as on it,0when it is not set; the methods measure in the axes(t, r)of a meridian,talong the line fromoriginandraway from it. Candidates compare and hash by value.- property direction_vector: ndarray#
The direction as an array, to calculate with.
- holds(point: ndarray) bool#
Whether point lies on the axis.
- property origin_vector: ndarray#
The origin as an array, to calculate with.
- r_of(point: ndarray) float#
Distance of point from the axis.
- t_of(point: ndarray) float#
Distance of point along the axis from its origin.
- class volmdlr_tools.features.axes.AxisCluster(direction: tuple[float, float, float], face_ids: tuple[int, ...], axial_count: int, plane_count: int, area: float)#
Bases:
objectA direction shared by several faces.
directionis a unit vector whose largest component is positive; it names a line, not an arrow.face_idsare the faces that voted for it, numbered as the faces of the part’s adjacency graph are.axial_countcounts the faces whose axis it is, those turning about the direction or extruded along it,plane_countthe flat faces perpendicular to it, andareais the area of all the faces together. Clusters compare and hash by value.
- volmdlr_tools.features.axes.PARALLEL_SINE = 1e-06#
Directions closer than this (as a sine) are parallel.
- volmdlr_tools.features.axes.RELATIVE_TOL = 1e-05#
The largest deviation a fitted arc may have from its samples, relative to the part’s size. Spline approximations of circles in files from other systems stray about 4e-6 of the diagonal and must still read as arcs.
- volmdlr_tools.features.axes.axis_candidates(shape: Shape, *, tol: float | None = None) tuple[AxisCandidate, ...]#
Return the lines the part’s rotational faces turn about, largest turning area first.
Every cylinder, cone, torus and surface of revolution votes with its axis line; faces whose axes are parallel and lie on one line make one candidate. A sphere adds its area to the candidates that pass through its centre. A sphere no candidate passes through turns about any line through its centre: it makes a candidate of its own, along the line square to the other axes when they lie in one plane, and along the strongest of them otherwise.
- Parameters:
shape – the part to read.
tol – largest distance between two axes that count as one line. Defaults to a fixed multiple of the fitting tolerance of shape.
- volmdlr_tools.features.axes.axis_foot(point: ndarray, origin: ndarray, direction: ndarray) ndarray#
Return the point of the axis through origin along the unit direction that is nearest point.
- volmdlr_tools.features.axes.canonical_axis(direction: Sequence[float] | ndarray) ndarray#
Return direction as a unit vector whose largest component is positive: the line, not the arrow.
- volmdlr_tools.features.axes.coordinate_array(item: gp_Pnt | gp_Dir | gp_Vec | gp_XYZ) ndarray#
Return the coordinates of a point, direction or vector as an array.
- volmdlr_tools.features.axes.default_face_tolerance(shape: Shape) float#
Return the tolerance for comparing the faces of shape: a fixed multiple of its fitting tolerance.
- volmdlr_tools.features.axes.default_tolerance(shape: Shape) float#
Return the tolerance for fitting the sections of shape: a fixed fraction of its diagonal.
- volmdlr_tools.features.axes.dominant_axes(shape: Shape, angle_tolerance: float = 0.008726646259971648) tuple[AxisCluster, ...]#
Cluster the construction directions of shape’s faces, strongest first.
Every cylinder, cone, torus and surface of revolution votes with its axis, every linear extrusion with its direction, and every plane with its normal as a separate, weaker vote. Faces are taken in order; a direction within angle_tolerance of a cluster’s area-weighted mean so far, in either sense, joins the first such cluster. Clusters are sorted by axial count, then by area.
- Parameters:
shape – the part to read.
angle_tolerance – largest angle, in radians, between two directions that count as one axis.
- volmdlr_tools.features.axes.exactly_parallel(first: Sequence[float] | ndarray, second: Sequence[float] | ndarray) bool#
Tell whether two unit directions lie along one line, in either sense, as exact geometry read twice does.
The test is far tighter than
parallel(): it tells the directions of exact surfaces apart, not the directions a reader fitted.
- volmdlr_tools.features.axes.group_axis_lines(lines: Sequence[tuple[ndarray, ndarray]], tol: float) list[list[int]]#
Group lines, each a point and a unit direction, that are one line; return the indices in each group.
A line joins the first group whose first line is parallel to it, to within the angle tolerance shared by the techniques, and passes within tol of its point; otherwise it starts a group.
- volmdlr_tools.features.axes.lies_on_a_circle_about(points: ndarray, origin: ndarray, direction: ndarray, tolerance: float) bool#
Tell whether points lie on one circle about the axis through origin along the unit direction.
They do when they are all at one height along the axis and one distance from it, to within tolerance.
- volmdlr_tools.features.axes.meridian_coordinates(points: ndarray, origin: ndarray, direction: ndarray) ndarray#
Return 3D points as rows
(t, r)about the axis through origin along the unit direction.tis the position along the axis from origin andrthe distance from the axis.
- volmdlr_tools.features.axes.parallel(first: Sequence[float] | ndarray, second: Sequence[float] | ndarray, angle_tolerance: float = 0.008726646259971648) bool#
Tell whether two unit directions lie along one line, in either sense, to within angle_tolerance radians.
- volmdlr_tools.features.axes.part_diagonal(shape: Shape) float#
Return the diagonal of the tight box around shape’s exact geometry.
The box does not depend on whether, or how finely, the part has been meshed.
- volmdlr_tools.features.axes.radial_offsets(points: ndarray, origin: ndarray, direction: ndarray) ndarray#
Return the offset of each of points from the axis through origin along the unit direction.
Each row is the vector from the point of the axis nearest the point to the point, square to the axis.
- volmdlr_tools.features.axes.same_line(point: ndarray, axis: ndarray, other_point: ndarray, other_axis: ndarray, tolerance: float) bool#
Tell whether two lines, each a point and a unit direction, are one line to within tolerance.
The directions are compared as
exactly_parallel()does, and the point of the first line must lie within tolerance of the second.
- volmdlr_tools.features.axes.sine(first: Sequence[float] | ndarray, second: Sequence[float] | ndarray) float#
Return the sine of the angle between two vectors, scaled by their lengths: the length of their cross product.
- volmdlr_tools.features.axes.vector_tuple(vector: ndarray) tuple[float, float, float]#
Return the coordinates of a point or vector as a tuple of floats.
volmdlr_tools.features.core module#
Feature recognition module.
- class volmdlr_tools.features.core.FeatureCounts(counts: dict[str, int], extractions_run: set[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']])#
Bases:
dictPer-type feature counts, carrying the extractions they were counted over.
A
dictso every existing caller keeps working, plus the one fact a bare count table cannot carry: what was looked for.{"Blend": 0}with"blends"inextractions_runsays the part has no fillets; no"Blend"key at all says nobody ranFeatureProcessor.extract_blends().
- class volmdlr_tools.features.core.FeatureProcessor(shape: Shape, aag: AttributedAdjacencyGraph | None = None, name: str = '')#
Bases:
DessiaObjectRecognise a part’s features, and hold what was recognised.
There are two ways in:
recognise()reads every family of features at once and returns aRecognitionDocument: each feature as a record, every face of the part accounted for, and every reading set aside given as a refusal. Start here.extract_*reads one family, asextract_blends()orextract_sheet_metal_features(), and stores its features for the typed getters (holes,blends,bends, …), which refuse withUnextractedAccessErroruntil an extraction that fills them has run.
Both read the same part:
part_readingholds its graphs and its blends (blend_reading), read once and handed to every reading, so the document and the getters agree on which faces are blends, unlessextract_blends()is asked for another radius.aag, read by default with every edge convex or concave, is the reading’ssharp_aag; the reading’s ownaagis the graph read with tangent edges smooth.- property all_features: list[Feature]#
Every feature in the registry, whatever its class.
The registry is keyed by class; callers that must sweep all of them (validation rulebooks, reports) should read this rather than reimplementing the walk over the private dict.
The features another one owns are left out: the holes of a perforation (in its
holes) and the bends of a jog or a lance (in itsbends). A caller that must reach every opening and every bend expands them withwith_perforation_holes()andwith_held_folds().- Returns:
All extracted features.
- property beads: list[Bead]#
Get extracted beads: ribs pressed into the sheet along a path of straight runs and arcs.
Refuses until
extract_deformations()is called.
- property bends: list[Bend]#
Get extracted bend features.
Only the bends reported as features of their own: the bends a jog or a lance owns are held in its
bendsinstead. For every bend of the part, usebend_features()(orwith_held_folds()for every fold) overall_features.- Returns:
List of Bend objects.
- property blend_chains: list[BlendChain]#
Get extracted blend chains.
- Returns:
Tuple of BlendChain objects (immutable)
- property blend_reading: BlendReading#
The part’s blends, read once and handed to every reading of the part that needs them.
The cut features and the feature model are read with these blends, so that they agree on which faces are blends whichever ran first. Nothing is marked on
aagby reading them.
- property blends: list[Blend]#
Get extracted blend features.
- Returns:
Tuple of Blend objects (immutable)
- property cavities: list[Cavity]#
Get extracted cavity features, of every Cavity subclass.
The registry is keyed on the exact
type()of each feature, so the types are read off the class hierarchy rather than listed here — a hand-maintained list silently drops any subclass someone forgets to add to it.The list is heterogeneous: parameters beyond the shared ones vary by subclass — only
RoundCavitycarries adiameter. Check the concrete type (or that the attribute exists) before reading a subclass-specific parameter.The holes a
Perforationowns are left out: they are in that perforation’sholes, andwith_perforation_holes()lists them beside it.- Returns:
List of Cavity objects, of mixed concrete subclasses.
- property chamfer_chains: list[ChamferChain]#
Get extracted chamfer chains.
- Returns:
List of ChamferChain objects
- clear_all_features() None#
Clear all features from the registry, and with them every recorded extraction.
- clear_features(feature_types: list[type[Feature]] | None = None) None#
Clear extracted features.
- Parameters:
feature_types – Optional feature classes to clear (e.g., Bend, Cavity). If None, clears all features.
- property corner: list[Corner]#
Get extracted corner features.
- Returns:
Tuple of Corner objects (immutable)
- property corner_reliefs: list[CornerRelief]#
Get extracted corner relief features.
- Returns:
List of CornerRelief objects.
- property curls: list[Curl]#
Get extracted curl features: sheet edges rolled round with no flat leg.
- Returns:
List of Curl objects.
- property dimples: list[Dimple]#
Get extracted dimples: round domes pressed into the sheet.
Refuses until
extract_deformations()is called.
- property embosses: list[Emboss]#
Get extracted emboss features, dimples and beads included.
- Returns:
Tuple of Emboss objects (immutable)
- extract_all(blend_max_radius: float | None = None) None#
Recognize all available features for the shape.
- Parameters:
blend_max_radius – Maximum radius for blend recognition, in the model’s own length units; omitted, a fraction of the model’s own size.
- extract_blends(max_radius: float | None = None) None#
Recognize blend features and store them internally.
- Parameters:
max_radius – The maximum radius for blend recognition, in the model’s own length units. Omitted, it is taken as a fraction of the model’s own size, so the same call recognizes the fillets of a part modelled in millimetres and of one modelled in metres.
Without max_radius the blends are
blend_reading, those every other reading of the part is handed. With another radius they are read again up to it, since which blends a part has decides how each one is read. Either way they are marked onaag, for the readers of the graph’s nodes.
- extract_cavities() None#
Recognize cavity features and store them internally.
A hole a
Perforationalready owns is left out: the sheet-metal pass read it as one hole of that perforation, and listing it again as a cavity would put it in two features.
- extract_chamfers(mode: Literal['convex', 'convex_and_inside_bevels', 'any'] = 'convex_and_inside_bevels', max_offset_ratio: float = 0.5, min_angle_degrees: float = 5.0) None#
Recognize chamfer features and store them internally.
- Parameters:
mode – Which chamfers are read:
"convex", those of a convex edge only;"convex_and_inside_bevels"(default), also the chamfers filling the square corner of a concave edge, as where a pocket wall meets its floor;"any", the chamfers of any edge.max_offset_ratio – Maximum ratio of chamfer offset to model diagonal.
min_angle_degrees – Minimum angle between under-faces in degrees.
- extract_deformations(extractor_class: type[DeformationExtractor] = <class 'volmdlr_tools.features.extractors.sheet_metal.region_deformation.RegionDeformationExtractor'>) None#
Recognize the deformations pressed into the sheet and store them internally.
A deformation that stays inside the sheet is an emboss, a dimple or a bead; one that opens onto a cut is a flanged cutout, an extrusion hole or a louvre. A rib pressed across a bend is a gusset, found by either extractor before the deformations, which take none of its faces.
- Parameters:
extractor_class – The extractor driving the recognition. Defaults to the region-based extractor, which also finds deformations merged with cutout rims or the sheet boundary; pass
DeformationExtractorfor the wire-seeded one.- Raises:
ValueError – If the shape is not a sheet metal.
- extract_feature_model(stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False) FeatureModel#
Read the part’s single features and which was made on or cut into which, and store the model.
- Parameters:
stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock.
stock_convention – What counts as the raw stock; see
StockConvention. The default,DEFAULT_STOCK_CONVENTION, reads it as the bar the part was machined from, whatever its section, and only that reading reads cuts through the part’s outline (FeatureType.OUTLINE_CUT). Under it, each faced top, a flat face below the hull every neighbour meets at a sharp convex edge, comes out as an unnamedFeatureType.UNKNOWNfeature: the material above it was removed from the bar."extruded_profile"reads it as the profile the part was extruded from;"supporting_plane"as the bounding block the part was cut from.families – The families to read; all of them by default. See
Family.strict – Whether a reader’s exception is raised instead of recorded as a refusal.
- Returns:
The model, also available as
feature_model.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, or ifaagis the graph of another part.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces.
- extract_interacting_features(stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull') None#
Extract interacting machining features using the Sunil et al. (2010) algorithm.
- Parameters:
stock_convention – What counts as the raw stock; see
StockConvention. The default,DEFAULT_STOCK_CONVENTION, reads it as the bar the part was machined from, whatever its section, and only that reading fillsoutline_cuts, the cuts through the part’s outline; each faced top, a flat face below the hull every neighbour meets at a sharp convex edge, comes out as an unnamedUNKNOWNfeature."extruded_profile"reads it as the profile the part was extruded from, and"supporting_plane"as the bounding block the part was cut from. Which one ran is kept ininteracting_features_stock_convention.- Raises:
ValueError – If
stock_conventionis not one on offer.
- extract_lances() None#
Recognize lance features and store them internally.
Lances are recognized together with the other sheet metal features, so this runs
extract_sheet_metal_features(), which first discards every feature extracted before.- Raises:
ValueError – If the shape is not a sheet metal.
- extract_planar_trims(tol: float | None = None) None#
Recognize the planes the whole part lies on one side of, with the faces it has on each.
Not part of
extract_all(): every outer plane of a part is one, whether the part was cut back to it or simply ends there, and only what was built before tells the two apart.- Parameters:
tol – How far the part may reach past such a plane; defaults to a fraction of the model’s size.
- extract_ribs(max_thickness: float | None = None, blend_max_radius: float | None = None, pair_finder: str = 'edge_driven') None#
Recognize rib features (and rib structures) and store them internally.
Not part of
extract_all()— rib recognition walks the whole AAG and is markedly slower than the other extractors, so it is opt-in. Until it is called,ribsandrib_structuresare empty.- Parameters:
max_thickness – Maximum wall thickness for a rib, in the model’s units. When omitted it defaults to a fraction of the model’s bounding-box diagonal, so the threshold is unit-agnostic; pass an explicit value to constrain recognition to a known wall thickness.
blend_max_radius – Maximum fillet radius recognized as a blend and passed over when collecting a rib’s shell and base faces. When omitted it defaults to a fraction of the bounding-box diagonal, for the same unit-agnostic reason as
max_thickness.pair_finder – Which candidate end-face pair finder the
RibExtractorruns —"edge_driven"(default),"face_pair", or the experimental"nearly_planar"that also admits nearly-planar BSpline/Offset end faces. Same names and defaults asRibExtractoritself.
- Raises:
ValueError – If
pair_finderis not one of the three names.
- extract_sharp_edges() None#
Recognize sharp edge features and store them internally.
- extract_sheet_metal_features() None#
Recognize sheet metal features and store them internally by type.
- Raises:
ValueError – If the shape is not a sheet metal.
- property extractions_run: frozenset[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']]#
The extractions that have run on this processor, by
extract_*method name."blends"in the set meansextract_blends()has run, so an emptyblendsmeans the part has no fillets; absent, it means nobody has looked. Clearing an extraction’s features removes it again, since its result no longer exists — but only once none of the types it owns holds a result, and only if the clear discarded something, so neither a partial clear nor a pass that found nothing loses its place. Reading a collection whose extractions are all absent raises — seeUnextractedAccessError.- Returns:
Extraction names, e.g.
frozenset({"blends", "cavities"}).
- property extrusion_holes: list[ExtrusionHole]#
Get extracted extrusion holes: round holes whose rim is drawn into a collar.
Refuses until
extract_deformations()is called.
- property feature_model: FeatureModel | None#
The part’s feature model, or
Nonewhenextract_feature_model()has not run.
- features_volume_model(features: list[Feature]) VolumeModel#
Display features alongside the original shape in a VolumeModel.
- filter_blend_chains(min_radius: float | None = None, max_radius: float | None = None, min_length: float | None = None, max_length: float | None = None) list[BlendChain]#
Filter blend chains based on criteria.
- Parameters:
min_radius – Minimum chain radius
max_radius – Maximum chain radius
min_length – Minimum chain length
max_length – Maximum chain length
- Returns:
Filtered list of blend chains
- filter_blends(min_radius: float | None = None, max_radius: float | None = None, blend_type: str | None = None, confirmed_only: bool = False) list[Blend]#
Filter blends based on criteria.
- Parameters:
min_radius – Lower bound, read against
Blend.radius— the radius the blend was recognized by.max_radius – Upper bound, read against
Blend.widest_radius— the widest point the blend reaches. A round that opens out past the bound along its length is not admitted on the strength of its narrow end, which is what selecting small fillets for removal needs.blend_type – Name of the
BlendTypeto keep —"Ordinary","Vertex","Cliff"or"Uncertain". Any other string is refused, since an empty answer would be indistinguishable from a part that has none of that kind.confirmed_only – If True, only return confirmed blends
- Returns:
Filtered list of blends
- Raises:
ValueError – If blend_type is not the name of a
BlendType.
- filter_by_category(category: str, location: str | None = None) list#
Filter features by category and optionally by location.
- Parameters:
category (str) – Feature category (“cut”, “forming”, “blend”, “cavity”, “unknown”)
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of features matching the criteria
- Return type:
list
- filter_by_location(location: str) list#
Filter all features by location.
- Parameters:
location (str) – Location filter (“boundary” or “internal”)
- Returns:
List of features at the specified location
- Return type:
list
- filter_cavities(min_depth: float | None = None, max_depth: float | None = None) list[Cavity]#
Filter cavities based on depth criteria.
Depth is the cavity’s
depthparameter. A cavity whose depth is undetermined (depthanswers None) is excluded from any bounded query — an unknown depth never reads as a shallow one — but is present in an unbounded one.- Parameters:
min_depth – Minimum cavity depth (inclusive)
max_depth – Maximum cavity depth (inclusive)
- Returns:
Filtered list of cavities
- property flanged_cutouts: list[FlangedCutout]#
Get extracted flanged cutouts, extrusion holes and louvres included.
A cutout whose rim shape is not named is a plain
FlangedCutout; the named ones are listed here too, asembosseslists dimples and beads. Refuses untilextract_deformations()orextract_sheet_metal_features()is called.
- classmethod from_doc_model(doc_model: DocModel, prototype: Prototype | None = None, name: str = '') FeatureProcessor#
Initialize a FeatureProcessor on the shape of a DocModel prototype, the root one by default.
- Parameters:
doc_model – The DocModel to read, without converting it to a VolumeModel.
prototype – The prototype to perform recognition on, in its own frame; only its B-Rep is read.
name – (Optional) A name.
- Returns:
The processor FeatureProcessor(doc_model.to_volume_model().primitives[0]) would give.
- classmethod from_part_reading(reading: PartReading) FeatureProcessor#
Make the processor of a part that has been read already, which reads nothing of it again.
The processor’s
aagis the reading’s graph read with every edge convex or concave, and itspart_readingandblend_readingare the reading’s own, so that a part read once is shared by every reader of it, here and wherever else the reading was handed.- Parameters:
reading – The part, read.
- Returns:
The processor of the reading’s part.
- get_cut_features(location: str | None = None) list#
Get all cut features (slots, notches, corner reliefs, clips).
- Parameters:
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of cut features
- Return type:
list
- get_face_coverage() FaceCoverage#
Account for every face of the part against the features recognized on it.
The part-level counterpart of
get_feature_count(): that one says how much was found, this one says how much of the part was accounted for. It answers how many faces exactly one feature claimed, how many more than one claimed and which feature types those were, and how many none claimed — so a recognition gap becomes visible rather than assumed away, and double-counting is caught before it reaches a total.The report covers only the extractions that have run, and says which those were. Its size does not grow with the part: the face-index lists are capped samples, with the full counts alongside.
- Returns:
The coverage report, over
extractions_run.- Raises:
ValueError – If a recognized feature claims a face the part does not have, which is an extractor defect this report refuses to hide.
- get_feature_count() FeatureCounts#
Count the extracted features, per type, over the extractions that have run.
A type an extraction looks for but did not find is reported as
0; a type whose extraction never ran is absent entirely. Which extractions the counts cover is on the result — seeFeatureCounts.extractions_run.- Returns:
Feature class names mapped to counts, as a dict that also names the extractions counted over.
- get_forming_features(location: str | None = None) list#
Get all forming features (bends, jogs).
- Parameters:
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of forming features
- Return type:
list
- property gussets: list[Gusset]#
Get extracted gusset features: ribs pressed across a sheet-metal bend, filled by
extract_deformations().- Returns:
List of Gusset objects.
- has_features(feature_type: type[Feature] | None = None) bool#
Check if any features have been extracted.
- Parameters:
feature_type (Optional[type[Feature]]) – Optional feature class to check (e.g., Bend, Jog). If None, checks if any features exist.
- Returns:
True if features exist, False otherwise
- Return type:
bool
- property hems: list[Hem]#
Get extracted hem features: sheet edges folded back over the sheet.
- Returns:
List of Hem objects.
- property holes: tuple[Hole, ...]#
Get extracted hole features.
- Returns:
Tuple of Hole objects (immutable)
- property hooks: list[Hook]#
Get extracted hook features: tabs lanced out of the sheet and bent over, their end pointing back down.
A hook is no lance: it is listed here and not in
lances. Refuses untilextract_sheet_metal_features()is called.
- property interacting_features_stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] | None#
The stock convention the interacting features were read under.
Set by
extract_interacting_features(), so a set of interacting features can be told apart from the same part read under the other convention. None untilextract_interacting_features()has run, and again once a clear has discarded its features.
- property is_sheet_metal: bool#
Check if the shape is a sheet metal.
- Returns:
True if shape is sheet metal, False otherwise
- property lances: list[Lance]#
Get extracted lance features.
- Returns:
Tuple of Lance objects (immutable)
- property louvre: list[Louvre]#
Get extracted louvre features, however they were found.
Those read from the formed hood come from
extract_deformations(), those read from the slit’s cut walls alone fromextract_sheet_metal_features().- Returns:
Tuple of Louvre objects (immutable)
- property notches: list[Notch]#
Get extracted notch features.
- Returns:
Tuple of Notch objects (immutable)
- property outer_contour_nodes: list[int]#
AAG face indices of the part’s outer contour — its border faces.
The thickness faces of the sheet’s boundary chain: the faces an edge distance is measured to. Inner cutout walls are not here; they belong to the internal chains and are reached as features instead.
- Returns:
The border face indices, empty when the part is not recognized as sheet metal.
- property outline_cuts: tuple[OutlineCut, ...]#
Get extracted cuts through the outline of the bar, read under the
"convex_hull"stock convention.- Returns:
Tuple of OutlineCut objects (immutable)
- property part_reading: PartReading#
The part read once, shared by every reading of it: its graphs, its blends, its tolerances.
Its graph read with every edge convex or concave is
aag, and its blends areblend_reading.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – When
aagis the graph of another part.
- property perforations: list[Perforation]#
Get extracted perforations: fields of congruent holes punched through a flat plate on a lattice.
A perforation owns its holes: they are not in
cavities, and each perforation lists them in itsholes. Refuses untilextract_sheet_metal_features()is called.
- property planar_trims: list[PlanarTrim]#
Get the planes the part lies on one side of. Refuses until
extract_planar_trims()is called.
- plot_features_graph(features_to_highlight: list[Feature] | None = None, show_labels: bool = True)#
Plot the AAG with features highlighted.
- Parameters:
features_to_highlight – Optional list of features to highlight in the graph. If None, highlights all extracted features.
show_labels – Whether to show node labels.
- Returns:
Matplotlib figure or graph visualization object.
- property pockets: tuple[Pocket, ...]#
Get extracted pocket features.
- Returns:
Tuple of Pocket objects (including OpenPocket and AnnularGroove, immutable)
- post_process_unknown_features(internal_features: list[Feature]) list[Feature]#
Reclassify unknown internal features adjacent to multiple blends as CutoutWithBendInternal.
- recognise(stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False, body: bool = False, deadline: float | None = None, body_wall_rounds: bool = True) RecognitionDocument#
Recognise the part’s features and say what every face of it is, and store the document.
The part’s feature model is read again, with stock_faces and stock_convention, and stored as
feature_model. Without stock_faces the part is also read as turned: when every face of it is either on a profile turned about an axis or on a feature standing on that profile, and the profile carries most of the part’s surface, the profile is one revolution that the other features stand on, and the readings it takes faces from are set aside. A round drawn in a profile, such as the round end of a slot, is given to the feature whose profile it rounds, or to the body, rather than read as a blend. When faces are left that nothing explains, on a part not read as turned, the part is also read as profiles extruded along the direction it was most built along, and each profile is an extrusion of the faces left to it.With body, the part is read for the body it was made from instead of as turned: each extrusion, drafted extrusion or revolution the part was made from is a record of its own, with
stage"body", made first, and the holes, pockets and slots made in it are the features that stand on it. A turned part’s bore is a hole in its revolution, a keyway cut along it is a slot on that hole, holes off the axis stay holes, and a flat milled across the whole turn, a plane the part lies under that the turn reaches past, is a cut on the revolution. The faces a revolution at the root of the body does not hold are handed back to the extruded profiles, which still read what nothing else explains; a face no profile reads is refused, saying the revolution hands it back. A round that is a wall of a body’s extrusion or turn is a face of the body record, or of the pocket record for a window cut through the body, with a refusal naming the profile that keeps it, and no finishing blend record; a run of rounds one fillet makes goes so only whole, and stays blends when one record cannot keep it all. Naming stock_faces reads the part as without body, as does a part from which no body is read, and a part whose body reading fails outside strict mode, which leaves one refusal over the whole part saying so. See the “Body and features” section of the recognition document’s guide.With body, the faces the body and the feature readings leave unexplained, refuse, or read suspiciously, such as the cavity of a thin-walled shell, are also read again, region by region, with the readers of walls, pipes, lofts and sweeps. A reading takes a region only when the region holds at least half of the faces the reading contests, which are its faces other than those of the body, the stock and the work done on edges; the body it reads is then a record with
origin"advanced", and the readings that lie on it are set aside with a refusal. A reader tried on a region and not used leaves a refusal over the faces of the region its readings held, or over no face when it failed or ran out of time.Each reader runs on its own: one that fails, or runs out of time, leaves a refusal saying so, and the others’ records are still given.
With a deadline, the readings stop at that moment: a reader reached after it has passed is not run, and the body reading, when the deadline has passed before it starts, is not run either; each leaves a refusal over the whole part giving the out-of-time reason, so that no reading is lost without saying so. What was read before the deadline is in the document. A reader already running is cut short only if it watches the time it is given; the others finish.
- Parameters:
stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock, or of its revolution.
stock_convention – What counts as the raw stock; see
extract_feature_model().families – The families to read; all of them by default. See
Family.strict – Whether a reader’s exception, or a failure of the body reading, is raised instead of recorded as a refusal.
body – Whether to read the body the part was made from, and the features made on it.
deadline – The moment by which the readings must be over, as
time.perf_counter()gives it, not a duration:time.perf_counter() + 30. No limit beyond each reader’s own when omitted.body_wall_rounds – Whether a round that is a wall of a pocket, a slot, a step or a cut, or with body a wall of a body’s extrusion or turn, a rounded corner of the profile it was made from, such as a rounded corner of a pocket, a round along an extruded outline or a torus rounding a turned shaft’s shoulder about its axis, is given to the record whose profile it rounds, with the whole run of rounds it belongs to; otherwise it is a blend, applied to an edge once the body or the cut is made. True by default.
- Returns:
The document, also available as
recognition_document.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, ifdeadlineis not a finite moment, or ifaagis the graph of another part.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces, or when the body reading fails.
- property recognition_document: RecognitionDocument | None#
The part’s recognition document, or
Nonewhenrecognise()has not run.
- property rib_max_thickness: float | None#
The wall-thickness threshold rib recognition actually applied.
Differs from the
max_thicknesspassed toextract_ribs()when the scale-aware default was tightened to the part’s measured walls. None untilextract_ribs()has run.
- property rib_structures: list[RibStructure]#
Get extracted rib structures (groups of segments meeting at junctions).
Refuses until
extract_ribs()is called.
- property ribs: list[Rib]#
Get extracted rib segments. Refuses until
extract_ribs()is called.
- property sharp_edges: list[Edge, ...]#
Get extracted sharp edge features.
- Returns:
Tuple of Edge objects (immutable)
- property sheet_metal: SheetMetalShape | None#
The recognized sheet-metal shape, or None when the shape is not a sheet metal.
Use it to drive an extractor directly (e.g.
DeformationExtractor(sheet_metal=...)); recognition runs once and is cached.
- property sheet_thickness: float | None#
The part’s nominal sheet thickness s, in the model’s length unit.
That unit is metres for any model
volmdlrloads, which is what the rule layer (volmdlr_tools.features.rules) compares it in. The value is measured, not read from a parameter, so it can sit a float hair off the nominal thickness it was drawn at.The single authoritative input for every thickness-scaled stamping threshold (2s, 3s, 4s). Delegates to the sheet-metal recognizer, which measures it as the median length of the edges the boundary thickness faces share, falling back to the seed-to-opposite distance.
- Returns:
The thickness, or None when the part is not recognized as sheet metal — a rule with no s reports indeterminate, never a verdict.
- show_cavities() dict#
Implementation of a tag for displays.
- show_features(feature_type: type[Feature] | None = None) dict#
Implementation of a tag for displays.
- property slots: tuple[Slot, ...]#
Get extracted slot features.
- Returns:
Tuple of Slot objects (including all subtypes, immutable)
- property steps: tuple[Step, ...]#
Get extracted step features.
- Returns:
Tuple of Step objects (including BlindStep, immutable)
- property tabs: list[Tab]#
Get extracted tab features: flat ear plates beyond a single bend, ending in a round tip.
The bend a tab stands on is listed in
bends, and the hole through it with the cut features it reads as; the tab names both.- Returns:
List of Tab objects.
- to_markdown() str#
Return a markdown summary of extracted features.
Includes feature counts, category breakdown (cut/forming with boundary/internal split), and classification summary statistics.
The summary reports only what the extractions that ran can support: with none run it says so rather than describing the part, and otherwise it names the extractions its numbers cover.
- Returns:
Markdown-formatted string
- Return type:
str
- Raises:
ValueError – If a recognized feature claims a face the part does not have — see
get_face_coverage(), whose section this carries.
- unfold(k_factor: float = 0.33, fixed_face: int | None = None, cut_edges: Iterable[int] = (), length_unit: Literal['m', 'mm', 'in'] = 'm') FlatPattern#
Lay the sheet-metal part flat: the blank it is cut from, with its bend lines.
Recognises the sheet-metal features first if that has not been done; they are recognised apart from this processor’s own results, which are left as they were. Each fold (bend, hem or curl) is developed at its neutral radius,
inside_radius + k_factor * thickness. A formed feature (emboss, dimple, bead, louvre, extrusion hole, flanged cutout) is pressed after the blank is cut: the blank keeps the flat footprint it is pressed from, with a forming mark for the press and a slit where the sheet was sheared. An extrusion hole’s footprint is pierced with the smaller hole its collar is drawn from, unless the collar is longer than its footprint could supply by bending alone: the blank then has no hole there, and the mark is listed in the pattern’sflagged_markswith a note giving both lengths. A formed feature must meet one flat stretch of sheet along a single closed loop: one that reaches the sheet’s edge, lies across a bend, sits on another formed feature or meets the sheet along several loops is refused, as is a flanged cutout that is neither an extrusion hole nor a louvre.- Parameters:
k_factor – Where the neutral layer sits, as a fraction of the thickness measured from the inside face of a bend. That layer neither stretches nor shrinks, and its arc across a bend is the bend allowance. The default, 0.33, suits most air-bent steel with an inside radius close to the thickness; pass a measured value for other materials or tooling.
fixed_face – The face to develop from; by default the largest face of the largest flange.
cut_edges – Edges to cut so that faces closing on themselves can lie flat; an error naming such faces lists the edges, any one of which would do. Cutting an edge parts the two faces it runs between along every edge they share.
length_unit – The unit the part is in: metres for a part read from a file the usual way. The pattern is in the same unit and says so, so that a drawing of it can be written in the right scale.
- Returns:
The flat pattern.
- Raises:
ValueError – On a bad argument: a K-factor outside 0 to 1, a fixed face that is not a flat face of the sheet, or a cut edge not between two of its faces.
UnfoldError – If the part cannot be laid flat. Its
reasonis"not_sheet_metal"when the part is not recognised as sheet metal, is built in a way sheet-metal recognition does not support, or its thickness cannot be measured;"non_developable"when curved faces of the sheet belong to no bend or formed feature, or a bend or formed feature has no known flat shape;"closed_loop"when the sheet closes on itself and needs a cut edge;"overlap"when, laid flat, parts of the sheet land on each other;"placement_mismatch"when neighbouring faces do not line up once flat.
- property unknown_features: list[UnknownFeature]#
Get extracted unknown features.
- Returns:
List of UnknownFeature objects (immutable)
- view(feature_type: type[Feature] | None = None) None#
Open the recognized features, colored, in the local DocModel viewer.
Developer-workstation convenience (interactive side effect, no return value) kept out of
show_features()so the@cad_viewplatform contract stays “return babylon display data”.- Parameters:
feature_type – Same selection as
show_features().- Raises:
ValueError – If
feature_typeis not among the extracted types.
- class volmdlr_tools.features.core.FeaturesRecognizer(*args, **kwargs)#
Bases:
FeatureProcessorBackward compatibility alias for FeatureProcessor.
- . deprecated:: v1.0.0
Use FeatureProcessor instead. This alias will be removed in version 1.0.0.
- blends_recognition(max_radius: float)#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_blends() instead.
- cavities_recognition()#
Deprecated method for backward compatibility.
Deprecated since version v1.0.0: Use extract_cavities() instead.
- cavitivies_recognition()#
Deprecated alias for cavities_recognition() (legacy misspelling).
- emboss_recognition()#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_deformations() instead.
- Raises:
ValueError – If the shape is not a sheet metal.
- sharp_edges_recognition()#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_sharp_edges() instead.
- exception volmdlr_tools.features.core.UnextractedAccessError#
Bases:
RuntimeErrorA feature collection was read before any extraction that fills it had run.
Answering the empty list here would spell “nothing was looked for” the same way as “nothing was recognized”, so the read refuses instead. The message names the
extract_*call that satisfies the precondition; once it has run, the same property answers normally, and an empty answer means the part has none. A caller that would rather branch than catch can readFeatureProcessor.extractions_run, which the message points at.
- volmdlr_tools.features.core.recognise_features(part: Shape | PartReading, stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False, body: bool = False, deadline: float | None = None, body_wall_rounds: bool = True) RecognitionDocument#
Recognise a part’s features and say what every face of it is.
- Parameters:
part – The part: one solid, alone or as the only thing in a compound; or the part read already, as a
PartReading, which is used as it is and shared rather than read again. The document is the same either way.stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock.
stock_convention – What counts as the raw stock; see
FeatureProcessor.extract_feature_model().families – The families to read, such as
["cuts"]for holes, pockets and slots alone; all of them by default. SeeFamily.strict – Whether a reader’s exception is raised, as a
FeatureRecognitionError, instead of recorded as a refusal over the part.body – Whether to read the body the part was made from, and the holes, pockets and slots made in it, and to read again the regions those readings leave with the readers of walls, pipes, lofts and sweeps; see
FeatureProcessor.recognise().deadline – The moment by which the readings must be over, as
time.perf_counter()gives it, not a duration:time.perf_counter() + 30. No limit beyond each reader’s own when omitted. A reader not yet run when it passes, and the body reading, leave a refusal saying their time ran out; what was read before is in the document. A reader already running is cut short only if it watches the time it is given.body_wall_rounds – Whether a round that is a wall of a pocket, a slot, a step or a cut, or with body a wall of a body’s extrusion or turn, a rounded corner of the profile it was made from, is given to the record whose profile it rounds rather than read as a blend; true by default.
- Returns:
The document
FeatureProcessor.recognise()gives.- Raises:
ShapeTypeError – When part is not one solid.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, or ifdeadlineis not a finite moment.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces, or when the body reading fails.
volmdlr_tools.features.recognition module#
What recognition found on a part: its features, and what every face of the part is.
The recognition document is the one answer recognition gives. Its records are the part’s single features, each with the faces it accounts for. Its face account gives every face of the part one status, so that what was recognised can be told from what was not.
The face account answers, for the document, the question FaceCoverage
answers for the features a processor has stored one extraction at a time: does what was recognised add up to the
part. The account goes further. It tells the body the features stand on from what nobody read, and it keeps the
reason a reading was set aside.
- volmdlr_tools.features.recognition.AdvancedKind#
What an advanced body is: a wall of constant thickness, a pipe along a curve, a loft between sections, or a profile swept along a path.
alias of
Literal[‘wall’, ‘pipe’, ‘loft’, ‘sweep’]
- volmdlr_tools.features.recognition.BODY_REASON = 'lies on the body the part was made from'#
Why a face a body record holds is the body.
- volmdlr_tools.features.recognition.BodyKind#
What a body the part was made from is: a profile turned about an axis, or a profile extruded along a direction, straight or drafted.
alias of
Literal[‘revolution’, ‘extrusion’, ‘drafted_extrusion’]
- class volmdlr_tools.features.recognition.BodyTechnique(domain: TechniqueDomain, extrusion: ExtrusionReading | None = None, turn: TurnReading | None = None, outline_face_ids: frozenset[int] = frozenset({}), swept_face_ids: frozenset[int] = frozenset({}), tree: DomainTree | None = None, profile: Revolution | None = None, profile_refusal: FaceRefusal | None = None)#
Bases:
objectThe reading of a part’s technique a body record came from: how the body was made.
Exactly one of extrusion and turn is given: the one the body’s domain is read as. It describes the domain as it was read, before other records took some of its faces: the faces the body record holds are the record’s
face_ids, and may be fewer than the faces read here.- Parameters:
domain – The region of the part built by the technique, with the faces it holds and its place among the regions the part was built from.
extrusion – For a body made by extruding a profile, what the extrusion makes: its direction, the walls and the caps, the position of each cap, and the lean of each wall.
turn – For a body made by turning a profile, what the turn makes: its axis and the faces about it.
outline_face_ids – For an extrusion, the caps and the faces of the outer loop of the extruded body, not those round its windows; none for a turn.
swept_face_ids – For a turn, the faces of the part the turn sweeps, its profile, outer and bore; none for an extrusion.
tree – The regions of the part the domain is one of, with where each meets the one it was made on: how far the body reaches past the face it stands on is read from its interface there.
Nonefor a technique not read from a part’s regions.profile – For a turn, the profile read off the faces it sweeps as they are, a bevel a chamfer record describes included: the chains in the axes
(t, r)of the revolution,talong its axis from its origin, each closed or running from the axis to the axis, none crossing itself. The profile the body was turned from, with those bevels taken off its corners, is whatrecord_parameters()gives for the record.Nonefor an extrusion, or when the faces give no profile.profile_refusal – For a turn whose faces give no profile, why they do not;
Noneotherwise.
- Raises:
ValueError – When both readings are given, or neither, or an extrusion is given a profile or a refusal of one.
- domain: TechniqueDomain#
- extrusion: ExtrusionReading | None = None#
- outline_face_ids: frozenset[int] = frozenset({})#
- profile: Revolution | None = None#
- profile_refusal: FaceRefusal | None = None#
- swept_face_ids: frozenset[int] = frozenset({})#
- tree: DomainTree | None = None#
- turn: TurnReading | None = None#
- class volmdlr_tools.features.recognition.ConstructionNode(record: int, children: tuple[ConstructionNode, ...] = ())#
Bases:
objectOne record in the construction tree, with the records made on it.
- Parameters:
record – The index of the record in the document’s
records.children – The records made on this one, in the order they come: the bodies and the features first, then the work done on edges.
- children: tuple[ConstructionNode, ...] = ()#
- record: int#
- class volmdlr_tools.features.recognition.FaceStatus(kind: Literal['feature', 'body', 'refused', 'unexplained'], record: int | None = None, refusal: int | None = None, reason: str = '')#
Bases:
objectWhat one face of a part is.
- Parameters:
kind –
"feature"for a face a feature accounts for,"body"for a face of the body the features stand on or are cut into,"refused"for a face a reading was set aside over and nothing else accounts for,"unexplained"for a face nothing accounts for.record – The index of the record accounting for the face; given for a feature’s face, may be given for a face of the body when a body record holds it, and given for no other face.
refusal – The index of the first refusal holding the face; given for a refused face, and only for one.
reason – Why the face is what it is, for a face of the body or a refused face.
- Raises:
FeatureRecognitionError – When record or refusal is given, or missing, against what kind says.
- kind: Literal['feature', 'body', 'refused', 'unexplained']#
- reason: str = ''#
- record: int | None = None#
- refusal: int | None = None#
- class volmdlr_tools.features.recognition.FeatureRecord(kind: Literal['hole', 'pocket', 'slot', 'step', 'groove', 'cut', 'boss', 'addition', 'blend', 'chamfer', 'revolution', 'extrusion', 'drafted_extrusion', 'wall', 'pipe', 'loft', 'sweep'], sense: Literal['add', 'subtract', 'edge'], face_ids: frozenset[int], base_face_ids: frozenset[int] = frozenset({}), parents: tuple[int, ...] = (), readers: tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer', 'turned', 'slabs', 'body', 'trims', 'walls', 'pipes', 'lofts', 'sweeps'], ...] = (), stage: Literal['body', 'feature', 'finishing'] = 'feature', origin: Literal['simple', 'advanced'] = 'simple', end_face_ids: frozenset[int] = frozenset({}), _sources: tuple[tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer'], int], ...] = ())#
Bases:
objectOne feature of a part: what one modelling operation makes.
- Parameters:
kind – What the feature is.
"revolution"is the profile a turned part is turned from.sense –
"add"for material standing on the part,"subtract"for material taken away,"edge"for a blend or chamfer worked on edges.face_ids – The part’s faces the feature accounts for.
base_face_ids – The faces the feature stands on or is cut into, when its readers read them.
parents – The indices of the records this feature was made on or cut into; a parent may come after its child in the records, as a body the advanced readers read again follows the records it replaces; none for one made on the body alone.
readers – The readers whose readings the feature merges, in the order they read it.
stage – When the operation comes in the making of the part. A record worked on edges is always
"finishing". Only the body reading makes"body"records; every other record is a"feature", the profile a turned part is turned from and the profiles a part is extruded from among them.origin – Which family of readings made the record:
"simple"for the simple readers and"advanced"for the readers of the regions the others leave unexplained.end_face_ids –
The faces among face_ids that close the feature; every other face the record holds is a side, see
role_of(). What closes each kind of record:pocket, slot, step and groove: its floor, when it has one;
cut: its floor, when it has one;
hole: its bottom, which the shoulder of a counterbore is not;
boss: its top, when it stands on a flat face;
addition: the end faces of the extrusion it was read as;
extrusion body and drafted extrusion body: its two caps;
revolution, as a body or as the profile a part is turned from: the flat faces holding its axis, where a turn of less than a whole one starts and stops; a whole turn has none;
extrusion read from a slab of the part: its two caps;
any feature that runs right through: none, whatever a reading says of it;
blend and chamfer: none, they are worked on edges and give their faces no role.
A face is an end when any reading of the feature calls it one, unless the feature runs through. A body is the one to say what is an end of its own faces, whatever the records it took over said of them.
_sources – Which readings the record merges, as (reader, position among that reader’s readings); the document’s loop readings are the ones named
"depression_protrusion". Kept beside the record, not in what it equals, and followed by the record through every change of its faces or its number.
- Raises:
ValueError – When end_face_ids names a face the record does not hold, or a record worked on edges has end faces.
- base_face_ids: frozenset[int] = frozenset({})#
- end_face_ids: frozenset[int] = frozenset({})#
- face_ids: frozenset[int]#
- kind: Literal['hole', 'pocket', 'slot', 'step', 'groove', 'cut', 'boss', 'addition', 'blend', 'chamfer', 'revolution', 'extrusion', 'drafted_extrusion', 'wall', 'pipe', 'loft', 'sweep']#
- origin: Literal['simple', 'advanced'] = 'simple'#
- parents: tuple[int, ...] = ()#
- readers: tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer', 'turned', 'slabs', 'body', 'trims', 'walls', 'pipes', 'lofts', 'sweeps'], ...] = ()#
- restricted_to(faces: frozenset[int]) FeatureRecord#
Return the record cut down to faces, its end faces cut down with it.
- Parameters:
faces – The faces the record keeps; any other face it held is dropped.
- role_of(face: int) Literal['side', 'end'] | None#
Say what a face is to the record:
"end"for a face that closes it,"side"for any other it holds.- Parameters:
face – A face of the part.
- Returns:
Its role, or
Nonefor a face the record does not hold and for every face of a record worked on edges, which gives its faces no role.
- sense: Literal['add', 'subtract', 'edge']#
- stage: Literal['body', 'feature', 'finishing'] = 'feature'#
- volmdlr_tools.features.recognition.Origin#
Which family of readings made a record: the simple readers, or the advanced readers of the regions the others leave unexplained.
alias of
Literal[‘simple’, ‘advanced’]
- volmdlr_tools.features.recognition.ReaderName#
Who read a record: one of the feature model’s readers, the reading of a part as turned, the reading of a part as slabs stacked along a direction, the reading of the body the part was made from, the reading of the planes the whole part lies on one side of, or one of the readings of walls, pipes, lofts and sweeps.
alias of
Literal[‘interacting’, ‘depression_protrusion’, ‘split_adjacency’, ‘blend’, ‘chamfer’, ‘turned’, ‘slabs’, ‘body’, ‘trims’, ‘walls’, ‘pipes’, ‘lofts’, ‘sweeps’]
- class volmdlr_tools.features.recognition.RecognitionDocument(records: tuple[FeatureRecord, ...], face_account: tuple[FaceStatus, ...], refusals: tuple[FaceRefusal, ...] = (), _kept: KeptReadings | None = None)#
Bases:
objectA part’s features, and what every face of the part is.
- Parameters:
records – The part’s single features.
face_account – One status for each face of the part, face
iat indexi.refusals – The readings set aside, each with the faces it covered and why, whether or not another reading accounts for those faces.
- Raises:
FeatureRecognitionError – When the account does not add up: a face given to a record that does not hold it, a face a record holds given another status (
"body"for the face of a body record,"feature"for the face of any other record), a status naming a record or a refusal the document does not have, a record or a refusal naming a face the part does not have, or a record naming a parent the document does not have or parents that loop back on a record.
The technique readings the body records and the slab extrusion records came from are kept beside the document, not in it: see
technique_of(). They are not part of what the document equals. Copying the document or rebuilding it withdataclasses.replace()keeps them; pickling or saving it does not.- Parameters:
_kept – The technique readings of the body records and the slab extrusion records, and the loop readings of the others, which the records’ sources number;
Nonewhen the document was loaded or was made without them.
- counts() dict[Literal['feature', 'body', 'refused', 'unexplained'], int]#
Return how many faces of the part have each status, every status named even when no face has it.
- face_account: tuple[FaceStatus, ...]#
- loop_readings_of(index: int) tuple[tuple[DepressionProtrusion, ...], tuple[int, ...]]#
Return the loop readings the document’s records were made from, and which of them the record at index is.
- Parameters:
index – The position of the record in
records.- Returns:
Every loop reading of the part, and the positions among them of those the record merges; none for a record no loop reading found, as one only the cut reader read.
- Raises:
FeatureRecognitionError – When the document holds no loop readings: it was saved and loaded, or made without them. Read the part again with
recognise_features.IndexError – When the document has no record at index.
- records: tuple[FeatureRecord, ...]#
- refusals: tuple[FaceRefusal, ...] = ()#
- slab_stack_of(index: int) SlabStack#
Return the slabs read along the direction of the slab extrusion record at index, and which one it is.
The stack is what the profile of a slab is read from, see
record_parameters(). A slab that gives no technique, as one holding several separate outlines, still has its stack.- Parameters:
index – The position of the record in
records.- Raises:
FeatureRecognitionError – When the document holds no technique readings, as
technique_of()says, or the slab was not read from a part, so that it has no stack.IndexError – When the document has no record at index.
ValueError – When the record is not an extrusion the reader of slabs read.
- technique_of(index: int) BodyTechnique | SlabTechnique#
Return the technique reading the body record or the slab extrusion record at index came from.
A body record gives a
BodyTechniqueand needs the part read withbody=True. A record the reader of slabs read, as an extrusion, gives aSlabTechnique, with or without the body. Neither is there for a document that was pickled or saved and loaded. The profile an extruded body or a slab was drawn from, its outlines, holes, drafts and levels, is read from them byrecord_parameters().- Parameters:
index – The position of the record in
records.- Returns:
The domain of the body and its extrusion or its turn, or the direction and the levels of the slab.
- Raises:
FeatureRecognitionError – When the document holds no technique readings: it was not read with
body=Trueand no slab was read, the faces of the body were named withstock_facesso no body was read, its body reading failed, or it was saved and loaded. Read the part again withrecognise_features(shape, body=True)and nostock_faces.IndexError – When the document has no record at index.
FeatureRecognitionError – Also, for a slab record, when the slab holds several separate outlines or its walls lean by different angles: it has no one direction, levels and draft to give, and the caller reads the record some other way.
ValueError – When the record is neither a body nor an extrusion the reader of slabs read.
- tree() tuple[ConstructionNode, ...]#
Return the records as a construction tree: each under the record it was made on or cut into.
The roots are the records made on nothing: the bodies first, then the features, then the work done on edges. Each record’s children come in the same order, and records of one stage in the order of
records. A record with several parents hangs under the deepest of them, the one the longest chain of parents leads to, and under the one that comes first inrecordswhen they are as deep.The tree is a partial order only: a record always comes after the record it hangs under, and the work done on edges last among its siblings. It does not say which of two siblings is made first.
- Returns:
The roots of the tree; every record is in it once.
- volmdlr_tools.features.recognition.RecordFaceRole#
What a face is to the record that holds it: a
"side", a face the feature’s operation makes along its length or round its axis, or an"end", a face that closes it: the floor of a pocket, the bottom of a blind hole, the top of a boss, a cap of an extrusion, the start or the stop of a part turned less than a whole turn.alias of
Literal[‘side’, ‘end’]
- volmdlr_tools.features.recognition.RecordKind#
What a record is: one of the feature model’s kinds, one of the kinds a body is, or one of the kinds an advanced body is. Without the body reading, a
"revolution"is the profile a turned part is turned from and an"extrusion"a profile extruded along a direction.alias of
Literal[‘hole’, ‘pocket’, ‘slot’, ‘step’, ‘groove’, ‘cut’, ‘boss’, ‘addition’, ‘blend’, ‘chamfer’, ‘revolution’, ‘extrusion’, ‘drafted_extrusion’, ‘wall’, ‘pipe’, ‘loft’, ‘sweep’]
- volmdlr_tools.features.recognition.STOCK_REASON = 'a face of the stock the cuts are taken from'#
Why a face no feature accounts for is the body.
- class volmdlr_tools.features.recognition.SlabStack(slabs: tuple[DraftedSlab, ...], position: int, levels: tuple[float, float], capped: tuple[bool, bool] = (False, False))#
Bases:
objectThe slabs read along one direction of a part, and which of them a slab record came from.
- Parameters:
slabs – The slabs, in order along their direction.
position – The position among slabs of the slab the record came from.
levels – Where the record’s slab starts and stops along the direction, the start the lower: the plane of a cap at an end the slab has one, else the end of the stretch the slab was read over.
capped – Whether a cap closes the slab at its start, and at its end.
- Raises:
ValueError – When position names no slab of slabs, or levels are not in order.
- capped: tuple[bool, bool] = (False, False)#
- levels: tuple[float, float]#
- position: int#
- property slab: DraftedSlab#
The slab the record came from.
- slabs: tuple[DraftedSlab, ...]#
- class volmdlr_tools.features.recognition.SlabTechnique(extrusion: ExtrusionReading, direction: tuple[float, float, float], levels: tuple[float, float], draft_angle: float = 0.0, outline_face_ids: frozenset[int] = frozenset({}), stack: SlabStack | None = None)#
Bases:
objectThe reading a slab extrusion record came from: along which direction the slab was read, and where it stands.
A slab is a stretch of the part along one direction over which its section keeps following one law, straight or leaning. It describes the slab as it was read, before other records took some of its faces: the faces the record holds are its
face_ids, and may be fewer than the faces read here.- Parameters:
extrusion – The extrusion of the part along the slab’s direction, as the part’s faces fit it.
direction – The unit direction the slab was read along.
levels – Where the slab starts and stops along direction, measured from the origin of space in the model’s own length units; the start is the lower. Each is the position of the plane of the caps closing the slab at that end. At an end where the slab has no cap, as where it meets another slab or the body, it is the end of the stretch the slab was read over, which stops a little short of a rim, within a fraction of a percent of the part’s extent along direction.
draft_angle – The angle in radians by which the slab’s outline grows with each unit of height along direction, so positive when it widens along it and negative when it narrows; zero when the slab stands straight, its outline leaning by less than half a degree. A slab with several outer outlines, or whose walls lean by different angles, gives no technique, see
RecognitionDocument.technique_of().outline_face_ids – The caps of the slab and the faces on the outer loop of its section, not those round its windows.
stack – The slabs read along the slab’s direction, which its profile is read from: see
record_parameters().Nonefor a technique not read from a part.
- Raises:
ValueError – When direction is not of unit length, or levels are not in order.
- direction: tuple[float, float, float]#
- draft_angle: float = 0.0#
- extrusion: ExtrusionReading#
- levels: tuple[float, float]#
- outline_face_ids: frozenset[int] = frozenset({})#
- volmdlr_tools.features.recognition.Stage#
When a record’s operation comes in the making of the part:
"body"for the body the features are made on,"feature"for a feature made on it,"finishing"for the work done on edges last.alias of
Literal[‘body’, ‘feature’, ‘finishing’]
- volmdlr_tools.features.recognition.TURNED_REASON = 'lies on the turned profile, which keeps its faces'#
How a reading of faces that lie on the profile of a turned part is set aside.
volmdlr_tools.features.readers module#
Readers of a part’s faces, run one after the other, each on its own, guarded and with its own time budget.
A reader reads a part one way, as cuts or as blends, and knows nothing of the other readers. It returns its readings
and the faces it declines. run_readers() runs readers in the order they are listed: one that raises, or that
runs out of time, leaves a refusal saying so, and the readers after it still run.
What a caller chooses is which Family to read, through families=; the readers themselves, and how they are
run, belong to recognition and may change from one release to the next.
- volmdlr_tools.features.readers.FAMILIES: tuple[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles'], ...] = ('cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles')#
Every family, in the order they are listed.
- volmdlr_tools.features.readers.Family#
What an engineer asks recognition to read: the cuts into a part (holes, pockets, slots, steps, grooves), the bosses standing on it, additions running off its edges, its blends and chamfers, the planes it was cut back to, and the profiles it was turned or extruded from. The body a part was made from is read with
body=True, not by family.alias of
Literal[‘cuts’, ‘bosses’, ‘additions’, ‘blends’, ‘chamfers’, ‘trims’, ‘profiles’]
volmdlr_tools.refusals module#
The refusal every reader of a part’s faces gives when it declines them, and what a reader returns.
This module imports nothing else of the package, so that every layer of it may refuse faces the same way.
- class volmdlr_tools.refusals.FaceRefusal(reason: str, face_ids: tuple[int, ...] = (), area: float | None = None, reader: str = '')#
Bases:
objectFaces of a part that a reader declines, and why.
- Parameters:
reason – What made the faces unreadable.
face_ids – The faces the refusal is about; empty when it is about the whole part.
area – The area of those faces, when it is known.
reader – The reader whose reading the refusal sets aside, or that declined the faces; empty when it is not said. A reading several readers agreed on names each of them in the order they read it, joined by
"/":"interacting/depression_protrusion".
- property failed: bool#
Whether the reader the refusal names raised, so that it read nothing.
- property out_of_time: bool#
Whether the faces were not read because the reader’s time ran out, rather than because they do not fit.
- class volmdlr_tools.refusals.FailedReading(refusal: FaceRefusal, error: Exception)#
Bases:
objectA refusal that a failure caused, with the exception behind it.
- Parameters:
refusal – The faces declined, and why; its reason names the failure.
error – The exception the reader met on those faces and read on past.
- class volmdlr_tools.refusals.Readings(items: Iterable = (), *, timed_out: bool = False)#
Bases:
tupleWhat a reader read, in order, and whether its time ran out before it had read all it would have.
It is a tuple of the readings themselves.
timed_outtells a part that has no more of them from a reading that stopped short. Two of them compare equal when their readings do, whether or not the time ran out for either:timed_outsays how the readings came to be, not what they are.- Parameters:
items – The readings.
timed_out – Whether the reader’s time ran out before it was done.
volmdlr_tools.errors module#
What a caller can get wrong at this package’s entry points.
Handing an entry point the wrong kind of argument used to fail deep inside, on an
internal attribute the caller never chose to touch — an AttributeError that sends
them reading this library’s source instead of their own call. The errors here are
raised at the door instead, and name both what the door accepts and what it was given.
- exception volmdlr_tools.errors.FeatureRecognitionError#
Bases:
RuntimeErrorRaised when recognition would give an answer that contradicts itself, such as a face given two statuses.
It is also raised in strict mode (
strict=True) when a reader fails: the reader’s exception is raised as this error, the original kept as its cause, instead of recorded as a refusal over the part.A reading that does not fit a part is not an error: it is refused, with its reason, in the recognition document.
- exception volmdlr_tools.errors.ShapeTypeError#
Bases:
TypeErrorRaised when an entry point is given something it cannot read faces from.
It is a
TypeErrorbecause that is what a wrong argument type is, so a caller who already guards for one keeps catching it; it is a named subclass so a caller who wants to tell “not a shape I can work on” apart from any otherTypeErrorraised inside a geometric call can do so.
- exception volmdlr_tools.errors.UnsupportedSheetMetalError#
Bases:
ValueErrorRaised when a sheet-metal part is built in a way its recognition does not support.
A formed feature that meets the sheet along sharp edges instead of bends — a stiffener rib without rounds, a bridge strip cut square — is one such case: the faces across the sheet’s thickness no longer run round in single loops, and no feature of the part is extracted. It is a
ValueErrorbecause the argument is a solid whose content cannot be read as sheet metal.
- volmdlr_tools.errors.validate_shape(shape: Any, entry_point: str) None#
Refuse shape unless it is a shape whose faces can be read.
Call this before reading anything off shape, so that a wrong argument is reported as a wrong argument rather than as a missing attribute — or, for a face or an edge, rather than as an empty graph, which is the failure that looks like an answer.
- Parameters:
shape – The argument handed to the entry point.
entry_point – The entry point’s class name, quoted back in the message.
- Raises:
ShapeTypeError – When shape is not a body or a collection of bodies. The message names what is accepted and what was received, and adds the remedy for the two mistakes this door sees most: a
VolumeModel, and a lone sub-shape.
volmdlr_tools.features.constants module#
Constants for feature extraction and processing.
This module defines constants used throughout the feature extraction system. Using Enums instead of plain strings provides: - Type safety and IDE autocompletion - Protection against typos - Clear grouping of related values
- class volmdlr_tools.features.constants.ExtractionMode(*values)#
Bases:
str,EnumMode for coaxial feature extraction.
Controls whether to extract internal (bores, fillets) or external (bosses, shafts) coaxial features.
- Attributes:
- EXTERNAL: Extract external features (bosses, shafts, external rounded edges).
Surface normal points away from axis. Propagates through CONVEX edges.
- INTERNAL: Extract internal features (bores, holes, internal fillets).
Surface normal points toward axis. Propagates through CONCAVE edges.
- EXTERNAL = 'external'#
- INTERNAL = 'internal'#
- volmdlr_tools.features.constants.FREE_FORM_SURFACE_TYPES: frozenset[str] = frozenset({'BSplineSurface', 'BezierSurface'})#
The surface types of a free-form face, drawn through poles rather than named by a few dimensions.
- class volmdlr_tools.features.constants.FeatureCategory(*values)#
Bases:
str,EnumHigh-level category of manufacturing features.
- Variables:
CUT – Material removal features (slots, notches, holes).
ADDITION – Material addition features (bosses, shafts, extrusions).
FORMING – Deformation features (bends, jogs).
BLEND – Fillet/chamfer features.
CAVITY – Pocket/cavity features.
UNKNOWN – Unclassified features.
- ADDITION = 'addition'#
- BLEND = 'blend'#
- CAVITY = 'cavity'#
- CUT = 'cut'#
- FORMING = 'forming'#
- UNKNOWN = 'unknown'#
- class volmdlr_tools.features.constants.FeatureLocation(*values)#
Bases:
str,EnumLocation of features on sheet metal parts.
- Variables:
BOUNDARY – Features on the outer boundary of the sheet metal.
INTERNAL – Features in the internal area of the sheet metal.
- BOUNDARY = 'boundary'#
- INTERNAL = 'internal'#
- class volmdlr_tools.features.constants.FeatureType(*values)#
Bases:
str,EnumSpecific kind of manufacturing feature.
Declared on each
Featurefamily viafeature_type = FeatureType.X. Acts as a serialisable type tag so downstream code (defeaturing, reverse-engineering, UI) can branch withoutisinstancechecks. Subclasses that are sub-variants of a kind (e.g.RoundHoleunderHOLE) inherit their parent’s value.- ANNULAR_GROOVE = 'annular_groove'#
- BEAD = 'bead'#
- BEND = 'bend'#
- BLEND = 'blend'#
- BLEND_CHAIN = 'blend_chain'#
- BLIND_HOLE = 'blind_hole'#
- BLIND_SLOT = 'blind_slot'#
- BLIND_STEP = 'blind_step'#
- CAVITY = 'cavity'#
- CHAMFER = 'chamfer'#
- CHAMFER_CHAIN = 'chamfer_chain'#
- CONE = 'cone'#
- CORNER = 'corner'#
- COUNTERBORE = 'counterbore'#
- COUNTERDRILL = 'counterdrill'#
- COUNTERSINK = 'countersink'#
- CURL = 'curl'#
- CYLINDER = 'cylinder'#
- DIMPLE = 'dimple'#
- EMBOSS = 'emboss'#
- EXTRUSION = 'extrusion'#
- EXTRUSION_HOLE = 'extrusion_hole'#
- FLANGED_CUTOUT = 'flanged_cutout'#
- GUSSET = 'gusset'#
- HEM = 'hem'#
- HOLE = 'hole'#
- HOOK = 'hook'#
- JOG = 'jog'#
- LANCE = 'lance'#
- LOUVRE = 'louvre'#
- NOTCH = 'notch'#
- OPEN_POCKET = 'open_pocket'#
- OUTLINE_CUT = 'outline_cut'#
- PASSAGE = 'passage'#
- PERFORATION = 'perforation'#
- PLANAR_TRIM = 'planar_trim'#
- POCKET = 'pocket'#
- POLYGONAL_CAVITY = 'polygonal_cavity'#
- RECTANGULAR_CAVITY = 'rectangular_cavity'#
- RELIEF = 'relief'#
- RIB = 'rib'#
- RIB_STRUCTURE = 'rib_structure'#
- ROUND_CAVITY = 'round_cavity'#
- SECTOR_CAVITY = 'sector_cavity'#
- SLOT = 'slot'#
- SLOTTED_CAVITY = 'slotted_cavity'#
- SQUARE_CAVITY = 'square_cavity'#
- STEP = 'step'#
- STEPPED_HOLE = 'stepped_hole'#
- TAB = 'tab'#
- TAPER_HOLE = 'taper_hole'#
- THROUGH_HOLE = 'through_hole'#
- THROUGH_SLOT = 'through_slot'#
- TORUS = 'torus'#
- UNKNOWN = 'unknown'#
- is_hole() bool#
Verify is feature type if a kind of Hole.
- volmdlr_tools.features.constants.MIN_CHAMFER_UNDER_ANGLE_DEG: float = 100.0#
The least angle, in degrees, a chamfer face makes with each face it is cut between: a square step makes 90.
- volmdlr_tools.features.constants.extractions_summary(extractions: frozenset[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']]) str#
Name the extractions in a fixed order, for a message or a summary line.
Lives here, beside the literal it formats, because two modules render the same fact — the processor’s summaries and the face-coverage report — and two renderings of one fact drift.
- Parameters:
extractions – The extractions to name.
- Returns:
The names comma-separated and sorted, or
"none"when there are no extractions, so a summary line never reads as a blank.
volmdlr_tools.features.pattern_matcher module#
Pattern Matcher Module.
- class volmdlr_tools.features.pattern_matcher.GraphMatcher(G1: Graph, G2: Graph, node_match=None, edge_match=None, min_similarity: float = 0.8)#
Bases:
GraphMatcherOverride nx GraphMatcher class.
- class volmdlr_tools.features.pattern_matcher.PatternMatcher(graph_assembly: GraphAssembly, angular_tol: float = 1e-06, min_similarity: float = 1.0, min_face_signature_similarity: float = 1.0, name: str = '')#
Bases:
DessiaObjectA class for finding geometric patterns within a graph assembly structure.
This class provides functionality to search for specific subgraph patterns within a larger graph assembly, particularly focusing on solid geometries and their face relationships.
- Parameters:
graph_assembly – The graph assembly structure to search for patterns within.
angular_tol – Angular tol parameter in radians.
name – A descriptive name for the pattern matcher instance, defaults to ‘’
- EXACT_MATCH_SIMILARITY = 1.0#
- find_matches_from_multiple_patterns(patterns: list[AttributedAdjacencyGraph]) list[list[int]]#
Find patterns matches within a graph assembly structure for a list of different patterns.
- find_pattern_matches(pattern_graph: AttributedAdjacencyGraph) list[Shell]#
Find all occurrences of a pattern graph within the assembly’s solid nodes.
This method searches through all solid nodes in the graph assembly, extracts their associated adjacency graphs (AAG), and identifies subgraphs that match the given pattern using isomorphism detection.
- Parameters:
pattern_graph – The pattern graph to search for.
exact – If true, only return subgraphs that match the pattern graph.
If False, approximate solutions may be accepted. :returns: A list of matches, where each match is a list of Face objects
corresponding to the nodes in the pattern.
- matrix_similarity_verification(pattern_graph: AttributedAdjacencyGraph, target_graph: AttributedAdjacencyGraph) set#
Verify the similarity between two adjacency matrices.
- static row_similarity_scipy(sig1_batch, sig2_batch)#
Use scipy’s optimized distance computation.
- volmdlr_tools.features.pattern_matcher.prepare_graph(graph: AttributedAdjacencyGraph, tolerance: float = 1.0, n_bins: int = 150, n_points: int = 10000) None#
Prepare a pattern graph for matching.
It calculates all nodes degree and adds a node attribute with its value.
volmdlr_tools.features.spring_pattern_matcher module#
Spring Pattern Matcher Module.
- class volmdlr_tools.features.spring_pattern_matcher.SpringPatternMatcher(graph_assembly: GraphAssembly, angular_tol: float = 1e-06, min_similiraty: float = 1.0, name: str = '')#
Bases:
PatternMatcherA pattern matcher for identifying spring-like geometric patterns in 3D models.
This class extends FacePatternMatcher to specifically identify patterns that resemble specific springs by analyzing face relationships, distances, and plane parallelism.
- Parameters:
(list[int]) (NO_VISIT_COUNT_INDEXES) – Indexes that should not be counted during visits (11, 23).
- NO_VISIT_COUNT_INDEXES = (0, 1)#
- static cluster_points_kmeans(points: ndarray, points_per_group: int = 4) tuple[ndarray, ndarray, list[ndarray]]#
Cluster 3D points into groups of specified sizes using K-means.
- Parameters:
points – Numpy array of shape (n, 3) containing 3D coordinates.
points_per_group – Number of points per cluster (default 4)
- Returns:
labels: cluster labels for each point centroids: cluster centers groups: list of point groups
- get_springs(pattern_graph: AttributedAdjacencyGraph) list[Compound]#
Extract springs from a pattern graph by identifying patterns, clustering them, and building spring compounds.
- Parameters:
pattern_graph – The faces graph containing pattern data from which springs are to be extracted.
- Returns:
A list of spring compounds constructed from the patterns in the graph.
volmdlr_tools.features.edge_lines module#
This module provides functionality for finding specific patterns in attributed adjacency graphs.
Particularly useful for analyzing geometric structures with angular relationships between faces.
- class volmdlr_tools.features.edge_lines.EdgeLines(aag: AttributedAdjacencyGraph, angle_tolerance: float = 5, name: str = '')#
Bases:
SharpEdgeExtractorIdentifies border edges formed by faces meeting at approximately 90 degrees.
This class analyzes angular relationships between adjacent faces in a 3D model to detect sharp, convex edges. Edges are classified as sharp if the angle between the connected faces is close to 90 degrees, within a given tolerance.
- perform() None#
Detect and cache sharp convex edges formed at approximately 90 degrees.
Iterates through edges in the model, evaluates the angle between adjacent faces, and marks edges as sharp if the angle is convex and near 90 degrees.
volmdlr_tools.features.geometry_helpers module#
Shared geometry helpers for the feature pipeline.
Public home for predicates and accessors that the extractor layer, the feature-type layer, and the reverse-engineering engines all need. Each helper either reads cached attributes on the AAG (fast path) or performs a single OCP query — never both.
Engines, reversers, and extractors should import from here rather than defining their own copies; the previous duplication caused drift between the AAG-cached fast path and the BRepAdaptor-rebuilding slow path.
- volmdlr_tools.features.geometry_helpers.DIRECTION_TOLERANCE = 0.017453292519943295#
Two directions count as parallel, or square to each other, within this angle.
- class volmdlr_tools.features.geometry_helpers.FaceInterior(face: TopoDS_Face, tol: float = 1e-06)#
Bases:
objectTell whether points of a face’s surface lie strictly inside the face, boundary excluded.
Made once per face and asked many times: faster than calling
is_point_strictly_inside()again and again for the same face.- holds(point: gp_Pnt) bool#
Whether the point is strictly inside the face.
The point must lie on the face’s surface; a point off it may be reported as outside.
- Parameters:
point – The point to classify.
- Returns:
True when the point is inside the face and not on its boundary.
- volmdlr_tools.features.geometry_helpers.across_axis_frame(axis: Vector3D) tuple[Vector3D, Vector3D]#
Return two unit directions spanning the plane across an axis, the same two for the same axis.
- Parameters:
axis – A unit axis.
- Returns:
Two unit directions square to the axis and to each other, the second the axis crossed with the first.
- volmdlr_tools.features.geometry_helpers.are_parallel(direction: Sequence[float], other: Sequence[float], tolerance: float = 0.017453292519943295) bool#
Return whether two unit directions, in the plane or in space, lie along one line, either way round.
- Parameters:
direction – A unit direction.
other – Another, with as many components.
tolerance – The largest angle between them, in radians.
- volmdlr_tools.features.geometry_helpers.are_square(direction: Sequence[float], other: Sequence[float], tolerance: float = 0.017453292519943295) bool#
Return whether two unit directions, in the plane or in space, are at a right angle.
- Parameters:
direction – A unit direction.
other – Another, with as many components.
tolerance – The largest angle from a right angle, in radians.
- volmdlr_tools.features.geometry_helpers.axial_extent(faces: Iterable, direction: Vector3D) float#
Return how far a set of faces reaches along direction.
The span the faces themselves occupy, measured along the direction given — the distance between the first and last of them a plane sweeping that way would touch.
A box drawn around the faces is not a stand-in for this. A box has an orientation of its own, chosen to fit what it encloses, and where that differs from direction the box reaches further along it than its contents do. Measuring the faces in a frame that direction itself defines has no such freedom left in it.
- Parameters:
faces – Faces to measure, as volmdlr faces or their underlying shapes.
direction – Unit vector to measure along. Its sign does not matter.
- Returns:
The length of the span, or
0.0when no faces were given.
- volmdlr_tools.features.geometry_helpers.bbox_diagonal(shape: Shape) float#
Return the bounding-box diagonal of a shape — the model’s overall size.
The unit-agnostic scale reference used by scale-aware defaults (rib max-thickness fraction, measurement ray cutoffs): a fraction of the diagonal means the same thing on a millimetre fixture and a metre-scale part.
- volmdlr_tools.features.geometry_helpers.canonical_direction(direction: Vector3D) Vector3D#
Return direction with a deterministic sign.
Some directions are built in a way that fixes the line but not the arrow along it — a cross product of two plane normals, say, where both the operand order and each normal’s own sign are incidental. Such a direction would otherwise flip on a change as small as the order faces are iterated in, which makes it unusable in a recorded expectation.
The sign is fixed by making the largest-magnitude component positive. Keying on the first non-negligible component instead would key on float noise for a direction like
(0, 2e-6, 1), whose y sign is not reproducible across builds — reintroducing the very flip this prevents. This is a convention, not an orientation: it says nothing about which way the material lies.- Parameters:
direction – Direction whose sign is incidental.
- Returns:
The same line, signed the same way every time.
- volmdlr_tools.features.geometry_helpers.chain_end_to_end(pieces: Sequence[_Piece], ends: Callable[[_Piece], tuple[Sequence[float], Sequence[float]]], join: float, closed: bool = False) list[tuple[_Piece, bool]] | None#
Chain pieces, given in any order and direction, end to end into one run.
- Parameters:
pieces – The pieces to chain.
ends – Gives the two ends of a piece, as points.
join – Two ends this close meet.
closed – Whether the pieces must close into a loop; otherwise they must make one open run.
- Returns:
Each piece in order with whether it is walked from its second end to its first, or None when they do not chain as asked.
- volmdlr_tools.features.geometry_helpers.faces_are_anti_parallel(aag: AttributedAdjacencyGraph, first: int, second: int, tolerance: float = 0.1) bool#
Whether two planar faces have normals pointing in opposite directions; see
normals_are_anti_parallel().
- volmdlr_tools.features.geometry_helpers.faces_standing_inside(aag: AttributedAdjacencyGraph, below: int) frozenset[int]#
Return the faces that meet face below only along its inner wires, never along its outer wire.
What stands inside a face, as a boss inside the face it rises from, meets it so; a wall running out to the face’s outline, as a step’s wall to its floor, does not.
- volmdlr_tools.features.geometry_helpers.get_face_plane_normal(face: Face) Vector3D#
Return the unit normal of a planar face, read straight off its surface.
Its sign is arbitrary with respect to the material: the direction comes from the underlying
Geom_Planeaxis, honouring neitherTopAbs_REVERSEDnor the frame’s handedness, so it must only be used up to sign (seeis_axis_parallel(),is_axis_perpendicular()). For the outward normal of a face, useoutward_plane_normal(); of an AAG node,get_plane_normal().- Parameters:
face – A planar face.
- Returns:
Unit vector normal to the face’s plane.
- volmdlr_tools.features.geometry_helpers.get_interior_point_and_normal(aag: AttributedAdjacencyGraph, node: int) tuple[Point3D, Vector3D] | None#
Return a representative interior point and the outward normal there.
Works for any surface type. The normal honours the face’s
TopAbs_REVERSEDorientation so it points out of the material (matchingget_plane_normal()); for planar faces it short-circuits to the cached plane normal. Point and normal are sampled at the same parametric location, so they stay mutually consistent. ReturnsNonewhen no strictly interior sample exists or the surface normal is undefined there.
- volmdlr_tools.features.geometry_helpers.get_interior_points(aag: AttributedAdjacencyGraph, node: int) list[Point3D]#
Return representative points within a face, never an empty list.
The boundary-accepting instance of
interior_point_candidates()(projection-based containment, 10x10 grid) that the rib samplers use; see that function for the ladder and the best-effort caveat on the result.
- volmdlr_tools.features.geometry_helpers.get_outer_wire_edges(aag: AttributedAdjacencyGraph, face_id: int) list#
Return
TopoDS_Edgeobjects of face_id’s outer wire, in order.
- volmdlr_tools.features.geometry_helpers.get_plane_normal(aag: AttributedAdjacencyGraph, face_id: int) Vector3D#
Return the outward normal of a planar face.
Honours the face’s
TopAbs_REVERSEDorientation and the handedness of the plane’s frame (outward_plane_normal()), so the returned direction points out of the material rather than along the surface’s canonical axis — unlikeget_face_plane_normal(), which reads the surface axis directly and is only usable up to sign. Uses the AAG node’s cachedplane_normalwhen available (populated for planar faces during AAG construction); falls back to reading the face otherwise. For a face rather than a node, useoutward_plane_normal().- Raises:
ValueError – When the face is not planar.
- volmdlr_tools.features.geometry_helpers.grid_interior_points(ocp_face: TopoDS_Face, grid_size: int) Generator[Point3D, Any, None]#
Yield points of a UV grid that land inside the face’s trimmed area.
The grid spans the 0.05-0.95 parametric range — inset from the edges so samples do not cling to the boundary — and is
grid_sizeper axis, so the cost isgrid_size ** 2point classifications. On a heavily trimmed face most samples fall outside and few are yielded; on a sliver, none are, so callers must handle an empty result.- Parameters:
ocp_face – The face to sample.
grid_size – Samples per parametric axis.
- Returns:
Generator of points inside the face; possibly empty.
- volmdlr_tools.features.geometry_helpers.interior_point_candidates(ocp_face: TopoDS_Face, containment: Callable[[gp_Pnt, TopoDS_Face], bool], grid_fractions: Sequence[float], finer_grid_fractions: Sequence[float] = ()) list[Point3D]#
Return representative points within a face, never an empty list.
The cheapest-first sampling ladder shared by the lenient and strict interior samplers — the containment predicate and grid density are the caller’s, because they are tuned pairs (the interacting-features accessibility filter was tuned with strict containment on a 9x9 grid; the rib samplers with boundary-accepting containment on a 10x10 grid):
the centre of mass — one point;
failing that, the UV mid-point — one point;
failing that, the
grid_fractionsxgrid_fractionsUV grid — every sample that passes containment;failing that, the
finer_grid_fractionsgrid the same way, when the caller gives one — for a face thinner than the first grid’s spacing.
If even the grids come up empty (a sliver, or a face whose trimmed area excludes its whole parametric interior) the centre of mass is returned as a best effort. That point is known NOT to pass containment — it already failed step 1 — so treat the result as “a place to sample from”, not as a guaranteed-interior point.
- Parameters:
ocp_face – The face to sample.
containment – Predicate deciding whether a sampled point counts as inside the face (e.g.
is_point_strictly_inside()oris_point_on_or_inside_face()).grid_fractions – Parametric fractions of the UV range sampled per axis in the grid rung.
finer_grid_fractions – Parametric fractions sampled per axis in the last rung, if the first grid finds nothing; no such rung when empty.
- Returns:
Points accepted by containment, or the best-effort centre.
- volmdlr_tools.features.geometry_helpers.is_axis_parallel(direction: Vector3D, axis: Vector3D, tolerance: float = 1e-06) bool#
Return True if direction is parallel (or anti-parallel) to axis.
Uses
abs(direction · axis) > 1 - toleranceso the test is direction- agnostic — a face whose normal points opposite to axis still counts as parallel. axis is expected to be unit-length.
- volmdlr_tools.features.geometry_helpers.is_axis_perpendicular(direction: Vector3D, axis: Vector3D, tolerance: float = 0.001414213562373095) bool#
Return True if direction is perpendicular to axis.
The perpendicular counterpart of
is_axis_parallel(): usesabs(direction . axis) < tolerance, so it too is sign-agnostic. Both vectors are expected to be unit-length.The default tolerance is
PERPENDICULAR_DOT_TOL, not the parallel one — nearcos = 0the cosine varies at full rate, so admitting the same angular deviation takes a much larger number than it does nearcos = 1.- Parameters:
direction – Unit direction to test.
axis – Unit reference axis.
tolerance – Cosine-space window around perpendicularity.
- Returns:
True when the two are perpendicular within tolerance.
- volmdlr_tools.features.geometry_helpers.is_nearly_planar_face(aag: AttributedAdjacencyGraph, node: int, angular_tol: float = 0.08726646259971647) bool#
Return True if the face is flat enough to stand in for a planar end face.
True planes pass immediately. BSpline/Offset faces pass when no two sampled normals differ by more than
angular_tol(radians) across a UV grid — the “almost flat” gate that makes a single representative normal meaningful. Any other surface type returns False.The dot products are signed on purpose. A single face’s normal field is continuous, so a sign flip means the surface folded back on itself, not that it is flat: taking
abswould score a U-curled face as perfectly planar. Samples are compared pairwise rather than against the first one, soangular_tolbounds the true spread instead of twice it.
- volmdlr_tools.features.geometry_helpers.is_planar_face(aag: AttributedAdjacencyGraph, face_id: int) bool#
Return True if the face’s surface is a plane.
Reads the AAG node’s pre-computed
surface_typeattribute set during AAG construction; avoids the redundantBRepAdaptor_Surfacebuild on every call.
- volmdlr_tools.features.geometry_helpers.is_planar_perpendicular_to_axis(aag: AttributedAdjacencyGraph, face_id: int, axis: Vector3D, tolerance: float = 1e-06) bool#
Return True if face face_id is planar with normal parallel to axis.
Combination of
is_planar_face()andis_axis_parallel(). Equivalent to “the face’s plane is perpendicular to axis”.
- volmdlr_tools.features.geometry_helpers.is_point_on_or_inside_face(point: gp_Pnt, face: TopoDS_Face, tol: float = 1e-06) bool#
Check if a point lies within a face’s trimmed area, boundary included.
Unlike
is_point_strictly_inside(), the point does not have to lie exactly on the surface: it is first projected onto the underlying surface and rejected if that projection is farther thantol, then classified in UV space. Points on the trimming boundary count as inside — callers sampling a parametric grid rely on that, since a sample can land exactly on an edge.- Parameters:
point – The 3D point to classify.
face – The face to classify against.
tol – Maximum allowed point-to-surface projection distance. This bounds how far off the surface the point may sit; it does NOT widen the boundary margin, which uses a fixed 1e-7 UV tolerance.
- Returns:
True when the point projects onto the surface within
toland classifies asTopAbs_INorTopAbs_ON.
- volmdlr_tools.features.geometry_helpers.is_point_strictly_inside(point: gp_Pnt, face: TopoDS_Face, tol: float = 1e-06) bool#
Check if a point is strictly inside a face — boundary points are excluded.
The point must already lie on the face’s surface;
tolis the classifier’s own tolerance. Useis_point_on_or_inside_face()when the point may sit slightly off the surface, or when a point exactly on the boundary should count.- Parameters:
point – The 3D point to classify.
face – The face to classify against.
tol – Classification tolerance passed to
BRepClass_FaceClassifier.
- Returns:
True when the point classifies as
TopAbs_IN.
- volmdlr_tools.features.geometry_helpers.largest_tolerance(shape: TopoDS_Shape) float#
Return the largest edge or vertex tolerance of shape.
How far the shape’s edges may stray from the faces they bound: on an imported STEP file an edge’s 3D curve can sit this far off its face.
- volmdlr_tools.features.geometry_helpers.lie_in_one_plane(aag: AttributedAdjacencyGraph, first: int, second: int) bool#
Whether two planar faces lie in one plane and face the same way.
- volmdlr_tools.features.geometry_helpers.normals_are_anti_parallel(dot: float, tolerance: float = 0.1) bool#
Whether two unit normals whose dot product is dot point in opposite directions, within a cone.
Only the directions are compared, not where the faces lie: two walls of a slot facing each other across it pass, and so do two sides of a block facing away from each other. The default
ANTI_PARALLEL_NORMAL_TOL(a cone of about 25 degrees) is wide on purpose: real opposing slot and step walls drift several degrees from perfect anti-parallelism through draft and modelling.- Parameters:
dot – The dot product of the two normals, or an array of them, answered element by element.
tolerance – Cosine-space tolerance, compared as
dot < -1 + tolerance;DIVERGING_NORMAL_TOLwidens the cone to faces that only diverge.
- volmdlr_tools.features.geometry_helpers.part_lies_behind_face(aag: AttributedAdjacencyGraph, node: int, part_points: ndarray, tolerance: float) bool | None#
Return whether the whole part lies behind the tangent plane of face node.
True of a face of the part’s convex hull, a face the part could rest on; False when part of the part lies beyond it, as beyond the wall of a notch. A flat face is judged against its own plane, which needs no point inside it: a sliver of a floor too thin for any sampled interior point is still judged. Any other face’s tangent plane is taken at one interior point of it.
- Parameters:
aag – The graph the face belongs to.
node – The face to test.
part_points – Points standing in for the whole part, such as
sample_shape_edge_points()of its shape.tolerance – How far beyond the plane a point may lie and still count as behind it.
- Returns:
The verdict, or None when the face has no usable interior point or normal.
- volmdlr_tools.features.geometry_helpers.part_lies_behind_plane(part_points: ndarray, origin: Point3D, normal: Vector3D, tolerance: float) bool#
Return whether every point of a part lies behind a plane, on the side its normal points away from.
- Parameters:
part_points – Points standing in for the whole part, one per row.
origin – A point of the plane.
normal – The plane’s unit normal.
tolerance – How far beyond the plane a point may lie and still count as behind it.
- volmdlr_tools.features.geometry_helpers.piece_span(shape: TopoDS_Shape, direction: Vector3D, *, exact: bool = True) tuple[float, float] | None#
Return where one shape starts and ends along direction, without remembering the answer.
The span
span_along()gives for that shape, for a caller that measures many pieces of a part once each and does not want them to push the parts measured last out of the memory ofspan_along().- Parameters:
shape – A face, edge or any shape, as its underlying shape.
direction – Unit vector to measure along.
exact – When False, a span that is never shorter than the exact one, cheap to get: it may reach past the shape where the shape is curved or loosely joined. It rules out a long exact measurement; it is not one.
- Returns:
(start, end), or None for a shape with no extent.
- volmdlr_tools.features.geometry_helpers.point_and_normal_on_face(aag: AttributedAdjacencyGraph, node: int, near_point: Point3D, pull_toward: Point3D, offset_distance: float) tuple[Point3D, Vector3D] | None#
Return a strictly interior point of the face near near_point, with the outward normal there.
Moves near_point by offset_distance toward pull_toward (a point interior to the face), re-projects onto the surface, requires strict interiority, and evaluates the outward normal at that exact UV — per-sample local normals, so curved and nearly-planar faces are handled correctly. Retries with halved offsets when the projection lands outside the trimmed face (short or narrow faces). Complements
get_interior_point_and_normal(), which picks some interior point; this one picks an interior point near a location the caller chose.- Parameters:
aag – The model’s attributed adjacency graph.
node – AAG face index.
near_point – Anchor location, typically on or near the face’s boundary.
pull_toward – A point interior to the face; sets the offset direction.
offset_distance – How far to move from near_point toward pull_toward.
- Returns:
(point, outward_normal)sampled at the same UV, or None when no retry produces a strictly interior projection or the normal is undefined.
- volmdlr_tools.features.geometry_helpers.projected_uv_if_strictly_inside(point: gp_Pnt, face: TopoDS_Face, classifier_tolerance: float = 1e-07) tuple[float, float] | None#
Project point onto the face’s surface; return the UV only if strictly inside.
Unlike
is_point_on_or_inside_face(), boundary points (TopAbs_ON) are rejected and the projection distance is not bounded — the caller may pass a point that sits well off the surface (e.g. offset along a chord of a curved face) and wants the nearest on-surface parameter. Returning the UV lets the caller evaluate the surface point and normal there without projecting twice.- Parameters:
point – The 3D point to project.
face – The face whose trimmed area must strictly contain the projection.
classifier_tolerance – UV tolerance for
BRepClass_FaceClassifier.
- Returns:
The
(u, v)of the projection, or None when the projection fails or lands on/outside the trimming boundary.
- volmdlr_tools.features.geometry_helpers.runs_along(direction: gp_Dir | None, line: gp_Dir) bool#
Whether direction runs along line, either way, within
PARALLEL_DOT_TOL.
- volmdlr_tools.features.geometry_helpers.sample_edge_points(edge: TopoDS_Shape, count: int, start_fraction: float = 0.0, end_fraction: float = 1.0) list[Point3D]#
Sample
countpoints along an edge at equal parameter fractions.Fractions are of the edge’s raw parameter range, not arc length, so on splines and conics the spacing is not metrically uniform (use
GCPnts_QuasiUniformAbscissawhen uniform spacing matters). Narrow the[start_fraction, end_fraction]window to skip the edge’s ends — e.g.(0.15, 0.85)avoids corner junctions when the samples seed measurements near, but not on, the edge’s vertices.- Parameters:
edge – The edge to sample (
TopoDS_Edgeor a shape downcastable to one).count – Number of points to return.
start_fraction – Parameter fraction of the first sample (0 = edge start).
end_fraction – Parameter fraction of the last sample (1 = edge end).
- Returns:
The sampled points, ordered along the parameter range.
- volmdlr_tools.features.geometry_helpers.sample_shape_edge_points(shape: TopoDS_Shape, count: int) ndarray#
Return
countpoints along every edge of shape, as an(n, 3)array.Each edge is sampled once, however many faces share it.
- Parameters:
shape – The shape whose edges to sample.
count – Number of points per edge, see
sample_edge_points().
- volmdlr_tools.features.geometry_helpers.span_along(shapes_to_measure: Iterable, direction: Vector3D) tuple[float, float] | None#
Return where a set of shapes starts and ends along direction.
The coordinates along direction of the first and last point of them a plane sweeping that way would touch, measured from the origin — so spans of different shapes taken along the same direction can be compared. See
axial_extent()for why this is not read off a box.- Parameters:
shapes_to_measure – Faces, edges or any shapes, as volmdlr objects or their underlying shapes.
direction – Unit vector to measure along.
- Returns:
(start, end), or None when nothing was given.
- volmdlr_tools.features.geometry_helpers.stands_inside_the_outline(aag: AttributedAdjacencyGraph, node: int, below: int) bool#
Whether face node meets face below only along below’s inner wires; see
faces_standing_inside().
- volmdlr_tools.features.geometry_helpers.straight_edge_direction(aag: AttributedAdjacencyGraph, edge_index: int) gp_Dir | None#
Return the direction of a straight edge, or None for a curved or unknown one.
- volmdlr_tools.features.geometry_helpers.straight_edges(edges_to_read: Iterable, axis: Vector3D | None = None, running: Literal['along', 'across'] = 'along') list[tuple[Point3D, Point3D]]#
Return the two ends of each straight edge among some edges, or of those running along or across an axis.
- Parameters:
edges_to_read – Edges, as volmdlr objects or their underlying shapes.
axis – When given, only the edges running along this unit axis, or across it, are kept.
running –
"along"keeps the edges parallel to axis,"across"those square to it.
- Returns:
The ends of every straight edge of some length kept, in the order given.
- volmdlr_tools.features.geometry_helpers.turns_about_normal_of(aag: AttributedAdjacencyGraph, round_face: int, plane_face: int) bool#
Whether a round is a cylinder turning about the normal of a flat face.
Such a round is a corner of an outline drawn on that face, and none of the rounds along its edges turn so. The direction counts as the normal’s within the angle that makes two directions one axis (see
AXIS_ANGLE_TOLERANCE).- Parameters:
aag – The part’s adjacency graph.
round_face – The face to test.
plane_face – The face whose normal is the reference; the answer is False when it is not flat.
- Returns:
True when round_face is a cylinder turning about plane_face’s normal.
- volmdlr_tools.features.geometry_helpers.wire_edges(wire: TopoDS_Wire) list[TopoDS_Edge]#
Return the
TopoDS_Edgeobjects of wire, in order along it.
volmdlr_tools.features.unfold package#
Lay a recognised sheet-metal part flat: the blank, its bend lines, slits and forming marks.
volmdlr_tools.features.unfold.flat_pattern module#
The flat blank a sheet-metal part is cut from, and what the press needs to know about it.
Everything here is a plain value: 2D geometry in the part’s own length unit, angles in radians, and the face indices of the part the values came from.
- class volmdlr_tools.features.unfold.flat_pattern.BendLine(start: Point2D, end: Point2D, angle: float, direction: Literal['up', 'down'], inside_radius: float, k_factor: float, thickness: float, bend_nodes: list[int], name: str = '')#
Bases:
DessiaObjectWhere the press brake folds the blank, and how.
- Parameters:
start – One end of the bend’s centre line on the blank.
end – The other end.
angle – The included turn of the material, in radians.
direction –
"up"when the sheet folds toward the viewer of the blank.inside_radius – The bend’s inside radius.
k_factor – The K-factor the bend was developed with.
thickness – The sheet thickness.
bend_nodes – Face indices of the bend.
- property allowance: float#
Return the developed length across the bend.
- class volmdlr_tools.features.unfold.flat_pattern.FlatPattern(blank: Surface2D, bend_lines: list[BendLine], slits: list[Edge], forming_marks: list[FormingMark], face_placements: dict[int, Contour2D], k_factor: float, thickness: float, fixed_face: int, length_unit: Literal['m', 'mm', 'in'] = 'm', unplaced_holes: list[UnplacedHole] | None = None, name: str = '')#
Bases:
DessiaObjectThe blank a sheet-metal part is cut from, with what the press brake and the press need.
The blank is seen from outside the developed side of the sheet: that side’s outward normal points at the viewer, which is what
"up"means for bends and forming marks.- Parameters:
blank – The cut outline: outer contour and holes (pre-holes included).
bend_lines – One per fold: bend, hem or curl.
slits – Zero-width cuts.
forming_marks – One per formed feature.
face_placements – Each developed face index and its outline on the blank.
k_factor – The K-factor used.
thickness – The sheet thickness used.
fixed_face – The face the blank was developed from.
length_unit – The unit every length of the pattern is in: the unit of the part it was developed from. A part read from a file the usual way is in metres.
unplaced_holes – The holes cut at the developed side’s opening because their other opening could not be laid onto the blank, so the blank may cut them too wide.
- property area: float#
Return the blank’s area, holes subtracted.
- property bounding_rectangle: NestingRectangle#
Return the rectangle, at any angle, that holds the blank, with no part of the blank outside it.
The direction is that of the smallest rectangle through points sampled along the outline; the sides are then set by the blank’s exact extent in that direction, arcs included.
- property flagged_marks: list[FormingMark]#
Return the forming marks whose hole to pierce the blank does not give.
- class volmdlr_tools.features.unfold.flat_pattern.FormingMark(feature_type: Literal['emboss', 'dimple', 'bead', 'louvre', 'flanged_cutout', 'extrusion_hole'], position: Point2D, orientation: Vector2D, depth: float, side: Literal['up', 'down'], footprint: Contour2D, feature_nodes: list[int], pre_hole: Contour2D | None = None, pre_hole_issue: Literal['', 'collar_too_tall'] = '', pre_hole_note: str = '', name: str = '')#
Bases:
DessiaObjectA feature the press forms after the blank is cut, and where it goes.
- Parameters:
feature_type – What is formed.
position – The centre of its footprint on the blank.
orientation – The footprint’s principal direction (unit vector).
depth – How far the formed skin leaves the sheet’s plane.
side –
"up"when it rises toward the viewer of the blank.footprint – The outline of the region the feature is formed from.
feature_nodes – Face indices of the feature.
pre_hole – The hole pierced before a collar is drawn, or None.
pre_hole_issue – Why a collar has no hole to pierce on the blank, or
"":"collar_too_tall"when the collar is longer than its footprint can supply by bending alone, so the hole to pierce is left to the forming tool’s maker.pre_hole_note – The explanation, in plain words, or
"".
- class volmdlr_tools.features.unfold.flat_pattern.NestingRectangle(width: float, height: float, angle: float, corners: list[Point2D], name: str = '')#
Bases:
DessiaObjectThe smallest rectangle, at any angle, that holds the blank.
- Parameters:
width – The longer side.
height – The shorter side.
angle – The direction of the longer side, in radians from the x axis.
corners – The four corners, counter-clockwise.
- exception volmdlr_tools.features.unfold.flat_pattern.UnfoldError(reason: Literal['not_sheet_metal', 'non_developable', 'closed_loop', 'overlap', 'placement_mismatch'], message: str, faces: tuple[int, ...] | list[int] = (), candidate_cut_edges: tuple[int, ...] | list[int] = ())#
Bases:
ValueErrorRaised when a sheet-metal part cannot be laid flat, naming why and where.
- Parameters:
reason – What stopped the unfold.
message – The explanation, in plain words.
faces – The face indices involved.
candidate_cut_edges – For a closed loop, the edges each of whose cut would open it, most likely first; repeats are dropped.
- class volmdlr_tools.features.unfold.flat_pattern.UnplacedHole(faces: list[int], reason: Literal['no_other_side', 'no_counterpart', 'does_not_lie_flat', 'open_outline'], note: str = '', name: str = '')#
Bases:
DessiaObjectA hole whose opening on the other side of the sheet could not be laid onto the blank.
The blank cuts such a hole at its opening on the side it is developed from, which is too wide when the hole is countersunk, chamfered or tapered on that side.
- Parameters:
faces – Face indices of the hole’s wall.
reason – Why the other opening could not be laid onto the blank:
"no_other_side"when the wall never meets the other side of the sheet,"no_counterpart"when the face it meets there has no developed face one thickness across from it,"does_not_lie_flat"when that face does not lie flat onto its counterpart, and"open_outline"when the opening does not close into one contour.note – The explanation, in plain words.
name – Optional name.
- volmdlr_tools.features.unfold.flat_pattern.bend_allowance(inside_radius: float, bend_angle: float, thickness: float, k_factor: float) float#
Return the length of flat sheet a bend consumes: the arc of its neutral layer.
- Parameters:
inside_radius – The bend’s inside radius.
bend_angle – The included turn, in radians; its sign is ignored.
thickness – The sheet thickness.
k_factor – See
neutral_radius().
- Returns:
The developed length across the bend.
- volmdlr_tools.features.unfold.flat_pattern.check_k_factor(k_factor: float) None#
Refuse a K-factor that does not place the neutral layer inside the sheet.
- volmdlr_tools.features.unfold.flat_pattern.minimum_area_rectangle(points: ndarray) NestingRectangle#
Find the smallest-area rectangle enclosing a set of points.
One side of the optimal rectangle lies along an edge of the convex hull, so every hull edge direction is tried.
- Parameters:
points – An
(n, 2)array,n >= 3, not all collinear.- Returns:
The rectangle.
- volmdlr_tools.features.unfold.flat_pattern.neutral_radius(inside_radius: float, thickness: float, k_factor: float) float#
Return the radius of the layer of sheet a bend neither stretches nor compresses.
- Parameters:
inside_radius – The bend’s inside radius.
thickness – The sheet thickness.
k_factor – Where the neutral layer sits, as a fraction of the thickness from the inside.
- Returns:
inside_radius + k_factor * thickness.
- volmdlr_tools.features.unfold.flat_pattern.unit_factor(source: Literal['m', 'mm', 'in'], target: Literal['m', 'mm', 'in']) float#
Return what multiplies a length in
sourceunits to give it intargetunits.
volmdlr_tools.features.unfold.dxf module#
Write a flat pattern as a drawing for the cutter and the press brake.
Needs the optional dxf extra: pip install 'volmdlr_tools[dxf]'.
- volmdlr_tools.features.unfold.dxf.write_dxf(pattern: FlatPattern, path: str | Path, *, units: Literal['mm', 'm', 'in'] = 'mm', spline_tolerance: float | None = None) None#
Write the blank, its bend lines, slits and forming marks to a drawing file.
Needs the optional
dxfextra:pip install 'volmdlr_tools[dxf]'.The cut outline (outer contour and every hole, pre-holes included) goes on
OUTLINE, slits onSLIT, bend lines dashed onBEND_UPorBEND_DOWNwith a note onBEND_NOTES(angle, direction, inside radius, K-factor), and each formed feature’s footprint and label onFORMING; a formed feature whose hole to pierce the blank does not give, such as a collar too tall for its footprint, gets a second line under its label,PRE-HOLE: SET BY TOOLING. Lines, circles and circular arcs are written exactly; a curve with no exact drawing entity is written as a polyline that strays from it by no more than a ten-thousandth of the blank’s longer side.- Parameters:
pattern – The flat pattern.
path – Where to write.
units – The drawing’s unit. Every length is converted into it from the unit the pattern is in (
FlatPattern.length_unit).spline_tolerance – When given, free-form curves are written as polylines that stray from them by no more than this, in the drawing’s units (many cutters accept only lines and arcs). When omitted, they are written exactly.
- Raises:
ValueError – When
spline_toleranceis not positive, or a curve cannot be written as a polyline within its tolerance.
Module contents#
Feature recognition and extraction.
recognise_features() is the way in: it reads a part’s features and returns one RecognitionDocument,
which gives every face of the part a status. FeatureProcessor gives the same document with
FeatureProcessor.recognise(), beside the other extractions. read_region() reads one region of a part again
with the readers of walls, pipes, lofts and sweeps, leaving out the ones named, and gives a RegionReading.
What a caller of recognise_features() meets is offered here: the document, its FeatureRecord and
FaceStatus entries and its FaceRefusal refusals, the ConstructionNode of its
construction tree, the Stage a record comes at in the making of the part, the RecordFaceRole each face
of a record has, record_parameters() for the numbers of the feature a record names or the profiles an extruded
body or a slab was drawn from or a turned body was turned from, the Family names and FAMILIES to choose
readers by, and the PartReading and BlendReading a FeatureProcessor holds of its part. The
extractors, the cavity anatomy and the backward compatibility aliases are offered beside them.
- class volmdlr_tools.features.BlendExtractor(aag: AttributedAdjacencyGraph, max_radius: float | None = None, free_form_curvature: bool = False)#
Bases:
FeatureExtractorExtract 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.
The blends a reading finds are recorded on the graph’s faces, and stay there for the readings that follow. A reading lists only the blends within its own radius bound, but it does not clear what an earlier reading of the same graph recorded: a reading with a smaller bound than an earlier one still meets the earlier one’s larger blends among the neighbours of its own while it tells their edges apart, though it does not list them.
- 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 blend chain.
- Returns:
The sum of the lengths of all edges in edges_indices list.
- display_result() dict#
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 smooth but is not a spring edge.
The edge is classified as a cross edge if its curvature-derived radius matches the candidate radius within a tolerance threshold — it curves around the blend.
The edge is classified as a junction instead if the blend does not curve along it at all. The blend runs along such an edge rather than across it, continuing into whatever lies beyond, so the edge marks no end of the blend.
- 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.
junction_edges_ids: A list of IDs of the edges the blend runs along.
- 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, list[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, the candidate radius, and the per-spring-edge candidate radii.
- find_terminating_edges(face_id: int, smooth_edges_ids: list[int], spring_edges_ids: list[int], cross_edges_ids: list[int]) tuple[list[TopoDS_Shape], list[int], list[TopoDS_Shape], list[int]]#
Identify terminating and seam edges of a given face.
A terminating edge is one that does not belong to any of the provided exclusion lists AND crosses to a real neighbour face — i.e. bounds the blend against another face. A wire edge with no external neighbour through this face is a seam of the underlying periodic surface (a torus fillet’s meridian, for example): topologically it is an internal artifact of the parameter domain, not a boundary against another face, so it goes into the seam set instead of the terminating one — leaving a full-round fillet with the clean
2 spring / 0 cross / 0 termsignature its Euler condition expects, while still exposing the seam through the AAG for consumers that need to detect a closed / loop blend (e.g. profile extraction and the full-round Euler condition).- 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:
(terminating_edges, terminating_edges_ids, seam_edges, seam_edges_ids).
- 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_chains(r_dev_perc: float = 5.0) list[BlendChain]#
Identify and return chains of adjacent blend faces of one radius.
Blends are joined where they are adjacent along any edge, sharp ones included, then split by fillet radius; each chain carries the cross-edge length of its radius group. So a fillet that continues round a corner whose blend has another radius comes back as several chains, and two blends of one radius meeting at a sharp edge as one;
tangent_chains()joins blends along smooth edges only, whatever their radii. 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.These chains join blends of one radius however they meet, at a mitre too; the rounds of a part reading, each made in one go, are
BlendReading.chains().- 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.
- classmethod of_reading(aag: AttributedAdjacencyGraph, blends: BlendReading) BlendExtractor#
Return an extractor holding blends already read, marked on aag as reading them there would mark them.
Nothing is recognised again: the blends, their chains and the marks a reader of the graph’s nodes finds are exactly blends. Any blend marks aag carried before are replaced.
- Parameters:
aag – The adjacency graph of the part the blends were read from, numbered the same.
blends – The part’s blends.
- 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.BodyTechnique(domain: TechniqueDomain, extrusion: ExtrusionReading | None = None, turn: TurnReading | None = None, outline_face_ids: frozenset[int] = frozenset({}), swept_face_ids: frozenset[int] = frozenset({}), tree: DomainTree | None = None, profile: Revolution | None = None, profile_refusal: FaceRefusal | None = None)#
Bases:
objectThe reading of a part’s technique a body record came from: how the body was made.
Exactly one of extrusion and turn is given: the one the body’s domain is read as. It describes the domain as it was read, before other records took some of its faces: the faces the body record holds are the record’s
face_ids, and may be fewer than the faces read here.- Parameters:
domain – The region of the part built by the technique, with the faces it holds and its place among the regions the part was built from.
extrusion – For a body made by extruding a profile, what the extrusion makes: its direction, the walls and the caps, the position of each cap, and the lean of each wall.
turn – For a body made by turning a profile, what the turn makes: its axis and the faces about it.
outline_face_ids – For an extrusion, the caps and the faces of the outer loop of the extruded body, not those round its windows; none for a turn.
swept_face_ids – For a turn, the faces of the part the turn sweeps, its profile, outer and bore; none for an extrusion.
tree – The regions of the part the domain is one of, with where each meets the one it was made on: how far the body reaches past the face it stands on is read from its interface there.
Nonefor a technique not read from a part’s regions.profile – For a turn, the profile read off the faces it sweeps as they are, a bevel a chamfer record describes included: the chains in the axes
(t, r)of the revolution,talong its axis from its origin, each closed or running from the axis to the axis, none crossing itself. The profile the body was turned from, with those bevels taken off its corners, is whatrecord_parameters()gives for the record.Nonefor an extrusion, or when the faces give no profile.profile_refusal – For a turn whose faces give no profile, why they do not;
Noneotherwise.
- Raises:
ValueError – When both readings are given, or neither, or an extrusion is given a profile or a refusal of one.
- domain: TechniqueDomain#
- extrusion: ExtrusionReading | None = None#
- outline_face_ids: frozenset[int] = frozenset({})#
- profile: Revolution | None = None#
- profile_refusal: FaceRefusal | None = None#
- swept_face_ids: frozenset[int] = frozenset({})#
- tree: DomainTree | None = None#
- turn: TurnReading | None = None#
- class volmdlr_tools.features.CavityAnatomy(_roles: dict[int, CavityFaceRole])#
Bases:
objectAnatomical classification of cavity faces.
This class holds the result of classifying cavity faces by their role according to the cavity face nomenclature.
- property all_face_ids: list[int]#
Return all face IDs in the cavity.
- property blend_face_ids: list[int]#
Return all blend face IDs.
- property entry_blend_ids: list[int]#
Return entry blend face IDs.
- property entry_face_ids: list[int]#
Return entry face IDs.
- property floor_blend_ids: list[int]#
Return floor blend face IDs.
- property floor_face_ids: list[int]#
Return floor face IDs.
- classmethod from_classified(entry_face_ids: list[int], wall_face_ids: list[int] | None = None, floor_face_ids: list[int] | None = None, entry_blend_ids: list[int] | None = None, floor_blend_ids: list[int] | None = None, wall_blend_ids: list[int] | None = None) CavityAnatomy#
Create a CavityAnatomy from classified face ID lists.
- Parameters:
entry_face_ids – Entry face IDs.
wall_face_ids – Wall face IDs.
floor_face_ids – Floor face IDs.
entry_blend_ids – Entry blend face IDs: the feature’s rim blends (
FeatureSeed.rim_blend_face_ids), entry blend = rim blend.floor_blend_ids – Floor blend face IDs.
wall_blend_ids – Wall blend face IDs.
- Returns:
CavityAnatomy instance.
- get_ids(role: CavityFaceRole) list[int]#
Return face IDs with the given role.
- property structural_face_ids: list[int]#
Return only structural (non-blend) face IDs.
- property wall_blend_ids: list[int]#
Return wall blend face IDs.
- property wall_face_ids: list[int]#
Return wall face IDs.
- class volmdlr_tools.features.CavityDefinition(profile: Wire | None, depth: float, axis: Vector3D, origin: Point3D, access_direction: Vector3D | None = None, anatomy: CavityAnatomy | None = None, blends: list[Blend] = <factory>, wall_blends_from_profile: bool = False, feature_type: FeatureType = FeatureType.POCKET, parent_index: int | None = None, inner_profiles: list[Wire] = <factory>, classified_profile: ClassifiedProfile | None = None, profile_blend_ids: tuple[int, ...]=(), venting: Venting | None = None, clearance: float = 0.0, removes_outside_profile: bool = False, rim_blend_ids: tuple[int, ...] | None=None)#
Bases:
objectParametric definition of a reverse-engineered cavity.
This class holds all the parameters needed to recreate the cavity: - Profile: The 3D profile Wire. - Depth: The extrusion depth - Axis: The extrusion direction - Blends: Fillet information
profileis the cross-section of the material the cavity takes away, swept depth along axis, unlessremoves_outside_profileis set. Then it is the reverse: the profile bounds the material left standing, and the cavity takes away the bar around it across the same depth, as an outline cut swept round a whole closed contour does (a flange’s outline cut in one pass). A consumer that sweeps the profile must honour the flag, by keeping the inside of the swept profile instead of removing it, or refuse a definition that sets it: read as an ordinary cavity, it would remove the very material it says to keep. Such a definition carries no venting.- access_direction: Vector3D | None = None#
- anatomy: CavityAnatomy | None = None#
- axis: Vector3D#
- classified_profile: ClassifiedProfile | None = None#
- clearance: float = 0.0#
- depth: float#
- property entry_fillet_radius: float | None#
Return the entry (rim) fillet radius, or None if no entry blend.
The widest radius (
widest_rim_radius()) among the entry blends this feature’s rim owns (rim_blend_ids), so in a plan it is the radius of the feature’s entry inFeatureDecompositionPlan.rim_blends, and None when the plan lists no rim under it.
- faces_to_defeature() list[int]#
Return face IDs to pass to ComplexFeatureRemover for this cavity.
Excludes entry faces (surrounding stock) because they must not be removed during defeaturing — they are the faces that close the pocket opening on the original stock surface.
- feature_type: FeatureType = 'pocket'#
- property floor_fillet_radius: float | None#
Return the floor fillet radius, or None if no floor blend.
- property has_entry_blend: bool#
Check if the cavity has an entry blend.
- property has_floor_blend: bool#
Check if the cavity has a floor blend.
- inner_profiles: list[Wire]#
- property is_revolved: bool#
False: a cavity is rebuilt by sweeping its profile, never by revolving one.
Declared so every definition answers the question, rather than leaving each consumer to guess at the answer for the one class that does not.
- origin: Point3D#
- parent_index: int | None = None#
- profile: Wire | None#
- profile_blend_ids: tuple[int, ...] = ()#
- removes_outside_profile: bool = False#
- rim_blend_ids: tuple[int, ...] | None = None#
- wall_blends_from_profile: bool = False#
- class volmdlr_tools.features.CavityExtractor(aag: AttributedAdjacencyGraph, max_number_feature_faces: int = 100, name: str = '')#
Bases:
InnerFeaturesExtractorExtract 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() dict#
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.CavityFaceRole(*values)#
Bases:
EnumClassification of face roles within a cavity.
- ENTRY = 1#
- ENTRY_BLEND = 4#
- FLOOR = 3#
- FLOOR_BLEND = 5#
- UNKNOWN = 7#
- WALL = 2#
- WALL_BLEND = 6#
- class volmdlr_tools.features.ConstructionNode(record: int, children: tuple[ConstructionNode, ...] = ())#
Bases:
objectOne record in the construction tree, with the records made on it.
- Parameters:
record – The index of the record in the document’s
records.children – The records made on this one, in the order they come: the bodies and the features first, then the work done on edges.
- children: tuple[ConstructionNode, ...] = ()#
- record: int#
- class volmdlr_tools.features.CylinderExtractor(aag: AttributedAdjacencyGraph, max_radius: float = inf, linear_tolerance: float = 0.0001, angular_tolerance: float = 0.0175, extraction_mode: ExtractionMode = ExtractionMode.EXTERNAL, name: str = '')#
Bases:
FeatureExtractorExtract cylindrical features from an Attributed Adjacency Graph (AAG).
This class recognizes cylinders by identifying cylindrical faces and propagating to collect all coaxial cylindrical neighbors through appropriate edges.
Supports both extraction modes: - EXTERNAL (default): Extract bosses, shafts, pins (surface normal points away from axis).
Propagates through CONVEX/SMOOTH edges.
- INTERNAL: Extract bores, holes (surface normal points toward axis).
Propagates through CONCAVE/SMOOTH edges.
- Parameters:
aag – The Attributed Adjacency Graph (AAG) representation of the CAD model.
max_radius – Maximum radius for cylinder recognition (filters large cylinders).
linear_tolerance – Tolerance for radius and position comparisons.
angular_tolerance – Tolerance for axis direction comparisons (radians).
extraction_mode – Whether to extract EXTERNAL or INTERNAL cylinders.
name – Name for the extractor instance.
- get_cylinders() list[Cylinder]#
Create Cylinder objects from extracted face groups.
- Returns:
List of Cylinder feature objects.
- property ids_cylinders: list[list[int]]#
Return the face IDs of identified cylinders.
- Returns:
List of face ID lists, one per cylinder.
- perform() bool#
Perform the cylinder feature extraction.
Main entry point for cylinder recognition. Iterates through faces, identifies cylindrical seed faces, propagates to collect coaxial neighbors, validates angular coverage, and processes floating isolations.
- Returns:
True if extraction completed successfully.
- class volmdlr_tools.features.FaceCoverage(face_count: int, claimed_once: int, contested: int, unclaimed: int, extractions_run: frozenset[~typing.Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']]=frozenset({}), unclaimed_sample: tuple[int, ...]=(), contested_sample: dict[int, ~volmdlr_tools.features.coverage.ContestedFace]=<factory>)#
Bases:
objectHow a part’s faces divide between the features recognized on it.
Every face falls in exactly one of three buckets, so
claimedplusunclaimedis alwaysface_count. Read the buckets againstextractions_run: an unclaimed face is a face none of those passes claimed, which is a gap in the recognition that was asked for, not necessarily one in the recognition that exists.Faces are named by their AAG index. An index means the same face for as long as the graph does — it was measured to survive a graph rebuild, a rigid transform, and a STEP write-and-reload — so it is a sound handle to carry from this report to a viewer or to another query in the same session. It is not claimed to survive a topological edit, which renumbers faces: this is a within-session check, not a reference to store.
- Parameters:
face_count – Faces in the part, the denominator the rest is read against.
claimed_once – Faces exactly one feature claimed.
contested – Faces more than one feature claimed — double-counting, visible here before it reaches a total.
unclaimed – Faces no feature that ran claimed.
extractions_run – The extractions this report covers.
unclaimed_sample – Up to
COVERAGE_SAMPLE_LIMITunclaimed face indices, lowest first. A sample, not the list —unclaimedis the count.contested_sample –
Up to
COVERAGE_SAMPLE_LIMITcontested faces, lowest index first, each mapped to aContestedFacenaming who claimed it. Bounded in width as well as in length, so reading this mapping costs the same on any part.Only the sampled faces carry their claimants:
contestedis the full count, but which types competed is answered for the sample. A part whose contested faces exceed the cap is telling you to look at it, not to read the rest of the list.
- property claimed: int#
Faces at least one feature claimed, contested ones included.
- Returns:
claimed_oncepluscontested.
- claimed_once: int#
- contested: int#
- contested_sample: dict[int, ContestedFace]#
- extractions_run: frozenset[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']] = frozenset({})#
- face_count: int#
- classmethod over_features(face_count: int, features_by_type: dict[type[Feature], list[Feature]], extractions_run: frozenset[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']] = frozenset({}), sample_limit: int = 20) FaceCoverage#
Account for a part’s faces against the features recognized on it.
A feature claims the faces it is made of — its
nodes, once each however often it lists one, and not itsbase_nodes, which are by definition the neighbouring faces it was cut or formed through and belong to whatever else is there.A type that only groups other recognized features — a blend chain over its blends, a rib structure over its segments; see
Feature.groups_member_features— makes no claim of its own. Its faces are its members’ faces, so counting both would report every filleted face of every part as contested and bury the real overlaps.- Parameters:
face_count – Faces in the part, numbered
0toface_count - 1as the face graph numbers them.features_by_type – The recognized features, by concrete type.
extractions_run – The extractions that produced them, reported as the scope of the result.
sample_limit – How many face indices each sample may carry.
- Returns:
The coverage report.
- Raises:
ValueError – If a feature claims a face the part does not have. The invariant that claimed plus unclaimed is the face count would not hold, and a report that quietly dropped the claim would hide the defect that produced it — which is the opposite of this report’s job.
- to_markdown() str#
Render the report as a markdown section.
A section rather than a document, so the same text reads correctly alone and inside
FeatureProcessor.to_markdown(), which carries it verbatim. The result is bounded byCOVERAGE_TEXT_LENGTH_LIMIThowever complex the part.- Returns:
Markdown-formatted string.
- unclaimed: int#
- unclaimed_sample: tuple[int, ...] = ()#
- class volmdlr_tools.features.FaceStatus(kind: Literal['feature', 'body', 'refused', 'unexplained'], record: int | None = None, refusal: int | None = None, reason: str = '')#
Bases:
objectWhat one face of a part is.
- Parameters:
kind –
"feature"for a face a feature accounts for,"body"for a face of the body the features stand on or are cut into,"refused"for a face a reading was set aside over and nothing else accounts for,"unexplained"for a face nothing accounts for.record – The index of the record accounting for the face; given for a feature’s face, may be given for a face of the body when a body record holds it, and given for no other face.
refusal – The index of the first refusal holding the face; given for a refused face, and only for one.
reason – Why the face is what it is, for a face of the body or a refused face.
- Raises:
FeatureRecognitionError – When record or refusal is given, or missing, against what kind says.
- kind: Literal['feature', 'body', 'refused', 'unexplained']#
- reason: str = ''#
- record: int | None = None#
- refusal: int | None = None#
- class volmdlr_tools.features.FeatureCounts(counts: dict[str, int], extractions_run: set[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']])#
Bases:
dictPer-type feature counts, carrying the extractions they were counted over.
A
dictso every existing caller keeps working, plus the one fact a bare count table cannot carry: what was looked for.{"Blend": 0}with"blends"inextractions_runsays the part has no fillets; no"Blend"key at all says nobody ranFeatureProcessor.extract_blends().
- class volmdlr_tools.features.FeatureProcessor(shape: Shape, aag: AttributedAdjacencyGraph | None = None, name: str = '')#
Bases:
DessiaObjectRecognise a part’s features, and hold what was recognised.
There are two ways in:
recognise()reads every family of features at once and returns aRecognitionDocument: each feature as a record, every face of the part accounted for, and every reading set aside given as a refusal. Start here.extract_*reads one family, asextract_blends()orextract_sheet_metal_features(), and stores its features for the typed getters (holes,blends,bends, …), which refuse withUnextractedAccessErroruntil an extraction that fills them has run.
Both read the same part:
part_readingholds its graphs and its blends (blend_reading), read once and handed to every reading, so the document and the getters agree on which faces are blends, unlessextract_blends()is asked for another radius.aag, read by default with every edge convex or concave, is the reading’ssharp_aag; the reading’s ownaagis the graph read with tangent edges smooth.- property all_features: list[Feature]#
Every feature in the registry, whatever its class.
The registry is keyed by class; callers that must sweep all of them (validation rulebooks, reports) should read this rather than reimplementing the walk over the private dict.
The features another one owns are left out: the holes of a perforation (in its
holes) and the bends of a jog or a lance (in itsbends). A caller that must reach every opening and every bend expands them withwith_perforation_holes()andwith_held_folds().- Returns:
All extracted features.
- property beads: list[Bead]#
Get extracted beads: ribs pressed into the sheet along a path of straight runs and arcs.
Refuses until
extract_deformations()is called.
- property bends: list[Bend]#
Get extracted bend features.
Only the bends reported as features of their own: the bends a jog or a lance owns are held in its
bendsinstead. For every bend of the part, usebend_features()(orwith_held_folds()for every fold) overall_features.- Returns:
List of Bend objects.
- property blend_chains: list[BlendChain]#
Get extracted blend chains.
- Returns:
Tuple of BlendChain objects (immutable)
- property blend_reading: BlendReading#
The part’s blends, read once and handed to every reading of the part that needs them.
The cut features and the feature model are read with these blends, so that they agree on which faces are blends whichever ran first. Nothing is marked on
aagby reading them.
- property blends: list[Blend]#
Get extracted blend features.
- Returns:
Tuple of Blend objects (immutable)
- property cavities: list[Cavity]#
Get extracted cavity features, of every Cavity subclass.
The registry is keyed on the exact
type()of each feature, so the types are read off the class hierarchy rather than listed here — a hand-maintained list silently drops any subclass someone forgets to add to it.The list is heterogeneous: parameters beyond the shared ones vary by subclass — only
RoundCavitycarries adiameter. Check the concrete type (or that the attribute exists) before reading a subclass-specific parameter.The holes a
Perforationowns are left out: they are in that perforation’sholes, andwith_perforation_holes()lists them beside it.- Returns:
List of Cavity objects, of mixed concrete subclasses.
- property chamfer_chains: list[ChamferChain]#
Get extracted chamfer chains.
- Returns:
List of ChamferChain objects
- clear_all_features() None#
Clear all features from the registry, and with them every recorded extraction.
- clear_features(feature_types: list[type[Feature]] | None = None) None#
Clear extracted features.
- Parameters:
feature_types – Optional feature classes to clear (e.g., Bend, Cavity). If None, clears all features.
- property corner: list[Corner]#
Get extracted corner features.
- Returns:
Tuple of Corner objects (immutable)
- property corner_reliefs: list[CornerRelief]#
Get extracted corner relief features.
- Returns:
List of CornerRelief objects.
- property curls: list[Curl]#
Get extracted curl features: sheet edges rolled round with no flat leg.
- Returns:
List of Curl objects.
- property dimples: list[Dimple]#
Get extracted dimples: round domes pressed into the sheet.
Refuses until
extract_deformations()is called.
- property embosses: list[Emboss]#
Get extracted emboss features, dimples and beads included.
- Returns:
Tuple of Emboss objects (immutable)
- extract_all(blend_max_radius: float | None = None) None#
Recognize all available features for the shape.
- Parameters:
blend_max_radius – Maximum radius for blend recognition, in the model’s own length units; omitted, a fraction of the model’s own size.
- extract_blends(max_radius: float | None = None) None#
Recognize blend features and store them internally.
- Parameters:
max_radius – The maximum radius for blend recognition, in the model’s own length units. Omitted, it is taken as a fraction of the model’s own size, so the same call recognizes the fillets of a part modelled in millimetres and of one modelled in metres.
Without max_radius the blends are
blend_reading, those every other reading of the part is handed. With another radius they are read again up to it, since which blends a part has decides how each one is read. Either way they are marked onaag, for the readers of the graph’s nodes.
- extract_cavities() None#
Recognize cavity features and store them internally.
A hole a
Perforationalready owns is left out: the sheet-metal pass read it as one hole of that perforation, and listing it again as a cavity would put it in two features.
- extract_chamfers(mode: Literal['convex', 'convex_and_inside_bevels', 'any'] = 'convex_and_inside_bevels', max_offset_ratio: float = 0.5, min_angle_degrees: float = 5.0) None#
Recognize chamfer features and store them internally.
- Parameters:
mode – Which chamfers are read:
"convex", those of a convex edge only;"convex_and_inside_bevels"(default), also the chamfers filling the square corner of a concave edge, as where a pocket wall meets its floor;"any", the chamfers of any edge.max_offset_ratio – Maximum ratio of chamfer offset to model diagonal.
min_angle_degrees – Minimum angle between under-faces in degrees.
- extract_deformations(extractor_class: type[DeformationExtractor] = <class 'volmdlr_tools.features.extractors.sheet_metal.region_deformation.RegionDeformationExtractor'>) None#
Recognize the deformations pressed into the sheet and store them internally.
A deformation that stays inside the sheet is an emboss, a dimple or a bead; one that opens onto a cut is a flanged cutout, an extrusion hole or a louvre. A rib pressed across a bend is a gusset, found by either extractor before the deformations, which take none of its faces.
- Parameters:
extractor_class – The extractor driving the recognition. Defaults to the region-based extractor, which also finds deformations merged with cutout rims or the sheet boundary; pass
DeformationExtractorfor the wire-seeded one.- Raises:
ValueError – If the shape is not a sheet metal.
- extract_feature_model(stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False) FeatureModel#
Read the part’s single features and which was made on or cut into which, and store the model.
- Parameters:
stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock.
stock_convention – What counts as the raw stock; see
StockConvention. The default,DEFAULT_STOCK_CONVENTION, reads it as the bar the part was machined from, whatever its section, and only that reading reads cuts through the part’s outline (FeatureType.OUTLINE_CUT). Under it, each faced top, a flat face below the hull every neighbour meets at a sharp convex edge, comes out as an unnamedFeatureType.UNKNOWNfeature: the material above it was removed from the bar."extruded_profile"reads it as the profile the part was extruded from;"supporting_plane"as the bounding block the part was cut from.families – The families to read; all of them by default. See
Family.strict – Whether a reader’s exception is raised instead of recorded as a refusal.
- Returns:
The model, also available as
feature_model.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, or ifaagis the graph of another part.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces.
- extract_interacting_features(stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull') None#
Extract interacting machining features using the Sunil et al. (2010) algorithm.
- Parameters:
stock_convention – What counts as the raw stock; see
StockConvention. The default,DEFAULT_STOCK_CONVENTION, reads it as the bar the part was machined from, whatever its section, and only that reading fillsoutline_cuts, the cuts through the part’s outline; each faced top, a flat face below the hull every neighbour meets at a sharp convex edge, comes out as an unnamedUNKNOWNfeature."extruded_profile"reads it as the profile the part was extruded from, and"supporting_plane"as the bounding block the part was cut from. Which one ran is kept ininteracting_features_stock_convention.- Raises:
ValueError – If
stock_conventionis not one on offer.
- extract_lances() None#
Recognize lance features and store them internally.
Lances are recognized together with the other sheet metal features, so this runs
extract_sheet_metal_features(), which first discards every feature extracted before.- Raises:
ValueError – If the shape is not a sheet metal.
- extract_planar_trims(tol: float | None = None) None#
Recognize the planes the whole part lies on one side of, with the faces it has on each.
Not part of
extract_all(): every outer plane of a part is one, whether the part was cut back to it or simply ends there, and only what was built before tells the two apart.- Parameters:
tol – How far the part may reach past such a plane; defaults to a fraction of the model’s size.
- extract_ribs(max_thickness: float | None = None, blend_max_radius: float | None = None, pair_finder: str = 'edge_driven') None#
Recognize rib features (and rib structures) and store them internally.
Not part of
extract_all()— rib recognition walks the whole AAG and is markedly slower than the other extractors, so it is opt-in. Until it is called,ribsandrib_structuresare empty.- Parameters:
max_thickness – Maximum wall thickness for a rib, in the model’s units. When omitted it defaults to a fraction of the model’s bounding-box diagonal, so the threshold is unit-agnostic; pass an explicit value to constrain recognition to a known wall thickness.
blend_max_radius – Maximum fillet radius recognized as a blend and passed over when collecting a rib’s shell and base faces. When omitted it defaults to a fraction of the bounding-box diagonal, for the same unit-agnostic reason as
max_thickness.pair_finder – Which candidate end-face pair finder the
RibExtractorruns —"edge_driven"(default),"face_pair", or the experimental"nearly_planar"that also admits nearly-planar BSpline/Offset end faces. Same names and defaults asRibExtractoritself.
- Raises:
ValueError – If
pair_finderis not one of the three names.
- extract_sharp_edges() None#
Recognize sharp edge features and store them internally.
- extract_sheet_metal_features() None#
Recognize sheet metal features and store them internally by type.
- Raises:
ValueError – If the shape is not a sheet metal.
- property extractions_run: frozenset[Literal['blends', 'chamfers', 'cavities', 'ribs', 'sharp_edges', 'deformations', 'interacting_features', 'sheet_metal_features', 'lances', 'feature_model', 'planar_trims', 'recognition']]#
The extractions that have run on this processor, by
extract_*method name."blends"in the set meansextract_blends()has run, so an emptyblendsmeans the part has no fillets; absent, it means nobody has looked. Clearing an extraction’s features removes it again, since its result no longer exists — but only once none of the types it owns holds a result, and only if the clear discarded something, so neither a partial clear nor a pass that found nothing loses its place. Reading a collection whose extractions are all absent raises — seeUnextractedAccessError.- Returns:
Extraction names, e.g.
frozenset({"blends", "cavities"}).
- property extrusion_holes: list[ExtrusionHole]#
Get extracted extrusion holes: round holes whose rim is drawn into a collar.
Refuses until
extract_deformations()is called.
- property feature_model: FeatureModel | None#
The part’s feature model, or
Nonewhenextract_feature_model()has not run.
- features_volume_model(features: list[Feature]) VolumeModel#
Display features alongside the original shape in a VolumeModel.
- filter_blend_chains(min_radius: float | None = None, max_radius: float | None = None, min_length: float | None = None, max_length: float | None = None) list[BlendChain]#
Filter blend chains based on criteria.
- Parameters:
min_radius – Minimum chain radius
max_radius – Maximum chain radius
min_length – Minimum chain length
max_length – Maximum chain length
- Returns:
Filtered list of blend chains
- filter_blends(min_radius: float | None = None, max_radius: float | None = None, blend_type: str | None = None, confirmed_only: bool = False) list[Blend]#
Filter blends based on criteria.
- Parameters:
min_radius – Lower bound, read against
Blend.radius— the radius the blend was recognized by.max_radius – Upper bound, read against
Blend.widest_radius— the widest point the blend reaches. A round that opens out past the bound along its length is not admitted on the strength of its narrow end, which is what selecting small fillets for removal needs.blend_type – Name of the
BlendTypeto keep —"Ordinary","Vertex","Cliff"or"Uncertain". Any other string is refused, since an empty answer would be indistinguishable from a part that has none of that kind.confirmed_only – If True, only return confirmed blends
- Returns:
Filtered list of blends
- Raises:
ValueError – If blend_type is not the name of a
BlendType.
- filter_by_category(category: str, location: str | None = None) list#
Filter features by category and optionally by location.
- Parameters:
category (str) – Feature category (“cut”, “forming”, “blend”, “cavity”, “unknown”)
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of features matching the criteria
- Return type:
list
- filter_by_location(location: str) list#
Filter all features by location.
- Parameters:
location (str) – Location filter (“boundary” or “internal”)
- Returns:
List of features at the specified location
- Return type:
list
- filter_cavities(min_depth: float | None = None, max_depth: float | None = None) list[Cavity]#
Filter cavities based on depth criteria.
Depth is the cavity’s
depthparameter. A cavity whose depth is undetermined (depthanswers None) is excluded from any bounded query — an unknown depth never reads as a shallow one — but is present in an unbounded one.- Parameters:
min_depth – Minimum cavity depth (inclusive)
max_depth – Maximum cavity depth (inclusive)
- Returns:
Filtered list of cavities
- property flanged_cutouts: list[FlangedCutout]#
Get extracted flanged cutouts, extrusion holes and louvres included.
A cutout whose rim shape is not named is a plain
FlangedCutout; the named ones are listed here too, asembosseslists dimples and beads. Refuses untilextract_deformations()orextract_sheet_metal_features()is called.
- classmethod from_doc_model(doc_model: DocModel, prototype: Prototype | None = None, name: str = '') FeatureProcessor#
Initialize a FeatureProcessor on the shape of a DocModel prototype, the root one by default.
- Parameters:
doc_model – The DocModel to read, without converting it to a VolumeModel.
prototype – The prototype to perform recognition on, in its own frame; only its B-Rep is read.
name – (Optional) A name.
- Returns:
The processor FeatureProcessor(doc_model.to_volume_model().primitives[0]) would give.
- classmethod from_part_reading(reading: PartReading) FeatureProcessor#
Make the processor of a part that has been read already, which reads nothing of it again.
The processor’s
aagis the reading’s graph read with every edge convex or concave, and itspart_readingandblend_readingare the reading’s own, so that a part read once is shared by every reader of it, here and wherever else the reading was handed.- Parameters:
reading – The part, read.
- Returns:
The processor of the reading’s part.
- get_cut_features(location: str | None = None) list#
Get all cut features (slots, notches, corner reliefs, clips).
- Parameters:
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of cut features
- Return type:
list
- get_face_coverage() FaceCoverage#
Account for every face of the part against the features recognized on it.
The part-level counterpart of
get_feature_count(): that one says how much was found, this one says how much of the part was accounted for. It answers how many faces exactly one feature claimed, how many more than one claimed and which feature types those were, and how many none claimed — so a recognition gap becomes visible rather than assumed away, and double-counting is caught before it reaches a total.The report covers only the extractions that have run, and says which those were. Its size does not grow with the part: the face-index lists are capped samples, with the full counts alongside.
- Returns:
The coverage report, over
extractions_run.- Raises:
ValueError – If a recognized feature claims a face the part does not have, which is an extractor defect this report refuses to hide.
- get_feature_count() FeatureCounts#
Count the extracted features, per type, over the extractions that have run.
A type an extraction looks for but did not find is reported as
0; a type whose extraction never ran is absent entirely. Which extractions the counts cover is on the result — seeFeatureCounts.extractions_run.- Returns:
Feature class names mapped to counts, as a dict that also names the extractions counted over.
- get_forming_features(location: str | None = None) list#
Get all forming features (bends, jogs).
- Parameters:
location (Optional[str]) – Optional location filter (“boundary”, “internal”)
- Returns:
List of forming features
- Return type:
list
- property gussets: list[Gusset]#
Get extracted gusset features: ribs pressed across a sheet-metal bend, filled by
extract_deformations().- Returns:
List of Gusset objects.
- has_features(feature_type: type[Feature] | None = None) bool#
Check if any features have been extracted.
- Parameters:
feature_type (Optional[type[Feature]]) – Optional feature class to check (e.g., Bend, Jog). If None, checks if any features exist.
- Returns:
True if features exist, False otherwise
- Return type:
bool
- property hems: list[Hem]#
Get extracted hem features: sheet edges folded back over the sheet.
- Returns:
List of Hem objects.
- property holes: tuple[Hole, ...]#
Get extracted hole features.
- Returns:
Tuple of Hole objects (immutable)
- property hooks: list[Hook]#
Get extracted hook features: tabs lanced out of the sheet and bent over, their end pointing back down.
A hook is no lance: it is listed here and not in
lances. Refuses untilextract_sheet_metal_features()is called.
- property interacting_features_stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] | None#
The stock convention the interacting features were read under.
Set by
extract_interacting_features(), so a set of interacting features can be told apart from the same part read under the other convention. None untilextract_interacting_features()has run, and again once a clear has discarded its features.
- property is_sheet_metal: bool#
Check if the shape is a sheet metal.
- Returns:
True if shape is sheet metal, False otherwise
- property lances: list[Lance]#
Get extracted lance features.
- Returns:
Tuple of Lance objects (immutable)
- property louvre: list[Louvre]#
Get extracted louvre features, however they were found.
Those read from the formed hood come from
extract_deformations(), those read from the slit’s cut walls alone fromextract_sheet_metal_features().- Returns:
Tuple of Louvre objects (immutable)
- property notches: list[Notch]#
Get extracted notch features.
- Returns:
Tuple of Notch objects (immutable)
- property outer_contour_nodes: list[int]#
AAG face indices of the part’s outer contour — its border faces.
The thickness faces of the sheet’s boundary chain: the faces an edge distance is measured to. Inner cutout walls are not here; they belong to the internal chains and are reached as features instead.
- Returns:
The border face indices, empty when the part is not recognized as sheet metal.
- property outline_cuts: tuple[OutlineCut, ...]#
Get extracted cuts through the outline of the bar, read under the
"convex_hull"stock convention.- Returns:
Tuple of OutlineCut objects (immutable)
- property part_reading: PartReading#
The part read once, shared by every reading of it: its graphs, its blends, its tolerances.
Its graph read with every edge convex or concave is
aag, and its blends areblend_reading.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – When
aagis the graph of another part.
- property perforations: list[Perforation]#
Get extracted perforations: fields of congruent holes punched through a flat plate on a lattice.
A perforation owns its holes: they are not in
cavities, and each perforation lists them in itsholes. Refuses untilextract_sheet_metal_features()is called.
- property planar_trims: list[PlanarTrim]#
Get the planes the part lies on one side of. Refuses until
extract_planar_trims()is called.
- plot_features_graph(features_to_highlight: list[Feature] | None = None, show_labels: bool = True)#
Plot the AAG with features highlighted.
- Parameters:
features_to_highlight – Optional list of features to highlight in the graph. If None, highlights all extracted features.
show_labels – Whether to show node labels.
- Returns:
Matplotlib figure or graph visualization object.
- property pockets: tuple[Pocket, ...]#
Get extracted pocket features.
- Returns:
Tuple of Pocket objects (including OpenPocket and AnnularGroove, immutable)
- post_process_unknown_features(internal_features: list[Feature]) list[Feature]#
Reclassify unknown internal features adjacent to multiple blends as CutoutWithBendInternal.
- recognise(stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False, body: bool = False, deadline: float | None = None, body_wall_rounds: bool = True) RecognitionDocument#
Recognise the part’s features and say what every face of it is, and store the document.
The part’s feature model is read again, with stock_faces and stock_convention, and stored as
feature_model. Without stock_faces the part is also read as turned: when every face of it is either on a profile turned about an axis or on a feature standing on that profile, and the profile carries most of the part’s surface, the profile is one revolution that the other features stand on, and the readings it takes faces from are set aside. A round drawn in a profile, such as the round end of a slot, is given to the feature whose profile it rounds, or to the body, rather than read as a blend. When faces are left that nothing explains, on a part not read as turned, the part is also read as profiles extruded along the direction it was most built along, and each profile is an extrusion of the faces left to it.With body, the part is read for the body it was made from instead of as turned: each extrusion, drafted extrusion or revolution the part was made from is a record of its own, with
stage"body", made first, and the holes, pockets and slots made in it are the features that stand on it. A turned part’s bore is a hole in its revolution, a keyway cut along it is a slot on that hole, holes off the axis stay holes, and a flat milled across the whole turn, a plane the part lies under that the turn reaches past, is a cut on the revolution. The faces a revolution at the root of the body does not hold are handed back to the extruded profiles, which still read what nothing else explains; a face no profile reads is refused, saying the revolution hands it back. A round that is a wall of a body’s extrusion or turn is a face of the body record, or of the pocket record for a window cut through the body, with a refusal naming the profile that keeps it, and no finishing blend record; a run of rounds one fillet makes goes so only whole, and stays blends when one record cannot keep it all. Naming stock_faces reads the part as without body, as does a part from which no body is read, and a part whose body reading fails outside strict mode, which leaves one refusal over the whole part saying so. See the “Body and features” section of the recognition document’s guide.With body, the faces the body and the feature readings leave unexplained, refuse, or read suspiciously, such as the cavity of a thin-walled shell, are also read again, region by region, with the readers of walls, pipes, lofts and sweeps. A reading takes a region only when the region holds at least half of the faces the reading contests, which are its faces other than those of the body, the stock and the work done on edges; the body it reads is then a record with
origin"advanced", and the readings that lie on it are set aside with a refusal. A reader tried on a region and not used leaves a refusal over the faces of the region its readings held, or over no face when it failed or ran out of time.Each reader runs on its own: one that fails, or runs out of time, leaves a refusal saying so, and the others’ records are still given.
With a deadline, the readings stop at that moment: a reader reached after it has passed is not run, and the body reading, when the deadline has passed before it starts, is not run either; each leaves a refusal over the whole part giving the out-of-time reason, so that no reading is lost without saying so. What was read before the deadline is in the document. A reader already running is cut short only if it watches the time it is given; the others finish.
- Parameters:
stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock, or of its revolution.
stock_convention – What counts as the raw stock; see
extract_feature_model().families – The families to read; all of them by default. See
Family.strict – Whether a reader’s exception, or a failure of the body reading, is raised instead of recorded as a refusal.
body – Whether to read the body the part was made from, and the features made on it.
deadline – The moment by which the readings must be over, as
time.perf_counter()gives it, not a duration:time.perf_counter() + 30. No limit beyond each reader’s own when omitted.body_wall_rounds – Whether a round that is a wall of a pocket, a slot, a step or a cut, or with body a wall of a body’s extrusion or turn, a rounded corner of the profile it was made from, such as a rounded corner of a pocket, a round along an extruded outline or a torus rounding a turned shaft’s shoulder about its axis, is given to the record whose profile it rounds, with the whole run of rounds it belongs to; otherwise it is a blend, applied to an edge once the body or the cut is made. True by default.
- Returns:
The document, also available as
recognition_document.- Raises:
ShapeTypeError – When the shape is not one solid, alone or as the only thing in a compound.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, ifdeadlineis not a finite moment, or ifaagis the graph of another part.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces, or when the body reading fails.
- property recognition_document: RecognitionDocument | None#
The part’s recognition document, or
Nonewhenrecognise()has not run.
- property rib_max_thickness: float | None#
The wall-thickness threshold rib recognition actually applied.
Differs from the
max_thicknesspassed toextract_ribs()when the scale-aware default was tightened to the part’s measured walls. None untilextract_ribs()has run.
- property rib_structures: list[RibStructure]#
Get extracted rib structures (groups of segments meeting at junctions).
Refuses until
extract_ribs()is called.
- property ribs: list[Rib]#
Get extracted rib segments. Refuses until
extract_ribs()is called.
- property sharp_edges: list[Edge, ...]#
Get extracted sharp edge features.
- Returns:
Tuple of Edge objects (immutable)
- property sheet_metal: SheetMetalShape | None#
The recognized sheet-metal shape, or None when the shape is not a sheet metal.
Use it to drive an extractor directly (e.g.
DeformationExtractor(sheet_metal=...)); recognition runs once and is cached.
- property sheet_thickness: float | None#
The part’s nominal sheet thickness s, in the model’s length unit.
That unit is metres for any model
volmdlrloads, which is what the rule layer (volmdlr_tools.features.rules) compares it in. The value is measured, not read from a parameter, so it can sit a float hair off the nominal thickness it was drawn at.The single authoritative input for every thickness-scaled stamping threshold (2s, 3s, 4s). Delegates to the sheet-metal recognizer, which measures it as the median length of the edges the boundary thickness faces share, falling back to the seed-to-opposite distance.
- Returns:
The thickness, or None when the part is not recognized as sheet metal — a rule with no s reports indeterminate, never a verdict.
- show_cavities() dict#
Implementation of a tag for displays.
- show_features(feature_type: type[Feature] | None = None) dict#
Implementation of a tag for displays.
- property slots: tuple[Slot, ...]#
Get extracted slot features.
- Returns:
Tuple of Slot objects (including all subtypes, immutable)
- property steps: tuple[Step, ...]#
Get extracted step features.
- Returns:
Tuple of Step objects (including BlindStep, immutable)
- property tabs: list[Tab]#
Get extracted tab features: flat ear plates beyond a single bend, ending in a round tip.
The bend a tab stands on is listed in
bends, and the hole through it with the cut features it reads as; the tab names both.- Returns:
List of Tab objects.
- to_markdown() str#
Return a markdown summary of extracted features.
Includes feature counts, category breakdown (cut/forming with boundary/internal split), and classification summary statistics.
The summary reports only what the extractions that ran can support: with none run it says so rather than describing the part, and otherwise it names the extractions its numbers cover.
- Returns:
Markdown-formatted string
- Return type:
str
- Raises:
ValueError – If a recognized feature claims a face the part does not have — see
get_face_coverage(), whose section this carries.
- unfold(k_factor: float = 0.33, fixed_face: int | None = None, cut_edges: Iterable[int] = (), length_unit: Literal['m', 'mm', 'in'] = 'm') FlatPattern#
Lay the sheet-metal part flat: the blank it is cut from, with its bend lines.
Recognises the sheet-metal features first if that has not been done; they are recognised apart from this processor’s own results, which are left as they were. Each fold (bend, hem or curl) is developed at its neutral radius,
inside_radius + k_factor * thickness. A formed feature (emboss, dimple, bead, louvre, extrusion hole, flanged cutout) is pressed after the blank is cut: the blank keeps the flat footprint it is pressed from, with a forming mark for the press and a slit where the sheet was sheared. An extrusion hole’s footprint is pierced with the smaller hole its collar is drawn from, unless the collar is longer than its footprint could supply by bending alone: the blank then has no hole there, and the mark is listed in the pattern’sflagged_markswith a note giving both lengths. A formed feature must meet one flat stretch of sheet along a single closed loop: one that reaches the sheet’s edge, lies across a bend, sits on another formed feature or meets the sheet along several loops is refused, as is a flanged cutout that is neither an extrusion hole nor a louvre.- Parameters:
k_factor – Where the neutral layer sits, as a fraction of the thickness measured from the inside face of a bend. That layer neither stretches nor shrinks, and its arc across a bend is the bend allowance. The default, 0.33, suits most air-bent steel with an inside radius close to the thickness; pass a measured value for other materials or tooling.
fixed_face – The face to develop from; by default the largest face of the largest flange.
cut_edges – Edges to cut so that faces closing on themselves can lie flat; an error naming such faces lists the edges, any one of which would do. Cutting an edge parts the two faces it runs between along every edge they share.
length_unit – The unit the part is in: metres for a part read from a file the usual way. The pattern is in the same unit and says so, so that a drawing of it can be written in the right scale.
- Returns:
The flat pattern.
- Raises:
ValueError – On a bad argument: a K-factor outside 0 to 1, a fixed face that is not a flat face of the sheet, or a cut edge not between two of its faces.
UnfoldError – If the part cannot be laid flat. Its
reasonis"not_sheet_metal"when the part is not recognised as sheet metal, is built in a way sheet-metal recognition does not support, or its thickness cannot be measured;"non_developable"when curved faces of the sheet belong to no bend or formed feature, or a bend or formed feature has no known flat shape;"closed_loop"when the sheet closes on itself and needs a cut edge;"overlap"when, laid flat, parts of the sheet land on each other;"placement_mismatch"when neighbouring faces do not line up once flat.
- property unknown_features: list[UnknownFeature]#
Get extracted unknown features.
- Returns:
List of UnknownFeature objects (immutable)
- view(feature_type: type[Feature] | None = None) None#
Open the recognized features, colored, in the local DocModel viewer.
Developer-workstation convenience (interactive side effect, no return value) kept out of
show_features()so the@cad_viewplatform contract stays “return babylon display data”.- Parameters:
feature_type – Same selection as
show_features().- Raises:
ValueError – If
feature_typeis not among the extracted types.
- class volmdlr_tools.features.FeatureRecord(kind: Literal['hole', 'pocket', 'slot', 'step', 'groove', 'cut', 'boss', 'addition', 'blend', 'chamfer', 'revolution', 'extrusion', 'drafted_extrusion', 'wall', 'pipe', 'loft', 'sweep'], sense: Literal['add', 'subtract', 'edge'], face_ids: frozenset[int], base_face_ids: frozenset[int] = frozenset({}), parents: tuple[int, ...] = (), readers: tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer', 'turned', 'slabs', 'body', 'trims', 'walls', 'pipes', 'lofts', 'sweeps'], ...] = (), stage: Literal['body', 'feature', 'finishing'] = 'feature', origin: Literal['simple', 'advanced'] = 'simple', end_face_ids: frozenset[int] = frozenset({}), _sources: tuple[tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer'], int], ...] = ())#
Bases:
objectOne feature of a part: what one modelling operation makes.
- Parameters:
kind – What the feature is.
"revolution"is the profile a turned part is turned from.sense –
"add"for material standing on the part,"subtract"for material taken away,"edge"for a blend or chamfer worked on edges.face_ids – The part’s faces the feature accounts for.
base_face_ids – The faces the feature stands on or is cut into, when its readers read them.
parents – The indices of the records this feature was made on or cut into; a parent may come after its child in the records, as a body the advanced readers read again follows the records it replaces; none for one made on the body alone.
readers – The readers whose readings the feature merges, in the order they read it.
stage – When the operation comes in the making of the part. A record worked on edges is always
"finishing". Only the body reading makes"body"records; every other record is a"feature", the profile a turned part is turned from and the profiles a part is extruded from among them.origin – Which family of readings made the record:
"simple"for the simple readers and"advanced"for the readers of the regions the others leave unexplained.end_face_ids –
The faces among face_ids that close the feature; every other face the record holds is a side, see
role_of(). What closes each kind of record:pocket, slot, step and groove: its floor, when it has one;
cut: its floor, when it has one;
hole: its bottom, which the shoulder of a counterbore is not;
boss: its top, when it stands on a flat face;
addition: the end faces of the extrusion it was read as;
extrusion body and drafted extrusion body: its two caps;
revolution, as a body or as the profile a part is turned from: the flat faces holding its axis, where a turn of less than a whole one starts and stops; a whole turn has none;
extrusion read from a slab of the part: its two caps;
any feature that runs right through: none, whatever a reading says of it;
blend and chamfer: none, they are worked on edges and give their faces no role.
A face is an end when any reading of the feature calls it one, unless the feature runs through. A body is the one to say what is an end of its own faces, whatever the records it took over said of them.
_sources – Which readings the record merges, as (reader, position among that reader’s readings); the document’s loop readings are the ones named
"depression_protrusion". Kept beside the record, not in what it equals, and followed by the record through every change of its faces or its number.
- Raises:
ValueError – When end_face_ids names a face the record does not hold, or a record worked on edges has end faces.
- base_face_ids: frozenset[int] = frozenset({})#
- end_face_ids: frozenset[int] = frozenset({})#
- face_ids: frozenset[int]#
- kind: Literal['hole', 'pocket', 'slot', 'step', 'groove', 'cut', 'boss', 'addition', 'blend', 'chamfer', 'revolution', 'extrusion', 'drafted_extrusion', 'wall', 'pipe', 'loft', 'sweep']#
- origin: Literal['simple', 'advanced'] = 'simple'#
- parents: tuple[int, ...] = ()#
- readers: tuple[Literal['interacting', 'depression_protrusion', 'split_adjacency', 'blend', 'chamfer', 'turned', 'slabs', 'body', 'trims', 'walls', 'pipes', 'lofts', 'sweeps'], ...] = ()#
- restricted_to(faces: frozenset[int]) FeatureRecord#
Return the record cut down to faces, its end faces cut down with it.
- Parameters:
faces – The faces the record keeps; any other face it held is dropped.
- role_of(face: int) Literal['side', 'end'] | None#
Say what a face is to the record:
"end"for a face that closes it,"side"for any other it holds.- Parameters:
face – A face of the part.
- Returns:
Its role, or
Nonefor a face the record does not hold and for every face of a record worked on edges, which gives its faces no role.
- sense: Literal['add', 'subtract', 'edge']#
- stage: Literal['body', 'feature', 'finishing'] = 'feature'#
- class volmdlr_tools.features.FeaturesRecognizer(*args, **kwargs)#
Bases:
FeatureProcessorBackward compatibility alias for FeatureProcessor.
- . deprecated:: v1.0.0
Use FeatureProcessor instead. This alias will be removed in version 1.0.0.
- blends_recognition(max_radius: float)#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_blends() instead.
- cavities_recognition()#
Deprecated method for backward compatibility.
Deprecated since version v1.0.0: Use extract_cavities() instead.
- cavitivies_recognition()#
Deprecated alias for cavities_recognition() (legacy misspelling).
- emboss_recognition()#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_deformations() instead.
- Raises:
ValueError – If the shape is not a sheet metal.
- sharp_edges_recognition()#
Deprecated method for backward compatibility.
- . deprecated:: v1.0.0
Use extract_sharp_edges() instead.
- class volmdlr_tools.features.HoleExtractor(aag: AttributedAdjacencyGraph, linear_tolerance: float = 0.0001, angular_tolerance: float = 0.0175, name: str = '')#
Bases:
FeatureExtractorExtract hole features from an Attributed Adjacency Graph (AAG).
This class recognizes holes by grouping coaxial cylindrical/conical faces, building connected components, merging vertex-sharing fragments from intersecting holes, and splitting non-monotonic radius profiles.
Key differences from CavityExtractor: - Seed type: Coaxial face groups (vs. faces with inner wires) - Propagation: Through coaxial groups + neighbor intersection (vs. outer wire neighbors) - Validation: Angular coverage per radius level (vs. connected components)
- Parameters:
aag – The Attributed Adjacency Graph (AAG) representation of the CAD model.
linear_tolerance – Tolerance for radius and position comparisons.
angular_tolerance – Tolerance for axis direction comparisons (radians).
name (str) – Name for the extractor instance.
- bores_of(hole_faces: Collection[int]) tuple[frozenset[int], ...]#
Return a hole’s faces as they own their edges: the arcs of each of its bores together, every other face alone.
Notches cut along a bore part its cylinder into arcs side by side; those arcs are one bore. Lengths of a bore of one size apart along its axis are two. Worked out once for each set of faces.
- Parameters:
hole_faces – The faces of a hole.
- Returns:
The groups, in the order of their first face.
- 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. Groups coaxial cylindrical faces, finds connected components (merging vertex-sharing fragments from intersecting holes), splits non-monotonic radius profiles into separate holes, and adds ending faces.
- Returns:
True if extraction completed successfully.
- class volmdlr_tools.features.RecognitionDocument(records: tuple[FeatureRecord, ...], face_account: tuple[FaceStatus, ...], refusals: tuple[FaceRefusal, ...] = (), _kept: KeptReadings | None = None)#
Bases:
objectA part’s features, and what every face of the part is.
- Parameters:
records – The part’s single features.
face_account – One status for each face of the part, face
iat indexi.refusals – The readings set aside, each with the faces it covered and why, whether or not another reading accounts for those faces.
- Raises:
FeatureRecognitionError – When the account does not add up: a face given to a record that does not hold it, a face a record holds given another status (
"body"for the face of a body record,"feature"for the face of any other record), a status naming a record or a refusal the document does not have, a record or a refusal naming a face the part does not have, or a record naming a parent the document does not have or parents that loop back on a record.
The technique readings the body records and the slab extrusion records came from are kept beside the document, not in it: see
technique_of(). They are not part of what the document equals. Copying the document or rebuilding it withdataclasses.replace()keeps them; pickling or saving it does not.- Parameters:
_kept – The technique readings of the body records and the slab extrusion records, and the loop readings of the others, which the records’ sources number;
Nonewhen the document was loaded or was made without them.
- counts() dict[Literal['feature', 'body', 'refused', 'unexplained'], int]#
Return how many faces of the part have each status, every status named even when no face has it.
- face_account: tuple[FaceStatus, ...]#
- loop_readings_of(index: int) tuple[tuple[DepressionProtrusion, ...], tuple[int, ...]]#
Return the loop readings the document’s records were made from, and which of them the record at index is.
- Parameters:
index – The position of the record in
records.- Returns:
Every loop reading of the part, and the positions among them of those the record merges; none for a record no loop reading found, as one only the cut reader read.
- Raises:
FeatureRecognitionError – When the document holds no loop readings: it was saved and loaded, or made without them. Read the part again with
recognise_features.IndexError – When the document has no record at index.
- records: tuple[FeatureRecord, ...]#
- refusals: tuple[FaceRefusal, ...] = ()#
- slab_stack_of(index: int) SlabStack#
Return the slabs read along the direction of the slab extrusion record at index, and which one it is.
The stack is what the profile of a slab is read from, see
record_parameters(). A slab that gives no technique, as one holding several separate outlines, still has its stack.- Parameters:
index – The position of the record in
records.- Raises:
FeatureRecognitionError – When the document holds no technique readings, as
technique_of()says, or the slab was not read from a part, so that it has no stack.IndexError – When the document has no record at index.
ValueError – When the record is not an extrusion the reader of slabs read.
- technique_of(index: int) BodyTechnique | SlabTechnique#
Return the technique reading the body record or the slab extrusion record at index came from.
A body record gives a
BodyTechniqueand needs the part read withbody=True. A record the reader of slabs read, as an extrusion, gives aSlabTechnique, with or without the body. Neither is there for a document that was pickled or saved and loaded. The profile an extruded body or a slab was drawn from, its outlines, holes, drafts and levels, is read from them byrecord_parameters().- Parameters:
index – The position of the record in
records.- Returns:
The domain of the body and its extrusion or its turn, or the direction and the levels of the slab.
- Raises:
FeatureRecognitionError – When the document holds no technique readings: it was not read with
body=Trueand no slab was read, the faces of the body were named withstock_facesso no body was read, its body reading failed, or it was saved and loaded. Read the part again withrecognise_features(shape, body=True)and nostock_faces.IndexError – When the document has no record at index.
FeatureRecognitionError – Also, for a slab record, when the slab holds several separate outlines or its walls lean by different angles: it has no one direction, levels and draft to give, and the caller reads the record some other way.
ValueError – When the record is neither a body nor an extrusion the reader of slabs read.
- tree() tuple[ConstructionNode, ...]#
Return the records as a construction tree: each under the record it was made on or cut into.
The roots are the records made on nothing: the bodies first, then the features, then the work done on edges. Each record’s children come in the same order, and records of one stage in the order of
records. A record with several parents hangs under the deepest of them, the one the longest chain of parents leads to, and under the one that comes first inrecordswhen they are as deep.The tree is a partial order only: a record always comes after the record it hangs under, and the work done on edges last among its siblings. It does not say which of two siblings is made first.
- Returns:
The roots of the tree; every record is in it once.
- class volmdlr_tools.features.RecognizeBlends(aag: AttributedAdjacencyGraph, max_radius: float = 0.5)#
Bases:
BlendExtractorDeprecated: 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.
- class volmdlr_tools.features.RecognizeCavities(aag: AttributedAdjacencyGraph)#
Bases:
CavityExtractorDeprecated: 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.
- class volmdlr_tools.features.RegionReading(records: tuple[FeatureRecord, ...], refusals: tuple[FaceRefusal, ...])#
Bases:
objectWhat the advanced readers read of one region of a part.
- Parameters:
records – The bodies read, in the order the readers are tried:
stage="body",origin="advanced", the reader that read each as its onlyreadersentry, no parents, and only faces of the region.refusals – One for each reader tried that kept nothing, naming it, covering only faces of the region.
- records: tuple[FeatureRecord, ...]#
- refusals: tuple[FaceRefusal, ...]#
- class volmdlr_tools.features.SharpEdgeExtractor(aag: AttributedAdjacencyGraph, name: str = '')#
Bases:
FeatureExtractorExtract 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() dict#
Implementation of a tag for displays.
- 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.SharpEdgeRecognizer(aag: AttributedAdjacencyGraph, name: str = '')#
Bases:
SharpEdgeExtractorDeprecated: 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.
- class volmdlr_tools.features.SlabStack(slabs: tuple[DraftedSlab, ...], position: int, levels: tuple[float, float], capped: tuple[bool, bool] = (False, False))#
Bases:
objectThe slabs read along one direction of a part, and which of them a slab record came from.
- Parameters:
slabs – The slabs, in order along their direction.
position – The position among slabs of the slab the record came from.
levels – Where the record’s slab starts and stops along the direction, the start the lower: the plane of a cap at an end the slab has one, else the end of the stretch the slab was read over.
capped – Whether a cap closes the slab at its start, and at its end.
- Raises:
ValueError – When position names no slab of slabs, or levels are not in order.
- capped: tuple[bool, bool] = (False, False)#
- levels: tuple[float, float]#
- position: int#
- property slab: DraftedSlab#
The slab the record came from.
- slabs: tuple[DraftedSlab, ...]#
- class volmdlr_tools.features.SlabTechnique(extrusion: ExtrusionReading, direction: tuple[float, float, float], levels: tuple[float, float], draft_angle: float = 0.0, outline_face_ids: frozenset[int] = frozenset({}), stack: SlabStack | None = None)#
Bases:
objectThe reading a slab extrusion record came from: along which direction the slab was read, and where it stands.
A slab is a stretch of the part along one direction over which its section keeps following one law, straight or leaning. It describes the slab as it was read, before other records took some of its faces: the faces the record holds are its
face_ids, and may be fewer than the faces read here.- Parameters:
extrusion – The extrusion of the part along the slab’s direction, as the part’s faces fit it.
direction – The unit direction the slab was read along.
levels – Where the slab starts and stops along direction, measured from the origin of space in the model’s own length units; the start is the lower. Each is the position of the plane of the caps closing the slab at that end. At an end where the slab has no cap, as where it meets another slab or the body, it is the end of the stretch the slab was read over, which stops a little short of a rim, within a fraction of a percent of the part’s extent along direction.
draft_angle – The angle in radians by which the slab’s outline grows with each unit of height along direction, so positive when it widens along it and negative when it narrows; zero when the slab stands straight, its outline leaning by less than half a degree. A slab with several outer outlines, or whose walls lean by different angles, gives no technique, see
RecognitionDocument.technique_of().outline_face_ids – The caps of the slab and the faces on the outer loop of its section, not those round its windows.
stack – The slabs read along the slab’s direction, which its profile is read from: see
record_parameters().Nonefor a technique not read from a part.
- Raises:
ValueError – When direction is not of unit length, or levels are not in order.
- direction: tuple[float, float, float]#
- draft_angle: float = 0.0#
- extrusion: ExtrusionReading#
- levels: tuple[float, float]#
- outline_face_ids: frozenset[int] = frozenset({})#
- exception volmdlr_tools.features.UnextractedAccessError#
Bases:
RuntimeErrorA feature collection was read before any extraction that fills it had run.
Answering the empty list here would spell “nothing was looked for” the same way as “nothing was recognized”, so the read refuses instead. The message names the
extract_*call that satisfies the precondition; once it has run, the same property answers normally, and an empty answer means the part has none. A caller that would rather branch than catch can readFeatureProcessor.extractions_run, which the message points at.
- volmdlr_tools.features.read_region(part: shapes.Shape | PartReading, face_ids: Iterable[int], *, exclude: Iterable[str] = (), readers: Sequence[AdvancedReader] | None = None, strict: bool = False, deadline: float | None = None) RegionReading#
Read one region of a part with the advanced readers, except the ones named.
Every reader not excluded is tried, in the order walls, pipes, lofts, sweeps; none is skipped for not suiting the region. Every reader reads the region alone, so that both skins of a wall, every bend of a pipe, the whole band of a loft and every face a sweep’s profile is carried along must lie in it, a pipe’s legs and caps, a loft’s closing faces and a sweep’s start and end faces in the faces next to it. A reading is kept when the region holds at least
MIN_SHAREof its area, and what it keeps is its faces in the region that no reader before it kept: so a reading reaching past the region gives only the faces of the region, and two readings of the same faces give them to the first reader.A reader that keeps nothing leaves one refusal naming it, the first of these that applies:
it ran out of time: no face; a reader reached once the deadline has passed is not run and leaves the same;
it failed: its own reason, no face;
a reading of it lies mostly outside the region: the faces of the region the reading holds;
every face its readings hold in the region is taken by a reader before it: those faces;
a refusal of its own overlaps the region: the faces of the refusal within the region, the refusal that overlaps it most;
otherwise it reads nothing in the region: no face.
- Parameters:
part – The part, or the part read already, which is used as it is and shared.
face_ids – The faces of the region, numbered as the part’s adjacency graph numbers them.
exclude – The names of the readers left out, as a list such as
["walls"]: any ofwalls,pipes,loftsandsweeps, or of the names of readers when they are given.readers – The advanced readers, in the order they are tried;
ADVANCED_READERSwhen none are given.strict – Whether a reader’s exception is raised instead of recorded as a refusal.
deadline – The moment by which the reading must be over, as
time.perf_counter()gives it, not a duration; no limit beyond each reader’s own when omitted.
- Returns:
The bodies read and the refusals; both empty when every reader is left out.
- Raises:
TypeError – If exclude is a single string instead of a list of names.
ValueError – If the region holds no face, or a reader named in exclude is not one of the readers.
IndexError – If a face of the region is no face of the part.
FeatureRecognitionError – In strict mode, when a reader raises.
- volmdlr_tools.features.recognise_features(part: Shape | PartReading, stock_faces: Iterable[int] | None = None, stock_convention: Literal['extruded_profile', 'supporting_plane', 'convex_hull'] = 'convex_hull', *, families: Iterable[Literal['cuts', 'bosses', 'additions', 'blends', 'chamfers', 'trims', 'profiles']] | None = None, strict: bool = False, body: bool = False, deadline: float | None = None, body_wall_rounds: bool = True) RecognitionDocument#
Recognise a part’s features and say what every face of it is.
- Parameters:
part – The part: one solid, alone or as the only thing in a compound; or the part read already, as a
PartReading, which is used as it is and shared rather than read again. The document is the same either way.stock_faces – The faces of the body the cuts are taken from, when the caller has read that body; omitted, they are the faces of the part’s machining stock.
stock_convention – What counts as the raw stock; see
FeatureProcessor.extract_feature_model().families – The families to read, such as
["cuts"]for holes, pockets and slots alone; all of them by default. SeeFamily.strict – Whether a reader’s exception is raised, as a
FeatureRecognitionError, instead of recorded as a refusal over the part.body – Whether to read the body the part was made from, and the holes, pockets and slots made in it, and to read again the regions those readings leave with the readers of walls, pipes, lofts and sweeps; see
FeatureProcessor.recognise().deadline – The moment by which the readings must be over, as
time.perf_counter()gives it, not a duration:time.perf_counter() + 30. No limit beyond each reader’s own when omitted. A reader not yet run when it passes, and the body reading, leave a refusal saying their time ran out; what was read before is in the document. A reader already running is cut short only if it watches the time it is given.body_wall_rounds – Whether a round that is a wall of a pocket, a slot, a step or a cut, or with body a wall of a body’s extrusion or turn, a rounded corner of the profile it was made from, is given to the record whose profile it rounds rather than read as a blend; true by default.
- Returns:
The document
FeatureProcessor.recognise()gives.- Raises:
ShapeTypeError – When part is not one solid.
ValueError – If
stock_convention, or a family, is not one on offer, ifstock_facesis given but names no face, or ifdeadlineis not a finite moment.FeatureRecognitionError – In strict mode, when a reader raises, or reports a failure it read past, such as the recognition of an addition failing on its faces, or when the body reading fails.
- volmdlr_tools.features.record_parameters(reading: PartReading, document: RecognitionDocument, index: int) HoleStack | BossParameters | PocketParameters | SlotParameters | GrooveParameters | AdditionParameters | RibPlate | BlendParameters | ChamferParameters | ExtrudedBodyParameters | RevolvedBodyParameters | FaceRefusal#
Read the parameters of the feature the record at index names.
A hole gives its axis, its entry and its steps, a groove its axis and its profile, a pocket, a slot, a step, a cut or a boss its outline and its depth or height, an addition its profile, its direction and its length, all in the part’s own length units. The parameters say what the record’s faces read as, which is not always the kind of the record: a round blind hole with a wide flat floor may read as a pocket. The parameters may hold faces the record does not, such as the blends round a feature, or the steps of a hole read as one hole.
A blend gives the radius it rounds with, the edges it rounds, each named by the two faces that met along it, and the rounds of a larger radius it runs on over; a chamfer the distances it cuts back and the edges it bevels.
An extruded body (a body record of kind
"extrusion"or"drafted_extrusion") or a slab gives the profiles it was drawn from, one per stretch of it from the lowest up: the plane each is drawn in and the direction it is extruded along, its outer outlines, the holes in them and the islands in those, the draft of each outline and of each of its edges, signed so that a hole widening along the direction counts as an outline growing, the levels it is extruded between and what closes it at each, and, for a slab, the plane a run of slabs released the same way is drafted about and whether every outline of the part’s section at it is in the profile.A turned body (a body record of kind
"revolution") gives the profile it was turned from, read face by face from the faces it sweeps, in the half plane the turn starts from: its axis, the chains of lines and arcs of the profile as(t, r), along the axis and away from it, and the angle it is turned through, a whole turn or less. A corner of the profile a chamfer record bevels is sharp: the chamfer, a bevel turned on its rim, is worked on it after. A turned body whose faces close into no profile is refused with the reason the body reading gave. Arevolutionrecord that is not a body record, the turned profile of a part read withoutbody=True, is refused: only a body reading gives a profile.A pocket, a slot, a step, a cut or a boss is read first from the loop its faces were found from, or from where they meet the faces it opens in or stands on; when its faces do not read so, they are read as the one straight prism they make standing on the rest of the part, cut into it or rising from it. A boss neither reads, yet a rib, a thin plate standing on the part such as a gusset between a hub and its flange, gives the rib: its mid plane, its profile there, its thickness and its draft. A record no reading reads is refused with the reasons of the prism readings.
- Parameters:
reading – The reading of the part the document was made from.
document – The document
recognise_features()made of the part.index – The position of the record in the document’s
records.
- Returns:
The parameters, or a refusal naming the record’s faces and saying why they give none.
- Raises:
IndexError – When the document has no record at index.
ValueError – When the record is not a hole, groove, pocket, slot, step, cut, boss, addition, blend, chamfer, extruded body, slab or revolution, or reading is of a part with a different number of faces than the document’s.
FeatureRecognitionError – When the record is no addition, blend or chamfer and the document holds no readings to read its parameters from: it was saved and loaded, or made without them. Read the part again with
recognise_features.
- volmdlr_tools.features.step_holder(reading: PartReading, document: RecognitionDocument, index: int) int | None#
Return the position of the hole whose parameters hold the faces of the step record at index.
A hole read as one hole holds the faces of its steps, which the document may keep as records of their own: such a step is no feature to rebuild, its hole is, and
record_parameters()refuses the step naming that hole.Nonefor a step of a hole that no record names any longer, and for any record that is no step of a hole.- Parameters:
reading – The reading of the part the document was made from.
document – The document
recognise_features()made of the part.index – The position of the record in the document’s
records.
- Raises:
IndexError – When the document has no record at index.
ValueError – When reading is of a part with a different number of faces than the document’s.