mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 01:25:58 +08:00
use geometry orientation
This commit is contained in:
parent
ed94a8118a
commit
8df7458884
@ -2,12 +2,3 @@
|
|||||||
|
|
||||||
using namespace Slic3r::sla;
|
using namespace Slic3r::sla;
|
||||||
|
|
||||||
bool PointUtils::is_ccw(const Point &p1, const Point &p2, const Point ¢er)
|
|
||||||
{
|
|
||||||
Slic3r::Point v1 = p1 - center;
|
|
||||||
Slic3r::Point v2 = p2 - center;
|
|
||||||
|
|
||||||
double cross_product = v1.x() * (double) v2.y() -
|
|
||||||
v2.x() * (double) v1.y();
|
|
||||||
return cross_product > 0;
|
|
||||||
}
|
|
||||||
|
@ -14,9 +14,6 @@ class PointUtils
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PointUtils() = delete;
|
PointUtils() = delete;
|
||||||
|
|
||||||
// is point p1 to p2 in counter clock wise order against center?
|
|
||||||
static bool is_ccw(const Point &p1, const Point &p2, const Point ¢er);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r::sla
|
} // namespace Slic3r::sla
|
||||||
|
@ -214,20 +214,26 @@ Slic3r::Polygon VoronoiGraphUtils::to_polygon(const VD::cell_type & cell,
|
|||||||
const Slic3r::Points &points,
|
const Slic3r::Points &points,
|
||||||
double maximal_distance)
|
double maximal_distance)
|
||||||
{
|
{
|
||||||
const VD::edge_type *edge = cell.incident_edge();
|
|
||||||
Lines lines;
|
Lines lines;
|
||||||
Point center = points[cell.source_index()];
|
Point center = points[cell.source_index()];
|
||||||
// Convenient way to iterate edges around Voronoi cell.
|
// Convenient way to iterate edges around Voronoi cell.
|
||||||
|
const VD::edge_type *edge = cell.incident_edge();
|
||||||
do {
|
do {
|
||||||
assert(edge->is_linear());
|
assert(edge->is_linear());
|
||||||
if (edge->is_primary()) {
|
if (!edge->is_primary()) {
|
||||||
std::optional<Line> line = to_line(*edge, points, maximal_distance);
|
edge = edge->next();
|
||||||
if (line.has_value()) {
|
continue;
|
||||||
if (!PointUtils::is_ccw(line->a, line->b, center))
|
|
||||||
std::swap(line->a, line->b);
|
|
||||||
lines.push_back(line.value());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
std::optional<Line> line = to_line(*edge, points, maximal_distance);
|
||||||
|
if (!line.has_value()) {
|
||||||
|
edge = edge->next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Geometry::Orientation o = Geometry::orient(center, line->a, line->b);
|
||||||
|
assert(o != Geometry::Orientation::ORIENTATION_COLINEAR);
|
||||||
|
if (o == Geometry::Orientation::ORIENTATION_CW)
|
||||||
|
std::swap(line->a, line->b);
|
||||||
|
lines.push_back(line.value());
|
||||||
edge = edge->next();
|
edge = edge->next();
|
||||||
} while (edge != cell.incident_edge());
|
} while (edge != cell.incident_edge());
|
||||||
LineUtils::sort_CCW(lines, center);
|
LineUtils::sort_CCW(lines, center);
|
||||||
|
@ -355,6 +355,8 @@ SupportIslandPoints SupportPointGenerator::uniform_cover_island(
|
|||||||
SupportIslandPoints samples = SampleIslandUtils::sample_voronoi_graph(
|
SupportIslandPoints samples = SampleIslandUtils::sample_voronoi_graph(
|
||||||
skeleton, config, longest_path);
|
skeleton, config, longest_path);
|
||||||
|
|
||||||
|
SampleIslandUtils::align_samples(samples, island, config);
|
||||||
|
|
||||||
#ifdef SLA_SUPPORTPOINTGEN_DEBUG
|
#ifdef SLA_SUPPORTPOINTGEN_DEBUG
|
||||||
const char* support_point_color = "lightgreen";
|
const char* support_point_color = "lightgreen";
|
||||||
coord_t support_point_radius = config.head_radius;
|
coord_t support_point_radius = config.head_radius;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user