Ported Slic3r::BridgeDetector to XS

This commit is contained in:
Alessandro Ranellucci 2014-11-15 22:41:22 +01:00
parent 36825e0134
commit 379cde30e2
22 changed files with 539 additions and 307 deletions

View file

@ -1,4 +1,5 @@
#include "Geometry.hpp"
#include "ExPolygon.hpp"
#include "Line.hpp"
#include "PolylineCollection.hpp"
#include "clipper.hpp"
@ -111,6 +112,37 @@ directions_parallel(double angle1, double angle2, double max_diff)
return diff < max_diff || fabs(diff - PI) < max_diff;
}
template<class T>
bool
contains_point(const std::vector<T> &vector, const Point &point)
{
for (typename std::vector<T>::const_iterator it = vector.begin(); it != vector.end(); ++it) {
if (it->contains_point(point)) return true;
}
return false;
}
template bool contains_point(const ExPolygons &vector, const Point &point);
double
rad2deg(double angle)
{
return angle / PI * 180.0;
}
double
rad2deg_dir(double angle)
{
angle = (angle < PI) ? (-angle + PI/2.0) : (angle + PI/2.0);
if (angle < 0) angle += PI;
return rad2deg(angle);
}
double
deg2rad(double angle)
{
return PI * angle / 180.0;
}
Line
MedialAxis::edge_to_line(const VD::edge_type &edge) const
{