33from compas .colors import Color
44from compas .colors import ColorMap
55from compas .datastructures import Mesh
6- from compas .datastructures import mesh_flatness
76from compas_viewer import Viewer
87
98# ==============================================================================
1413MAXDEV = 0.005
1514KMAX = 500
1615
17- mesh = Mesh .from_obj (compas .get ("tubemesh.obj" ))
16+ mesh_not_planarized = Mesh .from_obj (compas .get ("tubemesh.obj" ))
17+ mesh_not_planarized .name = "Not Planarized"
1818
1919# ==============================================================================
2020# Planarize
2121# ==============================================================================
2222
23- V , F = mesh .to_vertices_and_faces ()
23+ V , F = mesh_not_planarized .to_vertices_and_faces ()
2424V2 = igl .quadmesh_planarize ((V , F ), KMAX , MAXDEV )
2525
2626# ==============================================================================
2727# Visualize
2828# ==============================================================================
2929
30- mesh = Mesh .from_vertices_and_faces (V2 , F )
31- dev = mesh_flatness ( mesh , maxdev = TOL )
30+ mesh_planarized = Mesh .from_vertices_and_faces (V2 , F )
31+ mesh_planarized . name = "Planarized"
3232
3333cmap = ColorMap .from_two_colors (Color .white (), Color .blue ())
3434
3535viewer = Viewer (width = 1600 , height = 900 )
36- # viewer.view.camera.position = [1, -6, 2]
37- # viewer.view.camera.look_at([1, 1, 1])
38-
39- viewer .scene .add (
40- mesh ,
41- facecolor = {face : (cmap (dev [face ]) if dev [face ] <= 1.0 else Color .red ()) for face in mesh .faces ()},
42- show_points = False ,
43- )
44- viewer .show ()
36+ viewer .scene .add (mesh_not_planarized , show_faces = False )
37+ viewer .scene .add (mesh_planarized )
38+ viewer .show ()
0 commit comments