Model

class compas_model.models.Model(name=None)

Bases: Datastructure

Class representing a general model of hierarchically organised elements, with interactions.

Attributes:
treeElementTree, read-only

A tree representing the spatial hierarchy of the elements in the model.

graphInteractionGraph, read-only

A graph containing the interactions between the elements of the model on its edges.

bvhElementBVH, read-only

To recompute the BVH, use compute_bvh(). The BVH is used to speed up collision detection: for example, during calculation of element contacts.

kdtreeKDTree, read-only

To recompute the tree, use compute_kdtree(). The KD tree is used for nearest neighbour searches: for example, during calculation of element contacts.

transformationcompas.geometry.Transformation

The transformation from local to world coordinates.

Notes

A model has an element tree to store the hierarchical relationships between elements, and an interaction graph to store the interactions between pairs of elements. Model elements are contained in the tree hierarchy in tree nodes, and in the interaction graph in graph nodes.

Every model element can appear only once in the tree, and only once in the graph. This means that every element can have only one hierarchical parent. At the same time, independently of the hierarchy, every element can have many interactions with other elements.

Methods

add_element

Add an element to the model.

add_elements

Add multiple elements to the model.

add_interaction

Add an interaction between two elements of the model.

add_material

Add a material to the model.

add_modifier

Add a modifier between two elements.

assign_material

Assign a material to an element or a list of elements.

collisions

Yield all collision pairs in the model.

compute_bvh

Compute the Bounding Volume Hierarchy (BVH) of the elements for fast collision checks.

compute_collisions

compute_contacts

Compute the contacts between the block elements of this model.

compute_kdtree

Compute the KD tree of the elements for fast nearest neighbour queries.

contacts

element_nnbrs

Find the nearest neighbours to a root element.

elements

Yield all the elements contained in the model.

has_element

Returns True if the model contains the given element.

has_interaction

Returns True if two elements have an interaction set between them.

has_material

Verify that the model contains a specific material.

materials

Yield all the materials contained in the model.

point_nnbrs

Find the nearest neighbours to a point.

remove_element

Remove an element from the model.

remove_interaction

Remove the interaction between two elements.

transform

Transform the model and all that it contains.

Inherited Methods

ToString

Converts the instance to a string.

compute_aabb

Compute the axis-aligned bounding box of the datastructure.

compute_obb

Compute the oriented bounding box of the datastructure.

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.

rotate

Rotate the datastructure.

rotated

Returns a rotated copy of this geometry.

scale

Scale the datastructure.

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.

transform_numpy

Transforms the data structure.

transformed

Returns a transformed copy of this data structure.

transformed_numpy

Returns a transformed copy of this data structure.

translate

Translate the datastructure.

translated

Returns a translated copy of this geometry.

validate_data

Validate the data against the object's data schema.