add factory ...
parent
caf01fb59f
commit
191ba733b1
|
@ -15,13 +15,8 @@
|
|||
#define DECLARE_SINGLETON(classname) \
|
||||
public: \
|
||||
static classname *Instance() { \
|
||||
static std::unique_ptr<classname> instance{nullptr}; \
|
||||
if (!instance) { \
|
||||
static std::once_flag flag; \
|
||||
std::call_once(flag, \
|
||||
[&] { instance.reset(new (std::nothrow) classname()); }); \
|
||||
} \
|
||||
return instance.get(); \
|
||||
static classname instance; \
|
||||
return &instance; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
|
|
|
@ -74,18 +74,4 @@ Eigen::Vector4d FitPlane(const pcl::PointCloud<PT> &cloud,
|
|||
return coeffs;
|
||||
}
|
||||
|
||||
// template <typename PT>
|
||||
// Eigen::Vector4d FitPlane(const pcl::PointCloud<PT> &cloud) {
|
||||
// Eigen::MatrixX3f A(cloud.size(), 3); // NOLINT
|
||||
// Eigen::VectorXf b(cloud.size());
|
||||
// b.setConstant(-1.0);
|
||||
// size_t i = 0;
|
||||
// for (const auto &p : cloud) {
|
||||
// A.row(i++) << p.x, p.y, p.z;
|
||||
// }
|
||||
// Eigen::Vector3f sol = A.colPivHouseholderQr().solve(b);
|
||||
// Eigen::Vector4d coeff(sol(0), sol(1), sol(2), 1.0);
|
||||
// return coeff / sol.norm();
|
||||
// }
|
||||
|
||||
} // namespace common
|
|
@ -62,7 +62,6 @@ template <typename PT>
|
|||
inline void TransformPointCloud(const Pose3d &pose,
|
||||
const pcl::PointCloud<PT> &cloud_in,
|
||||
pcl::PointCloud<PT> *const cloud_out) {
|
||||
ACHECK(cloud_out);
|
||||
pcl::transformPointCloud(cloud_in, *cloud_out, pose.TransMat().cast<float>());
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ void RemovePoints(const pcl::PointCloud<PT> &cloud_in,
|
|||
}
|
||||
size_t j = 0;
|
||||
for (size_t i = 0; i < cloud_in.size(); ++i) {
|
||||
const auto pt = cloud_in.points[i];
|
||||
const auto &pt = cloud_in.points[i];
|
||||
if (check(pt)) {
|
||||
if (removed_indices) removed_indices->push_back(i);
|
||||
continue;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "common/log/log.h"
|
||||
#include "common/macro/macros.h"
|
||||
|
||||
template <typename BaseClass>
|
||||
class AbstractFactory {
|
||||
virtual ~AbstractFactory() = default;
|
||||
virtual std::shared_ptr<BaseClass> Create() = 0;
|
||||
};
|
||||
|
||||
template <typename BaseClass, typename DerivedClass>
|
||||
class ConcreteFactory {
|
||||
virtual std::shared_ptr<BaseClass> Create() = 0;
|
||||
};
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
namespace common {
|
||||
|
||||
void Timer::Tic() {
|
||||
start_ = std::chrono::system_clock::now();
|
||||
}
|
||||
|
||||
double Timer::Toc(char unit) {
|
||||
ACHECK(unit == 's' || unit == 'm' || unit == 'u')
|
||||
<< "Only 's'(second), 'm'(millisecond) and 'u'(microsecond) are "
|
||||
|
|
|
@ -13,9 +13,7 @@ class Timer {
|
|||
Tic();
|
||||
}
|
||||
|
||||
void Tic() {
|
||||
start_ = std::chrono::system_clock::now();
|
||||
}
|
||||
void Tic();
|
||||
|
||||
// unit: 's' = second, 'm' = millisecond, 'u' = microsecond
|
||||
double Toc(char unit = 'm');
|
||||
|
|
Loading…
Reference in New Issue