Minor code cleanup here and there
This commit is contained in:
parent
795107dfa2
commit
70e8db8a0a
@ -22,7 +22,7 @@ sub new {
|
||||
keep_upper => 1,
|
||||
keep_lower => 1,
|
||||
rotate_lower => 1,
|
||||
preview => 0,
|
||||
preview => 1,
|
||||
};
|
||||
|
||||
my $optgroup;
|
||||
|
@ -90,12 +90,8 @@ MotionPlanner::shortest_path(const Point &from, const Point &to)
|
||||
if (!this->initialized) this->initialize();
|
||||
|
||||
// if we have an empty configuration space, return a straight move
|
||||
if (this->islands.empty()) {
|
||||
Polyline p;
|
||||
p.points.push_back(from);
|
||||
p.points.push_back(to);
|
||||
return p;
|
||||
}
|
||||
if (this->islands.empty())
|
||||
return Line(from, to);
|
||||
|
||||
// Are both points in the same island?
|
||||
int island_idx = -1;
|
||||
@ -103,12 +99,9 @@ MotionPlanner::shortest_path(const Point &from, const Point &to)
|
||||
if (island->contains(from) && island->contains(to)) {
|
||||
// since both points are in the same island, is a direct move possible?
|
||||
// if so, we avoid generating the visibility environment
|
||||
if (island->contains(Line(from, to))) {
|
||||
Polyline p;
|
||||
p.points.push_back(from);
|
||||
p.points.push_back(to);
|
||||
return p;
|
||||
}
|
||||
if (island->contains(Line(from, to)))
|
||||
return Line(from, to);
|
||||
|
||||
island_idx = island - this->islands.begin();
|
||||
break;
|
||||
}
|
||||
@ -119,10 +112,7 @@ MotionPlanner::shortest_path(const Point &from, const Point &to)
|
||||
if (env.expolygons.empty()) {
|
||||
// if this environment is empty (probably because it's too small), perform straight move
|
||||
// and avoid running the algorithms on empty dataset
|
||||
Polyline p;
|
||||
p.points.push_back(from);
|
||||
p.points.push_back(to);
|
||||
return p; // bye bye
|
||||
return Line(from, to);
|
||||
}
|
||||
|
||||
// Now check whether points are inside the environment.
|
||||
|
@ -472,11 +472,10 @@ TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons>* la
|
||||
// build loops
|
||||
layers->resize(z.size());
|
||||
for (std::vector<IntersectionLines>::iterator it = lines.begin(); it != lines.end(); ++it) {
|
||||
int layer_idx = it - lines.begin();
|
||||
size_t layer_idx = it - lines.begin();
|
||||
#ifdef SLIC3R_DEBUG
|
||||
printf("Layer %d:\n", layer_idx);
|
||||
printf("Layer %zu:\n", layer_idx);
|
||||
#endif
|
||||
|
||||
this->make_loops(*it, &(*layers)[layer_idx]);
|
||||
}
|
||||
}
|
||||
@ -708,7 +707,7 @@ TriangleMeshSlicer::make_loops(std::vector<IntersectionLine> &lines, Polygons* l
|
||||
// loop is complete
|
||||
Polygon p;
|
||||
p.points.reserve(loop.size());
|
||||
for (IntersectionLinePtrs::iterator lineptr = loop.begin(); lineptr != loop.end(); ++lineptr) {
|
||||
for (IntersectionLinePtrs::const_iterator lineptr = loop.begin(); lineptr != loop.end(); ++lineptr) {
|
||||
p.points.push_back((*lineptr)->a);
|
||||
}
|
||||
loops->push_back(p);
|
||||
@ -858,7 +857,7 @@ TriangleMeshSlicer::make_expolygons(std::vector<IntersectionLine> &lines, ExPoly
|
||||
void
|
||||
TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower)
|
||||
{
|
||||
std::vector<IntersectionLine> upper_lines, lower_lines;
|
||||
IntersectionLines upper_lines, lower_lines;
|
||||
|
||||
float scaled_z = scale_(z);
|
||||
for (int facet_idx = 0; facet_idx < this->mesh->stl.stats.number_of_facets; facet_idx++) {
|
||||
@ -869,11 +868,11 @@ TriangleMeshSlicer::cut(float z, TriangleMesh* upper, TriangleMesh* lower)
|
||||
float max_z = fmaxf(facet->vertex[0].z, fmaxf(facet->vertex[1].z, facet->vertex[2].z));
|
||||
|
||||
// intersect facet with cutting plane
|
||||
std::vector<IntersectionLine> lines;
|
||||
IntersectionLines lines;
|
||||
this->slice_facet(scaled_z, *facet, facet_idx, min_z, max_z, &lines);
|
||||
|
||||
// save intersection lines for generating correct triangulations
|
||||
for (std::vector<IntersectionLine>::iterator it = lines.begin(); it != lines.end(); ++it) {
|
||||
for (IntersectionLines::const_iterator it = lines.begin(); it != lines.end(); ++it) {
|
||||
if (it->edge_type == feTop) {
|
||||
lower_lines.push_back(*it);
|
||||
} else if (it->edge_type == feBottom) {
|
||||
|
Loading…
Reference in New Issue
Block a user