Construct octree based on inserted points
This commit is contained in:
parent
c261624999
commit
680b1b9809
@ -91,10 +91,10 @@ std::pair<double, double> adaptive_fill_line_spacing(const PrintObject &print_ob
|
||||
}
|
||||
|
||||
void FillAdaptive::_fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
const FillParams ¶ms,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon &expolygon,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon &expolygon,
|
||||
Polylines &polylines_out)
|
||||
{
|
||||
Vec3d rotation = Vec3d((5.0 * M_PI) / 4.0, Geometry::deg2rad(215.264), M_PI / 6.0);
|
||||
@ -329,8 +329,8 @@ void FillAdaptive::expand_cube(
|
||||
}
|
||||
|
||||
std::vector<Vec3d> child_centers = {
|
||||
Vec3d(-1, -1, -1), Vec3d( 1, -1, -1), Vec3d(-1, 1, -1), Vec3d(-1, -1, 1),
|
||||
Vec3d( 1, 1, 1), Vec3d(-1, 1, 1), Vec3d( 1, -1, 1), Vec3d( 1, 1, -1)
|
||||
Vec3d(-1, -1, -1), Vec3d( 1, -1, -1), Vec3d(-1, 1, -1), Vec3d( 1, 1, -1),
|
||||
Vec3d(-1, -1, 1), Vec3d( 1, -1, 1), Vec3d(-1, 1, 1), Vec3d( 1, 1, 1)
|
||||
};
|
||||
|
||||
double cube_radius_squared = (cubes_properties[depth].height * cubes_properties[depth].height) / 16;
|
||||
@ -349,4 +349,37 @@ void FillAdaptive::expand_cube(
|
||||
}
|
||||
}
|
||||
|
||||
void FillAdaptive_Internal::Octree::propagate_point(
|
||||
Vec3d point,
|
||||
FillAdaptive_Internal::Cube * current,
|
||||
int depth,
|
||||
const std::vector<FillAdaptive_Internal::CubeProperties> &cubes_properties)
|
||||
{
|
||||
using namespace FillAdaptive_Internal;
|
||||
|
||||
if(depth <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size_t octant_idx = Octree::find_octant(point, current->center);
|
||||
Cube * child = current->children[octant_idx].get();
|
||||
|
||||
// Octant not exists, then create it
|
||||
if(child == nullptr) {
|
||||
std::vector<Vec3d> child_centers = {
|
||||
Vec3d(-1, -1, -1), Vec3d( 1, -1, -1), Vec3d(-1, 1, -1), Vec3d( 1, 1, -1),
|
||||
Vec3d(-1, -1, 1), Vec3d( 1, -1, 1), Vec3d(-1, 1, 1), Vec3d( 1, 1, 1)
|
||||
};
|
||||
|
||||
const Vec3d &child_center = child_centers[octant_idx];
|
||||
Vec3d child_center_transformed = current->center + (child_center * (cubes_properties[depth].edge_length / 4));
|
||||
|
||||
current->children[octant_idx] = std::make_unique<Cube>(child_center_transformed);
|
||||
child = current->children[octant_idx].get();
|
||||
}
|
||||
|
||||
Octree::propagate_point(point, child, (depth - 1), cubes_properties);
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
@ -35,6 +35,17 @@ namespace FillAdaptive_Internal
|
||||
|
||||
Octree(std::unique_ptr<Cube> rootCube, const Vec3d &origin, const std::vector<CubeProperties> &cubes_properties)
|
||||
: root_cube(std::move(rootCube)), origin(origin), cubes_properties(cubes_properties) {}
|
||||
|
||||
inline static int find_octant(const Vec3d &i_cube, const Vec3d ¤t)
|
||||
{
|
||||
return (i_cube.z() > current.z()) * 4 + (i_cube.y() > current.y()) * 2 + (i_cube.x() > current.x());
|
||||
}
|
||||
|
||||
static void propagate_point(
|
||||
Vec3d point,
|
||||
FillAdaptive_Internal::Cube *current_cube,
|
||||
int depth,
|
||||
const std::vector<FillAdaptive_Internal::CubeProperties> &cubes_properties);
|
||||
};
|
||||
}; // namespace FillAdaptive_Internal
|
||||
|
||||
@ -48,12 +59,6 @@ class FillAdaptive : public Fill
|
||||
public:
|
||||
virtual ~FillAdaptive() {}
|
||||
|
||||
static void insert_octant(
|
||||
FillAdaptive_Internal::Cube * i_cube,
|
||||
FillAdaptive_Internal::Cube * current,
|
||||
int depth,
|
||||
const std::vector<FillAdaptive_Internal::CubeProperties> &cubes_properties);
|
||||
|
||||
protected:
|
||||
virtual Fill* clone() const { return new FillAdaptive(*this); };
|
||||
virtual void _fill_surface_single(
|
||||
|
Loading…
Reference in New Issue
Block a user