Skip to content

Fails to Account for non-matching Normals Vector Size #212

Open

Description

@Andr3wPearce

Within the pybind11 folder, the following code is found for the ccPointCloudPy.normalsFromNPArray_copy:

if (!self.hasNormals())
        self.reserveTheNormsTable();
    const PointCoordinateType *s = reinterpret_cast<const PointCoordinateType*>(array.data());
    for (size_t i=0; i<self.size(); ++i)
    {
        const CCVector3& N = reinterpret_cast<const CCVector3&>(s[3*i]);
        CCVector3 NN = N;
        NN.normalize();
        self.setPointNormal(i, NN);
    }

When I export a cloud from CloudCompare, it has a normals vector with a shape of (1). I'm not entirely sure why this is, but to fix, the code just needs to check the size of the previous normals and confirm they match the shape expected(which is (N, 3)).

Activity

  1. prascle commented on Sep 1, 2025

    @prascle
    Collaborator

    Hello,
    Back on CloudComPy after a long summer break. I hope you have resolved your issue.
    When using cloudComPy to obtain a Numpy array from normals, if the cloud does not contain normals, the result is a normal vector of shape (1): see ccPointCloudPy.normalsToNpArray_copy in the pybind11 folder. I think that's the case for you. You must first create normals with cloudComPy.
    When the cloud contains normals, the result is a normal vector of shape (number of points, 3): see test054.py in the examples.

    The piece of code you provide is used to define the normals in the cloud from a numpy array.

    If this does not answer your question, please let me know.

    Regards,
    Paul

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions