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

Property point_normals does not return active normals #6061

Closed
user27182 opened this issue May 9, 2024 · 1 comment · Fixed by #6062
Closed

Property point_normals does not return active normals #6061

user27182 opened this issue May 9, 2024 · 1 comment · Fixed by #6062
Labels
bug Uh-oh! Something isn't working as expected.

Comments

@user27182
Copy link
Contributor

user27182 commented May 9, 2024

Describe the bug, what's wrong, and what you expected.

If I set custom point normals, e.g. to [0, 0, 1] for all points, I would expect the point_normals property to return these custom normals. Instead, it computes new normals:

from pyvista import examples
mesh = examples.load_airplane()
mesh['scalars'] = range(mesh.n_points)

normals = [[0, 0, 1]] * mesh.n_points
mesh.point_data['CustomNormals'] = normals
mesh.point_data.active_normals_name = 'CustomNormals'

# Expected normal:  [0, 0, 1]
mesh.point_normals[0]  # actual normal: [ 0.00288475 -0.51048446  0.8598821 ]

# Normals are correctly set in the attributes:
mesh.point_data
# pyvista DataSetAttributes
# Association     : POINT
# Active Scalars  : scalars
# Active Vectors  : None
# Active Texture  : None
# Active Normals  : CustomNormals
# Contains arrays :
#     scalars                 int64      (1335,)              SCALARS
#     CustomNormals           int64      (1335, 3)            NORMALS

The issue is that point_normals doesn't get the active normals, it just gets an array named 'Normals'. I believe it should return the active normals instead, regardless of name.

See #6058 (reply in thread) for context.

Steps to reproduce the bug.

See above

System Information

OS : Darwin
            CPU(s) : 8
           Machine : arm64
      Architecture : 64bit
               RAM : 16.0 GiB
       Environment : IPython
       File system : apfs
        GPU Vendor : Apple
      GPU Renderer : Apple M2
       GPU Version : 4.1 Metal - 88
  MathText Support : True
  Python 3.12.2 (v3.12.2:6abddd9f6a, Feb  6 2024, 17:02:06) [Clang 13.0.0
  (clang-1300.0.29.30)]
           pyvista : 0.44.dev0
               vtk : 9.3.0
             numpy : 1.26.4
        matplotlib : 3.8.2
            scooby : 0.9.2
             pooch : 1.8.0
            pillow : 10.2.0
           imageio : 2.34.0
           IPython : 8.21.0
          colorcet : 3.1.0
           cmocean : 3.1.3
        ipywidgets : 8.1.2
             scipy : 1.12.0
              tqdm : 4.66.2
            meshio : 5.3.5
        jupyterlab : 4.1.4
    pytest_pyvista : 0.1.8
             trame : 3.5.3
      trame_client : 2.16.1
      trame_server : 2.17.2
         trame_vtk : 2.8.5
     trame_vuetify : 2.4.3
      nest_asyncio : 1.6.0
--------------------------------------------------------------------------------

Screenshots

No response

@user27182 user27182 added the bug Uh-oh! Something isn't working as expected. label May 9, 2024
@user27182
Copy link
Contributor Author

I think this is a duplicate of #2921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
1 participant