Commit Graph

328 Commits

Author SHA1 Message Date
Vojtech Bubnik
cc44089440 New BuildVolume class was created, which detects build volume type (rectangular,
circular, convex, concave) and performs efficient collision detection agains these build
volumes. As of now, collision detection is performed against a convex
hull of a concave build volume for efficency.

GCodeProcessor::Result renamed out of GCodeProcessor to GCodeProcessorResult,
so it could be forward declared.

Plater newly exports BuildVolume, not Bed3D. Bed3D is a rendering class,
while BuildVolume is a purely geometric class.

Reduced usage of global wxGetApp, the Bed3D is passed as a parameter
to View3D/Preview/GLCanvas.

Convex hull code was extracted from Geometry.cpp/hpp to Geometry/ConvexHulll.cpp,hpp.
New test inside_convex_polygon().
New efficent point inside polygon test: Decompose convex hull
to bottom / top parts and use the decomposition to detect point inside
a convex polygon in O(log n). decompose_convex_polygon_top_bottom(),
inside_convex_polygon().

New Circle constructing functions: circle_ransac() and circle_taubin_newton().

New polygon_is_convex() test with unit tests.
2021-11-16 10:15:51 +01:00
Filip Sykala
f9bdde5603 Remove SimplifyMesh 2021-11-02 14:23:49 +01:00
Vojtech Bubnik
d78a5acba9 Numerical improvements to Welzel minimum enclosing circle algorithm 2021-10-30 11:18:36 +02:00
Vojtech Bubnik
3216448bbc PlaceholderParser: implemented round(), digits() and zdigits() macros.
round() rounds to an integer.
This is a popular request, for example #3472

digits(value, num_digits, num_decimals) rounds to num_digits and
	num_decimals, left filled with spaces.
digits(value, num_digits) the same as digits(value, num_digits, 0)
    Neither decimal separator nor any decimals after decimal separator
    are emitted.
zdigits(...) is the same as digits(...) only left filled with zeros.
If the result does not fit num_digits, the result is never trimmed.
2021-10-29 13:36:26 +02:00
Vojtech Bubnik
cf7b6fb19a Extracted MedialAxis code from Geometry.cpp/hpp, moved to its own
files to Geometry/
Moved other Voronoi files to Geometry/
2021-10-27 16:03:04 +02:00
Vojtech Bubnik
497905406b New code for minimum enclosing circle by randomized Welzl algorithm.
Split the circle code from Geometry.cpp/hpp to Geometry/Circle.cpp,hpp
2021-10-27 15:12:29 +02:00
Vojtech Bubnik
743b99d22c Unit tests to the new optimized implementation of
Line::parallel_to() a Line::perpendicular_to().
2021-10-25 12:03:44 +02:00
Vojtech Bubnik
be236eda85 Renamed Geometry::intersect() to Geometry::convex_polygons_intersect()
to convey its true meaning.
2021-10-23 15:29:18 +02:00
tamasmeszaros
5f19539df5 Obvious fixes to stupid warnings 2021-10-21 09:55:12 +02:00
Vojtech Bubnik
7ff76d0768 New ClipperUtils functions: opening(), closing() as an alternative
for offset2() with clear meaning.
New ClipperUtils functions: expand(), shrink() as an alternative
for offset() with clear meaning.
All offset values for the new functions are positive.

Various offsetting ClipperUtils (offset, offset2, offset2_ex) working
over Polygons were marked as unsafe, sometimes producing invalid output
if called for more than one polygon. These functions were reworked
to offset polygons one by one. The new functions working over Polygons
shall work the same way as the old safe ones working over ExPolygons,
but working with Polygons shall be computationally more efficient.

Improvements in FDM support generator:
1) For both grid and snug supports: Don't filter out supports for which
   the contacts are completely reduced by support / object XY separation.
2) Rounding / merging of supports using the closing radius parameter is
   now smoother, it does not produce sharp corners.
3) Snug supports: When calculating support interfaces, expand the projected
   support contact areas to produce wider, printable and more stable interfaces.
4) Don't reduce support interfaces for snug supports for steep overhangs,
   that would normally not need them. Snug supports often produce very
   narrow support interface regions and turning them off makes the support
   interfaces disappear.
2021-10-14 09:11:31 +02:00
tamasmeszaros
4cc1b2740d Don't report intersection if two polygons are only touching. 2021-10-04 14:16:13 +02:00
tamasmeszaros
9fce0ce3a6 Fix compile issues and overlapping polygon fails 2021-10-01 18:27:37 +02:00
Lukas Matena
476b48ed11 Revert "Merge branch 'tm_convex_intersect_rotcalip'"
This reverts commit 627d8bcaef, reversing
changes made to 66d4462724.

The change breaks build on mac
2021-09-30 16:49:00 +02:00
tamasmeszaros
234f062ad4 Fast convex polygon intersection test with rotating calipers 2021-09-30 15:49:12 +02:00
Vojtech Bubnik
6c37955d75 Moved a commented out test for DynamicPrintConfig serialization
/ deserialization into a living unit test.
2021-09-24 11:32:15 +02:00
Vojtech Bubnik
8a2a9dba2f Eradicated admesh from TriangleMesh:
TriangleMesh newly only holds indexed_triangle_set and
TriangleMeshStats. TriangleMeshStats contains an excerpt of stl_stats.
TriangleMeshStats are updated when initializing with indexed_triangle_set.

Admesh triangle mesh fixing is newly only used when loading an STL.
AMF / 3MF / OBJ file formats are already indexed triangle sets, thus
they are no more converted to admesh stl_file format, nor fixed
through admesh repair machinery. When importing AMF / 3MF / OBJ files,
volume is calculated and if negative, all faces are flipped. Also
a bounding box and number of open edges is calculated.

Implemented its_number_of_patches(), its_num_open_edges()
Optimized its_split(), its_is_splittable() using a visitor pattern.

Reworked QHull integration into TriangleMesh:
    1) Face normals were not right.
    2) Indexed triangle set is newly emitted instead of duplicating
       vertices for each face.

Fixed cut_mesh(): Orient the triangulated faces correctly.
2021-09-20 17:12:22 +02:00
Vojtech Bubnik
58d8ab3dea Removed the PRUS format parser. WIP: admesh eradication:
stl_stats are newly only accessed by TriangleMesh::stats(),
most of the direct access to TriangleMesh::stl is gone with the exception
of parsing input files (3MF, AMF, obj).
2021-09-14 11:58:14 +02:00
Vojtech Bubnik
ec976cbe05 Fixed unit tests after cab71073a1 2021-09-13 15:45:33 +02:00
Lukáš Hejl
e520454c3e Fixed unit tests after the previous commit. 2021-09-11 00:54:30 +02:00
Filip Sykala
d45ab1c484 Fix trouble case test 2021-09-02 11:17:07 +02:00
Filip Sykala
25feacfd95 FIX Creation of non volume place in mode during simplification 2021-09-01 19:15:16 +02:00
Filip Sykala
c04856e049 Extend simplify test to chack distance of each triangle center and each vertices. Both simplify to origin and vice versa 2021-08-16 18:04:38 +02:00
Filip Sykala
b90ca142a5 Merge branch 'master' into fs_QuadricEdgeCollapse 2021-08-16 11:56:56 +02:00
Vojtech Bubnik
965c2f2c55 Improved error reporting when importing various configuration files:
1) Slic3r::RuntimeError was replaced with ConfigurationError,
   all exceptions thrown by the configuration layer are derived
   from ConfigurationError.
2) When parsing configuration files, ConfigurationError is catched and
   rethrown extended with the file name being parsed.
2021-08-13 13:37:24 +02:00
Filip Sykala
ef5c94f90a Fix: prevent degeneration of model during simplification 2021-08-06 15:11:20 +02:00
Filip Sykala
6bcc576b5f truncate model name 2021-07-21 08:34:43 +02:00
Filip Sykala
25a4887075 QEC: When collapsing edge flip normal than check other edges in triangle
Quadric is calculated with double precission of normal
Fix calculation of normal for changed triangles
2021-07-19 15:46:41 +02:00
Filip Sykala
86a3fd00a5 Merge branch 'master' into fs_QuadricEdgeCollapse 2021-07-19 09:18:55 +02:00
Filip Sykala
af526c54f4 Add simplification GUI 2021-07-19 09:17:50 +02:00
tamasmeszaros
db782b01a5 Fix build on gcc8 2021-07-16 16:40:59 +02:00
Filip Sykala
aca93a7ced Merge branch 'master' into fs_QuadricEdgeCollapse 2021-07-09 14:14:54 +02:00
Vojtech Bubnik
3a9857e493 Our friendly GCC does not consider std::pair<int, int> trivially
copiable either, while everybody else does. Shame on GCC.
2021-07-09 14:05:30 +02:00
Vojtech Bubnik
d8a0b11157 GCC does not consider std::pair<std::pair<...>, ...> to be trivially
copiable, thus fixing the unit tests with a custom trivially
copyable type.
2021-07-09 13:58:54 +02:00
Filip Sykala
b2238834fb Merge branch 'master' into fs_QuadricEdgeCollapse 2021-07-09 13:40:58 +02:00
Vojtech Bubnik
e4fd6a828f 1) Fixed a significant bug in MutablePriorityQueue when setting
the indices allowing rescheduling of values in the middle of the queue.
2) Implemented a cache friendly variant - MutableSkipHeapPriorityQueue
   based on
   https://playfulprogramming.blogspot.com/2015/08/cache-optimizing-priority-queue.html
   https://github.com/rollbear/prio_queue/blob/master/prio_queue.hpp
2021-07-09 12:53:29 +02:00
Filip Sykala
2c0b89e4a7 FIX Simplify test 2021-07-09 10:31:05 +02:00
Filip Sykala
c53c958cdd Merge branch 'master' into fs_QuadricEdgeCollapse 2021-07-09 09:10:05 +02:00
Filip Sykala
e26bffadd8 Add throw_on_cancel and statusfn into QEC 2021-07-09 09:09:52 +02:00
Vojtech Bubnik
60768d3248 Updated the Catch2 framework from v2.13.3 to v2.13.6.
Fixes Fix build error with non-const MINSIGSTKSZ. #6518
2021-07-08 16:55:59 +02:00
Filip Sykala
35a906139e Extend test with checking simplified model distance to original model 2021-07-08 08:33:06 +02:00
Filip Sykala
ed9152d004 Merge branch 'master' into fs_QuadricEdgeCollapse 2021-07-07 16:52:10 +02:00
Vojtech Bubnik
0f3cabb5d9 Support for forward compatibility of configurations, user and system
config bundles, project files (3MFs, AMFs). When loading these files,
the caller may decide whether to substitute some of the configuration
values the current PrusaSlicer version does not understand with
some reasonable default value, and whether to report it. If substitution
is disabled, an exception is being thrown as before this commit.
If substitution is enabled, list of substitutions is returned by the
API to be presented to the user. This allows us to introduce for example
new firmware flavor key in PrusaSlicer 2.4 while letting PrusaSlicer
2.3.2 to fall back to some default and to report it to the user.

When slicing from command line, substutions are performed by default
and reported into the console, however substitutions may be either
disabled or made silent with the new "config-compatibility" command
line option.

Substitute enums and bools only.  Allow booleans to be parsed as
    true: "1", "enabled", "on" case insensitive
    false: "0", "disabled", "off" case insensitive
This will allow us in the future for example to switch the draft_shield
boolean to an enum with the following values: "disabled" / "enabled" / "limited".

Added "enum_bitmask.hpp" - support for type safe sets of options.
See for example PresetBundle::load_configbundle(...
LoadConfigBundleAttributes flags) for an example of intended usage.

WIP: GUI for reporting the list of config substitutions needs to be
implemented by @YuSanka.
2021-06-27 16:57:05 +02:00
Filip Sykala
7c13cfa1d9 Add test checking diference in volume before/after simplification
FIX warnings
..\src\libslic3r\QuadricEdgeCollapse.cpp(173): warning C4056: overflow in floating-point constant arithmetic
..\src\libslic3r\QuadricEdgeCollapse.cpp(232): warning C4056: overflow in floating-point constant arithmetic
2021-06-22 09:41:38 +02:00
Filip Sykala
e3cdeda673 Add quadric edge collapse 2021-06-22 09:21:16 +02:00
tamasmeszaros
c4507842a0 Add new (winner) neighbor index based on measurements 2021-06-08 10:34:32 +02:00
tamasmeszaros
c8be2cdceb Added measuring sandbox for neighbors index creation 2021-06-08 10:34:32 +02:00
tamasmeszaros
c542e6e14b Corrected mesh split implementation 2021-06-08 10:28:23 +02:00
tamasmeszaros
8fdb0fddc0 Get rid of Contour3D 2021-06-08 10:28:23 +02:00
tamasmeszaros
e6f97358bc Refactored hollowing backend to use indexed_triangle_mesh 2021-06-08 10:28:23 +02:00
tamasmeszaros
1009f78862 SLA backend refactored, except Hollowing 2021-06-08 10:27:35 +02:00
Lukas Matena
6b6b086948 Fixed tests and windows build 2021-05-24 12:20:29 +02:00
enricoturri1966
9da87d8e0f Code cleanup 2021-05-24 10:03:48 +02:00
enricoturri1966
ca9fad002c 3rd attempt to fix unit test for 2D convex hull of sinking object on RasperryPi 2021-05-24 08:54:08 +02:00
enricoturri1966
dfa85c2c37 Another attempt to fix unit test for 2D convex hull of sinking object on RasperryPi 2021-05-21 15:37:25 +02:00
enricoturri1966
49f29e8353 Added debug output to help fixing unit test for 2D convex hull of sinking object on RasperryPi 2021-05-21 11:56:10 +02:00
enricoturri1966
90be278d98 Attempt to fix unit test for 2D convex hull of sinking object on RasperryPi 2021-05-21 10:14:13 +02:00
enricoturri1966
f0ef5e409d Added unit test for calculation of 2D convex hull of sinking object 2021-05-20 12:53:47 +02:00
Vojtech Bubnik
3481898d4d Fixed missing include 2021-05-18 16:15:54 +02:00
Vojtech Bubnik
70b4915f9c TriangleMeshSlicer: Got rid of admesh! 2021-05-18 15:05:30 +02:00
Vojtech Bubnik
308d6b7809 WIP: Reworked slicing
1) Slicing code moved to TriangleMeshSlicer.cpp,hpp from TriangleMesh.cpp,hpp
2) Refactored to use as little as possible of admesh.
2021-05-17 20:25:59 +02:00
Vojtech Bubnik
52b3c655ff Fixed Polygon::centroid()
Ported Polygon unit tests from Perl to C++.
2021-05-07 11:42:21 +02:00
Vojtech Bubnik
f16d4953be Removing offset2 from Perl bindings and other minor cleanup. 2021-05-06 14:29:20 +02:00
Vojtech Bubnik
a2de09e11e Fixing unit tests. 2021-05-05 13:19:01 +02:00
Vojtech Bubnik
09a80d954c Further rework of ClipperUtils: Replaced many to_polygons() /
to_expolygons() calls with templated ClipperUtils variants to avoid
memory allocation and copying.
2021-05-03 11:39:53 +02:00
Vojtech Bubnik
9f4e9da5c6 Merge branch 'tm_vb_clipper_eigen' 2021-04-23 11:44:25 +02:00
Vojtech Bubnik
8d0950ce12 Convincing ClipperLib to use Slic3r's own Point type internally. 2021-04-21 20:15:49 +02:00
tamasmeszaros
949b0e63e8 Fix integer overflows in libnest2d tests 2021-04-21 16:08:38 +02:00
tamasmeszaros
ad19ab219d New custom backend for libnest2d using libslic3r types
Adapted to new clipper->eigen mod
2021-04-21 16:02:25 +02:00
Vojtech Bubnik
542d95a593 Fixing unit tests 2021-04-21 15:31:06 +02:00
Vojtech Bubnik
ba94fa4867 Fixed unit tests. 2021-04-21 13:30:32 +02:00
Vojtech Bubnik
7112ac61b6 Replacing ClipperLib::IntPoint with Eigen point as a first step to
make the ClipperLib paths and polygons compatible with Slic3r paths
and polygons without conversions and memory allocations.
2021-04-14 09:22:51 +02:00
tamasmeszaros
41a0e270ac Fix integer overflows in libnest2d tests 2021-04-14 08:51:54 +02:00
tamasmeszaros
f3e3aabec7 Least supports optimization revived.
Fix missing include on Win32


Cleanup benchmarking code
2021-04-07 12:51:02 +02:00
tamasmeszaros
4eb13a407f Extend execution framework with convenience functions 2021-04-07 12:51:02 +02:00
Lukáš Hejl
dd4b26ba25 Fix of 7bd412a2ca 2021-04-05 20:32:41 +02:00
Lukáš Hejl
7bd412a2ca A few test cases for Voronoi diagrams.
A few test cases collected from multi-material segmentation. All new test cases are suppressed not to fail a building process.
2021-04-05 16:47:00 +02:00
tamasmeszaros
f117d02750 Back-porting improvements for libnest2d 2021-03-31 09:36:54 +02:00
Vojtech Bubnik
ba5e8860cb Fixing some compilation warnings 2021-03-15 10:36:03 +01:00
Vojtech Bubnik
adcbe4347c Fixed unit tests. 2021-03-15 09:55:56 +01:00
Vojtech Bubnik
8e27e355c2 Fixing unit tests. 2021-03-15 09:55:56 +01:00
Vojtech Bubnik
ceea9de8b8 WIP: Refactored bridging flow from normal flow, new config value
'thick_bridges' to switch between the Slic3r vs. S3D/Cura/Ideamaker
way of printing 1st object layer over supports.
Simplified the PresetHints.
2021-03-15 09:55:56 +01:00
tamasmeszaros
33d6655f26 Clean up hollowing test
Needs rethinking anyway
2021-03-08 17:38:10 +01:00
tamasmeszaros
82954ba715 Group hollowing result (including grid) into one struct 2021-03-08 17:38:10 +01:00
Vojtech Bubnik
5f5de1c812 Follow-up to 5276bd98d7:
WIP: MutablePolygon - linked list based polygon implementation
allowing rapid insertion and removal of points.
WIP: porting smooth_outward() from Cura.
2021-03-03 15:04:26 +01:00
Vojtech Bubnik
5276bd98d7 WIP: MutablePolygon - linked list based polygon implementation
allowing rapid insertion and removal of points.
WIP: porting smooth_outward() from Cura.
2021-03-01 18:41:46 +01:00
Vojtech Bubnik
db2d78ff21 Reduction on compiler warnings, mainly on MSVC.
Fix of the new gap_fill_enable flag: Take it into account when comparing
regions.
2021-02-10 17:29:07 +01:00
Vojtech Bubnik
5449e6c549 Fixing some compiler warnings on Linux 2021-02-08 11:58:03 +01:00
Vojtech Bubnik
73c9f939e0 Squash merge of lh_brim_rework,
brim separated to Brim.cpp,hpp
Refactored accessors to PrintObjectPtrs, PrintRegionPtrs, LayerPtrs,
SupportLayerPtrs for const correctness.
2021-02-03 15:12:53 +01:00
Vojtech Bubnik
a116914fce WIP VoronoiOffset: Squash merge of vb_voronoi_offset
Working contour offsetting,
skeleton_edges_rough() to detect "important" skeleton edges.
Radius of an inscribed circle along the "important" skeleton edges
changes slowly, therefore these "important" skeleton edges signify
oblong regions possibly needing a gap fill.
2021-01-29 16:34:22 +01:00
Lukas Matena
dc4bdad84a Fixed some more GCC warnings 2021-01-29 15:17:03 +01:00
Vojtech Bubnik
e78ad6ffa9 Fixing unit tests for supports. After "dont_support_bridges" was fixed
for perimeters, no support was rightfully generated for a preset
using a default "dont_support_bridges" = off.
2020-12-11 17:57:49 +01:00
Vojtech Bubnik
bd79036d13 Replaced all "long long" types with int64_t
Replaced all "unsigned long long" types with uint64_t.
These "new" types better communicate their meaning and they are
guaranteed to behave the same on all platforms & compilers.
2020-12-10 08:40:15 +01:00
Vojtech Bubnik
9f77335d8a Updated Catch2 to v2.13.3 to support compilation on OSX11 / ARM 2020-12-01 16:48:59 +01:00
Vojtech Bubnik
aa6ddfec85 Added functions to export raw image data to PNG for debugging purposes.
Renamed PNGRead.cpp/hpp to PNGReadWrite.cpp,hpp
EdgeGrid: Resurrected debugging output to PNG.
2020-11-26 09:01:44 +01:00
tamasmeszaros
0a932ebfe3 Enable http digest authentication for CURL 2020-11-25 13:58:03 +01:00
Vojtech Bubnik
e77fc43159 Merge remote-tracking branch 'remotes/origin/master' into lh_adaptive_infill_hooks 2020-11-16 10:54:19 +01:00
enricoturri1966
8c8ad70c58 ENABLE_GCODE_VIEWER set as default in fff_print test and PrusaSlicer.cpp 2020-11-12 15:01:59 +01:00
Vojtech Bubnik
239d588c5d 1) Implemented anchoring of infill lines to perimeters with length
limited anchors, while before a full perimeter segment was always
   taken if possible.
2) Adapted the line infills (grid, stars, triangles, cubic) to 1).
   This also solves a long standing issue of these infills producing
   anchors for each sweep direction independently, thus possibly
   overlapping and overextruding, which was quite detrimental
   in narrow areas.
3) Refactored cubic adaptive infill anchroing algorithm
   for performance and clarity.
2020-11-05 17:32:40 +01:00
Vojtech Bubnik
3cfccf1a5a Fixed unit tests broken with 3502f256fa 2020-10-29 12:39:03 +01:00
tamasmeszaros
2f422f5dbe Fix sla tests on mac 2020-10-15 13:50:05 +02:00