Merge branch 'et_gcode_viewer' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
enricoturri1966 2020-05-27 16:31:26 +02:00
commit 0e018e6690
110 changed files with 852 additions and 1379 deletions

View file

@ -53,6 +53,8 @@
#include "slic3r/GUI/3DScene.hpp"
#include "slic3r/GUI/InstanceCheck.hpp"
#include "slic3r/GUI/AppConfig.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/GUI/Plater.hpp"
#endif /* SLIC3R_GUI */
using namespace Slic3r;

View file

@ -1,7 +1,8 @@
#include "Arrange.hpp"
//#include "Geometry.hpp"
#include "SVG.hpp"
#include "BoundingBox.hpp"
#include <libnest2d/backends/clipper/geometries.hpp>
#include <libnest2d/optimizers/nlopt/subplex.hpp>
#include <libnest2d/placers/nfpplacer.hpp>

View file

@ -2,9 +2,12 @@
#define ARRANGE_HPP
#include "ExPolygon.hpp"
#include "BoundingBox.hpp"
namespace Slic3r { namespace arrangement {
namespace Slic3r {
class BoundingBox;
namespace arrangement {
/// A geometry abstraction for a circular print bed. Similarly to BoundingBox.
class CircleBed {

View file

@ -6,7 +6,6 @@
#include <stdint.h>
#include "../libslic3r.h"
#include "../BoundingBox.hpp"
#include "../PrintConfig.hpp"
#include "FillBase.hpp"

View file

@ -11,13 +11,13 @@
#include "../libslic3r.h"
#include "../BoundingBox.hpp"
#include "../PrintConfig.hpp"
#include "../Utils.hpp"
namespace Slic3r {
class ExPolygon;
class Surface;
enum InfillPattern : int;
class InfillFailedException : public std::runtime_error {
public:

View file

@ -901,7 +901,7 @@ static void connect_segment_intersections_by_contours(
const SegmentedIntersectionLine *il_prev = i_vline > 0 ? &segs[i_vline - 1] : nullptr;
const SegmentedIntersectionLine *il_next = i_vline + 1 < segs.size() ? &segs[i_vline + 1] : nullptr;
for (int i_intersection = 0; i_intersection < il.intersections.size(); ++ i_intersection) {
for (int i_intersection = 0; i_intersection < int(il.intersections.size()); ++ i_intersection) {
SegmentIntersection &itsct = il.intersections[i_intersection];
const Polygon &poly = poly_with_offset.contour(itsct.iContour);
const bool forward = itsct.is_low(); // == poly_with_offset.is_contour_ccw(intrsctn->iContour);
@ -914,7 +914,7 @@ static void connect_segment_intersections_by_contours(
int iprev = -1;
int d_prev = std::numeric_limits<int>::max();
if (il_prev) {
for (int i = 0; i < il_prev->intersections.size(); ++ i) {
for (int i = 0; i < int(il_prev->intersections.size()); ++ i) {
const SegmentIntersection &itsct2 = il_prev->intersections[i];
if (itsct.iContour == itsct2.iContour && itsct.type == itsct2.type) {
// The intersection points lie on the same contour and have the same orientation.
@ -932,7 +932,7 @@ static void connect_segment_intersections_by_contours(
int inext = -1;
int d_next = std::numeric_limits<int>::max();
if (il_next) {
for (int i = 0; i < il_next->intersections.size(); ++ i) {
for (int i = 0; i < int(il_next->intersections.size()); ++ i) {
const SegmentIntersection &itsct2 = il_next->intersections[i];
if (itsct.iContour == itsct2.iContour && itsct.type == itsct2.type) {
// The intersection points lie on the same contour and have the same orientation.
@ -950,7 +950,7 @@ static void connect_segment_intersections_by_contours(
bool same_prev = false;
bool same_next = false;
// Does the perimeter intersect the current vertical line above intrsctn?
for (int i = 0; i < il.intersections.size(); ++ i)
for (int i = 0; i < int(il.intersections.size()); ++ i)
if (const SegmentIntersection &it2 = il.intersections[i];
i != i_intersection && it2.iContour == itsct.iContour && it2.type != itsct.type) {
int d = distance_of_segmens(poly, it2.iSegment, itsct.iSegment, forward);
@ -1040,7 +1040,7 @@ static void connect_segment_intersections_by_contours(
}
// Make the LinkQuality::Invalid symmetric on vertical connections.
for (int i_intersection = 0; i_intersection < il.intersections.size(); ++ i_intersection) {
for (int i_intersection = 0; i_intersection < int(il.intersections.size()); ++ i_intersection) {
SegmentIntersection &it = il.intersections[i_intersection];
if (it.has_left_vertical() && it.prev_on_contour_quality == SegmentIntersection::LinkQuality::Invalid) {
SegmentIntersection &it2 = il.intersections[it.left_vertical()];
@ -1157,9 +1157,9 @@ static void traverse_graph_generate_polylines(
{
// For each outer only chords, measure their maximum distance to the bow of the outer contour.
// Mark an outer only chord as consumed, if the distance is low.
for (int i_vline = 0; i_vline < segs.size(); ++ i_vline) {
for (int i_vline = 0; i_vline < int(segs.size()); ++ i_vline) {
SegmentedIntersectionLine &vline = segs[i_vline];
for (int i_intersection = 0; i_intersection + 1 < vline.intersections.size(); ++ i_intersection) {
for (int i_intersection = 0; i_intersection + 1 < int(vline.intersections.size()); ++ i_intersection) {
if (vline.intersections[i_intersection].type == SegmentIntersection::OUTER_LOW &&
vline.intersections[i_intersection + 1].type == SegmentIntersection::OUTER_HIGH) {
bool consumed = false;
@ -1189,14 +1189,14 @@ static void traverse_graph_generate_polylines(
if (i_intersection == -1) {
// The path has been interrupted. Find a next starting point, closest to the previous extruder position.
coordf_t dist2min = std::numeric_limits<coordf_t>().max();
for (int i_vline2 = 0; i_vline2 < segs.size(); ++ i_vline2) {
for (int i_vline2 = 0; i_vline2 < int(segs.size()); ++ i_vline2) {
const SegmentedIntersectionLine &vline = segs[i_vline2];
if (! vline.intersections.empty()) {
assert(vline.intersections.size() > 1);
// Even number of intersections with the loops.
assert((vline.intersections.size() & 1) == 0);
assert(vline.intersections.front().type == SegmentIntersection::OUTER_LOW);
for (int i = 0; i < vline.intersections.size(); ++ i) {
for (int i = 0; i < int(vline.intersections.size()); ++ i) {
const SegmentIntersection& intrsctn = vline.intersections[i];
if (intrsctn.is_outer()) {
assert(intrsctn.is_low() || i > 0);
@ -1674,13 +1674,13 @@ static std::vector<MonotonousRegion> generate_montonous_regions(std::vector<Segm
auto test_overlap = [](int, int, int) { return false; };
#endif
for (int i_vline_seed = 0; i_vline_seed < segs.size(); ++ i_vline_seed) {
for (int i_vline_seed = 0; i_vline_seed < int(segs.size()); ++ i_vline_seed) {
SegmentedIntersectionLine &vline_seed = segs[i_vline_seed];
for (int i_intersection_seed = 1; i_intersection_seed + 1 < vline_seed.intersections.size(); ) {
while (i_intersection_seed < vline_seed.intersections.size() &&
for (int i_intersection_seed = 1; i_intersection_seed + 1 < int(vline_seed.intersections.size()); ) {
while (i_intersection_seed < int(vline_seed.intersections.size()) &&
vline_seed.intersections[i_intersection_seed].type != SegmentIntersection::INNER_LOW)
++ i_intersection_seed;
if (i_intersection_seed == vline_seed.intersections.size())
if (i_intersection_seed == int(vline_seed.intersections.size()))
break;
SegmentIntersection *start = &vline_seed.intersections[i_intersection_seed];
SegmentIntersection *end = &end_of_vertical_run(vline_seed, *start);
@ -1697,7 +1697,7 @@ static std::vector<MonotonousRegion> generate_montonous_regions(std::vector<Segm
assert(! test_overlap(region.left.vline, region.left.low, region.left.high));
start->consumed_vertical_up = true;
int num_lines = 1;
while (++ i_vline < segs.size()) {
while (++ i_vline < int(segs.size())) {
SegmentedIntersectionLine &vline_left = segs[i_vline - 1];
SegmentedIntersectionLine &vline_right = segs[i_vline];
std::pair<SegmentIntersection*, SegmentIntersection*> right = right_overlap(left, vline_left, vline_right);
@ -1860,7 +1860,7 @@ static void connect_monotonous_regions(std::vector<MonotonousRegion> &regions, c
}
}
}
if (region.right.vline + 1 < segs.size()) {
if (region.right.vline + 1 < int(segs.size())) {
auto &vline = segs[region.right.vline];
auto &vline_right = segs[region.right.vline + 1];
auto [rbegin, rend] = right_overlap(vline.intersections[region.right.low], vline.intersections[region.right.high], vline, vline_right);
@ -2100,7 +2100,7 @@ static std::vector<MonotonousRegionLink> chain_monotonous_regions(
AntPath &path2 = path_matrix(region, dir, *next, true);
if (path1.visibility > next_candidate.probability)
next_candidate = { next, &path1, &path1, path1.visibility, false };
if (path2.visibility > next_candidate.probability)
if (path2.visibility > next_candidate.probability)
next_candidate = { next, &path2, &path2, path2.visibility, true };
}
}
@ -2111,7 +2111,7 @@ static std::vector<MonotonousRegionLink> chain_monotonous_regions(
AntPath &path2 = path_matrix(region, dir, *next, true);
if (path1.visibility > next_candidate.probability)
next_candidate = { next, &path1, &path1, path1.visibility, false };
if (path2.visibility > next_candidate.probability)
if (path2.visibility > next_candidate.probability)
next_candidate = { next, &path2, &path2, path2.visibility, true };
}
}

View file

@ -7,6 +7,7 @@
#include "GCode/PrintExtents.hpp"
#include "GCode/WipeTower.hpp"
#include "ShortestPath.hpp"
#include "Print.hpp"
#include "Utils.hpp"
#include "libslic3r.h"

View file

@ -8,7 +8,6 @@
#include "MotionPlanner.hpp"
#include "Point.hpp"
#include "PlaceholderParser.hpp"
#include "Print.hpp"
#include "PrintConfig.hpp"
#include "GCode/CoolingBuffer.hpp"
#include "GCode/SpiralVase.hpp"
@ -38,6 +37,10 @@ class GCode;
class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
namespace { struct Item; }
struct PrintInstance;
using PrintObjectPtrs = std::vector<PrintObject*>;
class AvoidCrossingPerimeters {
public:

View file

@ -6,6 +6,7 @@
#include "../BoundingBox.hpp"
#include "../ExtrusionEntity.hpp"
#include "../ExtrusionEntityCollection.hpp"
#include "../Layer.hpp"
#include "../Print.hpp"
#include "PrintExtents.hpp"

View file

@ -1,4 +1,3 @@
#include "libslic3r/libslic3r.h"
#include "ThumbnailData.hpp"
namespace Slic3r {

View file

@ -24,4 +24,4 @@ typedef std::function<void(ThumbnailsList & thumbnails, const Vec2ds & sizes, bo
} // namespace Slic3r
#endif // slic3r_ThumbnailData_hpp_
#endif // slic3r_ThumbnailData_hpp_

View file

@ -1,5 +1,6 @@
#include "Print.hpp"
#include "ToolOrdering.hpp"
#include "Layer.hpp"
// #define SLIC3R_DEBUG
@ -15,7 +16,6 @@
#include <libslic3r.h>
#include "../GCodeWriter.hpp"
namespace Slic3r {

View file

@ -14,6 +14,8 @@ namespace Slic3r {
class Print;
class PrintObject;
class LayerTools;
namespace CustomGCode { struct Item; }
class PrintRegion;

View file

@ -282,7 +282,7 @@ namespace Slic3r {
};
GCodeReader parser;
unsigned int g1_lines_count = 0;
int g1_lines_count = 0;
int normal_g1_line_id = 0;
float normal_last_recorded_time = 0.0f;
int silent_g1_line_id = 0;

View file

@ -10,8 +10,6 @@
#include <cmath>
#include "libslic3r.h"
#include "Point.hpp"
#include "BoundingBox.hpp"
namespace Slic3r {

View file

@ -455,24 +455,19 @@ bool Model::looks_like_imperial_units() const
if (this->objects.size() == 0)
return false;
stl_vertex size = this->objects[0]->get_object_stl_stats().size;
for (ModelObject* obj : this->objects)
if (obj->get_object_stl_stats().volume < 9.0) // 9 = 3*3*3;
return true;
for (ModelObject* o : this->objects) {
auto sz = o->get_object_stl_stats().size;
if (size[0] < sz[0]) size[0] = sz[0];
if (size[1] < sz[1]) size[1] = sz[1];
if (size[2] < sz[2]) size[2] = sz[2];
}
return (size[0] < 3 && size[1] < 3 && size[2] < 3);
return false;
}
void Model::convert_from_imperial_units()
{
double in_to_mm = 25.4;
for (ModelObject* o : this->objects)
o->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm));
for (ModelObject* obj : this->objects)
if (obj->get_object_stl_stats().volume < 9.0) // 9 = 3*3*3;
obj->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm));
}
void Model::adjust_min_z()
@ -1273,6 +1268,27 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
return;
}
void ModelObject::merge()
{
if (this->volumes.size() == 1) {
// We can't merge meshes if there's just one volume
return;
}
TriangleMesh mesh;
for (ModelVolume* volume : volumes)
if (!volume->mesh().empty())
mesh.merge(volume->mesh());
mesh.repair();
this->clear_volumes();
ModelVolume* vol = this->add_volume(mesh);
if (!vol)
return;
}
// Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees,
// then the scaling in world coordinate system is not representable by the Geometry::Transformation structure.
// This situation is solved by baking in the instance transformation into the mesh vertices.
@ -1385,8 +1401,8 @@ unsigned int ModelObject::check_instances_print_volume_state(const BoundingBoxf3
inside_outside |= OUTSIDE;
}
model_instance->print_volume_state =
(inside_outside == (INSIDE | OUTSIDE)) ? ModelInstance::PVS_Partly_Outside :
(inside_outside == INSIDE) ? ModelInstance::PVS_Inside : ModelInstance::PVS_Fully_Outside;
(inside_outside == (INSIDE | OUTSIDE)) ? ModelInstancePVS_Partly_Outside :
(inside_outside == INSIDE) ? ModelInstancePVS_Inside : ModelInstancePVS_Fully_Outside;
if (inside_outside == INSIDE)
++ num_printable;
}

View file

@ -3,7 +3,6 @@
#include "libslic3r.h"
#include "Geometry.hpp"
#include "Layer.hpp"
#include "ObjectID.hpp"
#include "Point.hpp"
#include "PrintConfig.hpp"
@ -288,6 +287,7 @@ public:
bool needed_repair() const;
ModelObjectPtrs cut(size_t instance, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false); // Note: z is in world coordinates
void split(ModelObjectPtrs* new_objects);
void merge();
// Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees,
// then the scaling in world coordinate system is not representable by the Geometry::Transformation structure.
// This situation is solved by baking in the instance transformation into the mesh vertices.
@ -641,25 +641,26 @@ private:
}
};
enum ModelInstanceEPrintVolumeState : unsigned char
{
ModelInstancePVS_Inside,
ModelInstancePVS_Partly_Outside,
ModelInstancePVS_Fully_Outside,
ModelInstanceNum_BedStates
};
// A single instance of a ModelObject.
// Knows the affine transformation of an object.
class ModelInstance final : public ObjectBase
{
public:
enum EPrintVolumeState : unsigned char
{
PVS_Inside,
PVS_Partly_Outside,
PVS_Fully_Outside,
Num_BedStates
};
private:
Geometry::Transformation m_transformation;
public:
// flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state())
EPrintVolumeState print_volume_state;
ModelInstanceEPrintVolumeState print_volume_state;
// Whether or not this instance is printable
bool printable;
@ -706,7 +707,7 @@ public:
const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const { return m_transformation.get_matrix(dont_translate, dont_rotate, dont_scale, dont_mirror); }
bool is_printable() const { return object->printable && printable && (print_volume_state == PVS_Inside); }
bool is_printable() const { return object->printable && printable && (print_volume_state == ModelInstancePVS_Inside); }
// Getting the input polygon for arrange
arrangement::ArrangePolygon get_arrange_polygon() const;
@ -735,10 +736,10 @@ private:
ModelObject* object;
// Constructor, which assigns a new unique ID.
explicit ModelInstance(ModelObject* object) : print_volume_state(PVS_Inside), printable(true), object(object) { assert(this->id().valid()); }
explicit ModelInstance(ModelObject* object) : print_volume_state(ModelInstancePVS_Inside), printable(true), object(object) { assert(this->id().valid()); }
// Constructor, which assigns a new unique ID.
explicit ModelInstance(ModelObject *object, const ModelInstance &other) :
m_transformation(other.m_transformation), print_volume_state(PVS_Inside), printable(other.printable), object(object) { assert(this->id().valid() && this->id() != other.id()); }
m_transformation(other.m_transformation), print_volume_state(ModelInstancePVS_Inside), printable(other.printable), object(object) { assert(this->id().valid() && this->id() != other.id()); }
explicit ModelInstance(ModelInstance &&rhs) = delete;
ModelInstance& operator=(const ModelInstance &rhs) = delete;
@ -753,6 +754,7 @@ private:
}
};
class ModelWipeTower final : public ObjectBase
{
public:

View file

@ -1,4 +1,6 @@
#include "ModelArrange.hpp"
#include <libslic3r/Model.hpp>
#include "MTUtils.hpp"
namespace Slic3r {

View file

@ -1,11 +1,14 @@
#ifndef MODELARRANGE_HPP
#define MODELARRANGE_HPP
#include <libslic3r/Model.hpp>
#include <libslic3r/Arrange.hpp>
namespace Slic3r {
class Model;
class ModelInstance;
using ModelInstancePtrs = std::vector<ModelInstance*>;
using arrangement::ArrangePolygon;
using arrangement::ArrangePolygons;
using arrangement::ArrangeParams;

View file

@ -4,10 +4,9 @@
#include "PrintBase.hpp"
#include "BoundingBox.hpp"
#include "ExtrusionEntityCollection.hpp"
#include "Flow.hpp"
#include "Point.hpp"
#include "Layer.hpp"
#include "Model.hpp"
#include "Slicing.hpp"
#include "GCode/ToolOrdering.hpp"
#include "GCode/WipeTower.hpp"
@ -28,6 +27,8 @@ class GCode;
class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
enum class SlicingMode : uint32_t;
class Layer;
class SupportLayer;
// Print step IDs for keeping track of the print state.
enum PrintStep {
@ -152,18 +153,11 @@ public:
const Layer* get_layer(int idx) const { return m_layers[idx]; }
Layer* get_layer(int idx) { return m_layers[idx]; }
// Get a layer exactly at print_z.
const Layer* get_layer_at_printz(coordf_t print_z) const {
auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; });
return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it;
}
Layer* get_layer_at_printz(coordf_t print_z) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z)); }
const Layer* get_layer_at_printz(coordf_t print_z) const;
Layer* get_layer_at_printz(coordf_t print_z);
// Get a layer approximately at print_z.
const Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const {
coordf_t limit = print_z - epsilon;
auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; });
return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it;
}
Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); }
const Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const;
Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon);
// print_z: top of the layer; slice_z: center of the layer.
Layer* add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z);

View file

@ -1096,8 +1096,8 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionBool(false));
def = this->add("ironing_type", coEnum);
def->label = L("Ironingy Type");
def->tooltip = L("Ironingy Type");
def->label = L("Ironing Type");
def->tooltip = L("Ironing Type");
def->enum_keys_map = &ConfigOptionEnum<IroningType>::get_enum_values();
def->enum_values.push_back("top");
def->enum_values.push_back("topmost");

View file

@ -33,7 +33,7 @@ enum PrintHostType {
htOctoPrint, htDuet, htFlashAir, htAstroBox
};
enum InfillPattern {
enum InfillPattern : int {
ipRectilinear, ipMonotonous, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipCount,
};

View file

@ -4,6 +4,7 @@
#include "ElephantFootCompensation.hpp"
#include "Geometry.hpp"
#include "I18N.hpp"
#include "Layer.hpp"
#include "SupportMaterial.hpp"
#include "Surface.hpp"
#include "Slicing.hpp"
@ -2829,4 +2830,28 @@ void PrintObject::project_and_append_custom_supports(
} // loop over ModelVolumes
}
const Layer* PrintObject::get_layer_at_printz(coordf_t print_z) const {
auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; });
return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it;
}
Layer* PrintObject::get_layer_at_printz(coordf_t print_z) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z)); }
// Get a layer approximately at print_z.
const Layer* PrintObject::get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const {
coordf_t limit = print_z - epsilon;
auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; });
return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it;
}
Layer* PrintObject::get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); }
} // namespace Slic3r

View file

@ -1,18 +1,11 @@
#include <cmath>
#include <libslic3r/SLA/Common.hpp>
#include <libslic3r/SLA/Concurrency.hpp>
#include <libslic3r/SLA/SupportTree.hpp>
#include <libslic3r/SLA/SpatIndex.hpp>
#include <libslic3r/SLA/EigenMesh3D.hpp>
#include <libslic3r/SLA/Contour3D.hpp>
#include <libslic3r/SLA/Clustering.hpp>
#include <libslic3r/SLA/Hollowing.hpp>
// Workaround: IGL signed_distance.h will define PI in the igl namespace.
#undef PI
// HEAVY headers... takes eternity to compile
#include <libslic3r/AABBTreeIndirect.hpp>
// for concave hull merging decisions
#include <libslic3r/SLA/BoostAdapter.hpp>
@ -23,24 +16,23 @@
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#endif
#include <igl/ray_mesh_intersect.h>
#include <igl/point_mesh_squared_distance.h>
#include <igl/remove_duplicate_vertices.h>
#include <igl/collapse_small_triangles.h>
#include <igl/signed_distance.h>
#ifdef SLIC3R_HOLE_RAYCASTER
#include <libslic3r/SLA/Hollowing.hpp>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include <tbb/parallel_for.h>
#include "ClipperUtils.hpp"
namespace Slic3r {
namespace sla {
// Bring back PI from the igl namespace
using igl::PI;
/* **************************************************************************
* PointIndex implementation
@ -188,100 +180,72 @@ void BoxIndex::foreach(std::function<void (const BoxIndexEl &)> fn)
* EigenMesh3D implementation
* ****************************************************************************/
class EigenMesh3D::AABBImpl: public igl::AABB<Eigen::MatrixXd, 3> {
class EigenMesh3D::AABBImpl {
private:
AABBTreeIndirect::Tree3f m_tree;
public:
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
igl::WindingNumberAABB<Vec3d, Eigen::MatrixXd, Eigen::MatrixXi> windtree;
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
void init(const TriangleMesh& tm)
{
m_tree = AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set(
tm.its.vertices, tm.its.indices);
}
void intersect_ray(const TriangleMesh& tm,
const Vec3d& s, const Vec3d& dir, igl::Hit& hit)
{
AABBTreeIndirect::intersect_ray_first_hit(tm.its.vertices,
tm.its.indices,
m_tree,
s, dir, hit);
}
void intersect_ray(const TriangleMesh& tm,
const Vec3d& s, const Vec3d& dir, std::vector<igl::Hit>& hits)
{
AABBTreeIndirect::intersect_ray_all_hits(tm.its.vertices,
tm.its.indices,
m_tree,
s, dir, hits);
}
double squared_distance(const TriangleMesh& tm,
const Vec3d& point, int& i, Eigen::Matrix<double, 1, 3>& closest) {
size_t idx_unsigned = 0;
Vec3d closest_vec3d(closest);
double dist = AABBTreeIndirect::squared_distance_to_indexed_triangle_set(
tm.its.vertices,
tm.its.indices,
m_tree, point, idx_unsigned, closest_vec3d);
i = int(idx_unsigned);
closest = closest_vec3d;
return dist;
}
};
static const constexpr double MESH_EPS = 1e-6;
void to_eigen_mesh(const TriangleMesh &tmesh, Eigen::MatrixXd &V, Eigen::MatrixXi &F)
EigenMesh3D::EigenMesh3D(const TriangleMesh& tmesh)
: m_aabb(new AABBImpl()), m_tm(&tmesh)
{
const stl_file& stl = tmesh.stl;
V.resize(3*stl.stats.number_of_facets, 3);
F.resize(stl.stats.number_of_facets, 3);
for (unsigned int i = 0; i < stl.stats.number_of_facets; ++i) {
const stl_facet &facet = stl.facet_start[i];
V.block<1, 3>(3 * i + 0, 0) = facet.vertex[0].cast<double>();
V.block<1, 3>(3 * i + 1, 0) = facet.vertex[1].cast<double>();
V.block<1, 3>(3 * i + 2, 0) = facet.vertex[2].cast<double>();
F(i, 0) = int(3*i+0);
F(i, 1) = int(3*i+1);
F(i, 2) = int(3*i+2);
}
if (!tmesh.has_shared_vertices())
{
Eigen::MatrixXd rV;
Eigen::MatrixXi rF;
// We will convert this to a proper 3d mesh with no duplicate points.
Eigen::VectorXi SVI, SVJ;
igl::remove_duplicate_vertices(V, F, MESH_EPS, rV, SVI, SVJ, rF);
V = std::move(rV);
F = std::move(rF);
}
}
void to_triangle_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, TriangleMesh &out)
{
Pointf3s points(size_t(V.rows()));
std::vector<Vec3i> facets(size_t(F.rows()));
for (Eigen::Index i = 0; i < V.rows(); ++i)
points[size_t(i)] = V.row(i);
for (Eigen::Index i = 0; i < F.rows(); ++i)
facets[size_t(i)] = F.row(i);
out = {points, facets};
}
EigenMesh3D::EigenMesh3D(const TriangleMesh& tmesh): m_aabb(new AABBImpl()) {
auto&& bb = tmesh.bounding_box();
m_ground_level += bb.min(Z);
to_eigen_mesh(tmesh, m_V, m_F);
// Build the AABB accelaration tree
m_aabb->init(m_V, m_F);
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
m_aabb->windtree.set_mesh(m_V, m_F);
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
m_aabb->init(tmesh);
}
EigenMesh3D::~EigenMesh3D() {}
EigenMesh3D::EigenMesh3D(const EigenMesh3D &other):
m_V(other.m_V), m_F(other.m_F), m_ground_level(other.m_ground_level),
m_tm(other.m_tm), m_ground_level(other.m_ground_level),
m_aabb( new AABBImpl(*other.m_aabb) ) {}
EigenMesh3D::EigenMesh3D(const Contour3D &other)
{
m_V.resize(Eigen::Index(other.points.size()), 3);
m_F.resize(Eigen::Index(other.faces3.size() + 2 * other.faces4.size()), 3);
for (Eigen::Index i = 0; i < Eigen::Index(other.points.size()); ++i)
m_V.row(i) = other.points[size_t(i)];
for (Eigen::Index i = 0; i < Eigen::Index(other.faces3.size()); ++i)
m_F.row(i) = other.faces3[size_t(i)];
size_t N = other.faces3.size() + 2 * other.faces4.size();
for (size_t i = other.faces3.size(); i < N; i += 2) {
size_t quad_idx = (i - other.faces3.size()) / 2;
auto & quad = other.faces4[quad_idx];
m_F.row(Eigen::Index(i)) = Vec3i{quad(0), quad(1), quad(2)};
m_F.row(Eigen::Index(i + 1)) = Vec3i{quad(2), quad(3), quad(0)};
}
}
EigenMesh3D &EigenMesh3D::operator=(const EigenMesh3D &other)
{
m_V = other.m_V;
m_F = other.m_F;
m_tm = other.m_tm;
m_ground_level = other.m_ground_level;
m_aabb.reset(new AABBImpl(*other.m_aabb)); return *this;
}
@ -290,6 +254,42 @@ EigenMesh3D &EigenMesh3D::operator=(EigenMesh3D &&other) = default;
EigenMesh3D::EigenMesh3D(EigenMesh3D &&other) = default;
const std::vector<Vec3f>& EigenMesh3D::vertices() const
{
return m_tm->its.vertices;
}
const std::vector<Vec3i>& EigenMesh3D::indices() const
{
return m_tm->its.indices;
}
const Vec3f& EigenMesh3D::vertices(size_t idx) const
{
return m_tm->its.vertices[idx];
}
const Vec3i& EigenMesh3D::indices(size_t idx) const
{
return m_tm->its.indices[idx];
}
Vec3d EigenMesh3D::normal_by_face_id(int face_id) const {
return m_tm->stl.facet_start[face_id].normal.cast<double>();
}
EigenMesh3D::hit_result
EigenMesh3D::query_ray_hit(const Vec3d &s, const Vec3d &dir) const
{
@ -297,24 +297,26 @@ EigenMesh3D::query_ray_hit(const Vec3d &s, const Vec3d &dir) const
igl::Hit hit;
hit.t = std::numeric_limits<float>::infinity();
if (m_holes.empty()) {
m_aabb->intersect_ray(m_V, m_F, s, dir, hit);
hit_result ret(*this);
ret.m_t = double(hit.t);
ret.m_dir = dir;
ret.m_source = s;
if(!std::isinf(hit.t) && !std::isnan(hit.t)) {
ret.m_normal = this->normal_by_face_id(hit.id);
ret.m_face_id = hit.id;
}
#ifdef SLIC3R_HOLE_RAYCASTER
if (! m_holes.empty()) {
return ret;
}
else {
// If there are holes, the hit_results will be made by
// query_ray_hits (object) and filter_hits (holes):
return filter_hits(query_ray_hits(s, dir));
}
#endif
m_aabb->intersect_ray(*m_tm, s, dir, hit);
hit_result ret(*this);
ret.m_t = double(hit.t);
ret.m_dir = dir;
ret.m_source = s;
if(!std::isinf(hit.t) && !std::isnan(hit.t)) {
ret.m_normal = this->normal_by_face_id(hit.id);
ret.m_face_id = hit.id;
}
return ret;
}
std::vector<EigenMesh3D::hit_result>
@ -322,7 +324,7 @@ EigenMesh3D::query_ray_hits(const Vec3d &s, const Vec3d &dir) const
{
std::vector<EigenMesh3D::hit_result> outs;
std::vector<igl::Hit> hits;
m_aabb->intersect_ray(m_V, m_F, s, dir, hits);
m_aabb->intersect_ray(*m_tm, s, dir, hits);
// The sort is necessary, the hits are not always sorted.
std::sort(hits.begin(), hits.end(),
@ -351,6 +353,8 @@ EigenMesh3D::query_ray_hits(const Vec3d &s, const Vec3d &dir) const
return outs;
}
#ifdef SLIC3R_HOLE_RAYCASTER
EigenMesh3D::hit_result EigenMesh3D::filter_hits(
const std::vector<EigenMesh3D::hit_result>& object_hits) const
{
@ -445,26 +449,14 @@ EigenMesh3D::hit_result EigenMesh3D::filter_hits(
// if we got here, the ray ended up in infinity
return out;
}
#endif
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
EigenMesh3D::si_result EigenMesh3D::signed_distance(const Vec3d &p) const {
double sign = 0; double sqdst = 0; int i = 0; Vec3d c;
igl::signed_distance_winding_number(*m_aabb, m_V, m_F, m_aabb->windtree,
p, sign, sqdst, i, c);
return si_result(sign * std::sqrt(sqdst), i, c);
}
bool EigenMesh3D::inside(const Vec3d &p) const {
return m_aabb->windtree.inside(p);
}
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
double EigenMesh3D::squared_distance(const Vec3d &p, int& i, Vec3d& c) const {
double sqdst = 0;
Eigen::Matrix<double, 1, 3> pp = p;
Eigen::Matrix<double, 1, 3> cc;
sqdst = m_aabb->squared_distance(m_V, m_F, pp, i, cc);
sqdst = m_aabb->squared_distance(*m_tm, pp, i, cc);
c = cc;
return sqdst;
}
@ -498,7 +490,7 @@ PointSet normals(const PointSet& points,
std::function<void()> thr, // throw on cancel
const std::vector<unsigned>& pt_indices)
{
if (points.rows() == 0 || mesh.V().rows() == 0 || mesh.F().rows() == 0)
if (points.rows() == 0 || mesh.vertices().empty() || mesh.indices().empty())
return {};
std::vector<unsigned> range = pt_indices;
@ -520,11 +512,11 @@ PointSet normals(const PointSet& points,
mesh.squared_distance(points.row(eidx), faceid, p);
auto trindex = mesh.F().row(faceid);
auto trindex = mesh.indices(faceid);
const Vec3d &p1 = mesh.V().row(trindex(0));
const Vec3d &p2 = mesh.V().row(trindex(1));
const Vec3d &p3 = mesh.V().row(trindex(2));
const Vec3d &p1 = mesh.vertices(trindex(0)).cast<double>();
const Vec3d &p2 = mesh.vertices(trindex(1)).cast<double>();
const Vec3d &p3 = mesh.vertices(trindex(2)).cast<double>();
// We should check if the point lies on an edge of the hosting
// triangle. If it does then all the other triangles using the
@ -557,36 +549,30 @@ PointSet normals(const PointSet& points,
}
// vector for the neigboring triangles including the detected one.
std::vector<Vec3i> neigh;
std::vector<size_t> neigh;
if (ic >= 0) { // The point is right on a vertex of the triangle
for (int n = 0; n < mesh.F().rows(); ++n) {
for (size_t n = 0; n < mesh.indices().size(); ++n) {
thr();
Vec3i ni = mesh.F().row(n);
Vec3i ni = mesh.indices(n);
if ((ni(X) == ic || ni(Y) == ic || ni(Z) == ic))
neigh.emplace_back(ni);
neigh.emplace_back(n);
}
} else if (ia >= 0 && ib >= 0) { // the point is on and edge
// now get all the neigboring triangles
for (int n = 0; n < mesh.F().rows(); ++n) {
for (size_t n = 0; n < mesh.indices().size(); ++n) {
thr();
Vec3i ni = mesh.F().row(n);
Vec3i ni = mesh.indices(n);
if ((ni(X) == ia || ni(Y) == ia || ni(Z) == ia) &&
(ni(X) == ib || ni(Y) == ib || ni(Z) == ib))
neigh.emplace_back(ni);
neigh.emplace_back(n);
}
}
// Calculate the normals for the neighboring triangles
std::vector<Vec3d> neighnorms;
neighnorms.reserve(neigh.size());
for (const Vec3i &tri : neigh) {
const Vec3d & pt1 = mesh.V().row(tri(0));
const Vec3d & pt2 = mesh.V().row(tri(1));
const Vec3d & pt3 = mesh.V().row(tri(2));
Eigen::Vector3d U = pt2 - pt1;
Eigen::Vector3d V = pt3 - pt1;
neighnorms.emplace_back(U.cross(V).normalized());
}
for (size_t &tri_id : neigh)
neighnorms.emplace_back(mesh.normal_by_face_id(tri_id));
// Throw out duplicates. They would cause trouble with summing. We
// will use std::unique which works on sorted ranges. We will sort

View file

@ -7,18 +7,13 @@
#include <functional>
#include <Eigen/Geometry>
//#include "SLASpatIndex.hpp"
//#include <libslic3r/ExPolygon.hpp>
//#include <libslic3r/TriangleMesh.hpp>
// #define SLIC3R_SLA_NEEDS_WINDTREE
namespace Slic3r {
// Typedefs from Point.hpp
typedef Eigen::Matrix<float, 3, 1, Eigen::DontAlign> Vec3f;
typedef Eigen::Matrix<double, 3, 1, Eigen::DontAlign> Vec3d;
typedef Eigen::Matrix<int, 3, 1, Eigen::DontAlign> Vec3i;
typedef Eigen::Matrix<int, 4, 1, Eigen::DontAlign> Vec4i;
namespace sla {

View file

@ -28,14 +28,14 @@ Contour3D::Contour3D(TriangleMesh &&trmesh)
}
Contour3D::Contour3D(const EigenMesh3D &emesh) {
points.reserve(size_t(emesh.V().rows()));
faces3.reserve(size_t(emesh.F().rows()));
points.reserve(emesh.vertices().size());
faces3.reserve(emesh.indices().size());
for (int r = 0; r < emesh.V().rows(); r++)
points.emplace_back(emesh.V().row(r).cast<double>());
for (const Vec3f& vert : emesh.vertices())
points.emplace_back(vert.cast<double>());
for (int i = 0; i < emesh.F().rows(); i++)
faces3.emplace_back(emesh.F().row(i));
for (const auto& ind : emesh.indices())
faces3.emplace_back(ind);
}
Contour3D &Contour3D::merge(const Contour3D &ctr)

View file

@ -2,7 +2,16 @@
#define SLA_EIGENMESH3D_H
#include <libslic3r/SLA/Common.hpp>
#include "libslic3r/SLA/Hollowing.hpp"
// There is an implementation of a hole-aware raycaster that was eventually
// not used in production version. It is now hidden under following define
// for possible future use.
#define SLIC3R_HOLE_RAYCASTER
#ifdef SLIC3R_HOLE_RAYCASTER
#include "libslic3r/SLA/Hollowing.hpp"
#endif
namespace Slic3r {
@ -10,31 +19,26 @@ class TriangleMesh;
namespace sla {
struct Contour3D;
void to_eigen_mesh(const TriangleMesh &mesh, Eigen::MatrixXd &V, Eigen::MatrixXi &F);
void to_triangle_mesh(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, TriangleMesh &);
/// An index-triangle structure for libIGL functions. Also serves as an
/// alternative (raw) input format for the SLASupportTree.
// Implemented in libslic3r/SLA/Common.cpp
class EigenMesh3D {
class AABBImpl;
Eigen::MatrixXd m_V;
Eigen::MatrixXi m_F;
const TriangleMesh* m_tm;
double m_ground_level = 0, m_gnd_offset = 0;
std::unique_ptr<AABBImpl> m_aabb;
#ifdef SLIC3R_HOLE_RAYCASTER
// This holds a copy of holes in the mesh. Initialized externally
// by load_mesh setter.
std::vector<DrainHole> m_holes;
#endif
public:
explicit EigenMesh3D(const TriangleMesh&);
explicit EigenMesh3D(const Contour3D &other);
EigenMesh3D(const EigenMesh3D& other);
EigenMesh3D& operator=(const EigenMesh3D&);
@ -48,8 +52,10 @@ public:
inline void ground_level_offset(double o) { m_gnd_offset = o; }
inline double ground_level_offset() const { return m_gnd_offset; }
inline const Eigen::MatrixXd& V() const { return m_V; }
inline const Eigen::MatrixXi& F() const { return m_F; }
const std::vector<Vec3f>& vertices() const;
const std::vector<Vec3i>& indices() const;
const Vec3f& vertices(size_t idx) const;
const Vec3i& indices(size_t idx) const;
// Result of a raycast
class hit_result {
@ -88,51 +94,28 @@ public:
return is_hit() && normal().dot(m_dir) > 0;
}
};
#ifdef SLIC3R_HOLE_RAYCASTER
// Inform the object about location of holes
// creates internal copy of the vector
void load_holes(const std::vector<DrainHole>& holes) {
m_holes = holes;
}
// Casting a ray on the mesh, returns the distance where the hit occures.
hit_result query_ray_hit(const Vec3d &s, const Vec3d &dir) const;
// Casts a ray on the mesh and returns all hits
std::vector<hit_result> query_ray_hits(const Vec3d &s, const Vec3d &dir) const;
// Iterates over hits and holes and returns the true hit, possibly
// on the inside of a hole.
// This function is currently not used anywhere, it was written when the
// holes were subtracted on slices, that is, before we started using CGAL
// to actually cut the holes into the mesh.
hit_result filter_hits(const std::vector<EigenMesh3D::hit_result>& obj_hits) const;
#endif
class si_result {
double m_value;
int m_fidx;
Vec3d m_p;
si_result(double val, int i, const Vec3d& c):
m_value(val), m_fidx(i), m_p(c) {}
friend class EigenMesh3D;
public:
si_result() = delete;
double value() const { return m_value; }
operator double() const { return m_value; }
const Vec3d& point_on_mesh() const { return m_p; }
int F_idx() const { return m_fidx; }
};
// Casting a ray on the mesh, returns the distance where the hit occures.
hit_result query_ray_hit(const Vec3d &s, const Vec3d &dir) const;
// Casts a ray on the mesh and returns all hits
std::vector<hit_result> query_ray_hits(const Vec3d &s, const Vec3d &dir) const;
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
// The signed distance from a point to the mesh. Outputs the distance,
// the index of the triangle and the closest point in mesh coordinate space.
si_result signed_distance(const Vec3d& p) const;
bool inside(const Vec3d& p) const;
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
double squared_distance(const Vec3d& p, int& i, Vec3d& c) const;
inline double squared_distance(const Vec3d &p) const
{
@ -141,15 +124,7 @@ public:
return squared_distance(p, i, c);
}
Vec3d normal_by_face_id(int face_id) const {
auto trindex = F().row(face_id);
const Vec3d& p1 = V().row(trindex(0));
const Vec3d& p2 = V().row(trindex(1));
const Vec3d& p3 = V().row(trindex(2));
Eigen::Vector3d U = p2 - p1;
Eigen::Vector3d V = p3 - p1;
return U.cross(V).normalized();
}
Vec3d normal_by_face_id(int face_id) const;
};
// Calculate the normals for the selected points (from 'points' set) on the

View file

@ -28,7 +28,7 @@ std::array<double, 3> find_best_rotation(const ModelObject& modelobj,
// We will use only one instance of this converted mesh to examine different
// rotations
EigenMesh3D emesh(modelobj.raw_mesh());
const TriangleMesh& mesh = modelobj.raw_mesh();
// For current iteration number
unsigned status = 0;
@ -44,10 +44,10 @@ std::array<double, 3> find_best_rotation(const ModelObject& modelobj,
// call the status callback in each iteration but the actual value may be
// the same for subsequent iterations (status goes from 0 to 100 but
// iterations can be many more)
auto objfunc = [&emesh, &status, &statuscb, &stopcond, max_tries]
auto objfunc = [&mesh, &status, &statuscb, &stopcond, max_tries]
(double rx, double ry, double rz)
{
EigenMesh3D& m = emesh;
const TriangleMesh& m = mesh;
// prepare the rotation transformation
Transform3d rt = Transform3d::Identity();
@ -68,18 +68,8 @@ std::array<double, 3> find_best_rotation(const ModelObject& modelobj,
// area. The current function is only an example of how to optimize.
// Later we can add more criteria like the number of overhangs, etc...
for(int i = 0; i < m.F().rows(); i++) {
auto idx = m.F().row(i);
Vec3d p1 = m.V().row(idx(0));
Vec3d p2 = m.V().row(idx(1));
Vec3d p3 = m.V().row(idx(2));
Eigen::Vector3d U = p2 - p1;
Eigen::Vector3d V = p3 - p1;
// So this is the normal
auto n = U.cross(V).normalized();
for(size_t i = 0; i < m.stl.facet_start.size(); i++) {
Vec3d n = m.stl.facet_start[i].normal.cast<double>();
// rotate the normal with the current rotation given by the solver
n = rt * n;

View file

@ -7,9 +7,9 @@
#include <libslic3r/SLA/SupportPoint.hpp>
#include <libslic3r/SLA/EigenMesh3D.hpp>
#include <libslic3r/BoundingBox.hpp>
#include <libslic3r/ClipperUtils.hpp>
#include <libslic3r/Point.hpp>
#include <libslic3r/TriangleMesh.hpp>
#include <boost/container/small_vector.hpp>

View file

@ -1,621 +0,0 @@
#include <cmath>
#include "SLA/SLASupportTree.hpp"
#include "SLA/SLACommon.hpp"
#include "SLA/SLASpatIndex.hpp"
// Workaround: IGL signed_distance.h will define PI in the igl namespace.
#undef PI
// HEAVY headers... takes eternity to compile
// for concave hull merging decisions
#include "SLABoostAdapter.hpp"
#include "boost/geometry/index/rtree.hpp"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#endif
#include <igl/ray_mesh_intersect.h>
#include <igl/point_mesh_squared_distance.h>
#include <igl/remove_duplicate_vertices.h>
#include <igl/signed_distance.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include <tbb/parallel_for.h>
#include "SLASpatIndex.hpp"
#include "ClipperUtils.hpp"
namespace Slic3r {
namespace sla {
// Bring back PI from the igl namespace
using igl::PI;
/* **************************************************************************
* PointIndex implementation
* ************************************************************************** */
class PointIndex::Impl {
public:
using BoostIndex = boost::geometry::index::rtree< PointIndexEl,
boost::geometry::index::rstar<16, 4> /* ? */ >;
BoostIndex m_store;
};
PointIndex::PointIndex(): m_impl(new Impl()) {}
PointIndex::~PointIndex() {}
PointIndex::PointIndex(const PointIndex &cpy): m_impl(new Impl(*cpy.m_impl)) {}
PointIndex::PointIndex(PointIndex&& cpy): m_impl(std::move(cpy.m_impl)) {}
PointIndex& PointIndex::operator=(const PointIndex &cpy)
{
m_impl.reset(new Impl(*cpy.m_impl));
return *this;
}
PointIndex& PointIndex::operator=(PointIndex &&cpy)
{
m_impl.swap(cpy.m_impl);
return *this;
}
void PointIndex::insert(const PointIndexEl &el)
{
m_impl->m_store.insert(el);
}
bool PointIndex::remove(const PointIndexEl& el)
{
return m_impl->m_store.remove(el) == 1;
}
std::vector<PointIndexEl>
PointIndex::query(std::function<bool(const PointIndexEl &)> fn) const
{
namespace bgi = boost::geometry::index;
std::vector<PointIndexEl> ret;
m_impl->m_store.query(bgi::satisfies(fn), std::back_inserter(ret));
return ret;
}
std::vector<PointIndexEl> PointIndex::nearest(const Vec3d &el, unsigned k = 1) const
{
namespace bgi = boost::geometry::index;
std::vector<PointIndexEl> ret; ret.reserve(k);
m_impl->m_store.query(bgi::nearest(el, k), std::back_inserter(ret));
return ret;
}
size_t PointIndex::size() const
{
return m_impl->m_store.size();
}
void PointIndex::foreach(std::function<void (const PointIndexEl &)> fn)
{
for(auto& el : m_impl->m_store) fn(el);
}
void PointIndex::foreach(std::function<void (const PointIndexEl &)> fn) const
{
for(const auto &el : m_impl->m_store) fn(el);
}
/* **************************************************************************
* BoxIndex implementation
* ************************************************************************** */
class BoxIndex::Impl {
public:
using BoostIndex = boost::geometry::index::
rtree<BoxIndexEl, boost::geometry::index::rstar<16, 4> /* ? */>;
BoostIndex m_store;
};
BoxIndex::BoxIndex(): m_impl(new Impl()) {}
BoxIndex::~BoxIndex() {}
BoxIndex::BoxIndex(const BoxIndex &cpy): m_impl(new Impl(*cpy.m_impl)) {}
BoxIndex::BoxIndex(BoxIndex&& cpy): m_impl(std::move(cpy.m_impl)) {}
BoxIndex& BoxIndex::operator=(const BoxIndex &cpy)
{
m_impl.reset(new Impl(*cpy.m_impl));
return *this;
}
BoxIndex& BoxIndex::operator=(BoxIndex &&cpy)
{
m_impl.swap(cpy.m_impl);
return *this;
}
void BoxIndex::insert(const BoxIndexEl &el)
{
m_impl->m_store.insert(el);
}
bool BoxIndex::remove(const BoxIndexEl& el)
{
return m_impl->m_store.remove(el) == 1;
}
std::vector<BoxIndexEl> BoxIndex::query(const BoundingBox &qrbb,
BoxIndex::QueryType qt)
{
namespace bgi = boost::geometry::index;
std::vector<BoxIndexEl> ret; ret.reserve(m_impl->m_store.size());
switch (qt) {
case qtIntersects:
m_impl->m_store.query(bgi::intersects(qrbb), std::back_inserter(ret));
break;
case qtWithin:
m_impl->m_store.query(bgi::within(qrbb), std::back_inserter(ret));
}
return ret;
}
size_t BoxIndex::size() const
{
return m_impl->m_store.size();
}
void BoxIndex::foreach(std::function<void (const BoxIndexEl &)> fn)
{
for(auto& el : m_impl->m_store) fn(el);
}
/* ****************************************************************************
* EigenMesh3D implementation
* ****************************************************************************/
class EigenMesh3D::AABBImpl: public igl::AABB<Eigen::MatrixXd, 3> {
public:
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
igl::WindingNumberAABB<Vec3d, Eigen::MatrixXd, Eigen::MatrixXi> windtree;
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
};
EigenMesh3D::EigenMesh3D(const TriangleMesh& tmesh): m_aabb(new AABBImpl()) {
static const double dEPS = 1e-6;
const stl_file& stl = tmesh.stl;
auto&& bb = tmesh.bounding_box();
m_ground_level += bb.min(Z);
Eigen::MatrixXd V;
Eigen::MatrixXi F;
V.resize(3*stl.stats.number_of_facets, 3);
F.resize(stl.stats.number_of_facets, 3);
for (unsigned int i = 0; i < stl.stats.number_of_facets; ++i) {
const stl_facet &facet = stl.facet_start[i];
V.block<1, 3>(3 * i + 0, 0) = facet.vertex[0].cast<double>();
V.block<1, 3>(3 * i + 1, 0) = facet.vertex[1].cast<double>();
V.block<1, 3>(3 * i + 2, 0) = facet.vertex[2].cast<double>();
F(i, 0) = int(3*i+0);
F(i, 1) = int(3*i+1);
F(i, 2) = int(3*i+2);
}
// We will convert this to a proper 3d mesh with no duplicate points.
Eigen::VectorXi SVI, SVJ;
igl::remove_duplicate_vertices(V, F, dEPS, m_V, SVI, SVJ, m_F);
// Build the AABB accelaration tree
m_aabb->init(m_V, m_F);
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
m_aabb->windtree.set_mesh(m_V, m_F);
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
}
EigenMesh3D::~EigenMesh3D() {}
EigenMesh3D::EigenMesh3D(const EigenMesh3D &other):
m_V(other.m_V), m_F(other.m_F), m_ground_level(other.m_ground_level),
m_aabb( new AABBImpl(*other.m_aabb) ) {}
EigenMesh3D::EigenMesh3D(const Contour3D &other)
{
m_V.resize(Eigen::Index(other.points.size()), 3);
m_F.resize(Eigen::Index(other.faces3.size() + 2 * other.faces4.size()), 3);
for (Eigen::Index i = 0; i < Eigen::Index(other.points.size()); ++i)
m_V.row(i) = other.points[size_t(i)];
for (Eigen::Index i = 0; i < Eigen::Index(other.faces3.size()); ++i)
m_F.row(i) = other.faces3[size_t(i)];
size_t N = other.faces3.size() + 2 * other.faces4.size();
for (size_t i = other.faces3.size(); i < N; i += 2) {
size_t quad_idx = (i - other.faces3.size()) / 2;
auto & quad = other.faces4[quad_idx];
m_F.row(Eigen::Index(i)) = Vec3i{quad(0), quad(1), quad(2)};
m_F.row(Eigen::Index(i + 1)) = Vec3i{quad(2), quad(3), quad(0)};
}
}
EigenMesh3D &EigenMesh3D::operator=(const EigenMesh3D &other)
{
m_V = other.m_V;
m_F = other.m_F;
m_ground_level = other.m_ground_level;
m_aabb.reset(new AABBImpl(*other.m_aabb)); return *this;
}
EigenMesh3D::hit_result
EigenMesh3D::query_ray_hit(const Vec3d &s, const Vec3d &dir) const
{
igl::Hit hit;
hit.t = std::numeric_limits<float>::infinity();
m_aabb->intersect_ray(m_V, m_F, s, dir, hit);
hit_result ret(*this);
ret.m_t = double(hit.t);
ret.m_dir = dir;
ret.m_source = s;
if(!std::isinf(hit.t) && !std::isnan(hit.t)) ret.m_face_id = hit.id;
return ret;
}
std::vector<EigenMesh3D::hit_result>
EigenMesh3D::query_ray_hits(const Vec3d &s, const Vec3d &dir) const
{
std::vector<EigenMesh3D::hit_result> outs;
std::vector<igl::Hit> hits;
m_aabb->intersect_ray(m_V, m_F, s, dir, hits);
// The sort is necessary, the hits are not always sorted.
std::sort(hits.begin(), hits.end(),
[](const igl::Hit& a, const igl::Hit& b) { return a.t < b.t; });
// Convert the igl::Hit into hit_result
outs.reserve(hits.size());
for (const igl::Hit& hit : hits) {
outs.emplace_back(EigenMesh3D::hit_result(*this));
outs.back().m_t = double(hit.t);
outs.back().m_dir = dir;
outs.back().m_source = s;
if(!std::isinf(hit.t) && !std::isnan(hit.t))
outs.back().m_face_id = hit.id;
}
return outs;
}
#ifdef SLIC3R_SLA_NEEDS_WINDTREE
EigenMesh3D::si_result EigenMesh3D::signed_distance(const Vec3d &p) const {
double sign = 0; double sqdst = 0; int i = 0; Vec3d c;
igl::signed_distance_winding_number(*m_aabb, m_V, m_F, m_aabb->windtree,
p, sign, sqdst, i, c);
return si_result(sign * std::sqrt(sqdst), i, c);
}
bool EigenMesh3D::inside(const Vec3d &p) const {
return m_aabb->windtree.inside(p);
}
#endif /* SLIC3R_SLA_NEEDS_WINDTREE */
double EigenMesh3D::squared_distance(const Vec3d &p, int& i, Vec3d& c) const {
double sqdst = 0;
Eigen::Matrix<double, 1, 3> pp = p;
Eigen::Matrix<double, 1, 3> cc;
sqdst = m_aabb->squared_distance(m_V, m_F, pp, i, cc);
c = cc;
return sqdst;
}
/* ****************************************************************************
* Misc functions
* ****************************************************************************/
namespace {
bool point_on_edge(const Vec3d& p, const Vec3d& e1, const Vec3d& e2,
double eps = 0.05)
{
using Line3D = Eigen::ParametrizedLine<double, 3>;
auto line = Line3D::Through(e1, e2);
double d = line.distance(p);
return std::abs(d) < eps;
}
template<class Vec> double distance(const Vec& pp1, const Vec& pp2) {
auto p = pp2 - pp1;
return std::sqrt(p.transpose() * p);
}
}
PointSet normals(const PointSet& points,
const EigenMesh3D& mesh,
double eps,
std::function<void()> thr, // throw on cancel
const std::vector<unsigned>& pt_indices)
{
if(points.rows() == 0 || mesh.V().rows() == 0 || mesh.F().rows() == 0)
return {};
std::vector<unsigned> range = pt_indices;
if(range.empty()) {
range.resize(size_t(points.rows()), 0);
std::iota(range.begin(), range.end(), 0);
}
PointSet ret(range.size(), 3);
// for (size_t ridx = 0; ridx < range.size(); ++ridx)
tbb::parallel_for(size_t(0), range.size(),
[&ret, &range, &mesh, &points, thr, eps](size_t ridx)
{
thr();
auto eidx = Eigen::Index(range[ridx]);
int faceid = 0;
Vec3d p;
mesh.squared_distance(points.row(eidx), faceid, p);
auto trindex = mesh.F().row(faceid);
const Vec3d& p1 = mesh.V().row(trindex(0));
const Vec3d& p2 = mesh.V().row(trindex(1));
const Vec3d& p3 = mesh.V().row(trindex(2));
// We should check if the point lies on an edge of the hosting triangle.
// If it does then all the other triangles using the same two points
// have to be searched and the final normal should be some kind of
// aggregation of the participating triangle normals. We should also
// consider the cases where the support point lies right on a vertex
// of its triangle. The procedure is the same, get the neighbor
// triangles and calculate an average normal.
// mark the vertex indices of the edge. ia and ib marks and edge ic
// will mark a single vertex.
int ia = -1, ib = -1, ic = -1;
if(std::abs(distance(p, p1)) < eps) {
ic = trindex(0);
}
else if(std::abs(distance(p, p2)) < eps) {
ic = trindex(1);
}
else if(std::abs(distance(p, p3)) < eps) {
ic = trindex(2);
}
else if(point_on_edge(p, p1, p2, eps)) {
ia = trindex(0); ib = trindex(1);
}
else if(point_on_edge(p, p2, p3, eps)) {
ia = trindex(1); ib = trindex(2);
}
else if(point_on_edge(p, p1, p3, eps)) {
ia = trindex(0); ib = trindex(2);
}
// vector for the neigboring triangles including the detected one.
std::vector<Vec3i> neigh;
if(ic >= 0) { // The point is right on a vertex of the triangle
for(int n = 0; n < mesh.F().rows(); ++n) {
thr();
Vec3i ni = mesh.F().row(n);
if((ni(X) == ic || ni(Y) == ic || ni(Z) == ic))
neigh.emplace_back(ni);
}
}
else if(ia >= 0 && ib >= 0) { // the point is on and edge
// now get all the neigboring triangles
for(int n = 0; n < mesh.F().rows(); ++n) {
thr();
Vec3i ni = mesh.F().row(n);
if((ni(X) == ia || ni(Y) == ia || ni(Z) == ia) &&
(ni(X) == ib || ni(Y) == ib || ni(Z) == ib))
neigh.emplace_back(ni);
}
}
// Calculate the normals for the neighboring triangles
std::vector<Vec3d> neighnorms; neighnorms.reserve(neigh.size());
for(const Vec3i& tri : neigh) {
const Vec3d& pt1 = mesh.V().row(tri(0));
const Vec3d& pt2 = mesh.V().row(tri(1));
const Vec3d& pt3 = mesh.V().row(tri(2));
Eigen::Vector3d U = pt2 - pt1;
Eigen::Vector3d V = pt3 - pt1;
neighnorms.emplace_back(U.cross(V).normalized());
}
// Throw out duplicates. They would cause trouble with summing. We will
// use std::unique which works on sorted ranges. We will sort by the
// coefficient-wise sum of the normals. It should force the same
// elements to be consecutive.
std::sort(neighnorms.begin(), neighnorms.end(),
[](const Vec3d& v1, const Vec3d& v2){
return v1.sum() < v2.sum();
});
auto lend = std::unique(neighnorms.begin(), neighnorms.end(),
[](const Vec3d& n1, const Vec3d& n2) {
// Compare normals for equivalence. This is controvers stuff.
auto deq = [](double a, double b) { return std::abs(a-b) < 1e-3; };
return deq(n1(X), n2(X)) && deq(n1(Y), n2(Y)) && deq(n1(Z), n2(Z));
});
if(!neighnorms.empty()) { // there were neighbors to count with
// sum up the normals and then normalize the result again.
// This unification seems to be enough.
Vec3d sumnorm(0, 0, 0);
sumnorm = std::accumulate(neighnorms.begin(), lend, sumnorm);
sumnorm.normalize();
ret.row(long(ridx)) = sumnorm;
}
else { // point lies safely within its triangle
Eigen::Vector3d U = p2 - p1;
Eigen::Vector3d V = p3 - p1;
ret.row(long(ridx)) = U.cross(V).normalized();
}
});
return ret;
}
namespace bgi = boost::geometry::index;
using Index3D = bgi::rtree< PointIndexEl, bgi::rstar<16, 4> /* ? */ >;
namespace {
bool cmp_ptidx_elements(const PointIndexEl& e1, const PointIndexEl& e2)
{
return e1.second < e2.second;
};
ClusteredPoints cluster(Index3D &sindex,
unsigned max_points,
std::function<std::vector<PointIndexEl>(
const Index3D &, const PointIndexEl &)> qfn)
{
using Elems = std::vector<PointIndexEl>;
// Recursive function for visiting all the points in a given distance to
// each other
std::function<void(Elems&, Elems&)> group =
[&sindex, &group, max_points, qfn](Elems& pts, Elems& cluster)
{
for(auto& p : pts) {
std::vector<PointIndexEl> tmp = qfn(sindex, p);
std::sort(tmp.begin(), tmp.end(), cmp_ptidx_elements);
Elems newpts;
std::set_difference(tmp.begin(), tmp.end(),
cluster.begin(), cluster.end(),
std::back_inserter(newpts), cmp_ptidx_elements);
int c = max_points && newpts.size() + cluster.size() > max_points?
int(max_points - cluster.size()) : int(newpts.size());
cluster.insert(cluster.end(), newpts.begin(), newpts.begin() + c);
std::sort(cluster.begin(), cluster.end(), cmp_ptidx_elements);
if(!newpts.empty() && (!max_points || cluster.size() < max_points))
group(newpts, cluster);
}
};
std::vector<Elems> clusters;
for(auto it = sindex.begin(); it != sindex.end();) {
Elems cluster = {};
Elems pts = {*it};
group(pts, cluster);
for(auto& c : cluster) sindex.remove(c);
it = sindex.begin();
clusters.emplace_back(cluster);
}
ClusteredPoints result;
for(auto& cluster : clusters) {
result.emplace_back();
for(auto c : cluster) result.back().emplace_back(c.second);
}
return result;
}
std::vector<PointIndexEl> distance_queryfn(const Index3D& sindex,
const PointIndexEl& p,
double dist,
unsigned max_points)
{
std::vector<PointIndexEl> tmp; tmp.reserve(max_points);
sindex.query(
bgi::nearest(p.first, max_points),
std::back_inserter(tmp)
);
for(auto it = tmp.begin(); it < tmp.end(); ++it)
if(distance(p.first, it->first) > dist) it = tmp.erase(it);
return tmp;
}
} // namespace
// Clustering a set of points by the given criteria
ClusteredPoints cluster(
const std::vector<unsigned>& indices,
std::function<Vec3d(unsigned)> pointfn,
double dist,
unsigned max_points)
{
// A spatial index for querying the nearest points
Index3D sindex;
// Build the index
for(auto idx : indices) sindex.insert( std::make_pair(pointfn(idx), idx));
return cluster(sindex, max_points,
[dist, max_points](const Index3D& sidx, const PointIndexEl& p)
{
return distance_queryfn(sidx, p, dist, max_points);
});
}
// Clustering a set of points by the given criteria
ClusteredPoints cluster(
const std::vector<unsigned>& indices,
std::function<Vec3d(unsigned)> pointfn,
std::function<bool(const PointIndexEl&, const PointIndexEl&)> predicate,
unsigned max_points)
{
// A spatial index for querying the nearest points
Index3D sindex;
// Build the index
for(auto idx : indices) sindex.insert( std::make_pair(pointfn(idx), idx));
return cluster(sindex, max_points,
[max_points, predicate](const Index3D& sidx, const PointIndexEl& p)
{
std::vector<PointIndexEl> tmp; tmp.reserve(max_points);
sidx.query(bgi::satisfies([p, predicate](const PointIndexEl& e){
return predicate(p, e);
}), std::back_inserter(tmp));
return tmp;
});
}
ClusteredPoints cluster(const PointSet& pts, double dist, unsigned max_points)
{
// A spatial index for querying the nearest points
Index3D sindex;
// Build the index
for(Eigen::Index i = 0; i < pts.rows(); i++)
sindex.insert(std::make_pair(Vec3d(pts.row(i)), unsigned(i)));
return cluster(sindex, max_points,
[dist, max_points](const Index3D& sidx, const PointIndexEl& p)
{
return distance_queryfn(sidx, p, dist, max_points);
});
}
} // namespace sla
} // namespace Slic3r

View file

@ -11,7 +11,6 @@
#include "libslic3r.h"
#include "Utils.hpp"
#include "PrintConfig.hpp"
namespace Slic3r
{
@ -19,6 +18,7 @@ namespace Slic3r
class PrintConfig;
class PrintObjectConfig;
class ModelObject;
class DynamicPrintConfig;
// Parameters to guide object slicing and support generation.
// The slicing parameters account for a raft and whether the 1st object layer is printed with a normal or a bridging flow

View file

@ -95,8 +95,6 @@ set(SLIC3R_GUI_SOURCES
GUI/GUI_ObjectSettings.hpp
GUI/GUI_ObjectLayers.cpp
GUI/GUI_ObjectLayers.hpp
GUI/LambdaObjectDialog.cpp
GUI/LambdaObjectDialog.hpp
GUI/MeshUtils.cpp
GUI/MeshUtils.hpp
GUI/Tab.cpp

View file

@ -692,7 +692,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
glsafe(::glDisable(GL_BLEND));
}
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state)
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state)
{
if (config == nullptr)
return false;
@ -706,7 +706,7 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M
// Allow the objects to protrude below the print bed
print_volume.min(2) = -1e10;
ModelInstance::EPrintVolumeState state = ModelInstance::PVS_Inside;
ModelInstanceEPrintVolumeState state = ModelInstancePVS_Inside;
bool contained_min_one = false;
@ -725,11 +725,11 @@ bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, M
if (contained)
contained_min_one = true;
if ((state == ModelInstance::PVS_Inside) && volume->is_outside)
state = ModelInstance::PVS_Fully_Outside;
if ((state == ModelInstancePVS_Inside) && volume->is_outside)
state = ModelInstancePVS_Fully_Outside;
if ((state == ModelInstance::PVS_Fully_Outside) && volume->is_outside && print_volume.intersects(bb))
state = ModelInstance::PVS_Partly_Outside;
if ((state == ModelInstancePVS_Fully_Outside) && volume->is_outside && print_volume.intersects(bb))
state = ModelInstancePVS_Partly_Outside;
}
if (out_state != nullptr)

View file

@ -6,7 +6,7 @@
#include "libslic3r/Line.hpp"
#include "libslic3r/TriangleMesh.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Geometry.hpp"
#include <functional>
@ -34,6 +34,9 @@ class ExtrusionMultiPath;
class ExtrusionLoop;
class ExtrusionEntity;
class ExtrusionEntityCollection;
class ModelObject;
class ModelVolume;
enum ModelInstanceEPrintVolumeState : unsigned char;
// A container for interleaved arrays of 3D vertices and normals,
// possibly indexed by triangles and / or quads.
@ -572,7 +575,7 @@ public:
// returns true if all the volumes are completely contained in the print volume
// returns the containment state in the given out_state, if non-null
bool check_outside_state(const DynamicPrintConfig* config, ModelInstance::EPrintVolumeState* out_state);
bool check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state);
void reset_outside_state();
void update_colors_by_extruder(const DynamicPrintConfig* config);

View file

@ -300,13 +300,13 @@ void AppConfig::set_mouse_device(const std::string& name, double translation_spe
std::vector<std::string> AppConfig::get_mouse_device_names() const
{
static constexpr char *prefix = "mouse_device:";
static constexpr size_t prefix_len = 13; // strlen(prefix); reports error C2131: expression did not evaluate to a constant on VS2019
std::vector<std::string> out;
static constexpr const char *prefix = "mouse_device:";
static const size_t prefix_len = strlen(prefix);
std::vector<std::string> out;
for (const std::pair<std::string, std::map<std::string, std::string>>& key_value_pair : m_storage)
if (boost::starts_with(key_value_pair.first, "mouse_device:") && key_value_pair.first.size() > prefix_len)
if (boost::starts_with(key_value_pair.first, prefix) && key_value_pair.first.size() > prefix_len)
out.emplace_back(key_value_pair.first.substr(prefix_len));
return out;
return out;
}
void AppConfig::update_config_dir(const std::string &dir)

View file

@ -1,6 +1,7 @@
#include "BackgroundSlicingProcess.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "MainFrame.hpp"
#include <wx/app.h>
#include <wx/panel.h>
@ -36,6 +37,7 @@
#include "RemovableDriveManager.hpp"
#include "slic3r/Utils/Thread.hpp"
#include "slic3r/GUI/Plater.hpp"
namespace Slic3r {

View file

@ -5,15 +5,19 @@
#include <condition_variable>
#include <mutex>
#include <boost/filesystem/path.hpp>
#include <wx/event.h>
#include "libslic3r/Print.hpp"
#include "libslic3r/PrintBase.hpp"
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/Format/SL1.hpp"
#include "slic3r/Utils/PrintHost.hpp"
#if ENABLE_GCODE_VIEWER
#include "libslic3r/GCode/GCodeProcessor.hpp"
#endif // ENABLE_GCODE_VIEWER
namespace boost { namespace filesystem { class path; } }
namespace Slic3r {
class DynamicPrintConfig;
@ -22,7 +26,6 @@ class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
class Model;
class SLAPrint;
class SL1Archive;
class SlicingStatusEvent : public wxEvent
{
@ -92,7 +95,7 @@ public:
// Apply config over the print. Returns false, if the new config values caused any of the already
// processed steps to be invalidated, therefore the task will need to be restarted.
Print::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
// After calling the apply() function, set_task() may be called to limit the task to be processed by process().
// This is useful for calculating SLA supports for a single object only.
void set_task(const PrintBase::TaskParams &params);

View file

@ -1,4 +1,6 @@
#include "BedShapeDialog.hpp"
#include "GUI_App.hpp"
#include "OptionsGroup.hpp"
#include <wx/wx.h>
#include <wx/numformatter.h>

View file

@ -3,7 +3,7 @@
// The bed shape dialog.
// The dialog opens from Print Settins tab->Bed Shape : Set...
#include "OptionsGroup.hpp"
#include "GUI_Utils.hpp"
#include "2DBed.hpp"
#include "I18N.hpp"
@ -13,6 +13,8 @@
namespace Slic3r {
namespace GUI {
class ConfigOptionsGroup;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class BedShapePanel : public wxPanel
{

View file

@ -425,9 +425,6 @@ double Camera::calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double
if ((dx <= 0.0) || (dy <= 0.0))
return -1.0f;
double med_x = 0.5 * (max_x + min_x);
double med_y = 0.5 * (max_y + min_y);
dx *= margin_factor;
dy *= margin_factor;

View file

@ -27,6 +27,7 @@
#include "libslic3r/Utils.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "GUI_Utils.hpp"
#include "slic3r/Config/Snapshot.hpp"
#include "slic3r/Utils/PresetUpdater.hpp"

View file

@ -24,6 +24,9 @@
#include "AppConfig.hpp"
#include "PresetBundle.hpp"
#include "BedShapeDialog.hpp"
#include "GUI.hpp"
#include "wxExtensions.hpp"
namespace fs = boost::filesystem;

View file

@ -8,6 +8,7 @@
#endif // ENABLE_GCODE_VIEWER
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "I18N.hpp"
#include "ExtruderSequenceDialog.hpp"
#include "libslic3r/Print.hpp"
@ -272,14 +273,14 @@ wxCoord Control::get_position_from_value(const int value)
return wxCoord(SLIDER_MARGIN + int(val*step + 0.5));
}
wxSize Control::get_size()
wxSize Control::get_size() const
{
int w, h;
get_size(&w, &h);
return wxSize(w, h);
}
void Control::get_size(int *w, int *h)
void Control::get_size(int* w, int* h) const
{
GetSize(w, h);
is_horizontal() ? *w -= m_lock_icon_dim : *h -= m_lock_icon_dim;
@ -574,11 +575,32 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, bool right_
dc.GetMultiLineTextExtent(label, &text_width, &text_height);
wxPoint text_pos;
if (right_side)
text_pos = is_horizontal() ? wxPoint(pos.x + 1, pos.y + m_thumb_size.x / 2 + 1) :
wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1);
{
if (is_horizontal())
{
int width;
int height;
get_size(&width, &height);
int x_right = pos.x + 1 + text_width;
int xx = (x_right < width) ? pos.x + 1 : pos.x - text_width - 1;
text_pos = wxPoint(xx, pos.y + m_thumb_size.x / 2 + 1);
}
else
text_pos = wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1);
}
else
text_pos = is_horizontal() ? wxPoint(pos.x - text_width - 1, pos.y - m_thumb_size.x / 2 - text_height - 1) :
wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1);
{
if (is_horizontal())
{
int x = pos.x - text_width - 1;
int xx = (x > 0) ? x : pos.x + 1;
text_pos = wxPoint(xx, pos.y - m_thumb_size.x / 2 - text_height - 1);
}
else
text_pos = wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1);
}
dc.DrawText(label, text_pos);
}
@ -1323,6 +1345,15 @@ void Control::move_current_thumb(const bool condition)
if (is_horizontal())
delta *= -1;
// accelerators
int accelerator = 0;
if (wxGetKeyState(WXK_SHIFT))
accelerator += 5;
if (wxGetKeyState(WXK_CONTROL))
accelerator += 5;
if (accelerator > 0)
delta *= accelerator;
if (m_selection == ssLower) {
m_lower_value -= delta;
correct_lower_value();
@ -1366,6 +1397,22 @@ void Control::OnWheel(wxMouseEvent& event)
void Control::OnKeyDown(wxKeyEvent &event)
{
const int key = event.GetKeyCode();
#if ENABLE_GCODE_VIEWER
if (m_draw_mode != dmSequentialGCodeView && key == WXK_NUMPAD_ADD) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of add_tick() twice.
// To avoid this case we should suppress second add_tick() call.
m_ticks.suppress_plus(true);
add_current_tick(true);
}
else if (m_draw_mode != dmSequentialGCodeView && (key == WXK_NUMPAD_SUBTRACT || key == WXK_DELETE || key == WXK_BACK)) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of delete_tick() twice.
// To avoid this case we should suppress second delete_tick() call.
m_ticks.suppress_minus(true);
delete_current_tick();
}
else if (m_draw_mode != dmSequentialGCodeView && event.GetKeyCode() == WXK_SHIFT)
UseDefaultColors(false);
#else
if (key == WXK_NUMPAD_ADD) {
// OnChar() is called immediately after OnKeyDown(), which can cause call of add_tick() twice.
// To avoid this case we should suppress second add_tick() call.
@ -1380,6 +1427,7 @@ void Control::OnKeyDown(wxKeyEvent &event)
}
else if (event.GetKeyCode() == WXK_SHIFT)
UseDefaultColors(false);
#endif // ENABLE_GCODE_VIEWER
else if (is_horizontal())
{
#if ENABLE_GCODE_VIEWER
@ -1430,14 +1478,21 @@ void Control::OnKeyUp(wxKeyEvent &event)
void Control::OnChar(wxKeyEvent& event)
{
const int key = event.GetKeyCode();
if (key == '+' && !m_ticks.suppressed_plus()) {
add_current_tick(true);
m_ticks.suppress_plus(false);
}
else if (key == '-' && !m_ticks.suppressed_minus()) {
delete_current_tick();
m_ticks.suppress_minus(false);
#if ENABLE_GCODE_VIEWER
if (m_draw_mode != dmSequentialGCodeView)
{
#endif // ENABLE_GCODE_VIEWER
if (key == '+' && !m_ticks.suppressed_plus()) {
add_current_tick(true);
m_ticks.suppress_plus(false);
}
else if (key == '-' && !m_ticks.suppressed_minus()) {
delete_current_tick();
m_ticks.suppress_minus(false);
}
#if ENABLE_GCODE_VIEWER
}
#endif // ENABLE_GCODE_VIEWER
if (key == 'G')
#if ENABLE_GCODE_VIEWER
jump_to_value();

View file

@ -24,7 +24,7 @@ namespace DoubleSlider {
/* For exporting GCode in GCodeWriter is used XYZF_NUM(val) = PRECISION(val, 3) for XYZ values.
* So, let use same value as a permissible error for layer height.
*/
static double epsilon() { return 0.0011;}
constexpr double epsilon() { return 0.0011; }
// custom message the slider sends to its parent to notify a tick-change:
wxDECLARE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent);
@ -301,8 +301,8 @@ private:
int get_value_from_position(const wxCoord x, const wxCoord y);
int get_value_from_position(const wxPoint pos) { return get_value_from_position(pos.x, pos.y); }
wxCoord get_position_from_value(const int value);
wxSize get_size();
void get_size(int *w, int *h);
wxSize get_size() const;
void get_size(int* w, int* h) const;
double get_double_value(const SelectedSlider& selection);
wxString get_tooltip(int tick = -1);
int get_edited_tick_for_position(wxPoint pos, const std::string& gcode = ColorChangeCode);

View file

@ -3,6 +3,8 @@
#include "I18N.hpp"
#include "Field.hpp"
#include "wxExtensions.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include "libslic3r/PrintConfig.hpp"

View file

@ -5,6 +5,7 @@
#include "libslic3r/Print.hpp"
#include "libslic3r/Geometry.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "PresetBundle.hpp"
#include "Camera.hpp"
#include "I18N.hpp"

View file

@ -11,6 +11,7 @@
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/Geometry.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Layer.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Technologies.hpp"
#include "libslic3r/Tesselate.hpp"
@ -24,6 +25,8 @@
#include "slic3r/GUI/OpenGLManager.hpp"
#include "slic3r/GUI/3DBed.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
@ -1679,7 +1682,7 @@ void GLCanvas3D::reset_volumes()
int GLCanvas3D::check_volumes_outside_state() const
{
ModelInstance::EPrintVolumeState state;
ModelInstanceEPrintVolumeState state;
m_volumes.check_outside_state(m_config, &state);
return (int)state;
}
@ -2609,15 +2612,15 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
// checks for geometry outside the print volume to render it accordingly
if (!m_volumes.empty())
{
ModelInstance::EPrintVolumeState state;
ModelInstanceEPrintVolumeState state;
const bool contained_min_one = m_volumes.check_outside_state(m_config, &state);
_set_warning_texture(WarningTexture::ObjectClashed, state == ModelInstance::PVS_Partly_Outside);
_set_warning_texture(WarningTexture::ObjectOutside, state == ModelInstance::PVS_Fully_Outside);
_set_warning_texture(WarningTexture::ObjectClashed, state == ModelInstancePVS_Partly_Outside);
_set_warning_texture(WarningTexture::ObjectOutside, state == ModelInstancePVS_Fully_Outside);
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS,
contained_min_one && !m_model->objects.empty() && state != ModelInstance::PVS_Partly_Outside));
contained_min_one && !m_model->objects.empty() && state != ModelInstancePVS_Partly_Outside));
}
else
{

View file

@ -5,7 +5,6 @@
#include <memory>
#include <chrono>
#include "3DScene.hpp"
#include "GLToolbar.hpp"
#include "Event.hpp"
#include "Selection.hpp"
@ -18,6 +17,8 @@
#include "GCodeViewer.hpp"
#endif // ENABLE_GCODE_VIEWER
#include "libslic3r/Slicing.hpp"
#include <float.h>
#include <wx/timer.h>
@ -36,15 +37,18 @@ class wxGLContext;
namespace Slic3r {
class Bed3D;
struct Camera;
class BackgroundSlicingProcess;
#if !ENABLE_GCODE_VIEWER
class GCodePreviewData;
#endif // !ENABLE_GCODE_VIEWER
struct ThumbnailData;
struct SlicingParameters;
enum LayerHeightEditActionType : unsigned int;
class ModelObject;
class ModelInstance;
class PrintObject;
class Print;
class SLAPrint;
namespace CustomGCode { struct Item; }
namespace GUI {

View file

@ -3,6 +3,7 @@
#include "3DScene.hpp"
#include "GLCanvas3D.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include <GL/glew.h>

View file

@ -6,6 +6,7 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include <wx/event.h>
#include <wx/bitmap.h>

View file

@ -1,13 +1,11 @@
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "WipeTowerDialog.hpp"
#include <assert.h>
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/any.hpp>
#if __APPLE__
#import <IOKit/pwr_mgt/IOPMLib.h>
@ -18,22 +16,16 @@
#include "boost/nowide/convert.hpp"
#endif
#include <wx/display.h>
#include "wxExtensions.hpp"
#include "GUI_Preview.hpp"
#include "AboutDialog.hpp"
#include "AppConfig.hpp"
#include "ConfigWizard.hpp"
#include "PresetBundle.hpp"
#include "UpdateDialogs.hpp"
#include "MsgDialog.hpp"
#include "libslic3r/Utils.hpp"
#include "libslic3r/Print.hpp"
#include "Tab.hpp"
#include "GUI_ObjectList.hpp"
namespace Slic3r { namespace GUI {
namespace Slic3r {
class AppConfig;
namespace GUI {
#if __APPLE__
IOPMAssertionID assertionID;

View file

@ -36,6 +36,9 @@
#include "GUI_Utils.hpp"
#include "AppConfig.hpp"
#include "PresetBundle.hpp"
#include "3DScene.hpp"
#include "MainFrame.hpp"
#include "Plater.hpp"
#include "../Utils/PresetUpdater.hpp"
#include "../Utils/PrintHost.hpp"

View file

@ -3,8 +3,7 @@
#include <memory>
#include <string>
#include "libslic3r/PrintConfig.hpp"
#include "MainFrame.hpp"
#include "Preset.hpp"
#include "ImGuiWrapper.hpp"
#include "ConfigWizard.hpp"
#include "OpenGLManager.hpp"
@ -30,11 +29,21 @@ class PresetBundle;
class PresetUpdater;
class ModelObject;
class PrintHostJobQueue;
class Model;
namespace GUI{
class RemovableDriveManager;
class OtherInstanceMessageHandler;
class MainFrame;
class Sidebar;
class ObjectManipulation;
class ObjectSettings;
class ObjectList;
class ObjectLayers;
class Plater;
enum FileType
{
FT_STL,

View file

@ -2,9 +2,11 @@
#include "GUI_ObjectList.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "PresetBundle.hpp"
#include "libslic3r/Model.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <boost/algorithm/string.hpp>

View file

@ -4,13 +4,13 @@
#include "GUI_ObjectLayers.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "Plater.hpp"
#include "OptionsGroup.hpp"
#include "PresetBundle.hpp"
#include "Tab.hpp"
#include "wxExtensions.hpp"
#include "libslic3r/Model.hpp"
#include "LambdaObjectDialog.hpp"
#include "GLCanvas3D.hpp"
#include "Selection.hpp"
@ -1781,6 +1781,22 @@ void ObjectList::append_menu_items_convert_unit(wxMenu* menu)
[](wxCommandEvent&) { wxGetApp().plater()->convert_unit(false); }, "", menu);
}
void ObjectList::append_menu_item_merge_to_multipart_object(wxMenu* menu)
{
menu->AppendSeparator();
append_menu_item(menu, wxID_ANY, _L("Merge"), _L("Merge objects to the one multipart object"),
[this](wxCommandEvent&) { merge(true); }, "", menu,
[this]() { return this->can_merge_to_multipart_object(); }, wxGetApp().plater());
}
void ObjectList::append_menu_item_merge_to_single_object(wxMenu* menu)
{
menu->AppendSeparator();
append_menu_item(menu, wxID_ANY, _L("Merge"), _L("Merge objects to the one single object"),
[this](wxCommandEvent&) { merge(false); }, "", menu,
[this]() { return this->can_merge_to_single_object(); }, wxGetApp().plater());
}
void ObjectList::create_object_popupmenu(wxMenu *menu)
{
#ifdef __WXOSX__
@ -1795,6 +1811,10 @@ void ObjectList::create_object_popupmenu(wxMenu *menu)
// Split object to parts
append_menu_item_split(menu);
// menu->AppendSeparator();
// Merge multipart object to the single object
// append_menu_item_merge_to_single_object(menu);
menu->AppendSeparator();
// Layers Editing for object
@ -2365,6 +2385,107 @@ void ObjectList::split()
changed_object(obj_idx);
}
void ObjectList::merge(bool to_multipart_object)
{
// merge selected objects to the multipart object
if (to_multipart_object)
{
std::vector<int> obj_idxs;
wxDataViewItemArray sels;
GetSelections(sels);
assert(!sels.IsEmpty());
for (wxDataViewItem item : sels) {
const ItemType type = m_objects_model->GetItemType(item);
assert(type & (itObject/* | itInstance*/));
obj_idxs.emplace_back(type & itObject ? m_objects_model->GetIdByItem(item) :
m_objects_model->GetIdByItem(m_objects_model->GetTopParent(item)));
}
std::sort(obj_idxs.begin(), obj_idxs.end());
obj_idxs.erase(std::unique(obj_idxs.begin(), obj_idxs.end()), obj_idxs.end());
if (obj_idxs.size() <= 1)
return;
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Merge"));
Model* model = (*m_objects)[0]->get_model();
ModelObject* new_object = model->add_object();
new_object->name = _u8L("Merged");
DynamicPrintConfig* new_config = &new_object->config;
const Vec3d& main_offset = (*m_objects)[0]->instances[0]->get_offset();
for (int obj_idx : obj_idxs)
{
ModelObject* object = (*m_objects)[obj_idx];
Vec3d offset = object->instances[0]->get_offset();
if (object->id() == (*m_objects)[0]->id())
new_object->add_instance(*object->instances[0]);
auto new_opt_keys = new_config->keys();
const DynamicPrintConfig& from_config = object->config;
auto opt_keys = from_config.keys();
// merge settings
for (auto& opt_key : opt_keys) {
if (find(new_opt_keys.begin(), new_opt_keys.end(), opt_key) == new_opt_keys.end()) {
const ConfigOption* option = from_config.option(opt_key);
if (!option) {
// if current option doesn't exist in prints.get_edited_preset(),
// get it from default config values
option = DynamicPrintConfig::new_from_defaults_keys({ opt_key })->option(opt_key);
}
new_config->set_key_value(opt_key, option->clone());
}
}
// merge volumes
for (const ModelVolume* volume : object->volumes) {
ModelVolume* new_volume = new_object->add_volume(*volume);
Vec3d vol_offset = offset - main_offset + new_volume->get_offset();
new_volume->set_offset(vol_offset);
}
// save extruder value if it was set
if (object->volumes.size() == 1 && find(opt_keys.begin(), opt_keys.end(), "extruder") != opt_keys.end()) {
ModelVolume* volume = new_object->volumes.back();
const ConfigOption* option = from_config.option("extruder");
if (option)
volume->config.set_key_value("extruder", option->clone());
}
// merge layers
for (const auto& range : object->layer_config_ranges)
new_object->layer_config_ranges.emplace(range);
}
// remove selected objects
remove();
// Add new object(merged) to the object_list
add_object_to_list(m_objects->size() - 1);
}
// merge all parts to the one single object
// all part's settings will be lost
else
{
wxDataViewItem item = GetSelection();
if (!item)
return;
const int obj_idx = m_objects_model->GetIdByItem(item);
if (obj_idx == -1)
return;
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Merge all parts to the one single object"));
ModelObject* model_object = (*m_objects)[obj_idx];
model_object->merge();
m_objects_model->DeleteVolumeChildren(item);
changed_object(obj_idx);
}
}
void ObjectList::layers_editing()
{
const Selection& selection = scene_selection();
@ -2490,6 +2611,31 @@ bool ObjectList::can_split_instances()
return selection.is_multiple_full_instance() || selection.is_single_full_instance();
}
bool ObjectList::can_merge_to_multipart_object() const
{
wxDataViewItemArray sels;
GetSelections(sels);
if (sels.IsEmpty())
return false;
// should be selected just objects
for (wxDataViewItem item : sels)
if (!(m_objects_model->GetItemType(item) & (itObject/* | itInstance*/)))
return false;
return true;
}
bool ObjectList::can_merge_to_single_object() const
{
int obj_idx = get_selected_obj_idx();
if (obj_idx < 0)
return false;
// selected object should be multipart
return (*m_objects)[obj_idx]->volumes.size() > 1;
}
// NO_PARAMETERS function call means that changed object index will be determine from Selection()
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
{
@ -4111,6 +4257,7 @@ void ObjectList::show_multi_selection_menu()
}, wxGetApp().plater());
append_menu_items_convert_unit(menu);
append_menu_item_merge_to_multipart_object(menu);
wxGetApp().plater()->PopupMenu(menu);
}

View file

@ -254,6 +254,8 @@ public:
void append_menu_item_delete(wxMenu* menu);
void append_menu_item_scale_selection_to_fit_print_volume(wxMenu* menu);
void append_menu_items_convert_unit(wxMenu* menu);
void append_menu_item_merge_to_multipart_object(wxMenu *menu);
void append_menu_item_merge_to_single_object(wxMenu *menu);
void create_object_popupmenu(wxMenu *menu);
void create_sla_object_popupmenu(wxMenu*menu);
void create_part_popupmenu(wxMenu*menu);
@ -277,6 +279,7 @@ public:
void del_layers_from_object(const int obj_idx);
bool del_subobject_from_object(const int obj_idx, const int idx, const int type);
void split();
void merge(bool to_multipart_object);
void layers_editing();
wxDataViewItem add_layer_root_item(const wxDataViewItem obj_item);
@ -287,6 +290,8 @@ public:
bool is_splittable();
bool selected_instances_of_same_object();
bool can_split_instances();
bool can_merge_to_multipart_object() const;
bool can_merge_to_single_object() const;
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
wxBoxSizer* get_sizer() {return m_sizer;}

View file

@ -2,12 +2,16 @@
#include "GUI_ObjectList.hpp"
#include "I18N.hpp"
#include "GLCanvas3D.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "wxExtensions.hpp"
#include "PresetBundle.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Geometry.hpp"
#include "Selection.hpp"
#include "Plater.hpp"
#include "MainFrame.hpp"
#include <boost/algorithm/string.hpp>
#include "slic3r/Utils/FixModelByWin10.hpp"

View file

@ -4,7 +4,8 @@
#include <memory>
#include "GUI_ObjectSettings.hpp"
#include "GLCanvas3D.hpp"
#include "libslic3r/Point.hpp"
#include <float.h>
class wxBitmapComboBox;
class wxStaticText;

View file

@ -2,8 +2,10 @@
#include "GUI_ObjectList.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "wxExtensions.hpp"
#include "PresetBundle.hpp"
#include "Plater.hpp"
#include "libslic3r/Model.hpp"
#include <boost/algorithm/string.hpp>

View file

@ -6,13 +6,13 @@
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "I18N.hpp"
#include "AppConfig.hpp"
#include "3DScene.hpp"
#include "BackgroundSlicingProcess.hpp"
#include "OpenGLManager.hpp"
#include "GLCanvas3D.hpp"
#include "PresetBundle.hpp"
#include "DoubleSlider.hpp"
#include "Plater.hpp"
#include <wx/notebook.h>
#include <wx/glcanvas.h>

View file

@ -2,10 +2,11 @@
#define slic3r_GUI_Preview_hpp_
#include <wx/panel.h>
#include "libslic3r/Point.hpp"
#include "libslic3r/CustomGCode.hpp"
#include <string>
#include "libslic3r/Model.hpp"
#if ENABLE_GCODE_VIEWER
#include "libslic3r/GCode/GCodeProcessor.hpp"
#endif // ENABLE_GCODE_VIEWER

View file

@ -4,14 +4,9 @@
#include <GL/glew.h>
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
// TODO: Display tooltips quicker on Linux
namespace Slic3r {
namespace GUI {

View file

@ -4,7 +4,6 @@
#include "libslic3r/Point.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/Selection.hpp"
#include <cereal/archives/binary.hpp>
@ -31,9 +30,9 @@ static const float CONSTRAINED_COLOR[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
class ImGuiWrapper;
class GLCanvas3D;
class ClippingPlane;
enum class CommonGizmosDataID;
class CommonGizmosDataPool;
class Selection;
class GLGizmoBase
{

View file

@ -12,6 +12,7 @@
#include <algorithm>
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
namespace Slic3r {

View file

@ -8,6 +8,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "libslic3r/Model.hpp"

View file

@ -5,6 +5,8 @@
#include "slic3r/GUI/3DScene.hpp"
#include "libslic3r/ObjectID.hpp"
#include <cereal/types/vector.hpp>
@ -15,6 +17,7 @@ enum class FacetSupportType : int8_t;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;
class ClippingPlane;
class GLGizmoFdmSupports : public GLGizmoBase
{

View file

@ -3,6 +3,8 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "libslic3r/Model.hpp"
#include <numeric>
#include <GL/glew.h>

View file

@ -2,9 +2,14 @@
#define slic3r_GLGizmoFlatten_hpp_
#include "GLGizmoBase.hpp"
#include "slic3r/GUI/3DScene.hpp"
namespace Slic3r {
enum class ModelVolumeType : int;
namespace GUI {

View file

@ -11,6 +11,8 @@
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "libslic3r/Model.hpp"
namespace Slic3r {
namespace GUI {

View file

@ -5,12 +5,17 @@
#include "slic3r/GUI/GLSelectionRectangle.hpp"
#include <libslic3r/SLA/Hollowing.hpp>
#include <libslic3r/ObjectID.hpp>
#include <wx/dialog.h>
#include <cereal/types/vector.hpp>
namespace Slic3r {
class ConfigOption;
class ConfigOptionDef;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;

View file

@ -26,7 +26,6 @@ std::string GLGizmoScale3D::get_tooltip() const
bool single_instance = selection.is_single_full_instance();
bool single_volume = selection.is_single_modifier() || selection.is_single_volume();
bool single_selection = single_instance || single_volume;
Vec3f scale = 100.0f * Vec3f::Ones();
if (single_instance)

View file

@ -3,6 +3,8 @@
#include "GLGizmoBase.hpp"
#include "libslic3r/BoundingBox.hpp"
namespace Slic3r {
namespace GUI {

View file

@ -3,6 +3,7 @@
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include <GL/glew.h>

View file

@ -4,13 +4,17 @@
#include "GLGizmoBase.hpp"
#include "slic3r/GUI/GLSelectionRectangle.hpp"
#include "libslic3r/SLA/Common.hpp"
#include "libslic3r/SLA/SupportPoint.hpp"
#include "libslic3r/ObjectID.hpp"
#include <wx/dialog.h>
#include <cereal/types/vector.hpp>
namespace Slic3r {
class ConfigOption;
namespace GUI {
enum class SLAGizmoEventType : unsigned char;

View file

@ -6,6 +6,7 @@
#include "libslic3r/SLAPrint.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include <GL/glew.h>

View file

@ -6,6 +6,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoMove.hpp"
@ -17,6 +18,8 @@
#include "slic3r/GUI/Gizmos/GLGizmoCut.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoHollow.hpp"
#include "libslic3r/Model.hpp"
#include <wx/glcanvas.h>
namespace Slic3r {

View file

@ -6,6 +6,8 @@
#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "libslic3r/ObjectID.hpp"
#include <map>
namespace Slic3r {

View file

@ -1,5 +1,10 @@
#include "GUI_App.hpp"
#include "InstanceCheck.hpp"
#include "Plater.hpp"
#ifdef _WIN32
#include "MainFrame.hpp"
#endif
#include "libslic3r/Utils.hpp"
#include "libslic3r/Config.hpp"

View file

@ -1,6 +1,7 @@
#include "ArrangeJob.hpp"
#include "libslic3r/MTUtils.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"

View file

@ -3,6 +3,7 @@
#include "libslic3r/MTUtils.hpp"
#include "libslic3r/SLA/Rotfinder.hpp"
#include "libslic3r/MinAreaBoundingBox.hpp"
#include "libslic3r/Model.hpp"
#include "slic3r/GUI/Plater.hpp"

View file

@ -8,6 +8,8 @@
#include "slic3r/GUI/GUI_ObjectList.hpp"
#include "slic3r/Utils/SLAImport.hpp"
#include "libslic3r/Model.hpp"
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/combobox.h>

View file

@ -25,15 +25,6 @@
#include <wx/choicebk.h>
#endif // BOOK_TYPE
#if ENABLE_SCROLLABLE
static wxSize get_screen_size(wxWindow* window)
{
const auto idx = wxDisplay::GetFromWindow(window);
wxDisplay display(idx != wxNOT_FOUND ? idx : 0u);
return display.GetClientArea().GetSize();
}
#endif // ENABLE_SCROLLABLE
namespace Slic3r {
namespace GUI {

View file

@ -1,200 +0,0 @@
#include "LambdaObjectDialog.hpp"
#include <wx/window.h>
#include <wx/button.h>
#include "OptionsGroup.hpp"
#include "I18N.hpp"
namespace Slic3r
{
namespace GUI
{
LambdaObjectDialog::LambdaObjectDialog(wxWindow* parent,
const wxString type_name):
m_type_name(type_name)
{
Create(parent, wxID_ANY, _(L("Lambda Object")),
parent->GetScreenPosition(), wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
// instead of double dim[3] = { 1.0, 1.0, 1.0 };
object_parameters.dim[0] = 1.0;
object_parameters.dim[1] = 1.0;
object_parameters.dim[2] = 1.0;
sizer = new wxBoxSizer(wxVERTICAL);
// modificator options
if (m_type_name == wxEmptyString) {
m_modificator_options_book = new wxChoicebook( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxCHB_TOP);
sizer->Add(m_modificator_options_book, 1, wxEXPAND | wxALL, 10);
}
else {
m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
sizer->Add(m_panel, 1, wxEXPAND | wxALL, 10);
}
ConfigOptionDef def;
def.width = 70;
auto optgroup = init_modificator_options_page(_(L("Box")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
int opt_id = opt_key == "l" ? 0 :
opt_key == "w" ? 1 :
opt_key == "h" ? 2 : -1;
if (opt_id < 0) return;
object_parameters.dim[opt_id] = boost::any_cast<double>(value);
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Length");
Option option(def, "l");
optgroup->append_single_option_line(option);
def.label = L("Width");
option = Option(def, "w");
optgroup->append_single_option_line(option);
def.label = L("Height");
option = Option(def, "h");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Cylinder")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
int val = boost::any_cast<int>(value);
if (opt_key == "cyl_r")
object_parameters.cyl_r = val;
else if (opt_key == "cyl_h")
object_parameters.cyl_h = val;
else return;
};
def.type = coInt;
def.set_default_value(new ConfigOptionInt{ 1 });
def.label = L("Radius");
auto option = Option(def, "cyl_r");
optgroup->append_single_option_line(option);
def.label = L("Height");
option = Option(def, "cyl_h");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Sphere")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
if (opt_key == "sph_rho")
object_parameters.sph_rho = boost::any_cast<double>(value);
else return;
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Rho");
auto option = Option(def, "sph_rho");
optgroup->append_single_option_line(option);
}
optgroup = init_modificator_options_page(_(L("Slab")));
if (optgroup) {
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
double val = boost::any_cast<double>(value);
if (opt_key == "slab_z")
object_parameters.slab_z = val;
else if (opt_key == "slab_h")
object_parameters.slab_h = val;
else return;
};
def.type = coFloat;
def.set_default_value(new ConfigOptionFloat{ 1.0 });
def.label = L("Height");
auto option = Option(def, "slab_h");
optgroup->append_single_option_line(option);
def.label = L("Initial Z");
option = Option(def, "slab_z");
optgroup->append_single_option_line(option);
}
Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e)
{
auto page_idx = m_modificator_options_book->GetSelection();
if (page_idx < 0) return;
switch (page_idx)
{
case 0:
object_parameters.type = LambdaTypeBox;
break;
case 1:
object_parameters.type = LambdaTypeCylinder;
break;
case 2:
object_parameters.type = LambdaTypeSphere;
break;
case 3:
object_parameters.type = LambdaTypeSlab;
break;
default:
break;
}
}));
const auto button_sizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
wxButton* btn_OK = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
btn_OK->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
// validate user input
if (!CanClose())return;
EndModal(wxID_OK);
Destroy();
});
wxButton* btn_CANCEL = static_cast<wxButton*>(FindWindowById(wxID_CANCEL, this));
btn_CANCEL->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
// validate user input
if (!CanClose())return;
EndModal(wxID_CANCEL);
Destroy();
});
sizer->Add(button_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
SetSizer(sizer);
sizer->Fit(this);
sizer->SetSizeHints(this);
}
// Called from the constructor.
// Create a panel for a rectangular / circular / custom bed shape.
ConfigOptionsGroupShp LambdaObjectDialog::init_modificator_options_page(const wxString& title)
{
if (!m_type_name.IsEmpty() && m_type_name != title)
return nullptr;
auto panel = m_type_name.IsEmpty() ? new wxPanel(m_modificator_options_book) : m_panel;
ConfigOptionsGroupShp optgroup;
optgroup = std::make_shared<ConfigOptionsGroup>(panel, _(L("Add")) + " " +title + " " +dots);
optgroup->label_width = 100;
m_optgroups.push_back(optgroup);
if (m_type_name.IsEmpty()) {
panel->SetSizerAndFit(optgroup->sizer);
m_modificator_options_book->AddPage(panel, title);
}
else
panel->SetSizer(optgroup->sizer);
return optgroup;
}
} //namespace GUI
} //namespace Slic3r

View file

@ -1,59 +0,0 @@
#ifndef slic3r_LambdaObjectDialog_hpp_
#define slic3r_LambdaObjectDialog_hpp_
#include <vector>
#include <memory>
#include <wx/dialog.h>
#include <wx/sizer.h>
#include <wx/choicebk.h>
class wxPanel;
namespace Slic3r
{
namespace GUI
{
enum LambdaTypeIDs{
LambdaTypeBox,
LambdaTypeCylinder,
LambdaTypeSphere,
LambdaTypeSlab
};
struct OBJECT_PARAMETERS
{
LambdaTypeIDs type = LambdaTypeBox;
double dim[3];// = { 1.0, 1.0, 1.0 };
int cyl_r = 1;
int cyl_h = 1;
double sph_rho = 1.0;
double slab_h = 1.0;
double slab_z = 0.0;
};
class ConfigOptionsGroup;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class LambdaObjectDialog : public wxDialog
{
wxChoicebook* m_modificator_options_book = nullptr;
std::vector <ConfigOptionsGroupShp> m_optgroups;
wxString m_type_name;
wxPanel* m_panel = nullptr;
public:
LambdaObjectDialog(wxWindow* parent,
const wxString type_name = wxEmptyString);
~LambdaObjectDialog() {}
bool CanClose() { return true; } // ???
OBJECT_PARAMETERS& ObjectParameters() { return object_parameters; }
ConfigOptionsGroupShp init_modificator_options_page(const wxString& title);
// Note whether the window was already closed, so a pending update is not executed.
bool m_already_closed = false;
OBJECT_PARAMETERS object_parameters;
wxBoxSizer* sizer = nullptr;
};
} //namespace GUI
} //namespace Slic3r
#endif //slic3r_LambdaObjectDialog_hpp_

View file

@ -29,6 +29,7 @@
#include "InstanceCheck.hpp"
#include "I18N.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <fstream>
#include "GUI_App.hpp"

View file

@ -12,7 +12,6 @@
#include <map>
#include "GUI_Utils.hpp"
#include "Plater.hpp"
#include "Event.hpp"
class wxNotebook;
@ -27,6 +26,8 @@ namespace GUI
class Tab;
class PrintHostQueueDialog;
class Plater;
class MainFrame;
enum QuickSlice
{

View file

@ -104,8 +104,8 @@ private:
// whether certain points are visible or obscured by the mesh etc.
class MeshRaycaster {
public:
// The class makes a copy of the mesh as EigenMesh3D.
// The pointer can be invalidated after constructor returns.
// The class references extern TriangleMesh, which must stay alive
// during MeshRaycaster existence.
MeshRaycaster(const TriangleMesh& mesh)
: m_emesh(mesh)
{

View file

@ -6,6 +6,7 @@
#include "PresetBundle.hpp"
#include "AppConfig.hpp"
#include "GLCanvas3D.hpp"
#include "Plater.hpp"
#include <wx/glcanvas.h>

View file

@ -1,5 +1,7 @@
#include "OptionsGroup.hpp"
#include "ConfigExceptions.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include <utility>
#include <wx/numformatter.h>
@ -100,6 +102,36 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
return field;
}
OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
bool is_tab_opt /* = false */,
column_t extra_clmn /* = nullptr */) :
m_parent(_parent), title(title),
m_show_modified_btns(is_tab_opt),
staticbox(title!=""), extra_column(extra_clmn)
{
if (staticbox) {
stb = new wxStaticBox(_parent, wxID_ANY, _(title));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
} else
stb = nullptr;
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
auto num_columns = 1U;
if (label_width != 0) num_columns++;
if (extra_column != nullptr) num_columns++;
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 );
#if 0//#ifdef __WXGTK__
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sizer->Fit(m_panel);
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#else
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#endif /* __WXGTK__ */
}
void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& field)
{
if (!m_show_modified_btns) {

View file

@ -11,7 +11,6 @@
#include "libslic3r/PrintConfig.hpp"
#include "Field.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
// Translate the ifdef
@ -171,32 +170,7 @@ public:
}
OptionsGroup( wxWindow* _parent, const wxString& title, bool is_tab_opt = false,
column_t extra_clmn = nullptr) :
m_parent(_parent), title(title),
m_show_modified_btns(is_tab_opt),
staticbox(title!=""), extra_column(extra_clmn) {
if (staticbox) {
stb = new wxStaticBox(_parent, wxID_ANY, _(title));
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
} else
stb = nullptr;
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
auto num_columns = 1U;
if (label_width != 0) num_columns++;
if (extra_column != nullptr) num_columns++;
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 1,0);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width == 0 ? 0 : !extra_column ? 1 : 2 );
#if 0//#ifdef __WXGTK__
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
sizer->Fit(m_panel);
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#else
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
#endif /* __WXGTK__ */
}
column_t extra_clmn = nullptr);
wxGridSizer* get_grid_sizer() { return m_grid_sizer; }

View file

@ -2320,9 +2320,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
if (imperial_units)
convert_from_imperial_units(model);
else if (model.looks_like_imperial_units()) {
wxMessageDialog msg_dlg(q, _L(
"This model looks like saved in inches.\n"
"Should I consider this model as a saved in inches and convert it?") + "\n",
wxMessageDialog msg_dlg(q, format_wxstr(_L(
"Some object(s) in file %s looks like saved in inches.\n"
"Should I consider them as a saved in inches and convert them?"), from_path(filename)) + "\n",
_L("Saved in inches object detected"), wxICON_WARNING | wxYES | wxNO);
if (msg_dlg.ShowModal() == wxID_YES)
convert_from_imperial_units(model);
@ -2649,7 +2649,7 @@ void Plater::priv::object_list_changed()
{
const bool export_in_progress = this->background_process.is_export_scheduled(); // || ! send_gcode_file.empty());
// XXX: is this right?
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstance::PVS_Inside;
const bool model_fits = view3D->check_volumes_outside_state() == ModelInstancePVS_Inside;
sidebar->enable_buttons(!model.objects.empty() && !export_in_progress && model_fits);
}
@ -3345,7 +3345,7 @@ void Plater::priv::set_current_panel(wxPanel* panel)
// see: Plater::priv::object_list_changed()
// FIXME: it may be better to have a single function making this check and let it be called wherever needed
bool export_in_progress = this->background_process.is_export_scheduled();
bool model_fits = view3D->check_volumes_outside_state() != ModelInstance::PVS_Partly_Outside;
bool model_fits = view3D->check_volumes_outside_state() != ModelInstancePVS_Partly_Outside;
if (!model.objects.empty() && !export_in_progress && model_fits)
this->q->reslice();
// keeps current gcode preview, if any

View file

@ -25,10 +25,13 @@ namespace Slic3r {
class Model;
class ModelObject;
class ModelInstance;
class Print;
class SLAPrint;
enum SLAPrintObjectStep : unsigned int;
using ModelInstancePtrs = std::vector<ModelInstance*>;
namespace UndoRedo {
class Stack;
struct Snapshot;

View file

@ -1,6 +1,7 @@
#include "Preferences.hpp"
#include "AppConfig.hpp"
#include "OptionsGroup.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
namespace Slic3r {
@ -364,4 +365,4 @@ void PreferencesDialog::create_settings_mode_widget()
} // GUI
} // Slic3r
} // Slic3r

View file

@ -962,7 +962,7 @@ void PresetCollection::load_bitmap_add(const std::string &file_name)
const Preset* PresetCollection::get_selected_preset_parent() const
{
if (this->get_selected_idx() == -1)
if (this->get_selected_idx() == size_t(-1))
// This preset collection has no preset activated yet. Only the get_edited_preset() is valid.
return nullptr;

View file

@ -296,9 +296,8 @@ std::string PresetHints::top_bottom_shell_thickness_explanation(const PresetBund
double bottom_solid_min_thickness = print_config.opt_float("bottom_solid_min_thickness");
double layer_height = print_config.opt_float("layer_height");
bool variable_layer_height = printer_config.opt_bool("variable_layer_height");
//FIXME the following lines take into account the 1st extruder only.
//FIXME the following line takes into account the 1st extruder only.
double min_layer_height = variable_layer_height ? Slicing::min_layer_height_from_nozzle(printer_config, 1) : layer_height;
double max_layer_height = variable_layer_height ? Slicing::max_layer_height_from_nozzle(printer_config, 1) : layer_height;
if (layer_height <= 0.f) {
out += _utf8(L("Top / bottom shell thickness hint: Not available due to invalid layer height."));

View file

@ -10,6 +10,7 @@
#include "libslic3r/PrintConfig.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "Tab.hpp"
#include "PresetBundle.hpp"

View file

@ -228,11 +228,11 @@ public:
// implementation of base class virtuals to define model
virtual unsigned int GetColumnCount() const wxOVERRIDE { return colMax; }
virtual wxString GetColumnType(unsigned int col) const wxOVERRIDE;
virtual void GetValueByRow(wxVariant& variant, unsigned int row, unsigned int col) const wxOVERRIDE;
virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr& attr) const wxOVERRIDE { return true; }
virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, unsigned int col) wxOVERRIDE { return false; }
virtual unsigned int GetColumnCount() const override { return colMax; }
virtual wxString GetColumnType(unsigned int col) const override;
virtual void GetValueByRow(wxVariant& variant, unsigned int row, unsigned int col) const override;
virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr& attr) const override { return true; }
virtual bool SetValueByRow(const wxVariant& variant, unsigned int row, unsigned int col) override { return false; }
};

View file

@ -1,14 +1,17 @@
#include "libslic3r/libslic3r.h"
#include "Selection.hpp"
#include "3DScene.hpp"
#include "GLCanvas3D.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "GUI_ObjectManipulation.hpp"
#include "GUI_ObjectList.hpp"
#include "Gizmos/GLGizmoBase.hpp"
#include "3DScene.hpp"
#include "Camera.hpp"
#include "Plater.hpp"
#include "libslic3r/Model.hpp"
#include <GL/glew.h>
@ -57,7 +60,7 @@ bool Selection::Clipboard::is_sla_compliant() const
if (m_mode == Selection::Volume)
return false;
for (const ModelObject* o : m_model.objects)
for (const ModelObject* o : m_model->objects)
{
if (o->is_multiparts())
return false;
@ -72,6 +75,35 @@ bool Selection::Clipboard::is_sla_compliant() const
return true;
}
Selection::Clipboard::Clipboard()
{
m_model.reset(new Model);
}
void Selection::Clipboard::reset() {
m_model->clear_objects();
}
bool Selection::Clipboard::is_empty() const
{
return m_model->objects.empty();
}
ModelObject* Selection::Clipboard::add_object()
{
return m_model->add_object();
}
ModelObject* Selection::Clipboard::get_object(unsigned int id)
{
return (id < (unsigned int)m_model->objects.size()) ? m_model->objects[id] : nullptr;
}
const ModelObjectPtrs& Selection::Clipboard::get_objects() const
{
return m_model->objects;
}
Selection::Selection()
: m_volumes(nullptr)
, m_model(nullptr)
@ -79,11 +111,13 @@ Selection::Selection()
, m_mode(Instance)
, m_type(Empty)
, m_valid(false)
#if !ENABLE_GCODE_VIEWER
, m_curved_arrow(16)
#endif // !ENABLE_GCODE_VIEWER
, m_scale_factor(1.0f)
{
#if !ENABLE_GCODE_VIEWER
m_arrow.reset(new GLArrow);
m_curved_arrow.reset(new GLCurvedArrow(16));
#endif // !ENABLE_GCODE_VIEWER
this->set_bounding_boxes_dirty();
#if ENABLE_RENDER_SELECTION_CENTER
m_quadric = ::gluNewQuadric();
@ -113,17 +147,16 @@ bool Selection::init()
m_arrow.init_from(straight_arrow(10.0f, 5.0f, 5.0f, 10.0f, 1.0f));
m_curved_arrow.init_from(circular_arrow(16, 10.0f, 5.0f, 10.0f, 5.0f, 1.0f));
#else
if (!m_arrow.init())
if (!m_arrow->init())
return false;
m_arrow.set_scale(5.0 * Vec3d::Ones());
m_arrow->set_scale(5.0 * Vec3d::Ones());
if (!m_curved_arrow.init())
if (!m_curved_arrow->init())
return false;
m_curved_arrow.set_scale(5.0 * Vec3d::Ones());
m_curved_arrow->set_scale(5.0 * Vec3d::Ones());
#endif //ENABLE_GCODE_VIEWER
return true;
}
@ -1959,17 +1992,23 @@ void Selection::render_sidebar_rotation_hints(const std::string& sidebar_field)
shader->set_uniform("uniform_color", AXES_COLOR[axis], 4);
};
auto render_sidebar_rotation_hint = [this]() {
m_curved_arrow.render();
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_curved_arrow.render();
};
if (boost::ends_with(sidebar_field, "x")) {
set_color(X);
glsafe(::glRotated(90.0, 0.0, 1.0, 0.0));
render_sidebar_rotation_hint(X);
render_sidebar_rotation_hint();
} else if (boost::ends_with(sidebar_field, "y")) {
set_color(Y);
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
render_sidebar_rotation_hint(Y);
render_sidebar_rotation_hint();
} else if (boost::ends_with(sidebar_field, "z")) {
set_color(Z);
render_sidebar_rotation_hint(Z);
render_sidebar_rotation_hint();
}
}
#else
@ -1994,6 +2033,19 @@ void Selection::render_sidebar_scale_hints(const std::string& sidebar_field) con
{
bool uniform_scale = requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling();
auto render_sidebar_scale_hint = [this, uniform_scale](Axis axis) {
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", uniform_scale ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis], 4);
glsafe(::glTranslated(0.0, 5.0, 0.0));
m_arrow.render();
glsafe(::glTranslated(0.0, -10.0, 0.0));
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_arrow.render();
};
if (boost::ends_with(sidebar_field, "x") || uniform_scale)
{
glsafe(::glPushMatrix());
@ -2093,38 +2145,31 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field) co
#if !ENABLE_GCODE_VIEWER
void Selection::render_sidebar_position_hint(Axis axis) const
{
m_arrow.set_color(AXES_COLOR[axis], 3);
m_arrow.render();
m_arrow->set_color(AXES_COLOR[axis], 3);
m_arrow->render();
}
#endif // !ENABLE_GCODE_VIEWER
void Selection::render_sidebar_rotation_hint(Axis axis) const
{
#if !ENABLE_GCODE_VIEWER
m_curved_arrow.set_color(AXES_COLOR[axis], 3);
#endif // !ENABLE_GCODE_VIEWER
m_curved_arrow.render();
m_curved_arrow->set_color(AXES_COLOR[axis], 3);
m_curved_arrow->render();
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_curved_arrow.render();
m_curved_arrow->render();
}
void Selection::render_sidebar_scale_hint(Axis axis) const
{
#if ENABLE_GCODE_VIEWER
GLShaderProgram* shader = wxGetApp().get_current_shader();
if (shader != nullptr)
shader->set_uniform("uniform_color", (requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis], 4);
#else
m_arrow.set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
#endif // ENABLE_GCODE_VIEWER
m_arrow->set_color(((requires_uniform_scale() || wxGetApp().obj_manipul()->get_uniform_scaling()) ? UNIFORM_SCALE_COLOR : AXES_COLOR[axis]), 3);
glsafe(::glTranslated(0.0, 5.0, 0.0));
m_arrow.render();
m_arrow->render();
glsafe(::glTranslated(0.0, -10.0, 0.0));
glsafe(::glRotated(180.0, 0.0, 0.0, 1.0));
m_arrow.render();
m_arrow->render();
}
#endif // !ENABLE_GCODE_VIEWER
#ifndef NDEBUG
static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)

View file

@ -3,7 +3,6 @@
#include <set>
#include "libslic3r/Geometry.hpp"
#include "3DScene.hpp"
#if ENABLE_GCODE_VIEWER
#include "GLModel.hpp"
#endif // ENABLE_GCODE_VIEWER
@ -14,10 +13,20 @@ typedef class GLUquadric GLUquadricObj;
#endif // ENABLE_RENDER_SELECTION_CENTER
namespace Slic3r {
#if !ENABLE_GCODE_VIEWER
class Shader;
#endif // !ENABLE_GCODE_VIEWER
class Model;
class ModelObject;
class GLVolume;
class GLArrow;
class GLCurvedArrow;
class DynamicPrintConfig;
class GLShaderProgram;
using GLVolumePtrs = std::vector<GLVolume*>;
using ModelObjectPtrs = std::vector<ModelObject*>;
namespace GUI {
class TransformationType
{
@ -151,18 +160,23 @@ public:
class Clipboard
{
Model m_model;
// Model is stored through a pointer to avoid including heavy Model.hpp.
// It is created in constructor.
std::unique_ptr<Model> m_model;
Selection::EMode m_mode;
public:
void reset() { m_model.clear_objects(); }
bool is_empty() const { return m_model.objects.empty(); }
Clipboard();
void reset();
bool is_empty() const;
bool is_sla_compliant() const;
ModelObject* add_object() { return m_model.add_object(); }
ModelObject* get_object(unsigned int id) { return (id < (unsigned int)m_model.objects.size()) ? m_model.objects[id] : nullptr; }
const ModelObjectPtrs& get_objects() const { return m_model.objects; }
ModelObject* add_object();
ModelObject* get_object(unsigned int id);
const ModelObjectPtrs& get_objects() const;
Selection::EMode get_mode() const { return m_mode; }
void set_mode(Selection::EMode mode) { m_mode = mode; }
@ -206,12 +220,15 @@ private:
#if ENABLE_RENDER_SELECTION_CENTER
GLUquadricObj* m_quadric;
#endif // ENABLE_RENDER_SELECTION_CENTER
#if ENABLE_GCODE_VIEWER
GLModel m_arrow;
GLModel m_curved_arrow;
#else
mutable GLArrow m_arrow;
mutable GLCurvedArrow m_curved_arrow;
// Arrows are saved through pointers to avoid including 3DScene.hpp.
// It also allows mutability.
std::unique_ptr<GLArrow> m_arrow;
std::unique_ptr<GLCurvedArrow> m_curved_arrow;
#endif // ENABLE_GCODE_VIEWER
mutable float m_scale_factor;
@ -371,9 +388,9 @@ private:
void render_sidebar_layers_hints(const std::string& sidebar_field) const;
#if !ENABLE_GCODE_VIEWER
void render_sidebar_position_hint(Axis axis) const;
#endif // !ENABLE_GCODE_VIEWER
void render_sidebar_rotation_hint(Axis axis) const;
void render_sidebar_scale_hint(Axis axis) const;
#endif // !ENABLE_GCODE_VIEWER
public:
enum SyncRotationType {

View file

@ -3,6 +3,7 @@
#include "3DScene.hpp"
#include "GUI.hpp"
#include "../Utils/UndoRedo.hpp"
#include "Plater.hpp"
#include <string>

Some files were not shown because too many files have changed in this diff Show more