Skip to content

Commit

Permalink
#524 fix equality over double values
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Oct 4, 2020
1 parent 5479ce4 commit 3745d1a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
22 changes: 11 additions & 11 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,17 +1367,17 @@ std::pair<PrintBase::PrintValidationError, std::string> Print::validate() const
for (size_t i = 1; i < m_objects.size(); ++ i) {
const PrintObject *object = m_objects[i];
const SlicingParameters &slicing_params = object->slicing_parameters();
if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON ||
std::abs(slicing_params.layer_height - slicing_params0.layer_height ) > EPSILON)
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they have equal layer heights") };
if (slicing_params.raft_layers() != slicing_params0.raft_layers())
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers") };
if (object->config().support_material_contact_distance_type != m_objects.front()->config().support_material_contact_distance_type
|| object->config().support_material_contact_distance_top != m_objects.front()->config().support_material_contact_distance_top
|| object->config().support_material_contact_distance_bottom != m_objects.front()->config().support_material_contact_distance_bottom)
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance") };
if (! equal_layering(slicing_params, slicing_params0))
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are sliced equally.") };
if (std::abs(slicing_params.first_print_layer_height - slicing_params0.first_print_layer_height) > EPSILON ||
std::abs(slicing_params.layer_height - slicing_params0.layer_height ) > EPSILON)
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they have equal layer heights") };
if (slicing_params.raft_layers() != slicing_params0.raft_layers())
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed over an equal number of raft layers") };
if (object->config().support_material_contact_distance_type != m_objects.front()->config().support_material_contact_distance_type
|| object->config().support_material_contact_distance_top != m_objects.front()->config().support_material_contact_distance_top
|| object->config().support_material_contact_distance_bottom != m_objects.front()->config().support_material_contact_distance_bottom)
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance") };
if (! equal_layering(slicing_params, slicing_params0))
return { PrintBase::PrintValidationError::pveWrongSettings,L("The Wipe Tower is only supported for multiple objects if they are sliced equally.") };
if (has_custom_layering) {
PrintObject::update_layer_height_profile(*object->model_object(), slicing_params, layer_height_profiles[i]);
if (*(layer_height_profiles[i].end()-2) > *(layer_height_profiles[tallest_object_idx].end()-2))
Expand Down
42 changes: 21 additions & 21 deletions src/libslic3r/Slicing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@ inline bool equal_layering(const SlicingParameters &sp1, const SlicingParameters
{
assert(sp1.valid);
assert(sp2.valid);
return sp1.base_raft_layers == sp2.base_raft_layers &&
sp1.interface_raft_layers == sp2.interface_raft_layers &&
sp1.base_raft_layer_height == sp2.base_raft_layer_height &&
sp1.interface_raft_layer_height == sp2.interface_raft_layer_height &&
sp1.contact_raft_layer_height == sp2.contact_raft_layer_height &&
sp1.contact_raft_layer_height_bridging == sp2.contact_raft_layer_height_bridging &&
sp1.layer_height == sp2.layer_height &&
sp1.min_layer_height == sp2.min_layer_height &&
sp1.max_layer_height == sp2.max_layer_height &&
// sp1.max_suport_layer_height == sp2.max_suport_layer_height &&
sp1.first_print_layer_height == sp2.first_print_layer_height &&
sp1.first_object_layer_height == sp2.first_object_layer_height &&
sp1.first_object_layer_bridging == sp2.first_object_layer_bridging &&
sp1.soluble_interface == sp2.soluble_interface &&
sp1.gap_raft_object == sp2.gap_raft_object &&
sp1.gap_object_support == sp2.gap_object_support &&
sp1.gap_support_object == sp2.gap_support_object &&
sp1.raft_base_top_z == sp2.raft_base_top_z &&
sp1.raft_interface_top_z == sp2.raft_interface_top_z &&
sp1.raft_contact_top_z == sp2.raft_contact_top_z &&
sp1.object_print_z_min == sp2.object_print_z_min;
return sp1.base_raft_layers == sp2.base_raft_layers &&
sp1.interface_raft_layers == sp2.interface_raft_layers &&
std::abs(sp1.base_raft_layer_height - sp2.base_raft_layer_height) < EPSILON &&
std::abs(sp1.interface_raft_layer_height - sp2.interface_raft_layer_height) < EPSILON &&
std::abs(sp1.contact_raft_layer_height - sp2.contact_raft_layer_height) < EPSILON &&
sp1.contact_raft_layer_height_bridging == sp2.contact_raft_layer_height_bridging &&
std::abs(sp1.layer_height - sp2.layer_height) < EPSILON &&
std::abs(sp1.min_layer_height - sp2.min_layer_height) < EPSILON &&
std::abs(sp1.max_layer_height - sp2.max_layer_height) < EPSILON &&
// sp1.max_suport_layer_height == sp2.max_suport_layer_height &&
std::abs(sp1.first_print_layer_height - sp2.first_print_layer_height) < EPSILON &&
std::abs(sp1.first_object_layer_height - sp2.first_object_layer_height) < EPSILON &&
sp1.first_object_layer_bridging == sp2.first_object_layer_bridging &&
sp1.soluble_interface == sp2.soluble_interface &&
std::abs(sp1.gap_raft_object - sp2.gap_raft_object) < EPSILON &&
std::abs(sp1.gap_object_support - sp2.gap_object_support) < EPSILON &&
std::abs(sp1.gap_support_object - sp2.gap_support_object) < EPSILON &&
std::abs(sp1.raft_base_top_z - sp2.raft_base_top_z) < EPSILON &&
std::abs(sp1.raft_interface_top_z - sp2.raft_interface_top_z) < EPSILON &&
std::abs(sp1.raft_contact_top_z - sp2.raft_contact_top_z) < EPSILON &&
std::abs(sp1.object_print_z_min - sp2.object_print_z_min) < EPSILON;
}

typedef std::pair<coordf_t,coordf_t> t_layer_height_range;
Expand Down

0 comments on commit 3745d1a

Please sign in to comment.