OCC.Extend.TopologyUtils module

class TopologyExplorer(myShape, ignore_orientation=True)

Bases: object

Topology traversal

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

note when traversing TopoDS_Wire entities, its advised to use the specialized WireExplorer class, which will return the vertices / edges in the expected order

Parameters
  • myShape – the shape which topology will be traversed

  • 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

comp_solids()

loops over all compound solids

compounds()

loops over all compounds

edges()

loops over all edges

edges_from_face(face)
Parameters

face

Returns

edges_from_vertex(vertex)
edges_from_wire(wire)
faces()

loops over all faces

faces_from_edge(edge)
Parameters

edge

Returns

faces_from_solids(solid)
faces_from_vertex(vertex)
faces_from_wire(wire)
number_of_comp_solids()
number_of_compounds()
number_of_edges()
number_of_edges_from_face(face)
number_of_edges_from_vertex(vertex)
number_of_edges_from_wire(wire)
number_of_faces()
number_of_faces_from_edge(edge)
Parameters

edge

Returns

number_of_faces_from_solids(solid)
number_of_faces_from_vertex(vertex)
number_of_faces_from_wires(wire)
number_of_ordered_edges_from_wire(wire)
number_of_ordered_vertices_from_wire(wire)
number_of_shells()
number_of_solids()
number_of_solids_from_face(face)
number_of_vertices()
number_of_vertices_from_edge(edg)
number_of_vertices_from_face(face)
number_of_wires()
number_of_wires_from_edge(edg)
number_of_wires_from_face(face)
ordered_edges_from_wire(wire)

@param wire: TopoDS_Wire

ordered_vertices_from_wire(wire)

@param wire: TopoDS_Wire

shells()

loops over all shells

solids()

loops over all solids

solids_from_face(face)
vertices()

loops over all vertices

vertices_from_edge(edg)
vertices_from_face(face)
wires()

loops over all wires

wires_from_edge(edg)
wires_from_face(face)
wires_from_vertex(edg)
class WireExplorer(wire)

Bases: object

Wire traversal

ordered_edges()
ordered_vertices()
discretize_edge(a_topods_edge, deflection=0.2, algorithm='QuasiUniformDeflection')

Take a TopoDS_Edge and returns a list of points The more deflection is small, the more the discretization is precise, i.e. the more points you get in the returned points algorithm: to choose in [“UniformAbscissa”, “QuasiUniformDeflection”]

discretize_wire(a_topods_wire, deflection=0.5)

Returns a set of points

dump_topology_to_string(shape, level=0, buffer='')

Return the details of an object from the top down

get_sorted_hlr_edges(topods_shape, position=<class 'gp_Pnt'>, direction=<class 'gp_Dir'>, export_hidden_edges=True)

Return hidden and visible edges as two lists of edges

get_type_as_string(topods_shape)

just get the type string, remove TopAbs_ and lowercas all ending letters

is_compound(topods_shape)
is_compsolid(topods_shape)
is_edge(topods_shape)
is_face(topods_shape)
is_shell(topods_shape)
is_solid(topods_shape)
is_vertex(topods_shape)
is_wire(topods_shape)
list_of_shapes_to_compound(list_of_shapes)

takes a list of shape in input, gather all shapes into one compound returns the compund and a boolean, True if all shapes were added to the compund, False otherwise