Skip to content

fix: recompute axes grid bounds when switching files#2988

Draft
soumyasavarn wants to merge 12 commits into
f3d-app:masterfrom
soumyasavarn:fix/axes-grid-not-recomputed-on-file-switch
Draft

fix: recompute axes grid bounds when switching files#2988
soumyasavarn wants to merge 12 commits into
f3d-app:masterfrom
soumyasavarn:fix/axes-grid-not-recomputed-on-file-switch

Conversation

@soumyasavarn

@soumyasavarn soumyasavarn commented Mar 30, 2026

Copy link
Copy Markdown

Describe your changes

GridAxesConfigured was not being reset when the importer changed on file switch, so ConfigureGridAxesUsingCurrentActors() was never re-called with the new file's bounds. Added this->GridAxesConfigured = false; alongside the existing this->GridConfigured = false; in UpdateActors() in vtkext/private/module/vtkF3DRenderer.cxx.

Issue ticket number and link if any

Fixes #2963

Checklist for finalizing the PR

  • I have performed a self-review of my code
  • I have added tests for new features and bugfixes
  • I have added documentation for new features
  • If it is a modifying the libf3d API, I have updated bindings
  • If it is a modifying the .github/workflows/versions.json, I have updated docker_timestamp

AI Disclosure

  • I did not use AI to generate any of the content of that pull request
  • I used AI to generate code in that pull request, if yes please disclose which part of the code was generated and with which model.
  • ...

Continuous integration

Please write a comment to run CI, eg: \ci fast.
See here for more info.

GridAxesConfigured was not being reset when the importer changed
(i.e. on file switch), so ConfigureGridAxesUsingCurrentActors()
was never re-called. Add GridAxesConfigured = false alongside
the existing GridConfigured = false in UpdateActors().

Fixes f3d-app#2963
@soumyasavarn

Copy link
Copy Markdown
Author

\ci fast

@mwestphal mwestphal self-requested a review March 30, 2026 09:49
@soumyasavarn soumyasavarn marked this pull request as ready for review March 30, 2026 09:49
Comment thread application/testing/tests.interaction.cmake Outdated

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one small change

@soumyasavarn soumyasavarn marked this pull request as draft March 30, 2026 11:42
Comment thread vtkext/private/module/vtkF3DRenderer.cxx Outdated
Comment thread application/testing/tests.interaction.cmake Outdated
soumyasavarn and others added 3 commits March 30, 2026 17:32
removed unnecessary comment

Co-authored-by: Mathieu Westphal <mwestphal.f3d@protonmail.com>
Co-authored-by: Mathieu Westphal <mwestphal.f3d@protonmail.com>
@soumyasavarn soumyasavarn marked this pull request as ready for review March 30, 2026 12:43
@soumyasavarn soumyasavarn requested a review from mwestphal March 31, 2026 04:07
Comment thread testing/baselines/TestInteractionAxesGridSwitchFile.png Outdated
Comment thread application/testing/tests.interaction.cmake

@mwestphal mwestphal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the feature doesnt seem to work yet.

@soumyasavarn soumyasavarn marked this pull request as draft March 31, 2026 07:45
@soumyasavarn

Copy link
Copy Markdown
Author

@mwestphal I tested with the "F3D-3.4.1-147-g30c7f045-Windows-x86_64-raytracing":

  • dragon.vtu alone with --axes-grid → correctly centered
  • cow.vtp + dragon.vtu, pressing Right to switch → axes grid disappears completely

My fix makes the grid reappear on switch, but the bounds show -58 to 100
instead of the expected -100 to 100. Could this be related to actor transforms
being different when dragon is loaded as the second file vs first file?
Or is there something else that needs resetting on file switch?

@mwestphal

Copy link
Copy Markdown
Member

@mwestphal I tested with the "F3D-3.4.1-147-g30c7f045-Windows-x86_64-raytracing":

* dragon.vtu alone with --axes-grid → correctly centered

* cow.vtp + dragon.vtu, pressing Right to switch → axes grid disappears completely

My fix makes the grid reappear on switch, but the bounds show -58 to 100 instead of the expected -100 to 100. Could this be related to actor transforms being different when dragon is loaded as the second file vs first file? Or is there something else that needs resetting on file switch?

It looks like the bounds computation is not correct for some reason, so you need to dig into that.

@mwestphal

Copy link
Copy Markdown
Member

@soumyasavarn Merge branch 'f3d-app:master' into fix/axes-grid-not-recomputed-on-fi…

Please do not merge with master, but use rebase instead, and only when needed.

@soumyasavarn soumyasavarn force-pushed the fix/axes-grid-not-recomputed-on-file-switch branch from 4398688 to d3e2e36 Compare March 31, 2026 17:57
@mwestphal

