Parameterization Quantities
A parameterization is a set of 2D coordinates associated with a mesh, often referred to as “UV coordinates”. This sections details several functions for visualizing such parameterizations.
#include "polyscope/surface_mesh.h"
Example: visualizing an LSCM parameterization via libIGL
using namespace Eigen;
using namespace std;
// Fix two points on the boundary
VectorXi bnd, b(2, 1);
igl::boundary_loop(meshF, bnd);
if (bnd.size() == 0) {
polyscope::warning("mesh has no boundary, cannot parameterize");
return;
}
b(0) = bnd(0);
b(1) = bnd(round(bnd.size() / 2));
MatrixXd bc(2, 2);
bc << 0, 0, 1, 0;
// LSCM parametrization
Eigen::MatrixXd V_uv;
igl::lscm(meshV, meshF, b, bc, V_uv);
polyscope::getSurfaceMesh("input mesh")
->addVertexParameterizationQuantity("LSCM parameterization", V_uv);
Adding¶
SurfaceMesh::addParameterizationQuantity(std::string name, const T& coords, ParamCoordsType type=ParamCoordsType::UNIT)
Add a new parameterization quantity to the structure, defined at the corners of a mesh.
-
coords
is the array of 2D UV coordinates at corners. The type should be adaptable to an array offloat
-valued 2-vectors. The length should be the number of corners in the mesh. -
type
the default interpretation of the coordinate scale, see below
SurfaceMesh::addVertexParameterizationQuantity(std::string name, const T& coords, ParamCoordsType type=ParamCoordsType::UNIT)
Add a new parameterization quantity to the structure, defined at the vertices of a mesh.
-
coords
is the array of 2D UV coordinates at vertices. The type should be adaptable to an array offloat
-valued 2-vectors. The length should be the number of vertices in the mesh. -
type
the default interpretation of the coordinate scale, see below
SurfaceMesh::addLocalParameterizationQuantity(std::string name, const T& coords, ParamCoordsType type=ParamCoordsType::WORLD)
Add a new parameterization quantity to the structure, defined at the vertices of a mesh. this is similar to addVertexParameterizationQuantity
, but has preset settings for style
and type
which are suitable for local parameterizations about a point.
-
coords
is the array of 2D UV coordinates at vertices. The type should be adaptable to an array offloat
-valued 2-vectors. The length should be the number of vertices in the mesh. -
type
the default interpretation of the coordinate scale, see below
Visualizing islands and seams¶
For parameterizations on surface meshes, additional features are available to visualize UV island and seams. The term islands refers to connected components of faces in the 2D parameterization, and the term seams refers to the subset of edges separating adjacent faces which are not connected.
UV islands can be colored per-island with the ParamVizStyle::CHECKER_ISLANDS
style. Each face should have an integer indicating which island it is a part of, which the caller must compute and pass via the function below (Polyscope does not compute it automatically).
void SurfaceParameterizationQuantity::setIslandLabels(const T& labels)
setIslandLabels¶
Set an integer value per-face of the mesh, which can be used to color islands distinctly in the ParamVizStyle::CHECKER_ISLANDS
style. Each face should have an integer indicating which island it is a part of, numbered however you like.
Technically this can be any integer per-face, although it is generally useful for visualizing islands.
labels
is the array of face labels. The type should be adaptable to an array of integers. The length must be equal to the number of faces in the mesh.
This will have no effect unless you also set ParamVizStyle::CHECKER_ISLANDS
.
Additionally, the seams of a parameterization can be visualized as a curve network. These seams are computed automatically by Polyscope, the curve network is created by calling the function below, and is otherwise an ordinary curve network.
CurveNetwork* SurfaceParameterizationQuantity::createCurveNetworkFromSeams(std::string structureName="")
createCurveNetworkFromSeams¶
Create a curve network from the seams of a UV map.
structureName
the name of the new curve network structure. If left as the empty string (default) a name will be generated.
Parameterization Quantity Options¶
These options and behaviors are available for all types of parameterization quantities on any structure.
Styles¶
Several styles are available for how a parameterization is displayed.
The enum class ParamVizStyle
has options for how parameterizations are visualized:
CHECKER
: a two-color checker patternGRID
: a grid with thin linesLOCAL_CHECK
: a checkboard over a radial colormap, centered around(0,0)
LOCAL_RAD
: distance stripes over a radial colormap, centered around(0,0)
CHECKER_ISLANDS
: a checkerboard where islands are colored according to the island labels integer, which must be given explicitly (meshes only)
The function SurfaceParameterizationQuantity::setStyle(ParamVizStyle newStyle)
can be used to programmatically change the style.
Types¶
The enum class ParamCoordsType
has options that control how parameter coordinates are interpreted:
UNIT
: UV coords are assumed to lie on the[0,1]
intervalWORLD
: UV coords are assumed to be scaled like the world-space positions of the mesh
These enums can be passed as an optional third argument when a parameterization is registered.
Options¶
Parameter | Meaning | Getter | Setter | Persistent? |
---|---|---|---|---|
enabled | is the quantity enabled? | bool isEnabled() |
setEnabled(bool newVal) |
yes |
style | the visualization style (see above) | ParamVizStyle getStyle |
setStyle(ParamVizStyle style) |
yes |
checker colors | two colors to use for checkerboards | std::pair<glm::vec3,glm::vec3>getCheckerColors() |
setCheckerColors(std::pair<glm::vec3, glm::vec3> colors) |
yes |
grid colors | two colors to use for line and background of grid | std::pair<glm::vec3,glm::vec3>getGridColors() |
setGridColors(std::pair<glm::vec3, glm::vec3> colors) |
yes |
checker size | the width of checkers / stripes, always used as a relative value, unless the coord tpe is UNIT |
double getCheckerSize() |
setCheckerSize(double val) |
yes |
color map | the color map to use for radial displays | std::string getColorMap() |
setColorMap(std::string newMap) |
yes |
(all setters return this
to support chaining. setEnabled() returns generic quantity, so chain it last)