Page 1 of 1

get the point cloud in the window

Posted: Mon Mar 21, 2016 12:40 pm
by zzwbeyond
Hello everyone,

I create my plugin in CC, and I want to get the point cloud in the window with my plugin. But I can't get using follow code:

Code: Select all

	m_activeWindow = m_app->getActiveGLWindow();	
	winDBRoot = m_activeWindow->getOwnDB();
	globalDBRoot = m_activeWindow->getSceneDB();
	
	ccHObject::Container toProcess;
	if (winDBRoot) {
		toProcess.push_back(winDBRoot);
	}
	if (globalDBRoot) {
		toProcess.push_back(globalDBRoot);
	}

	while (!toProcess.empty()) {
		ccHObject* ent = toProcess.back();
		toProcess.pop_back();

		if (!ent->isEnabled())
			continue;

		if (ent->isVisible()) {
			if (ent->isA(CC_TYPES::POINT_CLOUD)) {
				ccLog::Warning("point cloud is found!");
			}
		} 
	}
Is there something wrong with my code? And how can I do to get the point cloud in the cloudcompare window?

Re: get the point cloud in the window

Posted: Mon Mar 21, 2016 3:28 pm
by daniel
You should look at how the other plugins work. For instance qHPR or qRANSAC_SD:
https://github.com/cloudcompare/trunk/b ... D.cpp#L111

Code: Select all

	const ccHObject::Container& selectedEntities = m_app->getSelectedEntities();
	size_t selNum = selectedEntities.size();
	if (selNum!=1)
	{
		m_app->dispToConsole("Select only one cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
		return;
	}

	ccHObject* ent = selectedEntities[0];
	assert(ent);
	if (!ent || !ent->isA(CC_TYPES::POINT_CLOUD))
	{
		m_app->dispToConsole("Select a real point cloud!",ccMainAppInterface::ERR_CONSOLE_MESSAGE);
		return;
	}

	ccPointCloud* pc = static_cast<ccPointCloud*>(ent);

Re: get the point cloud in the window

Posted: Mon Mar 21, 2016 4:01 pm
by zzwbeyond
Thanks, daniel.
I know this method, but I do not want to select the point cloud in my plugin. Is there some way to acquire the point cloud in the window without selecting the point cloud?

Re: get the point cloud in the window

Posted: Mon Mar 21, 2016 4:23 pm
by daniel
You mean that you want to get any cloud loaded in the DB tree?

In this case you can ask to the 'm_app' instance (ccMainAppInterface) the 'root' object of the DB tree with the 'dbRootObject' method.

You can then recursively search for all point clouds children (see the 'ccHObject::filterChildren' method).