Skip to content

Commit 49261bf

Browse files
author
pv
committed
PR comments and documentation.
1 parent 6730801 commit 49261bf

File tree

7 files changed

+145
-64
lines changed

7 files changed

+145
-64
lines changed

docs/_images/example_mapping.png

98.1 KB
Loading
-689 Bytes
Loading

docs/api/compas_libigl.rst

Lines changed: 96 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,99 @@
22
compas_libigl
33
********************************************************************************
44

5-
.. currentmodule:: compas_libigl
6-
7-
Functions
8-
=========
9-
10-
.. autosummary::
11-
:toctree: generated/
12-
:nosignatures:
13-
14-
add
15-
get
16-
get_beetle
17-
get_armadillo
18-
intersection_ray_mesh
19-
intersection_rays_mesh
20-
trimesh_boundaries
21-
trimesh_gaussian_curvature
22-
trimesh_principal_curvature
23-
trimesh_geodistance
24-
trimesh_geodistance_multiple
25-
trimesh_isolines
26-
groupsort_isolines
27-
trimesh_massmatrix
28-
trimesh_harmonic_mapping
29-
trimesh_lsc_mapping
30-
quadmesh_planarize
31-
trimesh_remesh_along_isoline
32-
trimesh_remesh_along_isolines
5+
Boundaries
6+
----------
7+
8+
.. autosummary::
9+
:toctree: generated/
10+
:nosignatures:
11+
12+
compas_libigl.boundaries.trimesh_boundaries
13+
14+
Curvature
15+
---------
16+
17+
.. autosummary::
18+
:toctree: generated/
19+
:nosignatures:
20+
21+
compas_libigl.curvature.trimesh_gaussian_curvature
22+
compas_libigl.curvature.trimesh_principal_curvature
23+
24+
Geodesic Distance
25+
-----------------
26+
27+
.. autosummary::
28+
:toctree: generated/
29+
:nosignatures:
30+
31+
compas_libigl.geodistance.trimesh_geodistance
32+
compas_libigl.geodistance.trimesh_geodistance_multiple
33+
34+
Intersections
35+
-------------
36+
37+
.. autosummary::
38+
:toctree: generated/
39+
:nosignatures:
40+
41+
compas_libigl.intersections.intersection_ray_mesh
42+
compas_libigl.intersections.intersection_rays_mesh
43+
44+
Isolines
45+
--------
46+
47+
.. autosummary::
48+
:toctree: generated/
49+
:nosignatures:
50+
51+
compas_libigl.isolines.trimesh_isolines
52+
compas_libigl.isolines.groupsort_isolines
53+
54+
Mapping
55+
-------
56+
57+
.. autosummary::
58+
:toctree: generated/
59+
:nosignatures:
60+
61+
compas_libigl.mapping.map_mesh
62+
compas_libigl.mapping.map_pattern_to_mesh
63+
64+
Mass Matrix
65+
-----------
66+
67+
.. autosummary::
68+
:toctree: generated/
69+
:nosignatures:
70+
71+
compas_libigl.massmatrix.trimesh_massmatrix
72+
73+
Meshing
74+
-------
75+
76+
.. autosummary::
77+
:toctree: generated/
78+
:nosignatures:
79+
80+
compas_libigl.meshing.trimesh_remesh_along_isoline
81+
compas_libigl.meshing.trimesh_remesh_along_isolines
82+
83+
Parametrisation
84+
---------------
85+
86+
.. autosummary::
87+
:toctree: generated/
88+
:nosignatures:
89+
90+
compas_libigl.parametrisation.trimesh_harmonic_mapping
91+
compas_libigl.parametrisation.trimesh_lsc_mapping
92+
93+
Planarization
94+
-------------
95+
96+
.. autosummary::
97+
:toctree: generated/
98+
:nosignatures:
99+
100+
compas_libigl.planarize.quadmesh_planarize

docs/examples/example_mapping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
mv, mf, mn, mb, mg = map_mesh((v, f), (pv, pf))
5858
mesh_mapped = Mesh.from_vertices_and_faces(mv, mf)
5959

60-
6160
# ==============================================================================
6261
# Offset mesh by normals, normals are interpolated from the original mesh.
6362
# ==============================================================================

docs/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
compas_libigl
33
********************************************************************************
44

5+
.. figure:: /_images/example_mapping_boundaries.png
6+
:figclass: figure
7+
:class: figure-img img-fluid
8+
59
.. rst-class:: lead
610

711
COMPAS Libigl provides a Python binding for `Libigl <https://libigl.github.io/>`_,

mesh_flattened.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/compas_libigl/mapping.py

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,25 @@ def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, tolerance=1e-6):
3232
3333
Parameters
3434
----------
35-
target_mesh : tuple
35+
target_mesh : tuple[list[list[float]], list[list[int]]]
3636
A tuple of (vertices, faces) representing the target mesh.
37-
vertices : list[list[float]]
38-
The vertices of the target mesh.
39-
faces : list[list[int]]
40-
The triangle faces of the target mesh.
41-
clip_boundaries : bool
42-
Whether to clip the pattern mesh to the boundaries of the target mesh.
43-
tolerance : float
44-
The tolerance for point comparison, to remove duplicates.
45-
pattern_mesh : tuple
37+
pattern_mesh : tuple[list[list[float]], list[list[int]]]
4638
A tuple of (vertices, faces) representing the pattern mesh.
47-
vertices : list[list[float]]
48-
The vertices of the pattern mesh.
49-
faces : list[list[int]]
50-
The polygonal faces of the pattern mesh.
39+
clip_boundaries : bool
40+
Whether to clip the pattern mesh to the boundaries of the target mesh.
41+
tolerance : float
42+
The tolerance for point comparison, to remove duplicates.
5143
5244
Returns
5345
-------
54-
tuple
55-
A tuple containing: mesh vertices, normals, grouping of polygons (to form holes), boundary flags.
46+
tuple[ndarray, VectorVectorInt, ndarray, VectorBool, VectorInt]
47+
A tuple containing:
48+
49+
* vertices: ndarray - The 3D coordinates of the mapped mesh vertices
50+
* faces: VectorVectorInt - The faces of the mapped mesh
51+
* normals: ndarray - The normal vectors at each vertex
52+
* boundary_flags: VectorBool - Boolean flags indicating if vertices are on the boundary
53+
* polygon_groups: VectorInt - Grouping indices for polygons (to form holes)
5654
"""
5755
# Unpack mesh tuples
5856
v, f = target_mesh
@@ -80,24 +78,26 @@ def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, patter
8078
----------
8179
name : str
8280
The name of the pattern to be created. Options are:
83-
"Hex",
84-
"Tri",
85-
"Octo",
86-
"Square",
87-
"Rhombus",
88-
"HexTri",
89-
"DissectedSquare",
90-
"DissectedTriangle",
91-
"DissectedHexQuad",
92-
"DissectedHexTri",
93-
"Floret",
94-
"Pythagorean",
95-
"Brick",
96-
"Weave",
97-
"ZigZag",
98-
"HexBigTri",
99-
"Dodeca",
100-
"SquareTri"
81+
82+
* "Hex"
83+
* "Tri"
84+
* "Octo"
85+
* "Square"
86+
* "Rhombus"
87+
* "HexTri"
88+
* "DissectedSquare"
89+
* "DissectedTriangle"
90+
* "DissectedHexQuad"
91+
* "DissectedHexTri"
92+
* "Floret"
93+
* "Pythagorean"
94+
* "Brick"
95+
* "Weave"
96+
* "ZigZag"
97+
* "HexBigTri"
98+
* "Dodeca"
99+
* "SquareTri"
100+
101101
mesh : compas.datastructures.Mesh
102102
The target mesh.
103103
clip_boundaries : bool
@@ -113,6 +113,11 @@ def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, patter
113113
-------
114114
compas.datastructures.Mesh
115115
The mapped pattern mesh.
116+
117+
Raises
118+
------
119+
ValueError
120+
If the specified pattern name is not supported.
116121
"""
117122

118123
TESSAGON_TYPES = {
@@ -136,6 +141,11 @@ def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, patter
136141
"SquareTri": SquareTriTessagon,
137142
}
138143

144+
# Check if the provided pattern name is supported
145+
if name not in TESSAGON_TYPES:
146+
supported_names = list(TESSAGON_TYPES.keys())
147+
raise ValueError(f"Pattern name '{name}' is not supported. Choose from: {', '.join(supported_names)}")
148+
139149
options = {
140150
"function": lambda u, v: [u * 1, v * 1, 0],
141151
"u_range": [-0.255, 1.33],

0 commit comments

Comments
 (0)