mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 22:24:01 -06:00

TriangleMesh newly only holds indexed_triangle_set and TriangleMeshStats. TriangleMeshStats contains an excerpt of stl_stats. TriangleMeshStats are updated when initializing with indexed_triangle_set. Admesh triangle mesh fixing is newly only used when loading an STL. AMF / 3MF / OBJ file formats are already indexed triangle sets, thus they are no more converted to admesh stl_file format, nor fixed through admesh repair machinery. When importing AMF / 3MF / OBJ files, volume is calculated and if negative, all faces are flipped. Also a bounding box and number of open edges is calculated. Implemented its_number_of_patches(), its_num_open_edges() Optimized its_split(), its_is_splittable() using a visitor pattern. Reworked QHull integration into TriangleMesh: 1) Face normals were not right. 2) Indexed triangle set is newly emitted instead of duplicating vertices for each face. Fixed cut_mesh(): Orient the triangulated faces correctly.
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#ifndef REPROJECTPOINTSONMESH_HPP
|
|
#define REPROJECTPOINTSONMESH_HPP
|
|
|
|
#include "libslic3r/Point.hpp"
|
|
#include "SupportPoint.hpp"
|
|
#include "Hollowing.hpp"
|
|
#include "IndexedMesh.hpp"
|
|
#include "libslic3r/Model.hpp"
|
|
|
|
#include <tbb/parallel_for.h>
|
|
|
|
namespace Slic3r { namespace sla {
|
|
|
|
template<class Pt> Vec3d pos(const Pt &p) { return p.pos.template cast<double>(); }
|
|
template<class Pt> void pos(Pt &p, const Vec3d &pp) { p.pos = pp.cast<float>(); }
|
|
|
|
template<class PointType>
|
|
void reproject_support_points(const IndexedMesh &mesh, std::vector<PointType> &pts)
|
|
{
|
|
tbb::parallel_for(size_t(0), pts.size(), [&mesh, &pts](size_t idx) {
|
|
int junk;
|
|
Vec3d new_pos;
|
|
mesh.squared_distance(pos(pts[idx]), junk, new_pos);
|
|
pos(pts[idx], new_pos);
|
|
});
|
|
}
|
|
|
|
inline void reproject_points_and_holes(ModelObject *object)
|
|
{
|
|
bool has_sppoints = !object->sla_support_points.empty();
|
|
bool has_holes = !object->sla_drain_holes.empty();
|
|
|
|
if (!object || (!has_holes && !has_sppoints)) return;
|
|
|
|
TriangleMesh rmsh = object->raw_mesh();
|
|
IndexedMesh emesh{rmsh};
|
|
|
|
if (has_sppoints)
|
|
reproject_support_points(emesh, object->sla_support_points);
|
|
|
|
if (has_holes)
|
|
reproject_support_points(emesh, object->sla_drain_holes);
|
|
}
|
|
|
|
}}
|
|
#endif // REPROJECTPOINTSONMESH_HPP
|