mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-18 20:35:56 +08:00
[partialy] Support for islands
This commit is contained in:
parent
fc23b8cf80
commit
44e47026f8
@ -312,6 +312,30 @@ void SupportPointGenerator::process(const std::vector<ExPolygons>& slices, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Vec2f> SupportPointGenerator::uniform_cover_island(
|
||||||
|
SupportPointGenerator::Structure &structure)
|
||||||
|
{
|
||||||
|
// X is maximal distance between 2 support points on island
|
||||||
|
float x = 10;
|
||||||
|
float one_support_area = M_PI * x;
|
||||||
|
const ExPolygon &island = *structure.polygon;
|
||||||
|
float area = structure.area;
|
||||||
|
const Point & bb_size = structure.bbox.size();
|
||||||
|
|
||||||
|
// only one support point?
|
||||||
|
if (area < one_support_area &&
|
||||||
|
bb_size[0] < x &&
|
||||||
|
bb_size[1] < x ) {
|
||||||
|
structure.centroid
|
||||||
|
}
|
||||||
|
|
||||||
|
// longest distance in area
|
||||||
|
float size = getSize()
|
||||||
|
// calculate island moments
|
||||||
|
|
||||||
|
// unit support force 11.1f / density_relative(1.)
|
||||||
|
}
|
||||||
|
|
||||||
void SupportPointGenerator::add_support_points(SupportPointGenerator::Structure &s, SupportPointGenerator::PointGrid3D &grid3d)
|
void SupportPointGenerator::add_support_points(SupportPointGenerator::Structure &s, SupportPointGenerator::PointGrid3D &grid3d)
|
||||||
{
|
{
|
||||||
// Select each type of surface (overrhang, dangling, slope), derive the support
|
// Select each type of surface (overrhang, dangling, slope), derive the support
|
||||||
@ -324,6 +348,7 @@ void SupportPointGenerator::add_support_points(SupportPointGenerator::Structure
|
|||||||
// completely new island - needs support no doubt
|
// completely new island - needs support no doubt
|
||||||
// deficit is full, there is nothing below that would hold this island
|
// deficit is full, there is nothing below that would hold this island
|
||||||
uniformly_cover({ *s.polygon }, s, s.area * tp, grid3d, IslandCoverageFlags(icfIsNew | icfWithBoundary) );
|
uniformly_cover({ *s.polygon }, s, s.area * tp, grid3d, IslandCoverageFlags(icfIsNew | icfWithBoundary) );
|
||||||
|
grid3d.insert(uniform_cover_island(s), s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +584,6 @@ static inline std::vector<Vec2f> poisson_disk_from_samples(const std::vector<Vec
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SupportPointGenerator::uniformly_cover(const ExPolygons& islands, Structure& structure, float deficit, PointGrid3D &grid3d, IslandCoverageFlags flags)
|
void SupportPointGenerator::uniformly_cover(const ExPolygons& islands, Structure& structure, float deficit, PointGrid3D &grid3d, IslandCoverageFlags flags)
|
||||||
{
|
{
|
||||||
//int num_of_points = std::max(1, (int)((island.area()*pow(SCALING_FACTOR, 2) * m_config.tear_pressure)/m_config.support_force));
|
//int num_of_points = std::max(1, (int)((island.area()*pow(SCALING_FACTOR, 2) * m_config.tear_pressure)/m_config.support_force));
|
||||||
|
@ -161,6 +161,11 @@ public:
|
|||||||
grid.emplace(cell_id(pt.position), pt);
|
grid.emplace(cell_id(pt.position), pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert(const std::vector<Vec2f> &pos, Structure *island)
|
||||||
|
{
|
||||||
|
for (const auto &p : pos) insert(p, island);
|
||||||
|
}
|
||||||
|
|
||||||
bool collides_with(const Vec2f &pos, float print_z, float radius) {
|
bool collides_with(const Vec2f &pos, float print_z, float radius) {
|
||||||
Vec3f pos3d(pos.x(), pos.y(), print_z);
|
Vec3f pos3d(pos.x(), pos.y(), print_z);
|
||||||
Vec3i cell = cell_id(pos3d);
|
Vec3i cell = cell_id(pos3d);
|
||||||
@ -204,8 +209,9 @@ private:
|
|||||||
public:
|
public:
|
||||||
enum IslandCoverageFlags : uint8_t { icfNone = 0x0, icfIsNew = 0x1, icfWithBoundary = 0x2 };
|
enum IslandCoverageFlags : uint8_t { icfNone = 0x0, icfIsNew = 0x1, icfWithBoundary = 0x2 };
|
||||||
|
|
||||||
|
public: // for testing
|
||||||
|
std::vector<Vec2f> uniform_cover_island(SupportPointGenerator::Structure &structure);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void uniformly_cover(const ExPolygons& islands, Structure& structure, float deficit, PointGrid3D &grid3d, IslandCoverageFlags flags = icfNone);
|
void uniformly_cover(const ExPolygons& islands, Structure& structure, float deficit, PointGrid3D &grid3d, IslandCoverageFlags flags = icfNone);
|
||||||
|
|
||||||
void add_support_points(Structure& structure, PointGrid3D &grid3d);
|
void add_support_points(Structure& structure, PointGrid3D &grid3d);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user