Model
- class compas_model.models.Model(name=None)
Bases:
Datastructure
Class representing a general model of hierarchically organised elements, with interactions.
- Attributes:
- tree
ElementTree
, read-only A tree representing the spatial hierarchy of the elements in the model.
- graph
InteractionGraph
, read-only A graph containing the interactions between the elements of the model on its edges.
- bvh
ElementBVH
, 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.- kdtree
KDTree
, 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.- transformation
compas.geometry.Transformation
The transformation from local to world coordinates.
- tree
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 an element to the model.
Add multiple elements to the model.
Add an interaction between two elements of the model.
Add a material to the model.
Add a modifier between two elements.
Assign a material to an element or a list of elements.
Yield all collision pairs in the model.
Compute the Bounding Volume Hierarchy (BVH) of the elements for fast collision checks.
Compute the contacts between the block elements of this model.
Compute the KD tree of the elements for fast nearest neighbour queries.
Find the nearest neighbours to a root element.
Yield all the elements contained in the model.
Returns True if the model contains the given element.
Returns True if two elements have an interaction set between them.
Verify that the model contains a specific material.
Yield all the materials contained in the model.
Find the nearest neighbours to a point.
Remove an element from the model.
Remove the interaction between two elements.
Transform the model and all that it contains.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the datastructure.
Compute the oriented bounding box of the datastructure.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Rotate the datastructure.
Returns a rotated copy of this geometry.
Scale the datastructure.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Transforms the data structure.
Returns a transformed copy of this data structure.
Returns a transformed copy of this data structure.
Translate the datastructure.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.