Fixed some instance of simplify_polygons() invocation.
Geometry::deg2rad() made a template. Some methods of Layer made inline. Added a helper template remove_nulls().
This commit is contained in:
parent
6b99cbdc02
commit
04cd474708
7 changed files with 17 additions and 54 deletions
|
@ -198,7 +198,7 @@ ExPolygon::simplify_p(double tolerance) const
|
|||
p.points.pop_back();
|
||||
pp.push_back(p);
|
||||
}
|
||||
simplify_polygons(pp, &pp);
|
||||
pp = simplify_polygons(pp);
|
||||
return pp;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,11 +168,7 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
|
|||
continue;
|
||||
|
||||
// get filler object
|
||||
#if SLIC3R_CPPVER >= 11
|
||||
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(fill_pattern));
|
||||
#else
|
||||
std::auto_ptr<Fill> f = std::auto_ptr<Fill>(Fill::new_from_type(fill_pattern));
|
||||
#endif
|
||||
f->set_bounding_box(layerm.layer()->object()->bounding_box());
|
||||
|
||||
// calculate the actual flow we'll be using for this infill
|
||||
|
|
|
@ -317,12 +317,6 @@ rad2deg_dir(double angle)
|
|||
return rad2deg(angle);
|
||||
}
|
||||
|
||||
double
|
||||
deg2rad(double angle)
|
||||
{
|
||||
return PI * angle / 180.0;
|
||||
}
|
||||
|
||||
void
|
||||
simplify_polygons(const Polygons &polygons, double tolerance, Polygons* retval)
|
||||
{
|
||||
|
@ -334,7 +328,7 @@ simplify_polygons(const Polygons &polygons, double tolerance, Polygons* retval)
|
|||
p.points.pop_back();
|
||||
pp.push_back(p);
|
||||
}
|
||||
Slic3r::simplify_polygons(pp, retval);
|
||||
*retval = Slic3r::simplify_polygons(pp);
|
||||
}
|
||||
|
||||
double
|
||||
|
|
|
@ -64,7 +64,7 @@ bool directions_parallel(double angle1, double angle2, double max_diff = 0);
|
|||
template<class T> bool contains(const std::vector<T> &vector, const Point &point);
|
||||
double rad2deg(double angle);
|
||||
double rad2deg_dir(double angle);
|
||||
double deg2rad(double angle);
|
||||
template<typename T> T deg2rad(T angle) { return T(PI) * angle / T(180.0); }
|
||||
void simplify_polygons(const Polygons &polygons, double tolerance, Polygons* retval);
|
||||
|
||||
double linint(double value, double oldmin, double oldmax, double newmin, double newmax);
|
||||
|
|
|
@ -13,12 +13,10 @@ Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
|||
coordf_t slice_z)
|
||||
: upper_layer(NULL),
|
||||
lower_layer(NULL),
|
||||
regions(),
|
||||
slicing_errors(false),
|
||||
slice_z(slice_z),
|
||||
print_z(print_z),
|
||||
height(height),
|
||||
slices(),
|
||||
_id(id),
|
||||
_object(object)
|
||||
{
|
||||
|
@ -38,37 +36,6 @@ Layer::~Layer()
|
|||
this->clear_regions();
|
||||
}
|
||||
|
||||
size_t
|
||||
Layer::id() const
|
||||
{
|
||||
return this->_id;
|
||||
}
|
||||
|
||||
void
|
||||
Layer::set_id(size_t id)
|
||||
{
|
||||
this->_id = id;
|
||||
}
|
||||
|
||||
PrintObject*
|
||||
Layer::object()
|
||||
{
|
||||
return this->_object;
|
||||
}
|
||||
|
||||
const PrintObject*
|
||||
Layer::object() const
|
||||
{
|
||||
return this->_object;
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
Layer::region_count() const
|
||||
{
|
||||
return this->regions.size();
|
||||
}
|
||||
|
||||
void
|
||||
Layer::clear_regions()
|
||||
{
|
||||
|
|
|
@ -15,13 +15,12 @@ class Layer;
|
|||
class PrintRegion;
|
||||
class PrintObject;
|
||||
|
||||
|
||||
// TODO: make stuff private
|
||||
class LayerRegion
|
||||
{
|
||||
friend class Layer;
|
||||
|
||||
public:
|
||||
public:
|
||||
Layer* layer() { return this->_layer; }
|
||||
const Layer* layer() const { return this->_layer; }
|
||||
PrintRegion* region() { return this->_region; }
|
||||
|
@ -88,10 +87,10 @@ class Layer {
|
|||
friend class PrintObject;
|
||||
|
||||
public:
|
||||
size_t id() const;
|
||||
void set_id(size_t id);
|
||||
PrintObject* object();
|
||||
const PrintObject* object() const;
|
||||
size_t id() const { return this->_id; }
|
||||
void set_id(size_t id) { this->_id = id; }
|
||||
PrintObject* object() { return this->_object; }
|
||||
const PrintObject* object() const { return this->_object; }
|
||||
|
||||
Layer *upper_layer;
|
||||
Layer *lower_layer;
|
||||
|
@ -107,7 +106,7 @@ public:
|
|||
// order will be recovered by the G-code generator.
|
||||
ExPolygonCollection slices;
|
||||
|
||||
size_t region_count() const;
|
||||
size_t region_count() const { return this->regions.size(); }
|
||||
const LayerRegion* get_region(int idx) const { return this->regions.at(idx); }
|
||||
LayerRegion* get_region(int idx) { return this->regions.at(idx); }
|
||||
LayerRegion* add_region(PrintRegion* print_region);
|
||||
|
@ -129,7 +128,6 @@ protected:
|
|||
size_t _id; // sequential number of layer, 0-based
|
||||
PrintObject *_object;
|
||||
|
||||
|
||||
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
||||
coordf_t slice_z);
|
||||
virtual ~Layer();
|
||||
|
|
|
@ -119,6 +119,14 @@ void append(std::vector<T>& dest, std::vector<T>&& src)
|
|||
src.shrink_to_fit();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void remove_nulls(std::vector<T*> &vec)
|
||||
{
|
||||
vec.erase(
|
||||
std::remove_if(vec.begin(), vec.end(), [](const T *ptr) { return ptr == nullptr; }),
|
||||
vec.end());
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue