mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-24 13:38:14 +08:00
Octree's first cube depends on model size.
This commit is contained in:
parent
71237cf11f
commit
fd3a31651c
@ -142,9 +142,8 @@ void FillAdaptive::merge_polylines(Polylines &polylines, const Line &new_line)
|
|||||||
|
|
||||||
|
|
||||||
std::unique_ptr<FillAdaptive_Internal::Octree> FillAdaptive::build_octree(
|
std::unique_ptr<FillAdaptive_Internal::Octree> FillAdaptive::build_octree(
|
||||||
TriangleMesh &triangleMesh,
|
TriangleMesh &triangle_mesh,
|
||||||
coordf_t line_spacing,
|
coordf_t line_spacing,
|
||||||
const BoundingBoxf3 &printer_volume,
|
|
||||||
const Vec3d &cube_center)
|
const Vec3d &cube_center)
|
||||||
{
|
{
|
||||||
using namespace FillAdaptive_Internal;
|
using namespace FillAdaptive_Internal;
|
||||||
@ -154,10 +153,11 @@ std::unique_ptr<FillAdaptive_Internal::Octree> FillAdaptive::build_octree(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The furthest point from center of bed.
|
Vec3d bb_size = triangle_mesh.bounding_box().size();
|
||||||
double furthest_point = std::sqrt(((printer_volume.size()[0] * printer_volume.size()[0]) / 4.0) +
|
// The furthest point from the center of the bottom of the mesh bounding box.
|
||||||
((printer_volume.size()[1] * printer_volume.size()[1]) / 4.0) +
|
double furthest_point = std::sqrt(((bb_size.x() * bb_size.x()) / 4.0) +
|
||||||
(printer_volume.size()[2] * printer_volume.size()[2]));
|
((bb_size.y() * bb_size.y()) / 4.0) +
|
||||||
|
(bb_size.z() * bb_size.z()));
|
||||||
double max_cube_edge_length = furthest_point * 2;
|
double max_cube_edge_length = furthest_point * 2;
|
||||||
|
|
||||||
std::vector<CubeProperties> cubes_properties;
|
std::vector<CubeProperties> cubes_properties;
|
||||||
@ -172,19 +172,20 @@ std::unique_ptr<FillAdaptive_Internal::Octree> FillAdaptive::build_octree(
|
|||||||
cubes_properties.push_back(props);
|
cubes_properties.push_back(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triangleMesh.its.vertices.empty())
|
if (triangle_mesh.its.vertices.empty())
|
||||||
{
|
{
|
||||||
triangleMesh.require_shared_vertices();
|
triangle_mesh.require_shared_vertices();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d rotation = Vec3d(Geometry::deg2rad(225.0), Geometry::deg2rad(215.264), Geometry::deg2rad(30.0));
|
Vec3d rotation = Vec3d(Geometry::deg2rad(225.0), Geometry::deg2rad(215.264), Geometry::deg2rad(30.0));
|
||||||
Transform3d rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), rotation, Vec3d::Ones(), Vec3d::Ones());
|
Transform3d rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), rotation, Vec3d::Ones(), Vec3d::Ones());
|
||||||
|
|
||||||
AABBTreeIndirect::Tree3f aabbTree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(triangleMesh.its.vertices, triangleMesh.its.indices);
|
AABBTreeIndirect::Tree3f aabbTree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(
|
||||||
|
triangle_mesh.its.vertices, triangle_mesh.its.indices);
|
||||||
std::unique_ptr<Octree> octree = std::unique_ptr<Octree>(
|
std::unique_ptr<Octree> octree = std::unique_ptr<Octree>(
|
||||||
new Octree{std::unique_ptr<Cube>(new Cube{cube_center, cubes_properties.size() - 1, cubes_properties.back()}), cube_center});
|
new Octree{std::unique_ptr<Cube>(new Cube{cube_center, cubes_properties.size() - 1, cubes_properties.back()}), cube_center});
|
||||||
|
|
||||||
FillAdaptive::expand_cube(octree->root_cube.get(), cubes_properties, rotation_matrix, aabbTree, triangleMesh);
|
FillAdaptive::expand_cube(octree->root_cube.get(), cubes_properties, rotation_matrix, aabbTree, triangle_mesh);
|
||||||
|
|
||||||
return octree;
|
return octree;
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<FillAdaptive_Internal::Octree> build_octree(
|
static std::unique_ptr<FillAdaptive_Internal::Octree> build_octree(
|
||||||
TriangleMesh &triangleMesh,
|
TriangleMesh &triangle_mesh,
|
||||||
coordf_t line_spacing,
|
coordf_t line_spacing,
|
||||||
const BoundingBoxf3 &printer_volume,
|
|
||||||
const Vec3d &cube_center);
|
const Vec3d &cube_center);
|
||||||
|
|
||||||
static void expand_cube(
|
static void expand_cube(
|
||||||
|
@ -447,16 +447,11 @@ std::unique_ptr<FillAdaptive_Internal::Octree> PrintObject::prepare_adaptive_inf
|
|||||||
|
|
||||||
coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f);
|
coordf_t line_spacing = infill_extrusion_width / ((fill_density / 100.0f) * 0.333333333f);
|
||||||
|
|
||||||
BoundingBoxf bed_shape(this->print()->config().bed_shape.values);
|
|
||||||
BoundingBoxf3 printer_volume(Vec3d(bed_shape.min.x(), bed_shape.min.y(), 0),
|
|
||||||
Vec3d(bed_shape.max.x(), bed_shape.max.y(), this->print()->config().max_print_height));
|
|
||||||
|
|
||||||
Vec3d model_center = this->model_object()->bounding_box().center();
|
|
||||||
model_center.z() = 0.0f; // Set position in Z axis to 0
|
|
||||||
// Center of the first cube in octree
|
// Center of the first cube in octree
|
||||||
|
Vec3d model_center = this->model_object()->bounding_box().center();
|
||||||
|
|
||||||
TriangleMesh mesh = this->model_object()->mesh();
|
TriangleMesh mesh = this->model_object()->mesh();
|
||||||
return FillAdaptive::build_octree(mesh, line_spacing, printer_volume, model_center);
|
return FillAdaptive::build_octree(mesh, line_spacing, model_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintObject::clear_layers()
|
void PrintObject::clear_layers()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user