New "rear" seam position

This commit is contained in:
Alessandro Ranellucci 2017-03-01 17:20:43 +01:00
parent 4d521ca839
commit d984864ce0
5 changed files with 35 additions and 4 deletions

View File

@ -183,6 +183,26 @@ BoundingBox3Base<PointClass>::size() const
}
template Pointf3 BoundingBox3Base<Pointf3>::size() const;
template <class PointClass> double
BoundingBoxBase<PointClass>::radius() const
{
double x = this->max.x - this->min.x;
double y = this->max.y - this->min.y;
return 0.5 * sqrt(x*x+y*y);
}
template double BoundingBoxBase<Point>::radius() const;
template double BoundingBoxBase<Pointf>::radius() const;
template <class PointClass> double
BoundingBox3Base<PointClass>::radius() const
{
double x = this->max.x - this->min.x;
double y = this->max.y - this->min.y;
double z = this->max.z - this->min.z;
return 0.5 * sqrt(x*x+y*y+z*z);
}
template double BoundingBox3Base<Pointf3>::radius() const;
template <class PointClass> void
BoundingBoxBase<PointClass>::translate(coordf_t x, coordf_t y)
{

View File

@ -29,6 +29,7 @@ class BoundingBoxBase
void merge(const BoundingBoxBase<PointClass> &bb);
void scale(double factor);
PointClass size() const;
double radius() const;
void translate(coordf_t x, coordf_t y);
void offset(coordf_t delta);
PointClass center() const;
@ -48,6 +49,7 @@ class BoundingBox3Base : public BoundingBoxBase<PointClass>
void merge(const std::vector<PointClass> &points);
void merge(const BoundingBox3Base<PointClass> &bb);
PointClass size() const;
double radius() const;
void translate(coordf_t x, coordf_t y, coordf_t z);
void offset(coordf_t delta);
PointClass center() const;

View File

@ -324,7 +324,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
Point last_pos = this->last_pos();
if (this->config.spiral_vase) {
loop.split_at(last_pos);
} else if (seam_position == spNearest || seam_position == spAligned) {
} else if (seam_position == spNearest || seam_position == spAligned || seam_position == spRear) {
const Polygon polygon = loop.polygon();
// simplify polygon in order to skip false positives in concave/convex detection
@ -354,8 +354,13 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
}
// retrieve the last start position for this object
if (this->layer != NULL && this->_seam_position.count(this->layer->object()) > 0) {
last_pos = this->_seam_position[this->layer->object()];
if (this->layer != NULL) {
if (seam_position == spRear) {
last_pos = this->layer->object()->bounding_box().center();
last_pos.y += coord_t(3. * this->layer->object()->bounding_box().radius());
} else if (this->_seam_position.count(this->layer->object()) > 0) {
last_pos = this->_seam_position[this->layer->object()];
}
}
Point point;
@ -392,6 +397,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed)
last_pos = Point(polygon.bounding_box().max.x, centroid.y);
last_pos.rotate(fmod((float)rand()/16.0, 2.0*PI), centroid);
}
// Find the closest point, avoid overhangs.
loop.split_at(last_pos, true);
}

View File

@ -943,9 +943,11 @@ PrintConfigDef::PrintConfigDef()
def->enum_values.push_back("random");
def->enum_values.push_back("nearest");
def->enum_values.push_back("aligned");
def->enum_values.push_back("rear");
def->enum_labels.push_back("Random");
def->enum_labels.push_back("Nearest");
def->enum_labels.push_back("Aligned");
def->enum_labels.push_back("Rear");
def->default_value = new ConfigOptionEnum<SeamPosition>(spAligned);
def = this->add("serial_port", coString);

View File

@ -41,7 +41,7 @@ enum SupportMaterialPattern {
};
enum SeamPosition {
spRandom, spNearest, spAligned
spRandom, spNearest, spAligned, spRear
};
template<> inline t_config_enum_values ConfigOptionEnum<GCodeFlavor>::get_enum_values() {
@ -89,6 +89,7 @@ template<> inline t_config_enum_values ConfigOptionEnum<SeamPosition>::get_enum_
keys_map["random"] = spRandom;
keys_map["nearest"] = spNearest;
keys_map["aligned"] = spAligned;
keys_map["rear"] = spRear;
return keys_map;
}