Removed the Point::wkt() and Point::dump_perl() methods.
Added to_string() for the basis Eigen vector types.
This commit is contained in:
parent
65011f9382
commit
5b94f53cd7
@ -7,18 +7,6 @@ use warnings;
|
|||||||
use List::Util qw(first);
|
use List::Util qw(first);
|
||||||
use Slic3r::Geometry::Clipper qw(union_ex diff_pl);
|
use Slic3r::Geometry::Clipper qw(union_ex diff_pl);
|
||||||
|
|
||||||
sub wkt {
|
|
||||||
my $self = shift;
|
|
||||||
return sprintf "POLYGON(%s)",
|
|
||||||
join ',', map "($_)", map { join ',', map "$_->[0] $_->[1]", @$_ } @$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub dump_perl {
|
|
||||||
my $self = shift;
|
|
||||||
return sprintf "[%s]",
|
|
||||||
join ',', map "[$_]", map { join ',', map "[$_->[0],$_->[1]]", @$_ } @$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub offset {
|
sub offset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return Slic3r::Geometry::Clipper::offset(\@$self, @_);
|
return Slic3r::Geometry::Clipper::offset(\@$self, @_);
|
||||||
|
@ -7,11 +7,6 @@ sub new_scale {
|
|||||||
return $class->new(map Slic3r::Geometry::scale($_), @_);
|
return $class->new(map Slic3r::Geometry::scale($_), @_);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub dump_perl {
|
|
||||||
my $self = shift;
|
|
||||||
return sprintf "[%s,%s]", @$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
package Slic3r::Pointf;
|
package Slic3r::Pointf;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
@ -10,9 +10,4 @@ sub new_scale {
|
|||||||
return $class->new(map [ Slic3r::Geometry::scale($_->[X]), Slic3r::Geometry::scale($_->[Y]) ], @points);
|
return $class->new(map [ Slic3r::Geometry::scale($_->[X]), Slic3r::Geometry::scale($_->[Y]) ], @points);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub dump_perl {
|
|
||||||
my $self = shift;
|
|
||||||
return sprintf "[%s]", join ',', map "[$_->[0],$_->[1]]", @$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -505,17 +505,6 @@ ExPolygon::lines() const
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
ExPolygon::dump_perl() const
|
|
||||||
{
|
|
||||||
std::ostringstream ret;
|
|
||||||
ret << "[" << this->contour.dump_perl();
|
|
||||||
for (Polygons::const_iterator h = this->holes.begin(); h != this->holes.end(); ++h)
|
|
||||||
ret << "," << h->dump_perl();
|
|
||||||
ret << "]";
|
|
||||||
return ret.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
BoundingBox get_extents(const ExPolygon &expolygon)
|
BoundingBox get_extents(const ExPolygon &expolygon)
|
||||||
{
|
{
|
||||||
return get_extents(expolygon.contour);
|
return get_extents(expolygon.contour);
|
||||||
|
@ -63,7 +63,6 @@ public:
|
|||||||
void triangulate_pp(Polygons* polygons) const;
|
void triangulate_pp(Polygons* polygons) const;
|
||||||
void triangulate_p2t(Polygons* polygons) const;
|
void triangulate_p2t(Polygons* polygons) const;
|
||||||
Lines lines() const;
|
Lines lines() const;
|
||||||
std::string dump_perl() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Count a nuber of polygons stored inside the vector of expolygons.
|
// Count a nuber of polygons stored inside the vector of expolygons.
|
||||||
|
@ -7,14 +7,6 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
std::string Line::wkt() const
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "LINESTRING(" << this->a(0) << " " << this->a(1) << ","
|
|
||||||
<< this->b(0) << " " << this->b(1) << ")";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Line::intersection_infinite(const Line &other, Point* point) const
|
bool Line::intersection_infinite(const Line &other, Point* point) const
|
||||||
{
|
{
|
||||||
Vec2d a1 = this->a.cast<double>();
|
Vec2d a1 = this->a.cast<double>();
|
||||||
|
@ -20,7 +20,6 @@ class Line
|
|||||||
public:
|
public:
|
||||||
Line() {}
|
Line() {}
|
||||||
explicit Line(Point _a, Point _b): a(_a), b(_b) {}
|
explicit Line(Point _a, Point _b): a(_a), b(_b) {}
|
||||||
std::string wkt() const;
|
|
||||||
explicit operator Lines() const { Lines lines; lines.emplace_back(*this); return lines; }
|
explicit operator Lines() const { Lines lines; lines.emplace_back(*this); return lines; }
|
||||||
void scale(double factor) { this->a *= factor; this->b *= factor; }
|
void scale(double factor) { this->a *= factor; this->b *= factor; }
|
||||||
void translate(double x, double y) { Vector v(x, y); this->a += v; this->b += v; }
|
void translate(double x, double y) { Vector v(x, y); this->a += v; this->b += v; }
|
||||||
|
@ -153,19 +153,6 @@ bool MultiPoint::first_intersection(const Line& line, Point* intersection) const
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
MultiPoint::dump_perl() const
|
|
||||||
{
|
|
||||||
std::ostringstream ret;
|
|
||||||
ret << "[";
|
|
||||||
for (Points::const_iterator p = this->points.begin(); p != this->points.end(); ++p) {
|
|
||||||
ret << p->dump_perl();
|
|
||||||
if (p != this->points.end()-1) ret << ",";
|
|
||||||
}
|
|
||||||
ret << "]";
|
|
||||||
return ret.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME This is very inefficient in term of memory use.
|
//FIXME This is very inefficient in term of memory use.
|
||||||
// The recursive algorithm shall run in place, not allocating temporary data in each recursion.
|
// The recursive algorithm shall run in place, not allocating temporary data in each recursion.
|
||||||
Points
|
Points
|
||||||
|
@ -76,7 +76,6 @@ public:
|
|||||||
|
|
||||||
bool intersection(const Line& line, Point* intersection) const;
|
bool intersection(const Line& line, Point* intersection) const;
|
||||||
bool first_intersection(const Line& line, Point* intersection) const;
|
bool first_intersection(const Line& line, Point* intersection) const;
|
||||||
std::string dump_perl() const;
|
|
||||||
|
|
||||||
static Points _douglas_peucker(const Points &points, const double tolerance);
|
static Points _douglas_peucker(const Points &points, const double tolerance);
|
||||||
};
|
};
|
||||||
|
@ -693,7 +693,7 @@ namespace client
|
|||||||
case coInts: output.set_i(static_cast<const ConfigOptionInts *>(opt.opt)->values[idx]); break;
|
case coInts: output.set_i(static_cast<const ConfigOptionInts *>(opt.opt)->values[idx]); break;
|
||||||
case coStrings: output.set_s(static_cast<const ConfigOptionStrings *>(opt.opt)->values[idx]); break;
|
case coStrings: output.set_s(static_cast<const ConfigOptionStrings *>(opt.opt)->values[idx]); break;
|
||||||
case coPercents: output.set_d(static_cast<const ConfigOptionPercents*>(opt.opt)->values[idx]); break;
|
case coPercents: output.set_d(static_cast<const ConfigOptionPercents*>(opt.opt)->values[idx]); break;
|
||||||
case coPoints: output.set_s(static_cast<const ConfigOptionPoints *>(opt.opt)->values[idx].dump_perl()); break;
|
case coPoints: output.set_s(to_string(static_cast<const ConfigOptionPoints *>(opt.opt)->values[idx])); break;
|
||||||
case coBools: output.set_b(static_cast<const ConfigOptionBools *>(opt.opt)->values[idx] != 0); break;
|
case coBools: output.set_b(static_cast<const ConfigOptionBools *>(opt.opt)->values[idx] != 0); break;
|
||||||
default:
|
default:
|
||||||
ctx->throw_exception("Unknown vector variable type", opt.it_range);
|
ctx->throw_exception("Unknown vector variable type", opt.it_range);
|
||||||
|
@ -6,20 +6,6 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
std::string Point::wkt() const
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "POINT(" << (*this)(0) << " " << (*this)(1) << ")";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Point::dump_perl() const
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "[" << (*this)(0) << "," << (*this)(1) << "]";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Point::rotate(double angle)
|
void Point::rotate(double angle)
|
||||||
{
|
{
|
||||||
double cur_x = (double)(*this)(0);
|
double cur_x = (double)(*this)(0);
|
||||||
@ -172,20 +158,6 @@ std::ostream& operator<<(std::ostream &stm, const Pointf &pointf)
|
|||||||
return stm << pointf(0) << "," << pointf(1);
|
return stm << pointf(0) << "," << pointf(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Pointf::wkt() const
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "POINT(" << (*this)(0) << " " << (*this)(1) << ")";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Pointf::dump_perl() const
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "[" << (*this)(0) << "," << (*this)(1) << "]";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pointf::rotate(double angle)
|
void Pointf::rotate(double angle)
|
||||||
{
|
{
|
||||||
double cur_x = (*this)(0);
|
double cur_x = (*this)(0);
|
||||||
@ -210,14 +182,14 @@ void Pointf::rotate(double angle, const Pointf ¢er)
|
|||||||
|
|
||||||
namespace int128 {
|
namespace int128 {
|
||||||
|
|
||||||
int orient(const Point &p1, const Point &p2, const Point &p3)
|
int orient(const Vec2crd &p1, const Vec2crd &p2, const Vec2crd &p3)
|
||||||
{
|
{
|
||||||
Slic3r::Vector v1(p2 - p1);
|
Slic3r::Vector v1(p2 - p1);
|
||||||
Slic3r::Vector v2(p3 - p1);
|
Slic3r::Vector v2(p3 - p1);
|
||||||
return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1));
|
return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
int cross(const Point &v1, const Point &v2)
|
int cross(const Vec2crd &v1, const Vec2crd &v2)
|
||||||
{
|
{
|
||||||
return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1));
|
return Int128::sign_determinant_2x2_filtered(v1(0), v1(1), v2(0), v2(1));
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,21 @@
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class Line;
|
class Line;
|
||||||
class Linef;
|
|
||||||
class MultiPoint;
|
class MultiPoint;
|
||||||
class Point;
|
class Point;
|
||||||
class Point3;
|
class Point3;
|
||||||
class Pointf;
|
class Pointf;
|
||||||
class Pointf3;
|
class Pointf3;
|
||||||
typedef Point Vector;
|
typedef Point Vector;
|
||||||
typedef Point3 Vector3;
|
typedef Point3 Vector3;
|
||||||
typedef Pointf Vectorf;
|
typedef Pointf Vectorf;
|
||||||
typedef Pointf3 Vectorf3;
|
typedef Pointf3 Vectorf3;
|
||||||
typedef std::vector<Point> Points;
|
typedef std::vector<Point> Points;
|
||||||
typedef std::vector<Point*> PointPtrs;
|
typedef std::vector<Point*> PointPtrs;
|
||||||
typedef std::vector<const Point*> PointConstPtrs;
|
typedef std::vector<const Point*> PointConstPtrs;
|
||||||
typedef std::vector<Point3> Points3;
|
typedef std::vector<Point3> Points3;
|
||||||
typedef std::vector<Pointf> Pointfs;
|
typedef std::vector<Pointf> Pointfs;
|
||||||
typedef std::vector<Pointf3> Pointf3s;
|
typedef std::vector<Pointf3> Pointf3s;
|
||||||
|
|
||||||
// Eigen types, to replace the Slic3r's own types in the future.
|
// Eigen types, to replace the Slic3r's own types in the future.
|
||||||
// Vector types with a fixed point coordinate base type.
|
// Vector types with a fixed point coordinate base type.
|
||||||
@ -54,6 +53,11 @@ inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1(0) * v2(
|
|||||||
inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
inline float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||||
inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
inline double cross2(const Vec2d &v1, const Vec2d &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||||
|
|
||||||
|
inline std::string to_string(const Vec2crd &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + "]"; }
|
||||||
|
inline std::string to_string(const Vec2d &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + "]"; }
|
||||||
|
inline std::string to_string(const Vec3crd &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; }
|
||||||
|
inline std::string to_string(const Vec3d &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; }
|
||||||
|
|
||||||
class Point : public Vec2crd
|
class Point : public Vec2crd
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -77,16 +81,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Point& rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1); }
|
|
||||||
bool operator!=(const Point& rhs) const { return ! (*this == rhs); }
|
|
||||||
bool operator< (const Point& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); }
|
bool operator< (const Point& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); }
|
||||||
|
|
||||||
Point& operator+=(const Point& rhs) { (*this)(0) += rhs(0); (*this)(1) += rhs(1); return *this; }
|
Point& operator+=(const Point& rhs) { (*this)(0) += rhs(0); (*this)(1) += rhs(1); return *this; }
|
||||||
Point& operator-=(const Point& rhs) { (*this)(0) -= rhs(0); (*this)(1) -= rhs(1); return *this; }
|
Point& operator-=(const Point& rhs) { (*this)(0) -= rhs(0); (*this)(1) -= rhs(1); return *this; }
|
||||||
Point& operator*=(const double &rhs) { (*this)(0) *= rhs; (*this)(1) *= rhs; return *this; }
|
Point& operator*=(const double &rhs) { (*this)(0) *= rhs; (*this)(1) *= rhs; return *this; }
|
||||||
|
|
||||||
std::string wkt() const;
|
|
||||||
std::string dump_perl() const;
|
|
||||||
void rotate(double angle);
|
void rotate(double angle);
|
||||||
void rotate(double angle, const Point ¢er);
|
void rotate(double angle, const Point ¢er);
|
||||||
Point rotated(double angle) const { Point res(*this); res.rotate(angle); return res; }
|
Point rotated(double angle) const { Point res(*this); res.rotate(angle); return res; }
|
||||||
@ -106,15 +106,15 @@ public:
|
|||||||
namespace int128 {
|
namespace int128 {
|
||||||
// Exact orientation predicate,
|
// Exact orientation predicate,
|
||||||
// returns +1: CCW, 0: collinear, -1: CW.
|
// returns +1: CCW, 0: collinear, -1: CW.
|
||||||
int orient(const Point &p1, const Point &p2, const Point &p3);
|
int orient(const Vec2crd &p1, const Vec2crd &p2, const Vec2crd &p3);
|
||||||
// Exact orientation predicate,
|
// Exact orientation predicate,
|
||||||
// returns +1: CCW, 0: collinear, -1: CW.
|
// returns +1: CCW, 0: collinear, -1: CW.
|
||||||
int cross(const Point &v1, const Slic3r::Point &v2);
|
int cross(const Vec2crd &v1, const Vec2crd &v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be used by std::unordered_map, std::unordered_multimap and friends.
|
// To be used by std::unordered_map, std::unordered_multimap and friends.
|
||||||
struct PointHash {
|
struct PointHash {
|
||||||
size_t operator()(const Point &pt) const {
|
size_t operator()(const Vec2crd &pt) const {
|
||||||
return std::hash<coord_t>()(pt(0)) ^ std::hash<coord_t>()(pt(1));
|
return std::hash<coord_t>()(pt(0)) ^ std::hash<coord_t>()(pt(1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -159,34 +159,34 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void insert(const ValueType &value) {
|
void insert(const ValueType &value) {
|
||||||
const Point *pt = m_point_accessor(value);
|
const Vec2crd *pt = m_point_accessor(value);
|
||||||
if (pt != nullptr)
|
if (pt != nullptr)
|
||||||
m_map.emplace(std::make_pair(Point(pt->x()>>m_grid_log2, pt->y()>>m_grid_log2), value));
|
m_map.emplace(std::make_pair(Vec2crd(pt->x()>>m_grid_log2, pt->y()>>m_grid_log2), value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(ValueType &&value) {
|
void insert(ValueType &&value) {
|
||||||
const Point *pt = m_point_accessor(value);
|
const Vec2crd *pt = m_point_accessor(value);
|
||||||
if (pt != nullptr)
|
if (pt != nullptr)
|
||||||
m_map.emplace(std::make_pair(Point(pt->x()>>m_grid_log2, pt->y()>>m_grid_log2), std::move(value)));
|
m_map.emplace(std::make_pair(Vec2crd(pt->x()>>m_grid_log2, pt->y()>>m_grid_log2), std::move(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a pair of <ValueType*, distance_squared>
|
// Return a pair of <ValueType*, distance_squared>
|
||||||
std::pair<const ValueType*, double> find(const Point &pt) {
|
std::pair<const ValueType*, double> find(const Vec2crd &pt) {
|
||||||
// Iterate over 4 closest grid cells around pt,
|
// Iterate over 4 closest grid cells around pt,
|
||||||
// find the closest start point inside these cells to pt.
|
// find the closest start point inside these cells to pt.
|
||||||
const ValueType *value_min = nullptr;
|
const ValueType *value_min = nullptr;
|
||||||
double dist_min = std::numeric_limits<double>::max();
|
double dist_min = std::numeric_limits<double>::max();
|
||||||
// Round pt to a closest grid_cell corner.
|
// Round pt to a closest grid_cell corner.
|
||||||
Point grid_corner((pt(0)+(m_grid_resolution>>1))>>m_grid_log2, (pt(1)+(m_grid_resolution>>1))>>m_grid_log2);
|
Vec2crd grid_corner((pt(0)+(m_grid_resolution>>1))>>m_grid_log2, (pt(1)+(m_grid_resolution>>1))>>m_grid_log2);
|
||||||
// For four neighbors of grid_corner:
|
// For four neighbors of grid_corner:
|
||||||
for (coord_t neighbor_y = -1; neighbor_y < 1; ++ neighbor_y) {
|
for (coord_t neighbor_y = -1; neighbor_y < 1; ++ neighbor_y) {
|
||||||
for (coord_t neighbor_x = -1; neighbor_x < 1; ++ neighbor_x) {
|
for (coord_t neighbor_x = -1; neighbor_x < 1; ++ neighbor_x) {
|
||||||
// Range of fragment starts around grid_corner, close to pt.
|
// Range of fragment starts around grid_corner, close to pt.
|
||||||
auto range = m_map.equal_range(Point(grid_corner(0) + neighbor_x, grid_corner(1) + neighbor_y));
|
auto range = m_map.equal_range(Vec2crd(grid_corner(0) + neighbor_x, grid_corner(1) + neighbor_y));
|
||||||
// Find the map entry closest to pt.
|
// Find the map entry closest to pt.
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
const ValueType &value = it->second;
|
const ValueType &value = it->second;
|
||||||
const Point *pt2 = m_point_accessor(value);
|
const Vec2crd *pt2 = m_point_accessor(value);
|
||||||
if (pt2 != nullptr) {
|
if (pt2 != nullptr) {
|
||||||
const double d2 = (pt - *pt2).squaredNorm();
|
const double d2 = (pt - *pt2).squaredNorm();
|
||||||
if (d2 < dist_min) {
|
if (d2 < dist_min) {
|
||||||
@ -203,7 +203,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef typename std::unordered_multimap<Point, ValueType, PointHash> map_type;
|
typedef typename std::unordered_multimap<Vec2crd, ValueType, PointHash> map_type;
|
||||||
PointAccessor m_point_accessor;
|
PointAccessor m_point_accessor;
|
||||||
map_type m_map;
|
map_type m_map;
|
||||||
coord_t m_search_radius;
|
coord_t m_search_radius;
|
||||||
@ -231,10 +231,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Point3 &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1) && (*this)(2) == rhs(2); }
|
Point xy() const { return Point((*this)(0), (*this)(1)); }
|
||||||
bool operator!=(const Point3 &rhs) const { return ! (*this == rhs); }
|
|
||||||
|
|
||||||
Point xy() const { return Point((*this)(0), (*this)(1)); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
|
std::ostream& operator<<(std::ostream &stm, const Pointf &pointf);
|
||||||
@ -260,13 +257,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string wkt() const;
|
|
||||||
std::string dump_perl() const;
|
|
||||||
void rotate(double angle);
|
void rotate(double angle);
|
||||||
void rotate(double angle, const Pointf ¢er);
|
void rotate(double angle, const Pointf ¢er);
|
||||||
|
|
||||||
bool operator==(const Pointf &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1); }
|
|
||||||
bool operator!=(const Pointf &rhs) const { return ! (*this == rhs); }
|
|
||||||
bool operator< (const Pointf& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); }
|
bool operator< (const Pointf& rhs) const { return (*this)(0) < rhs(0) || ((*this)(0) == rhs(0) && (*this)(1) < rhs(1)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -292,9 +285,6 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Pointf3 &rhs) const { return (*this)(0) == rhs(0) && (*this)(1) == rhs(1) && (*this)(2) == rhs(2); }
|
|
||||||
bool operator!=(const Pointf3 &rhs) const { return ! (*this == rhs); }
|
|
||||||
|
|
||||||
Pointf xy() const { return Pointf((*this)(0), (*this)(1)); }
|
Pointf xy() const { return Pointf((*this)(0), (*this)(1)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,19 +230,6 @@ Polygon::centroid() const
|
|||||||
return Point(x_temp/(6*area_temp), y_temp/(6*area_temp));
|
return Point(x_temp/(6*area_temp), y_temp/(6*area_temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
Polygon::wkt() const
|
|
||||||
{
|
|
||||||
std::ostringstream wkt;
|
|
||||||
wkt << "POLYGON((";
|
|
||||||
for (Points::const_iterator p = this->points.begin(); p != this->points.end(); ++p) {
|
|
||||||
wkt << p->x() << " " << p->y();
|
|
||||||
if (p != this->points.end()-1) wkt << ",";
|
|
||||||
}
|
|
||||||
wkt << "))";
|
|
||||||
return wkt.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
// find all concave vertices (i.e. having an internal angle greater than the supplied angle)
|
// find all concave vertices (i.e. having an internal angle greater than the supplied angle)
|
||||||
// (external = right side, thus we consider ccw orientation)
|
// (external = right side, thus we consider ccw orientation)
|
||||||
Points
|
Points
|
||||||
|
@ -54,7 +54,6 @@ public:
|
|||||||
void simplify(double tolerance, Polygons &polygons) const;
|
void simplify(double tolerance, Polygons &polygons) const;
|
||||||
void triangulate_convex(Polygons* polygons) const;
|
void triangulate_convex(Polygons* polygons) const;
|
||||||
Point centroid() const;
|
Point centroid() const;
|
||||||
std::string wkt() const;
|
|
||||||
Points concave_points(double angle = PI) const;
|
Points concave_points(double angle = PI) const;
|
||||||
Points convex_points(double angle = PI) const;
|
Points convex_points(double angle = PI) const;
|
||||||
// Projection of a point onto the polygon.
|
// Projection of a point onto the polygon.
|
||||||
|
@ -196,18 +196,6 @@ bool Polyline::is_straight() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Polyline::wkt() const
|
|
||||||
{
|
|
||||||
std::ostringstream wkt;
|
|
||||||
wkt << "LINESTRING((";
|
|
||||||
for (Points::const_iterator p = this->points.begin(); p != this->points.end(); ++p) {
|
|
||||||
wkt << p->x() << " " << p->y();
|
|
||||||
if (p != this->points.end()-1) wkt << ",";
|
|
||||||
}
|
|
||||||
wkt << "))";
|
|
||||||
return wkt.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
BoundingBox get_extents(const Polyline &polyline)
|
BoundingBox get_extents(const Polyline &polyline)
|
||||||
{
|
{
|
||||||
return polyline.bounding_box();
|
return polyline.bounding_box();
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
template <class T> void simplify_by_visibility(const T &area);
|
template <class T> void simplify_by_visibility(const T &area);
|
||||||
void split_at(const Point &point, Polyline* p1, Polyline* p2) const;
|
void split_at(const Point &point, Polyline* p1, Polyline* p2) const;
|
||||||
bool is_straight() const;
|
bool is_straight() const;
|
||||||
std::string wkt() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BoundingBox get_extents(const Polyline &polyline);
|
extern BoundingBox get_extents(const Polyline &polyline);
|
||||||
|
@ -73,10 +73,10 @@ extern "C" {
|
|||||||
#undef malloc
|
#undef malloc
|
||||||
#undef realloc
|
#undef realloc
|
||||||
#undef free
|
#undef free
|
||||||
#undef Zero
|
|
||||||
#undef Packet
|
|
||||||
#undef select
|
#undef select
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
#undef Zero
|
||||||
|
#undef Packet
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
%code{% THIS->triangulate_convex(&RETVAL); %};
|
%code{% THIS->triangulate_convex(&RETVAL); %};
|
||||||
Clone<Point> centroid();
|
Clone<Point> centroid();
|
||||||
Clone<BoundingBox> bounding_box();
|
Clone<BoundingBox> bounding_box();
|
||||||
std::string wkt();
|
|
||||||
Points concave_points(double angle);
|
Points concave_points(double angle);
|
||||||
Points convex_points(double angle);
|
Points convex_points(double angle);
|
||||||
Clone<Point> point_projection(Point* point)
|
Clone<Point> point_projection(Point* point)
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
bool is_straight();
|
bool is_straight();
|
||||||
Clone<BoundingBox> bounding_box();
|
Clone<BoundingBox> bounding_box();
|
||||||
void remove_duplicate_points();
|
void remove_duplicate_points();
|
||||||
std::string wkt();
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
Polyline*
|
Polyline*
|
||||||
|
Loading…
Reference in New Issue
Block a user