Skip to content

compas_tf.brep ¤

Classes¤

BrepMixin ¤

Gives a class get_brep(): its meshes as a solid, coplanar-merged Brep.

Mixed into every compas_tf element, feature and model. A subclass only has to say WHICH meshes it owns, by overriding :meth:brep_meshes; the default picks up a meshes attribute, which is what the cut features carry.

Methods:¤

brep_meshes ¤
brep_meshes(variant: str | None = None) -> list

The meshes :meth:get_brep converts.

Parameters:

Name Type Description Default
variant str

Which geometry to convert, for classes that own more than one (see :meth:compas_tf.element.TFElement.brep_meshes). Ignored here.

None

Returns:

Type Description
list[:class:`compas.datastructures.Mesh`]

Empty when the class carries no geometry (a marker feature, say), in which case :meth:get_brep returns None.

get_brep ¤
get_brep(variant: str | None = None, merge_coplanar: bool = True, solid: bool = True, lineardeflection: float = LINEAR_DEFLECTION, angulardeflection: float = ANGULAR_DEFLECTION)

This object's geometry as a solid Brep, with coplanar faces merged.

Parameters:

Name Type Description Default
variant str

Which baked geometry variant to convert, for elements carrying more than one - e.g. "ColumnAddFeature" for a column's uncut stock. Default is the element's finished, placed geometry.

None
merge_coplanar bool

Merge coplanar faces into single (hole-carrying) faces.

True
solid bool

Sew the faces into a closed solid.

True
lineardeflection float

Tolerances for the coplanar-face merge.

LINEAR_DEFLECTION
angulardeflection float

Tolerances for the coplanar-face merge.

LINEAR_DEFLECTION

Returns:

Type Description
class:`compas_occt.brep.OCCBrep` or None

A single solid, or a compound when the object owns several meshes. None when it owns none.

Functions:¤

mesh_to_brep ¤

mesh_to_brep(mesh, solid: bool = True, merge_coplanar: bool = True, lineardeflection: float = LINEAR_DEFLECTION, angulardeflection: float = ANGULAR_DEFLECTION, name: str | None = None)

Convert one COMPAS mesh into a solid OCC Brep with its coplanar faces merged.

The merge is why the conversion is worth doing: a boolean leaves triangle soup, and merging collapses it back into the flat faces the part was actually modelled with. A Mesh face cannot carry a hole either, so a drilled face has to be fanned into many faces around the hole - a Brep face carries its hole loops properly and comes back as ONE face.

The merge is guarded: OCC's face unification also fuses nearly coplanar faces, which flattens lofted (twisted-quad) geometry. So the angular deflection is tight by default, and if unification changes the solid's volume the exact, unsimplified Brep is kept instead.

Parameters:

Name Type Description Default
mesh :class:`compas.datastructures.Mesh`

The mesh to convert. Should be closed for solid=True.

required
solid bool

Sew the faces into a closed solid.

True
merge_coplanar bool

Merge coplanar faces (and the edges between them) into single faces.

True
lineardeflection float

Tolerances handed to OCCBrep.simplify. See the module docstring for why the angular default is so tight.

LINEAR_DEFLECTION
angulardeflection float

Tolerances handed to OCCBrep.simplify. See the module docstring for why the angular default is so tight.

LINEAR_DEFLECTION
name str

Name given to the resulting Brep.

None

Returns:

Type Description
class:`compas_occt.brep.OCCBrep`

meshes_to_brep ¤

meshes_to_brep(meshes: list, name: str | None = None, **kwargs)

Convert a list of meshes into ONE Brep - a compound when there are several.

Parameters:

Name Type Description Default
meshes list[:class:`compas.datastructures.Mesh`]

The meshes to convert. Empty gives None.

required
name str

Name given to the resulting Brep.

None
**kwargs

Forwarded to :func:mesh_to_brep.

{}

Returns:

Type Description
class:`compas_occt.brep.OCCBrep` or None