Fix bug in lines merging
This commit is contained in:
parent
03e103fcc8
commit
000987451a
@ -145,34 +145,30 @@ void FillAdaptive::generate_infill_lines(
|
||||
}
|
||||
}
|
||||
|
||||
void FillAdaptive::connect_lines(Lines &lines, const Line &new_line)
|
||||
void FillAdaptive::connect_lines(Lines &lines, Line new_line)
|
||||
{
|
||||
int eps = scale_(0.10);
|
||||
bool modified = false;
|
||||
|
||||
for (Line &line : lines)
|
||||
for (size_t i = 0; i < lines.size(); ++i)
|
||||
{
|
||||
if (std::abs(new_line.a.x() - line.b.x()) < eps && std::abs(new_line.a.y() - line.b.y()) < eps)
|
||||
if (std::abs(new_line.a.x() - lines[i].b.x()) < eps && std::abs(new_line.a.y() - lines[i].b.y()) < eps)
|
||||
{
|
||||
line.b.x() = new_line.b.x();
|
||||
line.b.y() = new_line.b.y();
|
||||
modified = true;
|
||||
new_line.a = lines[i].a;
|
||||
lines.erase(lines.begin() + i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (std::abs(new_line.b.x() - line.a.x()) < eps && std::abs(new_line.b.y() - line.a.y()) < eps)
|
||||
if (std::abs(new_line.b.x() - lines[i].a.x()) < eps && std::abs(new_line.b.y() - lines[i].a.y()) < eps)
|
||||
{
|
||||
line.a.x() = new_line.a.x();
|
||||
line.a.y() = new_line.a.y();
|
||||
modified = true;
|
||||
new_line.b = lines[i].b;
|
||||
lines.erase(lines.begin() + i);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!modified)
|
||||
{
|
||||
lines.push_back(new_line);
|
||||
lines.emplace_back(new_line.a, new_line.b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<FillAdaptive_Internal::Octree> FillAdaptive::build_octree(
|
||||
TriangleMesh &triangle_mesh,
|
||||
|
@ -62,7 +62,7 @@ protected:
|
||||
|
||||
void generate_infill_lines(FillAdaptive_Internal::Cube *cube, double z_position, const Vec3d &origin, std::vector<Lines> &dir_lines_out);
|
||||
|
||||
void connect_lines(Lines &lines, const Line &new_line);
|
||||
static void connect_lines(Lines &lines, Line new_line);
|
||||
|
||||
public:
|
||||
static std::unique_ptr<FillAdaptive_Internal::Octree> build_octree(
|
||||
|
Loading…
Reference in New Issue
Block a user