meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7020__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meerk40t/__init__.py +1 -1
- meerk40t/balormk/balor_params.py +167 -167
- meerk40t/balormk/clone_loader.py +457 -457
- meerk40t/balormk/controller.py +1566 -1512
- meerk40t/balormk/cylindermod.py +64 -0
- meerk40t/balormk/device.py +966 -1959
- meerk40t/balormk/driver.py +778 -591
- meerk40t/balormk/galvo_commands.py +1194 -0
- meerk40t/balormk/gui/balorconfig.py +237 -111
- meerk40t/balormk/gui/balorcontroller.py +191 -184
- meerk40t/balormk/gui/baloroperationproperties.py +116 -115
- meerk40t/balormk/gui/corscene.py +845 -0
- meerk40t/balormk/gui/gui.py +179 -147
- meerk40t/balormk/livelightjob.py +466 -382
- meerk40t/balormk/mock_connection.py +131 -109
- meerk40t/balormk/plugin.py +133 -135
- meerk40t/balormk/usb_connection.py +306 -301
- meerk40t/camera/__init__.py +1 -1
- meerk40t/camera/camera.py +514 -397
- meerk40t/camera/gui/camerapanel.py +1241 -1095
- meerk40t/camera/gui/gui.py +58 -58
- meerk40t/camera/plugin.py +441 -399
- meerk40t/ch341/__init__.py +27 -27
- meerk40t/ch341/ch341device.py +628 -628
- meerk40t/ch341/libusb.py +595 -589
- meerk40t/ch341/mock.py +171 -171
- meerk40t/ch341/windriver.py +157 -157
- meerk40t/constants.py +13 -0
- meerk40t/core/__init__.py +1 -1
- meerk40t/core/bindalias.py +550 -539
- meerk40t/core/core.py +47 -47
- meerk40t/core/cutcode/cubiccut.py +73 -73
- meerk40t/core/cutcode/cutcode.py +315 -312
- meerk40t/core/cutcode/cutgroup.py +141 -137
- meerk40t/core/cutcode/cutobject.py +192 -185
- meerk40t/core/cutcode/dwellcut.py +37 -37
- meerk40t/core/cutcode/gotocut.py +29 -29
- meerk40t/core/cutcode/homecut.py +29 -29
- meerk40t/core/cutcode/inputcut.py +34 -34
- meerk40t/core/cutcode/linecut.py +33 -33
- meerk40t/core/cutcode/outputcut.py +34 -34
- meerk40t/core/cutcode/plotcut.py +335 -335
- meerk40t/core/cutcode/quadcut.py +61 -61
- meerk40t/core/cutcode/rastercut.py +168 -148
- meerk40t/core/cutcode/waitcut.py +34 -34
- meerk40t/core/cutplan.py +1843 -1316
- meerk40t/core/drivers.py +330 -329
- meerk40t/core/elements/align.py +801 -669
- meerk40t/core/elements/branches.py +1858 -1507
- meerk40t/core/elements/clipboard.py +229 -219
- meerk40t/core/elements/element_treeops.py +4595 -2837
- meerk40t/core/elements/element_types.py +125 -105
- meerk40t/core/elements/elements.py +4315 -3617
- meerk40t/core/elements/files.py +117 -64
- meerk40t/core/elements/geometry.py +473 -224
- meerk40t/core/elements/grid.py +467 -316
- meerk40t/core/elements/materials.py +158 -94
- meerk40t/core/elements/notes.py +50 -38
- meerk40t/core/elements/offset_clpr.py +934 -912
- meerk40t/core/elements/offset_mk.py +963 -955
- meerk40t/core/elements/penbox.py +339 -267
- meerk40t/core/elements/placements.py +300 -83
- meerk40t/core/elements/render.py +785 -687
- meerk40t/core/elements/shapes.py +2618 -2092
- meerk40t/core/elements/testcases.py +105 -0
- meerk40t/core/elements/trace.py +651 -563
- meerk40t/core/elements/tree_commands.py +415 -409
- meerk40t/core/elements/undo_redo.py +116 -58
- meerk40t/core/elements/wordlist.py +319 -200
- meerk40t/core/exceptions.py +9 -9
- meerk40t/core/laserjob.py +220 -220
- meerk40t/core/logging.py +63 -63
- meerk40t/core/node/blobnode.py +83 -86
- meerk40t/core/node/bootstrap.py +105 -103
- meerk40t/core/node/branch_elems.py +40 -31
- meerk40t/core/node/branch_ops.py +45 -38
- meerk40t/core/node/branch_regmark.py +48 -41
- meerk40t/core/node/cutnode.py +29 -32
- meerk40t/core/node/effect_hatch.py +375 -257
- meerk40t/core/node/effect_warp.py +398 -0
- meerk40t/core/node/effect_wobble.py +441 -309
- meerk40t/core/node/elem_ellipse.py +404 -309
- meerk40t/core/node/elem_image.py +1082 -801
- meerk40t/core/node/elem_line.py +358 -292
- meerk40t/core/node/elem_path.py +259 -201
- meerk40t/core/node/elem_point.py +129 -102
- meerk40t/core/node/elem_polyline.py +310 -246
- meerk40t/core/node/elem_rect.py +376 -286
- meerk40t/core/node/elem_text.py +445 -418
- meerk40t/core/node/filenode.py +59 -40
- meerk40t/core/node/groupnode.py +138 -74
- meerk40t/core/node/image_processed.py +777 -766
- meerk40t/core/node/image_raster.py +156 -113
- meerk40t/core/node/layernode.py +31 -31
- meerk40t/core/node/mixins.py +135 -107
- meerk40t/core/node/node.py +1427 -1304
- meerk40t/core/node/nutils.py +117 -114
- meerk40t/core/node/op_cut.py +463 -335
- meerk40t/core/node/op_dots.py +296 -251
- meerk40t/core/node/op_engrave.py +414 -311
- meerk40t/core/node/op_image.py +755 -369
- meerk40t/core/node/op_raster.py +787 -522
- meerk40t/core/node/place_current.py +37 -40
- meerk40t/core/node/place_point.py +329 -126
- meerk40t/core/node/refnode.py +58 -47
- meerk40t/core/node/rootnode.py +225 -219
- meerk40t/core/node/util_console.py +48 -48
- meerk40t/core/node/util_goto.py +84 -65
- meerk40t/core/node/util_home.py +61 -61
- meerk40t/core/node/util_input.py +102 -102
- meerk40t/core/node/util_output.py +102 -102
- meerk40t/core/node/util_wait.py +65 -65
- meerk40t/core/parameters.py +709 -707
- meerk40t/core/planner.py +875 -785
- meerk40t/core/plotplanner.py +656 -652
- meerk40t/core/space.py +120 -113
- meerk40t/core/spoolers.py +706 -705
- meerk40t/core/svg_io.py +1836 -1549
- meerk40t/core/treeop.py +534 -445
- meerk40t/core/undos.py +278 -124
- meerk40t/core/units.py +784 -680
- meerk40t/core/view.py +393 -322
- meerk40t/core/webhelp.py +62 -62
- meerk40t/core/wordlist.py +513 -504
- meerk40t/cylinder/cylinder.py +247 -0
- meerk40t/cylinder/gui/cylindersettings.py +41 -0
- meerk40t/cylinder/gui/gui.py +24 -0
- meerk40t/device/__init__.py +1 -1
- meerk40t/device/basedevice.py +322 -123
- meerk40t/device/devicechoices.py +50 -0
- meerk40t/device/dummydevice.py +163 -128
- meerk40t/device/gui/defaultactions.py +618 -602
- meerk40t/device/gui/effectspanel.py +114 -0
- meerk40t/device/gui/formatterpanel.py +253 -290
- meerk40t/device/gui/warningpanel.py +337 -260
- meerk40t/device/mixins.py +13 -13
- meerk40t/dxf/__init__.py +1 -1
- meerk40t/dxf/dxf_io.py +766 -554
- meerk40t/dxf/plugin.py +47 -35
- meerk40t/external_plugins.py +79 -79
- meerk40t/external_plugins_build.py +28 -28
- meerk40t/extra/cag.py +112 -116
- meerk40t/extra/coolant.py +403 -0
- meerk40t/extra/encode_detect.py +204 -0
- meerk40t/extra/ezd.py +1165 -1165
- meerk40t/extra/hershey.py +834 -340
- meerk40t/extra/imageactions.py +322 -316
- meerk40t/extra/inkscape.py +628 -622
- meerk40t/extra/lbrn.py +424 -424
- meerk40t/extra/outerworld.py +283 -0
- meerk40t/extra/param_functions.py +1542 -1556
- meerk40t/extra/potrace.py +257 -253
- meerk40t/extra/serial_exchange.py +118 -0
- meerk40t/extra/updater.py +602 -453
- meerk40t/extra/vectrace.py +147 -146
- meerk40t/extra/winsleep.py +83 -83
- meerk40t/extra/xcs_reader.py +597 -0
- meerk40t/fill/fills.py +781 -335
- meerk40t/fill/patternfill.py +1061 -1061
- meerk40t/fill/patterns.py +614 -567
- meerk40t/grbl/control.py +87 -87
- meerk40t/grbl/controller.py +990 -903
- meerk40t/grbl/device.py +1084 -768
- meerk40t/grbl/driver.py +989 -771
- meerk40t/grbl/emulator.py +532 -497
- meerk40t/grbl/gcodejob.py +783 -767
- meerk40t/grbl/gui/grblconfiguration.py +373 -298
- meerk40t/grbl/gui/grblcontroller.py +485 -271
- meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
- meerk40t/grbl/gui/grbloperationconfig.py +105 -0
- meerk40t/grbl/gui/gui.py +147 -116
- meerk40t/grbl/interpreter.py +44 -44
- meerk40t/grbl/loader.py +22 -22
- meerk40t/grbl/mock_connection.py +56 -56
- meerk40t/grbl/plugin.py +294 -264
- meerk40t/grbl/serial_connection.py +93 -88
- meerk40t/grbl/tcp_connection.py +81 -79
- meerk40t/grbl/ws_connection.py +112 -0
- meerk40t/gui/__init__.py +1 -1
- meerk40t/gui/about.py +2042 -296
- meerk40t/gui/alignment.py +1644 -1608
- meerk40t/gui/autoexec.py +199 -0
- meerk40t/gui/basicops.py +791 -670
- meerk40t/gui/bufferview.py +77 -71
- meerk40t/gui/busy.py +232 -133
- meerk40t/gui/choicepropertypanel.py +1662 -1469
- meerk40t/gui/consolepanel.py +706 -542
- meerk40t/gui/devicepanel.py +687 -581
- meerk40t/gui/dialogoptions.py +110 -107
- meerk40t/gui/executejob.py +316 -306
- meerk40t/gui/fonts.py +90 -90
- meerk40t/gui/functionwrapper.py +252 -0
- meerk40t/gui/gui_mixins.py +729 -0
- meerk40t/gui/guicolors.py +205 -182
- meerk40t/gui/help_assets/help_assets.py +218 -201
- meerk40t/gui/helper.py +154 -0
- meerk40t/gui/hersheymanager.py +1440 -846
- meerk40t/gui/icons.py +3422 -2747
- meerk40t/gui/imagesplitter.py +555 -508
- meerk40t/gui/keymap.py +354 -344
- meerk40t/gui/laserpanel.py +897 -806
- meerk40t/gui/laserrender.py +1470 -1232
- meerk40t/gui/lasertoolpanel.py +805 -793
- meerk40t/gui/magnetoptions.py +436 -0
- meerk40t/gui/materialmanager.py +2944 -0
- meerk40t/gui/materialtest.py +1722 -1694
- meerk40t/gui/mkdebug.py +646 -359
- meerk40t/gui/mwindow.py +163 -140
- meerk40t/gui/navigationpanels.py +2605 -2467
- meerk40t/gui/notes.py +143 -142
- meerk40t/gui/opassignment.py +414 -410
- meerk40t/gui/operation_info.py +310 -299
- meerk40t/gui/plugin.py +500 -328
- meerk40t/gui/position.py +714 -669
- meerk40t/gui/preferences.py +901 -650
- meerk40t/gui/propertypanels/attributes.py +1461 -1131
- meerk40t/gui/propertypanels/blobproperty.py +117 -114
- meerk40t/gui/propertypanels/consoleproperty.py +83 -80
- meerk40t/gui/propertypanels/gotoproperty.py +77 -0
- meerk40t/gui/propertypanels/groupproperties.py +223 -217
- meerk40t/gui/propertypanels/hatchproperty.py +489 -469
- meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
- meerk40t/gui/propertypanels/inputproperty.py +59 -58
- meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
- meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
- meerk40t/gui/propertypanels/outputproperty.py +59 -58
- meerk40t/gui/propertypanels/pathproperty.py +389 -380
- meerk40t/gui/propertypanels/placementproperty.py +1214 -383
- meerk40t/gui/propertypanels/pointproperty.py +140 -136
- meerk40t/gui/propertypanels/propertywindow.py +313 -181
- meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
- meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
- meerk40t/gui/propertypanels/textproperty.py +770 -755
- meerk40t/gui/propertypanels/waitproperty.py +56 -55
- meerk40t/gui/propertypanels/warpproperty.py +121 -0
- meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
- meerk40t/gui/ribbon.py +2471 -2210
- meerk40t/gui/scene/scene.py +1100 -1051
- meerk40t/gui/scene/sceneconst.py +22 -22
- meerk40t/gui/scene/scenepanel.py +439 -349
- meerk40t/gui/scene/scenespacewidget.py +365 -365
- meerk40t/gui/scene/widget.py +518 -505
- meerk40t/gui/scenewidgets/affinemover.py +215 -215
- meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
- meerk40t/gui/scenewidgets/bedwidget.py +120 -97
- meerk40t/gui/scenewidgets/elementswidget.py +137 -107
- meerk40t/gui/scenewidgets/gridwidget.py +785 -745
- meerk40t/gui/scenewidgets/guidewidget.py +765 -765
- meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
- meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
- meerk40t/gui/scenewidgets/nodeselector.py +28 -28
- meerk40t/gui/scenewidgets/rectselectwidget.py +592 -346
- meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
- meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
- meerk40t/gui/scenewidgets/selectionwidget.py +2958 -2756
- meerk40t/gui/simpleui.py +362 -333
- meerk40t/gui/simulation.py +2451 -2094
- meerk40t/gui/snapoptions.py +208 -203
- meerk40t/gui/spoolerpanel.py +1227 -1180
- meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
- meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
- meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
- meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
- meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
- meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
- meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
- meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
- meerk40t/gui/themes.py +200 -78
- meerk40t/gui/tips.py +590 -0
- meerk40t/gui/toolwidgets/circlebrush.py +35 -35
- meerk40t/gui/toolwidgets/toolcircle.py +248 -242
- meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
- meerk40t/gui/toolwidgets/tooldraw.py +97 -90
- meerk40t/gui/toolwidgets/toolellipse.py +219 -212
- meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
- meerk40t/gui/toolwidgets/toolline.py +39 -144
- meerk40t/gui/toolwidgets/toollinetext.py +79 -236
- meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
- meerk40t/gui/toolwidgets/toolmeasure.py +163 -216
- meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
- meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
- meerk40t/gui/toolwidgets/toolparameter.py +754 -668
- meerk40t/gui/toolwidgets/toolplacement.py +108 -108
- meerk40t/gui/toolwidgets/toolpoint.py +68 -59
- meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
- meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
- meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
- meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
- meerk40t/gui/toolwidgets/toolrect.py +211 -207
- meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
- meerk40t/gui/toolwidgets/toolribbon.py +598 -113
- meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
- meerk40t/gui/toolwidgets/tooltext.py +98 -89
- meerk40t/gui/toolwidgets/toolvector.py +213 -204
- meerk40t/gui/toolwidgets/toolwidget.py +39 -39
- meerk40t/gui/usbconnect.py +98 -91
- meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
- meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
- meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
- meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
- meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
- meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
- meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
- meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
- meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
- meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
- meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
- meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
- meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
- meerk40t/gui/wordlisteditor.py +985 -931
- meerk40t/gui/wxmeerk40t.py +1447 -1169
- meerk40t/gui/wxmmain.py +5644 -4112
- meerk40t/gui/wxmribbon.py +1591 -1076
- meerk40t/gui/wxmscene.py +1631 -1453
- meerk40t/gui/wxmtree.py +2416 -2089
- meerk40t/gui/wxutils.py +1769 -1099
- meerk40t/gui/zmatrix.py +102 -102
- meerk40t/image/__init__.py +1 -1
- meerk40t/image/dither.py +429 -0
- meerk40t/image/imagetools.py +2793 -2269
- meerk40t/internal_plugins.py +150 -130
- meerk40t/kernel/__init__.py +63 -12
- meerk40t/kernel/channel.py +259 -212
- meerk40t/kernel/context.py +538 -538
- meerk40t/kernel/exceptions.py +41 -41
- meerk40t/kernel/functions.py +463 -414
- meerk40t/kernel/jobs.py +100 -100
- meerk40t/kernel/kernel.py +3828 -3571
- meerk40t/kernel/lifecycles.py +71 -71
- meerk40t/kernel/module.py +49 -49
- meerk40t/kernel/service.py +147 -147
- meerk40t/kernel/settings.py +383 -343
- meerk40t/lihuiyu/controller.py +883 -876
- meerk40t/lihuiyu/device.py +1181 -1069
- meerk40t/lihuiyu/driver.py +1466 -1372
- meerk40t/lihuiyu/gui/gui.py +127 -106
- meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
- meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
- meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
- meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
- meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
- meerk40t/lihuiyu/interpreter.py +53 -53
- meerk40t/lihuiyu/laserspeed.py +450 -450
- meerk40t/lihuiyu/loader.py +90 -90
- meerk40t/lihuiyu/parser.py +404 -404
- meerk40t/lihuiyu/plugin.py +101 -102
- meerk40t/lihuiyu/tcp_connection.py +111 -109
- meerk40t/main.py +231 -165
- meerk40t/moshi/builder.py +788 -781
- meerk40t/moshi/controller.py +505 -499
- meerk40t/moshi/device.py +495 -442
- meerk40t/moshi/driver.py +862 -696
- meerk40t/moshi/gui/gui.py +78 -76
- meerk40t/moshi/gui/moshicontrollergui.py +538 -522
- meerk40t/moshi/gui/moshidrivergui.py +87 -75
- meerk40t/moshi/plugin.py +43 -43
- meerk40t/network/console_server.py +140 -57
- meerk40t/network/kernelserver.py +10 -9
- meerk40t/network/tcp_server.py +142 -140
- meerk40t/network/udp_server.py +103 -77
- meerk40t/network/web_server.py +404 -0
- meerk40t/newly/controller.py +1158 -1144
- meerk40t/newly/device.py +874 -732
- meerk40t/newly/driver.py +540 -412
- meerk40t/newly/gui/gui.py +219 -188
- meerk40t/newly/gui/newlyconfig.py +116 -101
- meerk40t/newly/gui/newlycontroller.py +193 -186
- meerk40t/newly/gui/operationproperties.py +51 -51
- meerk40t/newly/mock_connection.py +82 -82
- meerk40t/newly/newly_params.py +56 -56
- meerk40t/newly/plugin.py +1214 -1246
- meerk40t/newly/usb_connection.py +322 -322
- meerk40t/rotary/gui/gui.py +52 -46
- meerk40t/rotary/gui/rotarysettings.py +240 -232
- meerk40t/rotary/rotary.py +202 -98
- meerk40t/ruida/control.py +291 -91
- meerk40t/ruida/controller.py +138 -1088
- meerk40t/ruida/device.py +676 -231
- meerk40t/ruida/driver.py +534 -472
- meerk40t/ruida/emulator.py +1494 -1491
- meerk40t/ruida/exceptions.py +4 -4
- meerk40t/ruida/gui/gui.py +71 -76
- meerk40t/ruida/gui/ruidaconfig.py +239 -72
- meerk40t/ruida/gui/ruidacontroller.py +187 -184
- meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
- meerk40t/ruida/loader.py +54 -52
- meerk40t/ruida/mock_connection.py +57 -109
- meerk40t/ruida/plugin.py +124 -87
- meerk40t/ruida/rdjob.py +2084 -945
- meerk40t/ruida/serial_connection.py +116 -0
- meerk40t/ruida/tcp_connection.py +146 -0
- meerk40t/ruida/udp_connection.py +73 -0
- meerk40t/svgelements.py +9671 -9669
- meerk40t/tools/driver_to_path.py +584 -579
- meerk40t/tools/geomstr.py +5583 -4680
- meerk40t/tools/jhfparser.py +357 -292
- meerk40t/tools/kerftest.py +904 -890
- meerk40t/tools/livinghinges.py +1168 -1033
- meerk40t/tools/pathtools.py +987 -949
- meerk40t/tools/pmatrix.py +234 -0
- meerk40t/tools/pointfinder.py +942 -942
- meerk40t/tools/polybool.py +941 -940
- meerk40t/tools/rasterplotter.py +1660 -547
- meerk40t/tools/shxparser.py +1047 -901
- meerk40t/tools/ttfparser.py +726 -446
- meerk40t/tools/zinglplotter.py +595 -593
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/LICENSE +21 -21
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/METADATA +150 -139
- meerk40t-0.9.7020.dist-info/RECORD +446 -0
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/WHEEL +1 -1
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/top_level.txt +0 -1
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/zip-safe +1 -1
- meerk40t/balormk/elementlightjob.py +0 -159
- meerk40t-0.9.3001.dist-info/RECORD +0 -437
- test/bootstrap.py +0 -63
- test/test_cli.py +0 -12
- test/test_core_cutcode.py +0 -418
- test/test_core_elements.py +0 -144
- test/test_core_plotplanner.py +0 -397
- test/test_core_viewports.py +0 -312
- test/test_drivers_grbl.py +0 -108
- test/test_drivers_lihuiyu.py +0 -443
- test/test_drivers_newly.py +0 -113
- test/test_element_degenerate_points.py +0 -43
- test/test_elements_classify.py +0 -97
- test/test_elements_penbox.py +0 -22
- test/test_file_svg.py +0 -176
- test/test_fill.py +0 -155
- test/test_geomstr.py +0 -1523
- test/test_geomstr_nodes.py +0 -18
- test/test_imagetools_actualize.py +0 -306
- test/test_imagetools_wizard.py +0 -258
- test/test_kernel.py +0 -200
- test/test_laser_speeds.py +0 -3303
- test/test_length.py +0 -57
- test/test_lifecycle.py +0 -66
- test/test_operations.py +0 -251
- test/test_operations_hatch.py +0 -57
- test/test_ruida.py +0 -19
- test/test_spooler.py +0 -22
- test/test_tools_rasterplotter.py +0 -29
- test/test_wobble.py +0 -133
- test/test_zingl.py +0 -124
- {test → meerk40t/cylinder}/__init__.py +0 -0
- /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
- {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/entry_points.txt +0 -0
test/test_geomstr.py
DELETED
@@ -1,1523 +0,0 @@
|
|
1
|
-
import math
|
2
|
-
import random
|
3
|
-
import time
|
4
|
-
import unittest
|
5
|
-
from copy import copy
|
6
|
-
from math import tau
|
7
|
-
|
8
|
-
import numpy as np
|
9
|
-
|
10
|
-
from meerk40t.fill.fills import scanline_fill
|
11
|
-
from meerk40t.fill.patterns import set_diamond1, set_line
|
12
|
-
from meerk40t.svgelements import Arc, CubicBezier, Line, Matrix, QuadraticBezier
|
13
|
-
from meerk40t.tools.geomstr import (
|
14
|
-
TYPE_LINE,
|
15
|
-
TYPE_POINT,
|
16
|
-
BeamTable,
|
17
|
-
Clip,
|
18
|
-
Geomstr,
|
19
|
-
MergeGraph,
|
20
|
-
Pattern,
|
21
|
-
Polygon,
|
22
|
-
Scanbeam,
|
23
|
-
)
|
24
|
-
|
25
|
-
|
26
|
-
def draw(segments, min_x, min_y, max_x, max_y, buffer=0, filename="test.png"):
|
27
|
-
from PIL import Image, ImageDraw
|
28
|
-
|
29
|
-
min_x -= buffer
|
30
|
-
min_y -= buffer
|
31
|
-
max_x += buffer
|
32
|
-
max_y += buffer
|
33
|
-
im = Image.new("RGBA", (int(max_x - min_x) + 1, int(max_y - min_y) + 1), "white")
|
34
|
-
|
35
|
-
draw = ImageDraw.Draw(im)
|
36
|
-
for i in range(len(segments) - 1):
|
37
|
-
# Draw raw segments.
|
38
|
-
f = segments[i]
|
39
|
-
t = segments[i + 1]
|
40
|
-
if f is None or t is None:
|
41
|
-
continue
|
42
|
-
draw.line(
|
43
|
-
((f.real - min_x, f.imag - min_y), (t.real - min_x, t.imag - min_y)),
|
44
|
-
fill="#000000",
|
45
|
-
)
|
46
|
-
# for segment in segments:
|
47
|
-
# # Draw end points.
|
48
|
-
# f = segment[0]
|
49
|
-
# t = segment[-1]
|
50
|
-
# draw.ellipse((f.real - 3, f.imag - 3, f.real + 3, f.imag + 3), fill="#FF0000")
|
51
|
-
# draw.ellipse((t.real - 2, t.imag - 2, t.real + 2, t.imag + 2), fill="#0000FF")
|
52
|
-
im.save(filename)
|
53
|
-
|
54
|
-
|
55
|
-
def draw_geom(segments, min_x, min_y, max_x, max_y, buffer=0, filename="test.png"):
|
56
|
-
from PIL import Image, ImageDraw
|
57
|
-
|
58
|
-
min_x -= buffer
|
59
|
-
min_y -= buffer
|
60
|
-
max_x += buffer
|
61
|
-
max_y += buffer
|
62
|
-
im = Image.new("RGBA", (int(max_x - min_x) + 1, int(max_y - min_y) + 1), "white")
|
63
|
-
|
64
|
-
draw = ImageDraw.Draw(im)
|
65
|
-
for line in segments.segments[: segments.index]:
|
66
|
-
if line[2].real == TYPE_POINT:
|
67
|
-
f = line[0]
|
68
|
-
draw.ellipse(
|
69
|
-
(
|
70
|
-
f.real - 3 - min_x,
|
71
|
-
f.imag - 3 - min_y,
|
72
|
-
f.real + 3 - min_x,
|
73
|
-
f.imag + 3 - min_y,
|
74
|
-
),
|
75
|
-
fill="#FF0000",
|
76
|
-
)
|
77
|
-
elif line[2].real == TYPE_LINE:
|
78
|
-
# Draw raw segments.
|
79
|
-
f = line[0]
|
80
|
-
t = line[-1]
|
81
|
-
draw.line(
|
82
|
-
((f.real - min_x, f.imag - min_y), (t.real - min_x, t.imag - min_y)),
|
83
|
-
fill="#000000",
|
84
|
-
)
|
85
|
-
im.save(filename)
|
86
|
-
|
87
|
-
|
88
|
-
def random_point(i=100):
|
89
|
-
return complex(random.random() * i, random.random() * i)
|
90
|
-
|
91
|
-
|
92
|
-
def random_pointi(i=50):
|
93
|
-
return complex(random.randint(0, i), random.randint(0, i))
|
94
|
-
|
95
|
-
|
96
|
-
def random_segment(path, i=100, point=True, line=True, quad=True, cubic=True, arc=True):
|
97
|
-
t = random.randint(0, 5)
|
98
|
-
if t == 0 and point:
|
99
|
-
start = random_point(i=i)
|
100
|
-
path.point(start)
|
101
|
-
elif t == 1 and line:
|
102
|
-
start = random_point(i=i)
|
103
|
-
end = random_point(i=i)
|
104
|
-
path.line(start, end)
|
105
|
-
elif t == 2 and quad:
|
106
|
-
start = random_point(i=i)
|
107
|
-
control = random_point(i=i)
|
108
|
-
end = random_point(i=i)
|
109
|
-
path.quad(start, control, end)
|
110
|
-
elif t == 3 and cubic:
|
111
|
-
start = random_point(i=i)
|
112
|
-
c1 = random_point(i=i)
|
113
|
-
c2 = random_point(i=i)
|
114
|
-
end = random_point(i=i)
|
115
|
-
path.cubic(start, c1, c2, end)
|
116
|
-
elif t == 4 and arc:
|
117
|
-
start = random_point(i=i)
|
118
|
-
control = random_point(i=i)
|
119
|
-
end = random_point(i=i)
|
120
|
-
path.arc(start, control, end)
|
121
|
-
else:
|
122
|
-
random_segment(
|
123
|
-
path, i=i, point=point, line=line, quad=quad, cubic=cubic, arc=arc
|
124
|
-
)
|
125
|
-
|
126
|
-
|
127
|
-
class TestGeomstr(unittest.TestCase):
|
128
|
-
"""These tests ensure the basic functions of the Geomstr elements."""
|
129
|
-
|
130
|
-
def test_geomstr_translate_scale(self):
|
131
|
-
w = 10000
|
132
|
-
h = 10000
|
133
|
-
numpath = Geomstr()
|
134
|
-
numpath.polyline(
|
135
|
-
(
|
136
|
-
complex(0.05, 0.05),
|
137
|
-
complex(0.95, 0.05),
|
138
|
-
complex(0.95, 0.95),
|
139
|
-
complex(0.05, 0.95),
|
140
|
-
complex(0.05, 0.05),
|
141
|
-
)
|
142
|
-
)
|
143
|
-
numpath.polyline(
|
144
|
-
(
|
145
|
-
complex(0.25, 0.25),
|
146
|
-
complex(0.75, 0.25),
|
147
|
-
complex(0.75, 0.75),
|
148
|
-
complex(0.25, 0.75),
|
149
|
-
complex(0.25, 0.25),
|
150
|
-
)
|
151
|
-
)
|
152
|
-
numpath.uscale(w)
|
153
|
-
|
154
|
-
numpath2 = Geomstr()
|
155
|
-
numpath2.polyline(
|
156
|
-
(
|
157
|
-
complex(w * 0.05, h * 0.05),
|
158
|
-
complex(w * 0.95, h * 0.05),
|
159
|
-
complex(w * 0.95, h * 0.95),
|
160
|
-
complex(w * 0.05, h * 0.95),
|
161
|
-
complex(w * 0.05, h * 0.05),
|
162
|
-
)
|
163
|
-
)
|
164
|
-
numpath2.polyline(
|
165
|
-
(
|
166
|
-
complex(w * 0.25, h * 0.25),
|
167
|
-
complex(w * 0.75, h * 0.25),
|
168
|
-
complex(w * 0.75, h * 0.75),
|
169
|
-
complex(w * 0.25, h * 0.75),
|
170
|
-
complex(w * 0.25, h * 0.25),
|
171
|
-
)
|
172
|
-
)
|
173
|
-
q = numpath.segments == numpath2.segments
|
174
|
-
self.assertTrue(np.all(numpath.segments == numpath2.segments))
|
175
|
-
numpath.translate(3, 3)
|
176
|
-
self.assertFalse(np.all(numpath.segments == numpath2.segments))
|
177
|
-
numpath.translate(-3, -3)
|
178
|
-
self.assertTrue(np.all(numpath.segments == numpath2.segments))
|
179
|
-
|
180
|
-
def test_geomstr_bbox(self):
|
181
|
-
w = 10000
|
182
|
-
geomstr = Geomstr()
|
183
|
-
geomstr.polyline(
|
184
|
-
(
|
185
|
-
complex(0.05, 0.05),
|
186
|
-
complex(0.95, 0.05),
|
187
|
-
complex(0.95, 0.95),
|
188
|
-
complex(0.05, 0.95),
|
189
|
-
complex(0.05, 0.05),
|
190
|
-
)
|
191
|
-
)
|
192
|
-
geomstr.polyline(
|
193
|
-
(
|
194
|
-
complex(0.25, 0.25),
|
195
|
-
complex(0.75, 0.25),
|
196
|
-
complex(0.75, 0.75),
|
197
|
-
complex(0.25, 0.75),
|
198
|
-
complex(0.25, 0.25),
|
199
|
-
)
|
200
|
-
)
|
201
|
-
geomstr.uscale(w)
|
202
|
-
self.assertEqual(geomstr.bbox(), (500.0, 500.0, 9500.0, 9500.0))
|
203
|
-
geomstr.rotate(tau * 0.25)
|
204
|
-
for x, y in zip(geomstr.bbox(), (-9500.0, 500.00000000000057, -500.0, 9500.0)):
|
205
|
-
self.assertAlmostEqual(x, y)
|
206
|
-
|
207
|
-
def test_geomstr_transform(self):
|
208
|
-
numpath = Geomstr()
|
209
|
-
numpath.polyline(
|
210
|
-
(
|
211
|
-
complex(0.05, 0.05),
|
212
|
-
complex(0.95, 0.05),
|
213
|
-
complex(0.95, 0.95),
|
214
|
-
complex(0.05, 0.95),
|
215
|
-
complex(0.05, 0.05),
|
216
|
-
)
|
217
|
-
)
|
218
|
-
numpath.polyline(
|
219
|
-
(
|
220
|
-
complex(0.25, 0.25),
|
221
|
-
complex(0.75, 0.25),
|
222
|
-
complex(0.75, 0.75),
|
223
|
-
complex(0.25, 0.75),
|
224
|
-
complex(0.25, 0.25),
|
225
|
-
)
|
226
|
-
)
|
227
|
-
numpath.uscale(10000)
|
228
|
-
c = copy(numpath)
|
229
|
-
numpath.rotate(tau * 0.25)
|
230
|
-
c.transform(Matrix("rotate(.25turn)"))
|
231
|
-
t = numpath.segments == c.segments
|
232
|
-
self.assertTrue(np.all(t))
|
233
|
-
|
234
|
-
def test_geomstr_subpath(self):
|
235
|
-
"""
|
236
|
-
Adds two shapes and tests whether they are detected as subshapes with an `end` between them.
|
237
|
-
@return:
|
238
|
-
"""
|
239
|
-
numpath = Geomstr()
|
240
|
-
numpath.polyline(
|
241
|
-
(
|
242
|
-
complex(0.05, 0.05),
|
243
|
-
complex(0.95, 0.05),
|
244
|
-
complex(0.95, 0.95),
|
245
|
-
complex(0.05, 0.95),
|
246
|
-
complex(0.05, 0.05),
|
247
|
-
)
|
248
|
-
)
|
249
|
-
numpath.close()
|
250
|
-
numpath.end()
|
251
|
-
numpath.polyline(
|
252
|
-
(
|
253
|
-
complex(0.25, 0.25),
|
254
|
-
complex(0.75, 0.25),
|
255
|
-
complex(0.75, 0.75),
|
256
|
-
complex(0.25, 0.75),
|
257
|
-
complex(0.25, 0.25),
|
258
|
-
)
|
259
|
-
)
|
260
|
-
numpath.uscale(10000)
|
261
|
-
numpath.rotate(tau * 0.25)
|
262
|
-
subpaths = list(numpath.as_subpaths())
|
263
|
-
for subpath in subpaths:
|
264
|
-
print(subpath.segments)
|
265
|
-
for seg in subpath.segments:
|
266
|
-
self.assertEqual(seg[2].real, TYPE_LINE)
|
267
|
-
self.assertEqual(len(subpaths[0]), 4)
|
268
|
-
self.assertEqual(len(subpaths[1]), 4)
|
269
|
-
|
270
|
-
def test_geomstr_contiguous(self):
|
271
|
-
"""
|
272
|
-
Tests two disconnected polylines without marked ends between them and determines whether two
|
273
|
-
shapes are correctly detected.
|
274
|
-
@return:
|
275
|
-
"""
|
276
|
-
numpath = Geomstr()
|
277
|
-
numpath.polyline(
|
278
|
-
(
|
279
|
-
complex(0.05, 0.05),
|
280
|
-
complex(0.95, 0.05),
|
281
|
-
complex(0.95, 0.95),
|
282
|
-
complex(0.05, 0.95),
|
283
|
-
complex(0.05, 0.05),
|
284
|
-
)
|
285
|
-
)
|
286
|
-
numpath.polyline(
|
287
|
-
(
|
288
|
-
complex(0.25, 0.25),
|
289
|
-
complex(0.75, 0.25),
|
290
|
-
complex(0.75, 0.75),
|
291
|
-
complex(0.25, 0.75),
|
292
|
-
complex(0.25, 0.25),
|
293
|
-
)
|
294
|
-
)
|
295
|
-
numpath.uscale(10000)
|
296
|
-
numpath.rotate(tau * 0.25)
|
297
|
-
subpaths = list(numpath.as_contiguous())
|
298
|
-
print("")
|
299
|
-
for subpath in subpaths:
|
300
|
-
print(subpath.segments)
|
301
|
-
for seg in subpath.segments:
|
302
|
-
self.assertEqual(seg[2].real, TYPE_LINE)
|
303
|
-
self.assertEqual(len(subpaths[0]), 4)
|
304
|
-
self.assertEqual(len(subpaths[1]), 4)
|
305
|
-
|
306
|
-
def test_geomstr_subpath_contiguous(self):
|
307
|
-
"""
|
308
|
-
Create a 2-contour path within a single subpath geomstr
|
309
|
-
@return:
|
310
|
-
"""
|
311
|
-
numpath = Geomstr()
|
312
|
-
numpath.polyline(
|
313
|
-
(
|
314
|
-
complex(0.05, 0.05),
|
315
|
-
complex(0.95, 0.05),
|
316
|
-
complex(0.95, 0.95),
|
317
|
-
complex(0.05, 0.95),
|
318
|
-
complex(0.05, 0.05),
|
319
|
-
)
|
320
|
-
)
|
321
|
-
numpath.polyline(
|
322
|
-
(
|
323
|
-
complex(0.25, 0.25),
|
324
|
-
complex(0.75, 0.25),
|
325
|
-
complex(0.75, 0.75),
|
326
|
-
complex(0.25, 0.75),
|
327
|
-
complex(0.25, 0.25),
|
328
|
-
)
|
329
|
-
)
|
330
|
-
subpaths = list(numpath.as_subpaths())
|
331
|
-
self.assertEqual(len(subpaths), 1)
|
332
|
-
contigs = list(numpath.as_contiguous())
|
333
|
-
self.assertEqual(len(contigs), 2)
|
334
|
-
|
335
|
-
def test_geomstr_scanline(self):
|
336
|
-
w = 10000
|
337
|
-
h = 10000
|
338
|
-
paths = (
|
339
|
-
complex(w * 0.05, h * 0.05),
|
340
|
-
complex(w * 0.95, h * 0.05),
|
341
|
-
complex(w * 0.95, h * 0.95),
|
342
|
-
complex(w * 0.05, h * 0.95),
|
343
|
-
complex(w * 0.05, h * 0.05),
|
344
|
-
None,
|
345
|
-
complex(w * 0.25, h * 0.25),
|
346
|
-
complex(w * 0.75, h * 0.25),
|
347
|
-
complex(w * 0.75, h * 0.75),
|
348
|
-
complex(w * 0.25, h * 0.75),
|
349
|
-
complex(w * 0.25, h * 0.25),
|
350
|
-
)
|
351
|
-
|
352
|
-
fill = list(
|
353
|
-
scanline_fill(
|
354
|
-
settings={"hatch_distance": "0.02mm"}, outlines=paths, matrix=None
|
355
|
-
)
|
356
|
-
)
|
357
|
-
path = Geomstr()
|
358
|
-
last_x = None
|
359
|
-
last_y = None
|
360
|
-
for p in fill:
|
361
|
-
if p is None:
|
362
|
-
last_x = None
|
363
|
-
last_y = None
|
364
|
-
continue
|
365
|
-
x, y = p
|
366
|
-
if last_x is not None:
|
367
|
-
path.line(complex(last_x, last_y), complex(x, y))
|
368
|
-
last_x, last_y = x, y
|
369
|
-
p = copy(path)
|
370
|
-
self.assertNotEqual(path, p)
|
371
|
-
#
|
372
|
-
# print(path.segments)
|
373
|
-
# print("Original segments...")
|
374
|
-
# print(p.travel_distance())
|
375
|
-
# p.two_opt_distance()
|
376
|
-
# print(p.travel_distance())
|
377
|
-
# print(p.segments)
|
378
|
-
# draw(p.segments, w, h)
|
379
|
-
|
380
|
-
def test_geomstr_y_intercepts(self):
|
381
|
-
"""
|
382
|
-
Draws, 5 perfectly horizontal lines. Queries the y_intercepts
|
383
|
-
@return:
|
384
|
-
"""
|
385
|
-
g = Geomstr()
|
386
|
-
g.line(complex(0, 20), complex(100, 20))
|
387
|
-
g.line(complex(0, 40), complex(100, 40))
|
388
|
-
g.line(complex(0, 80), complex(100, 80))
|
389
|
-
g.line(complex(0, 60), complex(100, 60))
|
390
|
-
g.line(complex(0, 100), complex(100, 100))
|
391
|
-
q = g.y_intercept([0, 1, 2, 3, 4], 10)
|
392
|
-
self.assertEqual(q[0], 20.0)
|
393
|
-
self.assertEqual(q[1], 40.0)
|
394
|
-
self.assertEqual(q[2], 80.0)
|
395
|
-
self.assertEqual(q[3], 60.0)
|
396
|
-
self.assertEqual(q[4], 100.0)
|
397
|
-
|
398
|
-
def test_geomstr_x_intercepts(self):
|
399
|
-
"""
|
400
|
-
Draws, 5 perfectly vertical lines. Queries the x_intercepts
|
401
|
-
@return:
|
402
|
-
"""
|
403
|
-
g = Geomstr()
|
404
|
-
g.line(complex(20, 0), complex(20, 100))
|
405
|
-
g.line(complex(40, 0), complex(40, 100))
|
406
|
-
g.line(complex(80, 0), complex(80, 100))
|
407
|
-
g.line(complex(60, 0), complex(60, 100))
|
408
|
-
g.line(complex(100, 0), complex(100, 100))
|
409
|
-
q = g.x_intercept([0, 1, 2, 3, 4], 10)
|
410
|
-
self.assertEqual(q[0], 20.0)
|
411
|
-
self.assertEqual(q[1], 40.0)
|
412
|
-
self.assertEqual(q[2], 80.0)
|
413
|
-
self.assertEqual(q[3], 60.0)
|
414
|
-
self.assertEqual(q[4], 100.0)
|
415
|
-
|
416
|
-
def test_geomstr_classmethods(self):
|
417
|
-
"""
|
418
|
-
Test various classmethods for making defined geomstr shapes.
|
419
|
-
@return:
|
420
|
-
"""
|
421
|
-
path = Geomstr.lines(0, 1, 0, 101)
|
422
|
-
self.assertEqual(len(path), 1)
|
423
|
-
self.assertEqual(path.length(0), 100)
|
424
|
-
path = Geomstr.lines(100, 100, 0, 100)
|
425
|
-
self.assertEqual(len(path), 1)
|
426
|
-
self.assertEqual(path.length(0), 100)
|
427
|
-
path = Geomstr.lines(0, 0, 1, 1)
|
428
|
-
self.assertEqual(len(path), 1)
|
429
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
430
|
-
|
431
|
-
path = Geomstr.lines(0, 0, 1, 1, 2, 2)
|
432
|
-
self.assertEqual(len(path), 2)
|
433
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
434
|
-
self.assertEqual(path.length(1), math.sqrt(2))
|
435
|
-
|
436
|
-
path = Geomstr.lines((0, 0), (1, 1), (2, 2))
|
437
|
-
self.assertEqual(len(path), 2)
|
438
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
439
|
-
self.assertEqual(path.length(1), math.sqrt(2))
|
440
|
-
|
441
|
-
path = Geomstr.lines(complex(0, 0), complex(1, 1), complex(2, 2))
|
442
|
-
self.assertEqual(len(path), 2)
|
443
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
444
|
-
self.assertEqual(path.length(1), math.sqrt(2))
|
445
|
-
|
446
|
-
for i in range(50):
|
447
|
-
path = Geomstr.regular_polygon(
|
448
|
-
i, 100 + 100j, radius=50, radius_inner=30, alt_seq=1, density=5
|
449
|
-
)
|
450
|
-
# draw(path.segments[:path.index], 200, 200, filename=f"test{i}.png")
|
451
|
-
|
452
|
-
q = np.array([complex(0, 0), complex(1, 1), complex(2, 2)])
|
453
|
-
path = Geomstr.lines(q)
|
454
|
-
self.assertEqual(len(path), 2)
|
455
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
456
|
-
self.assertEqual(path.length(1), math.sqrt(2))
|
457
|
-
|
458
|
-
r = np.array([[0.0, 0.0], [1.0, 1.0], [2.0, 2.0]])
|
459
|
-
path = Geomstr.lines(r)
|
460
|
-
self.assertEqual(len(path), 2)
|
461
|
-
self.assertEqual(path.length(0), math.sqrt(2))
|
462
|
-
self.assertEqual(path.length(1), math.sqrt(2))
|
463
|
-
|
464
|
-
def test_geomstr_copies(self):
|
465
|
-
path = Geomstr.lines(complex(0, 0), complex(1, 1), complex(2, 2))
|
466
|
-
path.copies(2)
|
467
|
-
self.assertEqual(len(path), 4)
|
468
|
-
self.assertTrue(np.all(path.segments[:][0] == path.segments[:][2]))
|
469
|
-
self.assertTrue(np.all(path.segments[:][1] == path.segments[:][3]))
|
470
|
-
|
471
|
-
def test_geomstr_interpolated_points(self):
|
472
|
-
path = Geomstr.lines(complex(0, 0), complex(1, 1), complex(2, 2))
|
473
|
-
path.quad(complex(2, 2), complex(5, 0), complex(4, 4))
|
474
|
-
self.assertEqual(len(path), 3)
|
475
|
-
pts = list(path.as_interpolated_points(interpolate=100))
|
476
|
-
self.assertEqual(102, len(pts))
|
477
|
-
|
478
|
-
def test_geomstr_arc_center(self):
|
479
|
-
for i in range(1000):
|
480
|
-
start = random_point()
|
481
|
-
control = random_point()
|
482
|
-
end = random_point()
|
483
|
-
c = Arc(start=start, control=control, end=end)
|
484
|
-
|
485
|
-
path = Geomstr()
|
486
|
-
path.arc(start, control, end)
|
487
|
-
|
488
|
-
self.assertAlmostEqual(complex(c.center), path.arc_center(0))
|
489
|
-
|
490
|
-
def test_geomstr_arc_radius(self):
|
491
|
-
for i in range(1000):
|
492
|
-
start = random_point()
|
493
|
-
control = random_point()
|
494
|
-
end = random_point()
|
495
|
-
c = Arc(start=start, control=control, end=end)
|
496
|
-
|
497
|
-
path = Geomstr()
|
498
|
-
path.arc(start, control, end)
|
499
|
-
|
500
|
-
self.assertAlmostEqual(c.rx, path.arc_radius(0))
|
501
|
-
self.assertAlmostEqual(c.ry, path.arc_radius(0))
|
502
|
-
|
503
|
-
def test_geomstr_line_point(self):
|
504
|
-
for i in range(1000):
|
505
|
-
start = random_point()
|
506
|
-
end = random_point()
|
507
|
-
c = Line(start, end)
|
508
|
-
|
509
|
-
path = Geomstr()
|
510
|
-
path.line(start, end)
|
511
|
-
t = random.random()
|
512
|
-
self.assertEqual(c.point(t), path.position(0, t))
|
513
|
-
|
514
|
-
def test_geomstr_quad_point(self):
|
515
|
-
for i in range(1000):
|
516
|
-
start = random_point()
|
517
|
-
control = random_point()
|
518
|
-
end = random_point()
|
519
|
-
c = QuadraticBezier(start, control, end)
|
520
|
-
|
521
|
-
path = Geomstr()
|
522
|
-
path.quad(start, control, end)
|
523
|
-
|
524
|
-
t = random.random()
|
525
|
-
self.assertEqual(c.point(t), path.position(0, t))
|
526
|
-
|
527
|
-
def test_geomstr_cubic_point(self):
|
528
|
-
for i in range(1000):
|
529
|
-
start = random_point()
|
530
|
-
c1 = random_point()
|
531
|
-
c2 = random_point()
|
532
|
-
end = random_point()
|
533
|
-
c = CubicBezier(start, c1, c2, end)
|
534
|
-
|
535
|
-
path = Geomstr()
|
536
|
-
path.cubic(start, c1, c2, end)
|
537
|
-
|
538
|
-
t = random.random()
|
539
|
-
self.assertEqual(c.point(t), path.position(0, t))
|
540
|
-
|
541
|
-
def test_geomstr_cubic_length(self):
|
542
|
-
"""
|
543
|
-
This test is too time-consuming without scipy installed
|
544
|
-
@return:
|
545
|
-
"""
|
546
|
-
try:
|
547
|
-
import scipy
|
548
|
-
except ImportError:
|
549
|
-
return
|
550
|
-
difference = 0
|
551
|
-
t0 = 0
|
552
|
-
t1 = 0
|
553
|
-
for i in range(50):
|
554
|
-
start = random_point()
|
555
|
-
c1 = random_point()
|
556
|
-
c2 = random_point()
|
557
|
-
end = random_point()
|
558
|
-
c = CubicBezier(start, c1, c2, end)
|
559
|
-
|
560
|
-
path = Geomstr()
|
561
|
-
path.cubic(start, c1, c2, end)
|
562
|
-
t = time.time()
|
563
|
-
clen = c.length()
|
564
|
-
t0 += time.time() - t
|
565
|
-
|
566
|
-
t = time.time()
|
567
|
-
plen = path.length(0)
|
568
|
-
t1 += time.time() - t
|
569
|
-
self.assertAlmostEqual(clen, plen, delta=0.1)
|
570
|
-
difference += clen
|
571
|
-
difference -= plen
|
572
|
-
print(
|
573
|
-
f"geomstr cubic length time {t0}. svgelements cubic length time {t1}. total difference {difference}"
|
574
|
-
)
|
575
|
-
|
576
|
-
def test_geomstr_line_bounds(self):
|
577
|
-
for i in range(1000):
|
578
|
-
start = random_point()
|
579
|
-
end = random_point()
|
580
|
-
c = Line(start, end)
|
581
|
-
|
582
|
-
path = Geomstr()
|
583
|
-
path.line(start, end)
|
584
|
-
|
585
|
-
self.assertEqual(c.bbox(), path.bbox(0))
|
586
|
-
|
587
|
-
def test_geomstr_quad_bounds(self):
|
588
|
-
for i in range(1000):
|
589
|
-
start = random_point()
|
590
|
-
control = random_point()
|
591
|
-
end = random_point()
|
592
|
-
c = QuadraticBezier(start, control, end)
|
593
|
-
|
594
|
-
path = Geomstr()
|
595
|
-
path.quad(start, control, end)
|
596
|
-
|
597
|
-
self.assertEqual(c.bbox(), path.bbox(0))
|
598
|
-
|
599
|
-
def test_geomstr_cubic_bounds(self):
|
600
|
-
for i in range(1000):
|
601
|
-
start = random_point()
|
602
|
-
c1 = random_point()
|
603
|
-
c2 = random_point()
|
604
|
-
end = random_point()
|
605
|
-
c = CubicBezier(start, c1, c2, end)
|
606
|
-
|
607
|
-
path = Geomstr()
|
608
|
-
path.cubic(start, c1, c2, end)
|
609
|
-
|
610
|
-
self.assertEqual(c.bbox(), path.bbox(0))
|
611
|
-
|
612
|
-
def test_geomstr_point_functions(self):
|
613
|
-
from math import radians, sqrt
|
614
|
-
|
615
|
-
p = Geomstr()
|
616
|
-
p.point(complex(4, 4))
|
617
|
-
q = p.towards(0, complex(6, 6), 0.5)
|
618
|
-
self.assertEqual(q, complex(5, 5))
|
619
|
-
|
620
|
-
m = p.distance(0, complex(6, 6))
|
621
|
-
self.assertEqual(m, 2 * sqrt(2))
|
622
|
-
m = p.distance(0, complex(4, 0))
|
623
|
-
self.assertEqual(m, 4)
|
624
|
-
a45 = radians(45)
|
625
|
-
a90 = radians(90)
|
626
|
-
a180 = radians(180)
|
627
|
-
|
628
|
-
p.point(complex(0, 0))
|
629
|
-
a = p.angle(1, complex(3, 3))
|
630
|
-
self.assertEqual(a, a45)
|
631
|
-
a = p.angle(1, complex(0, 3))
|
632
|
-
self.assertEqual(a, a90)
|
633
|
-
a = p.angle(1, complex(-3, 0))
|
634
|
-
self.assertEqual(a, a180)
|
635
|
-
|
636
|
-
q = p.polar(1, a45, 10)
|
637
|
-
self.assertAlmostEqual(q, complex(sqrt(2) / 2 * 10, sqrt(2) / 2 * 10))
|
638
|
-
|
639
|
-
r = p.reflected(1, complex(10, 10))
|
640
|
-
self.assertEqual(r, complex(20, 20))
|
641
|
-
|
642
|
-
def test_geomstr_point_towards_static(self):
|
643
|
-
p = complex(4, 4)
|
644
|
-
q = Geomstr.towards(None, p, complex(6, 6), 0.5)
|
645
|
-
self.assertEqual(q, complex(5, 5))
|
646
|
-
|
647
|
-
def test_geomstr_point_distance_static(self):
|
648
|
-
from math import sqrt
|
649
|
-
|
650
|
-
p = complex(4, 4)
|
651
|
-
m = Geomstr.distance(None, p, complex(6, 6))
|
652
|
-
self.assertEqual(m, 2 * sqrt(2))
|
653
|
-
m = Geomstr.distance(None, p, complex(4, 0))
|
654
|
-
self.assertEqual(m, 4)
|
655
|
-
|
656
|
-
def test_geomstr_point_angle_static(self):
|
657
|
-
from math import radians
|
658
|
-
|
659
|
-
p = complex(0, 0)
|
660
|
-
a = Geomstr.angle(None, p, complex(3, 3))
|
661
|
-
a45 = radians(45)
|
662
|
-
self.assertEqual(a, a45)
|
663
|
-
a = Geomstr.angle(None, p, complex(0, 3))
|
664
|
-
a90 = radians(90)
|
665
|
-
self.assertEqual(a, a90)
|
666
|
-
a = Geomstr.angle(None, p, complex(-3, 0))
|
667
|
-
a180 = radians(180)
|
668
|
-
self.assertEqual(a, a180)
|
669
|
-
|
670
|
-
def test_geomstr_point_polar_static(self):
|
671
|
-
from math import radians, sqrt
|
672
|
-
|
673
|
-
p = complex(0)
|
674
|
-
a = radians(45)
|
675
|
-
q = Geomstr.polar(None, p, a, 10)
|
676
|
-
self.assertAlmostEqual(q, complex(sqrt(2) / 2 * 10, sqrt(2) / 2 * 10))
|
677
|
-
|
678
|
-
def test_geomstr_point_reflected_static(self):
|
679
|
-
p = complex(0)
|
680
|
-
r = Geomstr.reflected(None, p, complex(10, 10))
|
681
|
-
self.assertEqual(r, complex(20, 20))
|
682
|
-
|
683
|
-
def test_geomstr_simple_length_bbox(self):
|
684
|
-
path = Geomstr()
|
685
|
-
path.line(complex(0, 0), complex(50, 0))
|
686
|
-
self.assertEqual(len(path), 1)
|
687
|
-
self.assertEqual(path.raw_length(), 50)
|
688
|
-
self.assertEqual(path.bbox(), (0, 0, 50, 0))
|
689
|
-
path.line(complex(50, 0), complex(50, 50))
|
690
|
-
self.assertEqual(path.raw_length(), 100)
|
691
|
-
|
692
|
-
def test_geomstr_convex_hull(self):
|
693
|
-
path = Geomstr()
|
694
|
-
path.polyline(
|
695
|
-
[
|
696
|
-
complex(0, 0),
|
697
|
-
complex(100, 0),
|
698
|
-
complex(50, 50),
|
699
|
-
complex(100, 100),
|
700
|
-
complex(0, 100),
|
701
|
-
complex(0, 0),
|
702
|
-
]
|
703
|
-
)
|
704
|
-
pts = list(path.convex_hull(range(5)))
|
705
|
-
self.assertNotIn(complex(50, 50), pts)
|
706
|
-
self.assertEqual(len(pts), 4)
|
707
|
-
|
708
|
-
def test_geomstr_2opt(self):
|
709
|
-
path = Geomstr()
|
710
|
-
path.line(complex(0, 0), complex(50, 0))
|
711
|
-
path.line(complex(50, 50), complex(50, 0))
|
712
|
-
self.assertEqual(path.raw_length(), 100)
|
713
|
-
self.assertEqual(path.travel_distance(), 50)
|
714
|
-
path.two_opt_distance()
|
715
|
-
self.assertEqual(path.travel_distance(), 0)
|
716
|
-
|
717
|
-
def test_geomstr_scanbeam_build(self):
|
718
|
-
"""
|
719
|
-
Build the scanbeam. In a correct scanbeam we should be able to iterate
|
720
|
-
through the scanbeam adding or removing each segment without issue.
|
721
|
-
|
722
|
-
No remove segment ~x should occur before the append segment x value.
|
723
|
-
:return:
|
724
|
-
"""
|
725
|
-
for trials in range(50):
|
726
|
-
path = Geomstr()
|
727
|
-
for i in range(500):
|
728
|
-
path.line(
|
729
|
-
random_point(50),
|
730
|
-
random_point(50),
|
731
|
-
)
|
732
|
-
|
733
|
-
beam = Scanbeam(path)
|
734
|
-
m = list()
|
735
|
-
for v, idx in beam._sorted_edge_list:
|
736
|
-
if idx >= 0:
|
737
|
-
m.append(idx)
|
738
|
-
else:
|
739
|
-
try:
|
740
|
-
m.remove(~idx)
|
741
|
-
except ValueError as e:
|
742
|
-
raise e
|
743
|
-
self.assertEqual(len(m), 0)
|
744
|
-
beam.compute_beam()
|
745
|
-
|
746
|
-
def test_geomstr_scanbeam_increment(self):
|
747
|
-
path = Geomstr()
|
748
|
-
path.line(complex(0, 0), complex(50, 0)) # 0
|
749
|
-
path.line(complex(50, 0), complex(50, 50)) # 1 ACTIVE
|
750
|
-
path.line(complex(50, 50), complex(0, 50)) # 2
|
751
|
-
path.line(complex(0, 50), complex(0, 0)) # 3 ACTIVE
|
752
|
-
path.close()
|
753
|
-
self.assertEqual(path.travel_distance(), 0)
|
754
|
-
beam = Scanbeam(path)
|
755
|
-
beam.scanline_to(25)
|
756
|
-
self.assertEqual(len(beam._active_edge_list), 2)
|
757
|
-
|
758
|
-
def test_geomstr_scanbeam_decrement(self):
|
759
|
-
path = Geomstr()
|
760
|
-
path.line(complex(0, 0), complex(50, 0)) # 0
|
761
|
-
path.line(complex(50, 0), complex(50, 50)) # 1 ACTIVE
|
762
|
-
path.line(complex(50, 50), complex(0, 50)) # 2
|
763
|
-
path.line(complex(0, 50), complex(0, 0)) # 3 ACTIVE
|
764
|
-
path.close()
|
765
|
-
self.assertEqual(path.travel_distance(), 0)
|
766
|
-
beam = Scanbeam(path)
|
767
|
-
beam.scanline_to(float("inf"))
|
768
|
-
self.assertEqual(len(beam._active_edge_list), 0)
|
769
|
-
beam.scanline_to(25)
|
770
|
-
self.assertEqual(len(beam._active_edge_list), 2)
|
771
|
-
|
772
|
-
def test_geomstr_isinside(self):
|
773
|
-
path = Geomstr()
|
774
|
-
path.line(complex(0, 0), complex(50, 0))
|
775
|
-
path.line(complex(50, 0), complex(50, 50))
|
776
|
-
path.line(complex(50, 50), complex(0, 50))
|
777
|
-
path.line(complex(0, 50), complex(0, 0))
|
778
|
-
beam = Scanbeam(path)
|
779
|
-
self.assertTrue(beam.is_point_inside(25, 25))
|
780
|
-
|
781
|
-
path.line(complex(10, 10), complex(40, 10))
|
782
|
-
path.line(complex(40, 10), complex(40, 40))
|
783
|
-
path.line(complex(40, 40), complex(10, 40))
|
784
|
-
path.line(complex(10, 40), complex(10, 10))
|
785
|
-
beam = Scanbeam(path)
|
786
|
-
self.assertFalse(beam.is_point_inside(25, 25))
|
787
|
-
self.assertTrue(beam.is_point_inside(5, 25))
|
788
|
-
|
789
|
-
def test_geomstr_merge_intersections(self):
|
790
|
-
subject = Geomstr()
|
791
|
-
subject.line(complex(0, 0), complex(100, 100))
|
792
|
-
clip = Geomstr()
|
793
|
-
clip.line(complex(100, 0), complex(0, 100))
|
794
|
-
mg = MergeGraph(subject)
|
795
|
-
results = mg.find_intersections(clip)
|
796
|
-
self.assertEqual(len(results), 1)
|
797
|
-
self.assertEqual(results[0], (50, 50, 0, 0, 0))
|
798
|
-
|
799
|
-
def test_geomstr_intersect_segments(self):
|
800
|
-
path = Geomstr()
|
801
|
-
for i in range(50):
|
802
|
-
random_segment(path)
|
803
|
-
|
804
|
-
for j in range(path.index):
|
805
|
-
for k in range(path.index):
|
806
|
-
q = f"{path.segment_type(j)} x {path.segment_type(k)}: {list(path.intersections(j, k))}"
|
807
|
-
# print(q)
|
808
|
-
|
809
|
-
def test_geomstr_merge_merge(self):
|
810
|
-
subject = Geomstr()
|
811
|
-
subject.line(complex(0, 20), complex(100, 100))
|
812
|
-
subject.line(complex(20, 0), complex(100, 100))
|
813
|
-
clip = Geomstr()
|
814
|
-
clip.line(complex(100, 0), complex(0, 100))
|
815
|
-
mg = MergeGraph(subject)
|
816
|
-
results = mg.merge(clip)
|
817
|
-
print(results.segments)
|
818
|
-
|
819
|
-
def test_geomstr_merge_capacity_count(self):
|
820
|
-
for j in range(25):
|
821
|
-
clip = Geomstr()
|
822
|
-
for i in range(50):
|
823
|
-
clip.line(
|
824
|
-
random_pointi(50),
|
825
|
-
random_pointi(50),
|
826
|
-
)
|
827
|
-
subject = Geomstr()
|
828
|
-
for i in range(50):
|
829
|
-
subject.line(
|
830
|
-
random_pointi(50),
|
831
|
-
random_pointi(50),
|
832
|
-
)
|
833
|
-
mg = MergeGraph(subject)
|
834
|
-
results = mg.merge(clip)
|
835
|
-
self.assertEqual(results.index, results.capacity)
|
836
|
-
|
837
|
-
def test_geomstr_merge_order(self):
|
838
|
-
subject = Geomstr()
|
839
|
-
subject.line(complex(50, 0), complex(50, 100))
|
840
|
-
clip = Geomstr()
|
841
|
-
clip.line(complex(0, 20), complex(100, 20))
|
842
|
-
clip.line(complex(0, 40), complex(100, 40))
|
843
|
-
clip.line(complex(0, 80), complex(100, 80))
|
844
|
-
clip.line(complex(0, 60), complex(100, 60))
|
845
|
-
clip.line(complex(0, 100), complex(100, 100))
|
846
|
-
mg = MergeGraph(subject)
|
847
|
-
results = mg.merge(clip)
|
848
|
-
print(results)
|
849
|
-
|
850
|
-
def test_pattern_generation(self):
|
851
|
-
f = set_diamond1
|
852
|
-
p = Pattern()
|
853
|
-
p.create_from_pattern(f)
|
854
|
-
for s in p.generate(0, 0, 1, 1):
|
855
|
-
array = np.array(
|
856
|
-
[
|
857
|
-
[-1.0 + 0.0j, 0.0 + 0.0j, 41.0 + 0.0j, 0.0 + 0.0j, -0.5 - 0.5j],
|
858
|
-
[-0.5 - 0.5j, 0.0 + 0.0j, 41.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0j],
|
859
|
-
[0.0 + 0.0j, 0.0 + 0.0j, 41.0 + 0.0j, 0.0 + 0.0j, -0.5 + 0.5j],
|
860
|
-
[-0.5 + 0.5j, 0.0 + 0.0j, 41.0 + 0.0j, 0.0 + 0.0j, -1.0 + 0.0j],
|
861
|
-
]
|
862
|
-
)
|
863
|
-
array2 = s.segments[: s.index]
|
864
|
-
# self.assertTrue((array == array2).all())
|
865
|
-
|
866
|
-
def test_pattern_generation_counts(self):
|
867
|
-
f = set_diamond1
|
868
|
-
p = Pattern()
|
869
|
-
p.create_from_pattern(f)
|
870
|
-
|
871
|
-
three_x_three_grid = list(p.generate(0, 0, 4, 4))
|
872
|
-
# self.assertEqual(len(three_x_three_grid), 16)
|
873
|
-
p.set_cell_padding(0.5, 0.5)
|
874
|
-
three_x_three_grid = list(p.generate(0, 0, 4, 4))
|
875
|
-
# 1 0.5 1 0.5 1 = 4, so 4x4 with 0.5 padding fits 3x3
|
876
|
-
# self.assertEqual(len(three_x_three_grid), 9)
|
877
|
-
p.set_cell_padding(0, 0)
|
878
|
-
for s in p.generate(0, 0, 2, 2):
|
879
|
-
print(repr(s))
|
880
|
-
print("finished.")
|
881
|
-
|
882
|
-
def test_pattern_clip(self):
|
883
|
-
t = time.time()
|
884
|
-
f = set_diamond1
|
885
|
-
p = Pattern()
|
886
|
-
p.create_from_pattern(f)
|
887
|
-
poly = Polygon(0 + 2j, 4 + 0j, 4 + 4j, 0 + 2j)
|
888
|
-
for i in range(5):
|
889
|
-
for e in range(poly.geomstr.index):
|
890
|
-
poly.geomstr.split(e, 0.5)
|
891
|
-
poly.geomstr.uscale(15)
|
892
|
-
q = Clip(poly.geomstr)
|
893
|
-
|
894
|
-
clip = Geomstr()
|
895
|
-
for s in list(p.generate(*q.bounds)):
|
896
|
-
clip.append(s)
|
897
|
-
|
898
|
-
clipped = q.clip(clip)
|
899
|
-
# clipped.uscale(20)
|
900
|
-
# print(f"Time took {time.time() - t}")
|
901
|
-
#
|
902
|
-
# from PIL import ImageDraw, Image
|
903
|
-
#
|
904
|
-
# x0, y0, x1, y1 = clipped.bbox()
|
905
|
-
#
|
906
|
-
# img = Image.new("L", size=(int(x1-x0)+20, int(y1-y0) + 20), color="white")
|
907
|
-
# draw = ImageDraw.Draw(img)
|
908
|
-
# clipped.draw(draw, int(x0) + 10, int(y0) +10)
|
909
|
-
# img.save("test.png")
|
910
|
-
|
911
|
-
def test_point_in_polygon_beat(self):
|
912
|
-
"""
|
913
|
-
Raytraced comparison with our geomstr version.
|
914
|
-
|
915
|
-
See:
|
916
|
-
https://stackoverflow.com/questions/36399381/whats-the-fastest-way-of-checking-if-a-point-is-inside-a-polygon-in-python
|
917
|
-
@return:
|
918
|
-
"""
|
919
|
-
|
920
|
-
def points_in_polygon(polygon, pts):
|
921
|
-
pts = np.asarray(pts, dtype="float32")
|
922
|
-
polygon = np.asarray(polygon, dtype="float32")
|
923
|
-
contour2 = np.vstack((polygon[1:], polygon[:1]))
|
924
|
-
test_diff = contour2 - polygon
|
925
|
-
mask1 = (pts[:, None] == polygon).all(-1).any(-1)
|
926
|
-
m1 = (polygon[:, 1] > pts[:, None, 1]) != (contour2[:, 1] > pts[:, None, 1])
|
927
|
-
slope = ((pts[:, None, 0] - polygon[:, 0]) * test_diff[:, 1]) - (
|
928
|
-
test_diff[:, 0] * (pts[:, None, 1] - polygon[:, 1])
|
929
|
-
)
|
930
|
-
m2 = slope == 0
|
931
|
-
mask2 = (m1 & m2).any(-1)
|
932
|
-
m3 = (slope < 0) != (contour2[:, 1] < polygon[:, 1])
|
933
|
-
m4 = m1 & m3
|
934
|
-
count = np.count_nonzero(m4, axis=-1)
|
935
|
-
mask3 = ~(count % 2 == 0)
|
936
|
-
mask = mask1 | mask2 | mask3
|
937
|
-
return mask
|
938
|
-
|
939
|
-
N = 50000
|
940
|
-
lenpoly = 1000
|
941
|
-
polygon = [
|
942
|
-
[np.sin(x) + 0.5, np.cos(x) + 0.5]
|
943
|
-
for x in np.linspace(0, 2 * np.pi, lenpoly)
|
944
|
-
]
|
945
|
-
polygon = np.array(polygon, dtype="float32")
|
946
|
-
|
947
|
-
points = np.random.uniform(-1.5, 1.5, size=(N, 2)).astype("float32")
|
948
|
-
t = time.time()
|
949
|
-
mask = points_in_polygon(polygon, points)
|
950
|
-
t1 = time.time() - t
|
951
|
-
|
952
|
-
# Convert to correct format.
|
953
|
-
points = points[:, 0] + points[:, 1] * 1j
|
954
|
-
pg = polygon[:, 0] + polygon[:, 1] * 1j
|
955
|
-
poly = Polygon(*pg)
|
956
|
-
t = time.time()
|
957
|
-
q = Scanbeam(poly.geomstr)
|
958
|
-
r = q.points_in_polygon(points)
|
959
|
-
t2 = time.time() - t
|
960
|
-
for i in range(N):
|
961
|
-
if mask[i]:
|
962
|
-
self.assertTrue(r[i])
|
963
|
-
else:
|
964
|
-
self.assertFalse(r[i])
|
965
|
-
try:
|
966
|
-
print(
|
967
|
-
f"geomstr points in poly took {t2} seconds. Raytraced-numpy took {t1}. Speed-up {t1/t2}x"
|
968
|
-
)
|
969
|
-
except ZeroDivisionError:
|
970
|
-
pass
|
971
|
-
|
972
|
-
def test_point_in_polygon_scanline_beat(self):
|
973
|
-
"""
|
974
|
-
Test point in poly for Scanbeam against simplified version of same algorithm
|
975
|
-
@return:
|
976
|
-
"""
|
977
|
-
|
978
|
-
def build_edge_list(polygon):
|
979
|
-
edge_list = []
|
980
|
-
for i in range(0, len(polygon) - 1):
|
981
|
-
if (polygon[i].imag, polygon[i].real) < (
|
982
|
-
polygon[i + 1].imag,
|
983
|
-
polygon[i + 1].real,
|
984
|
-
):
|
985
|
-
edge_list.append((polygon[i], i))
|
986
|
-
edge_list.append((polygon[i + 1], ~i))
|
987
|
-
else:
|
988
|
-
edge_list.append((polygon[i], ~i))
|
989
|
-
edge_list.append((polygon[i + 1], i))
|
990
|
-
|
991
|
-
def sort_key(e):
|
992
|
-
return e[0].imag, e[0].real, ~e[1]
|
993
|
-
|
994
|
-
edge_list.sort(key=sort_key)
|
995
|
-
return edge_list
|
996
|
-
|
997
|
-
def build_scanbeam(edge_list):
|
998
|
-
actives = []
|
999
|
-
actives_table = []
|
1000
|
-
events = []
|
1001
|
-
y = -float("inf")
|
1002
|
-
for pt, index in edge_list:
|
1003
|
-
if y != pt.imag:
|
1004
|
-
actives_table.append(list(actives))
|
1005
|
-
events.append(pt.imag)
|
1006
|
-
if index >= 0:
|
1007
|
-
actives.append(index)
|
1008
|
-
else:
|
1009
|
-
actives.remove(~index)
|
1010
|
-
y = pt.imag
|
1011
|
-
actives_table.append(list(actives))
|
1012
|
-
largest_actives = max([len(a) for a in actives_table])
|
1013
|
-
scan = np.zeros((len(actives_table), largest_actives), dtype=int)
|
1014
|
-
scan -= 1
|
1015
|
-
for i, active in enumerate(actives_table):
|
1016
|
-
scan[i, 0 : len(active)] = active
|
1017
|
-
return scan, events
|
1018
|
-
|
1019
|
-
def points_in_polygon(polygon, point):
|
1020
|
-
edge_list = build_edge_list(polygon)
|
1021
|
-
scan, events = build_scanbeam(edge_list)
|
1022
|
-
pts_y = np.imag(point)
|
1023
|
-
idx = np.searchsorted(events, pts_y)
|
1024
|
-
actives = scan[idx]
|
1025
|
-
a = polygon[actives]
|
1026
|
-
b = polygon[actives + 1]
|
1027
|
-
|
1028
|
-
a = np.where(actives == -1, np.nan + np.nan * 1j, a)
|
1029
|
-
b = np.where(actives == -1, np.nan + np.nan * 1j, b)
|
1030
|
-
|
1031
|
-
old_np_seterr = np.seterr(invalid="ignore", divide="ignore")
|
1032
|
-
try:
|
1033
|
-
# If horizontal slope is undefined. But, all x-ints are at x since x0=x1
|
1034
|
-
m = (b.imag - a.imag) / (b.real - a.real)
|
1035
|
-
y0 = a.imag - (m * a.real)
|
1036
|
-
ys = np.reshape(np.repeat(np.imag(point), y0.shape[1]), y0.shape)
|
1037
|
-
x_intercepts = np.where(~np.isinf(m), (ys - y0) / m, a.real)
|
1038
|
-
finally:
|
1039
|
-
np.seterr(**old_np_seterr)
|
1040
|
-
|
1041
|
-
xs = np.reshape(np.repeat(np.real(point), y0.shape[1]), y0.shape)
|
1042
|
-
results = np.sum(x_intercepts <= xs, axis=1)
|
1043
|
-
results %= 2
|
1044
|
-
return results
|
1045
|
-
|
1046
|
-
N = 5000
|
1047
|
-
lenpoly = 1000
|
1048
|
-
polygon = [
|
1049
|
-
[np.sin(x) + 0.5, np.cos(x) + 0.5]
|
1050
|
-
for x in np.linspace(0, 2 * np.pi, lenpoly)
|
1051
|
-
]
|
1052
|
-
polygon = np.array(polygon, dtype="float32")
|
1053
|
-
|
1054
|
-
points = np.random.uniform(-1.5, 1.5, size=(N, 2)).astype("float32")
|
1055
|
-
points = points[:, 0] + points[:, 1] * 1j
|
1056
|
-
pg = polygon[:, 0] + polygon[:, 1] * 1j
|
1057
|
-
|
1058
|
-
t = time.time()
|
1059
|
-
mask = points_in_polygon(pg, points)
|
1060
|
-
t1 = time.time() - t
|
1061
|
-
|
1062
|
-
# Convert to correct format.
|
1063
|
-
|
1064
|
-
poly = Polygon(*pg)
|
1065
|
-
t = time.time()
|
1066
|
-
q = Scanbeam(poly.geomstr)
|
1067
|
-
r = q.points_in_polygon(points)
|
1068
|
-
t2 = time.time() - t
|
1069
|
-
for p1, p2 in zip(r, mask):
|
1070
|
-
assert bool(p1) == bool(p2)
|
1071
|
-
try:
|
1072
|
-
print(
|
1073
|
-
f"geomstr points in poly took {t2} seconds. Simple Scanline {t1}. Speed-up {t1 / t2}x"
|
1074
|
-
)
|
1075
|
-
except ZeroDivisionError:
|
1076
|
-
pass
|
1077
|
-
|
1078
|
-
# q = BeamTable(poly.geomstr)
|
1079
|
-
# q.compute_beam_brute()
|
1080
|
-
# t = time.time()
|
1081
|
-
# r = q.points_in_polygon(points)
|
1082
|
-
# t2 = time.time() - t
|
1083
|
-
# i = 0
|
1084
|
-
# for p1, p2 in zip(r, mask):
|
1085
|
-
# i += 1
|
1086
|
-
# if bool(p1) != bool(p2):
|
1087
|
-
# print(f"{i} {points[i]}")
|
1088
|
-
# self.assertEqual(bool(p1), bool(p2))
|
1089
|
-
|
1090
|
-
def test_render(self):
|
1091
|
-
rect = Geomstr.rect(x=300, y=200, width=500, height=500, rx=50, ry=50)
|
1092
|
-
image = rect.segmented().render()
|
1093
|
-
image.save("render-test.png")
|
1094
|
-
|
1095
|
-
def test_point_in_polygon(self):
|
1096
|
-
t1 = 0
|
1097
|
-
t2 = 0
|
1098
|
-
f = set_diamond1
|
1099
|
-
p = Pattern()
|
1100
|
-
p.create_from_pattern(f)
|
1101
|
-
|
1102
|
-
yy = []
|
1103
|
-
for i in range(100):
|
1104
|
-
yy.append(random_point(5))
|
1105
|
-
yy.append(yy[0])
|
1106
|
-
poly = Polygon(*yy) # 0,10 20,0 20,20.1 0,10
|
1107
|
-
poly.geomstr.uscale(5)
|
1108
|
-
m = Scanbeam(poly.geomstr)
|
1109
|
-
|
1110
|
-
pts = []
|
1111
|
-
for i in range(2000):
|
1112
|
-
pts.append(random_point(25))
|
1113
|
-
|
1114
|
-
t = time.time()
|
1115
|
-
r = m.points_in_polygon(pts)
|
1116
|
-
t1 += time.time() - t
|
1117
|
-
|
1118
|
-
t = time.time()
|
1119
|
-
rr = [int(m.is_point_inside(j.real, j.imag)) for j in pts]
|
1120
|
-
t2 += time.time() - t
|
1121
|
-
|
1122
|
-
for i, j in enumerate(pts):
|
1123
|
-
self.assertEqual(rr[i], r[i])
|
1124
|
-
try:
|
1125
|
-
print(
|
1126
|
-
f"is_point_inside takes {t2} numpy version takes {t1} speedup {t2/t1}x"
|
1127
|
-
)
|
1128
|
-
except ZeroDivisionError:
|
1129
|
-
print(f"{t2} vs {t1}")
|
1130
|
-
|
1131
|
-
def test_intersections_near(self):
|
1132
|
-
for r1 in np.linspace(0, 100, 5):
|
1133
|
-
r2 = r1 + 0.0001
|
1134
|
-
circle1 = Geomstr.circle(cx=0, cy=0, r=r1)
|
1135
|
-
circle2 = Geomstr.circle(cx=0, cy=0, r=r2)
|
1136
|
-
circle1.rotate(r1)
|
1137
|
-
for j in range(circle1.index):
|
1138
|
-
for k in range(circle2.index):
|
1139
|
-
c = list(
|
1140
|
-
circle1.intersections(circle1.segments[j], circle2.segments[k])
|
1141
|
-
)
|
1142
|
-
print(r1, r2)
|
1143
|
-
self.assertFalse(c)
|
1144
|
-
|
1145
|
-
def test_livinghinge_whiskers2(self):
|
1146
|
-
clip = Geomstr.ellipse(
|
1147
|
-
rx=96436.11909338088,
|
1148
|
-
ry=96436.11909338088,
|
1149
|
-
cx=550118.9389283657,
|
1150
|
-
cy=363374.1254904113,
|
1151
|
-
)
|
1152
|
-
subject = Geomstr()
|
1153
|
-
subject.line(5.82716822e05 + 343372.64182036j, 6.48483387e05 + 343372.64182036j)
|
1154
|
-
q = Clip(clip)
|
1155
|
-
subject = q.polycut(subject)
|
1156
|
-
subject = q.inside(subject)
|
1157
|
-
|
1158
|
-
m = Geomstr()
|
1159
|
-
m.append(clip)
|
1160
|
-
m.append(subject)
|
1161
|
-
m.uscale(0.002)
|
1162
|
-
draw(list(m.as_interpolated_points()), *m.bbox(), filename="whiskers.png")
|
1163
|
-
|
1164
|
-
def test_livinghinge_whiskers(self):
|
1165
|
-
"""
|
1166
|
-
Test for Whiskers bug. The given clip and exactly the right settings could allow a line to not clip correctly
|
1167
|
-
|
1168
|
-
We use a previously failing set of settings and make sure that the midpoints and both ends are always on the
|
1169
|
-
same side of the polygon.
|
1170
|
-
@return:
|
1171
|
-
"""
|
1172
|
-
clip = Geomstr.ellipse(
|
1173
|
-
rx=96436.11909338088,
|
1174
|
-
ry=96436.11909338088,
|
1175
|
-
cx=550118.9389283657,
|
1176
|
-
cy=363374.1254904113,
|
1177
|
-
)
|
1178
|
-
p = Pattern()
|
1179
|
-
p.create_from_pattern(set_line, 0, 0, outershape=clip)
|
1180
|
-
p.set_cell_padding(-11377.615848868112, -257.2803475393701)
|
1181
|
-
p.set_cell_dims(65766.56560039372, 5593.051033464568)
|
1182
|
-
p.extend_pattern = True
|
1183
|
-
subject = Geomstr()
|
1184
|
-
q = Clip(clip)
|
1185
|
-
self.path = Geomstr()
|
1186
|
-
for s in list(p.generate(*q.bounds)):
|
1187
|
-
subject.append(s)
|
1188
|
-
|
1189
|
-
subject = q.polycut(subject)
|
1190
|
-
subject = q.inside(subject)
|
1191
|
-
|
1192
|
-
m = Geomstr()
|
1193
|
-
m.append(clip)
|
1194
|
-
m.append(subject)
|
1195
|
-
m.uscale(0.002)
|
1196
|
-
draw(list(m.as_interpolated_points()), *m.bbox())
|
1197
|
-
|
1198
|
-
c = Geomstr()
|
1199
|
-
# Pip currently only works with line segments
|
1200
|
-
for sp in clip.as_subpaths():
|
1201
|
-
for segs in sp.as_interpolated_segments(interpolate=100):
|
1202
|
-
c.polyline(segs)
|
1203
|
-
c.end()
|
1204
|
-
sb = Scanbeam(c)
|
1205
|
-
|
1206
|
-
mid_points = subject.position(slice(subject.index), 0.5)
|
1207
|
-
r = np.where(sb.points_in_polygon(mid_points))
|
1208
|
-
|
1209
|
-
s = np.where(
|
1210
|
-
sb.points_in_polygon(subject.position(slice(subject.index), 0.05))
|
1211
|
-
)[0]
|
1212
|
-
|
1213
|
-
e = np.where(
|
1214
|
-
sb.points_in_polygon(subject.position(slice(subject.index), 0.95))
|
1215
|
-
)[0]
|
1216
|
-
|
1217
|
-
for q in r[0]:
|
1218
|
-
self.assertIn(q, s)
|
1219
|
-
self.assertIn(q, e)
|
1220
|
-
|
1221
|
-
def test_point_towards_numpy(self):
|
1222
|
-
p1 = complex(0, 100)
|
1223
|
-
p2 = complex(50, 22)
|
1224
|
-
steps = 5
|
1225
|
-
q = Geomstr.towards(None, p1, p2, np.linspace(0, 1, steps))
|
1226
|
-
self.assertEqual(len(q), steps)
|
1227
|
-
self.assertEqual(p1, q[0])
|
1228
|
-
self.assertEqual(p2, q[-1])
|
1229
|
-
|
1230
|
-
def test_point_split_line_numpy(self):
|
1231
|
-
g = Geomstr()
|
1232
|
-
g.line(complex(0, 100), complex(50, 22))
|
1233
|
-
g.insert(1, list(g.split(0, 0.5)))
|
1234
|
-
self.assertEqual(g.index, 3)
|
1235
|
-
|
1236
|
-
steps = 5
|
1237
|
-
splits = list(g.split(0, np.linspace(0, 1, steps)[1:-1]))
|
1238
|
-
g.insert(1, splits)
|
1239
|
-
self.assertEqual(g.index, 7)
|
1240
|
-
|
1241
|
-
steps = 10
|
1242
|
-
splits = list(g.split(0, np.linspace(1, 0, steps)[1:-1]))
|
1243
|
-
g.replace(0, 7, splits)
|
1244
|
-
self.assertEqual(g.index, steps - 2)
|
1245
|
-
for i in range(1, g.index):
|
1246
|
-
self.assertAlmostEqual(g.length(i - 1), g.length(i))
|
1247
|
-
|
1248
|
-
def test_point_split_quad_numpy(self):
|
1249
|
-
g = Geomstr()
|
1250
|
-
g.quad(complex(0, 100), complex(0, 0), complex(50, 22))
|
1251
|
-
sp = list(g.split(0, 0.21))
|
1252
|
-
self.assertAlmostEqual(g.position(0, 0.21), sp[0][-1])
|
1253
|
-
g.insert(1, sp)
|
1254
|
-
self.assertEqual(g.index, 3)
|
1255
|
-
|
1256
|
-
steps = 5
|
1257
|
-
splits = list(g.split(0, np.linspace(0, 1, steps)[1:-1]))
|
1258
|
-
g.insert(1, splits)
|
1259
|
-
self.assertEqual(g.index, 7)
|
1260
|
-
|
1261
|
-
steps = 10
|
1262
|
-
splits = list(g.split(0, np.linspace(1, 0, steps)[1:-1]))
|
1263
|
-
g.replace(0, 7, splits)
|
1264
|
-
self.assertEqual(g.index, steps - 2)
|
1265
|
-
|
1266
|
-
def test_point_split_quad_numpy_2(self):
|
1267
|
-
steps = 10
|
1268
|
-
g = Geomstr()
|
1269
|
-
g.quad(complex(0, 0), complex(0, 50), complex(0, 100))
|
1270
|
-
splits = list(g.split(0, np.linspace(1, 0, steps)[1:-1]))
|
1271
|
-
g.replace(0, 0, splits)
|
1272
|
-
for i in range(1, g.index):
|
1273
|
-
self.assertAlmostEqual(g.length(i - 1), g.length(i))
|
1274
|
-
|
1275
|
-
def test_point_split_cubic_numpy(self):
|
1276
|
-
g = Geomstr()
|
1277
|
-
g.cubic(complex(0, 100), complex(0, 0), complex(90, 67), complex(50, 22))
|
1278
|
-
sp = list(g.split(0, 0.21))
|
1279
|
-
self.assertAlmostEqual(g.position(0, 0.21), sp[0][-1])
|
1280
|
-
g.insert(1, list(g.split(0, 0.5)))
|
1281
|
-
self.assertEqual(g.index, 3)
|
1282
|
-
|
1283
|
-
steps = 5
|
1284
|
-
splits = list(g.split(0, np.linspace(0, 1, steps)[1:-1]))
|
1285
|
-
g.insert(1, splits)
|
1286
|
-
self.assertEqual(g.index, 7)
|
1287
|
-
|
1288
|
-
steps = 10
|
1289
|
-
splits = list(g.split(0, np.linspace(1, 0, steps)[1:-1]))
|
1290
|
-
g.replace(0, 7, splits)
|
1291
|
-
self.assertEqual(g.index, steps - 2)
|
1292
|
-
|
1293
|
-
def test_geomstr_svg(self):
|
1294
|
-
gs = Geomstr.svg("M0,0 h100 v100 h-100 v-100 z")
|
1295
|
-
self.assertEqual(gs.raw_length(), 400.0)
|
1296
|
-
|
1297
|
-
def test_geomstr_near(self):
|
1298
|
-
"""
|
1299
|
-
Test geomstr near command to find number of segment points within a given range.
|
1300
|
-
@return:
|
1301
|
-
"""
|
1302
|
-
gs = Geomstr.circle(500, 0, 0)
|
1303
|
-
q = gs.near(complex(0, 0), 499)
|
1304
|
-
self.assertEqual(len(q), 0)
|
1305
|
-
q = gs.near(complex(500, 0), 50)
|
1306
|
-
self.assertEqual(len(q), 2)
|
1307
|
-
gs.append(Geomstr.rect(0, 0, 10, 10))
|
1308
|
-
gs.end()
|
1309
|
-
gs.append(Geomstr.rect(5, 5, 10, 10))
|
1310
|
-
q = gs.near(complex(0, 0), 499)
|
1311
|
-
# 2 rectangles, 4 corners. 2 points each segment meeting at corners = 16
|
1312
|
-
self.assertEqual(len(q), 16)
|
1313
|
-
|
1314
|
-
def test_geomstr_area(self):
|
1315
|
-
gs = Geomstr.svg("M0,0 h100 v100 h-100 v-100 z")
|
1316
|
-
self.assertAlmostEqual(gs.area(), 100 * 100)
|
1317
|
-
gs = Geomstr.circle(100, 0, 0)
|
1318
|
-
self.assertAlmostEqual(gs.area(density=1000), (tau / 2) * 100 * 100, delta=1)
|
1319
|
-
gs = Geomstr.ellipse(100, 100, 0, 0)
|
1320
|
-
self.assertAlmostEqual(gs.area(density=1000), (tau / 2) * 100 * 100, delta=1)
|
1321
|
-
# We add another equally sized circle to the same geometry.
|
1322
|
-
gs.append(Geomstr.ellipse(100, 100, 1000, 1000))
|
1323
|
-
self.assertAlmostEqual(gs.area(density=1000), tau * 100 * 100, delta=1)
|
1324
|
-
|
1325
|
-
def test_geomstr_fractal_koch_snowflake(self):
|
1326
|
-
# seed = Geomstr.svg("M0,0 1,0 2,1 3,0 4,0")
|
1327
|
-
seed = Geomstr.turtle("F-F++F-F", n=6)
|
1328
|
-
|
1329
|
-
# design = Geomstr.turtle("F+F+F+F", n=4)
|
1330
|
-
design = Geomstr.turtle("F+F+F+F", n=6)
|
1331
|
-
design.uscale(500)
|
1332
|
-
for i in range(5):
|
1333
|
-
design.fractal(seed)
|
1334
|
-
print(design)
|
1335
|
-
bounds = design.bbox()
|
1336
|
-
draw(
|
1337
|
-
list(design.as_interpolated_points()),
|
1338
|
-
*bounds,
|
1339
|
-
buffer=50,
|
1340
|
-
filename="koch.png",
|
1341
|
-
)
|
1342
|
-
|
1343
|
-
def test_geomstr_fractal_swaps(self):
|
1344
|
-
for i in range(4):
|
1345
|
-
seed = Geomstr.svg("M0,0 h2 v1 l1,-1")
|
1346
|
-
design = Geomstr.turtle("FFF", n=4)
|
1347
|
-
design.segments[1][1] = i
|
1348
|
-
design.segments[1][3] = i
|
1349
|
-
design.uscale(500)
|
1350
|
-
design.fractal(seed)
|
1351
|
-
design.fractal(seed)
|
1352
|
-
draw(
|
1353
|
-
list(design.as_interpolated_points()),
|
1354
|
-
*design.bbox(),
|
1355
|
-
buffer=50,
|
1356
|
-
filename=f"swaps{i}.png",
|
1357
|
-
)
|
1358
|
-
|
1359
|
-
def test_geomstr_fractal_polya_sweep(self):
|
1360
|
-
"""
|
1361
|
-
http://www.fractalcurves.com/images/2S_triangle_sweep.jpg
|
1362
|
-
@return:
|
1363
|
-
"""
|
1364
|
-
seed = Geomstr.turtle("f+B", n=4)
|
1365
|
-
design = Geomstr.turtle("F", n=4)
|
1366
|
-
design.uscale(500)
|
1367
|
-
for _ in range(8):
|
1368
|
-
design.fractal(seed)
|
1369
|
-
draw(
|
1370
|
-
list(design.as_interpolated_points()),
|
1371
|
-
*design.bbox(),
|
1372
|
-
buffer=50,
|
1373
|
-
filename="polya.png",
|
1374
|
-
)
|
1375
|
-
|
1376
|
-
def test_geomstr_fractal_terdragon(self):
|
1377
|
-
"""
|
1378
|
-
http://www.fractalcurves.com/images/3T_ter.jpg
|
1379
|
-
@return:
|
1380
|
-
"""
|
1381
|
-
seed = Geomstr.turtle("F+F-F", n=3, d=math.sqrt(3))
|
1382
|
-
design = copy(seed)
|
1383
|
-
design.uscale(500)
|
1384
|
-
for _ in range(5):
|
1385
|
-
design.fractal(seed)
|
1386
|
-
draw(
|
1387
|
-
list(design.as_interpolated_points()),
|
1388
|
-
*design.bbox(),
|
1389
|
-
buffer=50,
|
1390
|
-
filename="terdragon.png",
|
1391
|
-
)
|
1392
|
-
|
1393
|
-
def test_geomstr_fractal_iterdragon(self):
|
1394
|
-
"""
|
1395
|
-
http://www.fractalcurves.com/images/3T_butterfly.jpg
|
1396
|
-
@return:
|
1397
|
-
"""
|
1398
|
-
seed = Geomstr.turtle("b+b-b", n=3, d=math.sqrt(3))
|
1399
|
-
design = copy(seed)
|
1400
|
-
design.uscale(500)
|
1401
|
-
for _ in range(8):
|
1402
|
-
design.fractal(seed)
|
1403
|
-
draw(
|
1404
|
-
list(design.as_interpolated_points()),
|
1405
|
-
*design.bbox(),
|
1406
|
-
buffer=50,
|
1407
|
-
filename="inverted-terdragon.png",
|
1408
|
-
)
|
1409
|
-
|
1410
|
-
def test_geomstr_fractal_box(self):
|
1411
|
-
"""
|
1412
|
-
http://www.fractalcurves.com/images/3T_block.jpg
|
1413
|
-
@return:
|
1414
|
-
"""
|
1415
|
-
seed = Geomstr.turtle("b+F-b", n=3, d=math.sqrt(3))
|
1416
|
-
design = copy(seed)
|
1417
|
-
design.uscale(500)
|
1418
|
-
for _ in range(8):
|
1419
|
-
design.fractal(seed)
|
1420
|
-
draw(
|
1421
|
-
list(design.as_interpolated_points()),
|
1422
|
-
*design.bbox(),
|
1423
|
-
buffer=50,
|
1424
|
-
filename="box.png",
|
1425
|
-
)
|
1426
|
-
|
1427
|
-
def test_geom_max_aabb(self):
|
1428
|
-
g = Geomstr.rect(0, 0, 200, 200)
|
1429
|
-
nx, ny, mx, my = g.aabb()
|
1430
|
-
print(nx)
|
1431
|
-
|
1432
|
-
def test_static_beam_horizontal_bowtie(self):
|
1433
|
-
"""
|
1434
|
-
0: down-right
|
1435
|
-
1: right side
|
1436
|
-
2: down-left
|
1437
|
-
3: left side
|
1438
|
-
30 21
|
1439
|
-
|\ /|
|
1440
|
-
| \ / |
|
1441
|
-
| / \ |
|
1442
|
-
|/ \|
|
1443
|
-
@return:
|
1444
|
-
"""
|
1445
|
-
bowtie = Geomstr.lines(
|
1446
|
-
complex(0, 0),
|
1447
|
-
complex(100, 100),
|
1448
|
-
complex(100, 0),
|
1449
|
-
complex(0, 100),
|
1450
|
-
complex(0, 0),
|
1451
|
-
)
|
1452
|
-
sb = BeamTable(bowtie)
|
1453
|
-
result = sb.actives_at(25)
|
1454
|
-
actives = bowtie.x_intercept(result, 25)
|
1455
|
-
|
1456
|
-
for x, y in zip(result, (0, 2)):
|
1457
|
-
self.assertEqual(x, y)
|
1458
|
-
|
1459
|
-
def test_static_beam_vertical_bowtie(self):
|
1460
|
-
"""
|
1461
|
-
0 3
|
1462
|
-
--------
|
1463
|
-
\ /
|
1464
|
-
\ /
|
1465
|
-
\/
|
1466
|
-
/\
|
1467
|
-
/ \
|
1468
|
-
/ \
|
1469
|
-
------
|
1470
|
-
2 1
|
1471
|
-
@return:
|
1472
|
-
"""
|
1473
|
-
bowtie = Geomstr.lines(
|
1474
|
-
complex(0, 0),
|
1475
|
-
complex(100, 100),
|
1476
|
-
complex(0, 100),
|
1477
|
-
complex(100, 0),
|
1478
|
-
complex(0, 0),
|
1479
|
-
)
|
1480
|
-
sb = BeamTable(bowtie)
|
1481
|
-
result = sb.actives_at(complex(25, 0))
|
1482
|
-
actives = bowtie.x_intercept(result, 25)
|
1483
|
-
|
1484
|
-
for x, y in zip(result, (3, 0, 2, 1)):
|
1485
|
-
self.assertEqual(x, y)
|
1486
|
-
|
1487
|
-
def test_scan_table_random(self):
|
1488
|
-
for c in range(1):
|
1489
|
-
print("\n\n\n\n\n")
|
1490
|
-
g = Geomstr()
|
1491
|
-
for i in range(25):
|
1492
|
-
random_segment(
|
1493
|
-
g, i=1000, arc=False, point=False, quad=False, cubic=False
|
1494
|
-
)
|
1495
|
-
t = time.time()
|
1496
|
-
sb = BeamTable(g)
|
1497
|
-
sb.compute_beam_brute()
|
1498
|
-
intersections = sb.intersections
|
1499
|
-
print(f"Time: {time.time() - t}")
|
1500
|
-
try:
|
1501
|
-
g.append(intersections)
|
1502
|
-
draw_geom(g, *g.bbox(), filename="scantable.png")
|
1503
|
-
except PermissionError:
|
1504
|
-
pass
|
1505
|
-
|
1506
|
-
# def test_geomstr_hatch(self):
|
1507
|
-
# gs = Geomstr.svg(
|
1508
|
-
# "M 207770.064517,235321.124952 C 206605.069353,234992.732685 205977.289179,234250.951228 205980.879932,233207.034699 C 205983.217733,232527.380908 206063.501616,232426.095743 206731.813533,232259.66605 L 207288.352862,232121.071081 L 207207.998708,232804.759538 C 207106.904585,233664.912764 207367.871267,234231.469286 207960.295387,234437.989447 C 208960.760372,234786.753419 209959.046638,234459.536445 210380.398871,233644.731075 C 210672.441667,233079.98258 210772.793626,231736.144349 210569.029382,231118.732625 C 210379.268508,230543.75153 209783.667018,230128.095713 209148.499972,230127.379646 C 208627.98084,230126.79283 208274.720902,230294.472682 207747.763851,230792.258962 C 207377.90966,231141.639128 207320.755956,231155.543097 206798.920578,231023.087178 C 206328.09633,230903.579262 206253.35266,230839.656219 206307.510015,230602.818034 C 206382.366365,230275.460062 207158.299204,225839.458855 207158.299204,225738.863735 C 207158.299204,225701.269015 208426.401454,225670.509699 209976.304204,225670.509699 C 211869.528049,225670.509699 212794.309204,225715.990496 212794.309204,225809.099369 C 212794.309204,225885.323687 212726.683921,226357.175687 212644.030798,226857.659369 L 212493.752392,227767.629699 L 210171.516354,227767.629699 L 207849.280317,227767.629699 L 207771.086662,228324.677199 C 207728.080152,228631.053324 207654.900983,229067.454479 207608.466287,229294.457543 L 207524.039566,229707.190387 L 208182.568319,229381.288158 C 209664.399179,228647.938278 211467.922971,228893.537762 212548.92912,229975.888551 C 214130.813964,231559.741067 213569.470754,234195.253882 211455.779825,235108.237047 C 210589.985852,235482.206254 208723.891068,235589.992389 207770.064517,235321.124952 L 207770.064517,235321.124952Z"
|
1509
|
-
# "M 217143.554487,235251.491866 C 215510.313868,234687.408946 214629.289204,233029.479999 214629.289204,230520.099699 C 214629.289204,227300.669136 216066.08164,225539.439699 218692.459204,225539.439699 C 221318.836768,225539.439699 222755.629204,227300.669136 222755.629204,230520.099699 C 222755.629204,233768.619944 221313.285526,235510.883949 218635.902338,235496.480807 C 218198.433364,235494.127417 217526.876831,235383.882393 217143.554487,235251.491866 L 217143.554487,235251.491866Z"
|
1510
|
-
# "M 190905.619204,231712.322088 L 190905.619204,228054.954477 L 190248.863277,228304.502088 C 189887.647517,228441.753274 189445.286267,228554.049699 189265.838277,228554.049699 C 188966.73452,228554.049699 188939.569204,228505.149339 188939.569204,227966.731848 C 188939.569204,227432.097785 188971.901741,227372.495945 189300.011704,227302.291681 C 190198.545589,227110.036287 190884.012886,226765.589154 191414.377757,226239.823305 C 191971.194511,225687.834949 192014.073023,225670.509699 192823.380257,225670.509699 L 193658.089204,225670.509699 L 193658.089204,230520.099699 L 193658.089204,235369.689699 L 192281.854204,235369.689699 L 190905.619204,235369.689699 L 190905.619204,231712.322088 L 190905.619204,231712.322088"
|
1511
|
-
#
|
1512
|
-
# )
|
1513
|
-
# # gs.uscale(0.05)
|
1514
|
-
# # bounds = gs.bbox()
|
1515
|
-
# # t = list(gs.as_interpolated_points(interpolate=5))
|
1516
|
-
# # draw(t, *bounds)
|
1517
|
-
# # return
|
1518
|
-
#
|
1519
|
-
# hatch = Geomstr.hatch(gs, distance=200, angle=tau / 4)
|
1520
|
-
# # hatch = Geomstr.hatch(gs, distance=200, angle=0)
|
1521
|
-
# print(hatch)
|
1522
|
-
# bounds = hatch.bbox()
|
1523
|
-
# draw(list(hatch.as_interpolated_points()), *bounds)
|