Skip to content

Distance quantities

Visualize distance-valued data at the elements of a surface mesh.

Distance quantities are basicly scalars, but are visualized with alternating stripes to show distance contours.

Example: visualizing exact geodesic distance computed via libIGL’s wrappers around Kirsanov’s MMP implementation.

// Compute distance from vertex iVertexSource
Eigen::VectorXi VS, FS, VT, FT;
VS.resize(1);
VS << iVertexSource;
VT.setLinSpaced(meshV.rows(), 0, meshV.rows() - 1);
Eigen::VectorXd d;
igl::exact_geodesic(meshV, meshF, VS, FS, VT, FT, d);

// Add the distance quantity to the surface mesh
polyscope::getSurfaceMesh("input mesh")
    ->addVertexDistanceQuantity(
        "distance from vertex " + std::to_string(iVertexSource), d);

Add distance to vertices

SurfaceMesh::addVertexDistanceQuantity(std::string name, const T& values)

Add a distance quantity defined at the vertices of the mesh.

  • values is the array of distances at vertices. The type should be adaptable to a float scalar array. The length should be the number of vertices in the mesh.
SurfaceMesh::addVertexDistanceQuantity(std::string name, const T& values)

Add a signed distance quantity defined at the vertices of the mesh.

  • values is the array of distances at vertices. The type should be adaptable to a float scalar array. The length should be the number of vertices in the mesh.

This quantity is very similar to addVertexDistanceQuantity, except the colormap is adjusted to scale symetrically for negative values.

Options

Parameter Meaning Getter Setter Persistent?
enabled is the quantity enabled? bool isEnabled() setEnabled(bool newVal) yes
color map the color map to use std::string getColorMap() setColorMap(std::string newMap) yes
map range the lower and upper limits used when mapping the data in to the color map std::pair<double,double> getMapRange() setMapRange(std::pair<double,double>) and resetMapRange() no
stripe size the size of the stripes showing distance isolines setStripeSize(double size, bool isRelative=true) double getStripeSize() yes

(all setters return this to support chaining. setEnabled() returns generic quantity, so chain it last)