mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Id-s put in a base class for support tree primitives
This commit is contained in:
parent
301a168b89
commit
f19b3a2344
4 changed files with 20 additions and 24 deletions
|
@ -58,12 +58,17 @@ template<class Vec> double distance(const Vec& pp1, const Vec& pp2) {
|
||||||
return distance(p);
|
return distance(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
const constexpr long ID_UNSET = -1;
|
|
||||||
|
|
||||||
const Vec3d DOWN = {0.0, 0.0, -1.0};
|
const Vec3d DOWN = {0.0, 0.0, -1.0};
|
||||||
|
|
||||||
|
struct SupportTreeNode
|
||||||
|
{
|
||||||
|
static const constexpr long ID_UNSET = -1;
|
||||||
|
|
||||||
|
long id = ID_UNSET; // For identification withing a tree.
|
||||||
|
};
|
||||||
|
|
||||||
// A pinhead originating from a support point
|
// A pinhead originating from a support point
|
||||||
struct Head {
|
struct Head: public SupportTreeNode {
|
||||||
Vec3d dir = DOWN;
|
Vec3d dir = DOWN;
|
||||||
Vec3d pos = {0, 0, 0};
|
Vec3d pos = {0, 0, 0};
|
||||||
|
|
||||||
|
@ -71,10 +76,7 @@ struct Head {
|
||||||
double r_pin_mm = 0.5;
|
double r_pin_mm = 0.5;
|
||||||
double width_mm = 2;
|
double width_mm = 2;
|
||||||
double penetration_mm = 0.5;
|
double penetration_mm = 0.5;
|
||||||
|
|
||||||
// For identification purposes. This will be used as the index into the
|
|
||||||
// container holding the head structures. See SLASupportTree::Impl
|
|
||||||
long id = ID_UNSET;
|
|
||||||
|
|
||||||
// If there is a pillar connecting to this head, then the id will be set.
|
// If there is a pillar connecting to this head, then the id will be set.
|
||||||
long pillar_id = ID_UNSET;
|
long pillar_id = ID_UNSET;
|
||||||
|
@ -115,21 +117,17 @@ struct Head {
|
||||||
};
|
};
|
||||||
|
|
||||||
// A junction connecting bridges and pillars
|
// A junction connecting bridges and pillars
|
||||||
struct Junction {
|
struct Junction: public SupportTreeNode {
|
||||||
double r = 1;
|
double r = 1;
|
||||||
Vec3d pos;
|
Vec3d pos;
|
||||||
|
|
||||||
long id = ID_UNSET;
|
|
||||||
|
|
||||||
Junction(const Vec3d &tr, double r_mm) : r(r_mm), pos(tr) {}
|
Junction(const Vec3d &tr, double r_mm) : r(r_mm), pos(tr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pillar {
|
struct Pillar: public SupportTreeNode {
|
||||||
double height, r;
|
double height, r;
|
||||||
Vec3d endpt;
|
Vec3d endpt;
|
||||||
|
|
||||||
long id = ID_UNSET;
|
|
||||||
|
|
||||||
// If the pillar connects to a head, this is the id of that head
|
// If the pillar connects to a head, this is the id of that head
|
||||||
bool starts_from_head = true; // Could start from a junction as well
|
bool starts_from_head = true; // Could start from a junction as well
|
||||||
long start_junction_id = ID_UNSET;
|
long start_junction_id = ID_UNSET;
|
||||||
|
@ -152,10 +150,9 @@ struct Pillar {
|
||||||
};
|
};
|
||||||
|
|
||||||
// A base for pillars or bridges that end on the ground
|
// A base for pillars or bridges that end on the ground
|
||||||
struct Pedestal {
|
struct Pedestal: public SupportTreeNode {
|
||||||
Vec3d pos;
|
Vec3d pos;
|
||||||
double height, r_bottom, r_top;
|
double height, r_bottom, r_top;
|
||||||
long id = ID_UNSET;
|
|
||||||
|
|
||||||
Pedestal(const Vec3d &p, double h, double rbottom, double rtop)
|
Pedestal(const Vec3d &p, double h, double rbottom, double rtop)
|
||||||
: pos{p}, height{h}, r_bottom{rbottom}, r_top{rtop}
|
: pos{p}, height{h}, r_bottom{rbottom}, r_top{rtop}
|
||||||
|
@ -167,9 +164,8 @@ struct Pedestal {
|
||||||
struct Anchor: public Head { using Head::Head; };
|
struct Anchor: public Head { using Head::Head; };
|
||||||
|
|
||||||
// A Bridge between two pillars (with junction endpoints)
|
// A Bridge between two pillars (with junction endpoints)
|
||||||
struct Bridge {
|
struct Bridge: public SupportTreeNode {
|
||||||
double r = 0.8;
|
double r = 0.8;
|
||||||
long id = ID_UNSET;
|
|
||||||
Vec3d startp = Vec3d::Zero(), endp = Vec3d::Zero();
|
Vec3d startp = Vec3d::Zero(), endp = Vec3d::Zero();
|
||||||
|
|
||||||
Bridge(const Vec3d &j1,
|
Bridge(const Vec3d &j1,
|
||||||
|
|
|
@ -570,7 +570,7 @@ bool SupportTreeBuildsteps::create_ground_pillar(const Vec3d &jp,
|
||||||
long head_id)
|
long head_id)
|
||||||
{
|
{
|
||||||
double sd = m_cfg.pillar_base_safety_distance_mm;
|
double sd = m_cfg.pillar_base_safety_distance_mm;
|
||||||
long pillar_id = ID_UNSET;
|
long pillar_id = SupportTreeNode::ID_UNSET;
|
||||||
bool can_add_base = radius >= m_cfg.head_back_radius_mm;
|
bool can_add_base = radius >= m_cfg.head_back_radius_mm;
|
||||||
double base_r = can_add_base ? m_cfg.base_radius_mm : 0.;
|
double base_r = can_add_base ? m_cfg.base_radius_mm : 0.;
|
||||||
double gndlvl = m_builder.ground_level;
|
double gndlvl = m_builder.ground_level;
|
||||||
|
@ -1029,7 +1029,7 @@ bool SupportTreeBuildsteps::connect_to_ground(Head &head)
|
||||||
|
|
||||||
bool SupportTreeBuildsteps::connect_to_model_body(Head &head)
|
bool SupportTreeBuildsteps::connect_to_model_body(Head &head)
|
||||||
{
|
{
|
||||||
if (head.id <= ID_UNSET) return false;
|
if (head.id <= SupportTreeNode::ID_UNSET) return false;
|
||||||
|
|
||||||
auto it = m_head_to_ground_scans.find(unsigned(head.id));
|
auto it = m_head_to_ground_scans.find(unsigned(head.id));
|
||||||
if (it == m_head_to_ground_scans.end()) return false;
|
if (it == m_head_to_ground_scans.end()) return false;
|
||||||
|
@ -1084,7 +1084,7 @@ bool SupportTreeBuildsteps::search_pillar_and_connect(const Head &source)
|
||||||
// We also need to remove elements progressively from the copied index.
|
// We also need to remove elements progressively from the copied index.
|
||||||
PointIndex spindex = m_pillar_index.guarded_clone();
|
PointIndex spindex = m_pillar_index.guarded_clone();
|
||||||
|
|
||||||
long nearest_id = ID_UNSET;
|
long nearest_id = SupportTreeNode::ID_UNSET;
|
||||||
|
|
||||||
Vec3d querypt = source.junction_point();
|
Vec3d querypt = source.junction_point();
|
||||||
|
|
||||||
|
@ -1105,7 +1105,7 @@ bool SupportTreeBuildsteps::search_pillar_and_connect(const Head &source)
|
||||||
if (size_t(nearest_id) < m_builder.pillarcount()) {
|
if (size_t(nearest_id) < m_builder.pillarcount()) {
|
||||||
if(!connect_to_nearpillar(source, nearest_id) ||
|
if(!connect_to_nearpillar(source, nearest_id) ||
|
||||||
m_builder.pillar(nearest_id).r < source.r_back_mm) {
|
m_builder.pillar(nearest_id).r < source.r_back_mm) {
|
||||||
nearest_id = ID_UNSET; // continue searching
|
nearest_id = SupportTreeNode::ID_UNSET; // continue searching
|
||||||
spindex.remove(ne); // without the current pillar
|
spindex.remove(ne); // without the current pillar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ class SupportTreeBuildsteps {
|
||||||
bool create_ground_pillar(const Vec3d &jp,
|
bool create_ground_pillar(const Vec3d &jp,
|
||||||
const Vec3d &sourcedir,
|
const Vec3d &sourcedir,
|
||||||
double radius,
|
double radius,
|
||||||
long head_id = ID_UNSET);
|
long head_id = SupportTreeNode::ID_UNSET);
|
||||||
|
|
||||||
void add_pillar_base(long pid)
|
void add_pillar_base(long pid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -175,8 +175,8 @@ void check_support_tree_integrity(const sla::SupportTreeBuilder &stree,
|
||||||
double H2 = cfg.max_dual_pillar_height_mm;
|
double H2 = cfg.max_dual_pillar_height_mm;
|
||||||
|
|
||||||
for (const sla::Head &head : stree.heads()) {
|
for (const sla::Head &head : stree.heads()) {
|
||||||
REQUIRE((!head.is_valid() || head.pillar_id != sla::ID_UNSET ||
|
REQUIRE((!head.is_valid() || head.pillar_id != sla::SupportTreeNode::ID_UNSET ||
|
||||||
head.bridge_id != sla::ID_UNSET));
|
head.bridge_id != sla::SupportTreeNode::ID_UNSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const sla::Pillar &pillar : stree.pillars()) {
|
for (const sla::Pillar &pillar : stree.pillars()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue