Basic_viewer: colour faces by value (distance, cell size, and a drawer value) - #9598
Open
RajdeepKushwaha5 wants to merge 13 commits into
Open
Basic_viewer: colour faces by value (distance, cell size, and a drawer value)#9598RajdeepKushwaha5 wants to merge 13 commits into
RajdeepKushwaha5 wants to merge 13 commits into
Conversation
Member
|
Successfully tested in CGAL-6.3-Ic-52 |
Member
|
@gdamiand I'm waiting for your approval to merge it. |
|
This pull-request was previously marked with the label |
… mesh aspect ratio)
…he distance legend
…ace_value, set_face_value)
… right-aligned so it fits
RajdeepKushwaha5
force-pushed
the
colour-by-value
branch
from
August 17, 2026 09:31
90b0aff to
3164f46
Compare
…ce mesh In whole-volume clipping the surface-mesh path (no volumes to keep or hide) drew every face with a plain glDrawArrays, so it ignored the drawer's per-face value: the colour stayed on distance and did not change when switching to the aspect ratio, and did not update when the plane moved. Draw that path the same way the main renderer does, per face with u_CellValue, so the drawer value applies here too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small feature
This PR adds a small feature to the public API: a drawer can attach a scalar value to each face, which the Basic_viewer maps to a colour palette, mirroring the existing colour path.
New API:
Graphics_scene_options:valued_face(does this face have a value),face_value(the value),face_value_name(the legend label).Graphics_scene:set_face_value(float),set_value_name(const std::string&).Purpose: mesh-quality visualisation. The viewer cannot compute a quality measure itself (it only has the boundary triangles); each drawer can. The surface mesh drawer uses this to expose the aspect ratio of each face.
Scope: small and additive. It mirrors
colored_face/face_color, defaults to off (no value), and changes no existing behaviour.Description
This adds an automatic colouring of the faces by a value, mapped to a colour from a palette, discussed with the mentors as a follow-up to the clipping work.
Palette (D key). D turns the colouring on and cycles the palette: off, then a heat, a jet, a grey ramp and viridis (a perceptually uniform map). The palette is evaluated in the face shader, so there is no texture.
Value (Shift+D key). Shift+D picks the value, skipping the ones that do not apply to the scene:
Distance is computed live in the shader from the clipping plane the user places with Ctrl+C. Distance and size are normalised over the range actually present in the scene, so the whole palette is used.
A value from the drawer. Following Guillaume's suggestion, the viewer does not have to compute geometric values itself. A drawer can attach a scalar value to each face, the same way it attaches a colour: the graphics-scene options gain valued_face / face_value / face_value_name, the scene stores the value next to the colour, and the viewer maps it to the palette. As the example, the surface mesh viewer exposes the aspect ratio (longest edge / shortest edge) of each face. This is the general mechanism for mesh-quality colouring (aspect ratio, Jacobian, and so on), with each drawer computing what its mesh allows.
Legend. A small legend is drawn when the colouring is on: a gradient bar in the current palette with the value range, labelled by the drawer's name (or distance / size). It uses the same range and palette as the faces, so the two match, and it is hidden when the value has no range (a uniform field).
The Basic_viewer part is contained in Basic_shaders.h and Basic_viewer.h. The value mechanism also touches Graphics_scene.h, Graphics_scene_options.h, the face-graph drawer (BGL/draw_face_graph.h), and the surface mesh drawer.
Testing: verified on grids of hexahedra (Linear_cell_complex) and on triangle meshes (Surface_mesh). The values and palettes behave as described, the per-cell and per-face modes read as flat blocks, the colours span the full palette with the legend matching the values present (including as the clipping plane is moved and rotated), the drawer-provided aspect ratio colours the surface mesh with a named legend, and the colouring holds in every clipping mode.
Note on next step (Guillaume's suggestion)
The value mechanism generalises the built-in size and enables mesh-quality colouring per data structure. The surface mesh aspect ratio is the first example; values on volumes (set_volume_val) and other measures are natural follow-ups.