Skip to content

Commit e237ca3

Browse files
committed
clean up examples
1 parent ee890d0 commit e237ca3

13 files changed

+24
-35
lines changed

docs/examples/example_boundaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
from pathlib import Path
23

34
from compas.colors import Color
45
from compas.datastructures import Mesh
@@ -9,11 +10,10 @@
910

1011
from compas_libigl.boundaries import trimesh_boundaries
1112

12-
from pathlib import Path
13-
1413
# ==============================================================================
1514
# Input geometry
1615
# ==============================================================================
16+
1717
mesh = Mesh.from_off(Path(__file__).parent.parent.parent / "data" / "beetle.off")
1818

1919
Rx = Rotation.from_axis_and_angle([1, 0, 0], math.radians(90))

docs/examples/example_curvature_gaussian.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# ==============================================================================
1212
# Input geometry
1313
# ==============================================================================
14+
1415
mesh = Mesh.from_obj(compas.get("tubemesh.obj"))
1516
trimesh = mesh.copy()
1617
trimesh.quads_to_triangles()

docs/examples/example_geodistance.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
cmap = ColorMap.from_color(Color.red())
3131

3232
viewer = Viewer(width=1600, height=900)
33-
# viewer.view.camera.position = [1, -6, 2]
34-
# viewer.view.camera.look_at([1, 1, 1])
3533

3634
viewer.scene.add(mesh, show_points=False)
3735

docs/examples/example_geodistance_multiple.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
trimesh = mesh.copy()
1717
trimesh.quads_to_triangles()
1818

19-
2019
# ==============================================================================
2120
# Get boundary vertices as source points
2221
# ==============================================================================

docs/examples/example_intersections.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
# ==============================================================================
6969

7070
viewer = Viewer(width=1600, height=900)
71-
# viewer.view.camera.position = [1, -6, 2]
72-
# viewer.view.camera.look_at([1, 1, 1])
7371

7472
viewer.scene.add(mesh, opacity=0.7, show_points=False)
7573

docs/examples/example_isolines.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import math
2+
from pathlib import Path
23

34
from compas.colors import ColorMap
45
from compas.datastructures import Mesh
56
from compas.geometry import Rotation
67
from compas.geometry import Scale
78
from compas_viewer import Viewer
89

9-
from compas_libigl.isolines import trimesh_isolines, groupsort_isolines
10-
11-
from pathlib import Path
10+
from compas_libigl.isolines import groupsort_isolines
11+
from compas_libigl.isolines import trimesh_isolines
1212

1313
# ==============================================================================
1414
# Input geometry
1515
# ==============================================================================
16+
1617
mesh = Mesh.from_off(Path(__file__).parent.parent.parent / "data" / "beetle.off")
1718

1819
Rx = Rotation.from_axis_and_angle([1, 0, 0], math.radians(90))
@@ -37,15 +38,12 @@
3738

3839
isolines = groupsort_isolines(vertices, edges, indices)
3940

40-
4141
# ==============================================================================
4242
# Visualisation
4343
# ==============================================================================
4444

45-
4645
viewer = Viewer()
4746

48-
4947
minval = min(scalars) + 0.01
5048
maxval = max(scalars) - 0.01
5149

docs/examples/example_mapping.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
from compas.colors import Color
24
from compas.datastructures import Mesh
35
from compas_viewer import Viewer
@@ -8,11 +10,10 @@
810
from compas_libigl.mapping import map_mesh
911
from compas_libigl.parametrisation import trimesh_lsc_mapping
1012

11-
from pathlib import Path
12-
1313
# ==============================================================================
1414
# Input geometry: 3D Mesh
1515
# ==============================================================================
16+
1617
mesh = Mesh.from_obj(Path(__file__).parent.parent.parent / "data" / "minimal_surface.obj")
1718

1819
for key, attr in mesh.vertices(True):
@@ -23,13 +24,12 @@
2324

2425
v, f = mesh.to_vertices_and_faces()
2526

