Skip to content
Closed

NA #46

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `Element.compute_elementgeometry()`.
* Added `Element.compute_modelgeometry()` to replace `Element.compute_geometry()`.
* Added `Element.compute_modeltransformation()` to replace `Element.compute_worldtransformation()`.
* Added `Element.is_dirty`.

### Changed

Expand Down
18 changes: 18 additions & 0 deletions src/compas_model/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class Element(Data):
Scaling factor to inflate the AABB with.
inflate_obb : float
Scaling factor to inflate the OBB with.
is_dirty : bool
Flag to indicate that the element needs to be updated.

"""

Expand Down Expand Up @@ -141,6 +143,8 @@ def __init__(
self.inflate_aabb = 0.0
self.inflate_obb = 0.0

self._is_dirty = True

# this is not entirely correct
def __repr__(self) -> str:
return f"Element(frame={self.frame!r}, name={self.name})"
Expand Down Expand Up @@ -178,6 +182,19 @@ def parent(self) -> "ElementNode":
def features(self) -> list[Feature]:
return self._features

@property
def is_dirty(self):
return self._is_dirty

@is_dirty.setter
def is_dirty(self, value):
self._is_dirty = value

if value:
elements = list(self.model.elements())
for neighbor in self.model.graph.neighbors_out(self.graphnode):
elements[neighbor].is_dirty = value

# ==========================================================================
# Computed attributes
# ==========================================================================
Expand Down Expand Up @@ -291,6 +308,7 @@ def compute_modelgeometry(self) -> Union[Brep, Mesh]:
:class:`compas.datastructures.Mesh` | :class:`compas.geometry.Brep`

"""
self.is_dirty = False
raise NotImplementedError

def compute_aabb(self) -> Box:
Expand Down
Loading