mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 04:15:55 +08:00
initial experimentation
This commit is contained in:
parent
888f45c0d3
commit
df554623bd
@ -47,6 +47,7 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
GUI/Gizmos/GLGizmoSlaSupports.hpp
|
GUI/Gizmos/GLGizmoSlaSupports.hpp
|
||||||
GUI/Gizmos/GLGizmoFdmSupports.cpp
|
GUI/Gizmos/GLGizmoFdmSupports.cpp
|
||||||
GUI/Gizmos/GLGizmoFdmSupports.hpp
|
GUI/Gizmos/GLGizmoFdmSupports.hpp
|
||||||
|
GUI/Gizmos/Experiment.cpp
|
||||||
GUI/Gizmos/GLGizmoFlatten.cpp
|
GUI/Gizmos/GLGizmoFlatten.cpp
|
||||||
GUI/Gizmos/GLGizmoFlatten.hpp
|
GUI/Gizmos/GLGizmoFlatten.hpp
|
||||||
GUI/Gizmos/GLGizmoCut.cpp
|
GUI/Gizmos/GLGizmoCut.cpp
|
||||||
|
77
src/slic3r/GUI/Gizmos/Experiment.cpp
Normal file
77
src/slic3r/GUI/Gizmos/Experiment.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include "libslic3r/Model.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "slic3r/GUI/GLCanvas3D.hpp"
|
||||||
|
#include "slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp"
|
||||||
|
#include "libslic3r/TriangleSelector.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r::GUI {
|
||||||
|
|
||||||
|
//TODO close in seprate namespace
|
||||||
|
|
||||||
|
struct Triangle {
|
||||||
|
stl_triangle_vertex_indices indices;
|
||||||
|
Vec3f normal;
|
||||||
|
size_t index_in_its;
|
||||||
|
Vec3i neighbours;
|
||||||
|
float min_z;
|
||||||
|
|
||||||
|
//members updated during algorithm
|
||||||
|
size_t area { 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SupportPlacerMesh {
|
||||||
|
|
||||||
|
indexed_triangle_set mesh;
|
||||||
|
std::vector<Triangle> triangles;
|
||||||
|
std::vector<size_t> triangle_indexes_by_z;
|
||||||
|
|
||||||
|
explicit SupportPlacerMesh(indexed_triangle_set &&mesh) :
|
||||||
|
mesh(mesh) {
|
||||||
|
|
||||||
|
auto neighbours = its_face_neighbors_par(mesh);
|
||||||
|
|
||||||
|
auto min_z_point = [](const size_t &t_index) {
|
||||||
|
const auto &t = triangles[t_index];
|
||||||
|
return std::min(mesh.vertices[t.indices.z()].z(),
|
||||||
|
std::min(mesh.vertices[t.indices.x()].z(), mesh.vertices[t.indices.y()].z()));
|
||||||
|
};
|
||||||
|
|
||||||
|
for (size_t face_index = 0; face_index < mesh.indices; ++face_index) {
|
||||||
|
Vec3f normal = its_face_normal(mesh, face_index);
|
||||||
|
triangles.push_back(Triangle { mesh.indices[face_index], normal, face_index, neighbours[face_index],
|
||||||
|
min_z_point(face_index) });
|
||||||
|
triangle_indexes_by_z.push_back(face_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(triangle_indexes_by_z.begin(), triangle_indexes_by_z.end(),
|
||||||
|
[&](const size_t &left, const size_t &right) {
|
||||||
|
return triangles[left].min_z < triangles[right].min_z;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign_areas() {
|
||||||
|
size_t next_to_process = 0;
|
||||||
|
while (next_to_process < triangles.size()) {
|
||||||
|
if (triangles[next_to_process].area > 0){
|
||||||
|
//already done, skip
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void do_experimental_support_placement(indexed_triangle_set mesh,
|
||||||
|
const TriangleSelectorGUI *selector) {
|
||||||
|
SupportPlacerMesh support_placer { std::move(mesh) };
|
||||||
|
|
||||||
|
support_placer.assign_areas();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -347,6 +347,12 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
|
|||||||
|
|
||||||
float dot_limit = limit.dot(down);
|
float dot_limit = limit.dot(down);
|
||||||
|
|
||||||
|
|
||||||
|
indexed_triangle_set mesh_triangles = mv->mesh().its;
|
||||||
|
its_transform(mesh_triangles, mi->get_matrix(true));
|
||||||
|
do_experimental_support_placement(std::move(mesh_triangles), m_triangle_selectors[mesh_id].get());
|
||||||
|
|
||||||
|
if (false) {
|
||||||
// Now calculate dot product of vert_direction and facets' normals.
|
// Now calculate dot product of vert_direction and facets' normals.
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
const indexed_triangle_set &its = mv->mesh().its;
|
const indexed_triangle_set &its = mv->mesh().its;
|
||||||
@ -357,6 +363,7 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
|
|||||||
}
|
}
|
||||||
++ idx;
|
++ idx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), block ? _L("Block supports by angle")
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), block ? _L("Block supports by angle")
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "GLGizmoPainterBase.hpp"
|
#include "GLGizmoPainterBase.hpp"
|
||||||
|
|
||||||
|
#include "Experiment.cpp"
|
||||||
|
|
||||||
namespace Slic3r::GUI {
|
namespace Slic3r::GUI {
|
||||||
|
|
||||||
class GLGizmoFdmSupports : public GLGizmoPainterBase
|
class GLGizmoFdmSupports : public GLGizmoPainterBase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user