Skip to content

Commit e18d6e4

Browse files
committed
properly rename cell_size -> edge_size for 2D
1 parent a4455be commit e18d6e4

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import pygalmesh
3636
points = numpy.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]])
3737
constraints = [[0, 1], [1, 2], [2, 3], [3, 0]]
3838

39-
mesh = pygalmesh.generate_2d(points, constraints, cell_size=1.0e-1, num_lloyd_steps=10)
39+
mesh = pygalmesh.generate_2d(points, constraints, edge_size=1.0e-1, num_lloyd_steps=10)
4040
# mesh.points, mesh.cells
4141
```
4242
The quality of the mesh isn't very good, but can be improved with

src/generate_2d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ generate_2d(
3030
// for what the bounds mean. Spoiler:
3131
// B = circumradius / shortest_edge,
3232
// relates to the smallest angle via sin(alpha_min) = 1 / (2B)
33-
// cell_size is "size",
33+
// edge_size S: "all segments of all triangles must be shorter than a bound S."
3434
const double max_circumradius_shortest_edge_ratio,
35-
const double cell_size,
35+
const double edge_size,
3636
const int num_lloyd_steps
3737
)
3838
{
@@ -53,7 +53,7 @@ generate_2d(
5353
cdt,
5454
Criteria(
5555
0.25 / (max_circumradius_shortest_edge_ratio * max_circumradius_shortest_edge_ratio),
56-
cell_size
56+
edge_size
5757
)
5858
);
5959

src/generate_2d.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define GENERATE_2D_HPP
33

44
#include <memory>
5+
#include <pthread.h>
56
#include <vector>
67

78
namespace pygalmesh {
@@ -11,7 +12,11 @@ generate_2d(
1112
const std::vector<std::array<double, 2>> & points,
1213
const std::vector<std::array<int, 2>> & constraints,
1314
const double max_circumradius_shortest_edge_ratio,
14-
const double cell_size,
15+
// https://github.com/CGAL/cgal/issues/5061#issuecomment-705520984
16+
// the "default" size criterion for a triangle in the 2D mesh generator refers to its
17+
// edges lengths. In the output mesh, all segments of all triangles must be shorter
18+
// than the given bound.pthread_mutexattr_getprotocol
19+
const double edge_size,
1520
const int num_lloyd_steps
1621
);
1722

src/pybind11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ PYBIND11_MODULE(_pygalmesh, m) {
262262
py::arg("points"),
263263
py::arg("constraints"),
264264
py::arg("max_circumradius_shortest_edge_ratio") = 1.41421356237,
265-
py::arg("cell_size") = 0.0,
265+
py::arg("edge_size") = 0.0,
266266
py::arg("num_lloyd_steps") = 0
267267
);
268268
m.def(

test/test_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_2d():
88
constraints = [[0, 1], [1, 2], [2, 3], [3, 0]]
99

1010
mesh = pygalmesh.generate_2d(
11-
points, constraints, cell_size=1.0e-1, num_lloyd_steps=10
11+
points, constraints, edge_size=1.0e-1, num_lloyd_steps=10
1212
)
1313

1414
assert mesh.points.shape == (276, 2)

0 commit comments

Comments
 (0)