Vojtech likes to use Sublime on Windows to get the wheels rolling.

This commit is contained in:
bubnikv 2016-04-11 17:05:58 +02:00
parent d392858ee3
commit 7da68c91a5
26 changed files with 408 additions and 864 deletions

View file

@ -594,6 +594,10 @@ void union_pt_chained(const Slic3r::Polygons &subject, Slic3r::Polygons* retval,
{
ClipperLib::PolyTree pt;
union_pt(subject, &pt, safety_offset_);
if (&subject == retval)
// It is safe to use the same variable for input and output, because this function makes
// a temporary copy of the results.
retval->clear();
traverse_pt(pt.Childs, retval);
}

View file

@ -36,7 +36,6 @@ MultiPoint::rotate(double angle)
double s = sin(angle);
double c = cos(angle);
for (Points::iterator it = points.begin(); it != points.end(); ++it) {
(*it).rotate(angle);
double cur_x = (double)it->x;
double cur_y = (double)it->y;
it->x = (coord_t)round(c * cur_x - s * cur_y);

View file

@ -11,7 +11,7 @@ struct Chaining
#ifndef sqr
template<typename T>
inline sqr(T x) { return x * x; }
inline T sqr(T x) { return x * x; }
#endif /* sqr */
template<typename T>
@ -43,7 +43,6 @@ inline int nearest_point_index(const std::vector<Chaining> &pairs, const Point &
}
}
}
return idx;
}
@ -64,12 +63,13 @@ Polylines PolylineCollection::chained_path_from(
if (! no_reverse)
c.last = src[i].last_point();
c.idx = i;
endpoints.push_back(c);
}
Polylines retval;
while (! endpoints.empty()) {
// find nearest point
int endpoint_index = nearest_point_index<double>(endpoints, start_near, no_reverse);
assert(endpoint_index >= 0 && endpoint_index < endpoints.size() * 2);
#if SLIC3R_CPPVER > 11
retval.push_back(std::move(src[endpoints[endpoint_index/2].idx]));
#else
@ -80,6 +80,7 @@ Polylines PolylineCollection::chained_path_from(
endpoints.erase(endpoints.begin() + endpoint_index/2);
start_near = retval.back().last_point();
}
return retval;
}
#if SLIC3R_CPPVER > 11

View file

@ -445,7 +445,8 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la
float min_z = fminf(facet->vertex[0].z, fminf(facet->vertex[1].z, facet->vertex[2].z));
float max_z = fmaxf(facet->vertex[0].z, fmaxf(facet->vertex[1].z, facet->vertex[2].z));
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
printf("\n==> FACET %d (%f,%f,%f - %f,%f,%f - %f,%f,%f):\n", facet_idx,
facet->vertex[0].x, facet->vertex[0].y, facet->vertex[0].z,
facet->vertex[1].x, facet->vertex[1].y, facet->vertex[1].z,
@ -457,7 +458,8 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la
std::vector<float>::const_iterator min_layer, max_layer;
min_layer = std::lower_bound(z.begin(), z.end(), min_z); // first layer whose slice_z is >= min_z
max_layer = std::upper_bound(z.begin() + (min_layer - z.begin()), z.end(), max_z) - 1; // last layer whose slice_z is <= max_z
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
printf("layers: min = %d, max = %d\n", (int)(min_layer - z.begin()), (int)(max_layer - z.begin()));
#endif
@ -473,7 +475,8 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la
layers->resize(z.size());
for (std::vector<IntersectionLines>::iterator it = lines.begin(); it != lines.end(); ++it) {
size_t layer_idx = it - lines.begin();
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
printf("Layer %zu:\n", layer_idx);
#endif
this->make_loops(*it, &(*layers)[layer_idx]);
@ -488,7 +491,8 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<ExPolygons>*
layers->resize(z.size());
for (std::vector<Polygons>::const_iterator loops = layers_p.begin(); loops != layers_p.end(); ++loops) {
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
size_t layer_id = loops - layers_p.begin();
printf("Layer %zu (slice_z = %.2f):\n", layer_id, z[layer_id]);
#endif
@ -712,7 +716,8 @@ TriangleMeshSlicer::make_loops(std::vector<IntersectionLine> &lines, Polygons* l
}
loops->push_back(p);
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
printf(" Discovered %s polygon of %d points\n", (p.is_counter_clockwise() ? "ccw" : "cw"), (int)p.points.size());
#endif
@ -833,7 +838,8 @@ TriangleMeshSlicer::make_expolygons(const Polygons &loops, ExPolygons* slices)
ExPolygons ex_slices;
offset2(p_slices, &ex_slices, +safety_offset, -safety_offset);
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
size_t holes_count = 0;
for (ExPolygons::const_iterator e = ex_slices.begin(); e != ex_slices.end(); ++e) {
holes_count += e->holes.size();
@ -1052,7 +1058,8 @@ TriangleMeshSlicer::TriangleMeshSlicer(TriangleMesh* _mesh) : mesh(_mesh), v_sca
}
this->facets_edges[facet_idx][i] = edge_idx;
#ifdef SLIC3R_DEBUG
#if 0
// #ifdef SLIC3R_DEBUG
printf(" [facet %d, edge %d] a_id = %d, b_id = %d --> edge %d\n", facet_idx, i, a_id, b_id, edge_idx);
#endif
}

View file

@ -1,5 +1,6 @@
#ifdef SLIC3RXS
#include <xsinit.h>
#include <assert.h>
namespace Slic3r {
@ -10,6 +11,8 @@ REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
// there is no ExtrusionLoop::Collection or ExtrusionEntity::Collection
REGISTER_CLASS(ExtrusionEntityCollection, "ExtrusionPath::Collection");
REGISTER_CLASS(ExtrusionSimulator, "ExtrusionSimulator");
REGISTER_CLASS(Filler, "Filler");
REGISTER_CLASS(Flow, "Flow");
REGISTER_CLASS(AvoidCrossingPerimeters, "GCode::AvoidCrossingPerimeters");
REGISTER_CLASS(OozePrevention, "GCode::OozePrevention");
@ -391,6 +394,7 @@ void from_SV(SV* poly_sv, MultiPoint* THIS)
void from_SV_check(SV* poly_sv, MultiPoint* THIS)
{
if (sv_isobject(poly_sv) && (SvTYPE(SvRV(poly_sv)) == SVt_PVMG)) {
// (MultiPoint*)SvIV((SV*)SvRV( poly_sv ))
*THIS = *(MultiPoint*)SvIV((SV*)SvRV( poly_sv ));
} else {
from_SV(poly_sv, THIS);