Create a new point cloud

Any question about the main GUI application (frontend)
Post Reply
radhikaravi
Posts: 6
Joined: Thu Oct 26, 2017 7:03 pm

Create a new point cloud

Post 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);
	}
}
daniel
Site Admin
Posts: 7381
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Create a new point cloud

Post 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).
Daniel, CloudCompare admin
3224970637
Posts: 1
Joined: Mon Sep 18, 2023 12:18 am

Re: Create a new point cloud

Post 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.
daniel
Site Admin
Posts: 7381
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Create a new point cloud

Post 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).
Daniel, CloudCompare admin
Post Reply