Copy link
Copy Markdown
Member

Hi @soumyasavarn , do you need help moving forward ?

@soumyasavarn

Copy link
Copy Markdown
Author

Hi @soumyasavarn , do you need help moving forward ?

Yes, a little guidance is needed. As of now only that one line fix is what I figured out is necessary "this->GridAxesConfigured = false;" in the updateActors(). Like, what amount of fix would be there as I am new to this codebase. Meanwhile, I will be unavailable for a week. If someone else wants to work on this you can let him.

Resetting GridAxesConfigured alone left coloring/visibility/mapper state
from the previous file, so ComputeVisiblePropOrientedBounds reported a
clipped bbox for the new file (dragon.vtu after cow.vtp showed
Z bounds of -58..100 instead of -100..100). Reset all derived
*Configured flags when the importer changes, request whole-extent
before alg->Update so streaming readers like vtkXMLUnstructuredGridReader
report full bounds rather than piece 0, and reset the missing flags in
Initialize() for symmetry.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@soumyasavarn soumyasavarn force-pushed the fix/axes-grid-not-recomputed-on-file-switch branch from c96b6e4 to c24ded7 Compare May 4, 2026 04:50
@mwestphal

Copy link
Copy Markdown
Member

Like, what amount of fix would be there as I am new to this codebase

I'm afraid this would require some investigation to figure out. Do your one line fix work as expected ?

Meanwhile, I will be unavailable for a week. If someone else wants to work on this you can let him.

No worries, it can wait.

soumyasavarn and others added 2 commits May 4, 2026 08:42
The previous attempt called vtkStreamingDemandDrivenPipeline::SetUpdateExtentToWholeExtent
on an instance with an int argument; that overload does not exist (it
is a static method taking vtkInformation*) and broke the build.
vtkAlgorithm::UpdateWholeExtent does the equivalent in one call and
works for both extent- and piece-based pipelines.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ComputeVisiblePropOrientedBounds iterates renderer Props whose visibility
and mapper inputs depend on per-file-switch state, so it returned a
clipped bbox after the cow.vtp -> dragon.vtu switch. Use
vtkF3DMetaImporter::GetGeometryBoundingBox instead - the importer
maintains the union of imported surface bounds and is authoritative
regardless of prop visibility ordering. Transform the 8 corners through
the env-up matrix to support non-axis-aligned up directions. Also revert
the speculative UpdateWholeExtent call in ComputeVisiblePropOrientedBounds
(that path is now only used by the floor grid, which was unaffected).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@soumyasavarn

Copy link
Copy Markdown
Author

Do your one line fix work as expected ?

Yes, without that the axes didn't appear.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Style Checks CI failed:

diff --git a/vtkext/private/module/vtkF3DRenderer.cxx b/vtkext/private/module/vtkF3DRenderer.cxx
index a98fe9f..b334ca8 100644
--- a/vtkext/private/module/vtkF3DRenderer.cxx
+++ b/vtkext/private/module/vtkF3DRenderer.cxx
@@ -978,12 +978,10 @@ void vtkF3DRenderer::ConfigureGridAxesUsingCurrentActors()
     {
       double bnds[6];
       importerBbox.GetBounds(bnds);
-      const double corners[8][3] = {
-        { bnds[0], bnds[2], bnds[4] }, { bnds[1], bnds[2], bnds[4] },
-        { bnds[0], bnds[3], bnds[4] }, { bnds[1], bnds[3], bnds[4] },
-        { bnds[0], bnds[2], bnds[5] }, { bnds[1], bnds[2], bnds[5] },
-        { bnds[0], bnds[3], bnds[5] }, { bnds[1], bnds[3], bnds[5] }
-      };
+      const double corners[8][3] = { { bnds[0], bnds[2], bnds[4] }, { bnds[1], bnds[2], bnds[4] },
+        { bnds[0], bnds[3], bnds[4] }, { bnds[1], bnds[3], bnds[4] }, { bnds[0], bnds[2], bnds[5] },
+        { bnds[1], bnds[2], bnds[5] }, { bnds[0], bnds[3], bnds[5] },
+        { bnds[1], bnds[3], bnds[5] } };
       for (int i = 0; i < 8; ++i)
       {
         double p[4] = { corners[i][0], corners[i][1], corners[i][2], 1.0 };

@mwestphal

Copy link
Copy Markdown
Member

HI @soumyasavarn

It looks lke you are using Generative AI for coding, please note in the MR description how it was used and which model in compliance with our AI policy: https://f3d.app/dev/AI_POLICY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Axes grid is not recomputed when switching file

2 participants