Fixed minor compilation warnings

This commit is contained in:
Alessandro Ranellucci 2016-12-01 19:21:36 +01:00
parent c931addda3
commit f16aaeafba
16 changed files with 61 additions and 64 deletions

View File

@ -2,16 +2,15 @@ cmake_minimum_required (VERSION 2.8)
project (slic3r)
# only on newer GCCs: -ftemplate-backtrace-limit=0
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSLIC3R_DEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DSLIC3R_DEBUG")
set(workaround "")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.3)
set(workaround "-fno-inline-small-functions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline-small-functions")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.3)
endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
set(CMAKE_CXX_FLAGS "-DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE ${workaround}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
IF(CMAKE_HOST_APPLE)

View File

@ -20,6 +20,7 @@
* https://github.com/admesh/admesh/issues
*/
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -53,6 +54,8 @@ stl_initialize(stl_file *stl) {
stl->stats.number_of_parts = 0;
stl->stats.original_num_facets = 0;
stl->stats.number_of_facets = 0;
stl->stats.bounding_diameter = 0;
stl->stats.shortest_edge = FLT_MAX;
stl->stats.facets_malloced = 0;
stl->stats.volume = -1.0;

View File

@ -441,7 +441,8 @@ union_pt_chained(const Polygons &subject, bool safety_offset_)
return retval;
}
static void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval)
void
traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval)
{
/* use a nearest neighbor search to order these children
TODO: supply start_near to chained_path() too? */

View File

@ -212,7 +212,7 @@ union_ex(const Slic3r::Surfaces &subject, bool safety_offset_ = false)
ClipperLib::PolyTree union_pt(const Slic3r::Polygons &subject, bool safety_offset_ = false);
Slic3r::Polygons union_pt_chained(const Slic3r::Polygons &subject, bool safety_offset_ = false);
static void traverse_pt(ClipperLib::PolyNodes &nodes, Slic3r::Polygons* retval);
void traverse_pt(ClipperLib::PolyNodes &nodes, Slic3r::Polygons* retval);
/* OTHER */
Slic3r::Polygons simplify_polygons(const Slic3r::Polygons &subject, bool preserve_collinear = false);

View File

@ -93,7 +93,7 @@ static inline bool is_ccw(const Polygon &poly)
return true;
// 1) Find the lowest lexicographical point.
int imin = 0;
size_t imin = 0;
for (size_t i = 1; i < poly.points.size(); ++ i) {
const Point &pmin = poly.points[imin];
const Point &p = poly.points[i];
@ -369,7 +369,7 @@ public:
myassert(aoffset1 < 0);
myassert(aoffset2 < 0);
myassert(aoffset2 < aoffset1);
bool sticks_removed = remove_sticks(polygons_src);
// bool sticks_removed = remove_sticks(polygons_src);
// if (sticks_removed) printf("Sticks removed!\n");
polygons_outer = offset(polygons_src, aoffset1,
CLIPPER_OFFSET_SCALE,
@ -411,9 +411,9 @@ public:
#ifdef SLIC3R_DEBUG
void export_to_svg(Slic3r::SVG &svg) {
svg.draw_outline(polygons_src, "black");
svg.draw_outline(polygons_outer, "green");
svg.draw_outline(polygons_inner, "brown");
//svg.draw_outline(polygons_src, "black");
//svg.draw_outline(polygons_outer, "green");
//svg.draw_outline(polygons_inner, "brown");
}
#endif /* SLIC3R_DEBUG */
@ -553,7 +553,7 @@ static inline IntersectionTypeOtherVLine intersection_type_on_prev_next_vertical
const std::vector<SegmentedIntersectionLine> &segs,
size_t iVerticalLine,
size_t iIntersection,
size_t iIntersectionOther,
int iIntersectionOther,
bool dir_is_next)
{
// This routine will propose a connecting line even if the connecting perimeter segment intersects
@ -567,7 +567,7 @@ static inline IntersectionTypeOtherVLine intersection_type_on_prev_next_vertical
const SegmentIntersection &itsct_other = il_other.intersections[iIntersectionOther];
myassert(itsct_other.is_inner());
myassert(iIntersectionOther > 0);
myassert(iIntersectionOther + 1 < il_other.intersections.size());
myassert(iIntersectionOther + 1 < (int)il_other.intersections.size());
// Is iIntersectionOther at the boundary of a vertical segment?
const SegmentIntersection &itsct_other2 = il_other.intersections[itsct_other.is_low() ? iIntersectionOther - 1 : iIntersectionOther + 1];
if (itsct_other2.is_inner())
@ -892,11 +892,11 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, float angle
#ifdef SLIC3R_DEBUG
static int iRun = 0;
BoundingBox bbox_svg(to_points(poly_with_offset.polygons_outer));
::Slic3r::SVG svg(debug_out_path("FillRectilinear2-%d.svg", iRun), bbox_svg); // , scale_(1.));
poly_with_offset.export_to_svg(svg);
//::Slic3r::SVG svg(debug_out_path("FillRectilinear2-%d.svg", iRun), bbox_svg); // , scale_(1.));
//poly_with_offset.export_to_svg(svg);
{
::Slic3r::SVG svg(debug_out_path("FillRectilinear2-initial-%d.svg", iRun), bbox_svg); // , scale_(1.));
poly_with_offset.export_to_svg(svg);
//::Slic3r::SVG svg(debug_out_path("FillRectilinear2-initial-%d.svg", iRun), bbox_svg); // , scale_(1.));
//poly_with_offset.export_to_svg(svg);
}
iRun ++;
#endif /* SLIC3R_DEBUG */
@ -934,8 +934,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, float angle
if (il > ir)
// No vertical line intersects this segment.
continue;
myassert(il >= 0 && il < segs.size());
myassert(ir >= 0 && ir < segs.size());
myassert(il >= 0 && il < (int)segs.size());
myassert(ir >= 0 && ir < (int)segs.size());
for (int i = il; i <= ir; ++ i) {
coord_t this_x = segs[i].pos;
assert(this_x == i * line_spacing + x0);
@ -1160,16 +1160,16 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, float angle
size_t j = i + 1;
for (; j < sil.intersections.size() && sil.intersections[j].is_inner(); ++ j) ;
if (i + 1 == j) {
svg.draw(Line(Point(sil.pos, sil.intersections[i].pos()), Point(sil.pos, sil.intersections[j].pos())), "blue");
//svg.draw(Line(Point(sil.pos, sil.intersections[i].pos()), Point(sil.pos, sil.intersections[j].pos())), "blue");
} else {
svg.draw(Line(Point(sil.pos, sil.intersections[i].pos()), Point(sil.pos, sil.intersections[i+1].pos())), "green");
svg.draw(Line(Point(sil.pos, sil.intersections[i+1].pos()), Point(sil.pos, sil.intersections[j-1].pos())), (j - i + 1 > 4) ? "yellow" : "magenta");
svg.draw(Line(Point(sil.pos, sil.intersections[j-1].pos()), Point(sil.pos, sil.intersections[j].pos())), "green");
//svg.draw(Line(Point(sil.pos, sil.intersections[i].pos()), Point(sil.pos, sil.intersections[i+1].pos())), "green");
//svg.draw(Line(Point(sil.pos, sil.intersections[i+1].pos()), Point(sil.pos, sil.intersections[j-1].pos())), (j - i + 1 > 4) ? "yellow" : "magenta");
//svg.draw(Line(Point(sil.pos, sil.intersections[j-1].pos()), Point(sil.pos, sil.intersections[j].pos())), "green");
}
i = j + 1;
}
}
svg.Close();
//svg.Close();
#endif /* SLIC3R_DEBUG */
// For each outer only chords, measure their maximum distance to the bow of the outer contour.
@ -1314,8 +1314,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, float angle
int iSegAbove = -1;
int iSegBelow = -1;
{
SegmentIntersection::SegmentIntersectionType type_crossing = (intrsctn->type == SegmentIntersection::INNER_LOW) ?
SegmentIntersection::INNER_HIGH : SegmentIntersection::INNER_LOW;
// SegmentIntersection::SegmentIntersectionType type_crossing = (intrsctn->type == SegmentIntersection::INNER_LOW) ?
// SegmentIntersection::INNER_HIGH : SegmentIntersection::INNER_LOW;
// Does the perimeter intersect the current vertical line above intrsctn?
for (size_t i = i_intersection + 1; i + 1 < seg.intersections.size(); ++ i)
// if (seg.intersections[i].iContour == intrsctn->iContour && seg.intersections[i].type == type_crossing) {
@ -1522,15 +1522,15 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, float angle
#ifdef SLIC3R_DEBUG
{
{
::Slic3r::SVG svg(debug_out_path("FillRectilinear2-final-%03d.svg", iRun), bbox_svg); // , scale_(1.));
poly_with_offset.export_to_svg(svg);
for (size_t i = n_polylines_out_initial; i < polylines_out.size(); ++ i)
svg.draw(polylines_out[i].lines(), "black");
//::Slic3r::SVG svg(debug_out_path("FillRectilinear2-final-%03d.svg", iRun), bbox_svg); // , scale_(1.));
//poly_with_offset.export_to_svg(svg);
//for (size_t i = n_polylines_out_initial; i < polylines_out.size(); ++ i)
//svg.draw(polylines_out[i].lines(), "black");
}
// Paint a picture per polyline. This makes it easier to discover the order of the polylines and their overlap.
for (size_t i_polyline = n_polylines_out_initial; i_polyline < polylines_out.size(); ++ i_polyline) {
::Slic3r::SVG svg(debug_out_path("FillRectilinear2-final-%03d-%03d.svg", iRun, i_polyline), bbox_svg); // , scale_(1.));
svg.draw(polylines_out[i_polyline].lines(), "black");
//::Slic3r::SVG svg(debug_out_path("FillRectilinear2-final-%03d-%03d.svg", iRun, i_polyline), bbox_svg); // , scale_(1.));
//svg.draw(polylines_out[i_polyline].lines(), "black");
}
}
#endif /* SLIC3R_DEBUG */

View File

@ -555,7 +555,7 @@ MedialAxis::build(ThickPolylines* polylines)
char path[2048];
static int iRun = 0;
sprintf(path, "out/MedialAxis-%d.svg", iRun ++);
dump_voronoi_to_svg(this->lines, this->vd, polylines, path);
//dump_voronoi_to_svg(this->lines, this->vd, polylines, path);
printf("Thick lines: ");

View File

@ -38,7 +38,7 @@ class MedialAxis {
double max_width;
double min_width;
MedialAxis(double _max_width, double _min_width, const ExPolygon* _expolygon = NULL)
: max_width(_max_width), min_width(_min_width), expolygon(_expolygon) {};
: expolygon(_expolygon), max_width(_max_width), min_width(_min_width) {};
void build(ThickPolylines* polylines);
void build(Polylines* polylines);

View File

@ -53,7 +53,7 @@ class ThickLine : public Line
coordf_t a_width, b_width;
ThickLine() : a_width(0), b_width(0) {};
ThickLine(Point _a, Point _b) : a_width(0), b_width(0), Line(_a, _b) {};
ThickLine(Point _a, Point _b) : Line(_a, _b), a_width(0), b_width(0) {};
};
class Linef

View File

@ -346,7 +346,7 @@ ModelMaterial::apply(const t_model_material_attributes &attributes)
ModelObject::ModelObject(Model *model)
: model(model), _bounding_box_valid(false)
: _bounding_box_valid(false), model(model)
{}
ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes)

View File

@ -313,10 +313,10 @@ MotionPlannerEnv::nearest_env_point(const Point &from, const Point &to) const
}
void
MotionPlannerGraph::add_edge(size_t from, size_t to, double weight)
MotionPlannerGraph::add_edge(node_t from, node_t to, double weight)
{
// extend adjacency list until this start node
if (this->adjacency_list.size() < from+1)
if (this->adjacency_list.size() < (size_t)from+1)
this->adjacency_list.resize(from+1);
this->adjacency_list[from].push_back(neighbor(to, weight));
@ -334,7 +334,7 @@ MotionPlannerGraph::find_node(const Point &point) const
}
Polyline
MotionPlannerGraph::shortest_path(size_t from, size_t to)
MotionPlannerGraph::shortest_path(node_t from, node_t to)
{
// this prevents a crash in case for some reason we got here with an empty adjacency list
if (this->adjacency_list.empty()) return Polyline();
@ -345,7 +345,7 @@ MotionPlannerGraph::shortest_path(size_t from, size_t to)
std::vector<node_t> previous;
{
// number of nodes
size_t n = this->adjacency_list.size();
const int n = this->adjacency_list.size();
// initialize dist and previous
dist.clear();

View File

@ -47,9 +47,9 @@ class MotionPlannerGraph
public:
Points nodes;
//std::map<std::pair<size_t,size_t>, double> edges;
void add_edge(size_t from, size_t to, double weight);
void add_edge(node_t from, node_t to, double weight);
size_t find_node(const Point &point) const;
Polyline shortest_path(size_t from, size_t to);
Polyline shortest_path(node_t from, node_t to);
};
class MotionPlanner

View File

@ -54,8 +54,7 @@ PerimeterGenerator::process()
for (Surfaces::const_iterator surface = this->slices->surfaces.begin();
surface != this->slices->surfaces.end(); ++surface) {
// detect how many perimeters must be generated for this island
signed short loop_number = this->config->perimeters + surface->extra_perimeters;
loop_number--; // 0-indexed loops
const size_t loop_number = this->config->perimeters + surface->extra_perimeters -1; // 0-indexed loops
Polygons gaps;
@ -67,7 +66,7 @@ PerimeterGenerator::process()
ThickPolylines thin_walls;
// we loop one time more than needed in order to find gaps after the last perimeter was applied
for (signed short i = 0; i <= loop_number+1; ++i) { // outer loop is 0
for (size_t i = 0; i <= loop_number+1; ++i) { // outer loop is 0
Polygons offsets;
if (i == 0) {
// the minimum thickness of a single loop is:
@ -170,16 +169,16 @@ PerimeterGenerator::process()
}
// nest loops: holes first
for (signed short d = 0; d <= loop_number; ++d) {
for (size_t d = 0; d <= loop_number; ++d) {
PerimeterGeneratorLoops &holes_d = holes[d];
// loop through all holes having depth == d
for (signed short i = 0; i < holes_d.size(); ++i) {
for (size_t i = 0; i < holes_d.size(); ++i) {
const PerimeterGeneratorLoop &loop = holes_d[i];
// find the hole loop that contains this one, if any
for (signed short t = d+1; t <= loop_number; ++t) {
for (signed short j = 0; j < holes[t].size(); ++j) {
for (size_t t = d+1; t <= loop_number; ++t) {
for (size_t j = 0; j < holes[t].size(); ++j) {
PerimeterGeneratorLoop &candidate_parent = holes[t][j];
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
candidate_parent.children.push_back(loop);
@ -191,8 +190,8 @@ PerimeterGenerator::process()
}
// if no hole contains this hole, find the contour loop that contains it
for (signed short t = loop_number; t >= 0; --t) {
for (signed short j = 0; j < contours[t].size(); ++j) {
for (size_t t = loop_number; t --> 0;) {
for (size_t j = 0; j < contours[t].size(); ++j) {
PerimeterGeneratorLoop &candidate_parent = contours[t][j];
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
candidate_parent.children.push_back(loop);
@ -207,16 +206,16 @@ PerimeterGenerator::process()
}
// nest contour loops
for (signed short d = loop_number; d >= 1; --d) {
for (size_t d = loop_number; d --> 0;) {
PerimeterGeneratorLoops &contours_d = contours[d];
// loop through all contours having depth == d
for (signed short i = 0; i < contours_d.size(); ++i) {
for (size_t i = 0; i < contours_d.size(); ++i) {
const PerimeterGeneratorLoop &loop = contours_d[i];
// find the contour loop that contains it
for (signed short t = d-1; t >= 0; --t) {
for (signed short j = 0; j < contours[t].size(); ++j) {
for (size_t t = d-1; t --> 0;) {
for (size_t j = 0; j < contours[t].size(); ++j) {
PerimeterGeneratorLoop &candidate_parent = contours[t][j];
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
candidate_parent.children.push_back(loop);
@ -465,7 +464,7 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
double thickness_delta = fabs(line.a_width - line.b_width);
if (thickness_delta > tolerance) {
const unsigned short segments = ceil(thickness_delta / tolerance);
const size_t segments = ceil(thickness_delta / tolerance);
const coordf_t seg_len = line_len / segments;
Points pp;
std::vector<coordf_t> width;

View File

@ -68,7 +68,7 @@ Polylines PolylineCollection::_chained_path_from(
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);
assert(endpoint_index >= 0 && endpoint_index < (int)endpoints.size() * 2);
#if SLIC3R_CPPVER > 11
if (move_from_src) {
retval.push_back(std::move(src[endpoints[endpoint_index/2].idx]));

View File

@ -826,7 +826,6 @@ Print::auto_assign_extruders(ModelObject* model_object) const
// only assign extruders if object has more than one volume
if (model_object->volumes.size() < 2) return;
size_t extruders = this->config.nozzle_diameter.values.size();
for (ModelVolumePtrs::const_iterator v = model_object->volumes.begin(); v != model_object->volumes.end(); ++v) {
if (!(*v)->material_id().empty()) {
//FIXME Vojtech: This assigns an extruder ID even to a modifier volume, if it has a material assigned.

View File

@ -5,8 +5,6 @@ namespace Slic3r {
PrintConfigDef::PrintConfigDef()
{
t_optiondef_map &Options = this->options;
ConfigOptionDef* def;
def = this->add("avoid_crossing_perimeters", coBool);
@ -1399,8 +1397,6 @@ PrintConfigBase::min_object_distance() const
CLIConfigDef::CLIConfigDef()
{
t_optiondef_map &Options = this->options;
ConfigOptionDef* def;
def = this->add("export_obj", coBool);

View File

@ -144,7 +144,7 @@ SLAPrint::slice()
}
// prepend total raft height to all sliced layers
for (int i = this->config.raft_layers; i < this->layers.size(); ++i)
for (size_t i = this->config.raft_layers; i < this->layers.size(); ++i)
this->layers[i].print_z += first_lh + lh * (this->config.raft_layers-1);
}
}
@ -272,7 +272,7 @@ SLAPrint::write_svg(const std::string &outputfile) const
}
// don't print support material in raft layers
if (i >= this->config.raft_layers) {
if (i >= (size_t)this->config.raft_layers) {
// look for support material pillars belonging to this layer
for (std::vector<SupportPillar>::const_iterator it = this->sm_pillars.begin(); it != this->sm_pillars.end(); ++it) {
if (!(it->top_layer >= i && it->bottom_layer <= i)) continue;