Skip to content

Commit 73da1d8

Browse files
authored
Polygon DEC (#195)
* Implementation of polygon Laplacian and mass matrices (unlumped & lumped) from "Polygon Laplacian Made Simple" by Bunge et al. 2020. * Implementation of polygon Laplacian, mass matrix, gradient, divergence, connection Laplacian, and DEC operators from "Discrete Differential Operators on Polygonal Meshes" by de Goes et al 2020. * A `PolygonMeshHeatSolver` that implements the Vector Heat Method, Unsigned Heat Method, and Signed Heat Method on polygon meshes, analogous to the `PointCloudHeatSolver` for point clouds. * Documentation & tests.
1 parent 1f8a50c commit 73da1d8

19 files changed

Lines changed: 1756 additions & 38 deletions
806 KB
Loading

docs/docs/pointcloud/algorithms/heat_solver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ The `SignedHeatOptions` struct allows several options:
101101
| Field | Default value |Meaning|
102102
|---|---|---|
103103
| `#!cpp bool preserveSourceNormals`| `false` | If `true`, preserve the initial curve normals at the source curve during vector diffusion. |
104-
| `#!cpp LevelSetConstraint levelSetConstraint`| `LevelSetConstraint::ZeroSet` | Specifies how/if level sets should be preserved. Can be set to `LevelSetConstraint::ZeroSet`, `LevelSetConstraint::Multiple`, or `LevelSetConstraint::None`, corresponding to preserving the zero set, mulitple level sets (one for each curve component), or no level sets, respectively. |
104+
| `#!cpp LevelSetConstraint levelSetConstraint`| `LevelSetConstraint::ZeroSet` | Specifies how/if level sets should be preserved. Can be set to `LevelSetConstraint::ZeroSet`, `LevelSetConstraint::Multiple`, or `LevelSetConstraint::None`, corresponding to preservation of `curves` as the zero set, as multiple level sets (one for each curve component), or no constraint, respectively. |
105105
| `#!cpp double softLevelSetWeight`| `-1` | If greater than 0, gives the weight with which the given level set constraint is "softly" enforced. |
106106
107107
## Scalar extension

docs/docs/surface/algorithms/geodesic_distance.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ This class also supports any (possibly-nonmanifold) triangle mesh as input, and
182182

183183
`#include "geometrycentral/surface/heat_method_distance.h"`
184184

185+
For the polygon mesh version, see the [polygon mesh heat solver](/surface/algorithms/polygon_heat_solver); for point clouds, see the [point cloud heat solver](/pointcloud/algorithms/heat_solver/).
186+
185187
### Single Solves
186188

187189
A one-off utility function is provided which computes the distance from a source vertex using the heat method. Repeated solves or more general source data should use the stateful version below.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Heat distance and transport on general polygon meshes
2+
3+
Compute signed and unsigned geodesic distance, and transport tangent vectors using fast solvers based on short-time heat flow.
4+
5+
![polygon mesh heat solve results](/media/polygon_heat_solvers.png)
6+
7+
These routines implement polygon mesh versions of the algorithms from:
8+
9+
- [The Heat Method for Distance Computation](http://www.cs.cmu.edu/~kmcrane/Projects/HeatMethod/index.html) (distance)
10+
- [The Vector Heat Method](https://nmwsharp.com/research/vector-heat-method) (parallel transport)
11+
- [A Heat Method for Generalized Signed Distance](https://nzfeng.github.io/research/SignedHeatMethod/index.html) (signed distance)
12+
13+
All computation is encapsulated by the `PolygonMeshHeatSolver` class, which maintains prefactored linear systems for the various methods. Some setup work is performed both on construction, and after the first query. Subsequent queries, even with different source points, will be fast.
14+
15+
`#include "geometrycentral/surface/polygon_mesh_heat_solver.h"`
16+
17+
For the original algorithms on triangle meshes, see the documentation for the [Unsigned Heat Method](/surface/algorithms/geodesic_distance/#heat-method-for-distance), [Vector Heat Method](/surface/algorithms/vector_heat_method), and [Signed Heat Method](/surface/algorithms/signed_heat_method).
18+
19+
**Example:** Basic usage
20+
21+
```cpp
22+
#include "geometrycentral/surface/polygon_mesh_heat_solver.h"
23+
24+
using namespace geometrycentral;
25+
using namespace geometrycentral::surface;
26+
27+
// Read in a polygon mesh
28+
std::unique_ptr<SurfaceMesh> mesh;
29+
std::unique_ptr<VertexPositionGeometry> geom;
30+
std::tie(mesh, geom) = readSurfaceMesh("my_mesh.obj");
31+
32+
// Create the solver
33+
PolygonMeshHeatSolver solver(*geom);
34+
35+
// Pick a source point or two
36+
Vertex vSource = mesh->vertex(7);
37+
Vertex vSource2 = mesh->vertex(8);
38+
39+
// Pick some source curves
40+
std::vector<std::vector<Vertex>> curves;
41+
curves.push_back({mesh->vertex(11), mesh->vertex(12), mesh->vertex(15), mesh->vertex(14), mesh->vertex(13)});
42+
curves.push_back({mesh->vertex(17), mesh->vertex(18), mesh->vertex(19)});
43+
44+
// Compute geodesic distance
45+
VertexData<double> distance = solver.computeDistance(vSource);
46+
47+
// Compute signed distance to a set of curves.
48+
VertexData<double> signedDistance = solver.computeSignedDistance(curves);
49+
50+
// Compute scalar extension
51+
VertexData<double> extended = solver.extendScalars({{vSource, 3.},
52+
{vSource2, -5.}});
53+
54+
// Compute parallel transport
55+
Vector2 sourceVec{1, 2};
56+
VertexData<Vector2> transport = solver.transportTangentVector(vSource, sourceVec);
57+
```
58+
59+
### Constructor
60+
61+
??? func "`#!cpp PolygonMeshHeatSolver::PolygonMeshHeatSolver(EmbeddedGeometryInterface& geom, double tCoef = 1.0)`"
62+
63+
Create a new solver for the heat methods. Precomputation is performed at startup and lazily as needed.
64+
65+
- `geom` is the geometry (and hence mesh) on which to compute. Any embedded geometry object (`VertexPositionGeometry`, etc) can be passed here.
66+
67+
- `tCoef` is the time to use for short time heat flow, as a factor `m * h^2`, where `h` is the maximum between-point spacing. The default value of `1.0` is almost always sufficient.
68+
69+
Algorithm options (like `tCoef`) cannot be changed after construction; create a new solver object with the new settings.
70+
71+
72+
## Geodesic distance
73+
74+
_Geodesic distance_ is the distance from a given source along the surface represented by the point cloud. Specifying multiple source points yields the distance to the nearest source.
75+
76+
??? func "`#!cpp VertexData<double> PolygonMeshHeatSolver::computeDistance(const Vertex& sourceVert)`"
77+
78+
Compute the geodesic distance from `sourceVert` to all other points.
79+
80+
??? func "`#!cpp VertexData<double> PolygonMeshHeatSolver::computeDistance(const std::vector<Vertex>& sourceVerts)`"
81+
82+
Like above, but for multiple source points.
83+
84+
## Signed geodesic distance
85+
86+
??? func "`#!cpp VertexData<double> PolygonMeshHeatSolver::computeSignedDistance(const std::vector<std::vector<Vertex>>& curves, const LevelSetConstraint& levelSetConstraint = LevelSetConstraint::ZeroSet)`"
87+
88+
Compute the signed geodesic distance from a set of curves `curves` to all other points. Each curve in `curves` is a single connected component specified as an ordered sequence of points; curve orientations are derived from this order. The argument `levelSetConstraint` can be set to `LevelSetConstraint::ZeroSet`, `LevelSetConstraint::Multiple`, or `LevelSetConstraint::None`, corresponding to preservation of `curves` as the zero set, as multiple level sets (one for each curve component), or no constraint, respectively.
89+
90+
## Scalar extension
91+
92+
Given scalar values defined at isolated vertices in the domain, extend it to a scalar field on all vertices. Each point will take the value from the nearest source point, in the sense of geodesic distance. Note that the fast diffusion algorithm means the result is a slightly smoothed-out field.
93+
94+
??? func "`#!cpp VertexData<double> PolygonMeshHeatSolver::extendScalars(const std::vector<std::tuple<Vertex, double>>& sources)`"
95+
96+
Given a collection of source vertices and scalars at those vertices, extends the scalar field to the whole mesh as a nearest-geodesic-neighbor interpolant.
97+
98+
99+
## Vector extension
100+
101+
Given tangent vectors defined at one or more isolated source locations on a surface, extend transport the vectors across the entire domain according to parallel transport. Each point on the domain will take the value of the nearest source point. Note that the fast diffusion algorithm means the result is a slightly smoothed-out field.
102+
103+
??? func "`#!cpp VertexData<Vector2> PolygonMeshHeatSolver::transportTangentVector(const Vertex& sourceVert, const Vector2& sourceVector)`"
104+
105+
Shorthand for the general version below when there is just one vector.
106+
107+
Computes parallel transport of the given vector along shortest geodesics to the rest of the domain.
108+
109+
Polar directions are defined in each vertex's tangent space. [See `EmbeddedGeometryInterface::vertexTangentBasis`](/surface/geometry#vertex-tangent-basis).
110+
111+
??? func "`#!cpp VertexData<Vector2> PolygonMeshHeatSolver::transportTangentVectors(const std::vector<std::tuple<Vertex, Vector2>>& sources)`"
112+
113+
Given a collection of source vertices and tangent vectors at those vertices, extends the vector field to the whole domain as a nearest-geodesic-neighbor interpolant via parallel transport along shortest geodesics.
114+
115+
Polar directions are defined in each vertex's tangent space. [See `EmbeddedGeometryInterface::vertexTangentBasis`](/surface/geometry#vertex-tangent-basis).

docs/docs/surface/algorithms/signed_heat_method.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ This section describes the _Signed Heat Method_ in geometry-central, which compu
22

33
Note that these quantities all depend on the _intrinsic_ geometry of a surface (via the `IntrinsicGeometryInterface`). Therefore, these routines can be run on abstract geometric domains as well as traditional surfaces in 3D.
44

5-
These algorithms are described in [A Heat Method for Generalized Signed Distance](https://nzfeng.github.io/research/SignedHeatMethod/SignedDistance.pdf).
5+
This algorithm is described in [A Heat Method for Generalized Signed Distance](https://nzfeng.github.io/research/SignedHeatMethod/SignedDistance.pdf).
66

77
`#include "geometrycentral/surface/signed_heat_method.h"`
88

9+
For the polygon mesh version, see the [polygon mesh heat solver](/surface/algorithms/polygon_heat_solver); for point clouds, see the [point cloud heat solver](/pointcloud/algorithms/heat_solver/).
910

1011
## Signed Heat Solver
1112

@@ -78,7 +79,7 @@ Options are passed in to `computeDistance` via a `SignedHeatOptions` struct, whi
7879
| Field | Default value |Meaning|
7980
|---|---|---|
8081
| `#!cpp bool preserveSourceNormals`| `false` | If `true`, preserve the initial curve normals at the source curve during vector diffusion. |
81-
| `#!cpp LevelSetConstraint levelSetConstraint`| `LevelSetConstraint::ZeroSet` | Specifies how/if level sets should be preserved. Can be set to `LevelSetConstraint::ZeroSet`, `LevelSetConstraint::Multiple`, or `LevelSetConstraint::None`, corresponding to preserving the zero set, mulitple level sets (one for each curve component), or no level sets, respectively. |
82+
| `#!cpp LevelSetConstraint levelSetConstraint`| `LevelSetConstraint::ZeroSet` | Specifies how/if level sets should be preserved. Can be set to `LevelSetConstraint::ZeroSet`, `LevelSetConstraint::Multiple`, or `LevelSetConstraint::None`, corresponding to preservation of the input curves as the zero set, as multiple level sets (one for each curve component), or no constraint, respectively. |
8283
| `#!cpp double softLevelSetWeight`| `-1` | If greater than 0, gives the weight with which the given level set constraint is "softly" enforced. |
8384
8485
## Citation

docs/docs/surface/algorithms/vector_heat_method.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ These algorithms are described in [The Vector Heat Method](http://www.cs.cmu.edu
66

77
`#include "geometrycentral/surface/vector_heat_method.h"`
88

9+
For the polygon mesh version, see the [polygon mesh heat solver](/surface/algorithms/polygon_heat_solver); for point clouds, see the [point cloud heat solver](/pointcloud/algorithms/heat_solver/).
910

1011
## Vector Heat Solver
1112

0 commit comments

Comments
 (0)