@@ -25,15 +25,46 @@ struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<E
25
25
}
26
26
};
27
27
28
+ template <>
29
+ struct rerun ::ComponentBatchAdapter<rerun::components::Position3D, Eigen::MatrixX3f> {
30
+ // Sanity check that this is binary compatible.
31
+ /* static_assert(sizeof(components::Position3D) == sizeof(Eigen::Vector3f)); ?? */
32
+ /* static_assert(alignof(components::Position3D) <= alignof(Eigen::Vector3f)); */
33
+
34
+ ComponentBatch<components::Position3D> operator ()(const Eigen::MatrixX3f &matrix
35
+ ) {
36
+ return ComponentBatch<components::Position3D>::borrow (
37
+ reinterpret_cast <const components::Position3D *>(matrix.data ()),
38
+ matrix.rows ()
39
+ );
40
+ }
41
+
42
+ ComponentBatch<components::Position3D> operator ()(std::vector<Eigen::MatrixX3f> &&container) {
43
+ throw std::runtime_error (" Not implemented for temporaries" );
44
+ }
45
+ };
46
+
47
+ std::vector<Eigen::Vector3f> generate_random_points_vector (int num_points) {
48
+ std::vector<Eigen::Vector3f> points (num_points);
49
+ for (auto & point : points) {
50
+ point.setRandom ();
51
+ }
52
+ return points;
53
+ }
54
+
28
55
int main () {
29
- auto rec = rerun::RecordingStream (" rerun_external_cpp_app " );
56
+ auto rec = rerun::RecordingStream (" rerun_cpp_example_opencv_eigen " );
30
57
rec.connect (" 127.0.0.1:9876" ).throw_on_failure ();
31
58
59
+ const int num_points = 1000 ;
60
+
32
61
// Points represented by std::vector<Eigen::Vector3f>
33
- std::vector<Eigen::Vector3f> points3d_eigen{{ 0 . 1f , 0 . 1f , 0 . 1f }} ;
34
- rec.log (" random " , rerun::Points3D (points3d_eigen ));
62
+ auto points3d_vector = generate_random_points_vector ( 1000 ) ;
63
+ rec.log (" points_from_vector " , rerun::Points3D (points3d_vector ));
35
64
36
- // Points represented by Nx3 Eigen::Mat...
65
+ // Points represented by Eigen::MatX3f (Nx3 matrix)
66
+ Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random (num_points, 3 );
67
+ rec.log (" points_from_matrix" , rerun::Points3D (points3d_matrix));
37
68
38
69
// Image
39
70
std::string image_path = " rerun-logo.png" ;
0 commit comments