Add test obj and address for support under ground level if no elevation

This commit is contained in:
tamasmeszaros 2019-10-03 14:23:03 +02:00
parent 23a7e77a81
commit c4d50ea639
6 changed files with 2535 additions and 18 deletions

View File

@ -308,6 +308,8 @@ public:
template<class...Args> long add_pillar(long headid, Args&&... args) template<class...Args> long add_pillar(long headid, Args&&... args)
{ {
std::lock_guard<Mutex> lk(m_mutex); 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()); assert(headid >= 0 && headid < m_head_indices.size());
Head &head = m_heads[m_head_indices[size_t(headid)]]; Head &head = m_heads[m_head_indices[size_t(headid)]];
@ -357,6 +359,8 @@ public:
template<class...Args> long add_pillar(Args&&...args) template<class...Args> long add_pillar(Args&&...args)
{ {
std::lock_guard<Mutex> lk(m_mutex); 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)...); m_pillars.emplace_back(std::forward<Args>(args)...);
Pillar& pillar = m_pillars.back(); Pillar& pillar = m_pillars.back();
pillar.id = long(m_pillars.size() - 1); pillar.id = long(m_pillars.size() - 1);

View File

@ -440,7 +440,7 @@ bool SupportTreeBuildsteps::interconnect(const Pillar &pillar,
bool SupportTreeBuildsteps::connect_to_nearpillar(const Head &head, bool SupportTreeBuildsteps::connect_to_nearpillar(const Head &head,
long nearpillar_id) long nearpillar_id)
{ {
auto nearpillar = [this, nearpillar_id]() { auto nearpillar = [this, nearpillar_id]() -> const Pillar& {
return m_builder.pillar(nearpillar_id); return m_builder.pillar(nearpillar_id);
}; };
@ -543,9 +543,8 @@ bool SupportTreeBuildsteps::search_pillar_and_connect(const Head &head)
nearest_id = ne.second; nearest_id = ne.second;
if(nearest_id >= 0) { if(nearest_id >= 0) {
auto nearpillarID = unsigned(nearest_id); if(size_t(nearest_id) < m_builder.pillarcount()) {
if(nearpillarID < m_builder.pillarcount()) { if(!connect_to_nearpillar(head, nearest_id)) {
if(!connect_to_nearpillar(head, nearpillarID)) {
nearest_id = ID_UNSET; // continue searching nearest_id = ID_UNSET; // continue searching
spindex.remove(ne); // without the current pillar spindex.remove(ne); // without the current pillar
} }
@ -1361,22 +1360,21 @@ void SupportTreeBuildsteps::routing_headless()
// This is only for checking // This is only for checking
double idist = bridge_mesh_intersect(sph, dir, R, true); double idist = bridge_mesh_intersect(sph, dir, R, true);
double dist = ray_mesh_intersect(sj, dir); double realdist = ray_mesh_intersect(sj, dir);
if (std::isinf(dist)) double dist = realdist;
dist = sph(Z) - m_mesh.ground_level()
+ m_mesh.ground_level_offset();
if(std::isnan(idist) || idist < 2*R || if (std::isinf(dist)) dist = sph(Z) - m_builder.ground_level;
std::isnan(dist) || dist < 2*R)
{ if(std::isnan(idist) || idist < 2*R || std::isnan(dist) || dist < 2*R) {
BOOST_LOG_TRIVIAL(warning) << "Can not find route for headless" BOOST_LOG_TRIVIAL(warning) << "Can not find route for headless"
<< " support stick at: " << " support stick at: "
<< sj.transpose(); << sj.transpose();
continue; continue;
} }
Vec3d ej = sj + (dist + HWIDTH_MM)* dir; bool use_endball = !std::isinf(realdist);
m_builder.add_compact_bridge(sp, ej, n, R, !std::isinf(dist)); Vec3d ej = sj + (dist + HWIDTH_MM) * dir;
m_builder.add_compact_bridge(sp, ej, n, R, use_endball);
} }
} }

View File

@ -236,7 +236,7 @@ bool TriangleMesh::needed_repair() const
|| this->stl.stats.backwards_edges > 0; || 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); its_write_obj(this->its, output_file);
} }

View File

@ -31,7 +31,7 @@ public:
float volume(); float volume();
void check_topology(); void check_topology();
bool is_manifold() const { return this->stl.stats.connected_facets_3_edge == (int)this->stl.stats.number_of_facets; } 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(float factor);
void scale(const Vec3d &versor); void scale(const Vec3d &versor);
void translate(float x, float y, float z); void translate(float x, float y, float z);

2504
tests/data/A_upsidedown.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@
#include "libslic3r/MTUtils.hpp" #include "libslic3r/MTUtils.hpp"
#include "libslic3r/SVG.hpp" #include "libslic3r/SVG.hpp"
#include "libslic3r/Format/OBJ.hpp"
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
#define PATH_SEPARATOR R"(\)" #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 // If there is no elevation, support points shall be removed from the
// bottom of the object. // 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, sla::remove_bottom_points(support_points, zmin,
supportcfg.base_height_mm); supportcfg.base_height_mm);
} else { } else {
@ -225,7 +226,16 @@ void test_supports(const std::string & obj_filename,
// Quick check if the dimensions and placement of supports are correct // Quick check if the dimensions and placement of supports are correct
auto obb = output_mesh.bounding_box(); 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); ASSERT_LE(obb.max.z(), zmax);
// Move out the support tree into the byproducts, we can examine it further // 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[] = { const char *const SUPPORT_TEST_MODELS[] = {
"cube_with_concave_hole_enlarged_standing.obj" "cube_with_concave_hole_enlarged_standing.obj",
"A_upsidedown.obj"
}; };
} // namespace } // namespace