Skip to content

Commit

Permalink
Merge pull request #7 from rerun-io/emilk/code-cleanup
Browse files Browse the repository at this point in the history
Slight code cleanup
  • Loading branch information
emilk authored Oct 27, 2023
2 parents 0977050 + 98cfc94 commit 8e11fe7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>

#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Dense>
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
Expand All @@ -9,42 +10,41 @@

// Adapters so we can log eigen vectors as rerun positions:
template <>
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<Eigen::Vector3f>> {
struct rerun::ComponentBatchAdapter<rerun::Position3D, std::vector<Eigen::Vector3f>> {
// Sanity check that this is binary compatible.
static_assert(sizeof(components::Position3D) == sizeof(Eigen::Vector3f));
static_assert(alignof(components::Position3D) <= alignof(Eigen::Vector3f));
static_assert(sizeof(rerun::Position3D) == sizeof(Eigen::Vector3f));
static_assert(alignof(rerun::Position3D) <= alignof(Eigen::Vector3f));

ComponentBatch<components::Position3D> operator()(const std::vector<Eigen::Vector3f>& container
) {
return ComponentBatch<components::Position3D>::borrow(
reinterpret_cast<const components::Position3D*>(container.data()),
ComponentBatch<rerun::Position3D> operator()(const std::vector<Eigen::Vector3f>& container) {
return ComponentBatch<rerun::Position3D>::borrow(
reinterpret_cast<const rerun::Position3D*>(container.data()),
container.size()
);
}

ComponentBatch<components::Position3D> operator()(std::vector<Eigen::Vector3f>&& container) {
ComponentBatch<rerun::Position3D> operator()(std::vector<Eigen::Vector3f>&& container) {
throw std::runtime_error("Not implemented for temporaries");
}
};

// Adapters so we can log an eigen matrix as rerun positions:
template <>
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, Eigen::Matrix3Xf> {
struct rerun::ComponentBatchAdapter<rerun::Position3D, Eigen::Matrix3Xf> {
// Sanity check that this is binary compatible.
static_assert(
sizeof(components::Position3D) ==
sizeof(rerun::Position3D) ==
sizeof(Eigen::Matrix3Xf::Scalar) * Eigen::Matrix3Xf::RowsAtCompileTime
);
static_assert(alignof(components::Position3D) <= alignof(Eigen::Matrix3Xf));
static_assert(alignof(rerun::Position3D) <= alignof(Eigen::Matrix3Xf));

ComponentBatch<components::Position3D> operator()(const Eigen::Matrix3Xf& matrix) {
return ComponentBatch<components::Position3D>::borrow(
reinterpret_cast<const components::Position3D*>(matrix.data()),
ComponentBatch<rerun::Position3D> operator()(const Eigen::Matrix3Xf& matrix) {
return ComponentBatch<rerun::Position3D>::borrow(
reinterpret_cast<const rerun::Position3D*>(matrix.data()),
matrix.cols()
);
}

ComponentBatch<components::Position3D> operator()(std::vector<Eigen::Matrix3Xf>&& container) {
ComponentBatch<rerun::Position3D> operator()(std::vector<Eigen::Matrix3Xf>&& container) {
throw std::runtime_error("Not implemented for temporaries");
}
};
Expand Down

0 comments on commit 8e11fe7

Please sign in to comment.