New TriangleMesh::convex_hull()
This commit is contained in:
parent
a29eeb7789
commit
9cf138574c
4 changed files with 27 additions and 2 deletions
|
@ -1001,7 +1001,7 @@ sub repaint {
|
||||||
|
|
||||||
# draw skirt
|
# draw skirt
|
||||||
if (@{$parent->{object_previews}} && $parent->{config}->skirts) {
|
if (@{$parent->{object_previews}} && $parent->{config}->skirts) {
|
||||||
my $convex_hull = Slic3r::Polygon->new(@{convex_hull([ map @{$_->contour->pp}, map @{$_->[2]}, @{$parent->{object_previews}} ])});
|
my $convex_hull = convex_hull([ map @{$_->contour}, map @{$_->[2]}, @{$parent->{object_previews}} ]);
|
||||||
($convex_hull) = @{offset([$convex_hull], $parent->{config}->skirt_distance * $parent->{scaling_factor}, 100, JT_ROUND)};
|
($convex_hull) = @{offset([$convex_hull], $parent->{config}->skirt_distance * $parent->{scaling_factor}, 100, JT_ROUND)};
|
||||||
$dc->SetPen($parent->{skirt_pen});
|
$dc->SetPen($parent->{skirt_pen});
|
||||||
$dc->SetBrush($parent->{transparent_brush});
|
$dc->SetBrush($parent->{transparent_brush});
|
||||||
|
@ -1289,7 +1289,7 @@ sub _trigger_model_object {
|
||||||
|
|
||||||
my $mesh = $model_object->mesh;
|
my $mesh = $model_object->mesh;
|
||||||
$mesh->repair;
|
$mesh->repair;
|
||||||
$self->convex_hull(Slic3r::Geometry::convex_hull($mesh->vertices));
|
$self->convex_hull($mesh->convex_hull);
|
||||||
$self->facets($mesh->facets_count);
|
$self->facets($mesh->facets_count);
|
||||||
$self->vertices(scalar @{$mesh->vertices});
|
$self->vertices(scalar @{$mesh->vertices});
|
||||||
$self->materials($model_object->materials_count);
|
$self->materials($model_object->materials_count);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "TriangleMesh.hpp"
|
#include "TriangleMesh.hpp"
|
||||||
#include "ClipperUtils.hpp"
|
#include "ClipperUtils.hpp"
|
||||||
|
#include "Geometry.hpp"
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -598,6 +599,19 @@ TriangleMesh::horizontal_projection(ExPolygons &retval) const
|
||||||
union_(pp, retval, true);
|
union_(pp, retval, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TriangleMesh::convex_hull(Polygon &hull)
|
||||||
|
{
|
||||||
|
if (this->stl.v_shared == NULL) stl_generate_shared_vertices(&(this->stl));
|
||||||
|
Points pp;
|
||||||
|
pp.reserve(this->stl.stats.shared_vertices);
|
||||||
|
for (int i = 0; i < this->stl.stats.shared_vertices; i++) {
|
||||||
|
stl_vertex* v = this->stl.v_shared;
|
||||||
|
pp.push_back(Point(v->x / SCALING_FACTOR, v->y / SCALING_FACTOR));
|
||||||
|
}
|
||||||
|
Slic3r::Geometry::convex_hull(pp, hull);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
SV*
|
SV*
|
||||||
TriangleMesh::to_SV() {
|
TriangleMesh::to_SV() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ class TriangleMesh
|
||||||
TriangleMeshPtrs split() const;
|
TriangleMeshPtrs split() const;
|
||||||
void merge(const TriangleMesh* mesh);
|
void merge(const TriangleMesh* mesh);
|
||||||
void horizontal_projection(ExPolygons &retval) const;
|
void horizontal_projection(ExPolygons &retval) const;
|
||||||
|
void convex_hull(Polygon &hull);
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
bool repaired;
|
bool repaired;
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,16 @@ TriangleMesh::bb3()
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
RETVAL
|
RETVAL
|
||||||
|
|
||||||
|
Polygon*
|
||||||
|
TriangleMesh::convex_hull()
|
||||||
|
PREINIT:
|
||||||
|
const char* CLASS = "Slic3r::Polygon";
|
||||||
|
CODE:
|
||||||
|
RETVAL = new Polygon ();
|
||||||
|
THIS->convex_hull(*RETVAL);
|
||||||
|
OUTPUT:
|
||||||
|
RETVAL
|
||||||
|
|
||||||
%}
|
%}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue