diff --git a/source/RobotAPI/components/ArViz/Client/elements/MeshCGALExtensions.h b/source/RobotAPI/components/ArViz/Client/elements/MeshCGALExtensions.h index 577ba25a95805bf2b9e10b7df56da568c8eca0ac..f00061ea4c9114c06981863032cca209a4240806 100644 --- a/source/RobotAPI/components/ArViz/Client/elements/MeshCGALExtensions.h +++ b/source/RobotAPI/components/ArViz/Client/elements/MeshCGALExtensions.h @@ -1,8 +1,11 @@ #pragma once +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" #include <CGAL/Polyhedron_3.h> #include <CGAL/Surface_mesh/Surface_mesh.h> #include <CGAL/boost/graph/iterator.h> +#pragma GCC diagnostic pop #include "Mesh.h" diff --git a/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h b/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h index c0051c7f4c1824538eb531976e2125defef6c0c4..2fd6529f564cc3990082fd25d0caeae351b900b8 100644 --- a/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h +++ b/source/RobotAPI/components/ArViz/Client/elements/PointCloud.h @@ -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> diff --git a/source/RobotAPI/components/ArViz/Introspection/json_elements.cpp b/source/RobotAPI/components/ArViz/Introspection/json_elements.cpp index 219a5d5821f4a4748fccbd65b481d549affbddd9..14feae3fd2b3eaa0e1f62d02c26dea5dc67659c7 100644 --- a/source/RobotAPI/components/ArViz/Introspection/json_elements.cpp +++ b/source/RobotAPI/components/ArViz/Introspection/json_elements.cpp @@ -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) {