Fix build
This commit is contained in:
parent
63121cee2e
commit
16a84ebc49
@ -800,25 +800,6 @@ double Emboss::get_shape_scale(const FontProp &fp, const FontFile &ff)
|
||||
return scale * Emboss::SHAPE_SCALE;
|
||||
}
|
||||
|
||||
static void store_trinagulation(
|
||||
const ExPolygons &shape,
|
||||
const std::vector<Vec3i> &triangles,
|
||||
const char *file_name = "C:/data/temp/triangulation.svg",
|
||||
double scale = 1e5)
|
||||
{
|
||||
BoundingBox bb;
|
||||
for (const auto &expoly : shape) bb.merge(expoly.contour.points);
|
||||
bb.scale(scale);
|
||||
SVG svg_vis(file_name, bb);
|
||||
svg_vis.draw(shape, "gray", .7f);
|
||||
Points pts = to_points(shape);
|
||||
svg_vis.draw(pts, "black", 4 * scale);
|
||||
for (const Vec3i &t : triangles) {
|
||||
Slic3r::Polygon triangle({pts[t[0]], pts[t[1]], pts[t[2]]});
|
||||
triangle.scale(scale);
|
||||
svg_vis.draw(triangle, "green");
|
||||
}
|
||||
}
|
||||
namespace priv {
|
||||
|
||||
void add_quad(uint32_t i1,
|
||||
|
@ -112,7 +112,7 @@ Slic3r::Pointfs compute_intersections(const Slic3r::Lines &lines)
|
||||
// IMPROVE0: BoundingBoxes of Polygons
|
||||
// IMPROVE1: Polygon's neighbor lines can't intersect
|
||||
// e.g. use indices to Point to find same points
|
||||
// IMPROVE2: Bentley–Ottmann_algorithm
|
||||
// IMPROVE2: Use BentleyOttmann algorithm
|
||||
// https://doc.cgal.org/latest/Surface_sweep_2/index.html -- CGAL implementation is significantly slower
|
||||
// https://stackoverflow.com/questions/4407493/is-there-a-robust-c-implementation-of-the-bentley-ottmann-algorithm
|
||||
Pointfs pts;
|
||||
|
@ -377,7 +377,7 @@ void SVG::export_expolygons(const char *path, const std::vector<std::pair<Slic3r
|
||||
svg.Close();
|
||||
}
|
||||
|
||||
float SVG::to_svg_coord(float x)
|
||||
float SVG::to_svg_coord(float x) throw()
|
||||
{
|
||||
// return x;
|
||||
return unscale<float>(x) * 10.f;
|
||||
|
@ -6,8 +6,7 @@
|
||||
#include <CGAL/spatial_sort.h>
|
||||
|
||||
using namespace Slic3r;
|
||||
namespace Slic3r::Private {
|
||||
|
||||
namespace priv{
|
||||
inline void insert_edges(Triangulation::HalfEdges &edges, uint32_t &offset, const Polygon &polygon, const Triangulation::Changes& changes) {
|
||||
const Points &pts = polygon.points;
|
||||
uint32_t size = static_cast<uint32_t>(pts.size());
|
||||
@ -35,9 +34,32 @@ inline void insert_edges(Triangulation::HalfEdges &edges, uint32_t &offset, cons
|
||||
offset += size;
|
||||
}
|
||||
|
||||
} // namespace Private
|
||||
inline bool has_bidirectional_constrained(
|
||||
const Triangulation::HalfEdges &constrained)
|
||||
{
|
||||
for (const auto &c : constrained) {
|
||||
auto key = std::make_pair(c.second, c.first);
|
||||
auto it = std::lower_bound(constrained.begin(), constrained.end(),
|
||||
key);
|
||||
if (it != constrained.end() && *it == key) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#define VISUALIZE_TRIANGULATION
|
||||
inline bool has_self_intersection(
|
||||
const Points &points,
|
||||
const Triangulation::HalfEdges &constrained_half_edges)
|
||||
{
|
||||
Lines lines;
|
||||
lines.reserve(constrained_half_edges.size());
|
||||
for (const auto &he : constrained_half_edges)
|
||||
lines.emplace_back(points[he.first], points[he.second]);
|
||||
return !intersection_points(lines).empty();
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
//#define VISUALIZE_TRIANGULATION
|
||||
#ifdef VISUALIZE_TRIANGULATION
|
||||
#include "admesh/stl.h" // indexed triangle set
|
||||
static void visualize(const Points &points,
|
||||
@ -53,38 +75,19 @@ static void visualize(const Points &points,
|
||||
}
|
||||
#endif // VISUALIZE_TRIANGULATION
|
||||
|
||||
static bool has_bidirectional_constrained(const Triangulation::HalfEdges &constrained) {
|
||||
for (const auto &c : constrained) {
|
||||
auto key = std::make_pair(c.second, c.first);
|
||||
auto it = std::lower_bound(constrained.begin(), constrained.end(), key);
|
||||
if (it != constrained.end() && *it == key) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool has_self_intersection(const Points &points,
|
||||
const Triangulation::HalfEdges &constrained_half_edges)
|
||||
{
|
||||
Lines lines;
|
||||
lines.reserve(constrained_half_edges.size());
|
||||
for (const auto &he : constrained_half_edges)
|
||||
lines.emplace_back(points[he.first], points[he.second]);
|
||||
return !intersection_points(lines).empty();
|
||||
}
|
||||
|
||||
Triangulation::Indices Triangulation::triangulate(const Points &points,
|
||||
const HalfEdges &constrained_half_edges)
|
||||
{
|
||||
assert(!points.empty());
|
||||
assert(!constrained_half_edges.empty());
|
||||
// edges can NOT contain bidirectional constrained
|
||||
assert(!has_bidirectional_constrained(constrained_half_edges));
|
||||
assert(!priv::has_bidirectional_constrained(constrained_half_edges));
|
||||
// constrained must be sorted
|
||||
assert(std::is_sorted(constrained_half_edges.begin(),
|
||||
constrained_half_edges.end()));
|
||||
// check that there is only unique poistion of points
|
||||
assert(std::adjacent_find(points.begin(), points.end()) == points.end());
|
||||
assert(!has_self_intersection(points, constrained_half_edges));
|
||||
assert(!priv::has_self_intersection(points, constrained_half_edges));
|
||||
// use cgal triangulation
|
||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Vb = CGAL::Triangulation_vertex_base_with_info_2<uint32_t, K>;
|
||||
@ -126,10 +129,6 @@ Triangulation::Indices Triangulation::triangulate(const Points &points,
|
||||
// Unmark constrained edges of outside faces.
|
||||
size_t num_faces = 0;
|
||||
for (CDT::Face_handle fh : faces) {
|
||||
for (int i = 0; i < 3; ++i) if (fh->vertex(i)->info() == 752) {
|
||||
int j = 42;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (!fh->is_constrained(i)) continue;
|
||||
auto key = std::make_pair(fh->vertex((i + 2) % 3)->info(), fh->vertex((i + 1) % 3)->info());
|
||||
@ -202,7 +201,7 @@ Triangulation::Indices Triangulation::triangulate(const Polygon &polygon)
|
||||
HalfEdges edges;
|
||||
edges.reserve(pts.size());
|
||||
uint32_t offset = 0;
|
||||
Private::insert_edges(edges, offset, polygon);
|
||||
priv::insert_edges(edges, offset, polygon);
|
||||
std::sort(edges.begin(), edges.end());
|
||||
return triangulate(pts, edges);
|
||||
}
|
||||
@ -219,7 +218,7 @@ Triangulation::Indices Triangulation::triangulate(const Polygons &polygons)
|
||||
|
||||
for (const Polygon &polygon : polygons) {
|
||||
Slic3r::append(points, polygon.points);
|
||||
Private::insert_edges(edges, offset, polygon);
|
||||
priv::insert_edges(edges, offset, polygon);
|
||||
}
|
||||
|
||||
std::sort(edges.begin(), edges.end());
|
||||
@ -255,9 +254,9 @@ Triangulation::Indices Triangulation::triangulate(const ExPolygons &expolygons,
|
||||
edges.reserve(points.size());
|
||||
uint32_t offset = 0;
|
||||
for (const ExPolygon &expolygon : expolygons) {
|
||||
Private::insert_edges(edges, offset, expolygon.contour);
|
||||
priv::insert_edges(edges, offset, expolygon.contour);
|
||||
for (const Polygon &hole : expolygon.holes)
|
||||
Private::insert_edges(edges, offset, hole);
|
||||
priv::insert_edges(edges, offset, hole);
|
||||
}
|
||||
std::sort(edges.begin(), edges.end());
|
||||
return triangulate(points, edges);
|
||||
@ -278,9 +277,9 @@ Triangulation::Indices Triangulation::triangulate(const ExPolygons &expolygons,
|
||||
edges.reserve(points.size());
|
||||
uint32_t offset = 0;
|
||||
for (const ExPolygon &expolygon : expolygons) {
|
||||
Private::insert_edges(edges, offset, expolygon.contour, changes);
|
||||
priv::insert_edges(edges, offset, expolygon.contour, changes);
|
||||
for (const Polygon &hole : expolygon.holes)
|
||||
Private::insert_edges(edges, offset, hole, changes);
|
||||
priv::insert_edges(edges, offset, hole, changes);
|
||||
}
|
||||
|
||||
std::sort(edges.begin(), edges.end());
|
||||
|
Loading…
Reference in New Issue
Block a user