mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 18:21:18 -06:00
Vojtech's improvements in the SLA preview cutting dialog.
This commit is contained in:
parent
678c513cb9
commit
4a210aeecf
7 changed files with 86 additions and 65 deletions
|
|
@ -897,13 +897,13 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const
|
|||
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
|
||||
#endif // !ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||
|
||||
TriangleMesh vol_mesh(v->mesh);
|
||||
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||
vol_mesh.transform(inst_matrix * v->get_matrix());
|
||||
bb.merge(vol_mesh.bounding_box());
|
||||
bb.merge(v->mesh.transformed_bounding_box(inst_matrix * v->get_matrix()));
|
||||
#else
|
||||
vol_mesh.transform(v->get_matrix());
|
||||
bb.merge(this->instances.front()->transform_mesh_bounding_box(vol_mesh, true));
|
||||
// unmaintaned
|
||||
assert(false);
|
||||
// vol_mesh.transform(v->get_matrix());
|
||||
// bb.merge(this->instances.front()->transform_mesh_bounding_box(vol_mesh, true));
|
||||
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||
}
|
||||
return bb;
|
||||
|
|
@ -920,13 +920,13 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_
|
|||
{
|
||||
if (v->is_model_part())
|
||||
{
|
||||
TriangleMesh mesh(v->mesh);
|
||||
#if ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||
mesh.transform(inst_matrix * v->get_matrix());
|
||||
bb.merge(mesh.bounding_box());
|
||||
bb.merge(v->mesh.transformed_bounding_box(inst_matrix * v->get_matrix()));
|
||||
#else
|
||||
mesh.transform(v->get_matrix());
|
||||
bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate));
|
||||
// not maintained
|
||||
assert(false);
|
||||
//mesh.transform(v->get_matrix());
|
||||
//bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate));
|
||||
#endif // ENABLE_GENERIC_SUBPARTS_PLACEMENT
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -805,14 +805,7 @@ void TriangleMeshSlicer::slice(const std::vector<float> &z, std::vector<Polygons
|
|||
void TriangleMeshSlicer::_slice_do(size_t facet_idx, std::vector<IntersectionLines>* lines, boost::mutex* lines_mutex,
|
||||
const std::vector<float> &z) const
|
||||
{
|
||||
const stl_facet &facet_orig = this->mesh->stl.facet_start[facet_idx];
|
||||
stl_facet facet = facet_orig;
|
||||
|
||||
if (m_use_quaternion) {
|
||||
facet.vertex[0] = m_quaternion * facet.vertex[0];
|
||||
facet.vertex[1] = m_quaternion * facet.vertex[1];
|
||||
facet.vertex[2] = m_quaternion * facet.vertex[2];
|
||||
}
|
||||
const stl_facet &facet = m_use_quaternion ? this->mesh->stl.facet_start[facet_idx].rotated(m_quaternion) : this->mesh->stl.facet_start[facet_idx];
|
||||
|
||||
// find facet extents
|
||||
const float min_z = fminf(facet.vertex[0](2), fminf(facet.vertex[1](2), facet.vertex[2](2)));
|
||||
|
|
@ -884,7 +877,7 @@ TriangleMeshSlicer::FacetSliceType TriangleMeshSlicer::slice_facet(
|
|||
const int *vertices = this->mesh->stl.v_indices[facet_idx].vertex;
|
||||
int i = (facet.vertex[1].z() == min_z) ? 1 : ((facet.vertex[2].z() == min_z) ? 2 : 0);
|
||||
|
||||
// These are used only if the cut plane is inclined:
|
||||
// These are used only if the cut plane is tilted:
|
||||
stl_vertex rotated_a;
|
||||
stl_vertex rotated_b;
|
||||
|
||||
|
|
@ -909,10 +902,11 @@ TriangleMeshSlicer::FacetSliceType TriangleMeshSlicer::slice_facet(
|
|||
// Is edge or face aligned with the cutting plane?
|
||||
if (a->z() == slice_z && b->z() == slice_z) {
|
||||
// Edge is horizontal and belongs to the current layer.
|
||||
// The following rotation of the three vertices may not be efficient, but this branch happens rarely.
|
||||
const stl_vertex &v0 = m_use_quaternion ? stl_vertex(m_quaternion * this->v_scaled_shared[vertices[0]]) : this->v_scaled_shared[vertices[0]];
|
||||
const stl_vertex &v1 = m_use_quaternion ? stl_vertex(m_quaternion * this->v_scaled_shared[vertices[1]]) : this->v_scaled_shared[vertices[1]];
|
||||
const stl_vertex &v2 = m_use_quaternion ? stl_vertex(m_quaternion * this->v_scaled_shared[vertices[2]]) : this->v_scaled_shared[vertices[2]];
|
||||
const stl_normal &normal = m_use_quaternion ? stl_vertex(m_quaternion * this->mesh->stl.facet_start[facet_idx].normal) : this->mesh->stl.facet_start[facet_idx].normal;
|
||||
const stl_normal &normal = facet.normal;
|
||||
// We may ignore this edge for slicing purposes, but we may still use it for object cutting.
|
||||
FacetSliceType result = Slicing;
|
||||
if (min_z == max_z) {
|
||||
|
|
@ -1029,7 +1023,7 @@ TriangleMeshSlicer::FacetSliceType TriangleMeshSlicer::slice_facet(
|
|||
i = vertices[2];
|
||||
assert(i != line_out->a_id && i != line_out->b_id);
|
||||
line_out->edge_type = ((m_use_quaternion ?
|
||||
m_quaternion * this->v_scaled_shared[i].z()
|
||||
(m_quaternion * this->v_scaled_shared[i]).z()
|
||||
: this->v_scaled_shared[i].z()) < slice_z) ? feTop : feBottom;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ public:
|
|||
TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd> &facets);
|
||||
TriangleMesh(const TriangleMesh &other) : repaired(false) { stl_initialize(&this->stl); *this = other; }
|
||||
TriangleMesh(TriangleMesh &&other) : repaired(false) { stl_initialize(&this->stl); this->swap(other); }
|
||||
~TriangleMesh() { stl_close(&this->stl); }
|
||||
~TriangleMesh() { clear(); }
|
||||
TriangleMesh& operator=(const TriangleMesh &other);
|
||||
TriangleMesh& operator=(TriangleMesh &&other) { this->swap(other); return *this; }
|
||||
void clear() { stl_close(&this->stl); this->repaired = false; }
|
||||
void swap(TriangleMesh &other) { std::swap(this->stl, other.stl); std::swap(this->repaired, other.repaired); }
|
||||
void ReadSTLFile(const char* input_file) { stl_open(&stl, input_file); }
|
||||
void write_ascii(const char* output_file) { stl_write_ascii(&this->stl, output_file, ""); }
|
||||
|
|
@ -182,7 +183,7 @@ private:
|
|||
// Quaternion that will be used to rotate every facet before the slicing
|
||||
Eigen::Quaternion<float, Eigen::DontAlign> m_quaternion;
|
||||
// Whether or not the above quaterion should be used
|
||||
bool m_use_quaternion = false;
|
||||
bool m_use_quaternion = false;
|
||||
|
||||
void _slice_do(size_t facet_idx, std::vector<IntersectionLines>* lines, boost::mutex* lines_mutex, const std::vector<float> &z) const;
|
||||
void make_loops(std::vector<IntersectionLine> &lines, Polygons* loops) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue