SLA support points improvements

- semi-intelligent algorithm to place support points
- enhanced ImGui dialog with editing/non-editing mode
- support points can have different head diameter (only implemented in GUI so far)
- autogenerated points supporting emerging islands are annotated and the info is kept
This commit is contained in:
Lukas Matena 2019-01-30 08:26:23 +01:00
parent f4243c694f
commit 21026ec9a8
16 changed files with 433 additions and 495 deletions

View file

@ -323,7 +323,7 @@ namespace Slic3r {
typedef std::map<int, ObjectMetadata> IdToMetadataMap;
typedef std::map<int, Geometry> IdToGeometryMap;
typedef std::map<int, std::vector<coordf_t>> IdToLayerHeightsProfileMap;
typedef std::map<int, std::vector<Vec3f>> IdToSlaSupportPointsMap;
typedef std::map<int, std::vector<sla::SupportPoint>> IdToSlaSupportPointsMap;
// Version of the 3mf file
unsigned int m_version;
@ -811,10 +811,14 @@ namespace Slic3r {
std::vector<std::string> object_data_points;
boost::split(object_data_points, object_data[1], boost::is_any_of(" "), boost::token_compress_off);
std::vector<Vec3f> sla_support_points;
std::vector<sla::SupportPoint> sla_support_points;
for (unsigned int i=0; i<object_data_points.size(); i+=3)
sla_support_points.push_back(Vec3d(std::atof(object_data_points[i+0].c_str()), std::atof(object_data_points[i+1].c_str()), std::atof(object_data_points[i+2].c_str())).cast<float>());
for (unsigned int i=0; i<object_data_points.size(); i+=5)
sla_support_points.emplace_back(std::atof(object_data_points[i+0].c_str()),
std::atof(object_data_points[i+1].c_str()),
std::atof(object_data_points[i+2].c_str()),
std::atof(object_data_points[i+3].c_str()),
std::atof(object_data_points[i+4].c_str()));
if (!sla_support_points.empty())
m_sla_support_points.insert(IdToSlaSupportPointsMap::value_type(object_id, sla_support_points));
@ -1961,7 +1965,7 @@ namespace Slic3r {
for (const ModelObject* object : model.objects)
{
++count;
const std::vector<Vec3f>& sla_support_points = object->sla_support_points;
const std::vector<sla::SupportPoint>& sla_support_points = object->sla_support_points;
if (!sla_support_points.empty())
{
sprintf(buffer, "object_id=%d|", count);
@ -1970,7 +1974,7 @@ namespace Slic3r {
// Store the layer height profile as a single space separated list.
for (size_t i = 0; i < sla_support_points.size(); ++i)
{
sprintf(buffer, (i==0 ? "%f %f %f" : " %f %f %f"), sla_support_points[i](0), sla_support_points[i](1), sla_support_points[i](2));
sprintf(buffer, (i==0 ? "%f %f %f %f %f" : " %f %f %f %f %f"), sla_support_points[i].pos(0), sla_support_points[i].pos(1), sla_support_points[i].pos(2), sla_support_points[i].head_front_radius, (float)sla_support_points[i].is_new_island);
out += buffer;
}
out += "\n";

View file

@ -583,7 +583,7 @@ void AMFParserContext::endElement(const char * /* name */)
else if (m_path.size() == 3 && m_path[1] == NODE_TYPE_OBJECT && m_object && strcmp(opt_key, "sla_support_points") == 0) {
// Parse object's layer height profile, a semicolon separated list of floats.
unsigned char coord_idx = 0;
Vec3f point(Vec3f::Zero());
Eigen::Matrix<float, 5, 1, Eigen::DontAlign> point(Eigen::Matrix<float, 5, 1, Eigen::DontAlign>::Zero());
char *p = const_cast<char*>(m_value[1].c_str());
for (;;) {
char *end = strchr(p, ';');
@ -591,8 +591,8 @@ void AMFParserContext::endElement(const char * /* name */)
*end = 0;
point(coord_idx) = atof(p);
if (++coord_idx == 3) {
m_object->sla_support_points.push_back(point);
if (++coord_idx == 5) {
m_object->sla_support_points.push_back(sla::SupportPoint(point));
coord_idx = 0;
}
if (end == nullptr)
@ -900,14 +900,14 @@ bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config)
}
//FIXME Store the layer height ranges (ModelObject::layer_height_ranges)
const std::vector<Vec3f>& sla_support_points = object->sla_support_points;
const std::vector<sla::SupportPoint>& sla_support_points = object->sla_support_points;
if (!sla_support_points.empty()) {
// Store the SLA supports as a single semicolon separated list.
stream << " <metadata type=\"slic3r.sla_support_points\">";
for (size_t i = 0; i < sla_support_points.size(); ++i) {
if (i != 0)
stream << ";";
stream << sla_support_points[i](0) << ";" << sla_support_points[i](1) << ";" << sla_support_points[i](2);
stream << sla_support_points[i].pos(0) << ";" << sla_support_points[i].pos(1) << ";" << sla_support_points[i].pos(2) << ";" << sla_support_points[i].head_front_radius << ";" << sla_support_points[i].is_new_island;
}
stream << "\n </metadata>\n";
}