DGtal 2.1.0
Loading...
Searching...
No Matches
PolyscopeViewer.h
1
15#pragma once
16
28#include "DGtal/io/Display3D.h"
29
30#include "polyscope/polyscope.h"
31
32#include "polyscope/curve_network.h"
33#include "polyscope/surface_mesh.h"
34#include "polyscope/volume_mesh.h"
35#include "polyscope/volume_grid.h"
36#include "polyscope/point_cloud.h"
37#include "polyscope/pick.h"
38
39namespace DGtal {
40 namespace drawutils {
41 // @brief Convert a DGtal color to a glm color
42 glm::vec3 toglm(const DGtal::Color& col);
43
44 // @brief Convert a vector of DGtal color to a vector of glm color
45 std::vector<glm::vec3> toglm(const std::vector<DGtal::Color>& col);
46
47 // @brief Convert an Eigen transform to glm matrix
48 glm::mat4 toglm(const Eigen::Affine3d& transform);
49 }
50
51 template < typename Space = Z3i::Space, typename KSpace = Z3i::KSpace>
52 class PolyscopeViewer : public Display3D<Space, KSpace> {
53 public:
55 polyscope::init();
56 }
57
59 polyscope::init();
60 }
61
62 // @brief Clear the view (ie. remove all polyscope structures)
63 void clearView() override {
64 polyscope::removeAllStructures();
65 }
66
67 // @brief Starts event loop (first render data)
68 void show() override {
71
72 polyscope::show();
73 }
74
75 // @brief Render new data
76 void renderNewData() override;
77
78 // @brief setCallback
79 void setCallback(typename Display3D<Space, KSpace>::Callback* callback) override;
80
81 // @brief Renders the clipping planes
83
85 this->clear();
86 }
87
88 public:
89 static constexpr double BallToCubeRatio = 0.025;
90 static constexpr double VectorScale = 1. / 30.;
91
92 private:
93 void setGeneralProperties(polyscope::Structure* s, const DisplayData<typename Space::RealPoint>& d);
94
95 void registerPointCloud (const std::string& n, const DisplayData<typename Space::RealPoint>& d);
96 void registerLineNetwork(const std::string& n, const DisplayData<typename Space::RealPoint>& d);
97 void registerSurfaceMesh(const std::string& n, const DisplayData<typename Space::RealPoint>& d);
98 void registerVolumeMesh (const std::string& n, const DisplayData<typename Space::RealPoint>& d);
99
100 // @brief Global callback handling UI, click and callback calls
102 };
103}
104
105#include "PolyscopeViewer.ih"
Structure representing an RGB triple with alpha component.
Definition Color.h:77
Base class for viewing DGtal objects.
Definition Display3D.h:381
virtual void clear()
Clear the viewer, including screen and internal data.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
void registerVolumeMesh(const std::string &n, const DisplayData< typename Space::RealPoint > &d)
void setGeneralProperties(polyscope::Structure *s, const DisplayData< typename Space::RealPoint > &d)
void setCallback(typename Display3D< Space, KSpace >::Callback *callback) override
void registerPointCloud(const std::string &n, const DisplayData< typename Space::RealPoint > &d)
void show() override
Starts the event loop and display of elements.
static constexpr double BallToCubeRatio
void clearView() override
Clear the screen.
PolyscopeViewer(const KSpace &k)
void registerSurfaceMesh(const std::string &n, const DisplayData< typename Space::RealPoint > &d)
void registerLineNetwork(const std::string &n, const DisplayData< typename Space::RealPoint > &d)
void renderNewData() override
Renders newly added data.
static constexpr double VectorScale
glm::vec3 toglm(const DGtal::Color &col)
DGtal is the top-level namespace which contains all DGtal functions and types.
A general callback for the viewer to give control to the user.
Definition Display3D.h:408
Data required to display an object.
Definition Display3D.h:247