Skip to content

Edit mode with boundary cell selection, ID assignment and save#4

Merged
luca-heltai merged 8 commits into
mainfrom
boundary_id_assignment
Mar 8, 2026
Merged

Edit mode with boundary cell selection, ID assignment and save#4
luca-heltai merged 8 commits into
mainfrom
boundary_id_assignment

Conversation

@pcolt

@pcolt pcolt commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • See all exterior boundary cells (including those not explicitly in the file)
  • Click-select individual boundary cells
  • Assign BoundaryID values to selected cells
  • Save the result as .vtu

Key design points

  • Exterior edge extraction: For each volume cell, enumerates sub-cells (edges in 2D, faces in 3D). Sub-cells shared by exactly 1 volume cell are exterior boundary.
  • Interior boundary preservation: File boundary cells that are interior (shared by 2 volume cells, like deal.II's inner ring markers) are preserved in the merged dataset.
  • Picking: Uses vtkCellPicker with PickFromListOn() restricted to the boundary actor, triggered via interactor observer on LeftButtonPressEvent.
  • No changes to vtk_pipeline.py: The existing visualization pipeline is untouched; edit mode uses its own actors.

Data flow

File load → build_visualization() [existing]
         → extract_all_boundary_subcells(full_dataset) [new]
         → build_merged_boundary_dataset() [new]
         → actors added to renderer (hidden)

Edit ON  → show merged_bnd_actor, hide original bnd_actor
         → install pick observer on interactor

Click    → observer fires → vtkCellPicker.Pick() → toggle cell in selection_set
         → update_selection_actor() → render

Assign   → modify BoundaryID array on merged_bnd_dataset
         → rebuild LUT + coloring → clear selection → render

Save     → combine vol cells + edited bnd cells → write .vtu

Edit OFF → hide merged actors, restore original bnd_actor
Screencast.from.2026-03-05.13-06-51.webm

@pcolt
pcolt requested a review from luca-heltai March 5, 2026 12:09
@pcolt

pcolt commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

Few fixes are probably needed like updating the legend color bar after a new boundary Id with new color is assigned

@pcolt

pcolt commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

Legend update was fixed

Screencast.from.2026-03-05.16-52-41.webm

@pcolt

pcolt commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator Author

Group selection by adjacency with angle threshold was added. I would need few simple 3D grids in .vtk/.vtu format to test those new features for 3D grids too.

Group selection by connectivity and angle threshold

  1. Adjacency graph (build_adjacency_graph): iterates every cell in the merged boundary dataset and records its edges.
    Cells sharing an edge become neighbors. For 1-D cells (boundary lines in 2-D meshes) the key is a single shared point.

  2. Cell normals (compute_cell_normals): for each 2-D cell, computes the cross product of two edge vectors from its first three vertices and normalizes it. For 1-D line cells it produces the 2-D perpendicular in the XY plane.

  3. Flood-fill (flood_select): BFS starting from the clicked cell. A neighbor is added to the selection only if the absolute value of the dot product between the two neighbor cells is greater than the cosine of the threshold angle.

Pick / Rotate mode toggle

Previously, left-click camera rotation was fully disabled in edit mode to avoid conflicts with cell picking. Now a Pick / Rotate toggle appears at the top of the edit drawer.

Screencast.from.2026-03-06.17-21-24.webm
Screencast.from.2026-03-06.17-21-50.webm

@luca-heltai

Copy link
Copy Markdown
Contributor

With 2listic/coral#50 you should be able to generate 3d grids with the dealii backend.

@luca-heltai luca-heltai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on this, but it is usable, and I like it. For me, it is a go.

@luca-heltai
luca-heltai merged commit 37c1bac into main Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants