mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
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->{drag_object} = undef;
|
||||||
$self->SetCursor(wxSTANDARD_CURSOR);
|
$self->SetCursor(wxSTANDARD_CURSOR);
|
||||||
} elsif ($event->ButtonDClick) {
|
} elsif ($event->ButtonDClick) {
|
||||||
$parent->object_preview_dialog if $parent->selected_object;
|
$parent->object_cut_dialog if $parent->selected_object;
|
||||||
} elsif ($event->Dragging) {
|
} elsif ($event->Dragging) {
|
||||||
return if !$self->{drag_start_pos}; # concurrency problems
|
return if !$self->{drag_start_pos}; # concurrency problems
|
||||||
my ($obj_idx, $instance_idx) = @{ $self->{drag_object} };
|
my ($obj_idx, $instance_idx) = @{ $self->{drag_object} };
|
||||||
|
@ -1146,7 +1146,7 @@ sub list_item_activated {
|
||||||
my ($self, $event, $obj_idx) = @_;
|
my ($self, $event, $obj_idx) = @_;
|
||||||
|
|
||||||
$obj_idx //= $event->GetIndex;
|
$obj_idx //= $event->GetIndex;
|
||||||
$self->object_preview_dialog($obj_idx);
|
$self->object_cut_dialog($obj_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub object_cut_dialog {
|
sub object_cut_dialog {
|
||||||
|
@ -1171,6 +1171,7 @@ sub object_cut_dialog {
|
||||||
if (my @new_objects = $dlg->NewModelObjects) {
|
if (my @new_objects = $dlg->NewModelObjects) {
|
||||||
$self->remove($obj_idx);
|
$self->remove($obj_idx);
|
||||||
$self->load_model_objects(@new_objects);
|
$self->load_model_objects(@new_objects);
|
||||||
|
$self->arrange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,8 @@ sub perform_cut {
|
||||||
if $self->{cut_options}{keep_upper} && defined $upper_object;
|
if $self->{cut_options}{keep_upper} && defined $upper_object;
|
||||||
push @{$self->{new_model_objects}}, $lower_object
|
push @{$self->{new_model_objects}}, $lower_object
|
||||||
if $self->{cut_options}{keep_lower} && defined $lower_object;
|
if $self->{cut_options}{keep_lower} && defined $lower_object;
|
||||||
|
|
||||||
|
$self->Close;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub NewModelObjects {
|
sub NewModelObjects {
|
||||||
|
|
|
@ -571,15 +571,19 @@ sub cut {
|
||||||
model => $self->model,
|
model => $self->model,
|
||||||
config => $self->config->clone,
|
config => $self->config->clone,
|
||||||
layer_height_ranges => $self->layer_height_ranges,
|
layer_height_ranges => $self->layer_height_ranges,
|
||||||
|
origin_translation => $self->origin_translation->clone,
|
||||||
);
|
);
|
||||||
my $lower = Slic3r::Model::Object->new(
|
my $lower = Slic3r::Model::Object->new(
|
||||||
input_file => $self->input_file,
|
input_file => $self->input_file,
|
||||||
model => $self->model,
|
model => $self->model,
|
||||||
config => $self->config->clone,
|
config => $self->config->clone,
|
||||||
layer_height_ranges => $self->layer_height_ranges,
|
layer_height_ranges => $self->layer_height_ranges,
|
||||||
|
origin_translation => $self->origin_translation->clone,
|
||||||
);
|
);
|
||||||
$upper->add_instance(offset => Slic3r::Point->new(0,0));
|
foreach my $instance (@{$self->instances}) {
|
||||||
$lower->add_instance(offset => Slic3r::Point->new(0,0));
|
$upper->add_instance(offset => $instance->offset);
|
||||||
|
$lower->add_instance(offset => $instance->offset);
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $volume (@{$self->volumes}) {
|
foreach my $volume (@{$self->volumes}) {
|
||||||
if ($volume->modifier) {
|
if ($volume->modifier) {
|
||||||
|
@ -589,9 +593,11 @@ sub cut {
|
||||||
} else {
|
} else {
|
||||||
my $upper_mesh = Slic3r::TriangleMesh->new;
|
my $upper_mesh = Slic3r::TriangleMesh->new;
|
||||||
my $lower_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;
|
$upper_mesh->repair;
|
||||||
$lower_mesh->repair;
|
$lower_mesh->repair;
|
||||||
|
$upper_mesh->reset_repair_stats;
|
||||||
|
$lower_mesh->reset_repair_stats;
|
||||||
|
|
||||||
$upper->add_volume(
|
$upper->add_volume(
|
||||||
material_id => $volume->material_id,
|
material_id => $volume->material_id,
|
||||||
|
|
|
@ -125,6 +125,17 @@ TriangleMesh::repair() {
|
||||||
this->repaired = true;
|
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
|
void
|
||||||
TriangleMesh::WriteOBJFile(char* output_file) {
|
TriangleMesh::WriteOBJFile(char* output_file) {
|
||||||
stl_generate_shared_vertices(&stl);
|
stl_generate_shared_vertices(&stl);
|
||||||
|
|
|
@ -36,6 +36,7 @@ class TriangleMesh
|
||||||
void horizontal_projection(ExPolygons &retval) const;
|
void horizontal_projection(ExPolygons &retval) const;
|
||||||
void convex_hull(Polygon* hull);
|
void convex_hull(Polygon* hull);
|
||||||
void bounding_box(BoundingBoxf3* bb) const;
|
void bounding_box(BoundingBoxf3* bb) const;
|
||||||
|
void reset_repair_stats();
|
||||||
stl_file stl;
|
stl_file stl;
|
||||||
bool repaired;
|
bool repaired;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
%};
|
%};
|
||||||
int facets_count()
|
int facets_count()
|
||||||
%code{% RETVAL = THIS->stl.stats.number_of_facets; %};
|
%code{% RETVAL = THIS->stl.stats.number_of_facets; %};
|
||||||
|
void reset_repair_stats();
|
||||||
%{
|
%{
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue