Merge branch 'bedshape'

This commit is contained in:
Alessandro Ranellucci 2014-06-16 22:57:04 +02:00
commit 7cc0bce97d
20 changed files with 497 additions and 130 deletions

View file

@ -18,6 +18,7 @@ BoundingBoxBase<PointClass>::BoundingBoxBase(const std::vector<PointClass> &poin
}
}
template BoundingBoxBase<Point>::BoundingBoxBase(const std::vector<Point> &points);
template BoundingBoxBase<Pointf>::BoundingBoxBase(const std::vector<Pointf> &points);
template <class PointClass>
BoundingBox3Base<PointClass>::BoundingBox3Base(const std::vector<PointClass> &points)
@ -65,6 +66,7 @@ BoundingBoxBase<PointClass>::scale(double factor)
this->max.scale(factor);
}
template void BoundingBoxBase<Point>::scale(double factor);
template void BoundingBoxBase<Pointf>::scale(double factor);
template void BoundingBoxBase<Pointf3>::scale(double factor);
template <class PointClass> void
@ -76,6 +78,7 @@ BoundingBoxBase<PointClass>::merge(const PointClass &point)
this->max.y = std::max(point.y, this->max.y);
}
template void BoundingBoxBase<Point>::merge(const Point &point);
template void BoundingBoxBase<Pointf>::merge(const Pointf &point);
template <class PointClass> void
BoundingBoxBase<PointClass>::merge(const BoundingBoxBase<PointClass> &bb)
@ -86,6 +89,7 @@ BoundingBoxBase<PointClass>::merge(const BoundingBoxBase<PointClass> &bb)
this->max.y = std::max(bb.max.y, this->max.y);
}
template void BoundingBoxBase<Point>::merge(const BoundingBoxBase<Point> &bb);
template void BoundingBoxBase<Pointf>::merge(const BoundingBoxBase<Pointf> &bb);
template <class PointClass> void
BoundingBox3Base<PointClass>::merge(const PointClass &point)
@ -111,6 +115,7 @@ BoundingBoxBase<PointClass>::size() const
return PointClass(this->max.x - this->min.x, this->max.y - this->min.y);
}
template Point BoundingBoxBase<Point>::size() const;
template Pointf BoundingBoxBase<Pointf>::size() const;
template <class PointClass> PointClass
BoundingBox3Base<PointClass>::size() const
@ -126,6 +131,7 @@ BoundingBoxBase<PointClass>::translate(coordf_t x, coordf_t y)
this->max.translate(x, y);
}
template void BoundingBoxBase<Point>::translate(coordf_t x, coordf_t y);
template void BoundingBoxBase<Pointf>::translate(coordf_t x, coordf_t y);
template <class PointClass> void
BoundingBox3Base<PointClass>::translate(coordf_t x, coordf_t y, coordf_t z)
@ -144,6 +150,7 @@ BoundingBoxBase<PointClass>::center() const
);
}
template Point BoundingBoxBase<Point>::center() const;
template Pointf BoundingBoxBase<Pointf>::center() const;
template <class PointClass> PointClass
BoundingBox3Base<PointClass>::center() const

View file

@ -53,10 +53,15 @@ class BoundingBox : public BoundingBoxBase<Point>
};
/*
class BoundingBoxf : public BoundingBoxBase<Pointf> {};
class BoundingBox3 : public BoundingBox3Base<Point3> {};
*/
class BoundingBoxf : public BoundingBoxBase<Pointf> {
public:
BoundingBoxf() {};
BoundingBoxf(const std::vector<Pointf> &points) : BoundingBoxBase<Pointf>(points) {};
};
class BoundingBoxf3 : public BoundingBox3Base<Pointf3> {
public:
BoundingBoxf3() {};

View file

@ -293,6 +293,18 @@ Pointf::from_SV(SV* point_sv)
this->y = SvNV(sv_y);
return true;
}
void
Pointf::from_SV_check(SV* point_sv)
{
if (sv_isobject(point_sv) && (SvTYPE(SvRV(point_sv)) == SVt_PVMG)) {
if (!sv_isa(point_sv, perl_class_name(this)) && !sv_isa(point_sv, perl_class_name_ref(this)))
CONFESS("Not a valid %s object (got %s)", perl_class_name(this), HvNAME(SvSTASH(SvRV(point_sv))));
*this = *(Pointf*)SvIV((SV*)SvRV( point_sv ));
} else {
this->from_SV(point_sv);
}
}
#endif
void

View file

@ -74,6 +74,7 @@ class Pointf
#ifdef SLIC3RXS
bool from_SV(SV* point_sv);
void from_SV_check(SV* point_sv);
SV* to_SV_pureperl() const;
#endif
};

View file

@ -427,7 +427,7 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
} else if (*opt_key == "nozzle_diameter") {
steps.insert(psInitExtruders);
} else if (*opt_key == "avoid_crossing_perimeters"
|| *opt_key == "bed_size"
|| *opt_key == "bed_shape"
|| *opt_key == "bed_temperature"
|| *opt_key == "bridge_acceleration"
|| *opt_key == "bridge_fan_speed"

View file

@ -11,11 +11,8 @@ PrintConfigDef::build_def() {
Options["avoid_crossing_perimeters"].tooltip = "Optimize travel moves in order to minimize the crossing of perimeters. This is mostly useful with Bowden extruders which suffer from oozing. This feature slows down both the print and the G-code generation.";
Options["avoid_crossing_perimeters"].cli = "avoid-crossing-perimeters!";
Options["bed_size"].type = coPoint;
Options["bed_size"].label = "Bed size";
Options["bed_size"].tooltip = "Size of your bed. This is used to adjust the preview in the plater and for auto-arranging parts in it.";
Options["bed_size"].sidetext = "mm";
Options["bed_size"].cli = "bed-size=s";
Options["bed_shape"].type = coPoints;
Options["bed_shape"].label = "Bed shape";
Options["bed_temperature"].type = coInt;
Options["bed_temperature"].label = "Other layers";

View file

@ -307,7 +307,7 @@ class PrintConfig : public virtual StaticPrintConfig
{
public:
ConfigOptionBool avoid_crossing_perimeters;
ConfigOptionPoint bed_size;
ConfigOptionPoints bed_shape;
ConfigOptionInt bed_temperature;
ConfigOptionFloat bridge_acceleration;
ConfigOptionInt bridge_fan_speed;
@ -378,7 +378,10 @@ class PrintConfig : public virtual StaticPrintConfig
PrintConfig() : StaticPrintConfig() {
this->avoid_crossing_perimeters.value = false;
this->bed_size.point = Pointf(200,200);
this->bed_shape.values.push_back(Pointf(0,0));
this->bed_shape.values.push_back(Pointf(200,0));
this->bed_shape.values.push_back(Pointf(200,200));
this->bed_shape.values.push_back(Pointf(0,200));
this->bed_temperature.value = 0;
this->bridge_acceleration.value = 0;
this->bridge_fan_speed.value = 100;
@ -466,7 +469,7 @@ class PrintConfig : public virtual StaticPrintConfig
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
if (opt_key == "avoid_crossing_perimeters") return &this->avoid_crossing_perimeters;
if (opt_key == "bed_size") return &this->bed_size;
if (opt_key == "bed_shape") return &this->bed_shape;
if (opt_key == "bed_temperature") return &this->bed_temperature;
if (opt_key == "bridge_acceleration") return &this->bridge_acceleration;
if (opt_key == "bridge_fan_speed") return &this->bridge_fan_speed;

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 34;
use Test::More tests => 39;
use constant PI => 4 * atan2(1, 1);
use constant EPSILON => 1E-4;
@ -40,10 +40,17 @@ isa_ok $line->[0], 'Slic3r::Point::Ref', 'line point is blessed';
], 'translate';
}
{
ok +Slic3r::Line->new([0,0],[200,0])->parallel_to_line(Slic3r::Line->new([200,200],[0,200])), 'parallel_to';
}
foreach my $base_angle (0, PI/4, PI/2, PI) {
my $line = Slic3r::Line->new([0,0], [100,0]);
$line->rotate($base_angle, [0,0]);
ok $line->parallel_to_line($line->clone), 'line is parallel to self';
my $clone = $line->clone;
ok $line->parallel_to_line($clone), 'line is parallel to self';
$clone->reverse;
ok $line->parallel_to_line($clone), 'line is parallel to self + PI';
ok $line->parallel_to($line->direction), 'line is parallel to its direction';
ok $line->parallel_to($line->direction + PI), 'line is parallel to its direction + PI';
ok $line->parallel_to($line->direction - PI), 'line is parallel to its direction - PI';

View file

@ -20,10 +20,10 @@
Clone<Point> center();
Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
double x_min() %code{% RETVAL = THIS->min.x; %};
double x_max() %code{% RETVAL = THIS->max.x; %};
double y_min() %code{% RETVAL = THIS->min.y; %};
double y_max() %code{% RETVAL = THIS->max.y; %};
long x_min() %code{% RETVAL = THIS->min.x; %};
long x_max() %code{% RETVAL = THIS->max.x; %};
long y_min() %code{% RETVAL = THIS->min.y; %};
long y_max() %code{% RETVAL = THIS->max.y; %};
%{
@ -39,6 +39,37 @@ new_from_points(CLASS, points)
%}
};
%name{Slic3r::Geometry::BoundingBoxf} class BoundingBoxf {
~BoundingBoxf();
Clone<BoundingBoxf> clone()
%code{% RETVAL = THIS; %};
void merge(BoundingBoxf* bb) %code{% THIS->merge(*bb); %};
void merge_point(Pointf* point) %code{% THIS->merge(*point); %};
void scale(double factor);
void translate(double x, double y);
Clone<Pointf> size();
Clone<Pointf> center();
Clone<Pointf> min_point() %code{% RETVAL = THIS->min; %};
Clone<Pointf> max_point() %code{% RETVAL = THIS->max; %};
double x_min() %code{% RETVAL = THIS->min.x; %};
double x_max() %code{% RETVAL = THIS->max.x; %};
double y_min() %code{% RETVAL = THIS->min.y; %};
double y_max() %code{% RETVAL = THIS->max.y; %};
%{
BoundingBoxf*
new_from_points(CLASS, points)
char* CLASS
Pointfs points
CODE:
RETVAL = new BoundingBoxf(points);
OUTPUT:
RETVAL
%}
};
%name{Slic3r::Geometry::BoundingBoxf3} class BoundingBoxf3 {
~BoundingBoxf3();
Clone<BoundingBoxf3> clone()

View file

@ -12,6 +12,10 @@ BoundingBox* O_OBJECT_SLIC3R
Ref<BoundingBox> O_OBJECT_SLIC3R_T
Clone<BoundingBox> O_OBJECT_SLIC3R_T
BoundingBoxf* O_OBJECT_SLIC3R
Ref<BoundingBoxf> O_OBJECT_SLIC3R_T
Clone<BoundingBoxf> O_OBJECT_SLIC3R_T
BoundingBoxf3* O_OBJECT_SLIC3R
Ref<BoundingBoxf3> O_OBJECT_SLIC3R_T
Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T

View file

@ -28,6 +28,9 @@
%typemap{BoundingBox*};
%typemap{Ref<BoundingBox>}{simple};
%typemap{Clone<BoundingBox>}{simple};
%typemap{BoundingBoxf*};
%typemap{Ref<BoundingBoxf>}{simple};
%typemap{Clone<BoundingBoxf>}{simple};
%typemap{BoundingBoxf3*};
%typemap{Ref<BoundingBoxf3>}{simple};
%typemap{Clone<BoundingBoxf3>}{simple};