Skip to content

Commit bd16f01

Browse files
committed
add pattern from triangulation
1 parent 1d0dfc4 commit bd16f01

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added "Pattern from Triangulation".
13+
* Added `compas_triangle` to requirements.
14+
1215
### Changed
1316

1417
### Removed

commands/RV_pattern.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#! python3
22
# venv: brg-csd
3-
# r: compas_rv>=0.5.0
3+
# r: compas_rv>=0.6.0
44

55
import rhinoscriptsyntax as rs # type: ignore
6+
from compas_triangle.delaunay import conforming_delaunay_triangulation
7+
from compas_triangle.rhino import discretise_boundary
8+
from compas_triangle.rhino import discretise_constraints
69

710
import compas_rhino
811
import compas_rhino.conversions
912
import compas_rhino.objects
13+
from compas.geometry import NurbsCurve
14+
from compas.geometry import Point
1015
from compas_rv.datastructures import Pattern
1116
from compas_rv.session import RVSession
1217

@@ -102,6 +107,53 @@ def RunCommand():
102107
pattern = Pattern.from_meshgrid(dx=DX, nx=NX, dy=DY, ny=NY)
103108

104109
elif option == "Triangulation":
110+
boundary_guids = compas_rhino.objects.select_curves("Select outer boundary.")
111+
if not boundary_guids:
112+
return
113+
114+
rs.UnselectAllObjects()
115+
hole_guids = compas_rhino.objects.select_curves("Select inner boundaries.")
116+
117+
rs.UnselectAllObjects()
118+
segments_guids = compas_rhino.objects.select_curves("Select constraint curves.")
119+
120+
rs.UnselectAllObjects()
121+
122+
target_length = rs.GetReal("Specifiy target edge length.", 1.0)
123+
if not target_length:
124+
return
125+
126+
boundary = discretise_boundary(boundary_guids, target_length)
127+
holes = None
128+
segments = None
129+
curves = None
130+
131+
if hole_guids:
132+
holes = discretise_constraints(hole_guids, target_length)
133+
134+
if segments_guids:
135+
segments = discretise_constraints(segments_guids, target_length)
136+
curves: list[NurbsCurve] = [NurbsCurve.from_interpolation(segment) for segment in segments]
137+
138+
points, triangles = conforming_delaunay_triangulation(
139+
boundary,
140+
polylines=segments,
141+
polygons=holes,
142+
area=target_length**2 / 2,
143+
)
144+
pattern = Pattern.from_vertices_and_faces(points, triangles)
145+
146+
fixed = [vertex for boundary in pattern.vertices_on_boundaries() for vertex in boundary]
147+
if curves:
148+
for index, point in enumerate(points):
149+
for curve in curves:
150+
closest: Point = curve.closest_point(point)
151+
if closest.distance_to_point(point) < 0.1 * target_length:
152+
fixed.append(index)
153+
154+
pattern.smooth_area(fixed=fixed)
155+
156+
elif option == "Skeleton":
105157
raise NotImplementedError
106158

107159
else:

compas-RV.rhproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
"id": "a6dc4669-0e8e-40ea-8d71-b9b0f4764ec1",
99
"identity": {
1010
"name": "COMPAS-RhinoVAULT",
11-
"version": "0.5.34-beta",
11+
"version": "0.6.4",
1212
"publisher": {
13-
"email": "[email protected]",
14-
"name": "Juney Lee",
15-
"company": "Carnegie Mellon University"
13+
"email": "[email protected]",
14+
"name": "Tom Van Mele",
15+
"company": "COMPAS Association",
16+
"url": "https://compas.dev/"
1617
},
1718
"description": "Rhino plugin for form finding of compression-only structures using Thrust Network Analysis.",
1819
"copyright": "ETH Zurich - Block Research Group",
@@ -610,7 +611,6 @@
610611
}
611612
}
612613
],
613-
"libraries": [],
614614
"resources": [
615615
{
616616
"id": "0475d743-2539-4543-b579-a5d20301277c",

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
compas >=2.5
1+
compas >=2.9
2+
compas_dem
23
compas_rui >=0.4.2
34
compas_session >=0.4.5
45
compas_skeleton
56
compas_tna >=0.5
7+
compas_triangle>=1.2.1

0 commit comments

Comments
 (0)