First working implementation of a GUI for cutting
This commit is contained in:
parent
882a98ed44
commit
4f17c2b7d1
6 changed files with 27 additions and 5 deletions
|
@ -1103,7 +1103,7 @@ sub mouse_event {
|
|||
$self->{drag_object} = undef;
|
||||
$self->SetCursor(wxSTANDARD_CURSOR);
|
||||
} elsif ($event->ButtonDClick) {
|
||||
$parent->object_preview_dialog if $parent->selected_object;
|
||||
$parent->object_cut_dialog if $parent->selected_object;
|
||||
} elsif ($event->Dragging) {
|
||||
return if !$self->{drag_start_pos}; # concurrency problems
|
||||
my ($obj_idx, $instance_idx) = @{ $self->{drag_object} };
|
||||
|
@ -1146,7 +1146,7 @@ sub list_item_activated {
|
|||
my ($self, $event, $obj_idx) = @_;
|
||||
|
||||
$obj_idx //= $event->GetIndex;
|
||||
$self->object_preview_dialog($obj_idx);
|
||||
$self->object_cut_dialog($obj_idx);
|
||||
}
|
||||
|
||||
sub object_cut_dialog {
|
||||
|
@ -1171,6 +1171,7 @@ sub object_cut_dialog {
|
|||
if (my @new_objects = $dlg->NewModelObjects) {
|
||||
$self->remove($obj_idx);
|
||||
$self->load_model_objects(@new_objects);
|
||||
$self->arrange;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@ sub perform_cut {
|
|||
if $self->{cut_options}{keep_upper} && defined $upper_object;
|
||||
push @{$self->{new_model_objects}}, $lower_object
|
||||
if $self->{cut_options}{keep_lower} && defined $lower_object;
|
||||
|
||||
$self->Close;
|
||||
}
|
||||
|
||||
sub NewModelObjects {
|
||||
|
|
|
@ -571,15 +571,19 @@ sub cut {
|
|||
model => $self->model,
|
||||
config => $self->config->clone,
|
||||
layer_height_ranges => $self->layer_height_ranges,
|
||||
origin_translation => $self->origin_translation->clone,
|
||||
);
|
||||
my $lower = Slic3r::Model::Object->new(
|
||||
input_file => $self->input_file,
|
||||
model => $self->model,
|
||||
config => $self->config->clone,
|
||||
layer_height_ranges => $self->layer_height_ranges,
|
||||
origin_translation => $self->origin_translation->clone,
|
||||
);
|
||||
$upper->add_instance(offset => Slic3r::Point->new(0,0));
|
||||
$lower->add_instance(offset => Slic3r::Point->new(0,0));
|
||||
foreach my $instance (@{$self->instances}) {
|
||||
$upper->add_instance(offset => $instance->offset);
|
||||
$lower->add_instance(offset => $instance->offset);
|
||||
}
|
||||
|
||||
foreach my $volume (@{$self->volumes}) {
|
||||
if ($volume->modifier) {
|
||||
|
@ -589,9 +593,11 @@ sub cut {
|
|||
} else {
|
||||
my $upper_mesh = Slic3r::TriangleMesh->new;
|
||||
my $lower_mesh = Slic3r::TriangleMesh->new;
|
||||
$volume->mesh->cut($z, $upper_mesh, $lower_mesh);
|
||||
$volume->mesh->cut($z + $volume->mesh->bounding_box->z_min, $upper_mesh, $lower_mesh);
|
||||
$upper_mesh->repair;
|
||||
$lower_mesh->repair;
|
||||
$upper_mesh->reset_repair_stats;
|
||||
$lower_mesh->reset_repair_stats;
|
||||
|
||||
$upper->add_volume(
|
||||
material_id => $volume->material_id,
|
||||
|
|
|
@ -125,6 +125,17 @@ TriangleMesh::repair() {
|
|||
this->repaired = true;
|
||||
}
|
||||
|
||||
void
|
||||
TriangleMesh::reset_repair_stats() {
|
||||
this->stl.stats.degenerate_facets = 0;
|
||||
this->stl.stats.edges_fixed = 0;
|
||||
this->stl.stats.facets_removed = 0;
|
||||
this->stl.stats.facets_added = 0;
|
||||
this->stl.stats.facets_reversed = 0;
|
||||
this->stl.stats.backwards_edges = 0;
|
||||
this->stl.stats.normals_fixed = 0;
|
||||
}
|
||||
|
||||
void
|
||||
TriangleMesh::WriteOBJFile(char* output_file) {
|
||||
stl_generate_shared_vertices(&stl);
|
||||
|
|
|
@ -36,6 +36,7 @@ class TriangleMesh
|
|||
void horizontal_projection(ExPolygons &retval) const;
|
||||
void convex_hull(Polygon* hull);
|
||||
void bounding_box(BoundingBoxf3* bb) const;
|
||||
void reset_repair_stats();
|
||||
stl_file stl;
|
||||
bool repaired;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
%};
|
||||
int facets_count()
|
||||
%code{% RETVAL = THIS->stl.stats.number_of_facets; %};
|
||||
void reset_repair_stats();
|
||||
%{
|
||||
|
||||
SV*
|
||||
|
|
Loading…
Reference in a new issue