Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tkoyama010
Copy link
Member

Summary

This PR adds support for the vtkAxisAlignedReflectionFilter introduced in VTK 9.5, which reflects datasets across axis-aligned planes.

Key Changes

  • Add VTK 9.5 import for vtkAxisAlignedReflectionFilter in _vtk_core.py
  • Implement reflect_axis_aligned() method in DataObjectFilters class
  • Add comprehensive tests with proper VTK version checking
  • Include example script demonstrating usage

Implementation Details

The new reflect_axis_aligned() method:

  • Reflects datasets across YZ, XZ, or XY planes
  • Supports configurable plane position via value parameter
  • Returns a MultiBlock containing reflection and optionally the original
  • Includes options for array reflection control
  • Has proper VTK 9.5+ version checking

Example Usage

import pyvista as pv

# Create a mesh
mesh = pv.Cube(center=(2, 0, 0))

# Reflect across YZ plane at x=1.0
reflected = mesh.reflect_axis_aligned(plane='x', value=1.0)

# Result is a MultiBlock with original and reflection
print(f"Blocks: {reflected.n_blocks}")  # Output: Blocks: 2

Testing

  • Added tests for all three reflection planes (x, y, z)
  • Tests for copy_input parameter behavior
  • Tests for invalid plane argument handling
  • Tests for VTK version error on older versions
  • Tests for vector data reflection

Notes

  • This filter requires VTK 9.5 or later
  • The filter properly handles all VTK dataset types
  • Documentation is included in the method docstring

🤖 Generated with Claude Code

tkoyama010 and others added 4 commits July 18, 2025 08:41
- Add VTK 9.5 import for vtkAxisAlignedReflectionFilter
- Implement reflect_axis_aligned() method in DataObjectFilters
- Add comprehensive tests with VTK version checking
- Create example demonstrating the new filter

The filter reflects datasets across axis-aligned planes (YZ, XZ, or XY)
and returns a MultiBlock containing the reflection and optionally the
original input.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove separate example file
- Enhance docstring examples with more detailed output
- Show bounds comparison between original and reflected meshes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@tkoyama010 tkoyama010 changed the title feat: Add reflect_axis_aligned() method for VTK 9.5+ axis-aligned reflection filter Add reflect_axis_aligned() method for VTK 9.5+ axis-aligned reflection filter Jul 17, 2025
Add noqa comment to suppress "too many positional arguments" warning
following the same pattern as other methods in the codebase.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@tkoyama010 tkoyama010 marked this pull request as draft July 17, 2025 23:56
@tkoyama010 tkoyama010 requested a review from Copilot July 17, 2025 23:56
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the vtkAxisAlignedReflectionFilter introduced in VTK 9.5, which provides axis-aligned reflection capabilities for PyVista datasets. The implementation allows users to reflect datasets across YZ, XZ, or XY planes with configurable positioning and output options.

  • Adds VTK 9.5+ import for vtkAxisAlignedReflectionFilter
  • Implements reflect_axis_aligned() method in DataObjectFilters class with comprehensive parameter support
  • Includes thorough test coverage with proper VTK version handling

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pyvista/core/_vtk_core.py Adds conditional import for VTK 9.5+ vtkAxisAlignedReflectionFilter
pyvista/core/filters/data_object.py Implements the new reflect_axis_aligned() method with full documentation
tests/core/test_dataobject_filters.py Comprehensive test suite covering all functionality and edge cases
Comments suppressed due to low confidence (1)

tests/core/test_dataobject_filters.py:1335

  • Using random data for testing vector reflection makes the test non-deterministic. Consider using a fixed seed with np.random.seed() or using deterministic test data to ensure consistent test results.
    mesh['vectors'] = np.random.rand(mesh.n_points, 3)

@pyvista-bot pyvista-bot added the enhancement Changes that enhance the library label Jul 17, 2025
Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 17.14286% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.27%. Comparing base (a9e1d5c) to head (b69ac93).
⚠️ Report is 1 commits behind head on main.

❌ Your patch check has failed because the patch coverage (17.14%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7724      +/-   ##
==========================================
- Coverage   96.39%   96.27%   -0.12%     
==========================================
  Files         150      150              
  Lines       32609    32644      +35     
  Branches     4109     4115       +6     
==========================================
- Hits        31432    31428       -4     
- Misses        572      605      +33     
- Partials      605      611       +6     

tkoyama010 and others added 5 commits July 19, 2025 06:02
Replace deprecated np.random.rand call with modern np.random.default_rng().random()
to fix NPY002 ruff linting error.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Replace plane index mapping with explicit vtkPlane configuration. This change
creates a reflection plane with proper normal and origin settings based on
the specified axis and value, improving clarity and maintainability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@user27182
Copy link
Contributor

I have not looked at this closely but this may be similar to reflect_x , reflect_y, reflect_z , might be good to add cross references and highlight the key difference(s) somewhere

@tkoyama010 tkoyama010 changed the title Add reflect_axis_aligned() method for VTK 9.5+ axis-aligned reflection filter Add reflect_axis_aligned as axis-aligned reflection filter Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants