BRep

class compas_occ.brep.BRep[source]

Bases: compas.data.data.Data

Class for Boundary Representation of geometric entities.

Attributes
  • vertices (list[BRepVertex], read-only) – The vertices of the BRep.

  • edges (list[BRepEdge], read-only) – The edges of the BRep.

  • loops (list[BRepLoop], read-only) – The loops of the BRep.

  • faces (list[BRepFace], read-only) – The faces of the BRep.

  • frame (Frame, read-only) – The local coordinate system of the BRep.

  • area (float, read-only) – The surface area of the BRep.

  • volume (float, read-only) – The volume of the regions contained by the BRep.

Other Attributes
  • occ_shape (TopoDS_Shape) – The underlying OCC shape of the BRep.

  • type ({TopAbs_COMPOUND, TopAbs_COMPSOLID, TopAbs_SOLID, TopAbs_SHELL, TopAbs_FACE, TopAbs_WIRE, TopAbs_EDGE, TopAbs_VERTEX, TopAbs_SHAPE}, read-only) – The type of BRep shape.

  • orientation ({TopAbs_FORWARD, TopAbs_REVERSED, TopAbs_INTERNAL, TopAbs_EXTERNAL}, read-only) – Orientation of the shape.

Examples

Constructors

>>> brep = BRep.from_corners([0, 0, 0], [1, 0, 0], [1, 1, 1], [1, 1, 0])
>>> from compas.geometry import Box
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> vertices, faces = box.to_vertices_and_faces()
>>> polygons = [[vertices[index] for index in face] for face in faces]
>>> brep = BRep.from_polygons(polygons)
>>> from compas.geometry import Box
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> brep = BRep.from_box(box)
>>> from compas.geometry import Box, Sphere
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> sphere = Sphere([1, 1, 1], 0.5)
>>> A = BRep.from_box(box)
>>> B = BRep.from_sphere(sphere)
>>> brep = BRep.from_boolean_union(A, B)

Booleans

>>> from compas.geometry import Box, Sphere
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> sphere = Sphere([1, 1, 1], 0.5)
>>> A = BRep.from_box(box)
>>> B = BRep.from_sphere(sphere)
>>> C = A + B
>>> D = A - B
>>> E = A & B

Methods

check

Check the shape.

contours

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

cull_unused_edges

Remove all unused edges.

cull_unused_faces

Remove all unused faces.

cull_unused_loops

Remove all unused loops.

cull_unused_vertices

Remove all unused vertices.

fix

Fix the shell.

from_boolean_difference

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

from_boolean_intersection

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

from_boolean_union

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

from_box

Construct a BRep from a COMPAS box.

from_cone

Construct a BRep from a COMPAS cone.

from_curves

Construct a BRep from a set of curves.

from_cylinder

Construct a BRep from a COMPAS cylinder.

from_extrusion

Construct a BRep by extruding a closed curve along a direction vector.

from_faces

Make a BRep from a list of BRep faces forming an open or closed shell.

from_mesh

Construct a BRep from a COMPAS mesh.

from_polygons

Construct a BRep from a set of polygons.

from_shape

Construct a BRep from an OCC shape.

from_sphere

Construct a BRep from a COMPAS sphere.

from_step

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

from_sweep

Construct a BRep by sweeping a profile along a path.

from_torus

Construct a BRep from a COMPAS torus.

make_solid

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

overlap

Compute the overlap between this BRep and another.

sew

Sew together the individual parts of the shape.

slice

Slice through the BRep with a plane.

split

Slice through the BRep with a plane.

to_json

Export the BRep to a JSON file.

to_meshes

Convert the faces of the BRep shape to meshes.

to_polygons

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

to_step

Write the BRep shape to a STEP file.

to_tesselation

Create a tesselation of the shape for visualisation.

to_viewmesh

Convert the BRep to a view mesh.

transform

Transform this BRep.

transformed

Return a transformed copy of the BRep.

vertex_edges

Identify the edges connected to a given vertex.

vertex_faces

Identify the faces connected to a vertex.

vertex_neighbors

Identify the neighbouring vertices of a given vertex.

Inherited Methods

ToString

Converts the instance to a string.

copy

Make an independent copy of the data object.

from_data

Construct an object of this type from the provided data.

from_json

Construct an object from serialized data contained in a JSON file.

from_jsonstring

Construct an object from serialized data contained in a JSON string.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_data

Convert an object to its native data representation.

to_jsonstring

Serialize the data representation of an object to a JSON string.

validate_data

Validate the object's data against its data schema.

validate_json

Validate the object's data against its json schema.