Hide points - option

Any question about the main GUI application (frontend)
Post Reply
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Hide points - option

Post by vinayan »

hi Daniel,

I am trying to hide a few points in my cloud. The user would select point on the cloud using mouse and that point should be invisible now. I have checked the ccGenericPointCloud and graphicalsegmentationTool source. It seems I can only hide once using the existing methods. If i want to hide again, I need to call resetTheVisibilityArray() which will make the previously hidden points visible.

Below code hides a single point on a mouse click. But if i try to hide another point later, the previously hidden points become visible(obviously since I called the resetVisiblityArray). Are there options to keep on making points invisible? If nothing exist please suggest ideas where I can get it done by modifying the core.

In another words , getTheVisibilityArray() is always null unless i explicitly call resetVisibilityArray().

Code: Select all

void myPlugin::hideSelectedPoint(ccHObject* entity, unsigned itemIndex, int x, int y, const CCVector3& P)
{
	if (!entity)
	{
		return;
	}

	if (entity->isKindOf(CC_TYPES::POINT_CLOUD))
	{
		ccGenericPointCloud* cloud = ccHObjectCaster::ToGenericPointCloud(entity);
		cloud->resetVisibilityArray();	 // any alternatives other than resetting the whole visibility?

		ccGenericPointCloud::VisibilityTableType* visibilityArray = cloud->getTheVisibilityArray();

		visibilityArray->setValue(itemIndex, POINT_HIDDEN );		
	}

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

Re: Hide points - option

Post by daniel »

You should first test if 'getTheVisibilityArray' returns a non null pointer. In this case this means the visibility array has already been allocated and you don't need to call 'resetVisibilityArray'. You can directly call visibilityArray->setValue.

You only need to call 'resetVisibilityArray' if the visibility array is not enabled yet.

Mind that to work properly, your plugin should restore the original state of the cloud at one point in time (with unallocateVisibilityArray).
Daniel, CloudCompare admin
vinayan
Posts: 27
Joined: Thu Nov 03, 2016 4:11 pm

Re: Hide points - option

Post by vinayan »

that worked!! although I am yet to understand what will happen if i do not set unallocateVisibilityArray. Hopefully a scenario would popup as I use the plugin and help me solve the problem. Thank you.
daniel
Site Admin
Posts: 7332
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Hide points - option

Post by daniel »

In this vase the points will remain invisible which may be confusing for the user. Invisible points are not deleted. Once done you should create a new cloud for instance (with the visible subset - there's a dedicated method to do this) and restore the original cloud visibility for instance.

But it all depend on what you are trying to achieve of course ;)
Daniel, CloudCompare admin
Post Reply