Page 1 of 1
Adding 2D label (picked point) between two already picked
Posted: Wed Feb 20, 2013 7:29 am
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?
Re: Adding 2D label (picked point) between two already picke
Posted: Wed Feb 20, 2013 8:04 am
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?)
Re: Adding 2D label (picked point) between two already picke
Posted: Wed Feb 20, 2013 9:19 am
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:
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?
Re: Adding 2D label (picked point) between two already picke
Posted: Wed Feb 20, 2013 12:37 pm
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.
Re: Adding 2D label (picked point) between two already picke
Posted: Sat Feb 23, 2013 9:23 pm
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?
Re: Adding 2D label (picked point) between two already picke
Posted: Sun Feb 24, 2013 7:50 am
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:
Re: Adding 2D label (picked point) between two already picke
Posted: Sun Feb 24, 2013 11:16 am
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)
Am i missing something?
Re: Adding 2D label (picked point) between two already picke
Posted: Sun Feb 24, 2013 12:29 pm
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).
Re: Adding 2D label (picked point) between two already picke
Posted: Sun Feb 24, 2013 1:10 pm
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)