mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-25 15:47:25 +08:00
Eradicated most of Pointf extras compared to pure Eigen::Vector2d.
This commit is contained in:
parent
cb138a20b8
commit
cae0806112
@ -18,7 +18,7 @@ public:
|
|||||||
BoundingBoxBase() : defined(false), min(PointClass::Zero()), max(PointClass::Zero()) {}
|
BoundingBoxBase() : defined(false), min(PointClass::Zero()), max(PointClass::Zero()) {}
|
||||||
BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) :
|
BoundingBoxBase(const PointClass &pmin, const PointClass &pmax) :
|
||||||
min(pmin), max(pmax), defined(pmin(0) < pmax(0) && pmin(1) < pmax(1)) {}
|
min(pmin), max(pmax), defined(pmin(0) < pmax(0) && pmin(1) < pmax(1)) {}
|
||||||
BoundingBoxBase(const std::vector<PointClass>& points)
|
BoundingBoxBase(const std::vector<PointClass>& points) : min(PointClass::Zero()), max(PointClass::Zero())
|
||||||
{
|
{
|
||||||
if (points.empty())
|
if (points.empty())
|
||||||
CONFESS("Empty point set supplied to BoundingBoxBase constructor");
|
CONFESS("Empty point set supplied to BoundingBoxBase constructor");
|
||||||
|
@ -696,7 +696,7 @@ public:
|
|||||||
std::istringstream is(str);
|
std::istringstream is(str);
|
||||||
std::string point_str;
|
std::string point_str;
|
||||||
while (std::getline(is, point_str, ',')) {
|
while (std::getline(is, point_str, ',')) {
|
||||||
Pointf point;
|
Pointf point(Vec2d::Zero());
|
||||||
std::istringstream iss(point_str);
|
std::istringstream iss(point_str);
|
||||||
std::string coord_str;
|
std::string coord_str;
|
||||||
if (std::getline(iss, coord_str, 'x')) {
|
if (std::getline(iss, coord_str, 'x')) {
|
||||||
|
@ -125,6 +125,7 @@ private:
|
|||||||
class GCode {
|
class GCode {
|
||||||
public:
|
public:
|
||||||
GCode() :
|
GCode() :
|
||||||
|
m_origin(Vec2d::Zero()),
|
||||||
m_enable_loop_clipping(true),
|
m_enable_loop_clipping(true),
|
||||||
m_enable_cooling_markers(false),
|
m_enable_cooling_markers(false),
|
||||||
m_enable_extrusion_role_markers(false),
|
m_enable_extrusion_role_markers(false),
|
||||||
|
@ -136,8 +136,9 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_
|
|||||||
{
|
{
|
||||||
// Wipe tower extrusions are saved as if the tower was at the origin with no rotation
|
// Wipe tower extrusions are saved as if the tower was at the origin with no rotation
|
||||||
// We need to get position and angle of the wipe tower to transform them to actual position.
|
// We need to get position and angle of the wipe tower to transform them to actual position.
|
||||||
Pointf wipe_tower_pos(print.config.wipe_tower_x.value, print.config.wipe_tower_y.value);
|
Transform2d trafo =
|
||||||
float wipe_tower_angle = print.config.wipe_tower_rotation_angle.value;
|
Eigen::Translation2d(print.config.wipe_tower_x.value, print.config.wipe_tower_y.value) *
|
||||||
|
Eigen::Rotation2Dd(print.config.wipe_tower_rotation_angle.value);
|
||||||
|
|
||||||
BoundingBoxf bbox;
|
BoundingBoxf bbox;
|
||||||
for (const std::vector<WipeTower::ToolChangeResult> &tool_changes : print.m_wipe_tower_tool_changes) {
|
for (const std::vector<WipeTower::ToolChangeResult> &tool_changes : print.m_wipe_tower_tool_changes) {
|
||||||
@ -147,19 +148,11 @@ BoundingBoxf get_wipe_tower_extrusions_extents(const Print &print, const coordf_
|
|||||||
for (size_t i = 1; i < tcr.extrusions.size(); ++ i) {
|
for (size_t i = 1; i < tcr.extrusions.size(); ++ i) {
|
||||||
const WipeTower::Extrusion &e = tcr.extrusions[i];
|
const WipeTower::Extrusion &e = tcr.extrusions[i];
|
||||||
if (e.width > 0) {
|
if (e.width > 0) {
|
||||||
Pointf p1((&e - 1)->pos.x, (&e - 1)->pos.y);
|
Pointf delta = 0.5 * Vec2d(e.width, e.width);
|
||||||
Pointf p2(e.pos.x, e.pos.y);
|
Pointf p1 = trafo * Vec2d((&e - 1)->pos.x, (&e - 1)->pos.y);
|
||||||
p1.rotate(wipe_tower_angle);
|
Pointf p2 = trafo * Vec2d(e.pos.x, e.pos.y);
|
||||||
p1 += wipe_tower_pos;
|
bbox.merge(p1.cwiseMin(p2) - delta);
|
||||||
p2.rotate(wipe_tower_angle);
|
bbox.merge(p1.cwiseMax(p2) + delta);
|
||||||
p2 += wipe_tower_pos;
|
|
||||||
|
|
||||||
bbox.merge(p1);
|
|
||||||
coordf_t radius = 0.5 * e.width;
|
|
||||||
bbox.min(0) = std::min(bbox.min(0), std::min(p1(0), p2(0)) - radius);
|
|
||||||
bbox.min(1) = std::min(bbox.min(1), std::min(p1(1), p2(1)) - radius);
|
|
||||||
bbox.max(0) = std::max(bbox.max(0), std::max(p1(0), p2(0)) + radius);
|
|
||||||
bbox.max(1) = std::max(bbox.max(1), std::max(p1(1), p2(1)) + radius);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,13 +410,13 @@ Pointfs arrange(size_t num_parts, const Pointf &part_size, coordf_t gap, const B
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
class ArrangeItem {
|
class ArrangeItem {
|
||||||
public:
|
public:
|
||||||
Pointf pos;
|
Pointf pos = Vec2d::Zero();
|
||||||
size_t index_x, index_y;
|
size_t index_x, index_y;
|
||||||
coordf_t dist;
|
coordf_t dist;
|
||||||
};
|
};
|
||||||
class ArrangeItemIndex {
|
class ArrangeItemIndex {
|
||||||
public:
|
public:
|
||||||
coordf_t index;
|
coordf_t index;
|
||||||
ArrangeItem item;
|
ArrangeItem item;
|
||||||
ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {};
|
ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {};
|
||||||
@ -433,7 +433,7 @@ arrange(size_t total_parts, const Pointf &part_size, coordf_t dist, const Boundi
|
|||||||
part(0) += dist;
|
part(0) += dist;
|
||||||
part(1) += dist;
|
part(1) += dist;
|
||||||
|
|
||||||
Pointf area;
|
Pointf area(Vec2d::Zero());
|
||||||
if (bb != NULL && bb->defined) {
|
if (bb != NULL && bb->defined) {
|
||||||
area = bb->size();
|
area = bb->size();
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
class Linef
|
class Linef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Linef() {}
|
Linef() : a(Vec2d::Zero()), b(Vec2d::Zero()) {}
|
||||||
explicit Linef(Pointf _a, Pointf _b): a(_a), b(_b) {}
|
explicit Linef(Pointf _a, Pointf _b): a(_a), b(_b) {}
|
||||||
|
|
||||||
Pointf a;
|
Pointf a;
|
||||||
|
@ -726,24 +726,22 @@ void ModelObject::center_around_origin()
|
|||||||
if (! v->modifier)
|
if (! v->modifier)
|
||||||
bb.merge(v->mesh.bounding_box());
|
bb.merge(v->mesh.bounding_box());
|
||||||
|
|
||||||
// first align to origin on XYZ
|
// First align to origin on XYZ, then center it on XY.
|
||||||
Vec3d vector(-bb.min(0), -bb.min(1), -bb.min(2));
|
|
||||||
|
|
||||||
// then center it on XY
|
|
||||||
Vec3d size = bb.size();
|
Vec3d size = bb.size();
|
||||||
vector(0) -= size(0)/2;
|
size(2) = 0.;
|
||||||
vector(1) -= size(1)/2;
|
Vec3d shift3 = - bb.min - 0.5 * size;
|
||||||
|
// Unaligned vector, for the Rotation2D to work on Visual Studio 2013.
|
||||||
|
Eigen::Vector2d shift2 = to_2d(shift3);
|
||||||
|
|
||||||
this->translate(vector);
|
this->translate(shift3);
|
||||||
this->origin_translation += vector;
|
this->origin_translation += shift3;
|
||||||
|
|
||||||
if (!this->instances.empty()) {
|
if (!this->instances.empty()) {
|
||||||
for (ModelInstance *i : this->instances) {
|
for (ModelInstance *i : this->instances) {
|
||||||
// apply rotation and scaling to vector as well before translating instance,
|
// apply rotation and scaling to vector as well before translating instance,
|
||||||
// in order to leave final position unaltered
|
// in order to leave final position unaltered
|
||||||
Vectorf v = - to_2d(vector);
|
Eigen::Rotation2Dd rot(i->rotation);
|
||||||
v.rotate(i->rotation);
|
i->offset -= rot * shift2 * i->scaling_factor;
|
||||||
i->offset += v * i->scaling_factor;
|
|
||||||
}
|
}
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
@ -762,7 +760,7 @@ void ModelObject::scale(const Vec3d &versor)
|
|||||||
for (ModelVolume *v : this->volumes)
|
for (ModelVolume *v : this->volumes)
|
||||||
v->mesh.scale(versor);
|
v->mesh.scale(versor);
|
||||||
// reset origin translation since it doesn't make sense anymore
|
// reset origin translation since it doesn't make sense anymore
|
||||||
this->origin_translation = Vec3d(0,0,0);
|
this->origin_translation = Vec3d::Zero();
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,7 +782,7 @@ void ModelObject::rotate(float angle, const Axis &axis)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->origin_translation = Vec3d(0, 0, 0);
|
this->origin_translation = Vec3d::Zero();
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ private:
|
|||||||
// Parent object, owning this instance.
|
// Parent object, owning this instance.
|
||||||
ModelObject* object;
|
ModelObject* object;
|
||||||
|
|
||||||
ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), object(object), print_volume_state(PVS_Inside) {}
|
ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), offset(Vec2d::Zero()), object(object), print_volume_state(PVS_Inside) {}
|
||||||
ModelInstance(ModelObject *object, const ModelInstance &other) :
|
ModelInstance(ModelObject *object, const ModelInstance &other) :
|
||||||
rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), print_volume_state(PVS_Inside) {}
|
rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), print_volume_state(PVS_Inside) {}
|
||||||
};
|
};
|
||||||
|
@ -153,28 +153,6 @@ std::ostream& operator<<(std::ostream &stm, const Pointf &pointf)
|
|||||||
return stm << pointf(0) << "," << pointf(1);
|
return stm << pointf(0) << "," << pointf(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pointf::rotate(double angle)
|
|
||||||
{
|
|
||||||
double cur_x = (*this)(0);
|
|
||||||
double cur_y = (*this)(1);
|
|
||||||
double s = ::sin(angle);
|
|
||||||
double c = ::cos(angle);
|
|
||||||
(*this)(0) = c * cur_x - s * cur_y;
|
|
||||||
(*this)(1) = c * cur_y + s * cur_x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Pointf::rotate(double angle, const Pointf ¢er)
|
|
||||||
{
|
|
||||||
double cur_x = (*this)(0);
|
|
||||||
double cur_y = (*this)(1);
|
|
||||||
double s = ::sin(angle);
|
|
||||||
double c = ::cos(angle);
|
|
||||||
double dx = cur_x - center(0);
|
|
||||||
double dy = cur_y - center(1);
|
|
||||||
(*this)(0) = center(0) + c * dx - s * dy;
|
|
||||||
(*this)(1) = center(1) + c * dy + s * dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace int128 {
|
namespace int128 {
|
||||||
|
|
||||||
int orient(const Vec2crd &p1, const Vec2crd &p2, const Vec2crd &p3)
|
int orient(const Vec2crd &p1, const Vec2crd &p2, const Vec2crd &p3)
|
||||||
|
@ -47,6 +47,8 @@ typedef Eigen::Transform<double, 2, Eigen::Affine, Eigen::DontAlign> Transform2d
|
|||||||
typedef Eigen::Transform<float, 3, Eigen::Affine, Eigen::DontAlign> Transform3f;
|
typedef Eigen::Transform<float, 3, Eigen::Affine, Eigen::DontAlign> Transform3f;
|
||||||
typedef Eigen::Transform<double, 3, Eigen::Affine, Eigen::DontAlign> Transform3d;
|
typedef Eigen::Transform<double, 3, Eigen::Affine, Eigen::DontAlign> Transform3d;
|
||||||
|
|
||||||
|
inline bool operator<(const Vec2d &lhs, const Vec2d &rhs) { return lhs(0) < rhs(0) || (lhs(0) == rhs(0) && lhs(1) < rhs(1)); }
|
||||||
|
|
||||||
inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
inline int64_t cross2(const Vec2i64 &v1, const Vec2i64 &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||||
inline coord_t cross2(const Vec2crd &v1, const Vec2crd &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
inline coord_t cross2(const Vec2crd &v1, const Vec2crd &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 float cross2(const Vec2f &v1, const Vec2f &v2) { return v1(0) * v2(1) - v1(1) * v2(0); }
|
||||||
@ -249,7 +251,8 @@ class Pointf : public Vec2d
|
|||||||
public:
|
public:
|
||||||
typedef coordf_t coord_type;
|
typedef coordf_t coord_type;
|
||||||
|
|
||||||
explicit Pointf() { (*this)(0) = (*this)(1) = 0.; }
|
// explicit Pointf() { (*this)(0) = (*this)(1) = 0.; }
|
||||||
|
explicit Pointf() { }
|
||||||
explicit Pointf(coordf_t x, coordf_t y) { (*this)(0) = x; (*this)(1) = y; }
|
explicit Pointf(coordf_t x, coordf_t y) { (*this)(0) = x; (*this)(1) = y; }
|
||||||
// This constructor allows you to construct Pointf from Eigen expressions
|
// This constructor allows you to construct Pointf from Eigen expressions
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
@ -263,10 +266,10 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)(0) == rhs(0) && (*this)(1) < rhs(1)); }
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -24,11 +24,12 @@ public:
|
|||||||
explicit Polygon(const Points &points): MultiPoint(points) {}
|
explicit Polygon(const Points &points): MultiPoint(points) {}
|
||||||
Polygon(const Polygon &other) : MultiPoint(other.points) {}
|
Polygon(const Polygon &other) : MultiPoint(other.points) {}
|
||||||
Polygon(Polygon &&other) : MultiPoint(std::move(other.points)) {}
|
Polygon(Polygon &&other) : MultiPoint(std::move(other.points)) {}
|
||||||
static Polygon new_scale(std::vector<Pointf> points) {
|
static Polygon new_scale(const std::vector<Pointf> &points) {
|
||||||
Points int_points;
|
Polygon pgn;
|
||||||
for (auto pt : points)
|
pgn.points.reserve(points.size());
|
||||||
int_points.push_back(Point::new_scale(pt(0), pt(1)));
|
for (const Pointf &pt : points)
|
||||||
return Polygon(int_points);
|
pgn.points.emplace_back(Point::new_scale(pt(0), pt(1)));
|
||||||
|
return pgn;
|
||||||
}
|
}
|
||||||
Polygon& operator=(const Polygon &other) { points = other.points; return *this; }
|
Polygon& operator=(const Polygon &other) { points = other.points; return *this; }
|
||||||
Polygon& operator=(Polygon &&other) { points = std::move(other.points); return *this; }
|
Polygon& operator=(Polygon &&other) { points = std::move(other.points); return *this; }
|
||||||
|
@ -23,12 +23,11 @@ public:
|
|||||||
explicit Polyline(const Point &p1, const Point &p2) { points.reserve(2); points.emplace_back(p1); points.emplace_back(p2); }
|
explicit Polyline(const Point &p1, const Point &p2) { points.reserve(2); points.emplace_back(p1); points.emplace_back(p2); }
|
||||||
Polyline& operator=(const Polyline &other) { points = other.points; return *this; }
|
Polyline& operator=(const Polyline &other) { points = other.points; return *this; }
|
||||||
Polyline& operator=(Polyline &&other) { points = std::move(other.points); return *this; }
|
Polyline& operator=(Polyline &&other) { points = std::move(other.points); return *this; }
|
||||||
static Polyline new_scale(std::vector<Pointf> points) {
|
static Polyline new_scale(const std::vector<Pointf> &points) {
|
||||||
Polyline pl;
|
Polyline pl;
|
||||||
Points int_points;
|
pl.points.reserve(points.size());
|
||||||
for (auto pt : points)
|
for (const Pointf &pt : points)
|
||||||
int_points.push_back(Point::new_scale(pt(0), pt(1)));
|
pl.points.emplace_back(Point::new_scale(pt(0), pt(1)));
|
||||||
pl.append(int_points);
|
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,8 +1575,7 @@ TriangleMesh make_cylinder(double r, double h, double fa) {
|
|||||||
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, 0));
|
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, 0));
|
||||||
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, h));
|
vertices.emplace_back(Vec3d(sin(0) * r , cos(0) * r, h));
|
||||||
for (double i = 0; i < 2*PI; i+=angle) {
|
for (double i = 0; i < 2*PI; i+=angle) {
|
||||||
Pointf p(0, r);
|
Vec2d p = Eigen::Rotation2Dd(i) * Eigen::Vector2d(0, r);
|
||||||
p.rotate(i);
|
|
||||||
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
||||||
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
||||||
id = vertices.size() - 1;
|
id = vertices.size() - 1;
|
||||||
@ -1626,8 +1625,7 @@ TriangleMesh make_sphere(double rho, double fa) {
|
|||||||
const double z = -rho + increment*rho*2.0;
|
const double z = -rho + increment*rho*2.0;
|
||||||
// radius of the circle for this step.
|
// radius of the circle for this step.
|
||||||
const double r = sqrt(abs(rho*rho - z*z));
|
const double r = sqrt(abs(rho*rho - z*z));
|
||||||
Pointf b(0, r);
|
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
||||||
b.rotate(ring[i]);
|
|
||||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||||
facets.emplace_back((i == 0) ? Point3(1, 0, ring.size()) : Point3(id, 0, id - 1));
|
facets.emplace_back((i == 0) ? Point3(1, 0, ring.size()) : Point3(id, 0, id - 1));
|
||||||
++ id;
|
++ id;
|
||||||
@ -1639,8 +1637,7 @@ TriangleMesh make_sphere(double rho, double fa) {
|
|||||||
const double r = sqrt(abs(rho*rho - z*z));
|
const double r = sqrt(abs(rho*rho - z*z));
|
||||||
|
|
||||||
for (size_t i = 0; i < ring.size(); i++) {
|
for (size_t i = 0; i < ring.size(); i++) {
|
||||||
Pointf b(0, r);
|
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
||||||
b.rotate(ring[i]);
|
|
||||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// wrap around
|
// wrap around
|
||||||
|
@ -270,7 +270,7 @@ bool ConfigBase__set(ConfigBase* THIS, const t_config_option_key &opt_key, SV* v
|
|||||||
values.reserve(len);
|
values.reserve(len);
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
SV** elem = av_fetch(av, i, 0);
|
SV** elem = av_fetch(av, i, 0);
|
||||||
Pointf point;
|
Pointf point(Vec2d::Zero());
|
||||||
if (elem == NULL || !from_SV_check(*elem, &point)) return false;
|
if (elem == NULL || !from_SV_check(*elem, &point)) return false;
|
||||||
values.emplace_back(point);
|
values.emplace_back(point);
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,7 @@ void Bed_2D::repaint()
|
|||||||
auto step = 10; // 1cm grid
|
auto step = 10; // 1cm grid
|
||||||
Polylines polylines;
|
Polylines polylines;
|
||||||
for (auto x = bb.min(0) - fmod(bb.min(0), step) + step; x < bb.max(0); x += step) {
|
for (auto x = bb.min(0) - fmod(bb.min(0), step) + step; x < bb.max(0); x += step) {
|
||||||
Polyline pl = Polyline::new_scale({ Pointf(x, bb.min(1)), Pointf(x, bb.max(1)) });
|
polylines.push_back(Polyline::new_scale({ Pointf(x, bb.min(1)), Pointf(x, bb.max(1)) }));
|
||||||
polylines.push_back(pl);
|
|
||||||
}
|
}
|
||||||
for (auto y = bb.min(1) - fmod(bb.min(1), step) + step; y < bb.max(1); y += step) {
|
for (auto y = bb.min(1) - fmod(bb.min(1), step) + step; y < bb.max(1); y += step) {
|
||||||
polylines.push_back(Polyline::new_scale({ Pointf(bb.min(0), y), Pointf(bb.max(0), y) }));
|
polylines.push_back(Polyline::new_scale({ Pointf(bb.min(0), y), Pointf(bb.max(0), y) }));
|
||||||
@ -112,9 +111,7 @@ void Bed_2D::repaint()
|
|||||||
auto x_end = Pointf(origin_px(0) + axes_len, origin_px(1));
|
auto x_end = Pointf(origin_px(0) + axes_len, origin_px(1));
|
||||||
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1)));
|
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(x_end(0), x_end(1)));
|
||||||
for (auto angle : { -arrow_angle, arrow_angle }){
|
for (auto angle : { -arrow_angle, arrow_angle }){
|
||||||
auto end = x_end;
|
auto end = Eigen::Translation2d(x_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- x_end) * Eigen::Vector2d(x_end(0) - arrow_len, x_end(1));
|
||||||
end(0) -= arrow_len;
|
|
||||||
end.rotate(angle, x_end);
|
|
||||||
dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1)));
|
dc.DrawLine(wxPoint(x_end(0), x_end(1)), wxPoint(end(0), end(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,9 +119,7 @@ void Bed_2D::repaint()
|
|||||||
auto y_end = Pointf(origin_px(0), origin_px(1) - axes_len);
|
auto y_end = Pointf(origin_px(0), origin_px(1) - axes_len);
|
||||||
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1)));
|
dc.DrawLine(wxPoint(origin_px(0), origin_px(1)), wxPoint(y_end(0), y_end(1)));
|
||||||
for (auto angle : { -arrow_angle, arrow_angle }) {
|
for (auto angle : { -arrow_angle, arrow_angle }) {
|
||||||
auto end = y_end;
|
auto end = Eigen::Translation2d(y_end) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- y_end) * Eigen::Vector2d(y_end(0), y_end(1) + arrow_len);
|
||||||
end(1) += arrow_len;
|
|
||||||
end.rotate(angle, y_end);
|
|
||||||
dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1)));
|
dc.DrawLine(wxPoint(y_end(0), y_end(1)), wxPoint(end(0), end(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ class Bed_2D : public wxPanel
|
|||||||
bool m_painted = false;
|
bool m_painted = false;
|
||||||
bool m_interactive = false;
|
bool m_interactive = false;
|
||||||
double m_scale_factor;
|
double m_scale_factor;
|
||||||
Pointf m_shift;
|
Pointf m_shift = Vec2d::Zero();
|
||||||
Pointf m_pos;
|
Pointf m_pos = Vec2d::Zero();
|
||||||
std::function<void(Pointf)> m_on_move = nullptr;
|
std::function<void(Pointf)> m_on_move = nullptr;
|
||||||
|
|
||||||
Point to_pixels(Pointf point);
|
Point to_pixels(Pointf point);
|
||||||
|
@ -952,8 +952,8 @@ static void thick_lines_to_indexed_vertex_array(
|
|||||||
// right, left, top, bottom
|
// right, left, top, bottom
|
||||||
int idx_prev[4] = { -1, -1, -1, -1 };
|
int idx_prev[4] = { -1, -1, -1, -1 };
|
||||||
double bottom_z_prev = 0.;
|
double bottom_z_prev = 0.;
|
||||||
Pointf b1_prev;
|
Pointf b1_prev(Vec2d::Zero());
|
||||||
Vectorf v_prev;
|
Vectorf v_prev(Vec2d::Zero());
|
||||||
int idx_initial[4] = { -1, -1, -1, -1 };
|
int idx_initial[4] = { -1, -1, -1, -1 };
|
||||||
double width_initial = 0.;
|
double width_initial = 0.;
|
||||||
double bottom_z_initial = 0.0;
|
double bottom_z_initial = 0.0;
|
||||||
@ -1064,7 +1064,7 @@ static void thick_lines_to_indexed_vertex_array(
|
|||||||
{
|
{
|
||||||
// Create a sharp corner with an overshot and average the left / right normals.
|
// Create a sharp corner with an overshot and average the left / right normals.
|
||||||
// At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc.
|
// At the crease angle of 45 degrees, the overshot at the corner will be less than (1-1/cos(PI/8)) = 8.2% over an arc.
|
||||||
Pointf intersection;
|
Pointf intersection(Vec2d::Zero());
|
||||||
Geometry::ray_ray_intersection(b1_prev, v_prev, a1, v, intersection);
|
Geometry::ray_ray_intersection(b1_prev, v_prev, a1, v, intersection);
|
||||||
a1 = intersection;
|
a1 = intersection;
|
||||||
a2 = 2. * a - intersection;
|
a2 = 2. * a - intersection;
|
||||||
|
@ -230,11 +230,13 @@ void BedShapePanel::update_shape()
|
|||||||
{
|
{
|
||||||
auto page_idx = m_shape_options_book->GetSelection();
|
auto page_idx = m_shape_options_book->GetSelection();
|
||||||
if (page_idx == SHAPE_RECTANGULAR) {
|
if (page_idx == SHAPE_RECTANGULAR) {
|
||||||
Pointf rect_size, rect_origin;
|
Pointf rect_size(Vec2d::Zero());
|
||||||
|
Pointf rect_origin(Vec2d::Zero());
|
||||||
try{
|
try{
|
||||||
rect_size = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
|
rect_size = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_size")); }
|
||||||
catch (const std::exception &e){
|
catch (const std::exception &e){
|
||||||
return;}
|
return;
|
||||||
|
}
|
||||||
try{
|
try{
|
||||||
rect_origin = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
|
rect_origin = boost::any_cast<Pointf>(m_optgroups[SHAPE_RECTANGULAR]->get_value("rect_origin"));
|
||||||
}
|
}
|
||||||
|
@ -667,7 +667,7 @@ void PointCtrl::set_value(const Pointf& value, bool change_event)
|
|||||||
|
|
||||||
void PointCtrl::set_value(const boost::any& value, bool change_event)
|
void PointCtrl::set_value(const boost::any& value, bool change_event)
|
||||||
{
|
{
|
||||||
Pointf pt;
|
Pointf pt(Vec2d::Zero());
|
||||||
const Pointf *ptf = boost::any_cast<Pointf>(&value);
|
const Pointf *ptf = boost::any_cast<Pointf>(&value);
|
||||||
if (!ptf)
|
if (!ptf)
|
||||||
{
|
{
|
||||||
@ -681,13 +681,10 @@ void PointCtrl::set_value(const boost::any& value, bool change_event)
|
|||||||
|
|
||||||
boost::any& PointCtrl::get_value()
|
boost::any& PointCtrl::get_value()
|
||||||
{
|
{
|
||||||
Pointf ret_point;
|
double x, y;
|
||||||
double val;
|
x_textctrl->GetValue().ToDouble(&x);
|
||||||
x_textctrl->GetValue().ToDouble(&val);
|
y_textctrl->GetValue().ToDouble(&y);
|
||||||
ret_point(0) = val;
|
return m_value = Pointf(x, y);
|
||||||
y_textctrl->GetValue().ToDouble(&val);
|
|
||||||
ret_point(1) = val;
|
|
||||||
return m_value = ret_point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticText::BUILD()
|
void StaticText::BUILD()
|
||||||
|
@ -396,6 +396,7 @@ GLGizmoScale::GLGizmoScale()
|
|||||||
: GLGizmoBase()
|
: GLGizmoBase()
|
||||||
, m_scale(1.0f)
|
, m_scale(1.0f)
|
||||||
, m_starting_scale(1.0f)
|
, m_starting_scale(1.0f)
|
||||||
|
, m_starting_drag_position(Vec2d::Zero())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ Point::coincides_with(point_sv)
|
|||||||
void scale(double factor)
|
void scale(double factor)
|
||||||
%code{% *THIS *= factor; %};
|
%code{% *THIS *= factor; %};
|
||||||
void rotate(double angle, Pointf* center)
|
void rotate(double angle, Pointf* center)
|
||||||
%code{% THIS->rotate(angle, *center); %};
|
%code{% *THIS = Eigen::Translation2d(*center) * Eigen::Rotation2Dd(angle) * Eigen::Translation2d(- *center) * Eigen::Vector2d((*THIS)(0), (*THIS)(1)); %};
|
||||||
Pointf* negative()
|
Pointf* negative()
|
||||||
%code{% RETVAL = new Pointf(- *THIS); %};
|
%code{% RETVAL = new Pointf(- *THIS); %};
|
||||||
Pointf* vector_to(Pointf* point)
|
Pointf* vector_to(Pointf* point)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user