Skip to content
Merged
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
10 changes: 9 additions & 1 deletion src/compas_tna/envelope/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, rho: Optional[float] = 20.0, is_parametric: bool = False, **k
super().__init__(**kwargs)

self.rho = rho
self.is_parametric = is_parametric
self._is_parametric = is_parametric

# Computed properties (cached)
self._area = 0.0
Expand Down Expand Up @@ -53,6 +53,14 @@ def selfweight(self):
self._total_selfweight = self.compute_selfweight()
return self._total_selfweight

@property
def is_parametric(self) -> bool:
return self._is_parametric

@is_parametric.setter
def is_parametric(self, value: bool) -> None:
self._is_parametric = value

# =============================================================================
# Geometry operations
# =============================================================================
Expand Down
40 changes: 33 additions & 7 deletions src/compas_tna/envelope/meshenvelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from compas_tna.envelope import Envelope


# TODO: What if intrados and extrados are surfaces?
def interpolate_middle_mesh(intrados: Mesh, extrados: Mesh) -> Mesh:
"""Interpolate a middle mesh between intrados and extrados meshes.

Expand Down Expand Up @@ -60,7 +59,6 @@ def interpolate_middle_mesh(intrados: Mesh, extrados: Mesh) -> Mesh:
return middle


# TODO: What if middle is a surface and not a mesh?
def offset_from_middle(middle: Mesh, fixed_xy: bool = True) -> tuple[Mesh, Mesh]:
"""
Offset a middle surface mesh to obtain extrados and intrados meshes using thickness attributes.
Expand Down Expand Up @@ -120,8 +118,7 @@ def offset_from_middle(middle: Mesh, fixed_xy: bool = True) -> tuple[Mesh, Mesh]
return intrados, extrados


# TODO: What if the target is a surface and not a mesh?
def project_mesh_to_target_vertical(mesh: Mesh, target: Mesh) -> None:
def project_mesh_to_target_vertica_nearest(mesh: Mesh, target: Mesh) -> None:
"""Project a mesh vertically (in Z direction) onto a target mesh.

Parameters
Expand Down Expand Up @@ -161,6 +158,35 @@ def project_mesh_to_target_vertical(mesh: Mesh, target: Mesh) -> None:
mesh.vertex_attributes(vertex, "xyz", new_point)


# TODO: What if the target is a surface and not a mesh?
def project_mesh_to_target_vertical(mesh: Mesh, target: Mesh) -> None:
"""Project a mesh vertically (in Z direction) onto a target mesh.

Parameters
----------
mesh : Mesh
The mesh to be projected.
target : Mesh
The target mesh to project onto.

Returns
-------
None
The mesh is modified in place.
"""
# Get point clouds for interpolation
target_points = asarray(target.vertices_attributes("xyz"))

# Get XY coordinates of middle mesh
mesh_xy = asarray(mesh.vertices_attributes("xy"))

# Interpolate Z coordinates from both surfaces
z_target = griddata(target_points[:, :2], target_points[:, 2], mesh_xy, method="linear").tolist()

for key, i in enumerate(mesh.vertices()):
mesh.vertex_attribute(key, "z", z_target[i])


def pattern_inverse_height_thickness(pattern: Mesh, tmin: Optional[float] = None, tmax: Optional[float] = None) -> None:
"""Set variable thickness based on inverse height.

Expand Down Expand Up @@ -214,6 +240,9 @@ def __init__(self, intrados: Mesh = None, extrados: Mesh = None, middle: Mesh =
# Thickness property
self._thickness = thickness

def __str__(self):
return f"MeshEnvelope(name={self.name})"

@property
def __data__(self):
data = super().__data__
Expand All @@ -224,9 +253,6 @@ def __data__(self):
data["thickness"] = self._thickness
return data

def __str__(self):
return f"Envelope(name={self.name})"

# =============================================================================
# Factory methods
# =============================================================================
Expand Down
Loading