Page 1 of 1

Iterate throug ccPointCloud Object

Posted: Wed Jan 22, 2020 10:24 pm
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

Re: Iterate throug ccPointCloud Object

Posted: Wed Jan 22, 2020 11:06 pm
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.

Re: Iterate throug ccPointCloud Object

Posted: Thu Jan 23, 2020 9:06 am
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...

Re: Iterate throug ccPointCloud Object

Posted: Thu Jan 23, 2020 9:42 pm
by daniel
On a ccPointCloud instance, you can use the getPoint(index) method. There's no 'GetPoint' (with a capital G) in CC.