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:
- Create n ON_PointCloud
- Iterate that array and insert points to that pointclouds based on “vector” called cluster.
- 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;