mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 19:05:53 +08:00
adapt mesh function calls
This commit is contained in:
parent
1da02f02c2
commit
68de2ba4b8
@ -366,7 +366,7 @@ sub on_btn_load {
|
||||
$new_volume->set_input_file_vol_idx($vol_idx);
|
||||
|
||||
# apply the same translation we applied to the object
|
||||
$new_volume->mesh->translate(@{$self->{model_object}->origin_translation});
|
||||
$new_volume->translate(@{$self->{model_object}->origin_translation});
|
||||
|
||||
# set a default extruder value, since user can't add it manually
|
||||
$new_volume->config->set_ifndef('extruder', 0);
|
||||
@ -405,11 +405,11 @@ sub on_btn_lambda {
|
||||
$params->{"slab_h"},
|
||||
);
|
||||
# box sets the base coordinate at 0,0, move to center of plate
|
||||
$mesh->translate(
|
||||
-$size->x*1.5/2.0,
|
||||
-$size->y*1.5/2.0, #**
|
||||
0,
|
||||
);
|
||||
#$mesh->translate(
|
||||
# -$size->x*1.5/2.0,
|
||||
# -$size->y*1.5/2.0, #**
|
||||
# 0,
|
||||
#);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -418,7 +418,7 @@ sub on_btn_lambda {
|
||||
if (!$Slic3r::GUI::Settings->{_}{autocenter}) {
|
||||
#TODO what we really want to do here is just align the
|
||||
# center of the modifier to the center of the part.
|
||||
$mesh->translate($center->x, $center->y, 0);
|
||||
#$mesh->translate($center->x, $center->y, 0);
|
||||
}
|
||||
|
||||
$mesh->repair;
|
||||
@ -497,7 +497,7 @@ sub _update {
|
||||
my $itemData = $self->get_selection;
|
||||
if ($itemData && $itemData->{type} eq 'volume') {
|
||||
my $volume = $self->{model_object}->volumes->[$itemData->{volume_id}];
|
||||
$volume->mesh->translate(@{ $volume->mesh->bounding_box->min_point->vector_to($self->{move_target}) });
|
||||
$volume->translate(@{ $volume->mesh->bounding_box->min_point->vector_to($self->{move_target}) });
|
||||
}
|
||||
|
||||
$self->{parts_changed} = 1;
|
||||
|
@ -158,7 +158,7 @@ if (@ARGV) { # slicing from command line
|
||||
my $model = Slic3r::Model->read_from_file($file);
|
||||
$model->add_default_instances;
|
||||
my $mesh = $model->mesh;
|
||||
$mesh->translate(0, 0, -$mesh->bounding_box->z_min);
|
||||
$mesh->align_to_bed();
|
||||
my $upper = Slic3r::TriangleMesh->new;
|
||||
my $lower = Slic3r::TriangleMesh->new;
|
||||
$mesh->cut(Z, $opt{cut}, $upper, $lower);
|
||||
@ -179,8 +179,8 @@ if (@ARGV) { # slicing from command line
|
||||
my $model = Slic3r::Model->read_from_file($file);
|
||||
$model->add_default_instances;
|
||||
my $mesh = $model->mesh;
|
||||
$mesh->align_to_bed();
|
||||
my $bb = $mesh->bounding_box;
|
||||
$mesh->translate(0, 0, -$bb->z_min);
|
||||
|
||||
my $x_parts = ceil(($bb->size->x - epsilon)/$grid_x);
|
||||
my $y_parts = ceil(($bb->size->y - epsilon)/$grid_y); #--
|
||||
|
@ -42,7 +42,7 @@ my %opt = (
|
||||
$model->add_default_instances;
|
||||
$model->center_instances_around_point(Slic3r::Pointf->new(100,100));
|
||||
my $mesh = $model->mesh;
|
||||
$mesh->translate(0, 0, -$mesh->bounding_box->z_min);
|
||||
$mesh->align_to_bed();
|
||||
|
||||
# get slices
|
||||
my @z = ();
|
||||
|
@ -1141,13 +1141,8 @@ ModelInstance::swap(ModelInstance &other)
|
||||
void
|
||||
ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||
{
|
||||
mesh->rotate_z(this->rotation); // rotate around mesh origin
|
||||
|
||||
mesh->scale(this->scaling_factor); // scale around mesh origin
|
||||
if (!dont_translate) {
|
||||
mesh->translate(this->offset.x, this->offset.y, 0);
|
||||
}
|
||||
|
||||
TransformationMatrix trafo = this->get_trafo_matrix(dont_translate);
|
||||
mesh->transform(trafo);
|
||||
}
|
||||
|
||||
TransformationMatrix ModelInstance::get_trafo_matrix(bool dont_translate) const
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Geometry.hpp"
|
||||
#include "Log.hpp"
|
||||
#include "TransformationMatrix.hpp"
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
@ -936,28 +937,28 @@ PrintObject::_slice_region(size_t region_id, std::vector<float> z, bool modifier
|
||||
|
||||
// compose mesh
|
||||
TriangleMesh mesh;
|
||||
|
||||
// we ignore the per-instance transformations currently and only
|
||||
// consider the first one
|
||||
TransformationMatrix trafo = object.instances[0]->get_trafo_matrix();
|
||||
|
||||
// align mesh to Z = 0 (it should be already aligned actually) and apply XY shift
|
||||
trafo.translate(
|
||||
-unscale(this->_copies_shift.x),
|
||||
-unscale(this->_copies_shift.y),
|
||||
-object.bounding_box().min.z
|
||||
);
|
||||
|
||||
for (const auto& i : region_volumes) {
|
||||
|
||||
const ModelVolume &volume = *(object.volumes[i]);
|
||||
|
||||
if (volume.modifier != modifier) continue;
|
||||
|
||||
mesh.merge(volume.mesh);
|
||||
mesh.merge(volume.get_transformed_mesh(&trafo));
|
||||
}
|
||||
if (mesh.facets_count() == 0) return layers;
|
||||
|
||||
// transform mesh
|
||||
// we ignore the per-instance transformations currently and only
|
||||
// consider the first one
|
||||
object.instances[0]->transform_mesh(&mesh, true);
|
||||
|
||||
// align mesh to Z = 0 (it should be already aligned actually) and apply XY shift
|
||||
mesh.translate(
|
||||
-unscale(this->_copies_shift.x),
|
||||
-unscale(this->_copies_shift.y),
|
||||
-object.bounding_box().min.z
|
||||
);
|
||||
|
||||
// perform actual slicing
|
||||
TriangleMeshSlicer<Z>(&mesh).slice(z, &layers);
|
||||
return layers;
|
||||
|
@ -16,6 +16,8 @@ SLAPrint::slice()
|
||||
TriangleMesh mesh = this->model->mesh();
|
||||
mesh.repair();
|
||||
|
||||
mesh.align_to_bed();
|
||||
|
||||
// align to origin taking raft into account
|
||||
this->bb = mesh.bounding_box();
|
||||
if (this->config.raft_layers > 0) {
|
||||
@ -24,8 +26,6 @@ SLAPrint::slice()
|
||||
this->bb.max.x += this->config.raft_offset.value;
|
||||
this->bb.max.y += this->config.raft_offset.value;
|
||||
}
|
||||
mesh.translate(0, 0, -bb.min.z);
|
||||
this->bb.translate(0, 0, -bb.min.z);
|
||||
|
||||
// if we are generating a raft, first_layer_height will not affect mesh slicing
|
||||
const float lh = this->config.layer_height.value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user