Fix asserts which would not compile. (#3741)

This commit is contained in:
Seth LaForge 2024-01-26 18:30:29 -08:00 committed by GitHub
parent 3cb573dcb9
commit e5bdc7d5bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 26 deletions

View file

@ -105,7 +105,6 @@ struct EmbossShape
// Note: image is only cache it is not neccessary to store
// Store file data as plain string
assert(file_data != nullptr);
ar(path, path_in_3mf, (file_data != nullptr) ? *file_data : std::string(""));
}
template<class Archive> void load(Archive &ar) {

View file

@ -475,7 +475,7 @@ static ClipperLib_Z::Paths clip_extrusion(const ClipperLib_Z::Path& subject, con
end = e2top;
}
assert(start.z() > 0 && end.z() > 0);
assert(start.z() >= 0 && end.z() >= 0);
// Interpolate extrusion line width.
double length_sqr = (end - start).cast<double>().squaredNorm();
@ -832,6 +832,8 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
if (extrusion->is_closed) {
ExtrusionLoop extrusion_loop(std::move(paths), pg_extrusion.is_contour ? elrDefault : elrHole);
extrusion_loop.make_counter_clockwise();
// TODO: it seems in practice that ExtrusionLoops occasionally have significantly disconnected paths,
// triggering the asserts below. Is this a problem?
for (auto it = std::next(extrusion_loop.paths.begin()); it != extrusion_loop.paths.end(); ++it) {
assert(it->polyline.points.size() >= 2);
assert(std::prev(it)->polyline.last_point() == it->polyline.first_point());
@ -843,12 +845,11 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
else {
// Because we are processing one ExtrusionLine all ExtrusionPaths should form one connected path.
// But there is possibility that due to numerical issue there is poss
assert([&paths = std::as_const(paths)]() -> bool {
for (auto it = std::next(paths.begin()); it != paths.end(); ++it)
if (std::prev(it)->polyline.last_point() != it->polyline.first_point())
return false;
return true;
}());
// TODO: do we need some tolerance for disconnected paths below?
for (auto it = std::next(paths.begin()); it != paths.end(); ++it) {
assert(it->polyline.points.size() >= 2);
assert(std::prev(it)->polyline.last_point() == it->polyline.first_point());
}
ExtrusionMultiPath multi_path;
multi_path.paths.emplace_back(std::move(paths.front()));

View file

@ -138,12 +138,6 @@ static std::vector<std::pair<TreeSupportSettings, std::vector<size_t>>> group_me
// as different settings in the same group may only occur in the tip, which uses the original settings objects from the meshes.
for (size_t object_id : print_object_ids) {
const PrintObject &print_object = *print.get_object(object_id);
#ifndef NDEBUG
const PrintObjectConfig &object_config = print_object.config();
#endif // NDEBUG
// Support must be enabled and set to Tree style.
assert(object_config.enable_support || object_config.enforce_support_layers > 0);
assert(object_config.support_type == stTree || object_config.support_style == smsOrganic);
bool found_existing_group = false;
TreeSupportSettings next_settings{ TreeSupportMeshGroupSettings{ print_object }, print_object.slicing_parameters() };
@ -3537,11 +3531,10 @@ static void generate_support_areas(Print &print, const BuildVolume &build_volume
if (print_object.config().support_style.value != smsOrganic &&
// Orca: use organic as default
print_object.config().support_style.value != smsDefault)
print_object.config().support_style.value != smsDefault) {
draw_areas(*print.get_object(processing.second.front()), volumes, config, overhangs, move_bounds,
bottom_contacts, top_contacts, intermediate_layers, layer_storage, throw_on_cancel);
else {
assert(print_object.config().support_style == smsOrganic);
} else {
organic_draw_branches(
*print.get_object(processing.second.front()), volumes, config, move_bounds,
bottom_contacts, top_contacts, interface_placer, intermediate_layers, layer_storage,

View file

@ -23,7 +23,7 @@ TreeSupportMeshGroupSettings::TreeSupportMeshGroupSettings(const PrintObject &pr
// Support must be enabled and set to Tree style.
assert(config.enable_support || config.enforce_support_layers > 0);
assert(config.support_type == stTree || config.support_style == smsOrganic);
assert(is_tree(config.support_type));
// Calculate maximum external perimeter width over all printing regions, taking into account the default layer height.
coordf_t external_perimeter_width = 0.;

View file

@ -396,7 +396,7 @@ IconManager::VIcons init_icons(IconManager &mng, const GuiCfg &cfg)
"reflection_y.svg", // reflection_y
};
assert(init_types.size() == static_cast<size_t>(IconType::_count));
assert(filenames.size() == static_cast<size_t>(IconType::_count));
std::string path = resources_dir() + "/images/";
for (std::string &filename : filenames) filename = path + filename;

View file

@ -2791,9 +2791,9 @@ static bool is_left_handed(const Transform3d& m)
}
#ifndef NDEBUG
static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)
static bool is_rotation_xy_synchronized(const Transform3d &rot_xyz_from, const Transform3d &rot_xyz_to)
{
const Eigen::AngleAxisd angle_axis(Geometry::rotation_xyz_diff(rot_xyz_from, rot_xyz_to));
const Eigen::AngleAxisd angle_axis((rot_xyz_from * rot_xyz_to.inverse()).rotation());
const Vec3d axis = angle_axis.axis();
const double angle = angle_axis.angle();
if (std::abs(angle) < 1e-8)
@ -2817,10 +2817,10 @@ static void verify_instances_rotation_synchronized(const Model &model, const GLV
//assert(idx_volume_first != -1); // object without instances?
if (idx_volume_first == -1)
continue;
const Vec3d &rotation0 = volumes[idx_volume_first]->get_instance_rotation();
const Transform3d &rotation0 = volumes[idx_volume_first]->get_instance_transformation().get_matrix();
for (int i = idx_volume_first + 1; i < (int)volumes.size(); ++i)
if (volumes[i]->object_idx() == idx_object) {
const Vec3d &rotation = volumes[i]->get_instance_rotation();
const Transform3d &rotation = volumes[i]->get_instance_transformation().get_matrix();
assert(is_rotation_xy_synchronized(rotation, rotation0));
}
}