Skip to content

Commit 0cfe0c5

Browse files
DOCS
1 parent 1a76930 commit 0cfe0c5

File tree

6 files changed

+70
-23
lines changed

6 files changed

+70
-23
lines changed

docs/api/compas_libigl.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ Functions
2020
trimesh_massmatrix
2121
trimesh_harmonic
2222
trimesh_lscm
23-
trimesh_remesh_along_isoline
2423
quadmesh_planarize

docs/examples/curvature.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@ Curvature
66
:figclass: figure
77
:class: figure-img img-fluid
88

9-
.. literalinclude:: curvature.py
9+
.. literalinclude:: curvature_gaussian.py
10+
:language: python
11+
12+
13+
.. figure:: /_images/curvature.png
14+
:figclass: figure
15+
:class: figure-img img-fluid
16+
17+
.. literalinclude:: curvature_principal.py
1018
:language: python

docs/examples/planarize.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from compas.colors import Color
44
from compas.colors import ColorMap
55
from compas.datastructures import Mesh
6-
from compas.datastructures import mesh_flatness
76
from compas_viewer import Viewer
87

98
# ==============================================================================
@@ -14,31 +13,26 @@
1413
MAXDEV = 0.005
1514
KMAX = 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()
2424
V2 = 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

3333
cmap = ColorMap.from_two_colors(Color.white(), Color.blue())
3434

3535
viewer = 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()

src/compas_libigl/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from .isolines import trimesh_isolines, groupsort_isolines
99
from .massmatrix import trimesh_massmatrix
1010
from .parametrisation import trimesh_harmonic, trimesh_lscm
11+
from .planarize import quadmesh_planarize
1112

12-
# from .planarize import quadmesh_planarize
1313
# from .meshing import trimesh_remesh_along_isoline
1414

1515

@@ -115,6 +115,6 @@ def get_armadillo():
115115
"trimesh_massmatrix",
116116
"trimesh_harmonic",
117117
"trimesh_lscm",
118-
# "quadmesh_planarize",
118+
"quadmesh_planarize",
119119
# "trimesh_remesh_along_isoline",
120120
]

src/compas_libigl/planarize.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import numpy as np
2+
from compas.plugins import plugin
3+
4+
from compas_libigl import _planarize
5+
6+
7+
@plugin(category="quadmesh")
8+
def quadmesh_planarize(M, kmax=500, maxdev=0.005):
9+
"""Planarize the faces of a quad mesh.
10+
11+
Parameters
12+
----------
13+
M : tuple or :class:`compas.datastructures.Mesh`
14+
A quad mesh represented by a list of vertices and a list of faces
15+
or by a COMPAS mesh object.
16+
kmax : int, optional
17+
The maximum number of iterations.
18+
Default is ``500``.
19+
maxdev : float, optional
20+
The maximum deviation from planar.
21+
Default is ``0.005``.
22+
23+
Returns
24+
-------
25+
list
26+
The coordinates of the new vertices.
27+
28+
Examples
29+
--------
30+
>>>
31+
32+
"""
33+
V, F = M
34+
V = np.asarray(V, dtype=np.float64)
35+
F = np.asarray(F, dtype=np.int32)
36+
return _planarize.planarize_quads(V, F, kmax, maxdev)

src/planarize.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
#include "planarize.hpp"
22

3-
void function(const compas::RowMatrixXd& V, const compas::RowMatrixXi& F) {}
3+
4+
compas::RowMatrixXd planarize_quads(compas::RowMatrixXd V, compas::RowMatrixXi F, int maxiter = 100, double threshold = 0.005) {
5+
compas::RowMatrixXd Vplanar;
6+
7+
igl::planarize_quad_mesh(V, F, maxiter, threshold, Vplanar);
8+
9+
return Vplanar;
10+
}
11+
412

513
NB_MODULE(_planarize, m) {
614

715
m.def(
8-
"function_name",
9-
&function,
10-
"Description.",
16+
"planarize_quads",
17+
&planarize_quads,
18+
"Planarize a quad mesh.",
1119
"V"_a,
12-
"F"_a);
20+
"F"_a,
21+
"maxiter"_a,
22+
"threshold"_a);
1323
}

0 commit comments

Comments
 (0)