Optimization of the tool path preview generation algorithm:

1) Replaced linear search with logarithmic search.
2) Templated the travel path generation, replaced 3 functions with one.
This commit is contained in:
bubnikv 2019-08-26 15:52:56 +02:00
parent 66535b41d5
commit 80490550b5
4 changed files with 161 additions and 309 deletions

View file

@ -13,22 +13,6 @@ namespace Slic3r {
const GCodePreviewData::Color GCodePreviewData::Color::Dummy(0.0f, 0.0f, 0.0f, 0.0f);
GCodePreviewData::Color::Color()
{
rgba[0] = 1.0f;
rgba[1] = 1.0f;
rgba[2] = 1.0f;
rgba[3] = 1.0f;
}
GCodePreviewData::Color::Color(float r, float g, float b, float a)
{
rgba[0] = r;
rgba[1] = g;
rgba[2] = b;
rgba[3] = a;
}
std::vector<unsigned char> GCodePreviewData::Color::as_bytes() const
{
std::vector<unsigned char> ret;

View file

@ -14,14 +14,14 @@ public:
{
float rgba[4];
Color();
Color(float r, float g, float b, float a);
Color(const float *argba) { memcpy(this->rgba, argba, sizeof(float) * 4); }
Color(float r = 1.f, float g = 1.f, float b = 1.f, float a = 1.f) { rgba[0] = r; rgba[1] = g; rgba[2] = b; rgba[3] = a; }
std::vector<unsigned char> as_bytes() const;
static const Color Dummy;
};
// Color mapping from a <min, max> range into a smooth rainbow of 10 colors.
struct Range
{