mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Ported Print::validate() to XS
This commit is contained in:
parent
3e4c572164
commit
bad0bd8520
10 changed files with 148 additions and 75 deletions
|
@ -48,81 +48,6 @@ sub reload_object {
|
|||
$self->add_model_object($_) for @models_objects;
|
||||
}
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
|
||||
if ($self->config->complete_objects) {
|
||||
# check horizontal clearance
|
||||
{
|
||||
my @a = ();
|
||||
foreach my $object (@{$self->objects}) {
|
||||
# get convex hulls of all meshes assigned to this print object
|
||||
my @mesh_convex_hulls = map $object->model_object->volumes->[$_]->mesh->convex_hull,
|
||||
map @$_,
|
||||
grep defined $_,
|
||||
@{$object->region_volumes};
|
||||
|
||||
# make a single convex hull for all of them
|
||||
my $convex_hull = convex_hull([ map @$_, @mesh_convex_hulls ]);
|
||||
|
||||
# apply the same transformations we apply to the actual meshes when slicing them
|
||||
$object->model_object->instances->[0]->transform_polygon($convex_hull);
|
||||
|
||||
# align object to Z = 0 and apply XY shift
|
||||
$convex_hull->translate(@{$object->_copies_shift});
|
||||
|
||||
# grow convex hull with the clearance margin
|
||||
($convex_hull) = @{offset([$convex_hull], scale $self->config->extruder_clearance_radius / 2, 1, JT_ROUND, scale(0.1))};
|
||||
|
||||
# now we need that no instance of $convex_hull does not intersect any of the previously checked object instances
|
||||
for my $copy (@{$object->_shifted_copies}) {
|
||||
my $p = $convex_hull->clone;
|
||||
|
||||
$p->translate(@$copy);
|
||||
if (@{ intersection(\@a, [$p]) }) {
|
||||
die "Some objects are too close; your extruder will collide with them.\n";
|
||||
}
|
||||
@a = @{union([@a, $p])};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# check vertical clearance
|
||||
{
|
||||
my @object_height = ();
|
||||
foreach my $object (@{$self->objects}) {
|
||||
my $height = $object->size->z;
|
||||
push @object_height, $height for @{$object->copies};
|
||||
}
|
||||
@object_height = sort { $a <=> $b } @object_height;
|
||||
# ignore the tallest *copy* (this is why we repeat height for all of them):
|
||||
# it will be printed as last one so its height doesn't matter
|
||||
pop @object_height;
|
||||
if (@object_height && max(@object_height) > scale $self->config->extruder_clearance_height) {
|
||||
die "Some objects are too tall and cannot be printed without extruder collisions.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($self->config->spiral_vase) {
|
||||
if ((map @{$_->copies}, @{$self->objects}) > 1) {
|
||||
die "The Spiral Vase option can only be used when printing a single object.\n";
|
||||
}
|
||||
if (@{$self->regions} > 1) {
|
||||
die "The Spiral Vase option can only be used when printing single material objects.\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $max_layer_height = max(
|
||||
map { $_->config->layer_height, $_->config->get_value('first_layer_height') } @{$self->objects},
|
||||
);
|
||||
my $extruders = $self->extruders;
|
||||
die "Layer height can't be greater than nozzle diameter\n"
|
||||
if grep { $max_layer_height > $self->config->get_at('nozzle_diameter', $_) } @$extruders;
|
||||
}
|
||||
}
|
||||
|
||||
# this value is not supposed to be compared with $layer->id
|
||||
# since they have different semantics
|
||||
sub total_layer_count {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue