Modal estimated printing time dialog

Fixed conflicts after merge with master
This commit is contained in:
enricoturri1966 2020-07-27 14:53:17 +02:00
commit 48ae8dc9a2
22 changed files with 1301 additions and 264 deletions

View file

@ -2,6 +2,7 @@
#include "ModelArrange.hpp"
#include "Geometry.hpp"
#include "MTUtils.hpp"
#include "TriangleSelector.hpp"
#include "Format/AMF.hpp"
#include "Format/OBJ.hpp"
@ -1832,28 +1833,25 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const
}
std::vector<int> FacetsAnnotation::get_facets(FacetSupportType type) const
indexed_triangle_set FacetsAnnotation::get_facets(const ModelVolume& mv, FacetSupportType type) const
{
std::vector<int> out;
for (auto& [facet_idx, this_type] : m_data)
if (this_type == type)
out.push_back(facet_idx);
TriangleSelector selector(mv.mesh());
selector.deserialize(m_data);
indexed_triangle_set out = selector.get_facets(type);
return out;
}
void FacetsAnnotation::set_facet(int idx, FacetSupportType type)
bool FacetsAnnotation::set(const TriangleSelector& selector)
{
bool changed = true;
if (type == FacetSupportType::NONE)
changed = m_data.erase(idx) != 0;
else
m_data[idx] = type;
if (changed)
std::map<int, std::vector<bool>> sel_map = selector.serialize();
if (sel_map != m_data) {
m_data = sel_map;
update_timestamp();
return true;
}
return false;
}
@ -1866,6 +1864,64 @@ void FacetsAnnotation::clear()
// Following function takes data from a triangle and encodes it as string
// of hexadecimal numbers (one digit per triangle). Used for 3MF export,
// changing it may break backwards compatibility !!!!!
std::string FacetsAnnotation::get_triangle_as_string(int triangle_idx) const
{
std::string out;
auto triangle_it = m_data.find(triangle_idx);
if (triangle_it != m_data.end()) {
const std::vector<bool>& code = triangle_it->second;
int offset = 0;
while (offset < int(code.size())) {
int next_code = 0;
for (int i=3; i>=0; --i) {
next_code = next_code << 1;
next_code |= int(code[offset + i]);
}
offset += 4;
assert(next_code >=0 && next_code <= 15);
char digit = next_code < 10 ? next_code + '0' : (next_code-10)+'A';
out.insert(out.begin(), digit);
}
}
return out;
}
// Recover triangle splitting & state from string of hexadecimal values previously
// generated by get_triangle_as_string. Used to load from 3MF.
void FacetsAnnotation::set_triangle_from_string(int triangle_id, const std::string& str)
{
assert(! str.empty());
m_data[triangle_id] = std::vector<bool>(); // zero current state or create new
std::vector<bool>& code = m_data[triangle_id];
for (auto it = str.crbegin(); it != str.crend(); ++it) {
const char ch = *it;
int dec = 0;
if (ch >= '0' && ch<='9')
dec = int(ch - '0');
else if (ch >='A' && ch <= 'F')
dec = 10 + int(ch - 'A');
else
assert(false);
// Convert to binary and append into code.
for (int i=0; i<4; ++i) {
code.insert(code.end(), bool(dec & (1 << i)));
}
}
}
// Test whether the two models contain the same number of ModelObjects with the same set of IDs
// ordered in the same order. In that case it is not necessary to kill the background processing.
bool model_object_list_equal(const Model &model_old, const Model &model_new)
@ -1937,7 +1993,7 @@ bool model_custom_supports_data_changed(const ModelObject& mo, const ModelObject
return true;
}
return false;
};
}
extern bool model_has_multi_part_objects(const Model &model)
{