Skip to content

OCCBrep ¤

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.

Functions¤

__from_data__ classmethod ¤

__from_data__(data: dict) -> OCCBrep

Construct an OCCBrep from its data representation.

Parameters:

  • data (dict) –

    The data dictionary.

Returns:

boolean_difference ¤

boolean_difference(*others: OCCBrep, tol=None) -> OCCBrep

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 ¤

boolean_intersection(*others: OCCBrep, tol=None) -> OCCBrep

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 ¤

boolean_union(*others: OCCBrep, tol=None) -> OCCBrep

Return the boolean union of the current shape and a collection of other shapes.

Parameters:

  • others (OCCBrep, default: () ) –

    A collection of other BRep shapes to unite with the current shape.

Returns:

  • OCCBrep

    The union between the current shape and the others.

Raises:

  • BrepBooleanError

check ¤

check()

Check the shape.

Returns:

  • None

contours ¤

contours(planes: list[Plane]) -> list[list[Polyline]]

Generate contour lines by slicing the BRep shape with a series of planes.

Parameters:

  • planes (list[Plane]) –

    The slicing planes.

Returns:

copy ¤

copy() -> OCCBrep

Deep-copy this BRep using the native OCC copying mechanism.

Returns:

cull_unused_edges ¤

cull_unused_edges() -> None

Remove all unused edges.

Returns:

  • None

cull_unused_faces ¤

cull_unused_faces() -> None

Remove all unused faces.

Returns:

  • None

cull_unused_loops ¤

cull_unused_loops() -> None

Remove all unused loops.

Returns:

  • None

cull_unused_vertices ¤

cull_unused_vertices() -> None

Remove all unused vertices.

Returns:

  • None

edge_faces ¤

edge_faces(edge: OCCBrepEdge) -> list[OCCBrepFace]

Identify the faces connected to an edge.

Parameters:

Returns:

edge_loops ¤

edge_loops(edge: OCCBrepEdge) -> list[OCCBrepLoop]

Identify the parent loops of an edge.

Parameters:

Returns:

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:

fix ¤

fix()

Fix the shell.

Returns:

  • None

from_boolean_difference classmethod ¤

from_boolean_difference(
    A: OCCBrep | list[OCCBrep], B: OCCBrep | list[OCCBrep], tol=None
) -> OCCBrep

Construct a BRep from the boolean difference of two other BReps.

Parameters:

Returns:

from_boolean_intersection classmethod ¤

from_boolean_intersection(
    A: OCCBrep | list[OCCBrep], B: OCCBrep | list[OCCBrep], tol=None
) -> OCCBrep

Construct a BRep from the boolean intersection of two other BReps.

Parameters:

Returns:

Raises:

  • BrepBooleanError

from_boolean_union classmethod ¤

from_boolean_union(
    A: OCCBrep | list[OCCBrep], B: OCCBrep | list[OCCBrep], tol=None
) -> OCCBrep

Construct a BRep from the boolean union of two other BReps.

Parameters:

Returns:

Raises:

  • BrepBooleanError

from_box classmethod ¤

from_box(box: Box) -> OCCBrep

Construct a BRep from a COMPAS box.

Parameters:

  • box (Box) –

Returns:

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:

from_breps classmethod ¤

from_breps(breps: list[OCCBrep]) -> OCCBrep

Construct one compound BRep out of multiple individual BReps.

from_cone classmethod ¤

from_cone(cone: Cone) -> OCCBrep

Construct a BRep from a COMPAS cone.

Parameters:

  • cone (Cone) –

    A COMPAS cone.

Returns:

from_curves classmethod ¤

from_curves(curves: list[NurbsCurve]) -> OCCBrep

Construct a BRep from a set of curves.

Parameters:

Returns:

from_cylinder classmethod ¤

from_cylinder(cylinder: Cylinder) -> OCCBrep

Construct a BRep from a COMPAS cylinder.

Parameters:

  • cylinder (Cylinder) –

    A COMPAS cylinder.

Returns:

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:

from_iges classmethod ¤

from_iges(filename: str | Path, solid: bool = True) -> OCCBrep

Conctruct a BRep from the data contained in a IGES file.

Parameters:

  • filename (str | Path) –

    The file.

  • solid (bool, default: True ) –

    If True, convert shells to solids when possible.

Returns:

from_loft classmethod ¤

from_loft(
    curves: list[OCCCurve], start: Point | None = None, end: Point | None = None
) -> OCCBrep

Construct a Brep by lofing through a sequence of curves.

Parameters:

  • curves (list[OCCCurve]) –

    The loft curves.

  • start (Point | None, default: None ) –

    The start point of the loft.

  • end (Point | None, default: None ) –

    The end point of the loft.

Returns:

from_mesh classmethod ¤

from_mesh(mesh: Mesh, solid: bool = True) -> OCCBrep

Construct a BRep from a COMPAS mesh.

Parameters:

  • mesh (Mesh) –

    The input mesh.

  • solid (bool, default: True ) –

    Flag indicating that if the resulting shape should be converted to a solid, if possible.

Returns:

from_native classmethod ¤

from_native(shape: TopoDS_Shape) -> OCCBrep

Construct a BRep from an OCC shape.

Parameters:

  • shape (TopoDS_Shape) –

    The OCC shape.

Returns:

from_plane classmethod ¤

from_plane(
    plane: Plane,
    domain_u: tuple[float, float] = (-1.0, +1.0),
    domain_v: tuple[float, float] = (-1.0, +1.0),
) -> OCCBrep

Make a BRep from a plane.

Parameters:

  • plane (Plane) –

    A COMPAS plane.

  • domain_u (tuple[float, float], default: (-1.0, +1.0) ) –

    The domain of the plane in the U direction.

  • domain_v (tuple[float, float], default: (-1.0, +1.0) ) –

    The domain of the plane in the V direction.

Returns:

from_planes classmethod ¤

from_planes(planes: list[Plane], solid: bool = True) -> OCCBrep

Make a BRep from a list of planes.

Parameters:

  • planes (list[Plane]) –

    The input planes.

  • solid (bool, default: True ) –

    Flag indicating that if the resulting shape should be converted to a solid, if possible.

Returns:

from_polygons classmethod ¤

from_polygons(polygons: list[Polygon], solid: bool = True) -> OCCBrep

Construct a BRep from a set of polygons.

Parameters:

  • polygons (list[Polygon]) –

    The input polygons.

  • solid (bool, default: True ) –

    Flag indicating that if the resulting shape should be converted to a solid, if possible.

Returns:

from_shape classmethod ¤

from_shape(shape: TopoDS_Shape) -> OCCBrep

Construct a BRep from an OCC shape.

Parameters:

  • shape (TopoDS_Shape) –

    The OCC shape.

Returns:

from_sphere classmethod ¤

from_sphere(sphere: Sphere) -> OCCBrep

Construct a BRep from a COMPAS sphere.

Parameters:

  • sphere (Sphere) –

    A COMPAS sphere.

Returns:

from_step classmethod ¤

from_step(filename: str | Path, heal: bool = False, solid: bool = False) -> OCCBrep

Conctruct a BRep from the data contained in a STEP file.

Parameters:

  • filename (str | Path) –

    The file.

  • solid (bool, default: False ) –

    If True, convert shells to solids when possible.

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:

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 ¤

from_torus(torus: Torus) -> OCCBrep

Construct a BRep from a COMPAS torus.

Parameters:

  • torus (Torus) –

    A COMPAS torus.

Returns:

heal ¤

heal()

Heal the shape.

Returns:

  • None

intersect ¤

intersect(other: OCCBrep) -> OCCBrep | None

Intersect this Brep with another.

Parameters:

  • other (OCCBrep) –

    The other brep.

Returns:

  • OCCBrep

    If it exists, the intersection is a curve that can be accessed via the edges of the returned brep.

make_positive ¤

make_positive()

Make the volume of a closed brep positive if it is not.

Returns:

  • None

make_solid ¤

make_solid()

Convert the current shape to a solid if it is a shell.

Returns:

  • None

offset ¤

offset(distance: float) -> OCCBrep

Construct a thickened copy of the brep.

Parameters:

  • distance (float) –

    The thickness in the form of an offset distance.

Returns:

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:

sew ¤

sew()

Sew together the individual parts of the shape.

Returns:

  • None

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 ¤

slice(plane: Plane) -> OCCBrep | None

Slice a BRep with a plane.

Parameters:

  • plane (Plane) –

    The slicing plane.

Returns:

  • OCCBrep | None

    The resulting Brep slice or None if the plane does not intersect the Brep.

split ¤

split(other: OCCBrep) -> list[OCCBrep]

Split a BRep using another BRep as splitter.

Parameters:

  • other (OCCBrep) –

    Another brep.

Returns:

to_brep ¤

to_brep(filepath: str | Path) -> None

Write the BRep shape to a BREP file.

Parameters:

  • filepath (str | Path) –

    Location of the file.

Returns:

  • None

to_iges ¤

to_iges(filepath: str | Path) -> bool

Write the BRep shape to a IGES file.

Parameters:

  • filepath (str | Path) –

    Location of the file.

Returns:

  • None

to_meshes ¤

to_meshes(u: int = 16, v: int = 16) -> list[Mesh]

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_polygons() -> list[Polygon]

Convert the faces of the BRep to simple polygons without underlying geometry.

Returns:

to_step ¤

to_step(
    filepath: str | Path,
    unit: str = "MM",
    author: str | None = None,
    name: str | None = None,
    description: str | None = None,
    organization: str | None = None,
) -> None

Write the BRep shape to a STEP file.

Parameters:

  • filepath (str | Path) –

    Location of the file.

  • unit (str, default: 'MM' ) –

    Base units for the geometry in the file.

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

Transform this Brep.

Parameters:

Returns:

  • None

transformed ¤

transformed(matrix: Transformation) -> OCCBrep

Return a transformed copy of the Brep.

Parameters:

Returns:

trim ¤

trim(plane: Plane) -> None

Trim a Brep with a plane.

Parameters:

  • plane (Plane) –

    The slicing plane.

Returns:

  • None

trimmed ¤

trimmed(plane: Plane) -> OCCBrep

Construct a copy of a Brep trimmed with a plane.

Parameters:

  • plane (Plane) –

    The slicing plane.

Returns:

vertex_edges ¤

vertex_edges(vertex: OCCBrepVertex) -> list[OCCBrepEdge]

Identify the edges connected to a given vertex.

Parameters:

Returns:

vertex_faces ¤

vertex_faces(vertex: OCCBrepVertex) -> list[OCCBrepFace]

Identify the faces connected to a vertex.

Parameters:

Returns:

vertex_neighbors ¤

vertex_neighbors(vertex: OCCBrepVertex) -> list[OCCBrepVertex]

Identify the neighbouring vertices of a given vertex.

Parameters:

Returns: