Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8556

C++ Array of ON_PointCloud

$
0
0

Dear @dale

I would like to ask how can I correctly create an array of pointclouds?

The code below crashes Rhino.
What I want to do is:

  1. Create n ON_PointCloud
  2. Iterate that array and insert points to that pointclouds based on “vector” called cluster.
  3. Bake the pointscloud to rhino.

This is my code that crash rhino, I am sure I am missing some basic C++ lessons:

   //allocate the array
   int n = groups.size();
   ON_PointCloud* arr = new ON_PointCloud[n];

   int counter = 0;
   for(auto it = cluster.begin(); it != cluster.end(); ++it) { //cluster is a vector of integeres
       int id = *it;
       ON_3dPoint p = *cloud->m_P.At(counter);
       arr[id].AppendPoint( p );
       counter++;
    }

     //It already crashes here
     //Iterate pointclouds and add them to rhino
     for(int i = 0; i < n; i++){
        CRhinoPointCloudObject* cloudNew_obj = new CRhinoPointCloudObject();
        cloudNew_obj->SetPointCloud(arr[i]);
        context.m_doc.AddObject(cloudNew_obj);
        context.m_doc.Redraw();
      }

       delete[] arr;

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 8556

Trending Articles