Iterate throug ccPointCloud Object

Feel free to ask any question here
Post Reply
SimoneTeruggi
Posts: 5
Joined: Wed Jan 22, 2020 10:15 pm

Iterate throug ccPointCloud Object

Post by SimoneTeruggi »

Hi,
first of all nice to meet you, it is my first time writing on this forum and I'm not really sure to be asking in the right place.
By the wy:
I am trying to implement a plug in in CC and there is the need to iterate through a ccPointCloud Object to store points coordinates and scalar fields to an array. The pointcloud I got from this pice of code:

Code: Select all

ccPointCloud* qMLtrainingTools::GetCloudFromCombo(QComboBox* comboBox, ccHObject* dbRoot)
{
	assert(comboBox && dbRoot);
	if (!comboBox || !dbRoot)
	{
		assert(false);
		return nullptr;
	}

	//return the cloud currently selected in the combox box
	int index = comboBox->currentIndex();
	if (index < 0)
	{
		assert(false);
		return nullptr;
	}
	unsigned uniqueID = comboBox->itemData(index).toUInt();
	ccHObject* item = dbRoot->find(uniqueID);
	if (!item || !item->isA(CC_TYPES::POINT_CLOUD))
	{
		assert(false);
		return nullptr;
	}
	return static_cast<ccPointCloud*>(item);
}
This is needed since I have a dialog window on which thereis a ComboBox with wich i select the point cloud.
I have seen that the SimpleCloud object has the possibility to iterate throug the points and get coordinates as well as scalar field value, but the #include <SimplePointCloud.h> isn't there anymore... Furthermore I do not know if there is a way to convert a ccPointCloud to a SimplePointCloud object.

Do you have any suggestion on how to proceed?

Thank you very much in advance for your kind attention.

Simone
daniel
Site Admin
Posts: 7707
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Iterate throug ccPointCloud Object

Post by daniel »

Well the 'SimpleCloud' is now simply CCLib::PointCloud (and it's not that simple).

But actually, you can use the ccPointCloud instance directly (it has the same features). It inherits the 'GenericPointCloud' and 'GenericIndexedPointCloud' interfaces for instances.
Daniel, CloudCompare admin
SimoneTeruggi
Posts: 5
Joined: Wed Jan 22, 2020 10:15 pm

Re: Iterate throug ccPointCloud Object

Post by SimoneTeruggi »

I am really sorry but I am a littel of a novice and I do not get it.

It seems I am not able to use the GenericCloud GetPoint() on this:

Code: Select all

ccPointCloud* cloudTraining = tDlg.getTrainingCloud();
which actually comes from here:

Code: Select all

ccPointCloud* qTrainingDlg::getTrainingCloud()
{
    //return the cloud currently selected in the combox box
    return qMLtrainingTools::GetCloudFromCombo(comboBox_training, m_app->dbRootObject());
}
which uses the GetCloudFromCombo shown before...
daniel
Site Admin
Posts: 7707
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Iterate throug ccPointCloud Object

Post by daniel »

On a ccPointCloud instance, you can use the getPoint(index) method. There's no 'GetPoint' (with a capital G) in CC.
Daniel, CloudCompare admin
Post Reply