Shape

class compas.geometry.Shape[source]

Bases: Geometry

Base class for geometric shapes.

Shapes are parametrically defined with repsect to a local coordinate system. The local coordinate system of a shape is defined by a frame. The default frame is the word coordinate system, i.e. the origin and the axes of the world XY plane.

Shapes are finite, closed objects, with a boundary that separates the interior from the exterior. They have a well-defined surface area and volume.

An explicit representation of a shape is obtained by discretising its boundary into a set of vertices and faces with a chosen resolution (to_vertices_and_faces()). The vertices and faces can be used to construct a compas.geometry.Polyhedron object (to_polyhedron()). A shape can also be converted to a compas.geometry.Brep object (to_brep()).

Breps and polyhedrons support boolean operations.

Parameters:
framecompas.geometry.Frame, optional

The local coordinate system of the shape. Default is None, in which case the world coordinate system is used.

Attributes:
areafloat, read-only

The surface area of the shape.

framecompas.geometry.Frame

The local coordinate system of the shape.

transformationcompas.geometry.Transformation, read-only

The transformation of the shape to global coordinates.

volumefloat, read-only

The volume of the shape.

Methods

compute_edges

Compute the edges of the discrete representation of the shape.

compute_faces

compute_triangles

Compute the triangles of the discrete representation of the shape.

compute_vertices

contains_point

Verify if a point is inside the shape.

contains_points

Verify if a list of points are inside the shape.

rotate

Rotate the shape.

scale

Scale the shape.

to_brep

Convert the shape to a Brep.

to_mesh

Returns a mesh representation of the box.

to_polyhedron

Convert the shape to a polyhedron.

to_vertices_and_faces

Convert the shape to a list of vertices and faces.

transform

Transform the shape.

translate

Translate the shape.

Inherited Methods

ToString

Converts the instance to a string.

compute_aabb

Compute the axis-aligned bounding box of the geometry.

compute_obb

Compute the oriented bounding box of the geometry.

copy

Make an independent copy of the data object.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

rotated

Returns a rotated copy of this geometry.

scaled

Returns a scaled copy of this geometry.

sha256

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

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

transformed

Returns a transformed copy of this geometry.

translated

Returns a translated copy of this geometry.

validate_data

Validate the data against the object's data schema.