Page 1 of 1

Create a new point cloud

Posted: Sat May 05, 2018 12:35 am
by radhikaravi
Hi, I have integrates an interface that I have developed with CloudCompare. So, in my interface, I have stereo-images and I use them to get 3D coordinates of any point. I want to know if there's any way I can create a new point cloud consisting this point and display it in CC as a new point cloud? Something like how the points are displayed on using "Point List Picking" tool, except that the points are totally new and do not belong to any already displayed point cloud.
Could you maybe point me in the right direction for which function in CC actually handles the highlighting of a point? I am providing a snippet of my code which is able to create labels for any clicked point with its 3D coordinates. This just creates the labels. I am unable to set a position on the screen for them because for that, I need to know where the 3D coordinates would appear among the already existing point clouds. How do I proceed further?

Code: Select all

void displayIntersectedPointInCC(Vector3d point)
{
	if (!cloudCreated)
	{
		cloud = new ccPointCloud();
		cloudCreated = true;
	}
	int count = intersectedObjectPoints.size();
	if (cloud->reserve(count))
	{
		cloud->setName("Intersected Points");
		cloud->setDisplay(associatedCloud->getDisplay());
		cloud->setGlobalShift(associatedCloud->getGlobalShift());
		cloud->setGlobalScale(associatedCloud->getGlobalScale());

		const CCVector3* P = new CCVector3{ static_cast<float>(point[0]), static_cast<float>(point[1]), static_cast<float>(point[2]) };
		cloud->addPoint(*P);

		MainWindow::TheInstance()->addToDB(cloud);

		if (!intersectedPointsContainerCreated)
		{
			intersectedPointsContainerCreated = true;
			intersectedPointsContainer = new ccHObject("Intersected Points");
			cloud->addChild(intersectedPointsContainer);
			intersectedPointsContainer->setDisplay(cloud->getDisplay());
			MainWindow::TheInstance()->addToDB(intersectedPointsContainer, false, true, false, false);
		}
		intersectedPointsContainer->a
		cc2DLabel* newLabel = new cc2DLabel();
		newLabel->addPoint(cloud, 0);
		newLabel->setVisible(true);
		newLabel->setDisplayedIn2D(false);
		newLabel->displayPointLegend(true);
		newLabel->setCollapsed(false);
		newLabel->setDisplay(cloud->getDisplay());

		assert(intersectedPointsContainer);
		intersectedPointsContainer->addChild(newLabel);
		MainWindow::TheInstance()->addToDB(newLabel, false, true, false, false);
	}
}

Re: Create a new point cloud

Posted: Sat May 05, 2018 7:42 am
by daniel
Oh you mean that you want to create a 2D point? I think the best way would be to actually draw a small cross, made of two orthogonal polylines. Because polylines can be displayed in 2D (i.e. in this case their vertices are expressed in pixel coordinates). See how 2D polylines are handled in the ccTracePolylineTool class for instance (especially the 'm_polyTipVertices' member).

Re: Create a new point cloud

Posted: Mon Sep 18, 2023 12:31 am
by 3224970637
Have you get it? I meet the same trouble on creating a new point cloud in my plugin. I need to creat a new point cloud and it must be empty that I could add points in it, but i was stuck in creating.

Re: Create a new point cloud

Posted: Mon Sep 18, 2023 6:23 am
by daniel
Doesn't look like the same issue to me?

To create a new point cloud, simply call:

Code: Select all

ccPointCloud* cloud = new ccPointCloud("name_of_your_cloud");
Then you have to 'reserve' some space before inserting points (with ccPointCloud::reserve).