26-
2727
# ==============================================================================
2828
# Input geometry: 2D Pattern creation using Tessagon library, can be other mesh.
2929
# ==============================================================================
3030

3131
options = {
32-
"function": lambda u, v: [u*1, v*1, 0],
32+
"function": lambda u, v: [u * 1, v * 1, 0],
3333
"u_range": [-0.255, 1.33],
3434
"v_range": [-0.34, 1.33],
3535
"u_num": 16,

docs/examples/example_mapping_all_patterns.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from itertools import filterfalse
2+
from pathlib import Path
3+
24
from compas.colors import Color
35
from compas.datastructures import Mesh
46
from compas_viewer import Viewer
@@ -12,7 +14,6 @@
1214
from tessagon.types.dodeca_tessagon import DodecaTessagon
1315
from tessagon.types.floret_tessagon import FloretTessagon
1416
from tessagon.types.hex_big_tri_tessagon import HexBigTriTessagon
15-
1617
from tessagon.types.hex_tessagon import HexTessagon
1718
from tessagon.types.hex_tri_tessagon import HexTriTessagon
1819
from tessagon.types.octo_tessagon import OctoTessagon
@@ -27,9 +28,6 @@
2728
from compas_libigl.mapping import map_mesh
2829
from compas_libigl.parametrisation import trimesh_lsc_mapping
2930

30-
from pathlib import Path
31-
32-
3331
TESSAGON_TYPES = {
3432
1: ("Hex", HexTessagon),
3533
2: ("Tri", TriTessagon),
@@ -68,13 +66,12 @@
6866

6967
v, f = mesh.to_vertices_and_faces()
7068

71-
7269
# ==============================================================================
7370
# Input geometry: 2D Pattern creation using Tessagon library, can be other mesh.
7471
# ==============================================================================
7572

7673
options = {
77-
"function": lambda u, v: [u*1, v*1, 0],
74+
"function": lambda u, v: [u * 1, v * 1, 0],
7875
"u_range": [-0.25, 1.25],
7976
"v_range": [-0.25, 1.25],
8077
"u_num": 20,
@@ -99,7 +96,9 @@
9996

10097
mv, mf = map_mesh((v, f), (pv, pf), clip_boundaries=True, tolerance=1e-6)
10198
mesh_mapped = Mesh.from_vertices_and_faces(mv, mf)
99+
102100
print(len(mv))
101+
103102
# ==============================================================================
104103
# Viewer
105104
# ==============================================================================
@@ -120,4 +119,4 @@
120119
mesh_flattened.vertex_attributes(i, "xyz", [uv[i][0], uv[i][1], 0])
121120
viewer.scene.add(mesh_flattened, name="mesh_flattened", show_lines=False, opacity=0.5)
122121

123-
viewer.show()
122+
viewer.show()

docs/examples/example_meshing_geodesic.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
from pathlib import Path
23

34
from compas.colors import ColorMap
45
from compas.datastructures import Mesh
@@ -7,10 +8,8 @@
78
from compas.geometry import Scale
89
from compas_viewer import Viewer
910

10-
from compas_libigl.meshing import trimesh_remesh_along_isolines
1111
from compas_libigl.geodistance import trimesh_geodistance_multiple
12-
13-
from pathlib import Path
12+
from compas_libigl.meshing import trimesh_remesh_along_isolines
1413

1514
# ==============================================================================
1615
# Input geometry

docs/examples/example_meshing_plane.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import math
2+
from pathlib import Path
23

34
from compas.colors import Color
45
from compas.datastructures import Mesh
@@ -9,8 +10,6 @@
910

1011
from compas_libigl.meshing import trimesh_remesh_along_isoline
1112

12-
from pathlib import Path
13-
1413
# Load and transform mesh
1514
mesh = Mesh.from_off(Path(__file__).parent.parent.parent / "data" / "beetle.off")
1615
R = Rotation.from_axis_and_angle([1, 0, 0], math.radians(90))

0 commit comments

Comments
 (0)