Moved TriangleSelectorWrapper methods to cpp file, added comment describing problems with FacetsAnnotations/TriangleSelector

structure
This commit is contained in:
PavelMikus 2022-04-07 13:52:59 +02:00
parent 706cd63e61
commit e516ba0dd0
4 changed files with 39 additions and 22 deletions

View file

@ -17,6 +17,7 @@
#include "Fill/FillLightning.hpp"
#include "Format/STL.hpp"
#include "SupportableIssuesSearch.hpp"
#include "TriangleSelectorWrapper.hpp"
#include <float.h>
#include <string_view>

View file

@ -172,7 +172,7 @@ Issues check_extrusion_entity_stability(const ExtrusionEntity *entity, size_t la
curvature = 0;
}
if (unsupported_distance > params.bridge_distance / (1 + int(max_curvature * 9 / PI))) {
if (unsupported_distance > params.bridge_distance / (1 + int(max_curvature * 7 / PI))) {
issues.supports_nedded.push_back(u_point);
unsupported_distance = 0;
curvature = 0;

View file

@ -1 +1,30 @@
#include "Model.hpp"
#include "TriangleSelectorWrapper.hpp"
#include <memory>
namespace Slic3r {
TriangleSelectorWrapper::TriangleSelectorWrapper(const TriangleMesh &mesh) :
mesh(mesh), selector(mesh), triangles_tree(
AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(mesh.its.vertices, mesh.its.indices)) {
}
void TriangleSelectorWrapper::enforce_spot(const Vec3f &point, float radius) {
size_t hit_face_index;
Vec3f hit_point;
auto dist = AABBTreeIndirect::squared_distance_to_indexed_triangle_set(mesh.its.vertices, mesh.its.indices,
triangles_tree,
point, hit_face_index, hit_point);
if (dist < 0 || dist > radius)
return;
std::unique_ptr<TriangleSelector::Cursor> cursor = std::make_unique<TriangleSelector::Sphere>(point, point,
radius, Transform3d::Identity(), TriangleSelector::ClippingPlane { });
selector.select_patch(hit_face_index, std::move(cursor), EnforcerBlockerType::ENFORCER, Transform3d::Identity(),
true,
0.0f);
}
}

View file

@ -1,39 +1,26 @@
#ifndef SRC_LIBSLIC3R_TRIANGLESELECTORWRAPPER_HPP_
#define SRC_LIBSLIC3R_TRIANGLESELECTORWRAPPER_HPP_
#include <memory>
#include "TriangleSelector.hpp"
#include "AABBTreeIndirect.hpp"
namespace Slic3r {
//NOTE: We need to replace the FacetsAnnotation struct for support storage (or extend/add another)
// Problems: Does not support negative volumes, strange usage for supports computed from extrusion -
// expensively converted back to triangles and then sliced again.
// Another problem is weird and very limited interface when painting supports via algorithms
class TriangleSelectorWrapper {
public:
const TriangleMesh &mesh;
TriangleSelector selector;
AABBTreeIndirect::Tree<3, float> triangles_tree;
TriangleSelectorWrapper(const TriangleMesh &mesh) :
mesh(mesh), selector(mesh), triangles_tree(AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(mesh.its.vertices, mesh.its.indices)) {
TriangleSelectorWrapper(const TriangleMesh &mesh);
}
void enforce_spot(const Vec3f &point, float radius) {
size_t hit_face_index;
Vec3f hit_point;
auto dist = AABBTreeIndirect::squared_distance_to_indexed_triangle_set(mesh.its.vertices, mesh.its.indices,
triangles_tree,
point, hit_face_index, hit_point);
if (dist < 0 || dist > radius)
return;
std::unique_ptr<TriangleSelector::Cursor> cursor = std::make_unique<TriangleSelector::Sphere>(point, point,
radius, Transform3d::Identity(), TriangleSelector::ClippingPlane { });
selector.select_patch(hit_face_index, std::move(cursor), EnforcerBlockerType::ENFORCER, Transform3d::Identity(), true,
0.0f);
}
void enforce_spot(const Vec3f &point, float radius);
};