mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-12 19:21:49 +08:00
add pivot tree into ObjectPart struct
This commit is contained in:
parent
3d1f2f0cb6
commit
8723fb22bb
@ -566,13 +566,33 @@ std::tuple<LayerIslands, PixelGrid> reckon_islands(
|
|||||||
return {result, current_layer_grid};
|
return {result, current_layer_grid};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ObjectPart {
|
struct CoordinateFunctor {
|
||||||
|
const std::vector<Vec3f> *coordinates;
|
||||||
|
CoordinateFunctor(const std::vector<Vec3f> *coords) :
|
||||||
|
coordinates(coords) {
|
||||||
|
}
|
||||||
|
CoordinateFunctor() :
|
||||||
|
coordinates(nullptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const float& operator()(size_t idx, size_t dim) const {
|
||||||
|
return coordinates->operator [](idx)[dim];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//TODO make pivot tree part of this structure, with cached invalidation, then recompute manually when needed
|
||||||
|
class ObjectPart {
|
||||||
float volume { };
|
float volume { };
|
||||||
Vec3f volume_centroid_accumulator = Vec3f::Zero();
|
Vec3f volume_centroid_accumulator = Vec3f::Zero();
|
||||||
float sticking_force { };
|
float sticking_force { };
|
||||||
Vec3f sticking_centroid_accumulator = Vec3f::Zero();
|
Vec3f sticking_centroid_accumulator = Vec3f::Zero();
|
||||||
std::vector<Vec3f> pivot_points { };
|
std::vector<Vec3f> pivot_points { };
|
||||||
|
|
||||||
|
CoordinateFunctor pivots_coordinate_functor;
|
||||||
|
bool is_pivot_tree_valid = false;
|
||||||
|
KDTreeIndirect<3, float, CoordinateFunctor> pivot_tree { CoordinateFunctor { } };
|
||||||
|
|
||||||
|
public:
|
||||||
void add(const ObjectPart &other) {
|
void add(const ObjectPart &other) {
|
||||||
this->volume_centroid_accumulator += other.volume_centroid_accumulator;
|
this->volume_centroid_accumulator += other.volume_centroid_accumulator;
|
||||||
this->volume += other.volume;
|
this->volume += other.volume;
|
||||||
@ -587,9 +607,12 @@ struct ObjectPart {
|
|||||||
this->sticking_force = island.sticking_force;
|
this->sticking_force = island.sticking_force;
|
||||||
this->sticking_centroid_accumulator = island.sticking_centroid_accumulator;
|
this->sticking_centroid_accumulator = island.sticking_centroid_accumulator;
|
||||||
this->pivot_points = island.pivot_points;
|
this->pivot_points = island.pivot_points;
|
||||||
|
this->pivots_coordinate_functor = CoordinateFunctor(&this->pivot_points);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPart() = default;
|
ObjectPart() {
|
||||||
|
this->pivots_coordinate_functor = CoordinateFunctor(&this->pivot_points);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WeakestConnection {
|
struct WeakestConnection {
|
||||||
@ -691,6 +714,10 @@ Issues check_global_stability(const std::vector<LayerIslands> &islands_graph, co
|
|||||||
prev_island_to_weakest_connection = next_island_to_weakest_connection;
|
prev_island_to_weakest_connection = next_island_to_weakest_connection;
|
||||||
next_island_to_weakest_connection.clear();
|
next_island_to_weakest_connection.clear();
|
||||||
|
|
||||||
|
// All object parts updated, inactive parts removed and weakest point of each island updated as well.
|
||||||
|
// Now compute the stability of each active object part, adding supports where necessary, and also
|
||||||
|
// check each island whether the weakest point is strong enough. If not, add supports as well.
|
||||||
|
|
||||||
}
|
}
|
||||||
return issues;
|
return issues;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user