Adding 2D label (picked point) between two already picked

Any question about the main GUI application (frontend)
Post Reply
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Adding 2D label (picked point) between two already picked

Post by eimixas »

Could be added 2D label (picked point) between two already picked points (in middle or some other ratio)?
I do calculations, i get XYZ, but i cant find any cc2DLabel contstructor that could take such parameters.
As every 2D label has to be associated with point in point cloud, so is it impossible to add this way?

Same question is about adding 2D label on position there "picked point" has projection on some plane?
daniel
Site Admin
Posts: 7396
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Adding 2D label (picked point) between two already picke

Post by daniel »

Labels to measure the distance between two points already exist (you can interactively create them with the 'Point picking' tool, and programmatically by adding two points in the same label (see ccLabel::addPoint).

For the other question, I'm not sure to understand it, sorry! (maybe you can provide me with a drawing?)
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Adding 2D label (picked point) between two already picke

Post by eimixas »

Yes i know about measuring distance between two points.
But i need third point between two. I will measure distance from that point to other point or plane.

And here is picture about second question:
Image
Plane is drawn on points 1, 2 and 4.
Point 3 is in middle between 1 and 2.
Point 5 is outside plane #1.
Point 6 is on plane and vector#1 intersection. (vector#1 is on point 5 and is perpendicular to plane#1)

I caculate XYZ of Point 6, and i need "point" on that position.

I could start using primitives "spheres" for "picked points" representation in CC, but is there way to add text labels near all primitives?
daniel
Site Admin
Posts: 7396
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Adding 2D label (picked point) between two already picke

Post by daniel »

You can create a new cloud with the points you want to attach labels to? This cloud doesn't need to be visible (+ it can be a child of another one).

And the only text label that is available is for picked points.
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Adding 2D label (picked point) between two already picke

Post by eimixas »

Could i add point to existing cloud?
I get execution error on code like this:

Code: Select all

		if (Cloud->resize(Cloud->capacity() + 1))
		{
			Cloud->addPoint(Points[2]);		<-- this line throws error
			...
		}
should be resize called or reserve?
or new must be created?

And how to get index of last added point?
daniel
Site Admin
Posts: 7396
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Adding 2D label (picked point) between two already picke

Post by daniel »

If you 'resize' a cloud, it will be filled with (0,0,0) points. You can then change those points coordinates, but it's not very clean.

You should call 'reserve' here (it only allocates memory to add points later). Then your code should work.

And 'cloud->size()' returns the current number of points, while 'capacity()' returns the maximum number of points. So the last inserted point index is:

Code: Select all

int index = (int)cloud->size()-1;
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Adding 2D label (picked point) between two already picke

Post by eimixas »

Tried, it works, new point is added to cloud, and i can create 2d label on that point:

Code: Select all

		if (Cloud->reserve(Cloud->size() + 1))
		{
			Cloud->addPoint(Points[2]);

			cc2DLabel *middlePoint = new cc2DLabel();
			middlePoint->addPoint(Cloud, Cloud->size() - 1);
			middlePoint->setDisplay(Cloud->getDisplay());
			middlePoint->setVisible(Cloud->isVisible());
			middlePoint->setDisplayedIn2D(false);
			middlePoint->setName(NewName);
			Parent->addChild(middlePoint);
			m_app->addToDB(middlePoint);
			//m_app->setSelectedInDB(middlePoint, true);
		}
but if i select that new 2d label in DB tree or in rendered "view" - i get error:
(last row is commented because of that)
Image

Am i missing something?
daniel
Site Admin
Posts: 7396
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Adding 2D label (picked point) between two already picke

Post by daniel »

Your cloud seems to have normals.

So you must also add a normal for the new point (and if your cloud has color or SFs you must also add those).
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Adding 2D label (picked point) between two already picke

Post by eimixas »

added:

Code: Select all

			Cloud->addPoint(Points[2]);
			Cloud->addNorm(0, 0, 0);
works fine. no colors or scalar fields needed. (point cloud is from imported *.stl mesh)
Post Reply