Account handle the z levels with and without the pad.

New method in support tree to query the needed elevation for the model and its supports.
This commit is contained in:
tamasmeszaros 2018-11-16 11:34:19 +01:00
parent d45739fa15
commit c5ccfeae3e
4 changed files with 46 additions and 14 deletions

View File

@ -71,12 +71,6 @@ template<class Vec> double distance(const Vec& pp1, const Vec& pp2) {
return distance(p);
}
/// The horizontally projected 2D boundary of the model as individual line
/// segments. This can be used later to create a spatial index of line segments
/// and query for possible pillar positions for non-ground facing support points
std::vector<std::pair<Vec2d, Vec2d>> model_boundary(const EigenMesh3D& emesh,
double offs = 0.01);
Contour3D sphere(double rho, Portion portion = make_portion(0.0, 2.0*PI),
double fa=(2*PI/360)) {
@ -513,7 +507,7 @@ struct Pad {
Pad(const TriangleMesh& object_support_mesh,
const ExPolygons& baseplate,
double ground_level,
const PoolConfig& cfg) : zlevel(ground_level)
const PoolConfig& cfg) : zlevel(ground_level + cfg.min_wall_height_mm/2)
{
ExPolygons basep;
base_plate(object_support_mesh, basep);
@ -522,6 +516,8 @@ struct Pad {
create_base_pool(basep, tmesh, cfg);
tmesh.translate(0, 0, float(zlevel));
}
bool empty() const { return tmesh.facets_count() == 0; }
};
EigenMesh3D to_eigenmesh(const Contour3D& cntr) {
@ -611,7 +607,12 @@ EigenMesh3D to_eigenmesh(const Model& model) {
return to_eigenmesh(combined_mesh);
}
PointSet to_point_set(const std::vector<Vec3d> &v)
{
PointSet ret(v.size(), 3);
{ long i = 0; for(const Vec3d& p : v) ret.row(i++) = p; }
return ret;
}
Vec3d model_coord(const ModelInstance& object, const Vec3f& mesh_coord) {
return object.transform_vector(mesh_coord.cast<double>());
@ -1269,7 +1270,7 @@ bool SLASupportTree::generate(const PointSet &points,
const double hbr = cfg.head_back_radius_mm;
const double pradius = cfg.pillar_radius_mm;
const double maxbridgelen = cfg.max_bridge_length_mm;
const double gndlvl = emesh.ground_level;
const double gndlvl = result.ground_level;
ClusterEl cl_centroids;
cl_centroids.reserve(gnd_clusters.size());
@ -1766,6 +1767,13 @@ const TriangleMesh &SLASupportTree::get_pad() const
return m_impl->pad().tmesh;
}
double SLASupportTree::get_elevation() const
{
double ph = m_impl->pad().empty()? 0 :
m_impl->pad().cfg.min_wall_height_mm/2.0;
return -m_impl->ground_level + ph;
}
SLASupportTree::SLASupportTree(const Model& model,
const SupportConfig& cfg,
const Controller& ctl): m_impl(new Impl())

View File

@ -63,7 +63,7 @@ struct SupportConfig {
// The elevation in Z direction upwards. This is the space between the pad
// and the model object's bounding box bottom.
double object_elevation_mm = 0;
double object_elevation_mm = 10;
};
/// A Control structure for the support calculation. Consists of the status
@ -101,11 +101,15 @@ void add_sla_supports(Model& model, const SupportConfig& cfg = {},
const Controller& ctl = {});
EigenMesh3D to_eigenmesh(const TriangleMesh& m);
PointSet to_point_set(const std::vector<Vec3d>&);
// obsolete, not used anymore
EigenMesh3D to_eigenmesh(const Model& model);
EigenMesh3D to_eigenmesh(const ModelObject& model);
PointSet support_points(const Model& model);
PointSet support_points(const ModelObject& modelobject);
PointSet support_points(const Model& model);
/* ************************************************************************** */
@ -169,6 +173,11 @@ public:
/// Get the pad geometry
const TriangleMesh& get_pad() const;
/// The Z offset to raise the model and the supports to the ground level.
/// This is the elevation given in the support config and the height of the
/// pad (if requested).
double get_elevation() const;
};
}

View File

@ -150,8 +150,8 @@ void SLAPrint::process()
po.m_supportdata.reset(new SLAPrintObject::SupportData());
po.m_supportdata->emesh = sla::to_eigenmesh(po.transformed_mesh());
// TODO: transform support points appropriately
po.m_supportdata->support_points = sla::support_points(mo);
po.m_supportdata->support_points =
sla::to_point_set(po.transformed_support_points());
}
// for(SLAPrintObject *po : pobjects) {
@ -454,4 +454,17 @@ const TriangleMesh &SLAPrintObject::transformed_mesh() const {
return m_transformed_rmesh;
}
std::vector<Vec3d> SLAPrintObject::transformed_support_points() const
{
assert(m_model_object != nullptr);
auto& spts = m_model_object->sla_support_points;
// this could be cached as well
std::vector<Vec3d> ret; ret.reserve(spts.size());
for(auto& sp : spts) ret.emplace_back( trafo() * Vec3d(sp.cast<double>()));
return ret;
}
} // namespace Slic3r

View File

@ -60,6 +60,8 @@ public:
// This will return the transformed mesh which is cached
const TriangleMesh& transformed_mesh() const;
std::vector<Vec3d> transformed_support_points() const;
// I refuse to grantee copying (Tamas)
SLAPrintObject(const SLAPrintObject&) = delete;
SLAPrintObject& operator=(const SLAPrintObject&) = delete;