mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-26 18:21:18 -06:00
Removed the PRUS format parser. WIP: admesh eradication:
stl_stats are newly only accessed by TriangleMesh::stats(), most of the direct access to TriangleMesh::stl is gone with the exception of parsing input files (3MF, AMF, obj).
This commit is contained in:
parent
1c6ecd9c1a
commit
58d8ab3dea
22 changed files with 149 additions and 159 deletions
|
|
@ -288,9 +288,12 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
|
|||
|
||||
// Now calculate dot product of vert_direction and facets' normals.
|
||||
int idx = -1;
|
||||
for (const stl_facet &facet : mv->mesh().stl.facet_start) {
|
||||
++idx;
|
||||
if (facet.normal.dot(down) > dot_limit) {
|
||||
const indexed_triangle_set &its = mv->mesh().its;
|
||||
for (stl_triangle_vertex_indices face : its.indices) {
|
||||
stl_vertex vertex[3] = { its.vertices[face[0]], its.vertices[face[1]], its.vertices[face[2]] };
|
||||
stl_vertex n = (vertex[2] - vertex[1]).cross(vertex[3] - vertex[2]).normalized();
|
||||
++ idx;
|
||||
if (n.dot(down) > dot_limit) {
|
||||
m_triangle_selectors[mesh_id]->set_facet(idx, block ? EnforcerBlockerType::BLOCKER : EnforcerBlockerType::ENFORCER);
|
||||
m_triangle_selectors.back()->request_update_render_data();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,11 +142,13 @@ void GLGizmoFlatten::update_planes()
|
|||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
const int num_of_facets = ch.stl.stats.number_of_facets;
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
std::vector<bool> facet_visited(num_of_facets, false);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
const int num_of_facets = ch.facets_count();
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
|
||||
const std::vector<Vec3i> face_neighbors = its_face_neighbors(ch.its);
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
std::vector<bool> facet_visited(num_of_facets, false);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
while (1) {
|
||||
// Find next unvisited triangle:
|
||||
int facet_idx = 0;
|
||||
|
|
@ -154,7 +156,7 @@ void GLGizmoFlatten::update_planes()
|
|||
if (!facet_visited[facet_idx]) {
|
||||
facet_queue[facet_queue_cnt ++] = facet_idx;
|
||||
facet_visited[facet_idx] = true;
|
||||
normal_ptr = &ch.stl.facet_start[facet_idx].normal;
|
||||
normal_ptr = &face_normals[facet_idx];
|
||||
m_planes.emplace_back();
|
||||
break;
|
||||
}
|
||||
|
|
@ -163,18 +165,16 @@ void GLGizmoFlatten::update_planes()
|
|||
|
||||
while (facet_queue_cnt > 0) {
|
||||
int facet_idx = facet_queue[-- facet_queue_cnt];
|
||||
const stl_normal& this_normal = ch.stl.facet_start[facet_idx].normal;
|
||||
const stl_normal& this_normal = face_normals[facet_idx];
|
||||
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
|
||||
stl_vertex* first_vertex = ch.stl.facet_start[facet_idx].vertex;
|
||||
const Vec3i face = ch.its.indices[facet_idx];
|
||||
for (int j=0; j<3; ++j)
|
||||
m_planes.back().vertices.emplace_back(first_vertex[j].cast<double>());
|
||||
m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>());
|
||||
|
||||
facet_visited[facet_idx] = true;
|
||||
for (int j = 0; j < 3; ++ j) {
|
||||
int neighbor_idx = ch.stl.neighbors_start[facet_idx].neighbor[j];
|
||||
if (! facet_visited[neighbor_idx])
|
||||
for (int j = 0; j < 3; ++ j)
|
||||
if (int neighbor_idx = face_neighbors[facet_idx][j]; neighbor_idx >= 0 && ! facet_visited[neighbor_idx])
|
||||
facet_queue[facet_queue_cnt ++] = neighbor_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_planes.back().normal = normal_ptr->cast<double>();
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/GUI/Camera.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
|
||||
|
||||
|
||||
|
|
@ -20,17 +21,10 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
|
|||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
{
|
||||
// Make sphere and save it into a vertex buffer.
|
||||
const TriangleMesh sphere_mesh = make_sphere(1., (2*M_PI)/24.);
|
||||
for (size_t i=0; i<sphere_mesh.its.vertices.size(); ++i)
|
||||
m_vbo_sphere.push_geometry(sphere_mesh.its.vertices[i].cast<double>(),
|
||||
sphere_mesh.stl.facet_start[i].normal.cast<double>());
|
||||
for (const stl_triangle_vertex_indices& indices : sphere_mesh.its.indices)
|
||||
m_vbo_sphere.push_triangle(indices(0), indices(1), indices(2));
|
||||
m_vbo_sphere.load_its_flat_shading(its_make_sphere(1., (2*M_PI)/24.));
|
||||
m_vbo_sphere.finalize_geometry(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// port of 948bc382655993721d93d3b9fce9b0186fcfb211
|
||||
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
|
||||
{
|
||||
|
|
@ -632,9 +626,15 @@ void TriangleSelectorGUI::update_render_data()
|
|||
|
||||
GLIndexedVertexArray &iva = tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers : m_iva_blockers;
|
||||
int & cnt = tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt : blc_cnt;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
iva.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||
const Vec3f &v0 = m_vertices[tr.verts_idxs[0]].v;
|
||||
const Vec3f &v1 = m_vertices[tr.verts_idxs[1]].v;
|
||||
const Vec3f &v2 = m_vertices[tr.verts_idxs[2]].v;
|
||||
//FIXME the normal may likely be pulled from m_triangle_selectors, but it may not be worth the effort
|
||||
// or the current implementation may be more cache friendly.
|
||||
const Vec3f n = (v1 - v0).cross(v2 - v1).normalized();
|
||||
iva.push_geometry(v0, n);
|
||||
iva.push_geometry(v1, n);
|
||||
iva.push_geometry(v2, n);
|
||||
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||
cnt += 3;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue