├── .github ├── CONTRIBUTING.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── Build.PL ├── LICENSE ├── README.md ├── appveyor.yml ├── doc └── How_to_build_Slic3r.txt ├── lib ├── Slic3r.pm └── Slic3r │ ├── Config.pm │ ├── ExPolygon.pm │ ├── ExtrusionLoop.pm │ ├── ExtrusionPath.pm │ ├── Flow.pm │ ├── GCode │ ├── ArcFitting.pm │ ├── MotionPlanner.pm │ ├── PressureRegulator.pm │ ├── Reader.pm │ └── VibrationLimit.pm │ ├── GUI.pm │ ├── GUI │ ├── 2DBed.pm │ ├── 3DScene.pm │ ├── AboutDialog.pm │ ├── BedShapeDialog.pm │ ├── BonjourBrowser.pm │ ├── ColorScheme.pm │ ├── ConfigWizard.pm │ ├── Controller.pm │ ├── Controller │ │ ├── ManualControlDialog.pm │ │ └── PrinterPanel.pm │ ├── MainFrame.pm │ ├── Notifier.pm │ ├── OptionsGroup.pm │ ├── OptionsGroup │ │ └── Field.pm │ ├── Plater.pm │ ├── Plater │ │ ├── 2D.pm │ │ ├── 2DToolpaths.pm │ │ ├── 3D.pm │ │ ├── 3DPreview.pm │ │ ├── LambdaObjectDialog.pm │ │ ├── ObjectCutDialog.pm │ │ ├── ObjectPartsPanel.pm │ │ ├── ObjectSettingsDialog.pm │ │ ├── OverrideSettingsPanel.pm │ │ └── SplineControl.pm │ ├── Preferences.pm │ ├── Preset.pm │ ├── PresetEditor.pm │ ├── PresetEditorDialog.pm │ ├── ProgressStatusBar.pm │ ├── Projector.pm │ └── SLAPrintOptions.pm │ ├── Geometry.pm │ ├── Geometry │ └── Clipper.pm │ ├── Layer.pm │ ├── Line.pm │ ├── Model.pm │ ├── Point.pm │ ├── Polygon.pm │ ├── Polyline.pm │ ├── Print.pm │ ├── Print │ ├── GCode.pm │ ├── Object.pm │ ├── Simple.pm │ ├── State.pm │ └── SupportMaterial.pm │ ├── SVG.pm │ ├── Surface.pm │ ├── Test.pm │ └── Test │ └── SectionCut.pm ├── package ├── common │ ├── coreperl │ ├── shell.cpp │ └── util.sh ├── deploy │ ├── bintray.sh │ ├── sftp-symlink.sh │ ├── sftp.sh │ ├── slic3r-upload.ppk.enc │ ├── slic3r-upload.rsa.enc │ └── winscp.ps1 ├── linux │ ├── appimage.sh │ ├── build_shell.mk │ ├── libpaths.appimage.txt │ ├── libpaths.txt │ ├── make_archive.sh │ ├── slic3r.desktop.in │ ├── startup_script.sh │ ├── travis-decrypt-key │ └── travis-setup.sh ├── osx │ ├── make_dmg.sh │ ├── plist.sh │ └── startup_script.sh └── win │ ├── appveyor_buildscript.ps1 │ ├── appveyor_deploy.ps1 │ ├── appveyor_preinstall.ps1 │ ├── compile_wrapper.ps1 │ ├── package_win32.ps1 │ ├── slic3r.exe.manifest │ └── slic3r.rc ├── share └── locale │ └── ja │ └── slic3r.mo ├── slic3r.pl ├── src ├── CMakeLists.txt ├── slic3r.cpp ├── standalone │ └── config.h ├── utils │ └── extrude-tin.cpp └── windows-build.txt ├── t ├── adaptive_slicing.t ├── adaptive_width.t ├── angles.t ├── arcs.t ├── avoid_crossing_perimeters.t ├── bridges.t ├── clean_polylines.t ├── clipper.t ├── collinear.t ├── combineinfill.t ├── config.t ├── cooling.t ├── custom_gcode.t ├── fill.t ├── flow.t ├── gaps.t ├── gcode.t ├── geometry.t ├── layers.t ├── loops.t ├── multi.t ├── perimeters.t ├── polyclip.t ├── pressure.t ├── print.t ├── retraction.t ├── shells.t ├── skirt_brim.t ├── slice.t ├── speed.t ├── support.t ├── svg.t ├── thin.t ├── threads.t └── vibrationlimit.t ├── utils ├── amf-to-stl.pl ├── config-bundle-to-config.pl ├── dump-stl.pl ├── estimate-gcode-time.pl ├── gcode_sectioncut.pl ├── modifier_helpers │ ├── layer_generator.jscad │ └── solid_layers.scad ├── pdf-slices.pl ├── post-processing │ ├── decimate.pl │ ├── fan_kickstart.py │ ├── filament-weight.pl │ ├── flowrate.pl │ ├── prowl-notification.pl │ ├── strip-toolchange.pl │ └── z-every-line.pl ├── send-gcode.pl ├── split_stl.pl ├── stl-to-amf.pl ├── view-mesh.pl ├── view-toolpaths.pl ├── wireframe.pl └── zsh │ ├── README.markdown │ └── functions │ └── _slic3r ├── var ├── Slic3r.icns ├── Slic3r.ico ├── Slic3r.png ├── Slic3r_128px.png ├── Slic3r_192px.png ├── Slic3r_192px_transparent.png ├── add.png ├── application_view_tile.png ├── arrow_down.png ├── arrow_in.png ├── arrow_left.png ├── arrow_out.png ├── arrow_redo.png ├── arrow_refresh.png ├── arrow_right.png ├── arrow_rotate_anticlockwise.png ├── arrow_rotate_clockwise.png ├── arrow_undo.png ├── arrow_up.png ├── box.png ├── brick.png ├── brick_add.png ├── brick_delete.png ├── brick_go.png ├── bricks.png ├── building.png ├── bullet_black.png ├── bullet_blue.png ├── bullet_green.png ├── bullet_red.png ├── bullet_white.png ├── cog.png ├── cog_go.png ├── control_pause.png ├── control_pause_blue.png ├── control_play.png ├── control_play_blue.png ├── control_stop.png ├── control_stop_blue.png ├── cross.png ├── delete.png ├── disk.png ├── error.png ├── film.png ├── funnel.png ├── hourglass.png ├── house.png ├── infill.png ├── joystick.png ├── layers.png ├── lorry_add.png ├── lorry_go.png ├── lorry_import.png ├── map_add.png ├── note.png ├── package.png ├── package_green.png ├── page_white_go.png ├── plugin.png ├── plugin_add.png ├── plugin_go.png ├── printer_empty.png ├── script.png ├── shape_flip_horizontal.png ├── shape_handles.png ├── shape_ungroup.png ├── spool.png ├── tag_blue.png ├── textfield.png ├── tick.png ├── time.png ├── variable_layer_height.png ├── wand.png ├── wrench.png ├── zoom.png ├── zoom_in.png └── zoom_out.png └── xs ├── Build.PL ├── MANIFEST ├── MANIFEST.SKIP ├── lib └── Slic3r │ └── XS.pm ├── libslic3r.doxygen ├── src ├── BSpline │ ├── BSpline.cpp │ ├── BSpline.h │ ├── BandedMatrix.h │ └── COPYRIGHT ├── Zip │ ├── ZipArchive.cpp │ └── ZipArchive.hpp ├── admesh │ ├── connect.c │ ├── normals.c │ ├── portable_endian.h │ ├── shared.c │ ├── stl.h │ ├── stl_io.c │ ├── stlinit.c │ └── util.c ├── boost │ └── nowide │ │ ├── args.hpp │ │ ├── cenv.hpp │ │ ├── config.hpp │ │ ├── convert.hpp │ │ ├── cstdio.hpp │ │ ├── cstdlib.hpp │ │ ├── filebuf.hpp │ │ ├── fstream.hpp │ │ ├── integration │ │ └── filesystem.hpp │ │ ├── iostream.cpp │ │ ├── iostream.hpp │ │ ├── stackstring.hpp │ │ ├── system.hpp │ │ ├── utf8_codecvt.hpp │ │ └── windows.hpp ├── clipper.cpp ├── clipper.hpp ├── expat │ ├── COPYING │ ├── README │ ├── ascii.h │ ├── asciitab.h │ ├── expat.h │ ├── expat_config.h │ ├── expat_external.h │ ├── iasciitab.h │ ├── internal.h │ ├── latin1tab.h │ ├── nametab.h │ ├── utf8tab.h │ ├── xmlparse.c │ ├── xmlrole.c │ ├── xmlrole.h │ ├── xmltok.c │ ├── xmltok.h │ ├── xmltok_impl.h │ ├── xmltok_impl.inc │ └── xmltok_ns.inc ├── exprtk │ └── exprtk.hpp ├── libslic3r │ ├── BoundingBox.cpp │ ├── BoundingBox.hpp │ ├── BridgeDetector.cpp │ ├── BridgeDetector.hpp │ ├── ClipperUtils.cpp │ ├── ClipperUtils.hpp │ ├── ConditionalGCode.cpp │ ├── ConditionalGCode.hpp │ ├── Config.cpp │ ├── Config.hpp │ ├── ExPolygon.cpp │ ├── ExPolygon.hpp │ ├── ExPolygonCollection.cpp │ ├── ExPolygonCollection.hpp │ ├── Extruder.cpp │ ├── Extruder.hpp │ ├── ExtrusionEntity.cpp │ ├── ExtrusionEntity.hpp │ ├── ExtrusionEntityCollection.cpp │ ├── ExtrusionEntityCollection.hpp │ ├── Fill │ │ ├── Fill.cpp │ │ ├── Fill.hpp │ │ ├── Fill3DHoneycomb.cpp │ │ ├── Fill3DHoneycomb.hpp │ │ ├── FillConcentric.cpp │ │ ├── FillConcentric.hpp │ │ ├── FillGyroid.cpp │ │ ├── FillGyroid.hpp │ │ ├── FillHoneycomb.cpp │ │ ├── FillHoneycomb.hpp │ │ ├── FillPlanePath.cpp │ │ ├── FillPlanePath.hpp │ │ ├── FillRectilinear.cpp │ │ └── FillRectilinear.hpp │ ├── Flow.cpp │ ├── Flow.hpp │ ├── GCode.cpp │ ├── GCode.hpp │ ├── GCode │ │ ├── CoolingBuffer.cpp │ │ ├── CoolingBuffer.hpp │ │ ├── SpiralVase.cpp │ │ └── SpiralVase.hpp │ ├── GCodeReader.cpp │ ├── GCodeReader.hpp │ ├── GCodeSender.cpp │ ├── GCodeSender.hpp │ ├── GCodeTimeEstimator.cpp │ ├── GCodeTimeEstimator.hpp │ ├── GCodeWriter.cpp │ ├── GCodeWriter.hpp │ ├── Geometry.cpp │ ├── Geometry.hpp │ ├── IO.cpp │ ├── IO.hpp │ ├── IO │ │ ├── AMF.cpp │ │ ├── TMF.cpp │ │ └── TMF.hpp │ ├── Layer.cpp │ ├── Layer.hpp │ ├── LayerHeightSpline.cpp │ ├── LayerHeightSpline.hpp │ ├── LayerRegion.cpp │ ├── LayerRegionFill.cpp │ ├── Line.cpp │ ├── Line.hpp │ ├── Model.cpp │ ├── Model.hpp │ ├── MotionPlanner.cpp │ ├── MotionPlanner.hpp │ ├── MultiPoint.cpp │ ├── MultiPoint.hpp │ ├── NonplanarFacet.cpp │ ├── NonplanarFacet.hpp │ ├── NonplanarSurface.cpp │ ├── NonplanarSurface.hpp │ ├── PerimeterGenerator.cpp │ ├── PerimeterGenerator.hpp │ ├── PlaceholderParser.cpp │ ├── PlaceholderParser.hpp │ ├── Point.cpp │ ├── Point.hpp │ ├── Polygon.cpp │ ├── Polygon.hpp │ ├── Polyline.cpp │ ├── Polyline.hpp │ ├── PolylineCollection.cpp │ ├── PolylineCollection.hpp │ ├── Print.cpp │ ├── Print.hpp │ ├── PrintConfig.cpp │ ├── PrintConfig.hpp │ ├── PrintObject.cpp │ ├── PrintRegion.cpp │ ├── SLAPrint.cpp │ ├── SLAPrint.hpp │ ├── SVG.cpp │ ├── SVG.hpp │ ├── SlicingAdaptive.cpp │ ├── SlicingAdaptive.hpp │ ├── SupportMaterial.hpp │ ├── Surface.cpp │ ├── Surface.hpp │ ├── SurfaceCollection.cpp │ ├── SurfaceCollection.hpp │ ├── TriangleMesh.cpp │ ├── TriangleMesh.hpp │ ├── libslic3r.h │ ├── utils.cpp │ └── utils.hpp ├── miniz │ └── miniz.h ├── perlglue.cpp ├── poly2tri │ ├── common │ │ ├── shapes.cc │ │ ├── shapes.h │ │ └── utils.h │ ├── poly2tri.h │ └── sweep │ │ ├── advancing_front.cc │ │ ├── advancing_front.h │ │ ├── cdt.cc │ │ ├── cdt.h │ │ ├── sweep.cc │ │ ├── sweep.h │ │ ├── sweep_context.cc │ │ └── sweep_context.h ├── polypartition.cpp ├── polypartition.h ├── ppport.h ├── slic3r │ └── GUI │ │ ├── 3DScene.cpp │ │ ├── 3DScene.hpp │ │ ├── GUI.cpp │ │ └── GUI.hpp ├── tiny_obj_loader.h └── xsinit.h ├── t ├── 01_trianglemesh.t ├── 03_point.t ├── 04_expolygon.t ├── 05_surface.t ├── 06_polygon.t ├── 07_extrusionpath.t ├── 08_extrusionloop.t ├── 09_polyline.t ├── 10_line.t ├── 11_clipper.t ├── 12_extrusionpathcollection.t ├── 13_polylinecollection.t ├── 14_geometry.t ├── 15_config.t ├── 16_flow.t ├── 17_boundingbox.t ├── 18_motionplanner.t ├── 19_model.t ├── 20_print.t ├── 21_gcode.t ├── 22_exception.t ├── 23_3mf.t ├── 24_gcodemath.t ├── inc │ └── 22_config_bad_config_options.ini └── models │ ├── 3mf │ ├── box.3mf │ ├── chess.3mf │ └── gimblekeychain.3mf │ ├── amf │ └── FaceColors.amf.xml │ └── stl │ └── spikey_top.stl └── xsp ├── BoundingBox.xsp ├── BridgeDetector.xsp ├── Clipper.xsp ├── ConditionalGCode.xsp ├── Config.xsp ├── ExPolygon.xsp ├── ExPolygonCollection.xsp ├── Extruder.xsp ├── ExtrusionEntityCollection.xsp ├── ExtrusionLoop.xsp ├── ExtrusionPath.xsp ├── Filler.xsp ├── Flow.xsp ├── GCode.xsp ├── GCodeSender.xsp ├── GCodeTimeEstimator.xsp ├── GCodeWriter.xsp ├── GUI.xsp ├── GUI_3DScene.xsp ├── Geometry.xsp ├── Layer.xsp ├── LayerHeightSpline.xsp ├── Line.xsp ├── Model.xsp ├── MotionPlanner.xsp ├── NonplanarFacet.xsp ├── NonplanarSurface.xsp ├── PerimeterGenerator.xsp ├── PlaceholderParser.xsp ├── Point.xsp ├── Polygon.xsp ├── Polyline.xsp ├── PolylineCollection.xsp ├── Print.xsp ├── SLAPrint.xsp ├── SlicingAdaptive.xsp ├── SupportMaterial.xsp ├── Surface.xsp ├── SurfaceCollection.xsp ├── TriangleMesh.xsp ├── XS.xsp ├── my.map ├── mytype.map └── typemap.xspt /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Version 2 | _Version of Slic3r used goes here_ 3 | 4 | _Use `About->About Slic3r` for release versions._ 5 | 6 | _Do not report Prusa3D Slic3r bugs here without confirming it is a problem on a development release of Slic3r, or your issue will be closed. *Only* use normal Slic3r version IDs._ 7 | 8 | _For -dev versions, use `git describe --tag` or get the hash value for the version you downloaded or `git rev-parse HEAD`_ 9 | 10 | ### Operating system type + version 11 | _What OS are you using, and state any version #s_ 12 | 13 | ### Behavior 14 | * _Describe the problem_ 15 | * _Steps needed to reproduce the problem_ 16 | * _If this is a command-line slicing issue, include the options used_ 17 | * _Expected Results_ 18 | * _Actual Results_ 19 | * _Screenshots from __*Slic3r*__ preview are preferred_ 20 | 21 | _Is this a new feature request?_ 22 | Related guides for writing feature requests: http://meta.stackexchange.com/a/259196 http://nickohrn.com/2013/09/write-great-feature-request-bug-report/ 23 | 24 | 25 | #### STL/Config (.ZIP) where problem occurs 26 | _Upload a zipped copy of an STL and your config (`File -> Export Config`)_ 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | Build 3 | Build.bat 4 | MYMETA.json 5 | MYMETA.yml 6 | _build 7 | blib 8 | xs/buildtmp 9 | *.o 10 | MANIFEST.bak 11 | xs/MANIFEST.bak 12 | xs/assertlib* 13 | .init_bundle.ini 14 | local-lib 15 | package/osx/Slic3r*.app 16 | *.dmg 17 | *.swp 18 | *.swo 19 | svg 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: perl 2 | before_install: 3 | - sh package/linux/travis-decrypt-key 4 | install: 5 | - export BOOST_DIR=$HOME/boost_1_63_0 6 | - export SLIC3R_STATIC=1 7 | - export CXX=g++-4.9 8 | - export CC=g++-4.9 9 | - source $HOME/perl5/perlbrew/etc/bashrc 10 | script: 11 | - bash package/linux/travis-setup.sh 12 | - perlbrew switch slic3r-perl 13 | - perl ./Build.PL 14 | after_success: 15 | - eval $(perl -Mlocal::lib=$TRAVIS_BUILD_DIR/local-lib) 16 | - LD_LIBRARY_PATH=$WXDIR/lib package/linux/make_archive.sh linux-x64 17 | - package/linux/appimage.sh x86_64 18 | - package/deploy/sftp.sh linux ~/slic3r-upload.rsa *.bz2 Slic3r*.AppImage 19 | - package/deploy/sftp-symlink.sh linux ~/slic3r-upload.rsa AppImage Slic3r*.AppImage 20 | - package/deploy/sftp-symlink.sh linux ~/slic3r-upload.rsa tar.bz2 *.bz2 21 | branches: 22 | only: 23 | - master 24 | - xsgui 25 | cache: 26 | apt: true 27 | directories: 28 | - "$HOME/cache" 29 | addons: 30 | apt: 31 | sources: 32 | - ubuntu-toolchain-r-test 33 | packages: 34 | - g++-4.9 35 | - gcc-4.9 36 | - libgtk2.0-0 37 | - libgtk2.0-dev 38 | - freeglut3 39 | ssh_known_hosts: dl.slic3r.org 40 | notifications: 41 | irc: 42 | channels: 43 | - chat.freenode.net#slic3r 44 | on_success: change 45 | on_failure: always 46 | use_notice: true 47 | sudo: required 48 | dist: trusty 49 | env: 50 | matrix: 51 | global: 52 | - secure: eEVRZNMv7FM6jrOU9iAFkDhWxFQ1WtHBEaObImcvtFUxy6vWSt3ehFFeTRouj3uHQAnbvUzziDyvPPm8/95alv5g/du8ML6YzzqKBKfazM0xQ7SF6R2DQL8lfFIp+RSV7T02byEP1f1g7Zva7xH9szIlDcSfU0pXW4KWbkBFMd8= 53 | - secure: gj338h+qHGccTD/VQFmEJkqdg2McIe2pO0iZ4Ae9BvY5vxkIML4BpoYZQXQTqiAOETnUjlcknY9lx0hI/PfkDD9MSJc5BC/3fMYRCu3SgAclEwklWf9vvtodUeT69mtnZuw1zze1nTbExuOw2mepbqFjxKKMl+9l5oCz4O54fXU= 54 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.3.0-{branch}-{build} 2 | image: WMF 5 3 | init: 4 | - ps: 5 | environment: 6 | LDLOADLIBS: -lstdc++ 7 | SLIC3R_STATIC: 1 8 | SLIC3R_VERSION: 1.3.0 9 | BOOST_DIR: C:\dev\boost_1_63_0 10 | WXDIR: C:\dev\wxwidgets 11 | WXSHARED: SHARED=0 12 | FORCE_WX_BUILD: 0 13 | FORCE_BOOST_REINSTALL: 0 14 | ENC_SECRET: 15 | secure: QfeTOSKXz1uFCEACqFKLNw== 16 | UPLOAD_USER: 17 | secure: fYPwnI3p6HNR+eMRJR3JfmyNolFn+Uc0MUn2bBXp9uU= 18 | matrix: 19 | - ARCH: 64bit 20 | - ARCH: 32bit 21 | 22 | install: 23 | - IF DEFINED ENC_SECRET nuget install secure-file -ExcludeVersion 24 | - IF DEFINED ENC_SECRET secure-file\tools\secure-file -decrypt package/deploy/slic3r-upload.ppk.enc -secret %ENC_SECRET% 25 | - ps: "& package/win/appveyor_preinstall.ps1" 26 | cache: 27 | - C:\Users\appveyor\local-lib-64bit.7z 28 | - C:\Users\appveyor\local-lib-32bit.7z 29 | - C:\Users\appveyor\freeglut.64bit.7z 30 | - C:\Users\appveyor\freeglut.32bit.7z 31 | - C:\users\appveyor\strawberry.64bit.msi 32 | - C:\users\appveyor\strawberry.32bit.msi 33 | - C:\Users\appveyor\winscp.zip 34 | - C:\Users\appveyor\extra_perl.7z 35 | - C:\Users\appveyor\wxwidgets-64bit.7z 36 | - C:\Users\appveyor\wxwidgets-32bit.7z 37 | - C:\Users\appveyor\boost.1.63.0.32bit.7z 38 | - C:\Users\appveyor\boost.1.63.0.64bit.7z 39 | build_script: 40 | - ps: "& package/win/appveyor_buildscript.ps1" 41 | artifacts: 42 | - path: .\slic3r*zip 43 | name: slic3r-dev 44 | deploy_script: 45 | - ps: "cd C:/projects/slic3r; & package/win/appveyor_deploy.ps1" 46 | on_success: 47 | - ps: 48 | on_failure: 49 | - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 50 | on_finish: 51 | - ps: 52 | -------------------------------------------------------------------------------- /lib/Slic3r/ExPolygon.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::ExPolygon; 2 | use strict; 3 | use warnings; 4 | 5 | # an ExPolygon is a polygon with holes 6 | 7 | use List::Util qw(first); 8 | use Slic3r::Geometry qw(X Y A B point_in_polygon epsilon scaled_epsilon); 9 | use Slic3r::Geometry::Clipper qw(union_ex diff_pl); 10 | 11 | sub wkt { 12 | my $self = shift; 13 | return sprintf "POLYGON(%s)", 14 | join ',', map "($_)", map { join ',', map "$_->[0] $_->[1]", @$_ } @$self; 15 | } 16 | 17 | sub dump_perl { 18 | my $self = shift; 19 | return sprintf "[%s]", 20 | join ',', map "[$_]", map { join ',', map "[$_->[0],$_->[1]]", @$_ } @$self; 21 | } 22 | 23 | sub offset { 24 | my $self = shift; 25 | return Slic3r::Geometry::Clipper::offset(\@$self, @_); 26 | } 27 | 28 | sub offset_ex { 29 | my $self = shift; 30 | return Slic3r::Geometry::Clipper::offset_ex(\@$self, @_); 31 | } 32 | 33 | sub bounding_box { 34 | my $self = shift; 35 | return $self->contour->bounding_box; 36 | } 37 | 38 | package Slic3r::ExPolygon::Collection; 39 | use Slic3r::Geometry qw(X1 Y1); 40 | 41 | sub size { 42 | my $self = shift; 43 | return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @$self ]) ]; 44 | } 45 | 46 | 1; 47 | -------------------------------------------------------------------------------- /lib/Slic3r/ExtrusionLoop.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::ExtrusionLoop; 2 | use strict; 3 | use warnings; 4 | 5 | use parent qw(Exporter); 6 | 7 | our @EXPORT_OK = qw(EXTRL_ROLE_DEFAULT 8 | EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER EXTRL_ROLE_SKIRT); 9 | our %EXPORT_TAGS = (roles => \@EXPORT_OK); 10 | 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /lib/Slic3r/ExtrusionPath.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::ExtrusionPath; 2 | use strict; 3 | use warnings; 4 | 5 | use parent qw(Exporter); 6 | 7 | our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER 8 | EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_GAPFILL EXTR_ROLE_BRIDGE 9 | EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_SUPPORTMATERIAL_INTERFACE 10 | EXTR_ROLE_NONE); 11 | our %EXPORT_TAGS = (roles => \@EXPORT_OK); 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /lib/Slic3r/Flow.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Flow; 2 | use strict; 3 | use warnings; 4 | 5 | use parent qw(Exporter); 6 | 7 | our @EXPORT_OK = qw(FLOW_ROLE_EXTERNAL_PERIMETER FLOW_ROLE_PERIMETER FLOW_ROLE_INFILL 8 | FLOW_ROLE_SOLID_INFILL 9 | FLOW_ROLE_TOP_SOLID_INFILL FLOW_ROLE_SUPPORT_MATERIAL 10 | FLOW_ROLE_SUPPORT_MATERIAL_INTERFACE); 11 | our %EXPORT_TAGS = (roles => \@EXPORT_OK); 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /lib/Slic3r/GCode/VibrationLimit.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::GCode::VibrationLimit; 2 | use Moo; 3 | 4 | extends 'Slic3r::GCode::Reader'; 5 | 6 | has '_min_time' => (is => 'lazy'); 7 | has '_last_dir' => (is => 'ro', default => sub { [0,0] }); 8 | has '_dir_time' => (is => 'ro', default => sub { [0,0] }); 9 | 10 | # inspired by http://hydraraptor.blogspot.it/2010/12/frequency-limit.html 11 | 12 | use List::Util qw(max); 13 | 14 | sub _build__min_time { 15 | my ($self) = @_; 16 | return 1 / ($self->config->vibration_limit * 60); # in minutes 17 | } 18 | 19 | sub process { 20 | my $self = shift; 21 | my ($gcode) = @_; 22 | 23 | my $new_gcode = ""; 24 | $self->parse($gcode, sub { 25 | my ($reader, $cmd, $args, $info) = @_; 26 | 27 | if ($cmd eq 'G1' && $info->{dist_XY} > 0) { 28 | my $point = Slic3r::Pointf->new($args->{X} // $reader->X, $args->{Y} // $reader->Y); 29 | my @dir = ( 30 | ($point->x <=> $reader->X), 31 | ($point->y <=> $reader->Y), #$ 32 | ); 33 | my $time = $info->{dist_XY} / ($args->{F} // $reader->F); # in minutes 34 | 35 | if ($time > 0) { 36 | my @pause = (); 37 | foreach my $axis (0..$#dir) { 38 | if ($dir[$axis] != 0 && $self->_last_dir->[$axis] != $dir[$axis]) { 39 | if ($self->_last_dir->[$axis] != 0) { 40 | # this axis is changing direction: check whether we need to pause 41 | if ($self->_dir_time->[$axis] < $self->_min_time) { 42 | push @pause, ($self->_min_time - $self->_dir_time->[$axis]); 43 | } 44 | } 45 | $self->_last_dir->[$axis] = $dir[$axis]; 46 | $self->_dir_time->[$axis] = 0; 47 | } 48 | $self->_dir_time->[$axis] += $time; 49 | } 50 | 51 | if (@pause) { 52 | $new_gcode .= sprintf "G4 P%d\n", max(@pause) * 60 * 1000; 53 | } 54 | } 55 | } 56 | 57 | $new_gcode .= $info->{raw} . "\n"; 58 | }); 59 | 60 | return $new_gcode; 61 | } 62 | 63 | 1; 64 | -------------------------------------------------------------------------------- /lib/Slic3r/GUI/BonjourBrowser.pm: -------------------------------------------------------------------------------- 1 | # A tiny dialog to select an OctoPrint device to print to. 2 | 3 | package Slic3r::GUI::BonjourBrowser; 4 | use strict; 5 | use warnings; 6 | use utf8; 7 | 8 | use Wx qw(:dialog :id :misc :sizer :choicebook wxTAB_TRAVERSAL); 9 | use Wx::Event qw(EVT_CLOSE); 10 | use base 'Wx::Dialog'; 11 | 12 | sub new { 13 | my $class = shift; 14 | my ($parent, $devices) = @_; 15 | my $self = $class->SUPER::new($parent, -1, "Device Browser", wxDefaultPosition, [350,700], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); 16 | 17 | $self->{devices} = $devices; 18 | 19 | # label 20 | my $text = Wx::StaticText->new($self, -1, "Choose an OctoPrint device in your network:", wxDefaultPosition, wxDefaultSize); 21 | 22 | # selector 23 | $self->{choice} = my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, wxDefaultSize, 24 | [ map $_->name, @{$self->{devices}} ]); 25 | 26 | my $main_sizer = Wx::BoxSizer->new(wxVERTICAL); 27 | $main_sizer->Add($text, 1, wxEXPAND | wxALL, 10); 28 | $main_sizer->Add($choice, 1, wxEXPAND | wxALL, 10); 29 | $main_sizer->Add($self->CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND); 30 | 31 | $self->SetSizer($main_sizer); 32 | $self->SetMinSize($self->GetSize); 33 | $main_sizer->SetSizeHints($self); 34 | 35 | # needed to actually free memory 36 | EVT_CLOSE($self, sub { 37 | $self->EndModal(wxID_OK); 38 | $self->Destroy; 39 | }); 40 | 41 | return $self; 42 | } 43 | 44 | sub GetValue { 45 | my ($self) = @_; 46 | return $self->{devices}[ $self->{choice}->GetSelection ]->address; 47 | } 48 | sub GetPort { 49 | my ($self) = @_; 50 | return $self->{devices}[ $self->{choice}->GetSelection ]->port; 51 | } 52 | 53 | 1; 54 | -------------------------------------------------------------------------------- /lib/Slic3r/GUI/Notifier.pm: -------------------------------------------------------------------------------- 1 | # Notify about the end of slicing. 2 | # The notifications are sent out using the Growl protocol if installed, and using DBus XWindow protocol. 3 | 4 | package Slic3r::GUI::Notifier; 5 | use Moo; 6 | 7 | has 'growler' => (is => 'rw'); 8 | 9 | my $icon = $Slic3r::var->("Slic3r.png"); 10 | 11 | sub BUILD { 12 | my ($self) = @_; 13 | 14 | if (eval 'use Growl::GNTP; 1') { 15 | # register with growl 16 | eval { 17 | $self->growler(Growl::GNTP->new(AppName => 'Slic3r', AppIcon => $icon)); 18 | $self->growler->register([{Name => 'SKEIN_DONE', DisplayName => 'Slicing Done'}]); 19 | }; 20 | # if register() fails (for example because of a timeout), disable growler at all 21 | $self->growler(undef) if $@; 22 | } 23 | } 24 | 25 | sub notify { 26 | my ($self, $message) = @_; 27 | my $title = 'Slicing Done!'; 28 | 29 | eval { 30 | $self->growler->notify(Event => 'SKEIN_DONE', Title => $title, Message => $message) 31 | if $self->growler; 32 | }; 33 | # Net::DBus is broken in multithreaded environment 34 | if (0 && eval 'use Net::DBus; 1') { 35 | eval { 36 | my $session = Net::DBus->session; 37 | my $serv = $session->get_service('org.freedesktop.Notifications'); 38 | my $notifier = $serv->get_object('/org/freedesktop/Notifications', 39 | 'org.freedesktop.Notifications'); 40 | $notifier->Notify('Slic3r', 0, $icon, $title, $message, [], {}, -1); 41 | undef $Net::DBus::bus_session; 42 | }; 43 | } 44 | } 45 | 46 | 1; 47 | -------------------------------------------------------------------------------- /lib/Slic3r/GUI/PresetEditorDialog.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::GUI::PresetEditorDialog; 2 | use strict; 3 | use warnings; 4 | use Wx qw(:dialog :id :misc :sizer :button :icon wxTheApp WXK_ESCAPE); 5 | use Wx::Event qw(EVT_CLOSE EVT_CHAR_HOOK); 6 | use base qw(Wx::Dialog Class::Accessor); 7 | use utf8; 8 | 9 | __PACKAGE__->mk_accessors(qw(preset_editor)); 10 | 11 | sub new { 12 | my ($class, $parent) = @_; 13 | my $self = $class->SUPER::new($parent, -1, "Settings", wxDefaultPosition, [900,500], 14 | wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxDIALOG_EX_METAL); 15 | 16 | $self->preset_editor($self->preset_editor_class->new($self)); 17 | $self->SetTitle($self->preset_editor->title); 18 | 19 | my $sizer = Wx::BoxSizer->new(wxVERTICAL); 20 | $sizer->Add($self->preset_editor, 1, wxEXPAND); 21 | 22 | $self->SetSizer($sizer); 23 | #$sizer->SetSizeHints($self); 24 | 25 | if (0) { 26 | my $buttons = $self->CreateStdDialogButtonSizer(wxCLOSE); 27 | $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10); 28 | } 29 | 30 | wxTheApp->restore_window_pos($self, "preset_editor"); 31 | 32 | EVT_CLOSE($self, sub { 33 | my (undef, $event) = @_; 34 | 35 | # save window size 36 | wxTheApp->save_window_pos($self, "preset_editor"); 37 | 38 | # propagate event 39 | $event->Skip; 40 | }); 41 | 42 | EVT_CHAR_HOOK($self, sub { 43 | my (undef, $event) = @_; 44 | 45 | if ($event->GetKeyCode == WXK_ESCAPE) { 46 | $self->Close; 47 | } else { 48 | $event->Skip; 49 | } 50 | }); 51 | 52 | return $self; 53 | } 54 | 55 | 56 | package Slic3r::GUI::PresetEditorDialog::Printer; 57 | use base qw(Slic3r::GUI::PresetEditorDialog); 58 | 59 | sub preset_editor_class { "Slic3r::GUI::PresetEditor::Printer" } 60 | 61 | 62 | package Slic3r::GUI::PresetEditorDialog::Filament; 63 | use base qw(Slic3r::GUI::PresetEditorDialog); 64 | 65 | sub preset_editor_class { "Slic3r::GUI::PresetEditor::Filament" } 66 | 67 | 68 | package Slic3r::GUI::PresetEditorDialog::Print; 69 | use base qw(Slic3r::GUI::PresetEditorDialog); 70 | 71 | sub preset_editor_class { "Slic3r::GUI::PresetEditor::Print" } 72 | 73 | 1; 74 | -------------------------------------------------------------------------------- /lib/Slic3r/Geometry/Clipper.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Geometry::Clipper; 2 | use strict; 3 | use warnings; 4 | 5 | require Exporter; 6 | our @ISA = qw(Exporter); 7 | our @EXPORT_OK = qw(offset offset_ex 8 | diff_ex diff union_ex intersection_ex JT_ROUND JT_MITER 9 | JT_SQUARE is_counter_clockwise union_pt offset2 offset2_ex 10 | intersection intersection_pl diff_pl union CLIPPER_OFFSET_SCALE 11 | union_pt_chained intersection_ppl); 12 | 13 | 1; 14 | -------------------------------------------------------------------------------- /lib/Slic3r/Layer.pm: -------------------------------------------------------------------------------- 1 | # Extends the C++ class Slic3r::Layer. 2 | 3 | package Slic3r::Layer; 4 | use strict; 5 | use warnings; 6 | 7 | # the following two were previously generated by Moo 8 | sub print { 9 | my $self = shift; 10 | return $self->object->print; 11 | } 12 | 13 | sub config { 14 | my $self = shift; 15 | return $self->object->config; 16 | } 17 | 18 | sub region { 19 | my $self = shift; 20 | my ($region_id) = @_; 21 | 22 | while ($self->region_count <= $region_id) { 23 | $self->add_region($self->object->print->get_region($self->region_count)); 24 | } 25 | 26 | return $self->get_region($region_id); 27 | } 28 | 29 | sub regions { 30 | my ($self) = @_; 31 | return [ map $self->get_region($_), 0..($self->region_count-1) ]; 32 | } 33 | 34 | package Slic3r::Layer::Support; 35 | our @ISA = qw(Slic3r::Layer); 36 | 37 | 1; 38 | -------------------------------------------------------------------------------- /lib/Slic3r/Line.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Line; 2 | use strict; 3 | use warnings; 4 | 5 | # a line is a two-points line 6 | use parent 'Slic3r::Polyline'; 7 | 8 | sub intersection { 9 | my $self = shift; 10 | my ($line, $require_crossing) = @_; 11 | return Slic3r::Geometry::line_intersection($self, $line, $require_crossing); 12 | } 13 | 14 | sub grow { 15 | my $self = shift; 16 | return Slic3r::Polyline->new(@$self)->grow(@_); 17 | } 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /lib/Slic3r/Point.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Point; 2 | use strict; 3 | use warnings; 4 | 5 | sub new_scale { 6 | my $class = shift; 7 | return $class->new(map Slic3r::Geometry::scale($_), @_); 8 | } 9 | 10 | sub dump_perl { 11 | my $self = shift; 12 | return sprintf "[%s,%s]", @$self; 13 | } 14 | 15 | package Slic3r::Point3; 16 | use strict; 17 | use warnings; 18 | 19 | sub new_scale { 20 | my $class = shift; 21 | return $class->new(map Slic3r::Geometry::scale($_), @_); 22 | } 23 | 24 | package Slic3r::Pointf; 25 | use strict; 26 | use warnings; 27 | 28 | sub new_unscale { 29 | my $class = shift; 30 | return $class->new(map Slic3r::Geometry::unscale($_), @_); 31 | } 32 | 33 | package Slic3r::Pointf3; 34 | use strict; 35 | use warnings; 36 | 37 | sub new_unscale { 38 | my $class = shift; 39 | return $class->new(map Slic3r::Geometry::unscale($_), @_); 40 | } 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /lib/Slic3r/Polygon.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Polygon; 2 | use strict; 3 | use warnings; 4 | 5 | # a polygon is a closed polyline. 6 | use parent 'Slic3r::Polyline'; 7 | 8 | use Slic3r::Geometry qw(PI); 9 | 10 | sub grow { 11 | my $self = shift; 12 | return $self->split_at_first_point->grow(@_); 13 | } 14 | 15 | # this method subdivides the polygon segments to that no one of them 16 | # is longer than the length provided 17 | sub subdivide { 18 | my $self = shift; 19 | my ($max_length) = @_; 20 | 21 | my @points = @$self; 22 | push @points, $points[0]; # append first point as this is a polygon 23 | my @new_points = shift @points; 24 | while (@points) { 25 | while ($new_points[-1]->distance_to($points[0]) > $max_length) { 26 | push @new_points, map Slic3r::Point->new(@$_), 27 | Slic3r::Geometry::point_along_segment($new_points[-1], $points[0], $max_length); 28 | } 29 | push @new_points, shift @points; 30 | } 31 | pop @new_points; # remove last point as it coincides with first one 32 | return Slic3r::Polygon->new(@new_points); 33 | } 34 | 35 | 1; -------------------------------------------------------------------------------- /lib/Slic3r/Polyline.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Polyline; 2 | use strict; 3 | use warnings; 4 | 5 | use Slic3r::Geometry qw(X Y); 6 | 7 | sub new_scale { 8 | my $class = shift; 9 | my @points = map { ref($_) eq 'Slic3r::Point' ? $_->pp : $_ } @_; 10 | return $class->new(map [ Slic3r::Geometry::scale($_->[X]), Slic3r::Geometry::scale($_->[Y]) ], @points); 11 | } 12 | 13 | sub dump_perl { 14 | my $self = shift; 15 | return sprintf "[%s]", join ',', map "[$_->[0],$_->[1]]", @$self; 16 | } 17 | 18 | 1; 19 | -------------------------------------------------------------------------------- /lib/Slic3r/Print/State.pm: -------------------------------------------------------------------------------- 1 | # Wraps C++ enums Slic3r::PrintStep and Slic3r::PrintObjectStep 2 | package Slic3r::Print::State; 3 | use strict; 4 | use warnings; 5 | 6 | require Exporter; 7 | our @ISA = qw(Exporter); 8 | our @EXPORT_OK = qw(STEP_LAYERS STEP_SLICE STEP_PERIMETERS STEP_PREPARE_INFILL 9 | STEP_INFILL STEP_SUPPORTMATERIAL STEP_SKIRT STEP_BRIM); 10 | our %EXPORT_TAGS = (steps => \@EXPORT_OK); 11 | 12 | 1; 13 | -------------------------------------------------------------------------------- /lib/Slic3r/Surface.pm: -------------------------------------------------------------------------------- 1 | package Slic3r::Surface; 2 | use strict; 3 | use warnings; 4 | 5 | require Exporter; 6 | our @ISA = qw(Exporter); 7 | our @EXPORT_OK = qw(S_TYPE_TOP S_TYPE_BOTTOM S_TYPE_BOTTOMBRIDGE S_TYPE_INTERNAL S_TYPE_INTERNALSOLID S_TYPE_INTERNALBRIDGE S_TYPE_INTERNALVOID S_TYPE_TOP_NONPLANAR S_TYPE_INTERNALSOLID_NONPLANAR); 8 | our %EXPORT_TAGS = (types => \@EXPORT_OK); 9 | 10 | sub p { 11 | my $self = shift; 12 | return @{$self->polygons}; 13 | } 14 | 15 | 1; 16 | -------------------------------------------------------------------------------- /package/common/coreperl: -------------------------------------------------------------------------------- 1 | # Core perl modules used in Slic3r 2 | attributes 3 | base 4 | bytes 5 | B 6 | POSIX 7 | FindBin 8 | Unicode::Normalize 9 | Tie::Handle 10 | Time::Local 11 | Math::Trig 12 | IO::Socket 13 | Errno 14 | Storable 15 | lib 16 | overload 17 | warnings 18 | local::lib 19 | strict 20 | utf8 21 | parent 22 | -------------------------------------------------------------------------------- /package/deploy/bintray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Prerequistes 3 | # Environment variables: 4 | # BINTRAY_API_KEY - Working API key 5 | # BINTRAY_API_USER - Bintray username. 6 | # Run this from the repository root (required to get slic3r version) 7 | 8 | source $(dirname $0)/common/util.sh 9 | SLIC3R_VERSION=$(grep "VERSION" xs/src/libslic3r/libslic3r.h | awk -F\" '{print $2}') 10 | get_commit 11 | set_build_id 12 | set_branch 13 | set_pr_id 14 | if [ "$current_branch" == "master" ] && [ -z ${PR_ID} ]; then 15 | # If building master, goes in slic3r_dev or slic3r, depending on whether or not this is a tagged build 16 | if [ -z ${TAGGED+x} ]; then 17 | SLIC3R_PKG=slic3r_dev 18 | else 19 | SLIC3R_PKG=slic3r 20 | fi 21 | version=$SLIC3R_BUILD_ID 22 | else 23 | # If building a branch, put the package somewhere else. 24 | echo "Delploying pull request $PR_ID" 25 | SLIC3R_PKG=Slic3r_Branches 26 | version=${SLIC3R_BUILD_ID}-PR${PR_ID} 27 | fi 28 | 29 | file=$1 30 | echo "Deploying $file to $version on Bintray repo $SLIC3R_PKG..." 31 | API=${BINTRAY_API_KEY} 32 | USER=${BINTRAY_API_USER} 33 | 34 | echo "Creating version: $version" 35 | curl -s -X POST -d "{ \"name\": \"$version\", \"released\": \"ISO8601 $(date +%Y-%m-%d'T'%H:%M:%S)\", \"desc\": \"This version...\", \"github_release_notes_file\": \"RELEASE.txt\", \"github_use_tag_release_notes\": true, \"vcs_tag\": \"$version\" }" -u${USER}:${API} https://api.bintray.com/content/lordofhyphens/Slic3r/${SLIC3R_PKG}/versions 36 | 37 | echo "Publishing ${file} to ${version}..." 38 | curl -s -H "X-Bintray-Package: $SLIC3R_PKG" -H "X-Bintray-Version: $version" -H 'X-Bintray-Publish: 1' -H 'X-Bintray-Override: 1' -T $file -u${USER}:${API} https://api.bintray.com/content/lordofhyphens/Slic3r/$(basename $1) 39 | #curl -X POST -u${USER}:${API} https://api.bintray.com/content/lordofhyphens/Slic3r/${SLIC3R_PKG}/$version/publish 40 | # Wait 5s for the server to catch up 41 | #sleep 5 42 | #curl -H 'Content-Type: application/json' -X PUT -d "{ \"list_in_downloads\":true }" -u${USER}:${API} https://api.bintray.com/file_metadata/lordofhyphens/Slic3r/$(basename $1) 43 | exit 0 44 | -------------------------------------------------------------------------------- /package/deploy/sftp-symlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Prerequisites 3 | # Environment Variables: 4 | # UPLOAD_USER - user to upload to sftp server 5 | # KEY is assumed to be path to a ssh key for UPLOAD_USER 6 | 7 | DIR=$1 8 | shift 9 | KEY=$1 10 | shift 11 | EXT=$1 12 | shift 13 | FILES=$* 14 | 15 | source $(dirname $0)/../common/util.sh 16 | set_pr_id 17 | set_branch 18 | if [ ! -z ${PR_ID+x} ] || [ $current_branch != "master" ]; then 19 | DIR=${DIR}/branches 20 | fi 21 | 22 | if [ -s $KEY ]; then 23 | for i in $FILES; do 24 | filepath=$(readlink -f "$i") 25 | filepath=$(basename $filepath) 26 | tmpfile=$(mktemp) 27 | 28 | echo "rm Slic3r-${current_branch}-latest.${EXT}" | sftp -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/" 29 | echo "symlink $filepath Slic3r-${current_branch}-latest.${EXT} " > $tmpfile 30 | sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/" 31 | result=$? 32 | if [ $? -eq 1 ]; then 33 | echo "Error with SFTP symlink" 34 | exit $result; 35 | fi 36 | done 37 | else 38 | echo "$KEY is not available, not symlinking." 39 | fi 40 | exit $result 41 | -------------------------------------------------------------------------------- /package/deploy/sftp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Prerequisites 3 | # Environment Variables: 4 | # UPLOAD_USER - user to upload to sftp server 5 | # KEY is assumed to be path to a ssh key for UPLOAD_USER 6 | 7 | DIR=$1 8 | shift 9 | KEY=$1 10 | shift 11 | FILES=$* 12 | source $(dirname $0)/../common/util.sh 13 | set_pr_id 14 | set_branch 15 | if [ ! -z ${PR_ID+x} ] || [ $current_branch != "master" ]; then 16 | DIR=${DIR}/branches 17 | fi 18 | 19 | if [ -s $KEY ]; then 20 | for i in $FILES; do 21 | filepath=$(readlink -f "$i") 22 | tmpfile=$(mktemp) 23 | echo put $filepath > $tmpfile 24 | sftp -b $tmpfile -i$KEY "${UPLOAD_USER}@dl.slic3r.org:$DIR/" 25 | result=$? 26 | if [ $? -eq 1 ]; then 27 | echo "Error with SFTP" 28 | exit $result; 29 | fi 30 | done 31 | else 32 | echo "$KEY is not available, not deploying." 33 | fi 34 | exit $result 35 | -------------------------------------------------------------------------------- /package/deploy/slic3r-upload.ppk.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/package/deploy/slic3r-upload.ppk.enc -------------------------------------------------------------------------------- /package/deploy/slic3r-upload.rsa.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/package/deploy/slic3r-upload.rsa.enc -------------------------------------------------------------------------------- /package/deploy/winscp.ps1: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | # Environment Variables: 3 | # UPLOAD_USER - user to upload to sftp server 4 | # KEY is assumed to be path to a ssh key for UPLOAD_USER 5 | 6 | Param( 7 | [string]$DIR, 8 | [string]$KEY, 9 | [string]$FILE 10 | ) 11 | Set-Variable -Name "UUSER" -Value "$env:UPLOAD_USER" 12 | Set-Variable -Name "UPLOAD" -Value "$($FILE | Resolve-Path)" 13 | if (Test-Path $KEY) { 14 | if ($env:APPVEYOR_PULL_REQUEST_NUMBER -Or $env:APPVEYOR_REPO_BRANCH -ne "master" ) { 15 | winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR/branches -hostkey=*" "put $UPLOAD ./$FILE" "exit" 16 | } else { 17 | winscp.com /privatekey=$KEY /command "open sftp://$UUSER@dl.slic3r.org/$DIR -hostkey=*" "put $UPLOAD ./$FILE" "exit" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /package/linux/build_shell.mk: -------------------------------------------------------------------------------- 1 | src=../common/shell.cpp 2 | 3 | # override with environment variable 4 | CXX ?= g++ 5 | 6 | # Path to perl header files 7 | INCLUDEDIR ?= ${HOME}/perl5/perlbrew/perls/slic3r-perl/lib/5.24.0/x86_64-linux-thread-multi/CORE 8 | 9 | # path to library files for perl 10 | LIBDIR ?= ${HOME}/perl5/perlbrew/perls/slic3r-perl/lib/5.24.0/x86_64-linux-thread-multi/CORE 11 | 12 | LIBS += -lperl -lpthread -lcrypt 13 | 14 | CXXFLAGS += -std=c++11 -static-libgcc -static-libstdc++ -I${INCLUDEDIR} 15 | LDFLAGS += -L${LIBDIR} 16 | 17 | .PHONY: all clean 18 | all: Slic3r Slic3r-console 19 | 20 | Slic3r: slic3r.o 21 | ${CXX} ${LDFLAGS} -o $@ $< ${LIBS} 22 | 23 | Slic3r-console: slic3r-console.o 24 | ${CXX} ${LDFLAGS} -o $@ $< ${LIBS} 25 | slic3r-console.o: ${src} 26 | ${CXX} -c ${CXXFLAGS} -o $@ $< 27 | slic3r.o: ${src} 28 | ${CXX} -c -DFORCE_GUI ${CXXFLAGS} -o $@ $< 29 | 30 | clean: 31 | rm *.o Slic3r* 32 | -------------------------------------------------------------------------------- /package/linux/libpaths.appimage.txt: -------------------------------------------------------------------------------- 1 | /usr/lib/x86_64-linux-gnu/libstdc++.so.6 # needed because of ancient distros and slic3r (and perl for perl reasons) needs modern c++. 2 | -------------------------------------------------------------------------------- /package/linux/libpaths.txt: -------------------------------------------------------------------------------- 1 | /home/travis/builds/alexrj/Slic3r/local-lib/lib/perl5/x86_64-linux-thread-multi/Alien/wxWidgets/gtk_3_0_2_uni/lib/libwx_baseu-3.0.so.0 2 | /home/travis/builds/alexrj/Slic3r/local-lib/lib/perl5/x86_64-linux-thread-multi/Alien/wxWidgets/gtk_3_0_2_uni/lib/libwx_gtk2u_adv-3.0.so.0 3 | /home/travis/builds/alexrj/Slic3r/local-lib/lib/perl5/x86_64-linux-thread-multi/Alien/wxWidgets/gtk_3_0_2_uni/lib/libwx_gtk2u_core-3.0.so.0 4 | /home/travis/builds/alexrj/Slic3r/local-lib/lib/perl5/x86_64-linux-thread-multi/Alien/wxWidgets/gtk_3_0_2_uni/lib/libwx_gtk2u_gl-3.0.so.0 5 | /home/travis/builds/alexrj/Slic3r/local-lib/lib/perl5/x86_64-linux-thread-multi/Alien/wxWidgets/gtk_3_0_2_uni/lib/libwx_gtk2u_html-3.0.so.0 6 | /lib/x86_64-linux-gnu/liblzma.so.5 7 | /lib/x86_64-linux-gnu/libpng12.so.0 8 | /usr/lib/x86_64-linux-gnu/libjpeg.so.8 9 | /usr/lib/x86_64-linux-gnu/libjbig.so.0 10 | /usr/lib/x86_64-linux-gnu/libtiff.so.5 11 | /usr/lib/x86_64-linux-gnu/libglut.so.3 # needed for appimage on some systems that don't have glut installed. 12 | -------------------------------------------------------------------------------- /package/linux/slic3r.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | 3 | Type=Application 4 | 5 | Name=APPLICATION_NAME 6 | 7 | Comment=Prepare 3D Models for printing 8 | 9 | Icon=slic3r 10 | 11 | Exec=Slic3r 12 | -------------------------------------------------------------------------------- /package/linux/startup_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BIN=$(readlink "$0") 4 | DIR=$(dirname "$BIN") 5 | export LD_LIBRARY_PATH="$DIR/bin" 6 | exec "$DIR/perl-local" -I"$DIR/local-lib/lib/perl5" "$DIR/slic3r.pl" $@ 7 | -------------------------------------------------------------------------------- /package/linux/travis-decrypt-key: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script to only decrypt if it is available 3 | 4 | if [ ! -z ${encrypted_daaf322d08bf_key+x} ]; then 5 | openssl aes-256-cbc -K $encrypted_daaf322d08bf_key -iv $encrypted_daaf322d08bf_iv -in $TRAVIS_BUILD_DIR/package/deploy/slic3r-upload.rsa.enc -out ~/slic3r-upload.rsa -d 6 | chmod 600 ~/slic3r-upload.rsa 7 | fi 8 | -------------------------------------------------------------------------------- /package/linux/travis-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script to configure travis environment prior to build 3 | WXVERSION=302 4 | CACHE=$HOME/cache 5 | mkdir -p $CACHE 6 | 7 | if [ ! -e $CACHE/slic3r-perlbrew-5.24.tar.bz2 ]; then 8 | echo "Downloading http://www.siusgs.com/slic3r/buildserver/slic3r-perl.524.travis.tar.bz2 => $CACHE/slic3r-perlbrew-5.24.tar.bz2" 9 | curl -L "http://www.siusgs.com/slic3r/buildserver/slic3r-perl.524.travis.tar.bz2" -o $CACHE/slic3r-perlbrew-5.24.tar.bz2; 10 | fi 11 | 12 | if [ ! -e $CACHE/boost-compiled.tar.bz2 ]; then 13 | echo "Downloading http://www.siusgs.com/slic3r/buildserver/boost_1_63_0.built.gcc-4.9.4-buildserver.tar.bz2 => $CACHE/boost-compiled.tar.bz2" 14 | curl -L "http://www.siusgs.com/slic3r/buildserver/boost_1_63_0.built.gcc-4.9.4-buildserver.tar.bz2" -o $CACHE/boost-compiled.tar.bz2 15 | fi 16 | 17 | if [ ! -e $CACHE/local-lib-wx${WXVERSION}.tar.bz2 ]; then 18 | echo "Downloading http://www.siusgs.com/slic3r/buildserver/slic3r-dependencies.travis-wx${WXVERSION}.tar.bz2 => $CACHE/local-lib-wx${WXVERSION}.tar.bz2" 19 | curl -L "http://www.siusgs.com/slic3r/buildserver/slic3r-dependencies.travis-wx${WXVERSION}.tar.bz2" -o $CACHE/local-lib-wx${WXVERSION}.tar.bz2 20 | fi 21 | 22 | if [ ! -e $CACHE/wx${WXVERSION}.tar.bz2 ]; then 23 | echo "Downloading http://www.siusgs.com/slic3r/buildserver/wx${WXVERSION}-libs.tar.bz2 => $CACHE/wx${WXVERSION}.tar.bz2" 24 | curl -L "http://www.siusgs.com/slic3r/buildserver/wx${WXVERSION}-libs.tar.bz2" -o $CACHE/wx${WXVERSION}.tar.bz2 25 | fi 26 | 27 | tar -C$TRAVIS_BUILD_DIR -xjf $CACHE/local-lib-wx${WXVERSION}.tar.bz2 28 | tar -C$HOME/perl5/perlbrew/perls -xjf $CACHE/slic3r-perlbrew-5.24.tar.bz2 29 | tar -C$HOME -xjf $CACHE/boost-compiled.tar.bz2 30 | tar -C$HOME -xjf $CACHE/wx${WXVERSION}.tar.bz2 31 | -------------------------------------------------------------------------------- /package/osx/startup_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR=$(dirname "$0") 4 | exec "$DIR/perl-local" -I"$DIR/local-lib/lib/perl5" "$DIR/slic3r.pl" $@ 5 | -------------------------------------------------------------------------------- /package/win/appveyor_buildscript.ps1: -------------------------------------------------------------------------------- 1 | if (!(Test-Path "C:\users\appveyor\local-lib-$env:ARCH.7z")) { 2 | wget "https://bintray.com/lordofhyphens/Slic3r/download_file?file_path=local-lib-$env:ARCH.7z" -o "C:\users\appveyor\local-lib-$env:ARCH.7z" | Write-Output 3 | } 4 | 5 | if (Test-Path "C:\users\appveyor\local-lib-$env:ARCH.7z") { 6 | cmd /c "7z x C:\Users\appveyor\local-lib-$env:ARCH.7z -oC:\projects\slic3r" -y | Write-Output 7 | rm -r 'C:\projects\slic3r\local-lib\Slic3r*' 8 | } 9 | 10 | $env:Path = "C:\Strawberry\c\bin;C:\Strawberry\perl\bin;" + $env:Path 11 | cd C:\projects\slic3r 12 | 13 | rm -r 'C:\Program Files (x86)\Microsoft Vis*\bin' -Force 14 | 15 | Add-AppveyorCompilationMessage -Message "Building Slic3r XS" 16 | perl ./Build.pl 17 | 18 | if ($LastExitCode -ne 0) { 19 | Add-AppveyorCompilationMessage -Message "XS Failed to Build" -Category Error 20 | $host.SetShouldExit($LastExitCode) 21 | exit 22 | } 23 | 24 | Add-AppveyorCompilationMessage -Message "Making ZIP package" 25 | cd package/win 26 | ./compile_wrapper.ps1 524 | Write-Output 27 | ./package_win32.ps1 524| Write-Output 28 | -------------------------------------------------------------------------------- /package/win/appveyor_deploy.ps1: -------------------------------------------------------------------------------- 1 | 2 | Add-AppveyorCompilationMessage -Message "Uploading to server." 3 | & ./package/deploy/winscp.ps1 -DIR win -KEY $env:APPVEYOR_BUILD_FOLDER/package/deploy/slic3r-upload.ppk -FILE *.zip *>> ./sftplog.txt 4 | -------------------------------------------------------------------------------- /package/win/compile_wrapper.ps1: -------------------------------------------------------------------------------- 1 | # Short Powershell script to build a wrapper exec 2 | Param 3 | ( 4 | [string]$perlVersion = "524", 5 | [string]$STRAWBERRY_PATH = "C:\Strawberry", 6 | # Path to C++ compiler, or just name if it is in path 7 | [string]$cxx = "g++" 8 | ) 9 | 10 | function Get-ScriptDirectory 11 | { 12 | $Invocation = (Get-Variable MyInvocation -Scope 1).Value 13 | Split-Path $Invocation.MyCommand.Path 14 | } 15 | $scriptDir = Get-ScriptDirectory 16 | 17 | $perllib = "-lperl$perlVersion" 18 | $shell_loc = "${scriptDir}\..\common\shell.cpp" 19 | 20 | # Build the resource file (used to load icon, etc) 21 | windres ${scriptDir}\slic3r.rc -O coff -o ${scriptDir}\slic3r.res 22 | 23 | # Compile an object file that does not have gui forced. 24 | Invoke-Expression "$cxx -c -I'${STRAWBERRY_PATH}\perl\lib\CORE\' $shell_loc -o ${scriptDir}/slic3r.o" 25 | 26 | 27 | # Compile an object file with --gui automatically passed as an argument 28 | Invoke-Expression "$cxx -c -I'${STRAWBERRY_PATH}\perl\lib\CORE\' -DFORCE_GUI $shell_loc -o ${scriptDir}/slic3r-gui.o" 29 | 30 | # Build the EXE for the unforced version as slic3r-console 31 | Invoke-Expression "$cxx -static-libgcc -static-libstdc++ -L'${STRAWBERRY_PATH}\c\lib' -L'${STRAWBERRY_PATH}\perl\bin' -L'${STRAWBERRY_PATH}\perl\lib\CORE\' $perllib ${scriptDir}/slic3r.o ${scriptDir}/slic3r.res -o ${scriptDir}/slic3r-console.exe | Write-Host" 32 | 33 | # Build the EXE for the forced GUI 34 | Invoke-Expression "$cxx -static-libgcc -static-libstdc++ -L'${STRAWBERRY_PATH}\c\lib' -mwindows -L'${STRAWBERRY_PATH}\perl\bin' -L'${STRAWBERRY_PATH}\perl\lib\CORE\' $perllib ${scriptDir}/slic3r-gui.o ${scriptDir}/slic3r.res -o ${scriptDir}/slic3r.exe | Write-Host" 35 | 36 | # Build an extra copy of the GUI version that creates a console window 37 | Invoke-Expression "$cxx -static-libgcc -static-libstdc++ -L'${STRAWBERRY_PATH}\c\lib' -L'${STRAWBERRY_PATH}\perl\bin' -L'${STRAWBERRY_PATH}\perl\lib\CORE\' $perllib ${scriptDir}/slic3r-gui.o ${scriptDir}/slic3r.res -o ${scriptDir}/slic3r-debug-console.exe | Write-Host" 38 | 39 | -------------------------------------------------------------------------------- /package/win/slic3r.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Slic3r 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /package/win/slic3r.rc: -------------------------------------------------------------------------------- 1 | id ICON "../../var/Slic3r.ico" 2 | 1 VERSIONINFO 3 | FILEVERSION 1,3,0,0 4 | PRODUCTVERSION 1,3,0,0 5 | FILEOS 0x4 6 | FILETYPE 0x1 7 | BEGIN 8 | BLOCK "StringFileInfo" 9 | BEGIN 10 | BLOCK "040904E4" 11 | BEGIN 12 | VALUE "CompanyName", "Slic3r.org" 13 | VALUE "FileDescription", "3D Printer Slicer application" 14 | VALUE "FileVersion", "1.3.0" 15 | VALUE "InternalName", "slic3r.exe" 16 | VALUE "LegalCopyright", "Alessandro Ranellucci" 17 | VALUE "OriginalFilename", "slic3r.exe" 18 | VALUE "ProductName", "Slic3r" 19 | VALUE "ProductVersion", "1.3.0" 20 | END 21 | END 22 | BLOCK "VarFileInfo" 23 | BEGIN 24 | VALUE "Translation", 0x409, 1252 25 | END 26 | END 27 | 1 24 "slic3r.exe.manifest" 28 | -------------------------------------------------------------------------------- /share/locale/ja/slic3r.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/share/locale/ja/slic3r.mo -------------------------------------------------------------------------------- /src/standalone/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/src/standalone/config.h -------------------------------------------------------------------------------- /src/utils/extrude-tin.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.hpp" 2 | #include "Model.hpp" 3 | #include "IO.hpp" 4 | #include "TriangleMesh.hpp" 5 | #include "libslic3r.h" 6 | #include 7 | #include 8 | 9 | using namespace Slic3r; 10 | 11 | void confess_at(const char *file, int line, const char *func, const char *pat, ...){} 12 | 13 | int 14 | main(int argc, char **argv) 15 | { 16 | // Convert arguments to UTF-8 (needed on Windows). 17 | // argv then points to memory owned by a. 18 | boost::nowide::args a(argc, argv); 19 | 20 | // read config 21 | ConfigDef config_def; 22 | { 23 | ConfigOptionDef* def; 24 | 25 | def = config_def.add("offset", coFloat); 26 | def->label = "Offset from the lowest point (min thickness)"; 27 | def->cli = "offset"; 28 | def->default_value = new ConfigOptionFloat(1); 29 | 30 | def = config_def.add("output", coString); 31 | def->label = "Output File"; 32 | def->tooltip = "The file where the output will be written (if not specified, it will be based on the input file)."; 33 | def->cli = "output"; 34 | def->default_value = new ConfigOptionString(""); 35 | } 36 | DynamicConfig config(&config_def); 37 | t_config_option_keys input_files; 38 | config.read_cli(argc, argv, &input_files); 39 | 40 | for (t_config_option_keys::const_iterator it = input_files.begin(); it != input_files.end(); ++it) { 41 | TriangleMesh mesh; 42 | Slic3r::IO::STL::read(*it, &mesh); 43 | mesh.extrude_tin(config.option("offset", true)->getFloat()); 44 | 45 | std::string outfile = config.option("output", true)->getString(); 46 | if (outfile.empty()) outfile = *it + "_extruded.stl"; 47 | 48 | Slic3r::IO::STL::write(mesh, outfile); 49 | boost::nowide::cout << "Extruded mesh written to " << outfile << std::endl; 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/windows-build.txt: -------------------------------------------------------------------------------- 1 | Install: 2 | mingw 3 | boost 4 | cmake 5 | git 6 | 7 | Assuming boost is in c:\program files\boost\boost_1_61_0 and mingw is in c:\mingw 8 | 9 | start cmd.exe 10 | > cd c:\program files\boost\boost_1_61_0 11 | > set PATH=c:\mingw\bin 12 | > bootstrap gcc 13 | > .\b2 --build-dir=c:\boost-mingw toolset=gcc link=static runtime-link=static variant=release --with-system --with-thread 14 | leave cmd window open 15 | 16 | start git bash 17 | > cd /c 18 | > git clone http://github.com/alexrj/slic3r 19 | > cd slic3r 20 | > git checkout cppsvg 21 | close git bash when done 22 | 23 | make sure c:\mingw\bin is part of the Path system variable, add it otherwise 24 | 25 | start cmake gui 26 | source code: c:\slic3r\src 27 | build directory: c:\slic3r\build 28 | click configure, select "mingw makefiles" from list, select "default native compilers", click finish 29 | click generate 30 | close cmake gui 31 | 32 | alternatively, do it from command line: 33 | cmake ..\src -G "MinGW Makefiles" -DBOOST_ROOT="c:\program files\boost\boost_1_61_0" 34 | (in case cmake can't find the libs, -DBoost_DEBUG=1 and -DBoost_COMPILER=-mgw46 are useful) 35 | 36 | go back to cmd window 37 | > cd c:\slic3r\build 38 | > mingw32-make.exe 39 | might be mingw64 on 64-bit setup, I'm not sure 40 | The resulting slic3r.exe is the target executable, it has no dependencies except windows system libraries (kernel32 and msvcrt) 41 | -------------------------------------------------------------------------------- /t/avoid_crossing_perimeters.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use List::Util qw(first sum); 12 | use Slic3r; 13 | use Slic3r::Test; 14 | 15 | { 16 | my $config = Slic3r::Config->new_from_defaults; 17 | $config->set('avoid_crossing_perimeters', 2); 18 | my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2); 19 | ok my $gcode = Slic3r::Test::gcode($print), "no crash with avoid_crossing_perimeters and multiple objects"; 20 | } 21 | 22 | __END__ 23 | -------------------------------------------------------------------------------- /t/config.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use Slic3r; 12 | use Slic3r::Test; 13 | 14 | { 15 | my $config = Slic3r::Config->new_from_defaults; 16 | $config->set('perimeter_extrusion_width', '250%'); 17 | ok $config->validate, 'percent extrusion width is validated'; 18 | } 19 | 20 | __END__ 21 | -------------------------------------------------------------------------------- /t/gaps.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use List::Util qw(first); 12 | use Slic3r; 13 | use Slic3r::Flow ':roles'; 14 | use Slic3r::Geometry qw(PI scale unscale convex_hull); 15 | use Slic3r::Geometry::Clipper qw(); 16 | use Slic3r::Surface ':types'; 17 | use Slic3r::Test; 18 | 19 | { 20 | my $config = Slic3r::Config->new_from_defaults; 21 | $config->set('skirts', 0); 22 | $config->set('perimeter_speed', 66); 23 | $config->set('external_perimeter_speed', 66); 24 | $config->set('small_perimeter_speed', 66); 25 | $config->set('gap_fill_speed', 99); 26 | $config->set('perimeters', 1); 27 | $config->set('cooling', 0); # to prevent speeds from being altered 28 | $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered 29 | $config->set('perimeter_extrusion_width', 0.35); 30 | $config->set('first_layer_extrusion_width', 0.35); 31 | 32 | my $print = Slic3r::Test::init_print('two_hollow_squares', config => $config); 33 | my @perimeter_points = (); 34 | my $last = ''; # perimeter | gap 35 | my $gap_fills_outside_last_perimeters = 0; 36 | Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { 37 | my ($self, $cmd, $args, $info) = @_; 38 | 39 | if ($info->{extruding} && $info->{dist_XY} > 0) { 40 | my $F = $args->{F} // $self->F; 41 | my $point = Slic3r::Point->new_scale($info->{new_X}, $info->{new_Y}); 42 | if ($F == $config->perimeter_speed*60) { 43 | if ($last eq 'gap') { 44 | @perimeter_points = (); 45 | } 46 | push @perimeter_points, $point; 47 | $last = 'perimeter'; 48 | } elsif ($F == $config->gap_fill_speed*60) { 49 | my $convex_hull = convex_hull(\@perimeter_points); 50 | if (!$convex_hull->contains_point($point)) { 51 | $gap_fills_outside_last_perimeters++; 52 | } 53 | 54 | $last = 'gap'; 55 | } 56 | } 57 | }); 58 | is $gap_fills_outside_last_perimeters, 0, 'gap fills are printed before leaving islands'; 59 | } 60 | 61 | __END__ 62 | -------------------------------------------------------------------------------- /t/loops.t: -------------------------------------------------------------------------------- 1 | use Test::More; 2 | use strict; 3 | use warnings; 4 | 5 | plan tests => 4; 6 | 7 | BEGIN { 8 | use FindBin; 9 | use lib "$FindBin::Bin/../lib"; 10 | use local::lib "$FindBin::Bin/../local-lib"; 11 | } 12 | 13 | use Slic3r; 14 | use Slic3r::Geometry qw(Z epsilon scale); 15 | use Slic3r::Test; 16 | 17 | { 18 | # We want to check what happens when three concentric loops happen 19 | # to be at the same height, the two external ones being ccw and the other being 20 | # a hole, thus cw. So we create three cubes, centered around origin, the internal 21 | # one having reversed normals. 22 | my $mesh1 = Slic3r::Test::mesh('20mm_cube'); 23 | 24 | # center around origin 25 | my $bb = $mesh1->bounding_box; 26 | $mesh1->translate( 27 | -($bb->x_min + $bb->size->x/2), 28 | -($bb->y_min + $bb->size->y/2), #// 29 | -($bb->z_min + $bb->size->z/2), 30 | ); 31 | 32 | my $mesh2 = $mesh1->clone; 33 | $mesh2->scale(1.2); 34 | 35 | my $mesh3 = $mesh2->clone; 36 | $mesh3->scale(1.2); 37 | 38 | $mesh1->reverse_normals; 39 | ok $mesh1->volume < 0, 'reverse_normals'; 40 | 41 | my $all_meshes = Slic3r::TriangleMesh->new; 42 | $all_meshes->merge($_) for $mesh1, $mesh2, $mesh3; 43 | 44 | my $loops = $all_meshes->slice_at(Z, 0); 45 | is scalar(@$loops), 1, 'one expolygon returned'; 46 | is scalar(@{$loops->[0]->holes}), 1, 'expolygon has one hole'; 47 | ok abs(-$loops->[0]->holes->[0]->area - scale($bb->size->x)*scale($bb->size->y)) < epsilon, #)) 48 | 'hole has expected size'; 49 | } 50 | 51 | __END__ 52 | -------------------------------------------------------------------------------- /t/pressure.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 1; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use List::Util qw(); 12 | use Slic3r; 13 | use Slic3r::Geometry qw(epsilon); 14 | use Slic3r::Test; 15 | 16 | { 17 | my $config = Slic3r::Config->new_from_defaults; 18 | $config->set('pressure_advance', 10); 19 | $config->set('retract_length', [1]); 20 | 21 | my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2); 22 | my $retracted = $config->retract_length->[0]; 23 | Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { 24 | my ($self, $cmd, $args, $info) = @_; 25 | 26 | if ($info->{extruding} && !$info->{dist_XY}) { 27 | $retracted += $info->{dist_E}; 28 | } elsif ($info->{retracting}) { 29 | $retracted += $info->{dist_E}; 30 | } 31 | }); 32 | 33 | ok abs($retracted) < 0.01, 'all retractions are compensated'; 34 | } 35 | 36 | 37 | __END__ 38 | -------------------------------------------------------------------------------- /t/speed.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 2; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use List::Util qw(none); 12 | use Slic3r; 13 | use Slic3r::Geometry qw(epsilon); 14 | use Slic3r::Test; 15 | 16 | { 17 | my $config = Slic3r::Config->new_from_defaults; 18 | my $test = sub { 19 | my $print = Slic3r::Test::init_print('20mm_cube', config => $config); 20 | my %speeds_by_z = (); # z => [] 21 | Slic3r::GCode::Reader->new->parse(my $gcode = Slic3r::Test::gcode($print), sub { 22 | my ($self, $cmd, $args, $info) = @_; 23 | 24 | if ($cmd eq 'G1' && $info->{dist_E} > 0 && $info->{dist_XY} > 0) { 25 | $speeds_by_z{$self->Z} //= []; 26 | push @{ $speeds_by_z{$self->Z} }, $self->F/60; 27 | } 28 | }); 29 | return %speeds_by_z; 30 | }; 31 | 32 | { 33 | $config->set('perimeter_speed', 0); 34 | $config->set('external_perimeter_speed', 0); 35 | $config->set('infill_speed', 0); 36 | $config->set('support_material_speed', 0); 37 | $config->set('solid_infill_speed', 0); 38 | $config->set('first_layer_speed', '50%'); 39 | $config->set('first_layer_height', 0.25); 40 | my %speeds_by_z = $test->(); 41 | ok !!(none { $_ > $config->max_print_speed/2+&epsilon } @{ $speeds_by_z{$config->first_layer_height} }), 42 | 'percent first_layer_speed is applied over autospeed'; 43 | } 44 | 45 | { 46 | $config->set('first_layer_speed', 33); 47 | my %speeds_by_z = $test->(); 48 | ok !!(none { $_ > $config->first_layer_speed } @{ $speeds_by_z{$config->first_layer_height} }), 49 | 'absolute first_layer_speed overrides autospeed'; 50 | } 51 | } 52 | 53 | __END__ 54 | -------------------------------------------------------------------------------- /t/svg.t: -------------------------------------------------------------------------------- 1 | use Test::More tests => 2; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use Slic3r; 12 | use Slic3r::Test; 13 | 14 | { 15 | my $print = Slic3r::Test::init_print('20mm_cube'); 16 | eval { 17 | my $fh = IO::Scalar->new(\my $gcode); 18 | $print->print->export_svg(output_fh => $fh, quiet => 1); 19 | $fh->close; 20 | }; 21 | die $@ if $@; 22 | ok !$@, 'successful SVG export'; 23 | } 24 | 25 | { 26 | my $print = Slic3r::Test::init_print('two_hollow_squares'); 27 | eval { 28 | my $fh = IO::Scalar->new(\my $gcode); 29 | $print->print->export_svg(output_fh => $fh, quiet => 1); 30 | $fh->close; 31 | }; 32 | die $@ if $@; 33 | ok !$@, 'successful SVG export of object with two islands'; 34 | } 35 | 36 | __END__ 37 | -------------------------------------------------------------------------------- /t/threads.t: -------------------------------------------------------------------------------- 1 | use Test::More; 2 | use strict; 3 | use warnings; 4 | 5 | BEGIN { 6 | use FindBin; 7 | use lib "$FindBin::Bin/../lib"; 8 | use local::lib "$FindBin::Bin/../local-lib"; 9 | } 10 | 11 | use List::Util qw(first); 12 | use Slic3r; 13 | use Slic3r::Test; 14 | 15 | if (!$Slic3r::have_threads) { 16 | plan skip_all => "this perl is not compiled with threads"; 17 | } 18 | plan tests => 2; 19 | 20 | { 21 | my $print = Slic3r::Test::init_print('20mm_cube'); 22 | { 23 | my $thread = threads->create(sub { Slic3r::thread_cleanup(); return 1; }); 24 | ok $thread->join, "print survives thread spawning"; 25 | } 26 | } 27 | 28 | { 29 | my $thread = threads->create(sub { 30 | { 31 | my $print = Slic3r::Test::init_print('20mm_cube'); 32 | Slic3r::Test::gcode($print); 33 | } 34 | Slic3r::thread_cleanup(); 35 | return 1; 36 | }); 37 | ok $thread->join, "process print in a separate thread"; 38 | } 39 | 40 | __END__ 41 | -------------------------------------------------------------------------------- /utils/amf-to-stl.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script converts an AMF file to STL 3 | 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | use FindBin; 9 | use lib "$FindBin::Bin/../lib"; 10 | use local::lib "$FindBin::Bin/../local-lib"; 11 | } 12 | 13 | use File::Basename qw(basename); 14 | use Getopt::Long qw(:config no_auto_abbrev); 15 | use Slic3r; 16 | $|++; 17 | 18 | my %opt = (); 19 | { 20 | my %options = ( 21 | 'help' => sub { usage() }, 22 | 'ascii' => \$opt{ascii}, 23 | ); 24 | GetOptions(%options) or usage(1); 25 | $ARGV[0] or usage(1); 26 | } 27 | 28 | { 29 | my $model = Slic3r::Model->read_from_file($ARGV[0]); 30 | my $output_file = $ARGV[0]; 31 | $output_file =~ s/\.amf(?:\.xml)?$/\.stl/i; 32 | 33 | printf "Writing to %s\n", basename($output_file); 34 | $model->write_stl($output_file, !$opt{ascii}); 35 | } 36 | 37 | 38 | sub usage { 39 | my ($exit_code) = @_; 40 | 41 | print <<"EOF"; 42 | Usage: amf-to-stl.pl [ OPTIONS ] file.amf 43 | 44 | --help Output this usage screen and exit 45 | --ascii Generate ASCII STL files (default: binary) 46 | 47 | EOF 48 | exit ($exit_code || 0); 49 | } 50 | 51 | __END__ 52 | -------------------------------------------------------------------------------- /utils/config-bundle-to-config.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script extracts a full active config from a config bundle. 3 | # (Often users reporting issues don't attach plain configs, but 4 | # bundles...) 5 | 6 | use strict; 7 | use warnings; 8 | 9 | BEGIN { 10 | use FindBin; 11 | use lib "$FindBin::Bin/../lib"; 12 | use local::lib "$FindBin::Bin/../local-lib"; 13 | } 14 | 15 | use Getopt::Long qw(:config no_auto_abbrev); 16 | use Slic3r; 17 | use Slic3r::Test; 18 | $|++; 19 | 20 | my %opt = (); 21 | { 22 | my %options = ( 23 | 'help' => sub { usage() }, 24 | 'output=s' => \$opt{output}, 25 | ); 26 | GetOptions(%options) or usage(1); 27 | $ARGV[0] or usage(1); 28 | } 29 | 30 | ($ARGV[0] && $opt{output}) or usage(1); 31 | 32 | { 33 | my $bundle_ini = Slic3r::Config->read_ini($ARGV[0]) 34 | or die "Failed to read $ARGV[0]\n"; 35 | 36 | my $config_ini = { _ => {} }; 37 | foreach my $section (qw(print filament printer)) { 38 | my $preset_name = $bundle_ini->{presets}{$section}; 39 | $preset_name =~ s/\.ini$//; 40 | my $preset = $bundle_ini->{"$section:$preset_name"} 41 | or die "Failed to find preset $preset_name in bundle\n"; 42 | $config_ini->{_}{$_} = $preset->{$_} for keys %$preset; 43 | } 44 | 45 | Slic3r::Config->write_ini($opt{output}, $config_ini); 46 | } 47 | 48 | 49 | sub usage { 50 | my ($exit_code) = @_; 51 | 52 | print <<"EOF"; 53 | Usage: config-bundle-to-config.pl --output config.ini bundle.ini 54 | EOF 55 | exit ($exit_code || 0); 56 | } 57 | 58 | __END__ 59 | -------------------------------------------------------------------------------- /utils/dump-stl.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script dumps a STL file into Perl syntax for writing tests 3 | # or dumps a test model into a STL file 4 | 5 | use strict; 6 | use warnings; 7 | 8 | BEGIN { 9 | use FindBin; 10 | use lib "$FindBin::Bin/../lib"; 11 | use local::lib "$FindBin::Bin/../local-lib"; 12 | } 13 | 14 | use Slic3r; 15 | use Slic3r::Test; 16 | $|++; 17 | 18 | $ARGV[0] or usage(1); 19 | 20 | if (-e $ARGV[0]) { 21 | my $model = Slic3r::Model->read_from_file($ARGV[0]); 22 | $model->objects->[0]->add_instance(offset => Slic3r::Pointf->new(0,0)); 23 | my $mesh = $model->mesh; 24 | $mesh->repair; 25 | printf "VERTICES = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->vertices}; 26 | printf "FACETS = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->facets}; 27 | exit 0; 28 | } elsif ((my $model = Slic3r::Test::model($ARGV[0]))) { 29 | $ARGV[1] or die "Missing writeable destination as second argument\n"; 30 | $model->write_stl($ARGV[1]); 31 | printf "Model $ARGV[0] written to $ARGV[1]\n"; 32 | exit 0; 33 | } else { 34 | die "No such model exists\n"; 35 | } 36 | 37 | 38 | sub usage { 39 | my ($exit_code) = @_; 40 | 41 | print <<"EOF"; 42 | Usage: dump-stl.pl file.stl 43 | dump-stl.pl modelname file.stl 44 | EOF 45 | exit ($exit_code || 0); 46 | } 47 | 48 | __END__ 49 | -------------------------------------------------------------------------------- /utils/estimate-gcode-time.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | BEGIN { 7 | use FindBin; 8 | use lib "$FindBin::Bin/../lib"; 9 | use local::lib "$FindBin::Bin/../local-lib"; 10 | } 11 | 12 | use Slic3r; 13 | 14 | die "Usage: estimate-gcode-time.pl FILE\n" 15 | if @ARGV != 1; 16 | 17 | my $estimator = Slic3r::GCode::TimeEstimator->new; 18 | $estimator->parse_file($ARGV[0]); 19 | printf "Time: %d minutes and %d seconds\n", int($estimator->time / 60), $estimator->time % 60; 20 | 21 | __END__ 22 | -------------------------------------------------------------------------------- /utils/modifier_helpers/layer_generator.jscad: -------------------------------------------------------------------------------- 1 | // title: Layer_generator 2 | // written by: Joseph Lenox 3 | // Used for generating cubes oriented about the center 4 | // for making simple modifier meshes. 5 | 6 | var width = 100; 7 | var layer_height = 0.3; 8 | var z = 30; 9 | function main() { 10 | 11 | return cube(size=[width,width,layer_height], center=true).translate([0,0,z]); 12 | } 13 | function getParameterDefinitions() { 14 | return [ 15 | { name: 'width', type: 'float', initial: 100, caption: "Width of the cube:" }, 16 | { name: 'layer_height', type: 'float', initial: 0.3, caption: "Layer height used:" }, 17 | { name: 'z', type: 'float', initial: 0, caption: "Z:" } 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /utils/modifier_helpers/solid_layers.scad: -------------------------------------------------------------------------------- 1 | // Used to generate a modifier mesh to do something every few layers. 2 | // Load into OpenSCAD, tweak the variables below, export as STL and load as 3 | // a modifier mesh. Then change settings for the modifier mesh. 4 | 5 | // Written by Joseph Lenox; in public domain. 6 | 7 | layer_height = 0.3; // set to layer height in slic3r for "best" results. 8 | number_of_solid_layers = 2; 9 | N = 4; // N > number_of_solid_layers or else the whole thing will be solid 10 | model_height = 300.0; 11 | model_width = 300.0; // these two should be at least as big as the model 12 | model_depth = 300.0; // but bigger isn't a problem 13 | initial_offset=0; // don't generate below this 14 | 15 | position_on_bed=[0,0,0]; // in case you need to move it around 16 | 17 | // don't touch below unless you know what you are doing. 18 | simple_layers = round(model_height/layer_height); 19 | translate(position_on_bed) 20 | for (i = [initial_offset:N:simple_layers]) { 21 | translate([0,0,i*layer_height]) 22 | translate([0,0,(layer_height*number_of_solid_layers)/2]) 23 | cube([model_width,model_depth,layer_height*number_of_solid_layers], center=true); 24 | } 25 | -------------------------------------------------------------------------------- /utils/post-processing/decimate.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i~ 2 | 3 | use strict; 4 | use warnings; 5 | 6 | my %lastpos = (X => 10000, Y => 10000, Z => 10000, E => 10000, F => 10000); 7 | my %pos = (X => 0, Y => 0, Z => 0, E => 0, F => 0); 8 | 9 | my $mindist = 0.33; 10 | 11 | my $mindistz = 0.005; 12 | 13 | my $mindistsq = $mindist * $mindist; 14 | 15 | sub dist { 16 | my $sq = 0; 17 | for (qw/X Y Z E/) { 18 | $sq += ($pos{$_} - $lastpos{$_}) ** 2; 19 | } 20 | return $sq; 21 | } 22 | 23 | while (<>) { 24 | if (m#\bG[01]\b#) { 25 | while (m#([XYZEF])(\d+(\.\d+)?)#gi) { 26 | $pos{uc $1} = $2; 27 | } 28 | if ( 29 | ( 30 | /X/ && 31 | /Y/ && 32 | (dist() >= $mindistsq) 33 | ) || 34 | (abs($pos{Z} - $lastpos{Z}) > $mindistz) || 35 | (!/X/ || !/Y/) 36 | ) { 37 | print; 38 | %lastpos = %pos; 39 | } 40 | elsif (($pos{F} - $lastpos{F}) != 0) { 41 | printf "G1 F%s\n", $pos{F}; 42 | $lastpos{F} = $pos{F}; 43 | } 44 | } 45 | else { 46 | if (m#\bG92\b#) { 47 | while (m#([XYZEF])(\d+(\.\d+)?)#gi) { 48 | $lastpos{uc $1} = $2; 49 | } 50 | } 51 | print; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /utils/post-processing/fan_kickstart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import sys 3 | import re 4 | 5 | sea = re.compile("M106 S[1-9]+[0-9]*") 6 | rep = re.compile("M106 S255\n\g<0>") 7 | out = open(sys.argv[1]+"_fixed", 'w') 8 | with open(sys.argv[1]) as f: 9 | for r in f: 10 | if re.search(sea, r) is not None: 11 | out.write(re.sub(sea,"M106 S255\n\g<0>",r)) 12 | else: 13 | out.write(r) 14 | -------------------------------------------------------------------------------- /utils/post-processing/filament-weight.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i 2 | # 3 | # Post-processing script for adding weight and cost of required 4 | # filament to G-code output. 5 | 6 | use strict; 7 | use warnings; 8 | 9 | # example densities, adjust according to filament specifications 10 | use constant PLA_P => 1.25; # g/cm3 11 | use constant ABS_P => 1.05; # g/cm3 12 | 13 | # example costs, adjust according to filament prices 14 | use constant PLA_PRICE => 0.05; # EUR/g 15 | use constant ABS_PRICE => 0.02; # EUR/g 16 | use constant CURRENCY => "EUR"; 17 | 18 | while (<>) { 19 | if (/^(;\s+filament\s+used\s+=\s.*\((\d+(?:\.\d+)?)cm3)\)/) { 20 | my $pla_weight = $2 * PLA_P; 21 | my $abs_weight = $2 * ABS_P; 22 | 23 | my $pla_costs = $pla_weight * PLA_PRICE; 24 | my $abs_costs = $abs_weight * ABS_PRICE; 25 | 26 | printf "%s or %.2fg PLA/%.2fg ABS)\n", $1, $pla_weight, $abs_weight; 27 | printf "; costs = %s %.2f (PLA), %s %.2f (ABS)\n", CURRENCY, $pla_costs, CURRENCY, $abs_costs; 28 | } else { 29 | print; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /utils/post-processing/flowrate.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i 2 | 3 | # 4 | # Post-processing script for calculating flow rate for each move 5 | 6 | use strict; 7 | use warnings; 8 | 9 | use constant PI => 3.141592653589793238; 10 | my @filament_diameter = split /,/, $ENV{SLIC3R_FILAMENT_DIAMETER}; 11 | 12 | my $E = 0; 13 | my $T = 0; 14 | my ($X, $Y, $F); 15 | while (<>) { 16 | if (/^G1.*? F([0-9.]+)/) { 17 | $F = $1; 18 | } 19 | if (/^G1 X([0-9.-]+) Y([0-9.-]+).*? E([0-9.-]+)/) { 20 | my ($x, $y, $e) = ($1, $2, $3); 21 | my $e_length = $e - $E; 22 | if ($e_length > 0 && defined $X && defined $Y) { 23 | my $dist = sqrt( (($x-$X)**2) + (($y-$Y)**2) ); 24 | if ($dist > 0) { 25 | my $mm_per_mm = $e_length / $dist; # dE/dXY 26 | my $mm3_per_mm = (($filament_diameter[$T] // 0) ** 2) * PI/4 * $mm_per_mm; 27 | my $vol_speed = $F/60 * $mm3_per_mm; 28 | my $comment = sprintf ' ; dXY = %.3fmm ; dE = %.5fmm ; dE/XY = %.5fmm/mm; volspeed = %.5fmm^3/sec', 29 | $dist, $e_length, $mm_per_mm, $vol_speed; 30 | s/(\R+)/$comment$1/; 31 | } 32 | } 33 | $E = $e; 34 | $X = $x; 35 | $Y = $y; 36 | } 37 | if (/^G1 X([0-9.]+) Y([0-9.]+)/) { 38 | $X = $1; 39 | $Y = $2; 40 | } 41 | if (/^G1.*? E([0-9.]+)/) { 42 | $E = $1; 43 | } 44 | if (/^G92 E0/) { 45 | $E = 0; 46 | } 47 | if (/^T(\d+)/) { 48 | $T = $1; 49 | } 50 | print; 51 | } 52 | 53 | __END__ 54 | -------------------------------------------------------------------------------- /utils/post-processing/prowl-notification.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Example post-processing script for sending a Prowl notification upon 4 | # completion. See http://www.prowlapp.com/ for more info. 5 | 6 | use strict; 7 | use warnings; 8 | 9 | use File::Basename qw(basename); 10 | use WebService::Prowl; 11 | 12 | # set your Prowl API key here 13 | my $apikey = ''; 14 | 15 | my $file = basename $ARGV[0]; 16 | my $prowl = WebService::Prowl->new(apikey => $apikey); 17 | my %options = (application => 'Slic3r', 18 | event =>'Slicing Done!', 19 | description => "$file was successfully generated"); 20 | printf STDERR "Error sending Prowl notification: %s\n", $prowl->error 21 | unless $prowl->add(%options); 22 | -------------------------------------------------------------------------------- /utils/post-processing/strip-toolchange.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i 2 | # 3 | # Remove all toolchange commands (and T# arguments) from gcode. 4 | 5 | use strict; 6 | use warnings; 7 | 8 | # read stdin and any/all files passed as parameters one line at a time 9 | while (<>) { 10 | if (not /^T[0-9]/) { 11 | s/\s*(T[0-9])//; 12 | print; 13 | } else { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /utils/post-processing/z-every-line.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i 2 | 3 | use strict; 4 | use warnings; 5 | 6 | my $z = 0; 7 | 8 | # read stdin and any/all files passed as parameters one line at a time 9 | while (<>) { 10 | # if we find a Z word, save it 11 | $z = $1 if /Z\s*(\d+(\.\d+)?)/; 12 | 13 | # if we don't have Z, but we do have X and Y 14 | if (!/Z/ && /X/ && /Y/ && $z > 0) { 15 | # chop off the end of the line (incl. comments), saving chopped section in $1 16 | s/\s*([\r\n\;\(].*)/" Z$z $1"/es; 17 | # print start of line, insert our Z value then re-add the chopped end of line 18 | # print "$_ Z$z $1"; 19 | } 20 | #else { 21 | # nothing interesting, print line as-is 22 | print or die $!; 23 | #} 24 | } 25 | -------------------------------------------------------------------------------- /utils/send-gcode.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | BEGIN { 7 | use FindBin; 8 | use lib "$FindBin::Bin/../lib"; 9 | use local::lib "$FindBin::Bin/../local-lib"; 10 | } 11 | 12 | use Slic3r; 13 | 14 | die "Usage: send-gcode.pl SERIALPORT BAUDRATE GCODE_FILE\n" 15 | if @ARGV != 3; 16 | 17 | my $serial = Slic3r::GCode::Sender->new; 18 | $serial->connect($ARGV[0], $ARGV[1]); 19 | 1 until $serial->is_connected; 20 | print "Connected to printer\n"; 21 | 22 | { 23 | local $/ = "\n"; 24 | Slic3r::open(\my $fh, '<', $ARGV[2]) 25 | or die "Unable to open $ARGV[2]: $!\n"; 26 | binmode $fh, ':utf8'; 27 | while (<$fh>) { 28 | $serial->send($_); 29 | } 30 | close $fh; 31 | } 32 | 33 | while ((my $queue_size = $serial->queue_size) > 0) { 34 | printf "Queue size: %d\n", $queue_size; 35 | } 36 | $serial->disconnect; 37 | 38 | __END__ 39 | -------------------------------------------------------------------------------- /utils/split_stl.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script splits a STL plate into individual files 3 | 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | use FindBin; 9 | use lib "$FindBin::Bin/../lib"; 10 | use local::lib "$FindBin::Bin/../local-lib"; 11 | } 12 | 13 | use File::Basename qw(basename); 14 | use Getopt::Long qw(:config no_auto_abbrev); 15 | use Slic3r; 16 | $|++; 17 | 18 | my %opt = (); 19 | { 20 | my %options = ( 21 | 'help' => sub { usage() }, 22 | 'ascii' => \$opt{ascii}, 23 | ); 24 | GetOptions(%options) or usage(1); 25 | $ARGV[0] or usage(1); 26 | } 27 | 28 | { 29 | my $model = Slic3r::Model->read_from_file($ARGV[0]); 30 | my $basename = $ARGV[0]; 31 | $basename =~ s/\.stl$//i; 32 | 33 | my $part_count = 0; 34 | my $mesh = $model->objects->[0]->volumes->[0]->mesh; 35 | foreach my $new_mesh (@{$mesh->split}) { 36 | $new_mesh->repair; 37 | 38 | my $new_model = Slic3r::Model->new; 39 | $new_model 40 | ->add_object() 41 | ->add_volume(mesh => $new_mesh); 42 | 43 | $new_model->add_default_instances; 44 | 45 | my $output_file = sprintf '%s_%02d.stl', $basename, ++$part_count; 46 | printf "Writing to %s\n", basename($output_file); 47 | $new_model->write_stl($output_file, !$opt{ascii}); 48 | } 49 | } 50 | 51 | 52 | sub usage { 53 | my ($exit_code) = @_; 54 | 55 | print <<"EOF"; 56 | Usage: split_stl.pl [ OPTIONS ] file.stl 57 | 58 | --help Output this usage screen and exit 59 | --ascii Generate ASCII STL files (default: binary) 60 | 61 | EOF 62 | exit ($exit_code || 0); 63 | } 64 | 65 | __END__ 66 | -------------------------------------------------------------------------------- /utils/stl-to-amf.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script converts a STL file to AMF 3 | 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | use FindBin; 9 | use lib "$FindBin::Bin/../lib"; 10 | use local::lib "$FindBin::Bin/../local-lib"; 11 | } 12 | 13 | use File::Basename qw(basename); 14 | use Getopt::Long qw(:config no_auto_abbrev); 15 | use Slic3r; 16 | $|++; 17 | 18 | my %opt = (); 19 | { 20 | my %options = ( 21 | 'help' => sub { usage() }, 22 | 'distinct-materials' => \$opt{distinct_materials}, 23 | ); 24 | GetOptions(%options) or usage(1); 25 | $ARGV[0] or usage(1); 26 | } 27 | 28 | { 29 | my @models = map Slic3r::Model->read_from_file($_), @ARGV; 30 | my $output_file = $ARGV[0]; 31 | $output_file =~ s/\.stl$/.amf.xml/i; 32 | 33 | my $new_model = Slic3r::Model->new; 34 | 35 | if ($opt{distinct_materials} && @models > 1) { 36 | my $new_object = $new_model->add_object; 37 | for my $m (0 .. $#models) { 38 | my $model = $models[$m]; 39 | $new_model->set_material($m, { Name => basename($ARGV[$m]) }); 40 | $new_object->add_volume( 41 | material_id => $m, 42 | facets => $model->objects->[0]->volumes->[0]->facets, 43 | vertices => $model->objects->[0]->vertices, 44 | ); 45 | } 46 | } else { 47 | foreach my $model (@models) { 48 | $new_model->add_object( 49 | vertices => $model->objects->[0]->vertices, 50 | )->add_volume( 51 | facets => $model->objects->[0]->volumes->[0]->facets, 52 | ); 53 | } 54 | } 55 | 56 | printf "Writing to %s\n", basename($output_file); 57 | $new_model->write_amf($output_file); 58 | } 59 | 60 | 61 | sub usage { 62 | my ($exit_code) = @_; 63 | 64 | print <<"EOF"; 65 | Usage: amf-to-stl.pl [ OPTIONS ] file.stl [ file2.stl [ file3.stl ] ] 66 | 67 | --help Output this usage screen and exit 68 | --distinct-materials Assign each STL file to a different material 69 | 70 | EOF 71 | exit ($exit_code || 0); 72 | } 73 | 74 | __END__ 75 | -------------------------------------------------------------------------------- /utils/view-mesh.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This script displays 3D preview of a mesh 3 | 4 | use strict; 5 | use warnings; 6 | 7 | BEGIN { 8 | use FindBin; 9 | use lib "$FindBin::Bin/../lib"; 10 | use local::lib "$FindBin::Bin/../local-lib"; 11 | } 12 | 13 | use Getopt::Long qw(:config no_auto_abbrev); 14 | use Slic3r; 15 | use Slic3r::Geometry qw(Z); 16 | use Slic3r::GUI; 17 | use Slic3r::GUI::3DScene; 18 | $|++; 19 | 20 | my %opt = (); 21 | { 22 | my %options = ( 23 | 'help' => sub { usage() }, 24 | 'cut=f' => \$opt{cut}, 25 | 'enable-moving' => \$opt{enable_moving}, 26 | ); 27 | GetOptions(%options) or usage(1); 28 | $ARGV[0] or usage(1); 29 | } 30 | 31 | { 32 | my $model = Slic3r::Model->read_from_file($ARGV[0]); 33 | 34 | # make sure all objects have at least one defined instance 35 | $model->add_default_instances; 36 | $_->center_around_origin for @{$model->objects}; # and align to Z = 0 37 | 38 | my $app = Slic3r::ViewMesh->new; 39 | $app->{canvas}->enable_picking(1); 40 | $app->{canvas}->enable_moving($opt{enable_moving}); 41 | $app->{canvas}->load_object($model, 0); 42 | $app->{canvas}->set_auto_bed_shape; 43 | $app->{canvas}->zoom_to_volumes; 44 | $app->{canvas}->SetCuttingPlane(Z, $opt{cut}) if defined $opt{cut}; 45 | $app->MainLoop; 46 | } 47 | 48 | 49 | sub usage { 50 | my ($exit_code) = @_; 51 | 52 | print <<"EOF"; 53 | Usage: view-mesh.pl [ OPTIONS ] file.stl 54 | 55 | --help Output this usage screen and exit 56 | --cut Z Display the cutting plane at the given Z 57 | 58 | EOF 59 | exit ($exit_code || 0); 60 | } 61 | 62 | package Slic3r::ViewMesh; 63 | use Wx qw(:sizer); 64 | use base qw(Wx::App); 65 | 66 | sub OnInit { 67 | my $self = shift; 68 | 69 | my $frame = Wx::Frame->new(undef, -1, 'Mesh Viewer', [-1, -1], [500, 400]); 70 | my $panel = Wx::Panel->new($frame, -1); 71 | 72 | $self->{canvas} = Slic3r::GUI::3DScene->new($panel); 73 | 74 | my $sizer = Wx::BoxSizer->new(wxVERTICAL); 75 | $sizer->Add($self->{canvas}, 1, wxEXPAND, 0); 76 | $panel->SetSizer($sizer); 77 | $sizer->SetSizeHints($panel); 78 | 79 | $frame->Show(1); 80 | } 81 | 82 | __END__ 83 | -------------------------------------------------------------------------------- /utils/zsh/README.markdown: -------------------------------------------------------------------------------- 1 | # ZSH Completions for Slic3r 2 | 3 | To enable zsh(1) completions for Slic3r, add the following to your 4 | ``~/.zshrc`` file, replacing ``/path/to/Slic3r/`` with the actual path 5 | to your Slic3r directory: 6 | 7 | typeset -U fpath 8 | 9 | if [[ -d /path/to/Slic3r/utils/zsh/functions ]]; then 10 | fpath=(/path/to/Slic3r/utils/zsh/functions $fpath) 11 | fi 12 | 13 | autoload -Uz compinit 14 | compinit 15 | zstyle ':completion:*' verbose true 16 | zstyle ':completion:*:descriptions' format '%B%d%b' 17 | zstyle ':completion:*:messages' format '%d' 18 | zstyle ':completion:*:warnings' format 'No matches for %d' 19 | zstyle ':completion:*' group-name '%d' 20 | 21 | See the zshcompsys(1) man page for further details. 22 | -------------------------------------------------------------------------------- /var/Slic3r.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r.icns -------------------------------------------------------------------------------- /var/Slic3r.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r.ico -------------------------------------------------------------------------------- /var/Slic3r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r.png -------------------------------------------------------------------------------- /var/Slic3r_128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r_128px.png -------------------------------------------------------------------------------- /var/Slic3r_192px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r_192px.png -------------------------------------------------------------------------------- /var/Slic3r_192px_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/Slic3r_192px_transparent.png -------------------------------------------------------------------------------- /var/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/add.png -------------------------------------------------------------------------------- /var/application_view_tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/application_view_tile.png -------------------------------------------------------------------------------- /var/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_down.png -------------------------------------------------------------------------------- /var/arrow_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_in.png -------------------------------------------------------------------------------- /var/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_left.png -------------------------------------------------------------------------------- /var/arrow_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_out.png -------------------------------------------------------------------------------- /var/arrow_redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_redo.png -------------------------------------------------------------------------------- /var/arrow_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_refresh.png -------------------------------------------------------------------------------- /var/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_right.png -------------------------------------------------------------------------------- /var/arrow_rotate_anticlockwise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_rotate_anticlockwise.png -------------------------------------------------------------------------------- /var/arrow_rotate_clockwise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_rotate_clockwise.png -------------------------------------------------------------------------------- /var/arrow_undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_undo.png -------------------------------------------------------------------------------- /var/arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/arrow_up.png -------------------------------------------------------------------------------- /var/box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/box.png -------------------------------------------------------------------------------- /var/brick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/brick.png -------------------------------------------------------------------------------- /var/brick_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/brick_add.png -------------------------------------------------------------------------------- /var/brick_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/brick_delete.png -------------------------------------------------------------------------------- /var/brick_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/brick_go.png -------------------------------------------------------------------------------- /var/bricks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bricks.png -------------------------------------------------------------------------------- /var/building.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/building.png -------------------------------------------------------------------------------- /var/bullet_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bullet_black.png -------------------------------------------------------------------------------- /var/bullet_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bullet_blue.png -------------------------------------------------------------------------------- /var/bullet_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bullet_green.png -------------------------------------------------------------------------------- /var/bullet_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bullet_red.png -------------------------------------------------------------------------------- /var/bullet_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/bullet_white.png -------------------------------------------------------------------------------- /var/cog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/cog.png -------------------------------------------------------------------------------- /var/cog_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/cog_go.png -------------------------------------------------------------------------------- /var/control_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_pause.png -------------------------------------------------------------------------------- /var/control_pause_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_pause_blue.png -------------------------------------------------------------------------------- /var/control_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_play.png -------------------------------------------------------------------------------- /var/control_play_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_play_blue.png -------------------------------------------------------------------------------- /var/control_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_stop.png -------------------------------------------------------------------------------- /var/control_stop_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/control_stop_blue.png -------------------------------------------------------------------------------- /var/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/cross.png -------------------------------------------------------------------------------- /var/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/delete.png -------------------------------------------------------------------------------- /var/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/disk.png -------------------------------------------------------------------------------- /var/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/error.png -------------------------------------------------------------------------------- /var/film.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/film.png -------------------------------------------------------------------------------- /var/funnel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/funnel.png -------------------------------------------------------------------------------- /var/hourglass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/hourglass.png -------------------------------------------------------------------------------- /var/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/house.png -------------------------------------------------------------------------------- /var/infill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/infill.png -------------------------------------------------------------------------------- /var/joystick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/joystick.png -------------------------------------------------------------------------------- /var/layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/layers.png -------------------------------------------------------------------------------- /var/lorry_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/lorry_add.png -------------------------------------------------------------------------------- /var/lorry_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/lorry_go.png -------------------------------------------------------------------------------- /var/lorry_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/lorry_import.png -------------------------------------------------------------------------------- /var/map_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/map_add.png -------------------------------------------------------------------------------- /var/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/note.png -------------------------------------------------------------------------------- /var/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/package.png -------------------------------------------------------------------------------- /var/package_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/package_green.png -------------------------------------------------------------------------------- /var/page_white_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/page_white_go.png -------------------------------------------------------------------------------- /var/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/plugin.png -------------------------------------------------------------------------------- /var/plugin_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/plugin_add.png -------------------------------------------------------------------------------- /var/plugin_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/plugin_go.png -------------------------------------------------------------------------------- /var/printer_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/printer_empty.png -------------------------------------------------------------------------------- /var/script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/script.png -------------------------------------------------------------------------------- /var/shape_flip_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/shape_flip_horizontal.png -------------------------------------------------------------------------------- /var/shape_handles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/shape_handles.png -------------------------------------------------------------------------------- /var/shape_ungroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/shape_ungroup.png -------------------------------------------------------------------------------- /var/spool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/spool.png -------------------------------------------------------------------------------- /var/tag_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/tag_blue.png -------------------------------------------------------------------------------- /var/textfield.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/textfield.png -------------------------------------------------------------------------------- /var/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/tick.png -------------------------------------------------------------------------------- /var/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/time.png -------------------------------------------------------------------------------- /var/variable_layer_height.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/variable_layer_height.png -------------------------------------------------------------------------------- /var/wand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/wand.png -------------------------------------------------------------------------------- /var/wrench.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/wrench.png -------------------------------------------------------------------------------- /var/zoom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/zoom.png -------------------------------------------------------------------------------- /var/zoom_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/zoom_in.png -------------------------------------------------------------------------------- /var/zoom_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/var/zoom_out.png -------------------------------------------------------------------------------- /xs/MANIFEST.SKIP: -------------------------------------------------------------------------------- 1 | 2 | #!start included /Library/Perl/Updates/5.12.4/ExtUtils/MANIFEST.SKIP 3 | # Avoid version control files. 4 | \bRCS\b 5 | \bCVS\b 6 | \bSCCS\b 7 | ,v$ 8 | \B\.svn\b 9 | \B\.git\b 10 | \B\.gitignore\b 11 | \b_darcs\b 12 | \B\.cvsignore$ 13 | 14 | # Avoid VMS specific MakeMaker generated files 15 | \bDescrip.MMS$ 16 | \bDESCRIP.MMS$ 17 | \bdescrip.mms$ 18 | 19 | # Avoid Makemaker generated and utility files. 20 | \bMANIFEST\.bak 21 | \bMakefile$ 22 | \bblib/ 23 | \bMakeMaker-\d 24 | \bpm_to_blib\.ts$ 25 | \bpm_to_blib$ 26 | \bblibdirs\.ts$ # 6.18 through 6.25 generated this 27 | 28 | # Avoid Module::Build generated and utility files. 29 | \bBuild$ 30 | \b_build/ 31 | \bBuild.bat$ 32 | \bBuild.COM$ 33 | \bBUILD.COM$ 34 | \bbuild.com$ 35 | 36 | # Avoid temp and backup files. 37 | ~$ 38 | \.old$ 39 | \#$ 40 | \b\.# 41 | \.bak$ 42 | \.tmp$ 43 | \.# 44 | \.rej$ 45 | 46 | # Avoid OS-specific files/dirs 47 | # Mac OSX metadata 48 | \B\.DS_Store 49 | # Mac OSX SMB mount metadata files 50 | \B\._ 51 | 52 | # Avoid Devel::Cover and Devel::CoverX::Covered files. 53 | \bcover_db\b 54 | \bcovered\b 55 | 56 | # Avoid MYMETA files 57 | ^MYMETA\. 58 | #!end included /Library/Perl/Updates/5.12.4/ExtUtils/MANIFEST.SKIP 59 | 60 | # Avoid configuration metadata file 61 | ^MYMETA\. 62 | 63 | # Avoid Module::Build generated and utility files. 64 | \bBuild$ 65 | \bBuild.bat$ 66 | \b_build 67 | \bBuild.COM$ 68 | \bBUILD.COM$ 69 | \bbuild.com$ 70 | ^MANIFEST\.SKIP 71 | 72 | # Avoid archives of this distribution 73 | \bSlic3r-XS-[\d\.\_]+ 74 | 75 | ^assertlib 76 | -------------------------------------------------------------------------------- /xs/src/BSpline/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 1998-2009,2015 2 | University Corporation for Atmospheric Research, UCAR 3 | All rights reserved. 4 | 5 | This software is licensed with the standard BSD license: 6 | 7 | http://www.opensource.org/licenses/bsd-license.html 8 | 9 | When citing this software, here is a suggested reference: 10 | 11 | This software is written by Gary Granger of the National Center for 12 | Atmospheric Research (NCAR), sponsored by the National Science Foundation 13 | (NSF). The algorithm is based on the cubic spline described by Katsuyuki 14 | Ooyama in Montly Weather Review, Vol 115, October 1987. This 15 | implementation has benefited from comparisons with a previous FORTRAN 16 | implementation by James L. Franklin, NOAA/Hurricane Research Division. 17 | 18 | The text of the license is reproduced below: 19 | 20 | Redistribution and use in source and binary forms, with or without 21 | modification, are permitted provided that the following conditions are met: 22 | 23 | * Redistributions of source code must retain the above copyright 24 | notice, this list of conditions and the following disclaimer. 25 | 26 | * Redistributions in binary form must reproduce the above copyright 27 | notice, this list of conditions and the following disclaimer in the 28 | documentation and/or other materials provided with the distribution. 29 | 30 | * Neither the name of the UCAR nor the names of its contributors may be 31 | used to endorse or promote products derived from this software 32 | without specific prior written permission. 33 | 34 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 38 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 39 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 42 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 43 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44 | POSSIBILITY OF SUCH DAMAGE. 45 | -------------------------------------------------------------------------------- /xs/src/Zip/ZipArchive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ZipArchive.hpp" 3 | 4 | namespace Slic3r { 5 | 6 | ZipArchive::ZipArchive (std::string zip_archive_name, char zip_mode) : archive(mz_zip_archive()), zip_name(zip_archive_name), mode(zip_mode), stats(0), finalized(false) 7 | { 8 | // Initialize the miniz zip archive struct. 9 | memset(&archive, 0, sizeof(archive)); 10 | 11 | if( mode == 'W'){ 12 | stats = mz_zip_writer_init_file(&archive, zip_name.c_str(), 0); 13 | } else if (mode == 'R') { 14 | stats = mz_zip_reader_init_file(&archive, zip_name.c_str(), 0); 15 | } else { 16 | std::cout << "Error:: Unknown zip mode" << std::endl; 17 | } 18 | } 19 | 20 | mz_bool 21 | ZipArchive::z_stats() 22 | { 23 | return stats; 24 | } 25 | 26 | mz_bool 27 | ZipArchive::add_entry (std::string entry_path, std::string file_path) 28 | { 29 | stats = 0; 30 | // Check if it's in the write mode. 31 | if(mode != 'W') 32 | return stats; 33 | stats = mz_zip_writer_add_file(&archive, entry_path.c_str(), file_path.c_str(), nullptr, 0, ZIP_DEFLATE_COMPRESSION); 34 | return stats; 35 | } 36 | 37 | mz_bool 38 | ZipArchive::extract_entry (std::string entry_path, std::string file_path) 39 | { 40 | stats = 0; 41 | // Check if it's in the read mode. 42 | if (mode != 'R') 43 | return stats; 44 | stats = mz_zip_reader_extract_file_to_file(&archive, entry_path.c_str(), file_path.c_str(), 0); 45 | return stats; 46 | } 47 | 48 | mz_bool 49 | ZipArchive::finalize() 50 | { 51 | stats = 0; 52 | // Finalize the archive and end writing if it's in the write mode. 53 | if(mode == 'W') { 54 | stats = mz_zip_writer_finalize_archive(&archive); 55 | stats |= mz_zip_writer_end(&archive); 56 | } else if (mode == 'R'){ 57 | stats = mz_zip_reader_end(&archive); 58 | } 59 | if(stats) 60 | finalized = true; 61 | return stats; 62 | } 63 | 64 | ZipArchive::~ZipArchive() { 65 | if(!finalized) 66 | this->finalize(); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /xs/src/Zip/ZipArchive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SLIC3R_ZIPARCHIVE_H 2 | #define SLIC3R_ZIPARCHIVE_H 3 | 4 | #define MINIZ_HEADER_FILE_ONLY 5 | #define ZIP_DEFLATE_COMPRESSION 8 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Slic3r { 12 | 13 | /// A zip wrapper for Miniz lib. 14 | class ZipArchive 15 | { 16 | public: 17 | 18 | /// Create a zip archive. 19 | /// \param zip_archive_name string the name of the zip file. 20 | /// \param zip_mode char the zip archive mode ('R' means read mode, 'W' means write mode). you cannot change the mode for the current object. 21 | ZipArchive(std::string zip_archive_name, char zip_mode); 22 | 23 | /// Get the status of the previous operation applied on the zip_archive. 24 | /// \return mz_bool 0: failure 1: success. 25 | mz_bool z_stats(); 26 | 27 | /// Add a file to the current zip archive. 28 | /// \param entry_path string the path of the entry in the zip archive. 29 | /// \param file_path string the path of the file in the disk. 30 | /// \return mz_bool 0: failure 1: success. 31 | mz_bool add_entry (std::string entry_path, std::string file_path); 32 | 33 | /// Extract a zip entry to a file on the disk. 34 | /// \param entry_path string the path of the entry in the zip archive. 35 | /// \param file_path string the path of the file in the disk. 36 | /// \return mz_bool 0: failure 1: success. 37 | mz_bool extract_entry (std::string entry_path, std::string file_path); 38 | 39 | /// Finalize the archive and free any allocated memory. 40 | /// \return mz_bool 0: failure 1: success. 41 | mz_bool finalize(); 42 | 43 | ~ZipArchive(); 44 | 45 | private: 46 | mz_zip_archive archive; ///< Miniz zip archive struct. 47 | const std::string zip_name; ///< The zip file name. 48 | const char mode; ///< The zip mode either read or write. 49 | mz_bool stats; ///< The status of the recently executed operation on the zip archive. 50 | bool finalized; ///< Whether the zip archive is finalized or not. Used during the destructor of the object. 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif //SLIC3R_ZIPARCHIVE_H 57 | -------------------------------------------------------------------------------- /xs/src/boost/nowide/config.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 Artyom Beilis (Tonkikh) 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | #ifndef BOOST_NOWIDE_CONFIG_HPP_INCLUDED 9 | #define BOOST_NOWIDE_CONFIG_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #ifndef BOOST_SYMBOL_VISIBLE 14 | # define BOOST_SYMBOL_VISIBLE 15 | #endif 16 | 17 | #ifdef BOOST_HAS_DECLSPEC 18 | # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK) 19 | # ifdef BOOST_NOWIDE_SOURCE 20 | # define BOOST_NOWIDE_DECL BOOST_SYMBOL_EXPORT 21 | # else 22 | # define BOOST_NOWIDE_DECL BOOST_SYMBOL_IMPORT 23 | # endif // BOOST_NOWIDE_SOURCE 24 | # endif // DYN_LINK 25 | #endif // BOOST_HAS_DECLSPEC 26 | 27 | #ifndef BOOST_NOWIDE_DECL 28 | # define BOOST_NOWIDE_DECL 29 | #endif 30 | 31 | // 32 | // Automatically link to the correct build variant where possible. 33 | // 34 | #if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NOWIDE_NO_LIB) && !defined(BOOST_NOWIDE_SOURCE) 35 | // 36 | // Set the name of our library, this will get undef'ed by auto_link.hpp 37 | // once it's done with it: 38 | // 39 | #define BOOST_LIB_NAME boost_nowide 40 | // 41 | // If we're importing code from a dll, then tell auto_link.hpp about it: 42 | // 43 | #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK) 44 | # define BOOST_DYN_LINK 45 | #endif 46 | // 47 | // And include the header that does the work: 48 | // 49 | #include 50 | #endif // auto-linking disabled 51 | 52 | 53 | #endif // boost/nowide/config.hpp 54 | // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -------------------------------------------------------------------------------- /xs/src/boost/nowide/cstdlib.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 Artyom Beilis (Tonkikh) 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | #ifndef BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED 9 | #define BOOST_NOWIDE_CSTDLIB_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #endif 15 | /// 16 | // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 17 | -------------------------------------------------------------------------------- /xs/src/boost/nowide/integration/filesystem.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 Artyom Beilis (Tonkikh) 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | #ifndef BOOST_NOWIDE_INTEGRATION_FILESYSTEM_HPP_INCLUDED 9 | #define BOOST_NOWIDE_INTEGRATION_FILESYSTEM_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | namespace boost { 14 | namespace nowide { 15 | /// 16 | /// Instal utf8_codecvt facet into boost::filesystem::path such all char strings are interpreted as utf-8 strings 17 | /// 18 | inline void nowide_filesystem() 19 | { 20 | std::locale tmp = std::locale(std::locale(),new boost::nowide::utf8_codecvt()); 21 | boost::filesystem::path::imbue(tmp); 22 | } 23 | } // nowide 24 | } // boost 25 | 26 | #endif 27 | /// 28 | // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 29 | -------------------------------------------------------------------------------- /xs/src/boost/nowide/system.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 Artyom Beilis (Tonkikh) 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | #ifndef BOOST_NOWIDE_CSTDLIB_HPP 9 | #define BOOST_NOWIDE_CSTDLIB_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | namespace boost { 15 | namespace nowide { 16 | 17 | #if !defined(BOOST_WINDOWS) && !defined(BOOST_NOWIDE_DOXYGEN) 18 | 19 | using ::system; 20 | 21 | #else // Windows 22 | 23 | /// 24 | /// Same as std::system but cmd is UTF-8. 25 | /// 26 | /// If the input is not valid UTF-8, -1 returned and errno set to EINVAL 27 | /// 28 | inline int system(char const *cmd) 29 | { 30 | if(!cmd) 31 | return _wsystem(0); 32 | wstackstring wcmd; 33 | if(!wcmd.convert(cmd)) { 34 | errno = EINVAL; 35 | return -1; 36 | } 37 | return _wsystem(wcmd.c_str()); 38 | } 39 | 40 | #endif 41 | } // nowide 42 | } // namespace boost 43 | 44 | #endif 45 | /// 46 | // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 47 | -------------------------------------------------------------------------------- /xs/src/boost/nowide/windows.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 Artyom Beilis (Tonkikh) 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | // 8 | #ifndef BOOST_NOWIDE_WINDOWS_HPP_INCLUDED 9 | #define BOOST_NOWIDE_WINDOWS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #ifdef BOOST_NOWIDE_USE_WINDOWS_H 14 | #include 15 | #else 16 | 17 | // 18 | // These are function prototypes... Allow to to include windows.h 19 | // 20 | extern "C" { 21 | 22 | __declspec(dllimport) wchar_t* __stdcall GetEnvironmentStringsW(void); 23 | __declspec(dllimport) int __stdcall FreeEnvironmentStringsW(wchar_t *); 24 | __declspec(dllimport) wchar_t* __stdcall GetCommandLineW(void); 25 | __declspec(dllimport) wchar_t** __stdcall CommandLineToArgvW(wchar_t const *,int *); 26 | __declspec(dllimport) unsigned long __stdcall GetLastError(); 27 | __declspec(dllimport) void* __stdcall LocalFree(void *); 28 | __declspec(dllimport) int __stdcall SetEnvironmentVariableW(wchar_t const *,wchar_t const *); 29 | __declspec(dllimport) unsigned long __stdcall GetEnvironmentVariableW(wchar_t const *,wchar_t *,unsigned long); 30 | 31 | } 32 | 33 | #endif 34 | 35 | 36 | 37 | #endif 38 | /// 39 | // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 40 | -------------------------------------------------------------------------------- /xs/src/clipper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/src/clipper.cpp -------------------------------------------------------------------------------- /xs/src/expat/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper 2 | Copyright (c) 2001-2016 Expat maintainers 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /xs/src/expat/ascii.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 | See the file COPYING for copying permission. 3 | */ 4 | 5 | #define ASCII_A 0x41 6 | #define ASCII_B 0x42 7 | #define ASCII_C 0x43 8 | #define ASCII_D 0x44 9 | #define ASCII_E 0x45 10 | #define ASCII_F 0x46 11 | #define ASCII_G 0x47 12 | #define ASCII_H 0x48 13 | #define ASCII_I 0x49 14 | #define ASCII_J 0x4A 15 | #define ASCII_K 0x4B 16 | #define ASCII_L 0x4C 17 | #define ASCII_M 0x4D 18 | #define ASCII_N 0x4E 19 | #define ASCII_O 0x4F 20 | #define ASCII_P 0x50 21 | #define ASCII_Q 0x51 22 | #define ASCII_R 0x52 23 | #define ASCII_S 0x53 24 | #define ASCII_T 0x54 25 | #define ASCII_U 0x55 26 | #define ASCII_V 0x56 27 | #define ASCII_W 0x57 28 | #define ASCII_X 0x58 29 | #define ASCII_Y 0x59 30 | #define ASCII_Z 0x5A 31 | 32 | #define ASCII_a 0x61 33 | #define ASCII_b 0x62 34 | #define ASCII_c 0x63 35 | #define ASCII_d 0x64 36 | #define ASCII_e 0x65 37 | #define ASCII_f 0x66 38 | #define ASCII_g 0x67 39 | #define ASCII_h 0x68 40 | #define ASCII_i 0x69 41 | #define ASCII_j 0x6A 42 | #define ASCII_k 0x6B 43 | #define ASCII_l 0x6C 44 | #define ASCII_m 0x6D 45 | #define ASCII_n 0x6E 46 | #define ASCII_o 0x6F 47 | #define ASCII_p 0x70 48 | #define ASCII_q 0x71 49 | #define ASCII_r 0x72 50 | #define ASCII_s 0x73 51 | #define ASCII_t 0x74 52 | #define ASCII_u 0x75 53 | #define ASCII_v 0x76 54 | #define ASCII_w 0x77 55 | #define ASCII_x 0x78 56 | #define ASCII_y 0x79 57 | #define ASCII_z 0x7A 58 | 59 | #define ASCII_0 0x30 60 | #define ASCII_1 0x31 61 | #define ASCII_2 0x32 62 | #define ASCII_3 0x33 63 | #define ASCII_4 0x34 64 | #define ASCII_5 0x35 65 | #define ASCII_6 0x36 66 | #define ASCII_7 0x37 67 | #define ASCII_8 0x38 68 | #define ASCII_9 0x39 69 | 70 | #define ASCII_TAB 0x09 71 | #define ASCII_SPACE 0x20 72 | #define ASCII_EXCL 0x21 73 | #define ASCII_QUOT 0x22 74 | #define ASCII_AMP 0x26 75 | #define ASCII_APOS 0x27 76 | #define ASCII_MINUS 0x2D 77 | #define ASCII_PERIOD 0x2E 78 | #define ASCII_COLON 0x3A 79 | #define ASCII_SEMI 0x3B 80 | #define ASCII_LT 0x3C 81 | #define ASCII_EQUALS 0x3D 82 | #define ASCII_GT 0x3E 83 | #define ASCII_LSQB 0x5B 84 | #define ASCII_RSQB 0x5D 85 | #define ASCII_UNDERSCORE 0x5F 86 | #define ASCII_LPAREN 0x28 87 | #define ASCII_RPAREN 0x29 88 | #define ASCII_FF 0x0C 89 | #define ASCII_SLASH 0x2F 90 | #define ASCII_HASH 0x23 91 | #define ASCII_PIPE 0x7C 92 | #define ASCII_COMMA 0x2C 93 | -------------------------------------------------------------------------------- /xs/src/expat/asciitab.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 | See the file COPYING for copying permission. 3 | */ 4 | 5 | /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 6 | /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 7 | /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 8 | /* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML, 9 | /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 10 | /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 11 | /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 12 | /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 13 | /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 14 | /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 15 | /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 16 | /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 17 | /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 18 | /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 19 | /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 20 | /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 21 | /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 22 | /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 23 | /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 24 | /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 25 | /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 26 | /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 27 | /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 28 | /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 29 | /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 30 | /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 31 | /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 32 | /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 33 | /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 34 | /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 35 | /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 36 | /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, 37 | -------------------------------------------------------------------------------- /xs/src/expat/expat_config.h: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | ** Copyright 2000, Clark Cooper 3 | ** All rights reserved. 4 | ** 5 | ** This is free software. You are permitted to copy, distribute, or modify 6 | ** it under the terms of the MIT/X license (contained in the COPYING file 7 | ** with this distribution.) 8 | */ 9 | 10 | #ifndef EXPATCONFIG_H 11 | #define EXPATCONFIG_H 12 | 13 | #include 14 | #include 15 | 16 | #define XML_NS 1 17 | #define XML_DTD 1 18 | #define XML_CONTEXT_BYTES 1024 19 | 20 | /* we will assume all Windows platforms are little endian */ 21 | #define BYTEORDER 1234 22 | 23 | /* Windows has memmove() available. */ 24 | #define HAVE_MEMMOVE 25 | 26 | #ifdef WIN32 27 | #define WIN32_LEAN_AND_MEAN 28 | #include 29 | #undef WIN32_LEAN_AND_MEAN 30 | #else 31 | #endif 32 | 33 | #endif /* ifndef EXPATCONFIG_H */ 34 | -------------------------------------------------------------------------------- /xs/src/expat/iasciitab.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 | See the file COPYING for copying permission. 3 | */ 4 | 5 | /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ 6 | /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 7 | /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 8 | /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML, 9 | /* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML, 10 | /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 11 | /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 12 | /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 13 | /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 14 | /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM, 15 | /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS, 16 | /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS, 17 | /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, 18 | /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 19 | /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, 20 | /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI, 21 | /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, 22 | /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 23 | /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 24 | /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 25 | /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 26 | /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 27 | /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 28 | /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB, 29 | /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT, 30 | /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, 31 | /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, 32 | /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 33 | /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 34 | /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 35 | /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 36 | /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 37 | /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER, 38 | -------------------------------------------------------------------------------- /xs/src/expat/latin1tab.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 | See the file COPYING for copying permission. 3 | */ 4 | 5 | /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 6 | /* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 7 | /* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 8 | /* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 9 | /* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 10 | /* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 11 | /* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 12 | /* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 13 | /* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 14 | /* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 15 | /* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 16 | /* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 17 | /* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 18 | /* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME, 19 | /* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER, 20 | /* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, 21 | /* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 22 | /* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 23 | /* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 24 | /* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 25 | /* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 26 | /* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 27 | /* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 28 | /* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 29 | /* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 30 | /* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 31 | /* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 32 | /* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 33 | /* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 34 | /* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER, 35 | /* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 36 | /* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, 37 | -------------------------------------------------------------------------------- /xs/src/expat/utf8tab.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 2 | See the file COPYING for copying permission. 3 | */ 4 | 5 | 6 | /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 7 | /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 8 | /* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 9 | /* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 10 | /* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 11 | /* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 12 | /* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 13 | /* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 14 | /* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 15 | /* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 16 | /* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 17 | /* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 18 | /* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 19 | /* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 20 | /* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 21 | /* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, 22 | /* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 23 | /* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 24 | /* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 25 | /* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 26 | /* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 27 | /* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 28 | /* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 29 | /* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2, 30 | /* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 31 | /* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 32 | /* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 33 | /* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3, 34 | /* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4, 35 | /* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML, 36 | /* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, 37 | /* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM, 38 | -------------------------------------------------------------------------------- /xs/src/expat/xmltok_impl.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd 3 | See the file COPYING for copying permission. 4 | */ 5 | 6 | enum { 7 | BT_NONXML, 8 | BT_MALFORM, 9 | BT_LT, 10 | BT_AMP, 11 | BT_RSQB, 12 | BT_LEAD2, 13 | BT_LEAD3, 14 | BT_LEAD4, 15 | BT_TRAIL, 16 | BT_CR, 17 | BT_LF, 18 | BT_GT, 19 | BT_QUOT, 20 | BT_APOS, 21 | BT_EQUALS, 22 | BT_QUEST, 23 | BT_EXCL, 24 | BT_SOL, 25 | BT_SEMI, 26 | BT_NUM, 27 | BT_LSQB, 28 | BT_S, 29 | BT_NMSTRT, 30 | BT_COLON, 31 | BT_HEX, 32 | BT_DIGIT, 33 | BT_NAME, 34 | BT_MINUS, 35 | BT_OTHER, /* known not to be a name or name start character */ 36 | BT_NONASCII, /* might be a name or name start character */ 37 | BT_PERCNT, 38 | BT_LPAR, 39 | BT_RPAR, 40 | BT_AST, 41 | BT_PLUS, 42 | BT_COMMA, 43 | BT_VERBAR 44 | }; 45 | 46 | #include 47 | -------------------------------------------------------------------------------- /xs/src/libslic3r/BridgeDetector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_BridgeDetector_hpp_ 2 | #define slic3r_BridgeDetector_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "ExPolygon.hpp" 6 | #include "ExPolygonCollection.hpp" 7 | #include 8 | 9 | namespace Slic3r { 10 | 11 | class BridgeDetector { 12 | public: 13 | /// The non-grown hole. 14 | ExPolygon expolygon; 15 | /// Lower slices, all regions. 16 | ExPolygonCollection lower_slices; 17 | /// Scaled extrusion width of the infill. 18 | coord_t extrusion_width; 19 | /// Angle resolution for the brute force search of the best bridging angle. 20 | double resolution; 21 | /// The final optimal angle. 22 | double angle; 23 | 24 | BridgeDetector(const ExPolygon &_expolygon, const ExPolygonCollection &_lower_slices, coord_t _extrusion_width); 25 | bool detect_angle(); 26 | Polygons coverage() const; 27 | Polygons coverage(double angle) const; 28 | 29 | /// Return the bridge edges that are not currently supported but would permit use of the supplied 30 | /// bridge angle if it was supported. 31 | Polylines unsupported_edges(double angle = -1) const; 32 | 33 | private: 34 | /// Open lines representing the supporting edges. 35 | Polylines _edges; 36 | /// Closed polygons representing the supporting areas. 37 | ExPolygons _anchors; 38 | 39 | class BridgeDirection { 40 | public: 41 | BridgeDirection(double a = -1.) : angle(a), coverage(0.), max_length(0.) {} 42 | /// the best direction is the one causing most lines to be bridged (thus most coverage) 43 | bool operator<(const BridgeDirection &other) const { 44 | // Initial sort by coverage only - comparator must obey strict weak ordering 45 | return this->coverage > other.coverage; 46 | }; 47 | double angle; 48 | double coverage; 49 | double max_length; 50 | }; 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /xs/src/libslic3r/ConditionalGCode.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * https://github.com/alexrj/Slic3r/wiki/Conditional-Gcode-Syntax-Spec 3 | * 4 | */ 5 | 6 | #ifndef slic3r_ConditionalGcode_hpp_ 7 | #define slic3r_ConditionalGcode_hpp_ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | // Valid start tokens 15 | // {, {if 16 | // 17 | // Valid end tokens 18 | // } 19 | // 20 | // Special case: 21 | // 22 | // {if is special, it indicates that the rest of the line is dropped (ignored) if 23 | // it evaluates to False/0. 24 | 25 | namespace Slic3r { 26 | 27 | /// Recursive expression parser. Offloads mathematics to exprtk. 28 | /// Precondition: All strings inside {} are able to be understood by exprtk (and thus parsed to a number). 29 | /// Starts from the end of the string and works from the inside out. 30 | /// Any statements that resolve to {if0} will remove everything on the same line. 31 | std::string expression(const std::string& input, const int depth = 0); 32 | 33 | /// External access function to begin replac 34 | std::string apply_math(const std::string& input); 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /xs/src/libslic3r/ExPolygonCollection.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_ExPolygonCollection_hpp_ 2 | #define slic3r_ExPolygonCollection_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "ExPolygon.hpp" 6 | #include "Line.hpp" 7 | #include "Polyline.hpp" 8 | 9 | namespace Slic3r { 10 | 11 | class ExPolygonCollection; 12 | typedef std::vector ExPolygonCollections; 13 | 14 | class ExPolygonCollection 15 | { 16 | public: 17 | ExPolygons expolygons; 18 | 19 | ExPolygonCollection() {}; 20 | ExPolygonCollection(const ExPolygon &expolygon); 21 | ExPolygonCollection(const ExPolygons &expolygons) : expolygons(expolygons) {}; 22 | operator Points() const; 23 | operator Polygons() const; 24 | operator ExPolygons&(); 25 | void scale(double factor); 26 | void translate(double x, double y); 27 | void rotate(double angle, const Point ¢er); 28 | template bool contains(const T &item) const; 29 | bool contains_b(const Point &point) const; 30 | void simplify(double tolerance); 31 | Polygon convex_hull() const; 32 | Lines lines() const; 33 | Polygons contours() const; 34 | Polygons holes() const; 35 | void append(const ExPolygons &expolygons); 36 | }; 37 | 38 | inline ExPolygonCollection& 39 | operator <<(ExPolygonCollection &coll, const ExPolygons &expolygons) { 40 | coll.append(expolygons); 41 | return coll; 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Extruder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_Extruder_hpp_ 2 | #define slic3r_Extruder_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Point.hpp" 6 | #include "PrintConfig.hpp" 7 | 8 | namespace Slic3r { 9 | 10 | class Extruder 11 | { 12 | public: 13 | /// ID of current object. 14 | unsigned int id; 15 | double E; 16 | double absolute_E; 17 | double retracted; 18 | double restart_extra; 19 | double e_per_mm3; 20 | double retract_speed_mm_min; 21 | 22 | Extruder(unsigned int id, GCodeConfig *config); 23 | virtual ~Extruder() {} 24 | void reset(); 25 | /// Calculate the amount extruded for relative or absolute moves. 26 | double extrude(double dE); 27 | double retract(double length, double restart_extra); 28 | double unretract(); 29 | double e_per_mm(double mm3_per_mm) const; 30 | double extruded_volume() const; 31 | 32 | /// Calculate amount of filament used for current Extruder object. 33 | double used_filament() const; 34 | 35 | /// Retrieve the filament diameter for this Extruder from config. 36 | double filament_diameter() const; 37 | /// Retrieve the filament density for this Extruder from config. 38 | double filament_density() const; 39 | /// Retrieve the filament cost for this Extruder from config. 40 | double filament_cost() const; 41 | /// Retrieve the extrustion multiplier for this Extruder from config. 42 | double extrusion_multiplier() const; 43 | double retract_length() const; 44 | double retract_lift() const; 45 | int retract_speed() const; 46 | double retract_restart_extra() const; 47 | double retract_length_toolchange() const; 48 | double retract_restart_extra_toolchange() const; 49 | 50 | private: 51 | GCodeConfig *config; 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /xs/src/libslic3r/ExtrusionEntityCollection.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_ExtrusionEntityCollection_hpp_ 2 | #define slic3r_ExtrusionEntityCollection_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "ExtrusionEntity.hpp" 6 | #include "Polyline.hpp" 7 | 8 | namespace Slic3r { 9 | 10 | class ExtrusionEntityCollection : public ExtrusionEntity 11 | { 12 | public: 13 | ExtrusionEntityCollection* clone() const; 14 | ExtrusionEntitiesPtr entities; // we own these entities 15 | std::vector orig_indices; // handy for XS 16 | bool no_sort; 17 | ExtrusionEntityCollection(): no_sort(false) {}; 18 | ExtrusionEntityCollection(const ExtrusionEntityCollection &collection); 19 | ExtrusionEntityCollection(const ExtrusionPaths &paths); 20 | ExtrusionEntityCollection& operator= (const ExtrusionEntityCollection &other); 21 | ~ExtrusionEntityCollection(); 22 | operator ExtrusionPaths() const; 23 | 24 | bool is_collection() const { 25 | return true; 26 | }; 27 | bool can_reverse() const { 28 | return !this->no_sort; 29 | }; 30 | bool empty() const { 31 | return this->entities.empty(); 32 | }; 33 | void clear(); 34 | void swap (ExtrusionEntityCollection &c); 35 | void append(const ExtrusionEntity &entity); 36 | void append(const ExtrusionEntitiesPtr &entities); 37 | void append(const ExtrusionPaths &paths); 38 | void append(const Polylines &polylines, const ExtrusionPath &templ); 39 | void replace(size_t i, const ExtrusionEntity &entity); 40 | void remove(size_t i); 41 | ExtrusionEntityCollection chained_path(bool no_reverse = false, std::vector* orig_indices = NULL) const; 42 | void chained_path(ExtrusionEntityCollection* retval, bool no_reverse = false, std::vector* orig_indices = NULL) const; 43 | void chained_path_from(Point start_near, ExtrusionEntityCollection* retval, bool no_reverse = false, std::vector* orig_indices = NULL) const; 44 | void reverse(); 45 | Point first_point() const; 46 | Point last_point() const; 47 | Polygons grow() const; 48 | size_t items_count() const; 49 | void flatten(ExtrusionEntityCollection* retval) const; 50 | ExtrusionEntityCollection flatten() const; 51 | double min_mm3_per_mm() const; 52 | Polyline as_polyline() const { 53 | CONFESS("Calling as_polyline() on a ExtrusionEntityCollection"); 54 | return Polyline(); 55 | }; 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Fill/Fill3DHoneycomb.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_Fill3DHoneycomb_hpp_ 2 | #define slic3r_Fill3DHoneycomb_hpp_ 3 | 4 | #include 5 | 6 | #include "../libslic3r.h" 7 | 8 | #include "Fill.hpp" 9 | 10 | namespace Slic3r { 11 | 12 | class Fill3DHoneycomb : public Fill 13 | { 14 | public: 15 | virtual Fill* clone() const { return new Fill3DHoneycomb(*this); }; 16 | virtual ~Fill3DHoneycomb() {} 17 | 18 | // require bridge flow since most of this pattern hangs in air 19 | virtual bool use_bridge_flow() const { return true; } 20 | 21 | protected: 22 | virtual void _fill_surface_single( 23 | unsigned int thickness_layers, 24 | const direction_t &direction, 25 | ExPolygon &expolygon, 26 | Polylines* polylines_out); 27 | }; 28 | 29 | } // namespace Slic3r 30 | 31 | #endif // slic3r_Fill3DHoneycomb_hpp_ 32 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Fill/FillConcentric.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_FillConcentric_hpp_ 2 | #define slic3r_FillConcentric_hpp_ 3 | 4 | #include "Fill.hpp" 5 | 6 | namespace Slic3r { 7 | 8 | class FillConcentric : public Fill 9 | { 10 | public: 11 | virtual ~FillConcentric() {} 12 | 13 | protected: 14 | virtual Fill* clone() const { return new FillConcentric(*this); }; 15 | virtual void _fill_surface_single( 16 | unsigned int thickness_layers, 17 | const direction_t &direction, 18 | ExPolygon &expolygon, 19 | Polylines* polylines_out); 20 | 21 | virtual bool no_sort() const { return true; } 22 | virtual bool can_solid() const { return true; }; 23 | }; 24 | 25 | } // namespace Slic3r 26 | 27 | #endif // slic3r_FillConcentric_hpp_ 28 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Fill/FillGyroid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_FillGyroid_hpp_ 2 | #define slic3r_FillGyroid_hpp_ 3 | 4 | #include 5 | 6 | #include "../libslic3r.h" 7 | 8 | #include "Fill.hpp" 9 | 10 | namespace Slic3r { 11 | 12 | class FillGyroid : public Fill 13 | { 14 | public: 15 | 16 | FillGyroid(){ scaling = 1.75; } 17 | virtual Fill* clone() const { return new FillGyroid(*this); }; 18 | virtual ~FillGyroid() {} 19 | 20 | /// require bridge flow since most of this pattern hangs in air 21 | virtual bool use_bridge_flow() const { return true; } 22 | 23 | protected: 24 | 25 | /// mult of density, to have a good %of weight for each density parameter 26 | float scaling; 27 | 28 | 29 | virtual void _fill_surface_single( 30 | unsigned int thickness_layers, 31 | const std::pair &direction, 32 | ExPolygon &expolygon, 33 | Polylines *polylines_out); 34 | 35 | /// create the gyroid grid to clip. 36 | Polylines makeGrid(coord_t gridZ, double density, double layer_width, size_t gridWidth, size_t gridHeight, size_t curveType); 37 | ///add line poly in reverse if needed into array 38 | inline void correctOrderAndAdd(const int num, Polyline poly, Polylines &array); 39 | ///create a curved horinzontal line (for each x, compute y) 40 | Polyline makeLineHori(double xPos, double yPos, double width, double height, 41 | double currentYBegin, double segmentSize, coord_t scaleFactor, 42 | double zCs, double zSn, 43 | bool flip, double decal=0); 44 | ///create a curved vertival line (for each y, compute x) 45 | Polyline makeLineVert(double xPos, double yPos, double width, double height, 46 | double currentXBegin, double segmentSize, coord_t scaleFactor, 47 | double zCs, double zSn, 48 | bool flip, double decal=0); 49 | 50 | }; 51 | 52 | } // namespace Slic3r 53 | 54 | #endif // slic3r_FillGyroid_hpp_ 55 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Fill/FillHoneycomb.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_FillHoneycomb_hpp_ 2 | #define slic3r_FillHoneycomb_hpp_ 3 | 4 | #include 5 | 6 | #include "../libslic3r.h" 7 | 8 | #include "Fill.hpp" 9 | 10 | namespace Slic3r { 11 | 12 | class FillHoneycomb : public Fill 13 | { 14 | public: 15 | virtual ~FillHoneycomb() {} 16 | 17 | protected: 18 | virtual Fill* clone() const { return new FillHoneycomb(*this); }; 19 | virtual void _fill_surface_single( 20 | unsigned int thickness_layers, 21 | const direction_t &direction, 22 | ExPolygon &expolygon, 23 | Polylines* polylines_out 24 | ); 25 | 26 | // Cache the hexagon math. 27 | struct CacheData 28 | { 29 | coord_t distance; 30 | coord_t hex_side; 31 | coord_t hex_width; 32 | coord_t pattern_height; 33 | coord_t y_short; 34 | coord_t x_offset; 35 | coord_t y_offset; 36 | Point hex_center; 37 | }; 38 | typedef std::pair CacheID; // density, spacing 39 | typedef std::map Cache; 40 | Cache cache; 41 | 42 | virtual float _layer_angle(size_t idx) const { return float(M_PI/3.) * (idx % 3); } 43 | }; 44 | 45 | } // namespace Slic3r 46 | 47 | #endif // slic3r_FillHoneycomb_hpp_ 48 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Fill/FillPlanePath.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_FillPlanePath_hpp_ 2 | #define slic3r_FillPlanePath_hpp_ 3 | 4 | #include 5 | 6 | #include "../libslic3r.h" 7 | 8 | #include "Fill.hpp" 9 | 10 | namespace Slic3r { 11 | 12 | // The original Perl code used path generators from Math::PlanePath library: 13 | // http://user42.tuxfamily.org/math-planepath/ 14 | // http://user42.tuxfamily.org/math-planepath/gallery.html 15 | 16 | class FillPlanePath : public Fill 17 | { 18 | public: 19 | virtual ~FillPlanePath() {} 20 | 21 | protected: 22 | virtual void _fill_surface_single( 23 | unsigned int thickness_layers, 24 | const direction_t &direction, 25 | ExPolygon &expolygon, 26 | Polylines* polylines_out); 27 | 28 | virtual float _layer_angle(size_t idx) const { return 0.f; } 29 | virtual bool _centered() const = 0; 30 | virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) = 0; 31 | }; 32 | 33 | class FillArchimedeanChords : public FillPlanePath 34 | { 35 | public: 36 | virtual Fill* clone() const { return new FillArchimedeanChords(*this); }; 37 | virtual ~FillArchimedeanChords() {} 38 | virtual bool can_solid() const { return true; }; 39 | 40 | protected: 41 | virtual bool _centered() const { return true; } 42 | virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); 43 | }; 44 | 45 | class FillHilbertCurve : public FillPlanePath 46 | { 47 | public: 48 | virtual Fill* clone() const { return new FillHilbertCurve(*this); }; 49 | virtual ~FillHilbertCurve() {} 50 | virtual bool can_solid() const { return true; }; 51 | 52 | protected: 53 | virtual bool _centered() const { return false; } 54 | virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); 55 | }; 56 | 57 | class FillOctagramSpiral : public FillPlanePath 58 | { 59 | public: 60 | virtual Fill* clone() const { return new FillOctagramSpiral(*this); }; 61 | virtual ~FillOctagramSpiral() {} 62 | virtual bool can_solid() const { return true; }; 63 | 64 | protected: 65 | virtual bool _centered() const { return true; } 66 | virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y); 67 | }; 68 | 69 | } // namespace Slic3r 70 | 71 | #endif // slic3r_FillPlanePath_hpp_ 72 | -------------------------------------------------------------------------------- /xs/src/libslic3r/GCode/CoolingBuffer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_CoolingBuffer_hpp_ 2 | #define slic3r_CoolingBuffer_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "GCode.hpp" 6 | #include 7 | #include 8 | 9 | namespace Slic3r { 10 | 11 | /* 12 | A standalone G-code filter, to control cooling of the print. 13 | The G-code is processed per layer. Once a layer is collected, fan start / stop commands are edited 14 | and the print is modified to stretch over a minimum layer time. 15 | */ 16 | 17 | class CoolingBuffer { 18 | public: 19 | CoolingBuffer(GCode &gcodegen) 20 | : _gcodegen(&gcodegen), _elapsed_time(0.), _elapsed_time_bridges(0.), 21 | _elapsed_time_external(0.), _layer_id(0) 22 | { 23 | this->_min_print_speed = this->_gcodegen->config.min_print_speed * 60; 24 | }; 25 | std::string append(const std::string &gcode, std::string obj_id, size_t layer_id, float print_z); 26 | std::string flush(); 27 | GCode* gcodegen() { return this->_gcodegen; }; 28 | 29 | private: 30 | GCode* _gcodegen; 31 | std::string _gcode; 32 | float _elapsed_time; 33 | float _elapsed_time_bridges; 34 | float _elapsed_time_external; 35 | size_t _layer_id; 36 | std::map _last_z; 37 | float _min_print_speed; 38 | }; 39 | 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /xs/src/libslic3r/GCode/SpiralVase.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_SpiralVase_hpp_ 2 | #define slic3r_SpiralVase_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "GCode.hpp" 6 | #include "GCodeReader.hpp" 7 | 8 | namespace Slic3r { 9 | 10 | class SpiralVase { 11 | public: 12 | bool enable; 13 | 14 | SpiralVase(const PrintConfig &config) 15 | : enable(false), _config(&config) 16 | { 17 | this->_reader.Z = this->_config->z_offset; 18 | this->_reader.apply_config(*this->_config); 19 | }; 20 | std::string process_layer(const std::string &gcode); 21 | 22 | private: 23 | const PrintConfig* _config; 24 | GCodeReader _reader; 25 | }; 26 | 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /xs/src/libslic3r/GCodeTimeEstimator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_GCodeTimeEstimator_hpp_ 2 | #define slic3r_GCodeTimeEstimator_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "GCodeReader.hpp" 6 | 7 | namespace Slic3r { 8 | 9 | class GCodeTimeEstimator : public GCodeReader { 10 | public: 11 | float time = 0; // in seconds 12 | 13 | void parse(const std::string &gcode); 14 | void parse_file(const std::string &file); 15 | 16 | protected: 17 | float acceleration = 9000; 18 | void _parser(GCodeReader&, const GCodeReader::GCodeLine &line); 19 | static float _accelerated_move(double length, double v, double acceleration); 20 | }; 21 | 22 | } /* namespace Slic3r */ 23 | 24 | #endif /* slic3r_GCodeTimeEstimator_hpp_ */ 25 | -------------------------------------------------------------------------------- /xs/src/libslic3r/IO.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_IO_hpp_ 2 | #define slic3r_IO_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Model.hpp" 6 | #include "TriangleMesh.hpp" 7 | #include 8 | 9 | namespace Slic3r { namespace IO { 10 | 11 | class STL 12 | { 13 | public: 14 | static bool read(std::string input_file, TriangleMesh* mesh); 15 | static bool read(std::string input_file, Model* model); 16 | static bool write(Model& model, std::string output_file, bool binary = true); 17 | static bool write(TriangleMesh& mesh, std::string output_file, bool binary = true); 18 | }; 19 | 20 | class OBJ 21 | { 22 | public: 23 | static bool read(std::string input_file, TriangleMesh* mesh); 24 | static bool read(std::string input_file, Model* model); 25 | static bool write(Model& model, std::string output_file); 26 | static bool write(TriangleMesh& mesh, std::string output_file); 27 | }; 28 | 29 | class AMF 30 | { 31 | public: 32 | static bool read(std::string input_file, Model* model); 33 | static bool write(Model& model, std::string output_file); 34 | }; 35 | 36 | class POV 37 | { 38 | public: 39 | static bool write(TriangleMesh& mesh, std::string output_file); 40 | }; 41 | 42 | class TMF 43 | { 44 | public: 45 | static bool read(std::string input_file, Model* model); 46 | static bool write(Model& model, std::string output_file); 47 | }; 48 | 49 | } } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /xs/src/libslic3r/LayerHeightSpline.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_LayerHeightSpline_hpp_ 2 | #define slic3r_LayerHeightSpline_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "BSpline/BSpline.h" // Warning: original BSplineBase.h/cpp merged into BSpline.h/cpp to avoid dependency issues caused by Build::WithXSpp which tries to compile all .cpp files in /src 6 | 7 | namespace Slic3r { 8 | 9 | 10 | class LayerHeightSpline 11 | { 12 | public: 13 | LayerHeightSpline(); 14 | LayerHeightSpline(const LayerHeightSpline &other); 15 | LayerHeightSpline& operator=(const LayerHeightSpline &other); 16 | void setObjectHeight(coordf_t object_height) { this->_object_height = object_height; }; 17 | bool hasData(); // indicate that we have valid data; 18 | bool setLayers(std::vector layers); 19 | bool updateLayerHeights(std::vector heights); 20 | bool layersUpdated() const { return this->_layers_updated; }; // true if the basis set of layers was updated (by the slicing algorithm) 21 | bool layerHeightsUpdated() const { return this->_layer_heights_updated; }; // true if the heights where updated (by the spline control user interface) 22 | void clear(); 23 | std::vector getOriginalLayers() const { return this->_layers; }; 24 | std::vector getInterpolatedLayers() const; 25 | const coordf_t getLayerHeightAt(coordf_t height); 26 | 27 | private: 28 | bool _updateBSpline(); 29 | 30 | coordf_t _object_height; 31 | bool _is_valid; 32 | bool _layers_updated; 33 | bool _layer_heights_updated; 34 | std::vector _layers; 35 | std::vector _layer_heights; 36 | std::vector _spline_layers; 37 | std::vector _spline_layer_heights; 38 | std::unique_ptr> _layer_height_spline; 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /xs/src/libslic3r/MotionPlanner.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_MotionPlanner_hpp_ 2 | #define slic3r_MotionPlanner_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "ClipperUtils.hpp" 6 | #include "ExPolygonCollection.hpp" 7 | #include "Polyline.hpp" 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Slic3r { 13 | 14 | constexpr coord_t MP_INNER_MARGIN = scale_(1.0); 15 | constexpr coord_t MP_OUTER_MARGIN = scale_(2.0); 16 | 17 | class MotionPlanner; 18 | 19 | class MotionPlannerEnv 20 | { 21 | friend class MotionPlanner; 22 | 23 | public: 24 | ExPolygon island; 25 | ExPolygonCollection env; 26 | MotionPlannerEnv() {}; 27 | MotionPlannerEnv(const ExPolygon &island) : island(island) {}; 28 | Point nearest_env_point(const Point &from, const Point &to) const; 29 | }; 30 | 31 | class MotionPlannerGraph 32 | { 33 | friend class MotionPlanner; 34 | 35 | private: 36 | typedef int node_t; 37 | typedef double weight_t; 38 | struct neighbor { 39 | node_t target; 40 | weight_t weight; 41 | neighbor(node_t arg_target, weight_t arg_weight) 42 | : target(arg_target), weight(arg_weight) { } 43 | }; 44 | typedef std::vector< std::vector > adjacency_list_t; 45 | adjacency_list_t adjacency_list; 46 | 47 | public: 48 | Points nodes; 49 | //std::map, double> edges; 50 | void add_edge(node_t from, node_t to, double weight); 51 | size_t find_node(const Point &point) const; 52 | Polyline shortest_path(node_t from, node_t to); 53 | }; 54 | 55 | class MotionPlanner 56 | { 57 | public: 58 | MotionPlanner(const ExPolygons &islands); 59 | ~MotionPlanner(); 60 | Polyline shortest_path(const Point &from, const Point &to); 61 | size_t islands_count() const; 62 | 63 | private: 64 | bool initialized; 65 | std::vector islands; 66 | MotionPlannerEnv outer; 67 | std::vector graphs; 68 | 69 | void initialize(); 70 | MotionPlannerGraph* init_graph(int island_idx); 71 | const MotionPlannerEnv& get_env(int island_idx) const; 72 | }; 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /xs/src/libslic3r/MultiPoint.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_MultiPoint_hpp_ 2 | #define slic3r_MultiPoint_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include 6 | #include 7 | #include "Line.hpp" 8 | #include "Point.hpp" 9 | 10 | namespace Slic3r { 11 | 12 | class BoundingBox; 13 | 14 | class MultiPoint 15 | { 16 | public: 17 | Points points; 18 | 19 | operator Points() const; 20 | void scale(double factor); 21 | void translate(double x, double y); 22 | void translate(const Point &vector); 23 | void rotate(double angle); 24 | void rotate(double angle, const Point ¢er); 25 | void reverse(); 26 | Point first_point() const; 27 | virtual Point last_point() const = 0; 28 | virtual Lines lines() const = 0; 29 | double length() const; 30 | bool is_valid() const { return this->points.size() >= 2; } 31 | 32 | int find_point(const Point &point) const; 33 | bool has_boundary_point(const Point &point) const; 34 | BoundingBox bounding_box() const; 35 | 36 | // Return true if there are exact duplicates. 37 | bool has_duplicate_points() const; 38 | 39 | // Remove exact duplicates, return true if any duplicate has been removed. 40 | bool remove_duplicate_points(); 41 | 42 | void append(const Point &point); 43 | void append(const Points &points); 44 | void append(const Points::const_iterator &begin, const Points::const_iterator &end); 45 | bool intersection(const Line& line, Point* intersection) const; 46 | std::string dump_perl() const; 47 | 48 | static Points _douglas_peucker(const Points &points, const double tolerance); 49 | 50 | protected: 51 | MultiPoint() {}; 52 | explicit MultiPoint(const Points &_points): points(_points) {}; 53 | ~MultiPoint() = default; 54 | }; 55 | 56 | } // namespace Slic3r 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /xs/src/libslic3r/NonplanarFacet.cpp: -------------------------------------------------------------------------------- 1 | #include "NonplanarFacet.hpp" 2 | 3 | 4 | namespace Slic3r { 5 | 6 | void 7 | NonplanarFacet::calculate_stats() { 8 | //calculate min and max values 9 | this->stats.min.x = this->vertex[0].x; 10 | this->stats.min.y = this->vertex[0].y; 11 | this->stats.min.z = this->vertex[0].z; 12 | this->stats.max.x = this->vertex[0].x; 13 | this->stats.max.y = this->vertex[0].y; 14 | this->stats.max.z = this->vertex[0].z; 15 | for(int j = 1; j < 3; j++) { 16 | this->stats.min.x = std::min(this->stats.min.x, this->vertex[j].x); 17 | this->stats.min.y = std::min(this->stats.min.y, this->vertex[j].y); 18 | this->stats.min.z = std::min(this->stats.min.z, this->vertex[j].z); 19 | this->stats.max.x = std::max(this->stats.max.x, this->vertex[j].x); 20 | this->stats.max.y = std::max(this->stats.max.y, this->vertex[j].y); 21 | this->stats.max.z = std::max(this->stats.max.z, this->vertex[j].z); 22 | } 23 | } 24 | 25 | void 26 | NonplanarFacet::translate(float x, float y, float z) 27 | { 28 | //translate facet 29 | for(int j = 0; j < 3; j++) { 30 | this->vertex[j].x += x; 31 | this->vertex[j].y += y; 32 | this->vertex[j].z += z; 33 | } 34 | 35 | //translate min and max values 36 | this->stats.min.x += x; 37 | this->stats.min.y += y; 38 | this->stats.min.z += z; 39 | this->stats.max.x += x; 40 | this->stats.max.y += y; 41 | this->stats.max.z += z; 42 | } 43 | 44 | void 45 | NonplanarFacet::scale(float versor[3]) 46 | { 47 | //scale facet 48 | for(int j = 0; j < 3; j++) { 49 | this->vertex[j].x *= versor[0]; 50 | this->vertex[j].y *= versor[1]; 51 | this->vertex[j].z *= versor[2]; 52 | } 53 | 54 | //scale min and max values 55 | this->stats.min.x *= versor[0]; 56 | this->stats.min.y *= versor[1]; 57 | this->stats.min.z *= versor[2]; 58 | this->stats.max.x *= versor[0]; 59 | this->stats.max.y *= versor[1]; 60 | this->stats.max.z *= versor[2]; 61 | } 62 | 63 | float 64 | NonplanarFacet::calculate_surface_area() 65 | { 66 | return 0.5 * ((this->vertex[1].x - this->vertex[0].x) * 67 | (this->vertex[2].y - this->vertex[0].y) - 68 | (this->vertex[1].y - this->vertex[0].y) * 69 | (this->vertex[2].x - this->vertex[0].x)); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /xs/src/libslic3r/NonplanarFacet.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_NonplanarFacet_hpp_ 2 | #define slic3r_NonplanarFacet_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Geometry.hpp" 6 | 7 | namespace Slic3r { 8 | 9 | typedef struct { 10 | float x; 11 | float y; 12 | float z; 13 | } facet_vertex; 14 | 15 | typedef struct { 16 | facet_vertex max; 17 | facet_vertex min; 18 | } facet_stats; 19 | 20 | class NonplanarFacet 21 | { 22 | public: 23 | facet_vertex vertex[3]; 24 | facet_vertex normal; 25 | int neighbor[3]; 26 | facet_stats stats; 27 | bool marked = false; 28 | 29 | NonplanarFacet() {}; 30 | ~NonplanarFacet() {}; 31 | void calculate_stats(); 32 | void translate(float x, float y, float z); 33 | void scale(float versor[3]); 34 | float calculate_surface_area(); 35 | 36 | }; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /xs/src/libslic3r/NonplanarSurface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_NonplanarSurface_hpp_ 2 | #define slic3r_NonplanarSurface_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "NonplanarFacet.hpp" 6 | #include "Point.hpp" 7 | #include "Polygon.hpp" 8 | #include "ExPolygon.hpp" 9 | #include "Geometry.hpp" 10 | #include "ClipperUtils.hpp" 11 | 12 | namespace Slic3r { 13 | 14 | typedef struct { 15 | float x; 16 | float y; 17 | float z; 18 | } mesh_vertex; 19 | 20 | typedef struct { 21 | mesh_vertex max; 22 | mesh_vertex min; 23 | } mesh_stats; 24 | 25 | class NonplanarSurface; 26 | 27 | typedef std::vector NonplanarSurfaces; 28 | 29 | class NonplanarSurface 30 | { 31 | public: 32 | std::map mesh; 33 | mesh_stats stats; 34 | NonplanarSurface() {}; 35 | ~NonplanarSurface() {}; 36 | NonplanarSurface(std::map &_mesh); 37 | bool operator==(const NonplanarSurface& other) const; 38 | void calculate_stats(); 39 | void translate(float x, float y, float z); 40 | void scale(float factor); 41 | void scale(float versor[3]); 42 | void rotate_z(float angle); 43 | void debug_output(); 44 | NonplanarSurfaces group_surfaces(); 45 | void mark_neighbor_surfaces(int id); 46 | bool check_max_printing_height(float height); 47 | void check_printable_surfaces(float max_angle); 48 | bool check_surface_area(float minimal_area); 49 | ExPolygons horizontal_projection() const; 50 | 51 | }; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /xs/src/libslic3r/PlaceholderParser.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_PlaceholderParser_hpp_ 2 | #define slic3r_PlaceholderParser_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include 6 | #include 7 | #include 8 | #include "PrintConfig.hpp" 9 | 10 | 11 | namespace Slic3r { 12 | 13 | typedef std::map t_strstr_map; 14 | typedef std::map > t_strstrs_map; 15 | 16 | class PlaceholderParser 17 | { 18 | public: 19 | t_strstr_map _single; 20 | t_strstrs_map _multiple; 21 | 22 | PlaceholderParser(); 23 | void update_timestamp(); 24 | void apply_config(const DynamicPrintConfig &config); 25 | void apply_env_variables(); 26 | void set(const std::string &key, const std::string &value); 27 | void set(const std::string &key, int value); 28 | void set(const std::string &key, std::vector values); 29 | std::string process(std::string str) const; 30 | 31 | private: 32 | bool find_and_replace(std::string &source, std::string const &find, std::string const &replace) const; 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Polyline.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_Polyline_hpp_ 2 | #define slic3r_Polyline_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Line.hpp" 6 | #include "MultiPoint.hpp" 7 | #include "Polygon.hpp" 8 | #include 9 | #include 10 | 11 | namespace Slic3r { 12 | 13 | class Polyline; 14 | class ThickPolyline; 15 | typedef std::vector Polylines; 16 | typedef std::vector ThickPolylines; 17 | 18 | class Polyline : public MultiPoint { 19 | public: 20 | operator Polylines() const; 21 | operator Line() const; 22 | Point last_point() const; 23 | Point leftmost_point() const; 24 | virtual Lines lines() const; 25 | void clip_end(double distance); 26 | void clip_start(double distance); 27 | void extend_end(double distance); 28 | void extend_start(double distance); 29 | Points equally_spaced_points(double distance) const; 30 | void simplify(double tolerance); 31 | template void simplify_by_visibility(const T &area); 32 | void split_at(const Point &point, Polyline* p1, Polyline* p2) const; 33 | bool is_straight() const; 34 | std::string wkt() const; 35 | }; 36 | 37 | class ThickPolyline : public Polyline { 38 | public: 39 | std::vector width; 40 | std::pair endpoints; 41 | ThickPolyline() : endpoints(std::make_pair(false, false)) {}; 42 | ThickLines thicklines() const; 43 | void reverse(); 44 | }; 45 | 46 | inline Polylines 47 | to_polylines(const Polygons &polygons) 48 | { 49 | Polylines pp; 50 | for (Polygons::const_iterator it = polygons.begin(); it != polygons.end(); ++it) 51 | pp.push_back((Polyline)*it); 52 | return pp; 53 | } 54 | 55 | inline Polylines 56 | to_polylines(const Lines &lines) 57 | { 58 | Polylines pp; 59 | for (Lines::const_iterator it = lines.begin(); it != lines.end(); ++it) 60 | pp.push_back((Polyline)*it); 61 | return pp; 62 | } 63 | 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /xs/src/libslic3r/PolylineCollection.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_PolylineCollection_hpp_ 2 | #define slic3r_PolylineCollection_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Polyline.hpp" 6 | 7 | namespace Slic3r { 8 | 9 | class PolylineCollection 10 | { 11 | static Polylines _chained_path_from( 12 | const Polylines &src, 13 | Point start_near, 14 | bool no_reverse 15 | #if SLIC3R_CPPVER >= 11 16 | , bool move_from_src 17 | #endif 18 | ); 19 | 20 | public: 21 | Polylines polylines; 22 | void chained_path(PolylineCollection* retval, bool no_reverse = false) const 23 | { retval->polylines = chained_path(this->polylines, no_reverse); } 24 | void chained_path_from(Point start_near, PolylineCollection* retval, bool no_reverse = false) const 25 | { retval->polylines = chained_path_from(this->polylines, start_near, no_reverse); } 26 | Point leftmost_point() const 27 | { return leftmost_point(polylines); } 28 | void append(const Polylines &polylines); 29 | 30 | static Point leftmost_point(const Polylines &polylines); 31 | #if SLIC3R_CPPVER >= 11 32 | static Polylines chained_path(Polylines &&src, bool no_reverse = false); 33 | static Polylines chained_path_from(Polylines &&src, Point start_near, bool no_reverse = false); 34 | #endif 35 | static Polylines chained_path(const Polylines &src, bool no_reverse = false); 36 | static Polylines chained_path_from(const Polylines &src, Point start_near, bool no_reverse = false); 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /xs/src/libslic3r/SLAPrint.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_SLAPrint_hpp_ 2 | #define slic3r_SLAPrint_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "ExPolygon.hpp" 6 | #include "ExPolygonCollection.hpp" 7 | #include "Fill/Fill.hpp" 8 | #include "Model.hpp" 9 | #include "Point.hpp" 10 | #include "PrintConfig.hpp" 11 | #include "SVG.hpp" 12 | 13 | namespace Slic3r { 14 | 15 | class SLAPrint 16 | { 17 | public: 18 | SLAPrintConfig config; 19 | 20 | class Layer { 21 | public: 22 | ExPolygonCollection slices; 23 | ExPolygonCollection perimeters; 24 | ExtrusionEntityCollection infill; 25 | ExPolygonCollection solid_infill; 26 | float slice_z, print_z; 27 | bool solid; 28 | 29 | Layer(float _slice_z, float _print_z) 30 | : slice_z(_slice_z), print_z(_print_z), solid(true) {}; 31 | }; 32 | std::vector layers; 33 | 34 | class SupportPillar : public Point { 35 | public: 36 | size_t top_layer, bottom_layer; 37 | SupportPillar(const Point &p) : Point(p), top_layer(0), bottom_layer(0) {}; 38 | }; 39 | std::vector sm_pillars; 40 | 41 | SLAPrint(Model* _model) : model(_model) {}; 42 | void slice(); 43 | void write_svg(const std::string &outputfile) const; 44 | 45 | private: 46 | Model* model; 47 | BoundingBoxf3 bb; 48 | 49 | void _infill_layer(size_t i, const Fill* fill); 50 | coordf_t sm_pillars_radius() const; 51 | std::string _SVG_path_d(const Polygon &polygon) const; 52 | std::string _SVG_path_d(const ExPolygon &expolygon) const; 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /xs/src/libslic3r/SlicingAdaptive.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_SlicingAdaptive_hpp_ 2 | #define slic3r_SlicingAdaptive_hpp_ 3 | 4 | #include "admesh/stl.h" 5 | 6 | namespace Slic3r 7 | { 8 | 9 | class TriangleMesh; 10 | 11 | class SlicingAdaptive 12 | { 13 | public: 14 | SlicingAdaptive() {}; 15 | ~SlicingAdaptive() {}; 16 | void clear(); 17 | void add_mesh(const TriangleMesh *mesh) { m_meshes.push_back(mesh); } 18 | void prepare(coordf_t object_size); 19 | float next_layer_height(coordf_t z, coordf_t quality_factor, coordf_t min_layer_height, coordf_t max_layer_height); 20 | float horizontal_facet_distance(coordf_t z, coordf_t max_layer_height); 21 | 22 | private: 23 | float _layer_height_from_facet(int ordered_id, float scaled_quality_factor); 24 | 25 | protected: 26 | // id of the current facet from last iteration 27 | coordf_t object_size; 28 | int current_facet; 29 | std::vector m_meshes; 30 | // Collected faces of all meshes, sorted by raising Z of the bottom most face. 31 | std::vector m_faces; 32 | // Z component of face normals, normalized. 33 | std::vector m_face_normal_z; 34 | }; 35 | 36 | }; // namespace Slic3r 37 | 38 | #endif /* slic3r_SlicingAdaptive_hpp_ */ 39 | -------------------------------------------------------------------------------- /xs/src/libslic3r/SupportMaterial.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_SupportMaterial_hpp_ 2 | #define slic3r_SupportMaterial_hpp_ 3 | 4 | namespace Slic3r { 5 | 6 | // how much we extend support around the actual contact area 7 | constexpr coordf_t SUPPORT_MATERIAL_MARGIN = 1.5; 8 | 9 | } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /xs/src/libslic3r/Surface.cpp: -------------------------------------------------------------------------------- 1 | #include "Surface.hpp" 2 | 3 | namespace Slic3r { 4 | 5 | Surface::operator Polygons() const 6 | { 7 | return this->expolygon; 8 | } 9 | 10 | double 11 | Surface::area() const 12 | { 13 | return this->expolygon.area(); 14 | } 15 | 16 | bool 17 | Surface::is_solid() const 18 | { 19 | return this->surface_type == stTop 20 | || this->surface_type == stBottom 21 | || this->surface_type == stBottomBridge 22 | || this->surface_type == stInternalSolid 23 | || this->surface_type == stInternalBridge 24 | || this->surface_type == stTopNonplanar 25 | || this->surface_type == stInternalSolidNonplanar; 26 | } 27 | 28 | bool 29 | Surface::is_nonplanar() const 30 | { 31 | return this->surface_type == stTopNonplanar 32 | || this->surface_type == stInternalSolidNonplanar; 33 | } 34 | 35 | bool 36 | Surface::is_external() const 37 | { 38 | return this->surface_type == stTop 39 | || this->surface_type == stBottom 40 | || this->surface_type == stBottomBridge 41 | || this->surface_type == stTopNonplanar; 42 | } 43 | 44 | bool 45 | Surface::is_internal() const 46 | { 47 | return this->surface_type == stInternal 48 | || this->surface_type == stInternalBridge 49 | || this->surface_type == stInternalSolid 50 | || this->surface_type == stInternalVoid 51 | || this->surface_type == stInternalSolidNonplanar; 52 | } 53 | 54 | bool 55 | Surface::is_bottom() const 56 | { 57 | return this->surface_type == stBottom 58 | || this->surface_type == stBottomBridge; 59 | } 60 | 61 | bool 62 | Surface::is_bridge() const 63 | { 64 | return this->surface_type == stBottomBridge 65 | || this->surface_type == stInternalBridge; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /xs/src/libslic3r/SurfaceCollection.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_SurfaceCollection_hpp_ 2 | #define slic3r_SurfaceCollection_hpp_ 3 | 4 | #include "libslic3r.h" 5 | #include "Surface.hpp" 6 | #include 7 | 8 | namespace Slic3r { 9 | 10 | class SurfaceCollection 11 | { 12 | public: 13 | Surfaces surfaces; 14 | 15 | SurfaceCollection() {}; 16 | SurfaceCollection(const Surfaces &_surfaces) 17 | : surfaces(_surfaces) {}; 18 | operator Polygons() const; 19 | operator ExPolygons() const; 20 | void simplify(double tolerance); 21 | void group(std::vector *retval) const; 22 | template bool any_internal_contains(const T &item) const; 23 | template bool any_bottom_contains(const T &item) const; 24 | SurfacesPtr filter_by_type(SurfaceType type); 25 | void filter_by_type(SurfaceType type, Polygons* polygons); 26 | 27 | void set(const SurfaceCollection &coll) { surfaces = coll.surfaces; } 28 | void set(SurfaceCollection &&coll) { surfaces = std::move(coll.surfaces); } 29 | void set(const ExPolygons &src, SurfaceType surfaceType) { clear(); this->append(src, surfaceType); } 30 | void set(const ExPolygons &src, const Surface &surfaceTempl) { clear(); this->append(src, surfaceTempl); } 31 | void set(const Surfaces &src) { clear(); this->append(src); } 32 | void set(ExPolygons &&src, SurfaceType surfaceType) { clear(); this->append(std::move(src), surfaceType); } 33 | void set(ExPolygons &&src, const Surface &surfaceTempl) { clear(); this->append(std::move(src), surfaceTempl); } 34 | void set(Surfaces &&src) { clear(); this->append(std::move(src)); } 35 | 36 | void append(const SurfaceCollection &coll); 37 | void append(const Surfaces &surfaces); 38 | void append(const ExPolygons &src, const Surface &templ); 39 | void append(const ExPolygons &src, SurfaceType surfaceType); 40 | void append(const ExPolygons &src, SurfaceType surfaceType, float distance_to_top); 41 | size_t polygons_count() const; 42 | bool empty() const { return this->surfaces.empty(); }; 43 | size_t size() const { return this->surfaces.size(); }; 44 | void clear() { this->surfaces.clear(); }; 45 | void erase(size_t i) { this->surfaces.erase(this->surfaces.begin() + i); }; 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /xs/src/libslic3r/utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "utils.hpp" 3 | #include 4 | 5 | void 6 | confess_at(const char *file, int line, const char *func, 7 | const char *pat, ...) 8 | { 9 | #ifdef SLIC3RXS 10 | va_list args; 11 | SV *error_sv = newSVpvf("Error in function %s at %s:%d: ", func, 12 | file, line); 13 | 14 | va_start(args, pat); 15 | sv_vcatpvf(error_sv, pat, &args); 16 | va_end(args); 17 | 18 | sv_catpvn(error_sv, "\n\t", 2); 19 | 20 | dSP; 21 | ENTER; 22 | SAVETMPS; 23 | PUSHMARK(SP); 24 | XPUSHs( sv_2mortal(error_sv) ); 25 | PUTBACK; 26 | call_pv("Carp::confess", G_DISCARD); 27 | FREETMPS; 28 | LEAVE; 29 | #endif 30 | } 31 | 32 | std::vector 33 | split_at_regex(const std::string& input, const std::string& regex) { 34 | // passing -1 as the submatch index parameter performs splitting 35 | std::regex re(regex); 36 | std::sregex_token_iterator 37 | first{input.begin(), input.end(), re, -1}, 38 | last; 39 | return {first, last}; 40 | } 41 | -------------------------------------------------------------------------------- /xs/src/libslic3r/utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_HPP 2 | #define UTILS_HPP 3 | 4 | #include 5 | #include 6 | 7 | /// Utility functions that aren't necessarily part of libslic3r but are used by it. 8 | 9 | /// Separate a string based on some regular expression string. 10 | std::vector 11 | split_at_regex(const std::string& input, const std::string& regex); 12 | 13 | #endif // UTILS_HPP 14 | -------------------------------------------------------------------------------- /xs/src/poly2tri/poly2tri.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors 3 | * http://code.google.com/p/poly2tri/ 4 | * 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * * Neither the name of Poly2Tri nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without specific 17 | * prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef POLY2TRI_H 33 | #define POLY2TRI_H 34 | 35 | #include "common/shapes.h" 36 | #include "sweep/cdt.h" 37 | 38 | #endif -------------------------------------------------------------------------------- /xs/src/poly2tri/sweep/cdt.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors 3 | * http://code.google.com/p/poly2tri/ 4 | * 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without modification, 8 | * are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * * Neither the name of Poly2Tri nor the names of its contributors may be 16 | * used to endorse or promote products derived from this software without specific 17 | * prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #include "cdt.h" 32 | 33 | namespace p2t { 34 | 35 | CDT::CDT(const std::vector& polyline) 36 | { 37 | sweep_context_ = new SweepContext(polyline); 38 | sweep_ = new Sweep; 39 | } 40 | 41 | void CDT::AddHole(const std::vector& polyline) 42 | { 43 | sweep_context_->AddHole(polyline); 44 | } 45 | 46 | void CDT::AddPoint(Point* point) { 47 | sweep_context_->AddPoint(point); 48 | } 49 | 50 | void CDT::Triangulate() 51 | { 52 | sweep_->Triangulate(*sweep_context_); 53 | } 54 | 55 | std::vector CDT::GetTriangles() 56 | { 57 | return sweep_context_->GetTriangles(); 58 | } 59 | 60 | std::list CDT::GetMap() 61 | { 62 | return sweep_context_->GetMap(); 63 | } 64 | 65 | CDT::~CDT() 66 | { 67 | delete sweep_context_; 68 | delete sweep_; 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /xs/src/slic3r/GUI/3DScene.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_3DScene_hpp_ 2 | #define slic3r_3DScene_hpp_ 3 | 4 | #include "../../libslic3r/libslic3r.h" 5 | #include "../../libslic3r/Point.hpp" 6 | #include "../../libslic3r/Line.hpp" 7 | #include "../../libslic3r/TriangleMesh.hpp" 8 | 9 | namespace Slic3r { 10 | 11 | class GLVertexArray { 12 | public: 13 | std::vector verts, norms; 14 | 15 | void reserve(size_t len) { 16 | this->verts.reserve(len); 17 | this->norms.reserve(len); 18 | }; 19 | void reserve_more(size_t len) { 20 | len += this->verts.size(); 21 | this->reserve(len); 22 | }; 23 | void push_vert(const Pointf3 &point) { 24 | this->verts.push_back(point.x); 25 | this->verts.push_back(point.y); 26 | this->verts.push_back(point.z); 27 | }; 28 | void push_vert(float x, float y, float z) { 29 | this->verts.push_back(x); 30 | this->verts.push_back(y); 31 | this->verts.push_back(z); 32 | }; 33 | void push_norm(const Pointf3 &point) { 34 | this->norms.push_back(point.x); 35 | this->norms.push_back(point.y); 36 | this->norms.push_back(point.z); 37 | }; 38 | void push_norm(float x, float y, float z) { 39 | this->norms.push_back(x); 40 | this->norms.push_back(y); 41 | this->norms.push_back(z); 42 | }; 43 | void load_mesh(const TriangleMesh &mesh); 44 | }; 45 | 46 | class _3DScene 47 | { 48 | public: 49 | static void _extrusionentity_to_verts_do(const Lines &lines, const std::vector &widths, 50 | const std::vector &heights, bool closed, double top_z, const Point ©, 51 | GLVertexArray* qverts, GLVertexArray* tverts); 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /xs/src/slic3r/GUI/GUI.cpp: -------------------------------------------------------------------------------- 1 | #include "GUI.hpp" 2 | 3 | #if __APPLE__ 4 | #import 5 | #elif _WIN32 6 | #include 7 | #pragma comment(lib, "user32.lib") 8 | #endif 9 | 10 | namespace Slic3r { namespace GUI { 11 | 12 | #if __APPLE__ 13 | IOPMAssertionID assertionID; 14 | #endif 15 | 16 | void 17 | disable_screensaver() 18 | { 19 | #if __APPLE__ 20 | CFStringRef reasonForActivity = CFSTR("Slic3r"); 21 | IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, 22 | kIOPMAssertionLevelOn, reasonForActivity, &assertionID); 23 | // ignore result: success == kIOReturnSuccess 24 | #elif _WIN32 25 | SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS); 26 | #endif 27 | } 28 | 29 | void 30 | enable_screensaver() 31 | { 32 | #if __APPLE__ 33 | IOReturn success = IOPMAssertionRelease(assertionID); 34 | #elif _WIN32 35 | SetThreadExecutionState(ES_CONTINUOUS); 36 | #endif 37 | } 38 | 39 | } } 40 | -------------------------------------------------------------------------------- /xs/src/slic3r/GUI/GUI.hpp: -------------------------------------------------------------------------------- 1 | #ifndef slic3r_GUI_hpp_ 2 | #define slic3r_GUI_hpp_ 3 | 4 | namespace Slic3r { namespace GUI { 5 | 6 | void disable_screensaver(); 7 | void enable_screensaver(); 8 | 9 | } } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /xs/t/07_extrusionpath.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 8; 8 | 9 | my $points = [ 10 | [100, 100], 11 | [200, 100], 12 | [200, 200], 13 | ]; 14 | 15 | my $path = Slic3r::ExtrusionPath->new( 16 | polyline => Slic3r::Polyline->new(@$points), 17 | role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 18 | mm3_per_mm => 1, 19 | ); 20 | isa_ok $path->polyline, 'Slic3r::Polyline::Ref', 'path polyline'; 21 | is_deeply $path->polyline->pp, $points, 'path points roundtrip'; 22 | 23 | $path->reverse; 24 | is_deeply $path->polyline->pp, [ reverse @$points ], 'reverse path'; 25 | 26 | $path->append([ 150, 150 ]); 27 | is scalar(@$path), 4, 'append to path'; 28 | 29 | $path->pop_back; 30 | is scalar(@$path), 3, 'pop_back from path'; 31 | 32 | ok $path->first_point->coincides_with($path->polyline->[0]), 'first_point'; 33 | 34 | $path = $path->clone; 35 | 36 | is $path->role, Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, 'role'; 37 | $path->role(Slic3r::ExtrusionPath::EXTR_ROLE_FILL); 38 | is $path->role, Slic3r::ExtrusionPath::EXTR_ROLE_FILL, 'modify role'; 39 | 40 | __END__ 41 | -------------------------------------------------------------------------------- /xs/t/13_polylinecollection.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 3; 8 | 9 | { 10 | my $collection = Slic3r::Polyline::Collection->new( 11 | Slic3r::Polyline->new([0,15], [0,18], [0,20]), 12 | Slic3r::Polyline->new([0,10], [0,8], [0,5]), 13 | ); 14 | is_deeply 15 | [ map $_->y, map @$_, @{$collection->chained_path_from(Slic3r::Point->new(0,30), 0)} ], 16 | [20, 18, 15, 10, 8, 5], 17 | 'chained_path_from'; 18 | is_deeply 19 | [ map $_->y, map @$_, @{$collection->chained_path(0)} ], 20 | [15, 18, 20, 10, 8, 5], 21 | 'chained_path'; 22 | } 23 | 24 | { 25 | my $collection = Slic3r::Polyline::Collection->new( 26 | Slic3r::Polyline->new([15,0], [10,0], [4,0]), 27 | Slic3r::Polyline->new([10,5], [15,5], [20,5]), 28 | ); 29 | is_deeply 30 | [ map $_->x, map @$_, @{$collection->chained_path_from(Slic3r::Point->new(30,0), 0)} ], 31 | [reverse 4, 10, 15, 10, 15, 20], 32 | 'chained_path_from'; 33 | } 34 | 35 | __END__ 36 | -------------------------------------------------------------------------------- /xs/t/14_geometry.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 9; 8 | 9 | use constant PI => 4 * atan2(1, 1); 10 | 11 | { 12 | my @points = ( 13 | Slic3r::Point->new(100,100), 14 | Slic3r::Point->new(100,200), 15 | Slic3r::Point->new(200,200), 16 | Slic3r::Point->new(200,100), 17 | Slic3r::Point->new(150,150), 18 | ); 19 | my $hull = Slic3r::Geometry::convex_hull(\@points); 20 | isa_ok $hull, 'Slic3r::Polygon', 'convex_hull returns a Polygon'; 21 | is scalar(@$hull), 4, 'convex_hull returns the correct number of points'; 22 | } 23 | 24 | # directions_parallel() and directions_parallel_within() are tested 25 | # also with Slic3r::Line::parallel_to() tests in 10_line.t 26 | { 27 | ok Slic3r::Geometry::directions_parallel_within(0, 0, 0), 'directions_parallel_within'; 28 | ok Slic3r::Geometry::directions_parallel_within(0, PI, 0), 'directions_parallel_within'; 29 | ok Slic3r::Geometry::directions_parallel_within(0, 0, PI/180), 'directions_parallel_within'; 30 | ok Slic3r::Geometry::directions_parallel_within(0, PI, PI/180), 'directions_parallel_within'; 31 | ok !Slic3r::Geometry::directions_parallel_within(PI/2, PI, 0), 'directions_parallel_within'; 32 | ok !Slic3r::Geometry::directions_parallel_within(PI/2, PI, PI/180), 'directions_parallel_within'; 33 | } 34 | 35 | { 36 | my $positions = Slic3r::Geometry::arrange(4, Slic3r::Pointf->new(20, 20), 5); 37 | is scalar(@$positions), 4, 'arrange() returns expected number of positions'; 38 | } 39 | 40 | __END__ 41 | -------------------------------------------------------------------------------- /xs/t/16_flow.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 2; 8 | 9 | { 10 | my $flow = Slic3r::Flow->new_from_width( 11 | role => Slic3r::Flow::FLOW_ROLE_PERIMETER, 12 | width => '1', 13 | nozzle_diameter => 0.5, 14 | layer_height => 0.3, 15 | bridge_flow_ratio => 1, 16 | ); 17 | isa_ok $flow, 'Slic3r::Flow', 'new_from_width'; 18 | } 19 | 20 | { 21 | my $flow = Slic3r::Flow->new( 22 | width => 1, 23 | height => 0.4, 24 | nozzle_diameter => 0.5, 25 | ); 26 | isa_ok $flow, 'Slic3r::Flow', 'new'; 27 | } 28 | 29 | __END__ 30 | -------------------------------------------------------------------------------- /xs/t/17_boundingbox.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 5; 8 | 9 | { 10 | my @points = ( 11 | Slic3r::Point->new(100, 200), 12 | Slic3r::Point->new(500, -600), 13 | ); 14 | my $bb = Slic3r::Geometry::BoundingBox->new_from_points(\@points); 15 | isa_ok $bb, 'Slic3r::Geometry::BoundingBox', 'new_from_points'; 16 | is_deeply $bb->min_point->pp, [100,-600], 'min_point'; 17 | is_deeply $bb->max_point->pp, [500,200], 'max_point'; 18 | } 19 | 20 | { 21 | my $bb = Slic3r::Geometry::BoundingBox->new; 22 | $bb->merge_point(Slic3r::Point->new(10, 10)); 23 | is_deeply $bb->min_point->pp, [10,10], 'min_point equals to the only defined point'; 24 | is_deeply $bb->max_point->pp, [10,10], 'max_point equals to the only defined point'; 25 | } 26 | 27 | __END__ 28 | -------------------------------------------------------------------------------- /xs/t/19_model.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 4; 8 | 9 | { 10 | my $model = Slic3r::Model->new; 11 | my $object = $model->_add_object; 12 | isa_ok $object, 'Slic3r::Model::Object::Ref'; 13 | isa_ok $object->origin_translation, 'Slic3r::Pointf3::Ref'; 14 | $object->origin_translation->translate(10,0,0); 15 | is_deeply \@{$object->origin_translation}, [10,0,0], 'origin_translation is modified by ref'; 16 | 17 | my $lhr = [ [ 5, 10, 0.1 ] ]; 18 | $object->set_layer_height_ranges($lhr); 19 | is_deeply $object->layer_height_ranges, $lhr, 'layer_height_ranges roundtrip'; 20 | } 21 | 22 | __END__ 23 | -------------------------------------------------------------------------------- /xs/t/20_print.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 5; 8 | 9 | { 10 | my $print = Slic3r::Print->new; 11 | isa_ok $print, 'Slic3r::Print'; 12 | isa_ok $print->config, 'Slic3r::Config::Static::Ref'; 13 | isa_ok $print->default_object_config, 'Slic3r::Config::Static::Ref'; 14 | isa_ok $print->default_region_config, 'Slic3r::Config::Static::Ref'; 15 | isa_ok $print->placeholder_parser, 'Slic3r::GCode::PlaceholderParser::Ref'; 16 | } 17 | 18 | __END__ 19 | -------------------------------------------------------------------------------- /xs/t/21_gcode.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 5; 8 | 9 | { 10 | my $gcodegen = Slic3r::GCode->new; 11 | $gcodegen->set_origin(Slic3r::Pointf->new(10,0)); 12 | is_deeply $gcodegen->origin->pp, [10,0], 'set_origin'; 13 | $gcodegen->origin->translate(5,5); 14 | is_deeply $gcodegen->origin->pp, [15,5], 'origin returns reference to point'; 15 | } 16 | 17 | { 18 | my $config = Slic3r::Config::Static::new_FullPrintConfig; 19 | my $gcodegen = Slic3r::GCode->new; 20 | $config->set('use_firmware_retraction', 1); 21 | $config->set('gcode_flavor', "reprap"); 22 | $config->set('gcode_comments', 1); 23 | $gcodegen->apply_print_config($config); 24 | $gcodegen->writer->set_extruders([0]); 25 | $gcodegen->writer->set_extruder(0); 26 | my @output = split(/\n/, $gcodegen->retract(1)); 27 | is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw marlin retract'; 28 | } 29 | 30 | { 31 | my $config = Slic3r::Config::Static::new_FullPrintConfig; 32 | $config->set('use_firmware_retraction', 1); 33 | $config->set('gcode_flavor', "repetier"); 34 | $config->set('gcode_comments', 1); 35 | 36 | my $gcodegen = Slic3r::GCode->new; 37 | $gcodegen->apply_print_config($config); 38 | $gcodegen->writer->set_extruders([0]); 39 | $gcodegen->writer->set_extruder(0); 40 | my @output = split(/\n/, $gcodegen->retract(1)); 41 | is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw repetier retract'; 42 | 43 | } 44 | { 45 | my $config = Slic3r::Config::Static::new_FullPrintConfig; 46 | $config->set('gcode_flavor', "smoothie"); 47 | $config->set('use_firmware_retraction', 1); 48 | $config->set('gcode_comments', 1); 49 | 50 | my $gcodegen = Slic3r::GCode->new; 51 | $gcodegen->apply_print_config($config); 52 | 53 | $gcodegen->writer->set_extruders([0]); 54 | $gcodegen->writer->set_extruder(0); 55 | my @output = split(/\n/, $gcodegen->retract(1)); 56 | ok($output[0] eq "G10 ; retract for toolchange extruder 0", 'Produces regular retract for flavors that are not Marlin or Repetier'); 57 | 58 | } 59 | 60 | __END__ 61 | -------------------------------------------------------------------------------- /xs/t/22_exception.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 1; 8 | 9 | { 10 | eval { 11 | Slic3r::xspp_test_croak_hangs_on_strawberry(); 12 | }; 13 | is $@, "xspp_test_croak_hangs_on_strawberry: exception catched\n", 'croak from inside a C++ exception delivered'; 14 | } 15 | 16 | __END__ 17 | -------------------------------------------------------------------------------- /xs/t/24_gcodemath.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Slic3r::XS; 7 | use Test::More tests => 7; 8 | { 9 | { 10 | my $test_string = "{if{3 == 4}} string"; 11 | 12 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 13 | is $result, "", 'If statement with nested bracket removes on false resolution.'; 14 | } 15 | { 16 | my $test_string = "{if{3 == 4}} string\notherstring"; 17 | 18 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 19 | is $result, "otherstring", 'if false only removes up to newline.'; 20 | } 21 | 22 | { 23 | my $test_string = "{if{3 == 3}} string"; 24 | 25 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 26 | is $result, " string", 'If statement with nested bracket removes itself only on resulting true, does not strip text outside of brackets.'; 27 | } 28 | { 29 | my $test_string = "{if{3 == 3}}string"; 30 | 31 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 32 | is $result, "string", 'If statement with nested bracket removes itself only on resulting true.'; 33 | } 34 | { 35 | my $test_string = "M104 S{4*5}; Sets temp to {4*5}"; 36 | 37 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 38 | is $result, "M104 S20; Sets temp to 20", 'Bracket replacement works with math ops'; 39 | } 40 | { 41 | my $test_string = "M104 S\\{a\\}; Sets temp to {4*5}"; 42 | 43 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 44 | is $result, "M104 S{a}; Sets temp to 20", 'Escaped string emittal.'; 45 | } 46 | { 47 | my $test_string = "M104 S{a}; Sets temp to {4*5}"; 48 | 49 | my $result = Slic3r::ConditionalGCode::apply_math($test_string); 50 | is $result, "M104 S{a}; Sets temp to 20", 'string (minus brackets) on failure to parse.'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xs/t/inc/22_config_bad_config_options.ini: -------------------------------------------------------------------------------- 1 | # generated by Slic3r 1.1.7 on Tue Aug 19 21:49:50 2014 2 | avoid_crossing_perimeters = 1 3 | bed_size = 200,180 4 | g0 = 0 5 | perimeter_acceleration = 0 6 | support_material_extruder = 1 7 | support_material_extrusion_width = 0 8 | -------------------------------------------------------------------------------- /xs/t/models/3mf/box.3mf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/t/models/3mf/box.3mf -------------------------------------------------------------------------------- /xs/t/models/3mf/chess.3mf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/t/models/3mf/chess.3mf -------------------------------------------------------------------------------- /xs/t/models/3mf/gimblekeychain.3mf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/t/models/3mf/gimblekeychain.3mf -------------------------------------------------------------------------------- /xs/t/models/stl/spikey_top.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/t/models/stl/spikey_top.stl -------------------------------------------------------------------------------- /xs/xsp/BridgeDetector.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/BridgeDetector.hpp" 6 | %} 7 | 8 | %name{Slic3r::BridgeDetector} class BridgeDetector { 9 | ~BridgeDetector(); 10 | 11 | bool detect_angle(); 12 | Polygons coverage(); 13 | %name{coverage_by_angle} Polygons coverage(double angle); 14 | Polylines unsupported_edges(); 15 | %name{unsupported_edges_by_angle} Polylines unsupported_edges(double angle); 16 | double angle() 17 | %code{% RETVAL = THIS->angle; %}; 18 | double resolution() 19 | %code{% RETVAL = THIS->resolution; %}; 20 | %{ 21 | 22 | BridgeDetector* 23 | BridgeDetector::new(expolygon, lower_slices, extrusion_width) 24 | ExPolygon* expolygon; 25 | ExPolygonCollection* lower_slices; 26 | long extrusion_width; 27 | CODE: 28 | RETVAL = new BridgeDetector(*expolygon, *lower_slices, extrusion_width); 29 | OUTPUT: 30 | RETVAL 31 | 32 | %} 33 | }; 34 | -------------------------------------------------------------------------------- /xs/xsp/Clipper.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "clipper.hpp" 6 | #include "libslic3r/ClipperUtils.hpp" 7 | %} 8 | 9 | %package{Slic3r::Geometry::Clipper}; 10 | 11 | Polygons offset(Polygons polygons, float delta, double scale = CLIPPER_OFFSET_SCALE, 12 | ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3); 13 | 14 | ExPolygons offset_ex(Polygons polygons, float delta, double scale = CLIPPER_OFFSET_SCALE, 15 | ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3); 16 | 17 | Polygons offset2(Polygons polygons, float delta1, float delta2, double scale = CLIPPER_OFFSET_SCALE, 18 | ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3); 19 | 20 | ExPolygons offset2_ex(Polygons polygons, float delta1, float delta2, double scale = CLIPPER_OFFSET_SCALE, 21 | ClipperLib::JoinType joinType = ClipperLib::jtMiter, double miterLimit = 3); 22 | 23 | Polygons diff(Polygons subject, Polygons clip, bool safety_offset = false); 24 | 25 | ExPolygons diff_ex(Polygons subject, Polygons clip, bool safety_offset = false); 26 | 27 | Polylines diff_pl(Polylines subject, Polygons clip); 28 | 29 | Polygons intersection(Polygons subject, Polygons clip, bool safety_offset = false); 30 | 31 | ExPolygons intersection_ex(Polygons subject, Polygons clip, bool safety_offset = false); 32 | 33 | Polylines intersection_pl(Polylines subject, Polygons clip); 34 | 35 | %name{intersection_ppl} Polylines intersection_pl(Polygons subject, Polygons clip); 36 | 37 | %name{union} Polygons union_(Polygons subject, bool safety_offset = false); 38 | 39 | ExPolygons union_ex(Polygons subject, bool safety_offset = false); 40 | 41 | Polygons union_pt_chained(Polygons subject, bool safety_offset = false); 42 | 43 | Polygons simplify_polygons(Polygons subject); 44 | 45 | %{ 46 | 47 | IV 48 | _constant() 49 | ALIAS: 50 | JT_MITER = jtMiter 51 | JT_ROUND = jtRound 52 | JT_SQUARE = jtSquare 53 | CLIPPER_OFFSET_SCALE = CLIPPER_OFFSET_SCALE 54 | CODE: 55 | RETVAL = ix; 56 | OUTPUT: RETVAL 57 | 58 | SV* 59 | union_pt(subject, safety_offset = false) 60 | Polygons subject 61 | bool safety_offset 62 | CODE: 63 | // perform operation 64 | ClipperLib::PolyTree polytree = union_pt(subject, safety_offset); 65 | RETVAL = polynode_children_2_perl(polytree); 66 | OUTPUT: 67 | RETVAL 68 | 69 | %} 70 | -------------------------------------------------------------------------------- /xs/xsp/ConditionalGCode.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/ConditionalGCode.hpp" 6 | %} 7 | 8 | 9 | %package{Slic3r::ConditionalGCode}; 10 | 11 | %{ 12 | PROTOTYPES: DISABLE 13 | std::string apply_math(std::string input) 14 | CODE: 15 | RETVAL = Slic3r::apply_math(input); 16 | OUTPUT: 17 | RETVAL 18 | %} 19 | -------------------------------------------------------------------------------- /xs/xsp/ExPolygon.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/ExPolygon.hpp" 6 | %} 7 | 8 | %name{Slic3r::ExPolygon} class ExPolygon { 9 | ~ExPolygon(); 10 | Clone clone() 11 | %code{% RETVAL = THIS; %}; 12 | SV* arrayref() 13 | %code{% RETVAL = to_AV(THIS); %}; 14 | SV* pp() 15 | %code{% RETVAL = to_SV_pureperl(THIS); %}; 16 | Ref contour() 17 | %code{% RETVAL = &(THIS->contour); %}; 18 | Polygons* holes() 19 | %code{% RETVAL = &(THIS->holes); %}; 20 | void scale(double factor); 21 | void translate(double x, double y); 22 | double area(); 23 | bool is_valid(); 24 | bool contains_line(Line* line) 25 | %code{% RETVAL = THIS->contains(*line); %}; 26 | bool contains_polyline(Polyline* polyline) 27 | %code{% RETVAL = THIS->contains(*polyline); %}; 28 | bool contains_point(Point* point) 29 | %code{% RETVAL = THIS->contains(*point); %}; 30 | ExPolygons simplify(double tolerance); 31 | Polygons simplify_p(double tolerance); 32 | Polylines medial_axis(double max_width, double min_width) 33 | %code{% THIS->medial_axis(max_width, min_width, &RETVAL); %}; 34 | Polygons get_trapezoids(double angle) 35 | %code{% THIS->get_trapezoids(&RETVAL, angle); %}; 36 | Polygons get_trapezoids2(double angle) 37 | %code{% THIS->get_trapezoids2(&RETVAL, angle); %}; 38 | Polygons triangulate() 39 | %code{% THIS->triangulate(&RETVAL); %}; 40 | Polygons triangulate_pp() 41 | %code{% THIS->triangulate_pp(&RETVAL); %}; 42 | %{ 43 | 44 | ExPolygon* 45 | ExPolygon::new(...) 46 | CODE: 47 | RETVAL = new ExPolygon (); 48 | // ST(0) is class name, ST(1) is contour and others are holes 49 | from_SV_check(ST(1), &RETVAL->contour); 50 | RETVAL->holes.resize(items-2); 51 | for (unsigned int i = 2; i < items; i++) { 52 | from_SV_check(ST(i), &RETVAL->holes[i-2]); 53 | } 54 | OUTPUT: 55 | RETVAL 56 | 57 | void 58 | ExPolygon::rotate(angle, center_sv) 59 | double angle; 60 | SV* center_sv; 61 | CODE: 62 | Point center; 63 | from_SV_check(center_sv, ¢er); 64 | THIS->rotate(angle, center); 65 | 66 | %} 67 | }; 68 | -------------------------------------------------------------------------------- /xs/xsp/Extruder.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/Extruder.hpp" 6 | %} 7 | 8 | %name{Slic3r::Extruder} class Extruder { 9 | Extruder(unsigned int id, StaticPrintConfig* config) 10 | %code%{ RETVAL = new Extruder (id, dynamic_cast(config)); %}; 11 | ~Extruder(); 12 | void reset(); 13 | double extrude(double dE); 14 | double retract(double length, double restart_extra); 15 | double unretract(); 16 | double e_per_mm(double mm3_per_mm); 17 | double extruded_volume(); 18 | double used_filament(); 19 | 20 | unsigned int id() 21 | %code%{ RETVAL = THIS->id; %}; 22 | 23 | double E() 24 | %code%{ RETVAL = THIS->E; %}; 25 | double set_E(double val) 26 | %code%{ RETVAL = THIS->E = val; %}; 27 | double absolute_E() 28 | %code%{ RETVAL = THIS->absolute_E; %}; 29 | double set_absolute_E(double val) 30 | %code%{ RETVAL = THIS->absolute_E = val; %}; 31 | double retracted() 32 | %code%{ RETVAL = THIS->retracted; %}; 33 | double set_retracted(double val) 34 | %code%{ RETVAL = THIS->retracted = val; %}; 35 | double restart_extra() 36 | %code%{ RETVAL = THIS->restart_extra; %}; 37 | double set_restart_extra(double val) 38 | %code%{ RETVAL = THIS->restart_extra = val; %}; 39 | double e_per_mm3() 40 | %code%{ RETVAL = THIS->e_per_mm3; %}; 41 | double retract_speed_mm_min() 42 | %code%{ RETVAL = THIS->retract_speed_mm_min; %}; 43 | 44 | double filament_diameter(); 45 | double filament_density(); 46 | double filament_cost(); 47 | double extrusion_multiplier(); 48 | double retract_length(); 49 | double retract_lift(); 50 | int retract_speed(); 51 | double retract_restart_extra(); 52 | double retract_length_toolchange(); 53 | double retract_restart_extra_toolchange(); 54 | }; 55 | -------------------------------------------------------------------------------- /xs/xsp/ExtrusionLoop.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/ExtrusionEntity.hpp" 6 | %} 7 | 8 | %name{Slic3r::ExtrusionLoop} class ExtrusionLoop { 9 | ExtrusionLoop(); 10 | ~ExtrusionLoop(); 11 | Clone clone() 12 | %code{% RETVAL = THIS; %}; 13 | void reverse(); 14 | bool make_clockwise(); 15 | bool make_counter_clockwise(); 16 | Clone first_point(); 17 | Clone last_point(); 18 | Clone polygon(); 19 | void append(ExtrusionPath* path) 20 | %code{% THIS->paths.push_back(*path); %}; 21 | double length(); 22 | bool split_at_vertex(Point* point) 23 | %code{% RETVAL = THIS->split_at_vertex(*point); %}; 24 | void split_at(Point* point, int prefer_non_overhang = 0) 25 | %code{% THIS->split_at(*point, prefer_non_overhang != 0); %}; 26 | ExtrusionPaths clip_end(double distance) 27 | %code{% THIS->clip_end(distance, &RETVAL); %}; 28 | bool has_overhang_point(Point* point) 29 | %code{% RETVAL = THIS->has_overhang_point(*point); %}; 30 | bool is_perimeter(); 31 | bool is_infill(); 32 | bool is_solid_infill(); 33 | Polygons grow(); 34 | Clone as_polyline(); 35 | %{ 36 | 37 | SV* 38 | ExtrusionLoop::arrayref() 39 | CODE: 40 | AV* av = newAV(); 41 | if (!THIS->paths.empty()) av_extend(av, THIS->paths.size()-1); 42 | for (ExtrusionPaths::iterator it = THIS->paths.begin(); it != THIS->paths.end(); ++it) { 43 | av_store(av, it - THIS->paths.begin(), perl_to_SV_ref(*it)); 44 | } 45 | RETVAL = newRV_noinc((SV*)av); 46 | OUTPUT: 47 | RETVAL 48 | 49 | ExtrusionLoopRole 50 | ExtrusionLoop::role(...) 51 | CODE: 52 | if (items > 1) { 53 | THIS->role = (ExtrusionLoopRole)SvUV(ST(1)); 54 | } 55 | RETVAL = THIS->role; 56 | OUTPUT: 57 | RETVAL 58 | 59 | %} 60 | }; 61 | 62 | %package{Slic3r::ExtrusionLoop}; 63 | %{ 64 | 65 | IV 66 | _constant() 67 | ALIAS: 68 | EXTRL_ROLE_DEFAULT = elrDefault 69 | EXTRL_ROLE_CONTOUR_INTERNAL_PERIMETER = elrContourInternalPerimeter 70 | EXTRL_ROLE_SKIRT = elrSkirt 71 | PROTOTYPE: 72 | CODE: 73 | RETVAL = ix; 74 | OUTPUT: RETVAL 75 | 76 | %} 77 | -------------------------------------------------------------------------------- /xs/xsp/GCodeSender.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | #ifdef BOOST_LIBS 4 | 5 | %{ 6 | #include 7 | #include "libslic3r/GCodeSender.hpp" 8 | %} 9 | 10 | %name{Slic3r::GCode::Sender} class GCodeSender { 11 | GCodeSender(); 12 | ~GCodeSender(); 13 | 14 | bool connect(std::string port, unsigned int baud_rate); 15 | void disconnect(); 16 | bool is_connected(); 17 | bool wait_connected(unsigned int timeout = 3); 18 | int queue_size(); 19 | void send(std::string s, bool priority = false); 20 | void pause_queue(); 21 | void resume_queue(); 22 | void purge_queue(bool priority = false); 23 | std::vector purge_log(); 24 | std::string getT(); 25 | std::string getB(); 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /xs/xsp/GCodeTimeEstimator.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/GCodeTimeEstimator.hpp" 6 | %} 7 | 8 | %name{Slic3r::GCode::TimeEstimator} class GCodeTimeEstimator { 9 | GCodeTimeEstimator(); 10 | ~GCodeTimeEstimator(); 11 | 12 | float time %get{time}; 13 | void parse(std::string gcode); 14 | void parse_file(std::string file); 15 | }; 16 | -------------------------------------------------------------------------------- /xs/xsp/GUI.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "slic3r/GUI/GUI.hpp" 6 | %} 7 | 8 | 9 | %package{Slic3r::GUI}; 10 | 11 | void disable_screensaver() 12 | %code{% Slic3r::GUI::disable_screensaver(); %}; 13 | 14 | void enable_screensaver() 15 | %code{% Slic3r::GUI::enable_screensaver(); %}; 16 | -------------------------------------------------------------------------------- /xs/xsp/GUI_3DScene.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | #include 4 | #include "slic3r/GUI/3DScene.hpp" 5 | 6 | %name{Slic3r::GUI::_3DScene::GLVertexArray} class GLVertexArray { 7 | GLVertexArray(); 8 | ~GLVertexArray(); 9 | void load_mesh(TriangleMesh* mesh) const 10 | %code%{ THIS->load_mesh(*mesh); %}; 11 | size_t size() const 12 | %code%{ RETVAL = THIS->verts.size(); %}; 13 | void* verts_ptr() const 14 | %code%{ RETVAL = THIS->verts.empty() ? 0 : &THIS->verts.front(); %}; 15 | void* norms_ptr() const 16 | %code%{ RETVAL = THIS->verts.empty() ? 0 : &THIS->norms.front(); %}; 17 | }; 18 | 19 | %package{Slic3r::GUI::_3DScene}; 20 | %{ 21 | 22 | void 23 | _extrusionentity_to_verts_do(Lines lines, std::vector widths, std::vector heights, bool closed, double top_z, Point* copy, GLVertexArray* qverts, GLVertexArray* tverts) 24 | CODE: 25 | _3DScene::_extrusionentity_to_verts_do(lines, widths, heights, closed, 26 | top_z, *copy, qverts, tverts); 27 | 28 | %} -------------------------------------------------------------------------------- /xs/xsp/Geometry.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/Geometry.hpp" 6 | %} 7 | 8 | 9 | %package{Slic3r::Geometry}; 10 | 11 | Pointfs arrange(size_t total_parts, Pointf* part, coordf_t dist, BoundingBoxf* bb = NULL) 12 | %code{% 13 | Pointfs points; 14 | if (! Slic3r::Geometry::arrange(total_parts, *part, dist, bb, points)) 15 | CONFESS("%zu parts won't fit in your print area!\n", total_parts); 16 | RETVAL = points; 17 | %}; 18 | 19 | %{ 20 | 21 | bool 22 | directions_parallel(angle1, angle2) 23 | double angle1 24 | double angle2 25 | CODE: 26 | RETVAL = Slic3r::Geometry::directions_parallel(angle1, angle2); 27 | OUTPUT: 28 | RETVAL 29 | 30 | bool 31 | directions_parallel_within(angle1, angle2, max_diff) 32 | double angle1 33 | double angle2 34 | double max_diff 35 | CODE: 36 | RETVAL = Slic3r::Geometry::directions_parallel(angle1, angle2, max_diff); 37 | OUTPUT: 38 | RETVAL 39 | 40 | Clone 41 | convex_hull(points) 42 | Points points 43 | CODE: 44 | RETVAL = Slic3r::Geometry::convex_hull(points); 45 | OUTPUT: 46 | RETVAL 47 | 48 | std::vector 49 | chained_path(points) 50 | Points points 51 | CODE: 52 | Slic3r::Geometry::chained_path(points, RETVAL); 53 | OUTPUT: 54 | RETVAL 55 | 56 | std::vector 57 | chained_path_from(points, start_from) 58 | Points points 59 | Point* start_from 60 | CODE: 61 | Slic3r::Geometry::chained_path(points, RETVAL, *start_from); 62 | OUTPUT: 63 | RETVAL 64 | 65 | double 66 | rad2deg(angle) 67 | double angle 68 | CODE: 69 | RETVAL = Slic3r::Geometry::rad2deg(angle); 70 | OUTPUT: 71 | RETVAL 72 | 73 | double 74 | rad2deg_dir(angle) 75 | double angle 76 | CODE: 77 | RETVAL = Slic3r::Geometry::rad2deg_dir(angle); 78 | OUTPUT: 79 | RETVAL 80 | 81 | double 82 | deg2rad(angle) 83 | double angle 84 | CODE: 85 | RETVAL = Slic3r::Geometry::deg2rad(angle); 86 | OUTPUT: 87 | RETVAL 88 | 89 | 90 | IV 91 | _constant() 92 | ALIAS: 93 | X = X 94 | Y = Y 95 | Z = Z 96 | PROTOTYPE: 97 | CODE: 98 | RETVAL = ix; 99 | OUTPUT: RETVAL 100 | 101 | %} 102 | 103 | -------------------------------------------------------------------------------- /xs/xsp/LayerHeightSpline.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/LayerHeightSpline.hpp" 6 | %} 7 | 8 | %name{Slic3r::LayerHeightSpline} class LayerHeightSpline { 9 | LayerHeightSpline(); 10 | Clone clone() 11 | %code%{ RETVAL = THIS; %}; 12 | 13 | void setObjectHeight(coordf_t object_height); 14 | bool hasData(); 15 | bool setLayers(std::vector layers) 16 | %code%{ RETVAL = THIS->setLayers(layers); %}; 17 | bool updateLayerHeights(std::vector heights) 18 | %code%{ RETVAL = THIS->updateLayerHeights(heights); %}; 19 | bool layersUpdated(); 20 | bool layerHeightsUpdated(); 21 | void clear(); 22 | std::vector getOriginalLayers(); 23 | std::vector getInterpolatedLayers(); 24 | coordf_t getLayerHeightAt(coordf_t height); 25 | }; 26 | -------------------------------------------------------------------------------- /xs/xsp/MotionPlanner.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/MotionPlanner.hpp" 6 | %} 7 | 8 | %name{Slic3r::MotionPlanner} class MotionPlanner { 9 | MotionPlanner(ExPolygons islands); 10 | ~MotionPlanner(); 11 | 12 | int islands_count(); 13 | Clone shortest_path(Point* from, Point* to) 14 | %code%{ RETVAL = THIS->shortest_path(*from, *to); %}; 15 | }; 16 | -------------------------------------------------------------------------------- /xs/xsp/NonplanarFacet.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/NonplanarFacet.hpp" 6 | %} 7 | 8 | %name{Slic3r::NonplanarFacet} class NonplanarFacet { 9 | NonplanarFacet(); 10 | ~NonplanarFacet(); 11 | }; -------------------------------------------------------------------------------- /xs/xsp/NonplanarSurface.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/NonplanarSurface.hpp" 6 | %} 7 | 8 | %name{Slic3r::NonplanarSurface} class NonplanarSurface { 9 | NonplanarSurface(); 10 | ~NonplanarSurface(); 11 | }; -------------------------------------------------------------------------------- /xs/xsp/PerimeterGenerator.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/PerimeterGenerator.hpp" 6 | %} 7 | 8 | %name{Slic3r::Layer::PerimeterGenerator} class PerimeterGenerator { 9 | PerimeterGenerator(SurfaceCollection* slices, double layer_height, Flow* flow, 10 | StaticPrintConfig* region_config, StaticPrintConfig* object_config, 11 | StaticPrintConfig* print_config, ExtrusionEntityCollection* loops, 12 | ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces) 13 | %code{% RETVAL = new PerimeterGenerator(slices, layer_height, *flow, 14 | dynamic_cast(region_config), 15 | dynamic_cast(object_config), 16 | dynamic_cast(print_config), 17 | loops, gap_fill, fill_surfaces); %}; 18 | ~PerimeterGenerator(); 19 | 20 | void set_lower_slices(ExPolygonCollection* lower_slices) 21 | %code{% THIS->lower_slices = lower_slices; %}; 22 | void set_layer_id(int layer_id) 23 | %code{% THIS->layer_id = layer_id; %}; 24 | void set_perimeter_flow(Flow* flow) 25 | %code{% THIS->perimeter_flow = *flow; %}; 26 | void set_ext_perimeter_flow(Flow* flow) 27 | %code{% THIS->ext_perimeter_flow = *flow; %}; 28 | void set_overhang_flow(Flow* flow) 29 | %code{% THIS->overhang_flow = *flow; %}; 30 | void set_solid_infill_flow(Flow* flow) 31 | %code{% THIS->solid_infill_flow = *flow; %}; 32 | 33 | Ref config() 34 | %code{% RETVAL = THIS->config; %}; 35 | 36 | void process(); 37 | }; 38 | -------------------------------------------------------------------------------- /xs/xsp/PlaceholderParser.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include 6 | #include "libslic3r/PlaceholderParser.hpp" 7 | %} 8 | 9 | %name{Slic3r::GCode::PlaceholderParser} class PlaceholderParser { 10 | PlaceholderParser(); 11 | ~PlaceholderParser(); 12 | Clone clone() 13 | %code{% RETVAL = THIS; %}; 14 | 15 | void update_timestamp(); 16 | void apply_env_variables(); 17 | void apply_config(DynamicPrintConfig *config) 18 | %code%{ THIS->apply_config(*config); %}; 19 | void set(std::string key, std::string value); 20 | %name{set_multiple} void set(std::string key, std::vector values); 21 | std::string process(std::string str) const; 22 | }; 23 | -------------------------------------------------------------------------------- /xs/xsp/Polygon.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/BoundingBox.hpp" 6 | #include "libslic3r/Polygon.hpp" 7 | #include "libslic3r/BoundingBox.hpp" 8 | %} 9 | 10 | %name{Slic3r::Polygon} class Polygon { 11 | ~Polygon(); 12 | Clone clone() 13 | %code{% RETVAL = THIS; %}; 14 | SV* arrayref() 15 | %code{% RETVAL = to_AV(THIS); %}; 16 | SV* pp() 17 | %code{% RETVAL = to_SV_pureperl(THIS); %}; 18 | void scale(double factor); 19 | void translate(double x, double y); 20 | void reverse(); 21 | Lines lines(); 22 | Clone split_at_vertex(Point* point) 23 | %code{% RETVAL = THIS->split_at_vertex(*point); %}; 24 | Clone split_at_index(int index); 25 | Clone split_at_first_point(); 26 | Points equally_spaced_points(double distance); 27 | double length(); 28 | double area(); 29 | bool is_counter_clockwise(); 30 | bool is_clockwise(); 31 | bool make_counter_clockwise(); 32 | bool make_clockwise(); 33 | bool is_valid(); 34 | Clone first_point(); 35 | bool contains_point(Point* point) 36 | %code{% RETVAL = THIS->contains(*point); %}; 37 | Polygons simplify(double tolerance); 38 | Polygons triangulate_convex() 39 | %code{% THIS->triangulate_convex(&RETVAL); %}; 40 | Clone centroid(); 41 | Clone bounding_box(); 42 | std::string wkt(); 43 | Points concave_points(double angle); 44 | Points convex_points(double angle); 45 | Clone intersection(Line* line) 46 | %code{% 47 | Point p; 48 | (void)THIS->intersection(*line, &p); 49 | RETVAL = p; 50 | %}; 51 | %{ 52 | 53 | Polygon* 54 | Polygon::new(...) 55 | CODE: 56 | RETVAL = new Polygon (); 57 | // ST(0) is class name, ST(1) is first point 58 | RETVAL->points.resize(items-1); 59 | for (unsigned int i = 1; i < items; i++) { 60 | from_SV_check(ST(i), &RETVAL->points[i-1]); 61 | } 62 | OUTPUT: 63 | RETVAL 64 | 65 | void 66 | Polygon::rotate(angle, center_sv) 67 | double angle; 68 | SV* center_sv; 69 | CODE: 70 | Point center; 71 | from_SV_check(center_sv, ¢er); 72 | THIS->rotate(angle, center); 73 | 74 | %} 75 | }; 76 | -------------------------------------------------------------------------------- /xs/xsp/PolylineCollection.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/PolylineCollection.hpp" 6 | %} 7 | 8 | %name{Slic3r::Polyline::Collection} class PolylineCollection { 9 | ~PolylineCollection(); 10 | Clone clone() 11 | %code{% RETVAL = THIS; %}; 12 | void clear() 13 | %code{% THIS->polylines.clear(); %}; 14 | PolylineCollection* chained_path(bool no_reverse) 15 | %code{% 16 | RETVAL = new PolylineCollection(); 17 | THIS->chained_path(RETVAL, no_reverse); 18 | %}; 19 | PolylineCollection* chained_path_from(Point* start_near, bool no_reverse) 20 | %code{% 21 | RETVAL = new PolylineCollection(); 22 | THIS->chained_path_from(*start_near, RETVAL, no_reverse); 23 | %}; 24 | int count() 25 | %code{% RETVAL = THIS->polylines.size(); %}; 26 | Clone leftmost_point(); 27 | %{ 28 | 29 | PolylineCollection* 30 | PolylineCollection::new(...) 31 | CODE: 32 | RETVAL = new PolylineCollection (); 33 | // ST(0) is class name, others are Polylines 34 | RETVAL->polylines.resize(items-1); 35 | for (unsigned int i = 1; i < items; i++) { 36 | // Note: a COPY of the input is stored 37 | from_SV_check(ST(i), &RETVAL->polylines[i-1]); 38 | } 39 | OUTPUT: 40 | RETVAL 41 | 42 | SV* 43 | PolylineCollection::arrayref() 44 | CODE: 45 | AV* av = newAV(); 46 | av_fill(av, THIS->polylines.size()-1); 47 | int i = 0; 48 | for (Polylines::iterator it = THIS->polylines.begin(); it != THIS->polylines.end(); ++it) { 49 | av_store(av, i++, perl_to_SV_ref(*it)); 50 | } 51 | RETVAL = newRV_noinc((SV*)av); 52 | OUTPUT: 53 | RETVAL 54 | 55 | SV* 56 | PolylineCollection::pp() 57 | CODE: 58 | AV* av = newAV(); 59 | av_fill(av, THIS->polylines.size()-1); 60 | int i = 0; 61 | for (Polylines::iterator it = THIS->polylines.begin(); it != THIS->polylines.end(); ++it) { 62 | av_store(av, i++, to_SV_pureperl(&*it)); 63 | } 64 | RETVAL = newRV_noinc((SV*)av); 65 | OUTPUT: 66 | RETVAL 67 | 68 | void 69 | PolylineCollection::append(...) 70 | CODE: 71 | for (unsigned int i = 1; i < items; i++) { 72 | Polyline polyline; 73 | from_SV_check(ST(i), &polyline); 74 | THIS->polylines.push_back(polyline); 75 | } 76 | 77 | %} 78 | }; 79 | -------------------------------------------------------------------------------- /xs/xsp/SLAPrint.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/SLAPrint.hpp" 6 | %} 7 | 8 | %name{Slic3r::SLAPrint} class SLAPrint { 9 | SLAPrint(Model* model); 10 | ~SLAPrint(); 11 | 12 | void apply_config(DynamicPrintConfig* config) 13 | %code%{ THIS->config.apply(*config, true); %}; 14 | void slice(); 15 | size_t layer_count() 16 | %code{% RETVAL = THIS->layers.size(); %}; 17 | 18 | DynamicPrintConfig* config() 19 | %code%{ RETVAL = new DynamicPrintConfig; RETVAL->apply(THIS->config); %}; 20 | 21 | ExPolygons layer_slices(size_t i) 22 | %code%{ RETVAL = THIS->layers[i].slices; %}; 23 | ExPolygons layer_solid_infill(size_t i) 24 | %code%{ RETVAL = THIS->layers[i].solid_infill; %}; 25 | ExPolygons layer_perimeters(size_t i) 26 | %code%{ RETVAL = THIS->layers[i].perimeters; %}; 27 | Ref layer_infill(size_t i) 28 | %code%{ RETVAL = &THIS->layers[i].infill; %}; 29 | bool layer_solid(size_t i) 30 | %code%{ RETVAL = THIS->layers[i].solid; %}; 31 | void write_svg(std::string file); 32 | 33 | %{ 34 | 35 | std::vector 36 | SLAPrint::heights() 37 | CODE: 38 | for (std::vector::const_iterator it = THIS->layers.begin(); 39 | it != THIS->layers.end(); 40 | ++it) 41 | RETVAL.push_back(it->print_z); 42 | OUTPUT: 43 | RETVAL 44 | 45 | SV* 46 | SLAPrint::sm_pillars() 47 | CODE: 48 | AV* av = newAV(); 49 | for (std::vector::const_iterator it = THIS->sm_pillars.begin(); 50 | it != THIS->sm_pillars.end(); 51 | ++it) 52 | { 53 | HV* hv = newHV(); 54 | (void)hv_stores( hv, "top_layer", newSViv(it->top_layer) ); 55 | (void)hv_stores( hv, "bottom_layer", newSViv(it->bottom_layer) ); 56 | (void)hv_stores( hv, "point", perl_to_SV_clone_ref((Point)*it) ); 57 | av_push(av, newRV_noinc((SV*)hv)); 58 | } 59 | RETVAL = newRV_noinc((SV*)av); 60 | OUTPUT: 61 | RETVAL 62 | 63 | %} 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /xs/xsp/SlicingAdaptive.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | %{ 4 | #include 5 | #include "libslic3r/SlicingAdaptive.hpp" 6 | %} 7 | 8 | %name{Slic3r::SlicingAdaptive} class SlicingAdaptive { 9 | SlicingAdaptive(); 10 | ~SlicingAdaptive(); 11 | void clear(); 12 | void add_mesh(TriangleMesh *mesh); 13 | void prepare(coordf_t object_size); 14 | float next_layer_height(coordf_t z, coordf_t quality_factor, coordf_t min_layer_height, coordf_t max_layer_height); 15 | float horizontal_facet_distance(coordf_t z, coordf_t max_layer_height); 16 | }; 17 | -------------------------------------------------------------------------------- /xs/xsp/SupportMaterial.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | 3 | #include 4 | #include "libslic3r/SupportMaterial.hpp" 5 | 6 | %package{Slic3r::Print::SupportMaterial}; 7 | %{ 8 | 9 | SV* 10 | MARGIN() 11 | PROTOTYPE: 12 | CODE: 13 | RETVAL = newSVnv(SUPPORT_MATERIAL_MARGIN); 14 | OUTPUT: RETVAL 15 | 16 | %} -------------------------------------------------------------------------------- /xs/xsp/XS.xsp: -------------------------------------------------------------------------------- 1 | %module{Slic3r::XS}; 2 | %package{Slic3r::XS}; 3 | 4 | #include 5 | 6 | %{ 7 | 8 | %} 9 | 10 | %package{Slic3r}; 11 | %{ 12 | 13 | SV* 14 | VERSION() 15 | CODE: 16 | RETVAL = newSVpv(SLIC3R_VERSION, 0); 17 | OUTPUT: RETVAL 18 | 19 | void 20 | xspp_test_croak_hangs_on_strawberry() 21 | CODE: 22 | try { 23 | throw 1; 24 | } catch (...) { 25 | croak("xspp_test_croak_hangs_on_strawberry: exception catched\n"); 26 | } 27 | %} 28 | -------------------------------------------------------------------------------- /xs/xsp/mytype.map: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zip-o-mat/Slic3r/f898061a448f00545ccef24e8ac8b037e1d44867/xs/xsp/mytype.map --------------------------------------------------------------------------------