Skip to content
Snippets Groups Projects
Commit 53f95bf8 authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Merge branch 'master' of gitlab.com:ArmarX/RobotAPI

parents 863ae93c dfc699d0
No related branches found
No related tags found
No related merge requests found
......@@ -58,19 +58,21 @@ namespace armarx::viz
p.color = color;
return addPoint(p);
}
PointCloud& addPoint(float x, float y, float z, const simox::color::Color& color)
PointCloud& addPoint(float x, float y, float z, const simox::Color& color)
{
return addPoint(x, y, z, Color{color});
}
PointCloud& addPoint(float x, float y, float z, std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a = 255)
template <typename ColorCoeff = int>
PointCloud & addPoint(float x, float y, float z, ColorCoeff r, ColorCoeff g, ColorCoeff b, ColorCoeff a = 255)
{
return addPoint(x, y, z, Color{r, g, b, a});
return addPoint(x, y, z, simox::Color(r, g, b, a));
}
PointCloud& addPoint(float x, float y, float z)
{
return addPoint(x, y, z, 0, 0, 0, 255);
return addPoint(x, y, z, simox::Color::black(255));
}
PointCloud& addPoint(float x, float y, float z, std::size_t id, int alpha = 255)
......@@ -91,7 +93,7 @@ namespace armarx::viz
std::enable_if_t < detail::has_members_rgba<PointT>::value, int> = 0>
PointCloud & addPoint(const PointT& p)
{
return addPoint(p.x, p.y, p.z, p.r, p.g, p.b, p.a);
return addPoint(p.x, p.y, p.z, simox::Color(p.r, p.g, p.b, p.a));
}
template < class PointT >
......@@ -100,6 +102,8 @@ namespace armarx::viz
return addPoint(p.x, p.y, p.z, color);
}
/// Draw a point cloud.
template <class PointCloudT>
PointCloud& pointCloud(const PointCloudT& cloud, bool checkFinite = true)
{
......@@ -114,6 +118,22 @@ namespace armarx::viz
return *this;
}
/// Draw a point cloud with fixed color.
template <class PointCloudT>
PointCloud& pointCloud(const PointCloudT& cloud, Color color, bool checkFinite = true)
{
clear();
for (const auto& p : cloud)
{
if (isfinite(p, checkFinite))
{
addPoint(p, color);
}
}
return *this;
}
/// Draw a point cloud with given indices.
template <class PointCloudT>
PointCloud& pointCloud(const PointCloudT& cloud, const std::vector<int>& indices,
bool checkFinite = true)
......@@ -121,7 +141,7 @@ namespace armarx::viz
clear();
for (int i : indices)
{
ARMARX_CHECK_FITS_SIZE(i, int(cloud.size()));
ARMARX_CHECK_FITS_SIZE(i, cloud.size());
const auto& p = cloud.at(size_t(i));
if (isfinite(p, checkFinite))
{
......@@ -131,11 +151,32 @@ namespace armarx::viz
return *this;
}
/// Draw a point cloud with given indices and fixed color.
template <class PointCloudT>
PointCloud& pointCloud(const PointCloudT& cloud, const std::vector<int>& indices,
Color color, bool checkFinite = true)
{
clear();
for (int i : indices)
{
ARMARX_CHECK_FITS_SIZE(i, cloud.size());
const auto& p = cloud.at(size_t(i));
if (isfinite(p, checkFinite))
{
addPoint(p, color);
}
}
return *this;
}
PointCloud& pointSizeInPixels(float s)
{
data_->pointSizeInPixels = s;
return *this;
}
private:
template <class PointT>
......
......@@ -154,8 +154,10 @@ namespace armarx::viz
j["pointSizeInPixels"] = pointCloud.pointSizeInPixels;
j["# Points"] = pointCloud.points.size();
j[json::meta::KEY]["# Points"] = json::meta::READ_ONLY;
j["Points[0:10]"] = ColoredPointList(pointCloud.points.begin(),
pointCloud.points.begin() + std::min(size_t(10), pointCloud.points.size()));
}
void data::from_json(const nlohmann::json& j, ElementPointCloud& pointCloud)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment