Skip to content

Commit 0d4c66a

Browse files
committed
update examples
1 parent ed7660f commit 0d4c66a

File tree

7 files changed

+28
-87
lines changed

7 files changed

+28
-87
lines changed

examples/delaunay1.png

-26.9 KB
Binary file not shown.

examples/delaunay1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from compas.datastructures import Mesh
2-
from compas_plotters import Plotter
2+
from compas_viewer import Viewer
3+
34
from compas_triangle.delaunay import delaunay_triangulation
45

56
points = [
@@ -12,14 +13,13 @@
1213
[7.710581229980631, 7.9254234389408875, 0.0],
1314
[7.847933566240888, 6.414547740078039, 0.0],
1415
[3.9104999267801377, 4.9036720412151915, 0.0],
15-
[5.2909301507195865, 6.342692886748852, 0.0]
16+
[5.2909301507195865, 6.342692886748852, 0.0],
1617
]
1718

1819
vertices, faces = delaunay_triangulation(points)
1920

2021
mesh = Mesh.from_vertices_and_faces(vertices, faces)
2122

22-
plotter = Plotter(figsize=(8, 8))
23-
plotter.add(mesh, sizepolicy='absolute', vertexsize=5.0)
24-
plotter.zoom_extents()
25-
plotter.show()
23+
viewer = Viewer()
24+
viewer.scene.add(mesh, show_points=True)
25+
viewer.show()

examples/delaunay2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from compas.datastructures import Mesh
2-
from compas_plotters import Plotter
2+
from compas_viewer import Viewer
3+
34
from compas_triangle.delaunay import constrained_delaunay_triangulation
45

56
points = [
@@ -12,14 +13,13 @@
1213
[7.710581229980631, 7.9254234389408875, 0.0],
1314
[7.847933566240888, 6.414547740078039, 0.0],
1415
[3.9104999267801377, 4.9036720412151915, 0.0],
15-
[5.2909301507195865, 6.342692886748852, 0.0]
16+
[5.2909301507195865, 6.342692886748852, 0.0],
1617
]
1718

1819
vertices, faces = constrained_delaunay_triangulation(points)
1920

2021
mesh = Mesh.from_vertices_and_faces(vertices, faces)
2122

22-
plotter = Plotter(figsize=(8, 8))
23-
plotter.add(mesh, sizepolicy='absolute', vertexsize=5.0)
24-
plotter.zoom_extents()
25-
plotter.show()
23+
viewer = Viewer()
24+
viewer.scene.add(mesh, show_points=True)
25+
viewer.show()

examples/delaunay3.png

-318 KB
Binary file not shown.

examples/delaunay3.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from compas.datastructures import Mesh
2-
from compas.utilities import geometric_key
3-
from compas_plotters import Plotter
2+
from compas.tolerance import TOL
3+
from compas_viewer import Viewer
4+
45
from compas_triangle.delaunay import conforming_delaunay_triangulation
56

67
points = [
@@ -13,22 +14,21 @@
1314
[7.710581229980631, 7.9254234389408875, 0.0],
1415
[7.847933566240888, 6.414547740078039, 0.0],
1516
[3.9104999267801377, 4.9036720412151915, 0.0],
16-
[5.2909301507195865, 6.342692886748852, 0.0]
17+
[5.2909301507195865, 6.342692886748852, 0.0],
1718
]
1819

1920
vertices, faces = conforming_delaunay_triangulation(points, angle=30, area=0.5)
2021

2122
mesh = Mesh.from_vertices_and_faces(vertices, faces)
2223

23-
gkey_key = mesh.gkey_key()
24+
gkey_key = mesh.gkey_vertex()
2425
key_index = {}
2526

2627
for index, point in enumerate(points):
27-
gkey = geometric_key(point)
28+
gkey = TOL.geometric_key(point)
2829
if gkey in gkey_key:
2930
key_index[gkey_key[gkey]] = str(index)
3031

31-
plotter = Plotter(figsize=(8, 8))
32-
plotter.add(mesh, sizepolicy='absolute', vertexsize=2.0)
33-
plotter.zoom_extents()
34-
plotter.show()
32+
viewer = Viewer()
33+
viewer.scene.add(mesh, show_points=True)
34+
viewer.show()

examples/delaunay4_rhino.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

examples/delaunay5.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from compas_plotters import Plotter
2-
from compas.geometry import Polygon, Translation
31
from compas.datastructures import Mesh
2+
from compas.geometry import Polygon
3+
from compas.geometry import Translation
4+
from compas_viewer import Viewer
5+
46
from compas_triangle.delaunay import conforming_delaunay_triangulation
57

68
# ==============================================================================
@@ -31,7 +33,6 @@
3133
# Viz
3234
# ==============================================================================
3335

34-
plotter = Plotter(figsize=(8, 8))
35-
plotter.add(mesh, sizepolicy='absolute', vertexsize=5)
36-
plotter.zoom_extents()
37-
plotter.show()
36+
viewer = Viewer()
37+
viewer.scene.add(mesh, show_points=True)
38+
viewer.show()

0 commit comments

Comments
 (0)