Skip to content

Commit f893918

Browse files
author
pv
committed
CHANGE simplify example.
1 parent 7ab67ec commit f893918

File tree

3 files changed

+16
-37
lines changed

3 files changed

+16
-37
lines changed

docs/examples/example_meshing.py

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,35 @@
1-
import math
2-
from pathlib import Path
3-
1+
from compas.geometry import Sphere
42
from compas.datastructures import Mesh
5-
from compas.geometry import Rotation
6-
from compas.geometry import Scale
73
from compas.geometry import Translation
8-
from compas.geometry import Vector
9-
from compas.geometry import scale_vector
104
from compas.geometry import transform_points_numpy
115
from compas_viewer import Viewer
126

137
from compas_cgal.meshing import mesh_remesh, mesh_dual
14-
from compas_cgal import _types_std # noqa: F401
158

169
def main():
17-
"""Remesh a bunny mesh that is loaded from .ply file."""
18-
19-
FILE = Path(__file__).parent.parent.parent / "data" / "Bunny.ply"
20-
21-
#bunny = Mesh.from_ply(FILE)
22-
bunny = Mesh.from_meshgrid(1,10,1,10)
23-
bunny.quads_to_triangles()
24-
bunny.remove_unused_vertices()
25-
26-
centroid = bunny.vertex_point(0)
27-
28-
vector = scale_vector(centroid, -1)
10+
"""Remesh a mesh."""
2911

30-
T = Translation.from_vector(vector)
31-
S = Scale.from_factors([100, 100, 100])
32-
R = Rotation.from_axis_and_angle(Vector(1, 0, 0), math.radians(90))
12+
mesh = Mesh.from_shape(Sphere(1))
13+
mesh.quads_to_triangles()
3314

34-
# bunny.transform(R * S * T)
35-
V0, F0 = bunny.to_vertices_and_faces()
36-
V1 = transform_points_numpy(V0, R * S * T)
37-
38-
39-
edge_length = 0.3
15+
edge_length = 0.5
4016
iterations = 10
41-
x_translation = 0.0
42-
V1, F1 = mesh_remesh((V0, F0), edge_length, iterations)
17+
x_translation = 2
18+
19+
# Remesh
20+
V1, F1 = mesh_remesh(mesh.to_vertices_and_faces(), edge_length, iterations)
4321
V1 = transform_points_numpy(V1, Translation.from_vector([x_translation, 0, 0]))
44-
mesh = Mesh.from_vertices_and_faces(V1, F1)
22+
remeshed = Mesh.from_vertices_and_faces(V1, F1)
4523

46-
24+
# Dual
4725
V2, F2 = mesh_dual((V1, F1), 2.14, True)
4826
V2 = transform_points_numpy(V2, Translation.from_vector([x_translation, 0, 0]))
4927
dual = Mesh.from_vertices_and_faces(V2, F2)
5028

51-
return bunny, mesh, dual
29+
return mesh, remeshed, dual
5230

5331

54-
bunny, mesh, dual = main()
32+
mesh, remeshed, dual = main()
5533

5634

5735
# ==============================================================================
@@ -63,8 +41,8 @@ def main():
6341
viewer.renderer.camera.target = [0, 0, 0]
6442
viewer.renderer.camera.position = [0, -0.25, 0.10]
6543

66-
# viewer.scene.add(bunny, show_points=False)
6744
viewer.scene.add(mesh, show_points=False)
45+
viewer.scene.add(remeshed, show_points=False)
6846
viewer.scene.add(dual, show_points=True)
6947

7048
viewer.show()

src/compas_cgal/meshing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from compas.plugins import plugin
33

44
from compas_cgal import _meshing
5+
from compas_cgal import _types_std # noqa: F401
56

67
from .types import VerticesFaces
78
from .types import VerticesFacesNumpy

src/meshing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pmp_dual(
7878

7979

8080
/////////////////////////////////////////////////////////////////////////////////
81-
// Scalled inner vertices
81+
// Scaled inner vertices
8282
/////////////////////////////////////////////////////////////////////////////////
8383

8484
if (scale_factor != 1.0 && scale_factor > 0.0){

0 commit comments

Comments
 (0)