|
| 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 | + |
| 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). |
0 commit comments