SLA support points are now saved in AMF

This commit is contained in:
Lukas Matena 2018-10-03 15:13:54 +02:00
parent e89465cc3f
commit 6b007986ee
4 changed files with 36 additions and 4 deletions

View File

@ -578,7 +578,28 @@ void AMFParserContext::endElement(const char * /* name */)
p = end + 1; p = end + 1;
} }
m_object->layer_height_profile_valid = true; m_object->layer_height_profile_valid = true;
} else if (m_path.size() == 5 && m_path[3] == NODE_TYPE_VOLUME && m_volume) { }
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());
char *p = const_cast<char*>(m_value[1].c_str());
for (;;) {
char *end = strchr(p, ';');
if (end != nullptr)
*end = 0;
point(coord_idx) = atof(p);
if (++coord_idx == 3) {
m_object->sla_support_points.push_back(point);
coord_idx = 0;
}
if (end == nullptr)
break;
p = end + 1;
}
}
else if (m_path.size() == 5 && m_path[3] == NODE_TYPE_VOLUME && m_volume) {
if (strcmp(opt_key, "modifier") == 0) { if (strcmp(opt_key, "modifier") == 0) {
// Is this volume a modifier volume? // Is this volume a modifier volume?
// "modifier" flag comes first in the XML file, so it may be later overwritten by the "type" flag. // "modifier" flag comes first in the XML file, so it may be later overwritten by the "type" flag.
@ -609,7 +630,6 @@ void AMFParserContext::endElement(const char * /* name */)
default: default:
break; break;
} }
m_path.pop_back(); m_path.pop_back();
} }
@ -878,6 +898,19 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
stream << "\n </metadata>\n"; stream << "\n </metadata>\n";
} }
//FIXME Store the layer height ranges (ModelObject::layer_height_ranges) //FIXME Store the layer height ranges (ModelObject::layer_height_ranges)
const std::vector<Vec3f>& 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 << "\n </metadata>\n";
}
stream << " <mesh>\n"; stream << " <mesh>\n";
stream << " <vertices>\n"; stream << " <vertices>\n";
std::vector<int> vertices_offsets; std::vector<int> vertices_offsets;

View File

@ -498,6 +498,7 @@ ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volum
instances(), instances(),
volumes(), volumes(),
config(other.config), config(other.config),
sla_support_points(other.sla_support_points),
layer_height_ranges(other.layer_height_ranges), layer_height_ranges(other.layer_height_ranges),
layer_height_profile(other.layer_height_profile), layer_height_profile(other.layer_height_profile),
layer_height_profile_valid(other.layer_height_profile_valid), layer_height_profile_valid(other.layer_height_profile_valid),

View File

@ -724,7 +724,6 @@ private:
void _render_bed(float theta) const; void _render_bed(float theta) const;
void _render_axes(bool depth_test) const; void _render_axes(bool depth_test) const;
void _render_objects() const; void _render_objects() const;
void _render_sla_support_points() const;
void _render_cutting_plane() const; void _render_cutting_plane() const;
void _render_warning_texture() const; void _render_warning_texture() const;
void _render_legend_texture() const; void _render_legend_texture() const;

View File

@ -1734,7 +1734,6 @@ void GLGizmoSlaSupports::update_mesh()
const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex(); const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex();
m_source_data.mesh_first_point = Vec3d((double)first_vertex[0], (double)first_vertex[1], (double)first_vertex[2]); m_source_data.mesh_first_point = Vec3d((double)first_vertex[0], (double)first_vertex[1], (double)first_vertex[2]);
// we'll now reload Grabbers (selection might have changed): // we'll now reload Grabbers (selection might have changed):
m_grabbers.clear(); m_grabbers.clear();
for (const Vec3f& point : m_model_object->sla_support_points) { for (const Vec3f& point : m_model_object->sla_support_points) {