Skip to content

Feature/ rotate clipping planes in volume cropping tool#2547

Merged
wayfarer3130 merged 23 commits intocornerstonejs:mainfrom
mbellehumeur:feat/rotate-clippling-planes
Feb 27, 2026
Merged

Feature/ rotate clipping planes in volume cropping tool#2547
wayfarer3130 merged 23 commits intocornerstonejs:mainfrom
mbellehumeur:feat/rotate-clippling-planes

Conversation

@mbellehumeur
Copy link
Copy Markdown
Contributor

@mbellehumeur mbellehumeur commented Jan 8, 2026

Context

ticket: 18376011052

Changes & Results

feat(volumeCropping): Enhance volume cropping tool with clipping plane functionality and UI improvements

  • Updated the volume cropping tool to include toggles for clipping planes and handles.
  • Improved instructions for user interaction with clipping planes.
  • Added new utility functions for handling clipping planes, including copying and calculating adaptive sphere radius.
  • Introduced constants for clipping plane indices and tolerances.
  • Enhanced the tool's ability to handle rotated volumes and maintain proper clipping plane orientation.
  • Added new utility functions for line intersection and color conversion.
  • Refactored existing code to have one source (ClippingPlanes[]) for the annotation and the events.
image ### Testing

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

… orientation based on image orientation patient values
…e functionality and UI improvements

- Updated the volume cropping tool to include toggles for clipping planes and handles.
- Improved instructions for user interaction with clipping planes.
- Added new utility functions for handling clipping planes, including copying and calculating adaptive sphere radius.
- Introduced constants for clipping plane indices and tolerances.
- Enhanced the tool's ability to handle rotated volumes and maintain proper clipping plane orientation.
- Added new utility functions for line intersection and color conversion.
- Refactored existing code for better clarity and maintainability.
Copy link
Copy Markdown
Contributor

@igoroctaviano igoroctaviano left a comment

Choose a reason for hiding this comment

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

LGTM, left one comment

Comment thread packages/tools/examples/volumeCroppingTool/index.ts Outdated
- Removed redundant code for updating sphere positions and clipping planes.
- Introduced utility methods for better clarity and maintainability.
- Enhanced error handling by using a consistent error variable naming convention.
- Improved the organization of the code related to corner and face sphere calculations.
…state changes

- Added event listener for VOLUMECROPPING_TOOL_CHANGED when the tool is enabled.
- Removed event listener to prevent memory leaks when the tool is disabled.
- Cleaned up commented-out code for better clarity in viewport initialization and tool selection logic.
…ne management

- Introduced utility methods for retrieving volume actors and mappers.
- Simplified clipping plane application logic by consolidating related functionality.
- Improved error handling in viewport retrieval and ensured safe access to viewports info.
- Cleaned up redundant code for better maintainability and clarity.
…ove clarity

- Removed unnecessary comments throughout the code to enhance readability.
- Streamlined the logic for handling annotations and viewport updates.
- Improved organization of event listener management for tool state changes.
Comment thread packages/tools/src/tools/VolumeCroppingTool.ts Outdated
Comment thread packages/tools/src/tools/VolumeCroppingTool.ts Outdated
Comment thread packages/tools/src/utilities/draw3D/addLine3DBetweenPoints.ts
Comment thread packages/tools/src/utilities/volumeCropping/calculateNewCornerPosition.ts Outdated
Comment thread packages/core/src/utilities/convertColorArrayToRgbString.ts
Comment thread packages/tools/src/utilities/volumeCropping/extractVolumeDirectionVectors.ts Outdated
Comment thread packages/tools/src/utilities/volumeCropping/extractVolumeDirectionVectors.ts Outdated
Comment thread packages/tools/src/utilities/volumeCropping/findLineBoundsIntersection.ts Outdated
Comment thread packages/tools/src/utilities/volumeCropping/findLineBoundsIntersection.ts Outdated
Comment thread packages/tools/src/utilities/volumeCropping/getOrientationFromNormal.ts Outdated
Comment thread packages/tools/src/utilities/volumeCropping/getOrientationFromNormal.ts Outdated
Copy link
Copy Markdown
Collaborator

@wayfarer3130 wayfarer3130 left a comment

Choose a reason for hiding this comment

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

A few changes to simplify things and move them into packages to be shared.

@wayfarer3130
Copy link
Copy Markdown
Collaborator

For the example, can you add shift+drag to rotate the crop mapping

@wayfarer3130 wayfarer3130 merged commit a1dfbd0 into cornerstonejs:main Feb 27, 2026
10 checks passed
wayfarer3130 added a commit that referenced this pull request Apr 10, 2026
* feat(rendering): Add function to calculate acquisition plane reformat orientation based on image orientation patient values

* feat(volumeCropping): Enhance volume cropping tool with clipping plane functionality and UI improvements

- Updated the volume cropping tool to include toggles for clipping planes and handles.
- Improved instructions for user interaction with clipping planes.
- Added new utility functions for handling clipping planes, including copying and calculating adaptive sphere radius.
- Introduced constants for clipping plane indices and tolerances.
- Enhanced the tool's ability to handle rotated volumes and maintain proper clipping plane orientation.
- Added new utility functions for line intersection and color conversion.
- Refactored existing code for better clarity and maintainability.

* refactor(getCameraVectors): Remove unused getAcquisitionPlaneReformatOrientation function and its documentation

* refactor(volumeCroppingTool): Remove commented-out code and improve clarity in clipping plane updates

* Removed 'virtual' annotations from control tool -remnamnts from the crosshair tool

* refactor(volumeCroppingTool): Remove commented-out code for clarity in toggle button functionality

* refactor(volumeCroppingControlTool): Remove unused methods and variables

* refactor(volumeCroppingTool): Simplify sphere and clipping plane updates

- Removed redundant code for updating sphere positions and clipping planes.
- Introduced utility methods for better clarity and maintainability.
- Enhanced error handling by using a consistent error variable naming convention.
- Improved the organization of the code related to corner and face sphere calculations.

* refactor(volumeCroppingControlTool): Manage event listeners for tool state changes

- Added event listener for VOLUMECROPPING_TOOL_CHANGED when the tool is enabled.
- Removed event listener to prevent memory leaks when the tool is disabled.
- Cleaned up commented-out code for better clarity in viewport initialization and tool selection logic.

* refactor(volumeCroppingTool): Enhance code structure for clipping plane management

- Introduced utility methods for retrieving volume actors and mappers.
- Simplified clipping plane application logic by consolidating related functionality.
- Improved error handling in viewport retrieval and ensured safe access to viewports info.
- Cleaned up redundant code for better maintainability and clarity.

* refactor(volumeCroppingControlTool): Clean up commented code and improve clarity

- Removed unnecessary comments throughout the code to enhance readability.
- Streamlined the logic for handling annotations and viewport updates.
- Improved organization of event listener management for tool state changes.

* Applied Agents.md

* Use existing ImageToWorld

* refactor(VolumeCroppingTool): Simplify diagonal calculation using vec3.distance

* refactor(VolumeCroppingTool): Replace manual normalization with vec3.normalize for direction vectors

* refactor(VolumeCroppingTool): Remove calculateNewCornerPosition function and simplify corner position calculation

* refactor(VolumeCroppingTool): Optimize line extension calculation using vec3.scaleAndAdd

* refactor(VolumeCroppingTool): Enhance orientation detection by utilizing vec3.dot for improved accuracy

* refactor(VolumeCroppingTool): Modularize 3D drawing utilities by adding addLine3DBetweenPoints and calculateAdaptiveSphereRadius functions

* feat(colorUtilities): Add convertColorArrayToRgbString utility and integrate it into core package

* feat(volumeCroppingTool): Add shift-drag to ratate the clipping planes

---------

Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
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.

3 participants