ENH: CLI: add layer range support for assembled object

JIRA: no jira
Change-Id: I03456997a1a7c38a73ebbcacfa3edff04b50fcb9
This commit is contained in:
lane.wei 2024-05-17 15:36:04 +08:00 committed by Lane.Wei
parent dd9af771c2
commit d5a59a5fde
2 changed files with 44 additions and 0 deletions

View File

@ -679,6 +679,23 @@ static int load_assemble_plate_list(std::string config_file, std::vector<assembl
assemble_object.print_params = object_json[JSON_ASSEMPLE_OBJECT_PRINT_PARAMS].get<std::map<std::string, std::string>>();
BOOST_LOG_TRIVIAL(debug) << boost::format("Plate %1%, object %2% has %3% print params") % (plate_index + 1) %assemble_object.path % assemble_object.print_params.size();
}
if (object_json.contains(JSON_ASSEMPLE_OBJECT_HEIGHT_RANGES)) {
json height_range_json = object_json[JSON_ASSEMPLE_OBJECT_HEIGHT_RANGES];
int range_count = height_range_json.size();
BOOST_LOG_TRIVIAL(debug) << boost::format("Plate %1%, object %2% has %3% height ranges") % (plate_index + 1) %assemble_object.path % range_count;
assemble_object.height_ranges.resize(range_count);
for (int range_index = 0; range_index < range_count; range_index++)
{
height_range_info_t height_range;
height_range.min_z = height_range_json[range_index][JSON_ASSEMPLE_OBJECT_MIN_Z];
height_range.max_z = height_range_json[range_index][JSON_ASSEMPLE_OBJECT_MAX_Z];
height_range.range_params = height_range_json[range_index][JSON_ASSEMPLE_OBJECT_RANGE_PARAMS].get<std::map<std::string, std::string>>();
assemble_object.height_ranges.push_back(std::move(height_range));
}
BOOST_LOG_TRIVIAL(debug) << boost::format("Plate %1%, object %2% has %3% print params") % (plate_index + 1) %assemble_object.path % assemble_object.print_params.size();
}
}
}
}
@ -820,6 +837,21 @@ static int construct_assemble_list(std::vector<assemble_plate_info_t> &assemble_
}
}
if (!assemble_object.height_ranges.empty())
{
for (int range_index = 0; range_index < assemble_object.height_ranges.size(); range_index++)
{
height_range_info_t& range = assemble_object.height_ranges[range_index];
DynamicPrintConfig range_config;
for (auto range_config_iter = range.range_params.begin(); range_config_iter != range.range_params.end(); range_config_iter++)
{
range_config.set_deserialize(range_config_iter->first, range_config_iter->second, config_substitutions);
BOOST_LOG_TRIVIAL(debug) << boost::format("object %1%, height range %2% key %3%, value %4%") % object_1_name % range_index % range_config_iter->first % range_config_iter->second;
}
object->layer_config_ranges[{ range.min_z, range.max_z }].assign_config(std::move(range_config));
}
}
if (assemble_object.pos_x.empty())
assemble_object.pos_x.resize(1, 0.f);
if (assemble_object.pos_y.empty())

View File

@ -31,6 +31,17 @@ namespace IO {
#define JSON_ASSEMPLE_OBJECT_ASSEMBLE_INDEX "assemble_index"
#define JSON_ASSEMPLE_OBJECT_PRINT_PARAMS "print_params"
#define JSON_ASSEMPLE_OBJECT_MIN_Z "min_z"
#define JSON_ASSEMPLE_OBJECT_MAX_Z "max_z"
#define JSON_ASSEMPLE_OBJECT_HEIGHT_RANGES "height_ranges"
#define JSON_ASSEMPLE_OBJECT_RANGE_PARAMS "range_params"
typedef struct _height_range_info {
float min_z;
float max_z;
std::map<std::string, std::string> range_params;
}height_range_info_t;
typedef struct _assemble_object_info {
std::string path;
@ -42,6 +53,7 @@ typedef struct _assemble_object_info {
std::vector<float> pos_y;
std::vector<float> pos_z;
std::map<std::string, std::string> print_params;
std::vector<height_range_info_t> height_ranges;
}assemble_object_info_t;
typedef struct _assemble_plate_info {