mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 16:51:21 -06:00
SLAPrint concept under its way.
This commit is contained in:
parent
22c9c5ae95
commit
19b1aa081d
11 changed files with 225 additions and 618 deletions
|
|
@ -10,37 +10,6 @@
|
|||
namespace Slic3r {
|
||||
namespace sla {
|
||||
|
||||
EigenMesh3D to_eigenmesh(const TriangleMesh& tmesh) {
|
||||
|
||||
const stl_file& stl = tmesh.stl;
|
||||
|
||||
EigenMesh3D outmesh;
|
||||
auto& V = outmesh.V;
|
||||
auto& F = outmesh.F;
|
||||
|
||||
V.resize(3*stl.stats.number_of_facets, 3);
|
||||
F.resize(stl.stats.number_of_facets, 3);
|
||||
for (unsigned int i=0; i<stl.stats.number_of_facets; ++i) {
|
||||
const stl_facet* facet = stl.facet_start+i;
|
||||
V(3*i+0, 0) = facet->vertex[0](0); V(3*i+0, 1) =
|
||||
facet->vertex[0](1); V(3*i+0, 2) = facet->vertex[0](2);
|
||||
V(3*i+1, 0) = facet->vertex[1](0); V(3*i+1, 1) =
|
||||
facet->vertex[1](1); V(3*i+1, 2) = facet->vertex[1](2);
|
||||
V(3*i+2, 0) = facet->vertex[2](0); V(3*i+2, 1) =
|
||||
facet->vertex[2](1); V(3*i+2, 2) = facet->vertex[2](2);
|
||||
|
||||
F(i, 0) = 3*i+0;
|
||||
F(i, 1) = 3*i+1;
|
||||
F(i, 2) = 3*i+2;
|
||||
}
|
||||
|
||||
return outmesh;
|
||||
}
|
||||
|
||||
inline EigenMesh3D to_eigenmesh(const ModelObject& modelobj) {
|
||||
return to_eigenmesh(modelobj.raw_mesh());
|
||||
}
|
||||
|
||||
std::array<double, 3> find_best_rotation(const ModelObject& modelobj,
|
||||
float accuracy,
|
||||
std::function<void(unsigned)> statuscb,
|
||||
|
|
|
|||
|
|
@ -536,19 +536,9 @@ enum { // For indexing Eigen vectors as v(X), v(Y), v(Z) instead of numbers
|
|||
X, Y, Z
|
||||
};
|
||||
|
||||
EigenMesh3D to_eigenmesh(const Model& model) {
|
||||
TriangleMesh combined_mesh;
|
||||
EigenMesh3D to_eigenmesh(const TriangleMesh& tmesh) {
|
||||
|
||||
for(ModelObject *o : model.objects) {
|
||||
TriangleMesh tmp = o->raw_mesh();
|
||||
for(ModelInstance * inst: o->instances) {
|
||||
TriangleMesh ttmp(tmp);
|
||||
inst->transform_mesh(&ttmp);
|
||||
combined_mesh.merge(ttmp);
|
||||
}
|
||||
}
|
||||
|
||||
const stl_file& stl = combined_mesh.stl;
|
||||
const stl_file& stl = tmesh.stl;
|
||||
|
||||
EigenMesh3D outmesh;
|
||||
auto& V = outmesh.V;
|
||||
|
|
@ -573,6 +563,27 @@ EigenMesh3D to_eigenmesh(const Model& model) {
|
|||
return outmesh;
|
||||
}
|
||||
|
||||
EigenMesh3D to_eigenmesh(const ModelObject& modelobj) {
|
||||
return to_eigenmesh(modelobj.raw_mesh());
|
||||
}
|
||||
|
||||
EigenMesh3D to_eigenmesh(const Model& model) {
|
||||
TriangleMesh combined_mesh;
|
||||
|
||||
for(ModelObject *o : model.objects) {
|
||||
TriangleMesh tmp = o->raw_mesh();
|
||||
for(ModelInstance * inst: o->instances) {
|
||||
TriangleMesh ttmp(tmp);
|
||||
inst->transform_mesh(&ttmp);
|
||||
combined_mesh.merge(ttmp);
|
||||
}
|
||||
}
|
||||
|
||||
return to_eigenmesh(combined_mesh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vec3d model_coord(const ModelInstance& object, const Vec3f& mesh_coord) {
|
||||
return object.transform_vector(mesh_coord.cast<double>());
|
||||
}
|
||||
|
|
@ -595,13 +606,24 @@ PointSet support_points(const Model& model) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
PointSet support_points(const ModelObject& modelobject, std::size_t instance_id)
|
||||
{
|
||||
PointSet ret(modelobject.sla_support_points.size(), 3);
|
||||
long i = 0;
|
||||
ModelInstance *inst = modelobject.instances[instance_id];
|
||||
for(const Vec3f& msource : modelobject.sla_support_points) {
|
||||
ret.row(i++) = model_coord(*inst, msource);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double ray_mesh_intersect(const Vec3d& s,
|
||||
const Vec3d& dir,
|
||||
const EigenMesh3D& m);
|
||||
|
||||
PointSet normals(const PointSet& points, const EigenMesh3D& mesh);
|
||||
|
||||
Vec2d to_vec2(const Vec3d& v3) {
|
||||
inline Vec2d to_vec2(const Vec3d& v3) {
|
||||
return {v3(X), v3(Y)};
|
||||
}
|
||||
|
||||
|
|
@ -1612,7 +1634,6 @@ void add_sla_supports(Model &model,
|
|||
<< " seconds" << std::endl;
|
||||
|
||||
bench.start();
|
||||
SLASupportTree::Impl& stree = _stree.get();
|
||||
ModelObject* o = model.add_object();
|
||||
o->add_instance();
|
||||
|
||||
|
|
@ -1648,7 +1669,7 @@ void add_sla_supports(Model &model,
|
|||
<< " second." << std::endl;
|
||||
|
||||
bench.start();
|
||||
poolmesh.translate(0, 0, poolcfg.min_wall_height_mm / 2);
|
||||
poolmesh.translate(.0f, .0f, float(poolcfg.min_wall_height_mm / 2));
|
||||
o->add_volume(poolmesh);
|
||||
bench.stop();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ typedef std::vector<Vec3crd> Points3;
|
|||
class TriangleMesh;
|
||||
class Model;
|
||||
class ModelInstance;
|
||||
class ModelObject;
|
||||
class ExPolygon;
|
||||
|
||||
using SliceLayer = std::vector<ExPolygon>;
|
||||
|
|
@ -31,6 +32,9 @@ struct SupportConfig {
|
|||
// Radius in mm of the pointing side of the head.
|
||||
double head_front_radius_mm = 0.2;
|
||||
|
||||
// How much the pinhead has to penetrate the model surface
|
||||
double head_penetraiton = 0.2;
|
||||
|
||||
// Radius of the back side of the 3d arrow.
|
||||
double head_back_radius_mm = 0.5;
|
||||
|
||||
|
|
@ -39,6 +43,10 @@ struct SupportConfig {
|
|||
|
||||
// Radius in mm of the support pillars.
|
||||
// Warning: this value will be at most 65% of head_back_radius_mm
|
||||
// TODO: This parameter is invalid. The pillar radius will be dynamic in
|
||||
// nature. Merged pillars will have an increased thickness. This parameter
|
||||
// may serve as the maximum radius, or maybe an increase when two are merged
|
||||
// The default radius will be derived from head_back_radius_mm
|
||||
double pillar_radius_mm = 0.8;
|
||||
|
||||
// Radius in mm of the pillar base.
|
||||
|
|
@ -63,6 +71,8 @@ struct Controller {
|
|||
std::function<bool(void)> stopcondition = [](){ return false; };
|
||||
};
|
||||
|
||||
/// An index-triangle structure for libIGL functions. Also serves as an
|
||||
/// alternative (raw) input format for the SLASupportTree
|
||||
struct EigenMesh3D {
|
||||
Eigen::MatrixXd V;
|
||||
Eigen::MatrixXi F;
|
||||
|
|
@ -80,8 +90,12 @@ void create_head(TriangleMesh&, double r1_mm, double r2_mm, double width_mm);
|
|||
void add_sla_supports(Model& model, const SupportConfig& cfg = {},
|
||||
const Controller& ctl = {});
|
||||
|
||||
EigenMesh3D to_eigenmesh(const TriangleMesh& m);
|
||||
EigenMesh3D to_eigenmesh(const Model& model);
|
||||
EigenMesh3D to_eigenmesh(const ModelObject& model);
|
||||
|
||||
PointSet support_points(const Model& model);
|
||||
PointSet support_points(const ModelObject& modelobject, size_t instance_id = 0);
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue