Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classmethod to read pvcc paraview #3662

Merged
merged 5 commits into from
Dec 13, 2022

Conversation

beroda
Copy link
Contributor

@beroda beroda commented Nov 30, 2022

Overview

This PR implements a classmethod to pyvista.Camera that reads a Paraview camera file (.pvcc).

It looks like:

camera = pyvista.Camera.from_paraview_pvcc("file.pvcc")

See attached pvcc file as example (outputted with Paraview 5.10).

<PVCameraConfiguration description="ParaView camera configuration" version="1.0">
  <Proxy group="views" type="RenderView" id="6395" servers="21">
    <Property name="CameraPosition" id="6395.CameraPosition" number_of_elements="3">
      <Element index="0" value="10.519087611966333"/>
      <Element index="1" value="40.74973775632195"/>
      <Element index="2" value="-20.24019652397463"/>
    </Property>
    <Property name="CameraFocalPoint" id="6395.CameraFocalPoint" number_of_elements="3">
      <Element index="0" value="15.335762892470676"/>
      <Element index="1" value="-26.960151717473682"/>
      <Element index="2" value="17.860905595181094"/>
    </Property>
    <Property name="CameraViewUp" id="6395.CameraViewUp" number_of_elements="3">
      <Element index="0" value="0.2191945908188539"/>
      <Element index="1" value="-0.4665856879512876"/>
      <Element index="2" value="-0.8568847805596613"/>
    </Property>
    <Property name="CenterOfRotation" id="6395.CenterOfRotation" number_of_elements="3">
      <Element index="0" value="15.039424359798431"/>
      <Element index="1" value="-7.047080755233765"/>
      <Element index="2" value="6.712674975395203"/>
    </Property>
    <Property name="RotationFactor" id="6395.RotationFactor" number_of_elements="1">
      <Element index="0" value="1"/>
    </Property>
    <Property name="CameraViewAngle" id="6395.CameraViewAngle" number_of_elements="1">
      <Element index="0" value="30"/>
    </Property>
    <Property name="CameraParallelScale" id="6395.CameraParallelScale" number_of_elements="1">
      <Element index="0" value="20.147235678333413"/>
    </Property>
    <Property name="CameraParallelProjection" id="6395.CameraParallelProjection" number_of_elements="1">
      <Element index="0" value="0"/>
      <Domain name="bool" id="6395.CameraParallelProjection.bool"/>
    </Property>
  </Proxy>
</PVCameraConfiguration>

@github-actions github-actions bot added the enhancement Changes that enhance the library label Nov 30, 2022
@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Merging #3662 (b8b405e) into main (f5dbce8) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3662      +/-   ##
==========================================
+ Coverage   94.05%   94.06%   +0.01%     
==========================================
  Files          83       83              
  Lines       18558    18614      +56     
==========================================
+ Hits        17454    17510      +56     
  Misses       1104     1104              

@beroda
Copy link
Contributor Author

beroda commented Dec 2, 2022

It might be interesting to implement the possibility to output a .pvcc file such that:

camera = pyvista.Camera()
camera.to_paraview_pvcc("file.pvcc")

I will implement-it shortly.

@beroda beroda marked this pull request as ready for review December 8, 2022 20:18
Copy link
Member

@banesullivan banesullivan left a comment

Choose a reason for hiding this comment

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

Thank you for implementing this, @beroda! This PR has minimal impact on the rest of the code base and you've included excellent docstrings and tests, so I'm happy to merge this!

@banesullivan banesullivan merged commit 824c78a into pyvista:main Dec 13, 2022
@beroda beroda deleted the feat/paraview_camera branch December 13, 2022 16:16
@banesullivan banesullivan mentioned this pull request Feb 1, 2023
5 tasks
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.

None yet

2 participants