Add test obj and address for support under ground level if no elevation
This commit is contained in:
parent
23a7e77a81
commit
c4d50ea639
@ -308,6 +308,8 @@ public:
|
||||
template<class...Args> long add_pillar(long headid, Args&&... args)
|
||||
{
|
||||
std::lock_guard<Mutex> lk(m_mutex);
|
||||
if (m_pillars.capacity() < m_heads.size())
|
||||
m_pillars.reserve(m_heads.size() * 2);
|
||||
|
||||
assert(headid >= 0 && headid < m_head_indices.size());
|
||||
Head &head = m_heads[m_head_indices[size_t(headid)]];
|
||||
@ -357,6 +359,8 @@ public:
|
||||
template<class...Args> long add_pillar(Args&&...args)
|
||||
{
|
||||
std::lock_guard<Mutex> lk(m_mutex);
|
||||
if (m_pillars.capacity() < m_heads.size())
|
||||
m_pillars.reserve(m_heads.size() * 2);
|
||||
m_pillars.emplace_back(std::forward<Args>(args)...);
|
||||
Pillar& pillar = m_pillars.back();
|
||||
pillar.id = long(m_pillars.size() - 1);
|
||||
|
@ -440,7 +440,7 @@ bool SupportTreeBuildsteps::interconnect(const Pillar &pillar,
|
||||
bool SupportTreeBuildsteps::connect_to_nearpillar(const Head &head,
|
||||
long nearpillar_id)
|
||||
{
|
||||
auto nearpillar = [this, nearpillar_id]() {
|
||||
auto nearpillar = [this, nearpillar_id]() -> const Pillar& {
|
||||
return m_builder.pillar(nearpillar_id);
|
||||
};
|
||||
|
||||
@ -543,9 +543,8 @@ bool SupportTreeBuildsteps::search_pillar_and_connect(const Head &head)
|
||||
nearest_id = ne.second;
|
||||
|
||||
if(nearest_id >= 0) {
|
||||
auto nearpillarID = unsigned(nearest_id);
|
||||
if(nearpillarID < m_builder.pillarcount()) {
|
||||
if(!connect_to_nearpillar(head, nearpillarID)) {
|
||||
if(size_t(nearest_id) < m_builder.pillarcount()) {
|
||||
if(!connect_to_nearpillar(head, nearest_id)) {
|
||||
nearest_id = ID_UNSET; // continue searching
|
||||
spindex.remove(ne); // without the current pillar
|
||||
}
|
||||
@ -1361,22 +1360,21 @@ void SupportTreeBuildsteps::routing_headless()
|
||||
|
||||
// This is only for checking
|
||||
double idist = bridge_mesh_intersect(sph, dir, R, true);
|
||||
double dist = ray_mesh_intersect(sj, dir);
|
||||
if (std::isinf(dist))
|
||||
dist = sph(Z) - m_mesh.ground_level()
|
||||
+ m_mesh.ground_level_offset();
|
||||
double realdist = ray_mesh_intersect(sj, dir);
|
||||
double dist = realdist;
|
||||
|
||||
if(std::isnan(idist) || idist < 2*R ||
|
||||
std::isnan(dist) || dist < 2*R)
|
||||
{
|
||||
if (std::isinf(dist)) dist = sph(Z) - m_builder.ground_level;
|
||||
|
||||
if(std::isnan(idist) || idist < 2*R || std::isnan(dist) || dist < 2*R) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Can not find route for headless"
|
||||
<< " support stick at: "
|
||||
<< sj.transpose();
|
||||
continue;
|
||||
}
|
||||
|
||||
Vec3d ej = sj + (dist + HWIDTH_MM)* dir;
|
||||
m_builder.add_compact_bridge(sp, ej, n, R, !std::isinf(dist));
|
||||
bool use_endball = !std::isinf(realdist);
|
||||
Vec3d ej = sj + (dist + HWIDTH_MM) * dir;
|
||||
m_builder.add_compact_bridge(sp, ej, n, R, use_endball);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ bool TriangleMesh::needed_repair() const
|
||||
|| this->stl.stats.backwards_edges > 0;
|
||||
}
|
||||
|
||||
void TriangleMesh::WriteOBJFile(const char* output_file)
|
||||
void TriangleMesh::WriteOBJFile(const char* output_file) const
|
||||
{
|
||||
its_write_obj(this->its, output_file);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
float volume();
|
||||
void check_topology();
|
||||
bool is_manifold() const { return this->stl.stats.connected_facets_3_edge == (int)this->stl.stats.number_of_facets; }
|
||||
void WriteOBJFile(const char* output_file);
|
||||
void WriteOBJFile(const char* output_file) const;
|
||||
void scale(float factor);
|
||||
void scale(const Vec3d &versor);
|
||||
void translate(float x, float y, float z);
|
||||
|
2504
tests/data/A_upsidedown.obj
Normal file
2504
tests/data/A_upsidedown.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@
|
||||
#include "libslic3r/MTUtils.hpp"
|
||||
|
||||
#include "libslic3r/SVG.hpp"
|
||||
#include "libslic3r/Format/OBJ.hpp"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define PATH_SEPARATOR R"(\)"
|
||||
@ -202,7 +203,7 @@ void test_supports(const std::string & obj_filename,
|
||||
|
||||
// If there is no elevation, support points shall be removed from the
|
||||
// bottom of the object.
|
||||
if (supportcfg.object_elevation_mm < EPSILON) {
|
||||
if (std::abs(supportcfg.object_elevation_mm) < EPSILON) {
|
||||
sla::remove_bottom_points(support_points, zmin,
|
||||
supportcfg.base_height_mm);
|
||||
} else {
|
||||
@ -225,7 +226,16 @@ void test_supports(const std::string & obj_filename,
|
||||
|
||||
// Quick check if the dimensions and placement of supports are correct
|
||||
auto obb = output_mesh.bounding_box();
|
||||
ASSERT_DOUBLE_EQ(obb.min.z(), zmin - supportcfg.object_elevation_mm);
|
||||
|
||||
double allowed_zmin = zmin - supportcfg.object_elevation_mm;
|
||||
|
||||
if (std::abs(supportcfg.object_elevation_mm) < EPSILON)
|
||||
allowed_zmin = zmin - 2 * supportcfg.head_back_radius_mm;
|
||||
|
||||
if (std::abs(obb.min.z() - allowed_zmin) > EPSILON)
|
||||
output_mesh.WriteOBJFile("outmesh_supports.obj");
|
||||
|
||||
ASSERT_GE(obb.min.z(), allowed_zmin);
|
||||
ASSERT_LE(obb.max.z(), zmax);
|
||||
|
||||
// Move out the support tree into the byproducts, we can examine it further
|
||||
@ -286,7 +296,8 @@ const char * const AROUND_PAD_TEST_OBJECTS[] = {
|
||||
};
|
||||
|
||||
const char *const SUPPORT_TEST_MODELS[] = {
|
||||
"cube_with_concave_hole_enlarged_standing.obj"
|
||||
"cube_with_concave_hole_enlarged_standing.obj",
|
||||
"A_upsidedown.obj"
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user