Topology¶
No example available.
Declaration¶
- class declaracad.occ.impl.topology.Topology[source]¶
Bases:
Atom
Topology traversal ported from the pythonocc examples by @jf—
Implements topology traversal from any TopoDS_Shape this class lets you find how various topological entities are connected from one to another find the faces connected to an edge, find the vertices this edge is made from, get all faces connected to a vertex, and find out how many topological elements are connected from a source
- Attributes:
- area
- bezier_curves
- bezier_surfaces
- bspline_curves
- bspline_surfaces
- center_point
- circle_curves
- comp_solids
- compounds
- cone_surfaces
- curve_bounds
- curves
- cylinder_surfaces
- edges
- ellipse_curves
- end_point
- end_tangent
- faces
- hyperbola_curves
- ignore_orientation
- length
- line_curves
- mass
- offset_curves
- offset_surfaces
- outer_wire
- parabola_cuves
- plane_surfaces
- points
- shape
- shells
- solids
- sphere_surfaces
- start_point
- start_tangent
- surface_bounds
- torus_surfaces
- unique_vertices
- vertices
- volume
- wires
Methods
are_faces_connected
(face, other_face[, edges])Check if two faces are connected by one of their edges.
bbox
(shapes[, optimal, tolerance, enlarge])Compute the bounding box of the shape or list of shapes
cast_curve
(shape[, expected_type, convert])Attempt to cast the shape (an edge or wire) to a curve.
cast_shape
(shape)Convert a TopoDS_Shape into it's actual type, ex an TopoDS_Edge
cast_surface
(shape[, expected_type, convert])Attempt to cast the shape (a face) to a surface
curve_value_at
(curve, t[, derivative])Get the value of the curve at parameter t with it's derivatives.
discretize
(shape, deflection[, method])Convert an edge or wire to points.
discretize_curve
(curve, deflection[, method])Convert a curve to points.
distance_between
(other_shape[, min_max])Compute the min and max distance between this and the other shape.
edges_from_wire
(wire)extract_curves
(curve_type)Returns a list of tuples containing the edge and curve
extract_surfaces
(surface_type)Returns a list of dicts containing the face and surface
faces_from_edge
(edge)faces_from_vertex
(vertex)faces_sharing_edges
(face, faces)Return list of faces which have at least one shared edge with face.
find_common_edges
(shape)Find edges common to this shape and the given shape
find_common_vertices
(shape)Find edges common to this shape and the given shape
find_unique_edges
(shapes)Find edges unique to only one shape in the set of shapes.
freeze
Freeze the atom to prevent further modifications to its attributes.
get_member
Get the named member for the atom.
get_value_at
(curve, t[, derivative])has_observer
Get whether the atom has the given observer for a given topic.
has_observers
Get whether the atom has observers for a given topic.
intersection
(shape[, multiple, tol])Returns the resulting intersection of this and the given shape or None if an error or an empty list there are no intersections.
intersection_parameters
(curve)Determine the parameter from a point on the curve
is_bezier_curve
(shape)Check if an edge or wire is a bezier curve.
is_bspline_curve
(shape)Check if an edge or wire is a bspline curve.
is_circle
(shape)Check if an edge or wire is a part of a circle.
is_clockwise
(shape)Check if the face or wire's orientation is clockwise relative to the postive Z axis.
is_cone
(shape)Check if a surface is a cone.
is_cylinder
(shape)Check if a surface is a cylinder.
is_edge
(shape)Check if the given shape is an edge.
is_ellipse
(shape)Check if an edge or wire is a part of an ellipse.
is_face
(shape)Check if the given shape is a face.
is_line
(shape)Check if an edge or wire is a line.
is_plane
(shape)Check if a surface is a plane.
is_reversed
(shape)Check if the shape's orentation is reversed.
is_shape_in_list
(shape, shapes)Check if an shape is in a list of shapes using the IsSame method.
is_shell
(shape)Check if the given shape is a shell.
is_solid
(shape)Check if the given shape is a solid.
is_vertex
(shape)Check if the given shape is a vertex.
is_wire
(shape)Check if the given shape is a face.
join_edges
(edges[, tolerance])Join a set of edges into a set of wires.
members
()Get the members dictionary for the type.
min_distance_between
(other_shape)notifications_enabled
Get whether notification is enabled for the atom.
notify
Call the registered observers for a given topic with positional and keyword arguments.
observe
Register an observer callback to observe changes on the given topic(s).
offset_curve
(curve, offset, direction)Create an offset curve for the given curve
offset_curve_value_at
(curve, offset, t, ...)Compute the offset value
ordered_edges_from_wire
(wire)Get edges from a wire.
Get vertices from a wire.
parameter_at
(curve, point)Determine the parameter from a point on the curve
parametrize_by_length
(shape, length)Parametrize an edge or wire.
parametrize_curve_by_length
(curve, length)Parametrize a curve
set_notifications_enabled
Enable or disable notifications for the atom.
solids_from_face
(face)suppress_notifications
()Disable member notifications within in a context.
surface_value_at
(surface, u, v[, derivative])Get the value of the surface at parameter t with it's derivatives.
unique_shapes
(shapes)Filter out those entities that share the same TShape but do not share the same orientation.
unobserve
Unregister an observer callback for the given topic(s).
vertices_from_edge
(edge)wires_from_face
(face)edges_from_face
edges_from_vertex
faces_from_solids
faces_from_wire
max_distance_between
vertices_from_face
wires_from_edge
wires_from_vertex
- classmethod are_faces_connected(face: TopoDS_Face, other_face: TopoDS_Face, edges: Iterable[TopoDS_Edge] | None = None) → bool[source]¶
Check if two faces are connected by one of their edges. This does NOT work for intersections or shared vertices!
- Parameters:
- face: TopoDS_Face
Face to check connection with
- other_face: TopoDS_Face
Face to check connection to
- edges: Optional[Iterable[TopoDS_Edge]]
An optional iterable of edges to check. If not provided all edges from face will be used.
- Returns:
- result: bool
True if any of the edges are the same
- classmethod bbox(shapes, optimal=False, tolerance=0, enlarge=0)[source]¶
Compute the bounding box of the shape or list of shapes
- Parameters:
- shapes: Shape, TopoDS_Shape or list of them
The shapes to compute the bounding box for
- Returns:
- bbox: BBox
The bounding box of the given shapes
- classmethod cast_curve(shape: TopoDS_Edge | TopoDS_Wire, expected_type: GeomAbs_CurveType | None = None, convert: bool = True) → Geom_Curve | BRepAdaptor_Curve | None[source]¶
Attempt to cast the shape (an edge or wire) to a curve. If a cast occurs the UV parameters will be lost.
- Parameters:
- shape: TopoDS_Edge
The shape to cast
- expected_type: GeomAbs_CurveType
The type to restrict
- Returns:
- curve: Curve or None
The curve or None if it could not be created or if it was not of the expected type (if given).
- classmethod cast_shape(shape: TopoDS_Shape) → TopoDS_Shape | None[source]¶
Convert a TopoDS_Shape into it’s actual type, ex an TopoDS_Edge
- Parameters:
- topods_shape: TopoDS_Shape
The shape to cas
- Returns:
- shape: Optional[TopoDS_Shape]
The actual shape or None if the value is not a TopoDS_Shape.
- classmethod cast_surface(shape: TopoDS_Face, expected_type: GeomAbs_SurfaceType | None = None, convert: bool = True) → Geom_Surface | BRepAdaptor_Surface | None[source]¶
Attempt to cast the shape (a face) to a surface
- Parameters:
- shape: TopoDS_Face
The shape to cast
- expected_type: GeomAbs_SurfaceType
The type to restrict
- Returns:
- surface: BRepAdaptor_Surface or None
The surface or None if it could not be created or did not match the expected type (if given).
- classmethod curve_value_at(curve, t: float, derivative: int = 0)[source]¶
Get the value of the curve at parameter t with it’s derivatives.
- Parameters:
- curve: BRepAdaptor_Curve
The curve to get the value from
- t: Float
The parameter value from 0 to 1
- derivative: Int
The derivative from 0 to 4
- Returns:
- results: Point or Tuple
If the derivative is 0 only the position at t is returned, otherwise a tuple of the position and all deriviatives.
- classmethod discretize(shape: TopoDS_Wire | TopoDS_Edge, deflection: float | int, method: str = 'quasi-deflection') → Iterable[Point][source]¶
Convert an edge or wire to points.
- Parameters:
- deflection: Float or Int
Maximum deflection allowed if method is ‘deflection’ or ‘quasi-‘defelction’ else this is the number of points
- n: Int
Number of points to use
- methode: Str
A value of either ‘deflection’ or ‘abissca’
- Yields:
- points: Point
A list of points that make up the curve
- classmethod discretize_curve(curve: BRepAdaptor_Curve | BRepAdaptor_CompCurve, deflection: float | int, method: str = 'quasi-deflection') → Iterable[Point][source]¶
Convert a curve to points.
- Parameters:
- deflection: Float or Int
Maximum deflection allowed if method is ‘deflection’ or ‘quasi-‘defelction’ else this is the number of points
- n: Int
Number of points to use
- method: Str
A value of either ‘deflection’ or ‘abissca’
- Yields:
- points: Point
A list of points that make up the curve
- distance_between(other_shape: Point | TopoDS_Shape, min_max: str = 'min') → BRepExtrema_DistShapeShape[source]¶
Compute the min and max distance between this and the other shape.
- Returns:
- result: BRepExtrema_DistShapeShape
The object
- extract_surfaces(surface_type: GeomAbs_SurfaceType) → list[dict[str, Any]][source]¶
Returns a list of dicts containing the face and surface
- classmethod faces_sharing_edges(face: TopoDS_Face, faces: Iterable[TopoDS_Face]) → set[TopoDS_Face][source]¶
Return list of faces which have at least one shared edge with face. The face itself is always excluded.
- Parameters:
- face: TopoDS_Face
The face to look check against
- faces: Iterable[TopoDS_Face]
The list of faces to look through.
- Returns:
- results: set[TopoDS_Face]
The set of faces which share an edge
- find_common_edges(shape: TopoDS_Shape) → set[TopoDS_Edge][source]¶
Find edges common to this shape and the given shape
- Parameters:
- shape: TopoDS_Shape
The other shape to find common edges with
- Returns:
- edges: List[TopoDS_Edge]
The edges that are considered the same in both shapes.
- find_common_vertices(shape: TopoDS_Shape) → set[TopoDS_Vertex][source]¶
Find edges common to this shape and the given shape
- Parameters:
- shape: TopoDS_Shape
The other shape to find common edges with
- Returns:
- edges: List[TopoDS_Edge]
The edges that are considered the same in both shapes.
- classmethod find_unique_edges(shapes: Iterable[TopoDS_Shape]) → set[TopoDS_Edge][source]¶
Find edges unique to only one shape in the set of shapes.
- Parameters:
- shapes: Iterable[TopoDS_Shape]
The shapes to find the set of unique edges from.
- ignore_orientation¶
Filter out TopoDS_* entities of similar TShape but different orientation for instance, a cube has 24 edges, 4 edges for each of 6 faces that results in 48 vertices, while there are only 8 vertices that have a unique geometric coordinate in certain cases ( computing a graph from the topology ) its preferable to return topological entities that share similar geometry, though differ in orientation by setting the
ignore_orientation
variable to True, in case of a cube, just 12 edges and only 8 vertices will be returned for further reference see TopoDS_Shape IsEqual / IsSame methods
- intersection(shape: Shape | TopoDS_Shape, multiple: bool = False, tol: float = 1e-06) → TopoDS_Shape | list[TopoDS_Shape] | None[source]¶
Returns the resulting intersection of this and the given shape or None if an error or an empty list there are no intersections.
- Parameters:
- shape: Union[Shape, TopoDS_Shape]
The shape to intersect with
- multiple: bool
If true, return all results from section edges.
- Returns:
- results: Optional[Union[TopoDS_Shape, list[TopoDS_Shape]]]:
The single result or list of intersections depending on the multiple parameter.
- intersection_parameters(curve) → list[float][source]¶
Determine the parameter from a point on the curve
- classmethod is_bezier_curve(shape) → bool[source]¶
Check if an edge or wire is a bezier curve.
- Returns:
- bool: Bool
Whether the shape is a bezier curve
- classmethod is_bspline_curve(shape) → bool[source]¶
Check if an edge or wire is a bspline curve.
- Returns:
- bool: Bool
Whether the shape is a bspline curve
- classmethod is_circle(shape) → bool[source]¶
Check if an edge or wire is a part of a circle. This can be used to see if an edge can be used for radius dimensions.
- Returns:
- bool: Bool
Whether the shape is a part of circle
- classmethod is_clockwise(shape: TopoDS_Shape) → bool[source]¶
Check if the face or wire’s orientation is clockwise relative to the postive Z axis.
- Returns:
- result: bool
Whether the shape’s orentation is reversed.
- classmethod is_cone(shape) → bool[source]¶
Check if a surface is a cone.
- Returns:
- bool: Bool
Whether the shape is a cone
- classmethod is_cylinder(shape) → bool[source]¶
Check if a surface is a cylinder.
- Returns:
- result: Bool
Whether the shape is a cylinder
- classmethod is_edge(shape) → bool[source]¶
Check if the given shape is an edge.
- Returns:
- result: Bool
Whether the shape is an edge.
- classmethod is_ellipse(shape) → bool[source]¶
Check if an edge or wire is a part of an ellipse. This can be used to see if an edge can be used for radius dimensions.
- Returns:
- bool: Bool
Whether the shape is a part of an ellipse
- classmethod is_face(shape) → bool[source]¶
Check if the given shape is a face.
- Returns:
- result: Bool
Whether the shape is a face.
- classmethod is_line(shape) → bool[source]¶
Check if an edge or wire is a line. This can be used to see if an edge can be used for length dimensions.
- Returns:
- bool: Bool
Whether the shape is a part of a line
- classmethod is_plane(shape) → bool[source]¶
Check if a surface is a plane.
- Returns:
- bool: Bool
Whether the shape is a part of a line
- classmethod is_reversed(shape: TopoDS_Shape) → bool[source]¶
Check if the shape’s orentation is reversed.
- Returns:
- result: bool
Whether the shape’s orentation is reversed.
- classmethod is_shape_in_list(shape, shapes)[source]¶
Check if an shape is in a list of shapes using the IsSame method.
- Parameters:
- shape: TopoDS_Shape
The shape to check
- shapes: Iterable[TopoDS_Shape]
An interable of shapes to check against
- Returns:
- bool: Bool
Whether the shape is in the list
- classmethod is_shell(shape) → bool[source]¶
Check if the given shape is a shell.
- Returns:
- result: Bool
Whether the shape is a shell.
- classmethod is_solid(shape) → bool[source]¶
Check if the given shape is a solid.
- Returns:
- result: Bool
Whether the shape is a solid.
- classmethod is_vertex(shape) → bool[source]¶
Check if the given shape is a vertex.
- Returns:
- result: Bool
Whether the shape is an vertex.
- classmethod is_wire(shape) → bool[source]¶
Check if the given shape is a face.
- Returns:
- result: Bool
Whether the shape is a face.
- classmethod join_edges(edges: Iterable[TopoDS_Edge], tolerance=1e-06) → list[TopoDS_Wire][source]¶
Join a set of edges into a set of wires.
- Parameters:
- edges: Iterable[TopoDS_Edge]
The edges to join
- Returns:
- wires: List[TopoDS_Wire]
The wires connected.
- classmethod offset_curve(curve: BRepAdaptor_Curve, offset: float, direction: Direction) → Geom_OffsetCurve[source]¶
Create an offset curve for the given curve
- classmethod offset_curve_value_at(curve: BRepAdaptor_Curve, offset: float, t: float, direction: Direction) → Point[source]¶
Compute the offset value
- classmethod ordered_edges_from_wire(wire: TopoDS_Wire) → list[TopoDS_Edge][source]¶
Get edges from a wire.
- Parameters:
- wire: TopoDS_Wire
- classmethod ordered_vertices_from_wire(wire: TopoDS_Wire) → list[TopoDS_Vertex][source]¶
Get vertices from a wire.
- Parameters:
- wire: TopoDS_Wire
- classmethod parameter_at(curve, point: Point) → list[float][source]¶
Determine the parameter from a point on the curve
- classmethod parametrize_by_length(shape: TopoDS_Wire | TopoDS_Edge, length: float) → Iterable[tuple[BRepAdaptor_CompCurve | BRepAdaptor_Curve, float]][source]¶
Parametrize an edge or wire.
- Parameters:
- length: float
The distance between each parameter
- Yields:
- param: Tuple[BRepAdaptor_Curve, float]
The curve and the parameter
- classmethod parametrize_curve_by_length(curve: BRepAdaptor_CompCurve | BRepAdaptor_Curve, length: float) → Iterable[tuple[float]][source]¶
Parametrize a curve
- Yields:
- param: Tuple[BRepAdaptor_Curve, float]
The curve and the parameter
- points¶
Get a list of points from vertices
- shape¶
The shape which topology will be traversed
- classmethod surface_value_at(surface, u, v, derivative=0)[source]¶
Get the value of the surface at parameter t with it’s derivatives.
- Parameters:
- surface: BRepAdaptor_Surface
The curve to get the value from
- t: Float
The parameter value from 0 to 1
- derivative: Int
The derivative from 0 to 4
- Returns:
- results: Point or Tuple
If the derivative is 0 only the position at t is returned, otherwise a tuple of the position and all deriviatives.
- topo_factory = {<TopAbs_ShapeEnum.TopAbs_COMPOUND: 0>: <built-in method Compound of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_COMPSOLID: 1>: <built-in method CompSolid of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_EDGE: 6>: <built-in method Edge of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_FACE: 4>: <built-in method Face of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_SHELL: 3>: <built-in method Shell of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_SOLID: 2>: <built-in method Solid of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_VERTEX: 7>: <built-in method Vertex of PyCapsule object>, <TopAbs_ShapeEnum.TopAbs_WIRE: 5>: <built-in method Wire of PyCapsule object>}¶
Maps topology types and functions that can create this topology
No implementation found