mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
New --cut feature
This commit is contained in:
parent
37c7b958d4
commit
fe1691c151
7 changed files with 117 additions and 21 deletions
|
@ -25,13 +25,15 @@ sub read_file {
|
|||
|
||||
sub write_file {
|
||||
my $self = shift;
|
||||
my ($file, $model, %params) = @_;
|
||||
my ($file, $mesh, %params) = @_;
|
||||
|
||||
$mesh = $mesh->mesh if $mesh->isa('Slic3r::Model');
|
||||
|
||||
my $path = Slic3r::encode_path($file);
|
||||
|
||||
$params{binary}
|
||||
? $model->mesh->write_binary($path)
|
||||
: $model->mesh->write_ascii($path);
|
||||
? $mesh->write_binary($path)
|
||||
: $mesh->write_ascii($path);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -191,6 +191,21 @@ sub has_objects_with_no_instances {
|
|||
return (first { !defined $_->instances } @{$self->objects}) ? 1 : 0;
|
||||
}
|
||||
|
||||
# makes sure all objects have at least one instance
|
||||
sub add_default_instances {
|
||||
my ($self) = @_;
|
||||
|
||||
# apply a default position to all objects not having one
|
||||
my $added = 0;
|
||||
foreach my $object (@{$self->objects}) {
|
||||
if (!defined $object->instances) {
|
||||
$object->add_instance(offset => [0,0]);
|
||||
$added = 1;
|
||||
}
|
||||
}
|
||||
return $added;
|
||||
}
|
||||
|
||||
# this returns the bounding box of the *transformed* instances
|
||||
sub bounding_box {
|
||||
my $self = shift;
|
||||
|
|
|
@ -46,13 +46,8 @@ sub set_model {
|
|||
# make method idempotent so that the object is reusable
|
||||
$self->_print->delete_all_objects;
|
||||
|
||||
my $need_arrange = $model->has_objects_with_no_instances;
|
||||
if ($need_arrange) {
|
||||
# apply a default position to all objects not having one
|
||||
foreach my $object (@{$model->objects}) {
|
||||
$object->add_instance(offset => [0,0]) if !defined $object->instances;
|
||||
}
|
||||
}
|
||||
# make sure all objects have at least one defined instance
|
||||
my $need_arrange = $model->add_default_instances;
|
||||
|
||||
# apply scaling and rotation supplied from command line if any
|
||||
foreach my $instance (map @{$_->instances}, @{$model->objects}) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue