From 716946a9f58c6b4ff999b41054a3ac536cc225e5 Mon Sep 17 00:00:00 2001 From: Samir55 Date: Tue, 10 Jul 2018 17:22:56 +0200 Subject: [PATCH] some porting. --- xs/src/libslic3r/Print.hpp | 23 ++++- xs/src/libslic3r/SupportMaterial.hpp | 124 +++++++++++++++++---------- 2 files changed, 102 insertions(+), 45 deletions(-) diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 7f83c684f..dd5bec251 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -228,7 +228,28 @@ class Print void auto_assign_extruders(ModelObject* model_object) const; std::string output_filename(); std::string output_filepath(const std::string &path); - + +// Flow support_material_flow (FlowRole role){ +// +// int extruder = (role == FlowRole::frSupportMaterial) +// ? default_object_config.support_material_extruder +// : default_object_config.support_material_interface_extruder; +// +// ConfigOptionFloatOrPercent width = default_object_config.support_material_extrusion_width || config.extrusion_width; +// +// if (role == FlowRole::frSupportMaterialInterface) { +// width = default_object_config.support_material_interface_extrusion_width || width; +// } +// +// // We use a bogus layer_height because we use the same flow for all +// // support material layers. +// return Flow::new_from_config_width( +// role, +// width, +// config.nozzle_diameter.get_at(extruder-1), +// default_object_config.layer_height, +// 0); +// } private: void clear_regions(); void delete_region(size_t idx); diff --git a/xs/src/libslic3r/SupportMaterial.hpp b/xs/src/libslic3r/SupportMaterial.hpp index 488580792..f3db6fe73 100644 --- a/xs/src/libslic3r/SupportMaterial.hpp +++ b/xs/src/libslic3r/SupportMaterial.hpp @@ -14,6 +14,9 @@ #include "SupportMaterial.hpp" #include "ExPolygon.hpp" +// Supports Material tests. + + using namespace std; namespace Slic3r @@ -177,6 +180,50 @@ public: } + void generate_interface_layers() + {} + + void generate_bottom_interface_layers() + {} + + void generate_base_layers() + {} + + void clip_with_object() + {} + + void generate_toolpaths() + {} + + void generate_pillars_shape() + {} + + void clip_with_shape() + { + //TODO + } + + /// This method returns the indices of the layers overlapping with the given one. + vector overlapping_layers(int layer_idx, vector support_z) + { + vector ret; + + float z_max = support_z[layer_idx]; + float z_min = layer_idx == 0 ? 0 : support_z[layer_idx - 1]; + + for (int i = 0; i < support_z.size(); i++) { + if (i == layer_idx) continue; + + float z_max2 = support_z[i]; + float z_min2 = i == 0 ? 0 : support_z[i - 1]; + + if (z_max > z_min2 && z_min < z_max2) + ret.push_back(i); + } + + return ret; + } + vector support_layers_z(vector contact_z, vector top_z, coordf_t max_object_layer_height) { // Quick table to check whether a given Z is a top surface. @@ -249,50 +296,6 @@ public: return z; } - void generate_interface_layers() - {} - - void generate_bottom_interface_layers() - {} - - void generate_base_layers() - {} - - void clip_with_object() - {} - - void generate_toolpaths() - {} - - void generate_pillars_shape() - {} - - void clip_with_shape() - { - //TODO - } - - /// This method returns the indices of the layers overlapping with the given one. - vector overlapping_layers(int layer_idx, vector support_z) - { - vector ret; - - float z_max = support_z[layer_idx]; - float z_min = layer_idx == 0 ? 0 : support_z[layer_idx - 1]; - - for (int i = 0; i < support_z.size(); i++) { - if (i == layer_idx) continue; - - float z_max2 = support_z[i]; - float z_min2 = i == 0 ? 0 : support_z[i - 1]; - - if (z_max > z_min2 && z_min < z_max2) - ret.push_back(i); - } - - return ret; - } - coordf_t contact_distance(coordf_t layer_height, coordf_t nozzle_diameter) { coordf_t extra = static_cast(object_config->support_material_contact_distance.value); @@ -306,6 +309,39 @@ public: }; +class SupportMaterialTests +{ +public: + bool test_1() + { + // Create a mesh & modelObject. + TriangleMesh mesh = TriangleMesh::make_cube(20, 20, 20); + + // Create modelObject. + Model model = Model(); + ModelObject *object = model.add_object(); + object->add_volume(mesh); + model.add_default_instances(); + + // Align to origin. + model.align_instances_to_origin(); + + // Create Print. + Print print = Print(); + + // Configure the printObjectConfig. + print.default_object_config.set_deserialize("support_material", "1"); + + // Add the modelObject. + print.add_model_object(model.objects[0]); + + // Create new supports. + SupportMaterial support = SupportMaterial(&print, &print.objects.front()->config, + print.objects.front().suppo) + + } + +}; } #endif