OCCBrep
¤
Class for Boundary Representation of geometric entities.
Attributes:
-
vertices(list[OCCBrepVertex]) –The vertices of the Brep.
-
edges(list[OCCBrepEdge]) –The edges of the Brep.
-
loops(list[OCCBrepLoop]) –The loops of the Brep.
-
faces(list[OCCBrepFace]) –The faces of the Brep.
-
frame(Frame) –The local coordinate system of the Brep.
-
area(float) –The surface area of the Brep.
-
volume(float) –The volume of the regions contained by the Brep.
-
API
Brep
OCCBrep Methods:-
__from_data__ -
boolean_difference -
boolean_intersection -
boolean_union -
copy -
filleted -
from_boolean_difference -
from_boolean_intersection -
from_boolean_union -
from_box -
from_brepfaces -
from_breps -
from_cone -
from_curves -
from_cylinder -
from_extrusion -
from_iges -
from_loft -
from_mesh -
from_native -
from_plane -
from_planes -
from_polygons -
from_shape -
from_sphere -
from_step -
from_step_with_attributes -
from_surface -
from_sweep -
from_torus -
intersect -
offset -
overlap_intersection -
slice -
split -
transformed -
trimmed
-
Attributes¤
is_polygonal
property
¤
is_polygonal: bool
True if every face of the Brep is a flat polygon.
This is the precondition of :meth:to_polylines: a Brep whose faces are all
planar and bounded by straight edges is fully described by the vertices of its
loops, so nothing is lost by reducing it to polylines. A Brep without faces is
not polygonal.
Methods:¤
__from_data__
classmethod
¤
boolean_difference
¤
Return the boolean difference of this shape and a collection of other shapes.
Parameters:
-
others(OCCBrep, default:()) –A collection of other BRep shapes to subtract from the current shape.
Results
OCCBrep The difference between the current shape and the other shapes.
Raises:
-
BrepBooleanError–
boolean_intersection
¤
Return the boolean intersection of the current shape and a collection of other shapes.
Parameters:
-
others(OCCBrep, default:()) –A collection of other BRep shapes to intersect with the current shape.
Returns:
-
OCCBrep–The intersection between the current shape and the others.
Raises:
-
BrepBooleanError–
boolean_union
¤
contours
¤
edge_faces
¤
edge_faces(edge: OCCBrepEdge) -> list[OCCBrepFace]
Identify the faces connected to an edge.
Parameters:
-
edge(OCCBrepEdge) –An edge of the Brep.
Returns:
-
list[OCCBrepFace]–The faces connected to the given edge.
edge_loops
¤
edge_loops(edge: OCCBrepEdge) -> list[OCCBrepLoop]
Identify the parent loops of an edge.
Parameters:
-
edge(OCCBrepEdge) –An edge of the Brep.
Returns:
-
list[OCCBrepLoop]–The loops containing the given edge.
fillet
¤
fillet(radius: float, exclude: list[OCCBrepEdge] | None = None) -> None
Fillet the edges of a BRep.
Parameters:
-
radius(float) –The radius of the fillet.
-
exclude(list[OCCBrepEdge] | None, default:None) –A list of edges to exclude from the fillet operation.
Raises:
-
BrepFilletError–If the fillet operation could not be completed.
Returns:
-
None–the Brep is modified in-place.
filleted
¤
filleted(radius: float, exclude: list[OCCBrepEdge] | None = None) -> OCCBrep
Construct a copy of a Brep with filleted edges.
Parameters:
-
radius(float) –The radius of the fillet.
-
exclude(list[OCCBrepEdge] | None, default:None) –A list of edges to exclude from the fillet operation.
Returns:
-
OCCBrep–
from_boolean_difference
classmethod
¤
from_boolean_intersection
classmethod
¤
from_boolean_union
classmethod
¤
from_box
classmethod
¤
from_brepfaces
classmethod
¤
from_brepfaces(faces: list[OCCBrepFace], solid: bool = True) -> OCCBrep
Make a BRep from a list of BRep faces forming an open or closed shell.
Parameters:
-
faces(list[OCCBrepFace]) –The input faces.
-
solid(bool, default:True) –Flag indicating that if the resulting shape should be converted to a solid, if possible.
Returns:
-
OCCBrep–
from_breps
classmethod
¤
Construct one compound BRep out of multiple individual BReps.
from_cone
classmethod
¤
from_curves
classmethod
¤
from_curves(curves: list[NurbsCurve]) -> OCCBrep
Construct a BRep from a set of curves.
Parameters:
-
curves(list[NurbsCurve]) –The input curves.
Returns:
-
OCCBrep–The resulting BRep.
from_cylinder
classmethod
¤
from_extrusion
classmethod
¤
from_extrusion(profile: OCCBrepEdge | OCCBrepFace, vector: Vector, cap_ends: bool = False) -> OCCBrep
Construct a BRep by extruding a closed curve along a direction vector.
Parameters:
-
profile(OCCBrepEdge | OCCBrepFace) –The base profile of the extrusion.
-
vector(Vector) –The extrusion vector. The extrusion has the same height as the length vector.
-
cap_ends(bool, default:False) –Flag indicating that the ends of the brep should be capped. Currently this flag is not supported.
Returns:
-
OCCBrep–
from_iges
classmethod
¤
from_loft
classmethod
¤
from_mesh
classmethod
¤
from_plane
classmethod
¤
from_planes
classmethod
¤
from_polygons
classmethod
¤
from_sphere
classmethod
¤
from_step
classmethod
¤
from_step_with_attributes
classmethod
¤
Read a STEP file together with the name and attributes of each top-level shape.
Parameters:
Returns:
from_surface
classmethod
¤
from_surface(surface: Surface | OCCNurbsSurface, domain_u: tuple[float, float] | None = None, domain_v: tuple[float, float] | None = None, precision: float = 1e-06, loop: OCCBrepLoop | None = None, inside: bool = True) -> OCCBrep
Construct a BRep from a COMPAS surface.
Parameters:
-
surface(Surface | OCCNurbsSurface) –The input surface.
-
domain_u(tuple[float, float] | None, default:None) –The domain of the surface in the U direction.
-
domain_v(tuple[float, float] | None, default:None) –The domain of the surface in the V direction.
-
precision(float, default:1e-06) –The precision of the discretisation of the surface.
-
loop(OCCBrepLoop | None, default:None) –The loop to trim the surface with.
-
inside(bool, default:True) –Whether to keep the inside or outside of the loop.
Returns:
-
OCCBrep–
from_sweep
classmethod
¤
from_sweep(profile: OCCBrepEdge | OCCBrepFace, path: OCCBrepLoop) -> OCCBrep
Construct a BRep by sweeping a profile along a path.
References
https://dev.opencascade.org/doc/occt-7.4.0/refman/html/class_b_rep_prim_a_p_imakesweep.html https://dev.opencascade.org/doc/occt-7.4.0/refman/html/class_b_rep_offset_a_p_i_make_pipe.html https://dev.opencascade.org/doc/occt-7.4.0/refman/html/class_b_rep_offset_a_p_i___make_pipe_shell.html
from_torus
classmethod
¤
intersect
¤
make_positive
¤
Make the volume of a closed brep positive if it is not.
Returns:
-
None–
offset
¤
overlap
¤
overlap(other: OCCBrep, linear_deflection: float | None = None, angular_deflection: float | None = None, tolerance: float = 0.0, relative: bool = False) -> tuple[list[OCCBrepFace], list[OCCBrepFace]]
Compute the overlap between this BRep and another.
Parameters:
-
other(OCCBrep) –The other brep.
-
linear_deflection(float | None, default:None) –Maximum linear deflection for shape approximation.
-
angular_deflection(float | None, default:None) –Maximum angular deflection for shape approximation.
-
tolerance(float, default:0.0) –Allowable deviation between shapes.
Other Parameters:
-
relative(bool) –If True, linear deflection used for faces is the maximum linear deflection of their edges.
Returns:
-
tuple[list[OCCBrepFace], list[OCCBrepFace]]–
overlap_intersection
¤
overlap_intersection(other: OCCBrep, linear_deflection: float | None = None, angular_deflection: float | None = None, tolerance: float = 0.0, relative: bool = False) -> OCCBrep | None
Compute the common (shared) region of the faces where this BRep overlaps another.
:meth:overlap reports which faces of the two Breps coincide; this returns the actual
common geometry between them (the boolean intersection of those overlapping faces).
Parameters:
-
other(OCCBrep) –The other brep.
Returns:
-
OCCBrep | None–The common region, or None if the breps do not overlap.
simplify
¤
simplify(merge_edges: bool = True, merge_faces: bool = True, lineardeflection: float | None = None, angulardeflection: float | None = None)
Simplify the shape by merging colinear edges and coplanar faces.
Parameters:
-
merge_edges(bool, default:True) –Merge edges with the same underlying geometry.
-
merge_faces(bool, default:True) –Merge faces with the same underlying geometry.
-
lineardeflection(float | None, default:None) –Default is
compas.tolerance.Tolerance.lineardeflection. -
angulardeflection(float | None, default:None) –Default is
compas.tolerance.Tolerance.angulardeflection.
Returns:
-
None–
slice
¤
split
¤
to_brep
¤
to_curves
¤
Convert the edges of the BRep to curves.
Every edge is converted to the COMPAS geometry matching its underlying curve:
a :class:compas.geometry.Line for a straight edge, a
:class:compas.geometry.Circle for a circular one, and so on, falling back to a
:class:compas.geometry.NurbsCurve for a general B-spline edge. Trimming is
respected -- the curve spans the edge, not the full underlying geometry.
Unlike the :attr:edges and :attr:curves attributes, each edge is reported
once, even where it is shared by two faces.
Returns:
Raises:
-
NotImplementedError–If an edge has a curve type that cannot be converted.
Examples:
to_iges
¤
to_meshes
¤
Convert the faces of the BRep shape to meshes.
Parameters:
-
u(int, default:16) –The number of mesh faces in the U direction of the underlying surface geometry of every face of the Brep.
-
v(int, default:16) –The number of mesh faces in the V direction of the underlying surface geometry of every face of the Brep.
Returns:
to_polygons
¤
to_polylines
¤
Convert the faces of the BRep to closed polylines.
One polyline is produced per loop of every face, in face order, with the outer loop of a face preceding its inner loops (the holes). Each polyline is closed: its last point repeats its first.
The conversion is only lossless if every face is a flat polygon, so it is
refused otherwise. Use :attr:is_polygonal to check up front, or
:meth:to_polygons to reduce the faces regardless of their geometry.
Returns:
Raises:
-
BrepError–If the Brep has no faces, or if any of them is not a flat polygon.
Examples:
to_step
¤
to_step_with_attributes
¤
to_step_with_attributes(filepath: str | Path, name: str | None = None, attributes: dict | None = None) -> None
Write the BRep to a STEP file with a name and custom attributes.
The attributes are stored as user-defined properties (general_property
entities) following the OCCT extended data exchange (XDE) conventions.
Parameters:
-
filepath(str | Path) –Location of the file.
-
name(str | None, default:None) –The name of the shape in the STEP file.
-
attributes(dict | None, default:None) –A mapping of attribute names to
str,int, orfloatvalues.
Returns:
-
None–
to_stl
¤
to_stl(filepath: str | Path, linear_deflection: float = 0.001, angular_deflection: float = 0.5) -> bool
Write the BRep shape to a STL file.
Parameters:
-
filepath(str | Path) –Location of the file.
-
linear_deflection(float, default:0.001) –Allowable deviation between curved geometry and mesh discretisation.
-
angular_deflection(float, default:0.5) –Maximum angle between two adjacent facets.
Returns:
-
None–
to_tesselation
¤
to_tesselation(linear_deflection: float | None = None, angular_deflection: float | None = None) -> tuple[Mesh, list[Polyline]]
Create a tesselation of the shape for visualisation.
Parameters:
-
linear_deflection(float | None, default:None) –Allowable "distance" deviation between curved geometry and mesh discretisation.
-
angular_deflection(float | None, default:None) –Allowable "curvature" deviation between curved geometry and mesh discretisation.
Returns:
to_viewmesh
¤
to_viewmesh(linear_deflection: float | None = None, angular_deflection: float | None = None) -> tuple[Mesh, list[Polyline]]
Convert the BRep to a view mesh.
Parameters:
-
linear_deflection(float | None, default:None) –Allowable "distance" deviation between curved geometry and mesh discretisation.
-
angular_deflection(float | None, default:None) –Allowable "curvature" deviation between curved geometry and mesh discretisation.
Returns:
transform
¤
transform(matrix: Transformation) -> None
transformed
¤
transformed(matrix: Transformation) -> OCCBrep
Return a transformed copy of the Brep.
Parameters:
-
matrix(Transformation) –A transformation matrix.
Returns:
-
OCCBrep–
trimmed
¤
vertex_edges
¤
vertex_edges(vertex: OCCBrepVertex) -> list[OCCBrepEdge]
Identify the edges connected to a given vertex.
Parameters:
-
vertex(OCCBrepVertex) –A vertex of the Brep
Returns:
-
list[OCCBrepEdge]–The edges connected to the given vertex.
vertex_faces
¤
vertex_faces(vertex: OCCBrepVertex) -> list[OCCBrepFace]
Identify the faces connected to a vertex.
Parameters:
-
vertex(OCCBrepVertex) –A vertex of the Brep.
Returns:
-
list[OCCBrepFace]–The faces connected to the given vertex.
vertex_neighbors
¤
vertex_neighbors(vertex: OCCBrepVertex) -> list[OCCBrepVertex]
Identify the neighbouring vertices of a given vertex.
Parameters:
-
vertex(OCCBrepVertex) –A vertex of the Brep.
Returns:
-
list[OCCBrepVertex]–The neighbouring vertices of the given vertex.