ENH: config: add filament_maps in partplate

Change-Id: I1183830788e703f1d33a8a4b620b58b822283dd4
(cherry picked from commit b0e3ab037e3f5af0851539af5ac15b8f96daf548)
This commit is contained in:
lane.wei
2024-06-20 16:10:16 +08:00
committed by Noisyfox
parent fe09c20725
commit 141af16fa2
11 changed files with 490 additions and 105 deletions

View File

@@ -344,6 +344,9 @@ public:
// Set a single vector item from either a scalar option or the first value of a vector option.vector of ConfigOptions.
// This function is useful to split values from multiple extrder / filament settings into separate configurations.
virtual void set_at(const ConfigOption *rhs, size_t i, size_t j) = 0;
//BBS
virtual void append(const ConfigOption *rhs) = 0;
virtual void set(const ConfigOption* rhs, size_t start, size_t len) = 0;
// Resize the vector of values, copy the newly added values from opt_default if provided.
virtual void resize(size_t n, const ConfigOption *opt_default = nullptr) = 0;
// Clear the values vector.
@@ -431,6 +434,41 @@ public:
throw ConfigurationError("ConfigOptionVector::set_at(): Assigning an incompatible type");
}
//BBS
void append(const ConfigOption *rhs) override
{
if (rhs->type() == this->type()) {
// Assign the first value of the rhs vector.
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);
if (other->values.empty())
throw ConfigurationError("ConfigOptionVector::append(): append an empty vector");
this->values.insert(this->values.end(), other->values.begin(), other->values.end());
} else if (rhs->type() == this->scalar_type())
this->values.push_back(static_cast<const ConfigOptionSingle<T>*>(rhs)->value);
else
throw ConfigurationError("ConfigOptionVector::append(): append an incompatible type");
}
// Set a single vector item from a range of another vector option
// This function is useful to split values from multiple extrder / filament settings into separate configurations.
void set(const ConfigOption* rhs, size_t start, size_t len) override
{
// It is expected that the vector value has at least one value, which is the default, if not overwritten.
assert(!this->values.empty());
T v = this->values.front();
this->values.resize(len, v);
if (rhs->type() == this->type()) {
// Assign the first value of the rhs vector.
auto other = static_cast<const ConfigOptionVector<T>*>(rhs);
if (other->values.size() < (start+len))
throw ConfigurationError("ConfigOptionVector::set_with(): Assigning from an vector with invalid size");
for (size_t i = 0; i < len; i++)
this->values[i] = other->get_at(start+i);
}
else
throw ConfigurationError("ConfigOptionVector::set_with(): Assigning an incompatible type");
}
const T& get_at(size_t i) const
{
assert(! this->values.empty());