Measuring: added getters for circle visualization
This commit is contained in:
parent
7d6d33f92c
commit
457afca5de
3 changed files with 36 additions and 5 deletions
|
@ -262,7 +262,7 @@ void MeasuringImpl::extract_features()
|
|||
for (const auto& [start_idx, end_idx] : circles) {
|
||||
std::pair<Vec3d, double> center_and_radius = get_center_and_radius(border, start_idx, end_idx, trafo);
|
||||
plane.surface_features.emplace_back(std::unique_ptr<SurfaceFeature>(
|
||||
new Circle(center_and_radius.first, center_and_radius.second)));
|
||||
new Circle(center_and_radius.first, center_and_radius.second, plane.normal)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -382,6 +382,15 @@ double Measuring::get_distance(const SurfaceFeature* feature, const Vec3d* pt)
|
|||
Eigen::ParametrizedLine<double, 3> line(s, (e-s).normalized());
|
||||
return line.distance(*pt);
|
||||
}
|
||||
else if (feature->get_type() == SurfaceFeatureType::Circle) {
|
||||
const Circle* circle = static_cast<const Circle*>(feature);
|
||||
// Find a plane containing normal, center and the point.
|
||||
const Vec3d& c = circle->get_center();
|
||||
const Vec3d& n = circle->get_normal();
|
||||
Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
||||
Vec3d proj = circle_plane.projection(*pt);
|
||||
return std::sqrt( std::pow((proj - c).norm() - circle->get_radius(), 2.) + (*pt - proj).squaredNorm());
|
||||
}
|
||||
|
||||
return std::numeric_limits<double>::max();
|
||||
}
|
||||
|
|
|
@ -28,22 +28,28 @@ public:
|
|||
class Edge : public SurfaceFeature {
|
||||
public:
|
||||
Edge(const Vec3d& start, const Vec3d& end) : m_start{start}, m_end{end} {}
|
||||
Edge(const Vec3d& start, const Vec3d& end, const Vec3d& pin) : m_start{start}, m_end{end},
|
||||
m_pin{std::unique_ptr<Vec3d>(new Vec3d(pin))} {}
|
||||
SurfaceFeatureType get_type() const override { return SurfaceFeatureType::Edge; }
|
||||
std::pair<Vec3d, Vec3d> get_edge() const { return std::make_pair(m_start, m_end); }
|
||||
private:
|
||||
Vec3d m_start;
|
||||
Vec3d m_end;
|
||||
std::unique_ptr<Vec3d> m_pin;
|
||||
};
|
||||
|
||||
class Circle : public SurfaceFeature {
|
||||
public:
|
||||
Circle(const Vec3d& center, double radius) : m_center{center}, m_radius{radius} {}
|
||||
Circle(const Vec3d& center, double radius, const Vec3d& normal)
|
||||
: m_center{center}, m_radius{radius}, m_normal{normal} {}
|
||||
SurfaceFeatureType get_type() const override { return SurfaceFeatureType::Circle; }
|
||||
Vec3d get_center() const { return m_center; }
|
||||
double get_radius() const { return m_radius; }
|
||||
Vec3d get_normal() const { return m_normal; }
|
||||
private:
|
||||
Vec3d m_center;
|
||||
double m_radius;
|
||||
Vec3d m_normal;
|
||||
};
|
||||
|
||||
class Plane : public SurfaceFeature {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue