Skip to content

Color Quantities

Visualize color rgb-valued data at the elements of a volume mesh.

volume mesh color values

Example: showing a color value at cells (here randomly generated data)

/* ... initialization, create mesh ... */ 

// Register the volume mesh with Polyscope
polyscope::registerTetMesh("my mesh", verts, tets);

// Add a color quantity
size_t nCells = tets.rows();
std::vector<std::array<double, 3>> randColor(nCells);
for (size_t i = 0; i < nCells; i++) {
  // generate random colors 
  randColor[i] = {{polyscope::randomUnit(), polyscope::randomUnit(), polyscope::randomUnit()}};
}
polyscope::getVolumeMesh("my mesh")->addCellColorQuantity("random color", randColor);

// Show the GUI
polyscope::show();

Add colors to elements

VolumeMesh::addVertexColorQuantity(std::string name, const T& data)

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

  • data is the array of colors at vertices. The type should be adaptable to a 3-vector array of floats. The length should be the number of vertices in the mesh.

RGB values are interpreted in the range [0,1].

VolumeMesh::addCellColorQuantity(std::string name, const T& data)

Add a color quantity defined at the faces of the mesh.

  • data is the array of colors at faces. The type should be adaptable to a 3-vector array of floats. The length should be the number of cells (tets, hexes, etc) in the mesh.

RGB values are interpreted in the range [0,1].

Color Quantity Options

These options and behaviors are available for all types of color quantities on any structure.

Parameter Meaning Getter Setter Persistent?
enabled is the quantity enabled? bool isEnabled() setEnabled(bool newVal) yes

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