How does the “Trace a polyline by point picking” tool implement line marking in the code?
How does the “Trace a polyline by point picking” tool implement line marking in the code?
hello,
I want to know how this tool draws lines,
My personal understanding is to select two dots, and there's a function that connects the two dots (similar to pcl's addLine) https://pointclouds.org/documentation/c ... 03550ecab5
But I didn't find anything relevant in the code.
Can you tell me how to draw the line.
thanks~
I want to know how this tool draws lines,
My personal understanding is to select two dots, and there's a function that connects the two dots (similar to pcl's addLine) https://pointclouds.org/documentation/c ... 03550ecab5
But I didn't find anything relevant in the code.
Can you tell me how to draw the line.
thanks~
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Well, in its basic form, the tool allows you to pick points on a cloud or on a mesh. And then it simply connects two consecutive points by straights segments (= polyline).
But there's an 'oversample' option that will generate intermediate points and try to stick them to the surface as well.
I don't know how the PCL function works, sorry.
But there's an 'oversample' option that will generate intermediate points and try to stick them to the surface as well.
I don't know how the PCL function works, sorry.
Daniel, CloudCompare admin
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Thank you for your answer,
Which code implements this step?
"It's just a straight line that connects two consecutive points."
I want to choose two points in a cloud of points and connect a line between them. How do I do that in code?
Which code implements this step?
"It's just a straight line that connects two consecutive points."
I want to choose two points in a cloud of points and connect a line between them. How do I do that in code?
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Oh that's a 'simple' construction of a ccPolyline instance.
If it's only a few known points, it's especially easy: https://github.com/CloudCompare/CloudCo ... g.cpp#L269
If you want them to add them on the file each time the user picks a point, then you have to manage the memory (by resizing the underlying cloud).
If it's only a few known points, it's especially easy: https://github.com/CloudCompare/CloudCo ... g.cpp#L269
If you want them to add them on the file each time the user picks a point, then you have to manage the memory (by resizing the underlying cloud).
Daniel, CloudCompare admin
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
I'm sorry, I looked at the source code and didn't find the right way,
If there are two dots (-34, 12, 8) and (12, -2, 9) how do I connect them with a red line,
Can you teach me how to write this code?
Thank you very much.
If there are two dots (-34, 12, 8) and (12, -2, 9) how do I connect them with a red line,
Can you teach me how to write this code?
Thank you very much.
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Well, it would be something like that:
Code: Select all
ccPointCloud* vertices = new ccPointCloud("vertices");
ccPolyline* polyline = new ccPolyline(vertices);
if (!vertices->reserve(2) || !polyline->reserve(2))
{
ccLog::Error("Not enough memory!");
delete vertices;
delete polyline;
return;
}
vertices->addPoint(CCVector3(-34, 12, 8));
vertices->addPoint(CCVector3(12, -2, 9));
polyline->addPointIndex(0, 2);
polyline->setVisible(true);
polyline->setColor(0, 0, 255);
vertices->setEnabled(false);
polyline->addChild(vertices);
Daniel, CloudCompare admin
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Thank you for your help.
I was able to draw a line successfully with your code.
But I need to add at the end
before it can be displayed.
But there seems to be a problem with the code to set the color.
If I write directly
there is an error
I wrote it as
Or
Neither can display the color.
I was able to draw a line successfully with your code.
But I need to add at the end
Code: Select all
MainWindow::TheInstance()->addToDB(polyline);
But there seems to be a problem with the code to set the color.
If I write directly
Code: Select all
polyline->setColor(0, 0, 255);
Code: Select all
error: no matching function for call to 'ccPolyline::setColor(int, int, int)'
polyline->setColor(0, 0, 255);
Code: Select all
ccColor::Rgb col = ccColor::Generator::Random();
polyline->setColor(col);
Code: Select all
ccColor::Rgb col;
col.r=0;
col.g=0;
col.b=255;
polyline->setColor(col);
- Attachments
-
- DeepinScreenshot_select-area_20210531153432.png (12.74 KiB) Viewed 3907 times
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Ah ok, it could be also 'polyline->setColor(ccColor::Rgb(0, 0, 255));' I guess then.
Have you called showColor(true) afterwards?
Have you called showColor(true) afterwards?
Daniel, CloudCompare admin
Re: How does the “Trace a polyline by point picking” tool implement line marking in the code?
Thank you very much.
Perfect solution to my problem
In fact, he's got the color, but he doesn't show it.
polyline->showColors(true);
That's why he shows the color by default.
Perfect solution to my problem
In fact, he's got the color, but he doesn't show it.
polyline->showColors(true);
That's why he shows the color by default.