summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/README2
-rw-r--r--Build/source/texk/dvisvgm/ChangeLog6
-rw-r--r--Build/source/texk/dvisvgm/Makefile.am11
-rw-r--r--Build/source/texk/dvisvgm/Makefile.in54
-rwxr-xr-xBuild/source/texk/dvisvgm/configure26
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/patch-01-cygwin15
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.7/doc/README12
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.7/src/psdefs.cpp83
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/ChangeLog (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/ChangeLog)5
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/TL-Changes (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/TL-Changes)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/AUTHORS (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/AUTHORS)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/COPYING (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/COPYING)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/ChangeLog (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/ChangeLog)89
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/INSTALL (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/INSTALL)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/LGPL-2.1.txt (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/LGPL-2.1.txt)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/Makefile.am (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/Makefile.am)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/NEWS (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/NEWS)12
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/README (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/README)9
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/Makefile.am7
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.cpp4464
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.hpp438
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/config.h.in (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/config.h.in)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/configure.ac (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/configure.ac)7
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/doc/Makefile.am (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/doc/Makefile.am)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/doc/README16
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.1 (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.1)22
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.txt.in (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.txt.in)15
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.cpp188
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.h48
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Character.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Character.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.cpp)14
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.h)6
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIActions.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIActions.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.h)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.h)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.cpp)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.cpp)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontStyle.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontStyle.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.cpp)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.cpp)4
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Glyph.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Glyph.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GlyphTracerMessages.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GlyphTracerMessages.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/GraphicPath.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/GraphicPath.h)45
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.h)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.cpp)5
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Makefile.am (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Makefile.am)8
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MessageException.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MessageException.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/NumericRanges.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/NumericRanges.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSFilter.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSFilter.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.cpp)7
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.h)1
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Pair.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Pair.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.cpp343
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.h60
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.cpp)310
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.h)16
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.cpp)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGOutputBase.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGOutputBase.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.cpp)5
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.h)7
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialActions.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialActions.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.cpp)1
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.cpp)2
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.cpp)95
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFActions.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFActions.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/VectorStream.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/VectorStream.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/dvisvgm.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/dvisvgm.cpp)8
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.cpp (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.cpp)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/iapi.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/iapi.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/ierrors.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/ierrors.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/macros.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/macros.h)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.dtd (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.dtd)0
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.xml (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.xml)6
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/psdefs.cpp87
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-1.8/src/types.h (renamed from Build/source/texk/dvisvgm/dvisvgm-1.7/src/types.h)0
-rw-r--r--Build/source/texk/dvisvgm/version.ac2
208 files changed, 6228 insertions, 351 deletions
diff --git a/Build/source/texk/README b/Build/source/texk/README
index da6c2499a45..6068197de2c 100644
--- a/Build/source/texk/README
+++ b/Build/source/texk/README
@@ -61,7 +61,7 @@ dvipos - ?
dvipsk - maintained here, by us
-dvisvgm 1.7 - checked 20jun14
+dvisvgm 1.8 - checked 31jul14
http://downloads.sourceforge.net/dvisvgm/
gsftopk - from Paul Vojta's xdvi?
diff --git a/Build/source/texk/dvisvgm/ChangeLog b/Build/source/texk/dvisvgm/ChangeLog
index e500d48557a..7dccd7ae73e 100644
--- a/Build/source/texk/dvisvgm/ChangeLog
+++ b/Build/source/texk/dvisvgm/ChangeLog
@@ -1,3 +1,9 @@
+2014-07-31 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * Imported release 1.8.
+ * version.ac: Adapted.
+ * Makefile.am: Adjusted.
+
2014-06-20 Peter Breitenlohner <peb@mppmu.mpg.de>
* Imported release 1.7.
diff --git a/Build/source/texk/dvisvgm/Makefile.am b/Build/source/texk/dvisvgm/Makefile.am
index c4c89a85209..45e3be31947 100644
--- a/Build/source/texk/dvisvgm/Makefile.am
+++ b/Build/source/texk/dvisvgm/Makefile.am
@@ -22,7 +22,7 @@ EXTRA_DIST += $(DVISVGM_TREE)-PATCHES
dist-hook:
rm -rf `find $(distdir) -name .svn -o -name .deps -o -name .dirstamp -o -name '*.$(OBJEXT)'`
-AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/src
+AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/clipper -I$(top_srcdir)/$(DVISVGM_TREE)/src
AM_CPPFLAGS += $(KPATHSEA_INCLUDES) $(POTRACE_INCLUDES) $(FREETYPE2_INCLUDES)
AM_CPPFLAGS += $(ZLIB_INCLUDES) $(LIBGS_INCLUDES)
if WIN32
@@ -42,15 +42,16 @@ nodist_dvisvgm_SOURCES = \
dvisvgm_dependencies = $(KPATHSEA_DEPEND) $(ZLIB_DEPEND) $(FREETYPE2_DEPEND)
-$(dvisvgm_OBJECTS): libdvisvgm.a
+$(dvisvgm_OBJECTS): $(noinst_LIBRARIES)
LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(POTRACE_LIBS) $(FREETYPE2_LIBS)
LDADD += $(ZLIB_LIBS) $(LIBGS_LIBS)
-noinst_LIBRARIES = libdvisvgm.a
+noinst_LIBRARIES = libdvisvgm.a libclipper.a
nodist_libdvisvgm_a_SOURCES = \
@DVISVGM_TREE@/src/BasicDVIReader.cpp \
+ @DVISVGM_TREE@/src/Bezier.cpp \
@DVISVGM_TREE@/src/BgColorSpecialHandler.cpp \
@DVISVGM_TREE@/src/Bitmap.cpp \
@DVISVGM_TREE@/src/BoundingBox.cpp \
@@ -103,6 +104,7 @@ nodist_libdvisvgm_a_SOURCES = \
@DVISVGM_TREE@/src/PdfSpecialHandler.cpp \
@DVISVGM_TREE@/src/PageRanges.cpp \
@DVISVGM_TREE@/src/PageSize.cpp \
+ @DVISVGM_TREE@/src/PathClipper.cpp \
@DVISVGM_TREE@/src/PreScanDVIReader.cpp \
@DVISVGM_TREE@/src/Process.cpp \
@DVISVGM_TREE@/src/PsSpecialHandler.cpp \
@@ -132,6 +134,9 @@ endif dlloader
$(libdvisvgm_a_OBJECTS): $(POTRACE_DEPEND)
+nodist_libclipper_a_SOURCES = \
+ @DVISVGM_TREE@/clipper/clipper.cpp
+
config.force: $(dvisvgm_dependencies)
echo timestamp >config.force
$(SHELL) ./config.status --recheck
diff --git a/Build/source/texk/dvisvgm/Makefile.in b/Build/source/texk/dvisvgm/Makefile.in
index a4a077df8a7..f0bbafd1e00 100644
--- a/Build/source/texk/dvisvgm/Makefile.in
+++ b/Build/source/texk/dvisvgm/Makefile.in
@@ -130,12 +130,18 @@ AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
+libclipper_a_AR = $(AR) $(ARFLAGS)
+libclipper_a_LIBADD =
+am__dirstamp = $(am__leading_dot)dirstamp
+nodist_libclipper_a_OBJECTS = \
+ @DVISVGM_TREE@/clipper/clipper.$(OBJEXT)
+libclipper_a_OBJECTS = $(nodist_libclipper_a_OBJECTS)
libdvisvgm_a_AR = $(AR) $(ARFLAGS)
libdvisvgm_a_LIBADD =
-am__dirstamp = $(am__leading_dot)dirstamp
@dlloader_TRUE@am__objects_1 = @DVISVGM_TREE@/src/DLLoader.$(OBJEXT)
nodist_libdvisvgm_a_OBJECTS = \
@DVISVGM_TREE@/src/BasicDVIReader.$(OBJEXT) \
+ @DVISVGM_TREE@/src/Bezier.$(OBJEXT) \
@DVISVGM_TREE@/src/BgColorSpecialHandler.$(OBJEXT) \
@DVISVGM_TREE@/src/Bitmap.$(OBJEXT) \
@DVISVGM_TREE@/src/BoundingBox.$(OBJEXT) \
@@ -188,6 +194,7 @@ nodist_libdvisvgm_a_OBJECTS = \
@DVISVGM_TREE@/src/PdfSpecialHandler.$(OBJEXT) \
@DVISVGM_TREE@/src/PageRanges.$(OBJEXT) \
@DVISVGM_TREE@/src/PageSize.$(OBJEXT) \
+ @DVISVGM_TREE@/src/PathClipper.$(OBJEXT) \
@DVISVGM_TREE@/src/PreScanDVIReader.$(OBJEXT) \
@DVISVGM_TREE@/src/Process.$(OBJEXT) \
@DVISVGM_TREE@/src/PsSpecialHandler.$(OBJEXT) \
@@ -257,7 +264,8 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
-SOURCES = $(nodist_libdvisvgm_a_SOURCES) $(nodist_dvisvgm_SOURCES)
+SOURCES = $(nodist_libclipper_a_SOURCES) \
+ $(nodist_libdvisvgm_a_SOURCES) $(nodist_dvisvgm_SOURCES)
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
@@ -657,7 +665,8 @@ top_srcdir = @top_srcdir@
#
#************************************************************************
EXTRA_DIST = $(DVISVGM_TREE) $(DVISVGM_TREE)-PATCHES $(TESTS)
-AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/src $(KPATHSEA_INCLUDES) \
+AM_CPPFLAGS = -I$(top_srcdir)/$(DVISVGM_TREE)/clipper \
+ -I$(top_srcdir)/$(DVISVGM_TREE)/src $(KPATHSEA_INCLUDES) \
$(POTRACE_INCLUDES) $(FREETYPE2_INCLUDES) $(ZLIB_INCLUDES) \
$(LIBGS_INCLUDES) $(am__append_1)
AM_CFLAGS = $(WARNING_CFLAGS)
@@ -672,8 +681,9 @@ nodist_dvisvgm_SOURCES = \
dvisvgm_dependencies = $(KPATHSEA_DEPEND) $(ZLIB_DEPEND) $(FREETYPE2_DEPEND)
LDADD = $(noinst_LIBRARIES) $(KPATHSEA_LIBS) $(POTRACE_LIBS) \
$(FREETYPE2_LIBS) $(ZLIB_LIBS) $(LIBGS_LIBS)
-noinst_LIBRARIES = libdvisvgm.a
+noinst_LIBRARIES = libdvisvgm.a libclipper.a
nodist_libdvisvgm_a_SOURCES = @DVISVGM_TREE@/src/BasicDVIReader.cpp \
+ @DVISVGM_TREE@/src/Bezier.cpp \
@DVISVGM_TREE@/src/BgColorSpecialHandler.cpp \
@DVISVGM_TREE@/src/Bitmap.cpp \
@DVISVGM_TREE@/src/BoundingBox.cpp @DVISVGM_TREE@/src/CMap.cpp \
@@ -719,6 +729,7 @@ nodist_libdvisvgm_a_SOURCES = @DVISVGM_TREE@/src/BasicDVIReader.cpp \
@DVISVGM_TREE@/src/PdfSpecialHandler.cpp \
@DVISVGM_TREE@/src/PageRanges.cpp \
@DVISVGM_TREE@/src/PageSize.cpp \
+ @DVISVGM_TREE@/src/PathClipper.cpp \
@DVISVGM_TREE@/src/PreScanDVIReader.cpp \
@DVISVGM_TREE@/src/Process.cpp \
@DVISVGM_TREE@/src/PsSpecialHandler.cpp \
@@ -736,6 +747,9 @@ nodist_libdvisvgm_a_SOURCES = @DVISVGM_TREE@/src/BasicDVIReader.cpp \
@DVISVGM_TREE@/src/XMLDocument.cpp \
@DVISVGM_TREE@/src/XMLNode.cpp \
@DVISVGM_TREE@/src/XMLString.cpp $(am__append_2)
+nodist_libclipper_a_SOURCES = \
+ @DVISVGM_TREE@/clipper/clipper.cpp
+
DISTCLEANFILES = config.force CXXLD.sh
TESTS = tests/dvisvgm.test
all: config.h
@@ -795,6 +809,20 @@ distclean-hdr:
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+@DVISVGM_TREE@/clipper/$(am__dirstamp):
+ @$(MKDIR_P) @DVISVGM_TREE@/clipper
+ @: > @DVISVGM_TREE@/clipper/$(am__dirstamp)
+@DVISVGM_TREE@/clipper/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) @DVISVGM_TREE@/clipper/$(DEPDIR)
+ @: > @DVISVGM_TREE@/clipper/$(DEPDIR)/$(am__dirstamp)
+@DVISVGM_TREE@/clipper/clipper.$(OBJEXT): \
+ @DVISVGM_TREE@/clipper/$(am__dirstamp) \
+ @DVISVGM_TREE@/clipper/$(DEPDIR)/$(am__dirstamp)
+
+libclipper.a: $(libclipper_a_OBJECTS) $(libclipper_a_DEPENDENCIES) $(EXTRA_libclipper_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libclipper.a
+ $(AM_V_AR)$(libclipper_a_AR) libclipper.a $(libclipper_a_OBJECTS) $(libclipper_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libclipper.a
@DVISVGM_TREE@/src/$(am__dirstamp):
@$(MKDIR_P) @DVISVGM_TREE@/src
@: > @DVISVGM_TREE@/src/$(am__dirstamp)
@@ -804,6 +832,9 @@ clean-noinstLIBRARIES:
@DVISVGM_TREE@/src/BasicDVIReader.$(OBJEXT): \
@DVISVGM_TREE@/src/$(am__dirstamp) \
@DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
+@DVISVGM_TREE@/src/Bezier.$(OBJEXT): \
+ @DVISVGM_TREE@/src/$(am__dirstamp) \
+ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
@DVISVGM_TREE@/src/BgColorSpecialHandler.$(OBJEXT): \
@DVISVGM_TREE@/src/$(am__dirstamp) \
@DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
@@ -957,6 +988,9 @@ clean-noinstLIBRARIES:
@DVISVGM_TREE@/src/PageSize.$(OBJEXT): \
@DVISVGM_TREE@/src/$(am__dirstamp) \
@DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
+@DVISVGM_TREE@/src/PathClipper.$(OBJEXT): \
+ @DVISVGM_TREE@/src/$(am__dirstamp) \
+ @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
@DVISVGM_TREE@/src/PreScanDVIReader.$(OBJEXT): \
@DVISVGM_TREE@/src/$(am__dirstamp) \
@DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
@@ -1089,12 +1123,15 @@ dvisvgm$(EXEEXT): $(dvisvgm_OBJECTS) $(dvisvgm_DEPENDENCIES) $(EXTRA_dvisvgm_DEP
mostlyclean-compile:
-rm -f *.$(OBJEXT)
+ -rm -f @DVISVGM_TREE@/clipper/*.$(OBJEXT)
-rm -f @DVISVGM_TREE@/src/*.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/clipper/$(DEPDIR)/clipper.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/BasicDVIReader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Bezier.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/BgColorSpecialHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Bitmap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/BoundingBox.Po@am__quote@
@@ -1147,6 +1184,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PSPreviewFilter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PageRanges.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PageSize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PathClipper.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PdfSpecialHandler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/PreScanDVIReader.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@@DVISVGM_TREE@/src/$(DEPDIR)/Process.Po@am__quote@
@@ -1666,6 +1704,8 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f @DVISVGM_TREE@/clipper/$(DEPDIR)/$(am__dirstamp)
+ -rm -f @DVISVGM_TREE@/clipper/$(am__dirstamp)
-rm -f @DVISVGM_TREE@/src/$(DEPDIR)/$(am__dirstamp)
-rm -f @DVISVGM_TREE@/src/$(am__dirstamp)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
@@ -1680,7 +1720,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf @DVISVGM_TREE@/src/$(DEPDIR)
+ -rm -rf @DVISVGM_TREE@/clipper/$(DEPDIR) @DVISVGM_TREE@/src/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
@@ -1728,7 +1768,7 @@ installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf @DVISVGM_TREE@/src/$(DEPDIR)
+ -rm -rf @DVISVGM_TREE@/clipper/$(DEPDIR) @DVISVGM_TREE@/src/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@@ -1775,7 +1815,7 @@ uninstall-man: uninstall-man1
dist-hook:
rm -rf `find $(distdir) -name .svn -o -name .deps -o -name .dirstamp -o -name '*.$(OBJEXT)'`
-$(dvisvgm_OBJECTS): libdvisvgm.a
+$(dvisvgm_OBJECTS): $(noinst_LIBRARIES)
$(libdvisvgm_a_OBJECTS): $(POTRACE_DEPEND)
diff --git a/Build/source/texk/dvisvgm/configure b/Build/source/texk/dvisvgm/configure
index 2ccd01dda60..737aaf13489 100755
--- a/Build/source/texk/dvisvgm/configure
+++ b/Build/source/texk/dvisvgm/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvisvgm (TeX Live) 1.7.
+# Generated by GNU Autoconf 2.69 for dvisvgm (TeX Live) 1.8.
#
# Report bugs to <tex-k@tug.org>.
#
@@ -590,12 +590,12 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dvisvgm (TeX Live)'
PACKAGE_TARNAME='dvisvgm--tex-live-'
-PACKAGE_VERSION='1.7'
-PACKAGE_STRING='dvisvgm (TeX Live) 1.7'
+PACKAGE_VERSION='1.8'
+PACKAGE_STRING='dvisvgm (TeX Live) 1.8'
PACKAGE_BUGREPORT='tex-k@tug.org'
PACKAGE_URL=''
-ac_unique_file="dvisvgm-1.7/src/dvisvgm.cpp"
+ac_unique_file="dvisvgm-1.8/src/dvisvgm.cpp"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
@@ -1372,7 +1372,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dvisvgm (TeX Live) 1.7 to adapt to many kinds of systems.
+\`configure' configures dvisvgm (TeX Live) 1.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1443,7 +1443,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvisvgm (TeX Live) 1.7:";;
+ short | recursive ) echo "Configuration of dvisvgm (TeX Live) 1.8:";;
esac
cat <<\_ACEOF
@@ -1581,7 +1581,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvisvgm (TeX Live) configure 1.7
+dvisvgm (TeX Live) configure 1.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2403,7 +2403,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dvisvgm (TeX Live) $as_me 1.7, which was
+It was created by dvisvgm (TeX Live) $as_me 1.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -7894,7 +7894,7 @@ fi
# Define the identity of the package.
PACKAGE='dvisvgm--tex-live-'
- VERSION='1.7'
+ VERSION='1.8'
cat >>confdefs.h <<_ACEOF
@@ -17755,7 +17755,7 @@ Usage: $0 [OPTIONS]
Report bugs to <bug-libtool@gnu.org>."
lt_cl_version="\
-dvisvgm (TeX Live) config.lt 1.7
+dvisvgm (TeX Live) config.lt 1.8
configured by $0, generated by GNU Autoconf 2.69.
Copyright (C) 2011 Free Software Foundation, Inc.
@@ -19566,7 +19566,7 @@ $as_echo "#define KPSE_CXX_UNSAFE 1" >>confdefs.h
fi
-DVISVGM_TREE=dvisvgm-1.7
+DVISVGM_TREE=dvisvgm-1.8
ac_config_files="$ac_config_files Makefile"
@@ -20118,7 +20118,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dvisvgm (TeX Live) $as_me 1.7, which was
+This file was extended by dvisvgm (TeX Live) $as_me 1.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20184,7 +20184,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dvisvgm (TeX Live) config.status 1.7
+dvisvgm (TeX Live) config.status 1.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/patch-01-cygwin b/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/patch-01-cygwin
deleted file mode 100644
index 47f5f74531a..00000000000
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/patch-01-cygwin
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -ur dvisvgm-1.7.orig/src/Ghostscript.cpp dvisvgm-1.7/src/Ghostscript.cpp
---- dvisvgm-1.7.orig/src/Ghostscript.cpp 2014-06-10 15:05:24.000000000 +0200
-+++ dvisvgm-1.7/src/Ghostscript.cpp 2014-06-25 11:45:36.000000000 +0200
-@@ -63,7 +63,11 @@
- const int abi_min=7, abi_max=9; // supported libgs ABI versions
- for (int i=abi_max; i >= abi_min; i--) {
- ostringstream oss;
-+#if defined(__CYGWIN__)
-+ oss << "cyggs-" << i << ".dll";
-+#else
- oss << "libgs.so." << i;
-+#endif
- DLLoader loader(oss.str().c_str());
- if (loader.loaded())
- return oss.str();
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/README b/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/README
deleted file mode 100644
index 6ecfc542aa3..00000000000
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/README
+++ /dev/null
@@ -1,12 +0,0 @@
-dvisvgm-1.6 (2014-04-22)
-- added option --zoom to "visually" scale the generated SVG graphics while
- preserving the original size and position values of the graphic objects
-- extended argument syntax of option --linkmark to allow to select the
- box/line color
-- changed default link marker from 'line' to 'box'
-- changed link markers to be only split on line breaks while extended in all
- other cases
-- if libgs is not directly linked to the binary, dvisvgm now looks for
- libgs.so.X instead of libgs.so (supported GS ABIs: X = 7, 8, 9)
-- removed time stamp and machine triplet from generated SVG files
-- some code improvements and refactorings
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/psdefs.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.7/src/psdefs.cpp
deleted file mode 100644
index 4edce3af1d8..00000000000
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/psdefs.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*************************************************************************
-** psdefs.cpp **
-** **
-** This file is part of dvisvgm -- the DVI to SVG converter **
-** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
-** **
-** This program is free software; you can redistribute it and/or **
-** modify it under the terms of the GNU General Public License as **
-** published by the Free Software Foundation; either version 3 of **
-** the License, or (at your option) any later version. **
-** **
-** This program is distributed in the hope that it will be useful, but **
-** WITHOUT ANY WARRANTY; without even the implied warranty of **
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
-** GNU General Public License for more details. **
-** **
-** You should have received a copy of the GNU General Public License **
-** along with this program; if not, see <http://www.gnu.org/licenses/>. **
-*************************************************************************/
-
-#include "PSInterpreter.h"
-
-const char *PSInterpreter::PSDEFS =
-"3 dict dup begin/Install{matrix setmatrix}def/HWResolution[72 72]def/PageSize[10"
-"000 10000]def end setpagedevice/@dodraw true store/@patcnt 0 store/@SD systemdic"
-"t def/@UD userdict def true setglobal @SD/:save @SD/save get put @SD/:restore @S"
-"D/restore get put @SD/:gsave @SD/gsave get put @SD/:grestore @SD/grestore get pu"
-"t @SD/:grestoreall @SD/grestoreall get put @SD/:stroke @SD/stroke get put @SD/:f"
-"ill @SD/fill get put @SD/:eofill @SD/eofill get put @SD/:clip @SD/clip get put @"
-"SD/:eoclip @SD/eoclip get put @SD/:charpath @SD/charpath get put @SD/:show @SD/s"
-"how get put @SD/.setopacityalpha known not{@SD/.setopacityalpha{pop}put}if @SD/p"
-"rseq{-1 1{-1 roll =only( )print}for(\\n)print}put @SD/prcmd{( )exch(\\ndvi.)3{pr"
-"int}repeat prseq}put @SD/cvxall{{cvx}forall}put @SD/defpr{[exch[/copy @SD]cvxall"
-" 5 -1 roll dup 6 1 roll[/get/exec]cvxall 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 "
-"1 roll dup length string cvs/prcmd cvx]cvx def}put @SD/querypos{{currentpoint}st"
-"opped{$error/newerror false put}{2(querypos)prcmd}ifelse}put @SD/applyscalevals{"
-"1 0 transform 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt "
-"0 1 transform 0 0 transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt "
-"1 0 transform dup mul exch dup dup mul 3 -1 roll add sqrt div 3(applyscalevals)p"
-"rcmd}put @SD/prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)prcmd}{0(closepat"
-"h)prcmd}pathforall}put @SD/charpath{/@dodraw false store :charpath/@dodraw true "
-"store}put @SD/show{@dodraw{dup :gsave currentpoint newpath moveto true charpath "
-"eofill :grestore :show}if}put @SD/stroke{@dodraw{0(newpath)prcmd prpath 0(stroke"
-")prcmd newpath}{:stroke}ifelse}put @SD/fill{@dodraw{0(newpath)prcmd prpath 0(fil"
-"l)prcmd newpath}{:fill}ifelse}put @SD/eofill{@dodraw{0(newpath)prcmd prpath 0(eo"
-"fill)prcmd newpath}{:eofill}ifelse}put @SD/clip{:clip 0(newpath)prcmd prpath 0(c"
-"lip)prcmd}put @SD/eoclip{:eoclip 0(newpath)prcmd prpath 0(eoclip)prcmd}put @SD/b"
-"op{pop pop}put/@rect{4 -2 roll moveto exch dup 0 rlineto exch 0 exch rlineto neg"
-" 0 rlineto closepath}bind def/@rectcc{4 -2 roll moveto 2 copy 0 lt exch 0 lt xor"
-"{dup 0 exch rlineto exch 0 rlineto neg 0 exch rlineto}{exch dup 0 rlineto exch 0"
-" exch rlineto neg 0 rlineto}ifelse closepath}bind def @SD/rectclip{newpath dup t"
-"ype/arraytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifelse clip newpath"
-"}put @SD/rectfill{gsave newpath dup type/arraytype eq{aload length 4 idiv{@rectc"
-"c}repeat}{@rectcc}ifelse fill grestore}put @SD/rectstroke{gsave newpath dup type"
-"/arraytype eq{aload length 4 idiv{@rect}repeat}{@rect}ifelse stroke grestore}put"
-" false setglobal @SD readonly pop/initclip 0 defpr/sysexec{@SD exch get exec}def"
-"/adddot{dup length 1 add string dup 0 46 put dup 3 -1 roll 1 exch putinterval}de"
-"f/setlinewidth{dup/setlinewidth sysexec applyscalevals 1(setlinewidth)prcmd}def/"
-"setlinecap 1 defpr/setlinejoin 1 defpr/setmiterlimit 1 defpr/setdash{mark 3 1 ro"
-"ll 2 copy/setdash sysexec applyscalevals exch aload length 1 add -1 roll countto"
-"mark(setdash)prcmd pop}def/setgstate{currentlinewidth 1(setlinewidth)prcmd curre"
-"ntlinecap 1(setlinecap)prcmd currentlinejoin 1(setlinejoin)prcmd currentmiterlim"
-"it 1(setmiterlimit)prcmd currentrgbcolor 3(setrgbcolor)prcmd 6 array currentmatr"
-"ix aload pop 6(setmatrix)prcmd currentdash mark 3 1 roll exch aload length 1 add"
-" -1 roll counttomark(setdash)prcmd pop}def/save{@UD begin/@saveID vmstatus pop p"
-"op def end :save @saveID 1(save)prcmd}def/restore{:restore setgstate @UD/@saveID"
-" known{@UD begin @saveID end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/grestor"
-"e{:grestore setgstate 0(grestore)prcmd}def/grestoreall{:grestoreall setstate 0(g"
-"restoreall)prcmd}def/rotate{dup type/arraytype ne{dup 1(rotate)prcmd}if/rotate s"
-"ysexec}def/scale{dup type/arraytype ne{2 copy 2(scale)prcmd}if/scale sysexec}def"
-"/translate{dup type/arraytype ne{2 copy 2(translate)prcmd}if/translate sysexec}d"
-"ef/setmatrix{dup/setmatrix sysexec aload pop 6(setmatrix)prcmd}def/initmatrix{ma"
-"trix setmatrix}def/concat{matrix currentmatrix matrix concatmatrix setmatrix}def"
-"/makepattern{gsave <</mx 3 -1 roll >> begin dup/XUID[1000000 @patcnt]put mx/make"
-"pattern sysexec dup dup begin PatternType @patcnt BBox aload pop XStep YStep Pai"
-"ntType mx aload pop 15(makepattern)prcmd newpath matrix setmatrix PaintProc 0 1("
-"makepattern)prcmd end/@patcnt @patcnt 1 add store end grestore}def/setpattern{be"
-"gin PatternType 1 eq{PaintType 1 eq{XUID aload pop exch pop 1}{:gsave[currentcol"
-"orspace aload length -1 roll pop]setcolorspace/setcolor sysexec XUID aload pop e"
-"xch pop currentrgbcolor :grestore 4}ifelse(setpattern)prcmd}{/setpattern sysexec"
-"}ifelse end}def/setcolor{dup type/dicttype eq{setpattern}{/setcolor sysexec}ifel"
-"se}def/setgray 1 defpr/setcmykcolor 4 defpr/sethsbcolor 3 defpr/setrgbcolor 3 de"
-"fpr/.setopacityalpha{dup/.setopacityalpha sysexec 1(setopacityalpha)prcmd}def ";
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/ChangeLog b/Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/ChangeLog
index 5459329ba65..9c1da1c7cb2 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/ChangeLog
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/ChangeLog
@@ -1,3 +1,8 @@
+2014-07-31 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * Import release 1.8.
+ * patch-01-cygwin (removed): Included upstream.
+
2014-06-25 Peter Breitenlohner <peb@mppmu.mpg.de>
* patch-01-cygwin (new): Cygwin soname for gs library.
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/TL-Changes b/Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/TL-Changes
index f42f746ea91..29913179366 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7-PATCHES/TL-Changes
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8-PATCHES/TL-Changes
@@ -1,4 +1,4 @@
-Changes applied to the dvisvgm-1.7 tree as obtained from:
+Changes applied to the dvisvgm-1.8 tree as obtained from:
http://downloads.sourceforge.net/dvisvgm/
Removed:
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/AUTHORS b/Build/source/texk/dvisvgm/dvisvgm-1.8/AUTHORS
index d9b6468421e..d9b6468421e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/AUTHORS
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/AUTHORS
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/COPYING b/Build/source/texk/dvisvgm/dvisvgm-1.8/COPYING
index 94a9ed024d3..94a9ed024d3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/COPYING
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/COPYING
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/ChangeLog b/Build/source/texk/dvisvgm/dvisvgm-1.8/ChangeLog
index c601847210e..a0ffb165fab 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/ChangeLog
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/ChangeLog
@@ -1,3 +1,92 @@
+2014-07-29 Martin Gieseking <martin.gieseking@uos.de>
+
+ * NEWS:
+ updated NEWS
+
+2014-07-28 Martin Gieseking <martin.gieseking@uos.de>
+
+ * configure.ac, src/Doxyfile:
+ set version to 1.8
+
+ * src/GraphicPath.h, src/PSInterpreter.cpp, src/PSInterpreter.h,
+ src/PsSpecialHandler.cpp, src/PsSpecialHandler.h, src/psdefs.cpp,
+ src/psdefs.ps, tests/PSInterpreterTest.cpp:
+ added evaluation of PS operator 'clippath' (copies clipping path into
+ graphics path)
+
+2014-07-26 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/Font.cpp, src/GFGlyphTracer.cpp, src/GraphicPath.h,
+ src/PsSpecialHandler.cpp:
+ renamed GraphicPath::newpath() to GraphicPath::clear()
+
+2014-07-24 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/InputReader.cpp, src/PSInterpreter.cpp:
+ ensure that InputReader::compare() checks whole and not just partial
+ words
+
+2014-07-22 Martin Gieseking <martin.gieseking@uos.de>
+
+ * doc/dvisvgm.txt.in, src/CommandLine.cpp, src/CommandLine.h,
+ src/PsSpecialHandler.cpp, src/PsSpecialHandler.h, src/dvisvgm.cpp,
+ src/options.xml:
+ added option --clippath to compute the intersection of clipping paths
+
+ * README, README.md, src/Bezier.cpp, src/Bezier.h, src/GraphicPath.h,
+ src/Makefile.am, src/PathClipper.cpp, src/PathClipper.h, src/dvisvgm.cpp:
+ added class PathClipper to compute intersections of closed curved
+ graphics paths
+
+ * src/GraphicPath.h:
+ added field to store the winding rule to class GraphicPath
+
+ * Makefile.am, clipper/License.txt, clipper/Makefile.am,
+ clipper/clipper.cpp, clipper/clipper.hpp, configure.ac, src/Makefile.am:
+ added slightly modified sources of clipper library (computes boolops on
+ polygons)
+
+ * src/DVIToSVG.h, src/dvisvgm.cpp:
+ prevent throwing a DVIException when option -l is present
+
+2014-07-20 Khaled Hosny <khaledhosny@eglug.org>
+
+ * src/FontEngine.cpp:
+ free existing FT_Face before creating a new one
+
+2014-07-18 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/TpicSpecialHandler.cpp:
+ TPIC handler: use class GraphicPath to create SVG path commands
+
+ * doc/dvisvgm.txt.in, src/CommandLine.cpp, src/CommandLine.h,
+ src/GraphicPath.h, src/PsSpecialHandler.cpp, src/SVGTree.cpp,
+ src/SVGTree.h, src/dvisvgm.cpp, src/options.xml,
+ tests/GraphicPathTest.cpp:
+ added option to create relative rather than absolute path commands
+
+2014-07-07 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/DVIToSVGActions.h, src/Doxyfile, src/HtmlSpecialHandler.h,
+ src/RangeMap.cpp, src/SpecialManager.cpp, src/ToUnicodeMap.cpp:
+ fixed a couple of broken doxygen comments
+
+2014-06-25 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/Ghostscript.cpp:
+ get proper name of Ghostscript library when building for Cygwin
+
+2014-06-23 Martin Gieseking <martin.gieseking@uos.de>
+
+ * README.md:
+ added markdown version of README
+
+2014-06-20 Martin Gieseking <martin.gieseking@uos.de>
+
+ * src/psdefs.cpp, src/psdefs.ps:
+ suppress output of PS operator ':show' to prevent the creation of
+ additional graphic elements
+
2014-06-17 Martin Gieseking <martin.gieseking@uos.de>
* NEWS:
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/INSTALL b/Build/source/texk/dvisvgm/dvisvgm-1.8/INSTALL
index a4b34144dcf..a4b34144dcf 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/INSTALL
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/INSTALL
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/LGPL-2.1.txt b/Build/source/texk/dvisvgm/dvisvgm-1.8/LGPL-2.1.txt
index 602bfc94635..602bfc94635 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/LGPL-2.1.txt
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/LGPL-2.1.txt
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.8/Makefile.am
index b73dbf588f8..c4675c016e0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/Makefile.am
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/Makefile.am
@@ -5,5 +5,5 @@
AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = COPYING LGPL-2.1.txt
-SUBDIRS = src tests doc
+SUBDIRS = clipper src tests doc
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/NEWS b/Build/source/texk/dvisvgm/dvisvgm-1.8/NEWS
index 34228a9dbb9..51245c1bf36 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/NEWS
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/NEWS
@@ -1,3 +1,15 @@
+dvisvgm-1.8 (2014-07-29)
+- added option --clipjoin which tells dvisvgm to compute intersections
+ of clipping paths itself and not to delegate this task to the SVG renderer
+- added option --relative to create relative rather than absolute path commands
+- added evaluation of PS operator 'clippath' which copies the current clipping
+ path into the graphics path
+- fixed PS operator 'show' to prevent the creation of unintended path overlays
+- fixed memory leak in class FontEngine (patch by Khaled Hosny)
+- fixed unintended throwing of a DVIException when dvisvgm is called with
+ option --list-specials
+- Cygwin builds of dvisvgm now look for the proper filename of the Ghostscript DLL
+
dvisvgm-1.7 (2014-06-18)
- all DVI files are pre-processed now to allow the implementation of
advanced features that rely on data not available on the pages being
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/README b/Build/source/texk/dvisvgm/dvisvgm-1.8/README
index 2454a2a23f4..e0d3b3fd6c5 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/README
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/README
@@ -9,9 +9,14 @@ DESCRIPTION
DEPENDENCIES
dvisvgm relies on the following free libraries:
+ * Clipper (http://www.angusj.com/delphi/clipper.php)
+ To compute the insersections of two curved paths, dvisvgm
+ flattens the paths to polygons, intersects them using Clipper,
+ and reconstructs the curves afterwards.
+
* FreeType 2 (http://www.freetype.org)
- This library is used to extract glyph outlines
- from PFB files.
+ This library is used to extract the glyph outlines
+ from vector fonts (PFB, OTF, TTF).
* Ghostscript (http://pages.cs.wisc.edu/~ghost)
The PostScript special handler requires the Ghostscript
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/Makefile.am
new file mode 100644
index 00000000000..a24a478e587
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/Makefile.am
@@ -0,0 +1,7 @@
+noinst_LIBRARIES = libclipper.a
+libclipper_a_SOURCES = clipper.cpp clipper.hpp
+
+AM_CXXFLAGS = -Wall
+
+clipper.cpp: clipper.hpp
+
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.cpp
new file mode 100644
index 00000000000..a6dbae285cf
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.cpp
@@ -0,0 +1,4464 @@
+/*******************************************************************************
+* *
+* Author : Angus Johnson *
+* Version : 6.1.5 *
+* Date : 16 July 2014 *
+* Website : http://www.angusj.com *
+* Copyright : Angus Johnson 2010-2014 *
+* *
+* License: *
+* Use, modification & distribution is subject to Boost Software License Ver 1. *
+* http://www.boost.org/LICENSE_1_0.txt *
+* *
+* Attributions: *
+* The code in this library is an extension of Bala Vatti's clipping algorithm: *
+* "A generic solution to polygon clipping" *
+* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
+* http://portal.acm.org/citation.cfm?id=129906 *
+* *
+* Computer graphics and geometric modeling: implementation and algorithms *
+* By Max K. Agoston *
+* Springer; 1 edition (January 4, 2005) *
+* http://books.google.com/books?q=vatti+clipping+agoston *
+* *
+* See also: *
+* "Polygon Offsetting by Computing Winding Numbers" *
+* Paper no. DETC2005-85513 pp. 565-575 *
+* ASME 2005 International Design Engineering Technical Conferences *
+* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
+* September 24-28, 2005 , Long Beach, California, USA *
+* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
+* *
+*******************************************************************************/
+
+/*******************************************************************************
+* *
+* This is a translation of the Delphi Clipper library and the naming style *
+* used has retained a Delphi flavour. *
+* *
+*******************************************************************************/
+
+#include "clipper.hpp"
+#include <cmath>
+#include <vector>
+#include <algorithm>
+#include <stdexcept>
+#include <cstring>
+#include <cstdlib>
+#include <ostream>
+#include <functional>
+
+namespace ClipperLib {
+
+static double const pi = 3.141592653589793238;
+static double const two_pi = pi *2;
+static double const def_arc_tolerance = 0.25;
+
+enum Direction { dRightToLeft, dLeftToRight };
+
+static int const Unassigned = -1; //edge not currently 'owning' a solution
+static int const Skip = -2; //edge that would otherwise close a path
+
+#define HORIZONTAL (-1.0E+40)
+#define TOLERANCE (1.0e-20)
+#define NEAR_ZERO(val) (((val) > -TOLERANCE) && ((val) < TOLERANCE))
+
+struct TEdge {
+ IntPoint Bot;
+ IntPoint Curr;
+ IntPoint Top;
+ IntPoint Delta;
+ double Dx;
+ PolyType PolyTyp;
+ EdgeSide Side;
+ int WindDelta; //1 or -1 depending on winding direction
+ int WindCnt;
+ int WindCnt2; //winding count of the opposite polytype
+ int OutIdx;
+ TEdge *Next;
+ TEdge *Prev;
+ TEdge *NextInLML;
+ TEdge *NextInAEL;
+ TEdge *PrevInAEL;
+ TEdge *NextInSEL;
+ TEdge *PrevInSEL;
+};
+
+struct IntersectNode {
+ TEdge *Edge1;
+ TEdge *Edge2;
+ IntPoint Pt;
+};
+
+struct LocalMinimum {
+ cInt Y;
+ TEdge *LeftBound;
+ TEdge *RightBound;
+};
+
+struct OutPt;
+
+struct OutRec {
+ int Idx;
+ bool IsHole;
+ bool IsOpen;
+ OutRec *FirstLeft; //see comments in clipper.pas
+ PolyNode *PolyNd;
+ OutPt *Pts;
+ OutPt *BottomPt;
+};
+
+struct OutPt {
+ int Idx;
+ IntPoint Pt;
+ OutPt *Next;
+ OutPt *Prev;
+};
+
+struct Join {
+ OutPt *OutPt1;
+ OutPt *OutPt2;
+ IntPoint OffPt;
+};
+
+struct LocMinSorter
+{
+ inline bool operator()(const LocalMinimum& locMin1, const LocalMinimum& locMin2)
+ {
+ return locMin2.Y < locMin1.Y;
+ }
+};
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+inline cInt Round(double val)
+{
+ if ((val < 0)) return static_cast<cInt>(val - 0.5);
+ else return static_cast<cInt>(val + 0.5);
+}
+//------------------------------------------------------------------------------
+
+inline cInt Abs(cInt val)
+{
+ return val < 0 ? -val : val;
+}
+
+//------------------------------------------------------------------------------
+// PolyTree methods ...
+//------------------------------------------------------------------------------
+
+void PolyTree::Clear()
+{
+ for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i)
+ delete AllNodes[i];
+ AllNodes.resize(0);
+ Childs.resize(0);
+}
+//------------------------------------------------------------------------------
+
+PolyNode* PolyTree::GetFirst() const
+{
+ if (!Childs.empty())
+ return Childs[0];
+ else
+ return 0;
+}
+//------------------------------------------------------------------------------
+
+int PolyTree::Total() const
+{
+ return (int)AllNodes.size();
+}
+
+//------------------------------------------------------------------------------
+// PolyNode methods ...
+//------------------------------------------------------------------------------
+
+PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false)
+{
+}
+//------------------------------------------------------------------------------
+
+int PolyNode::ChildCount() const
+{
+ return (int)Childs.size();
+}
+//------------------------------------------------------------------------------
+
+void PolyNode::AddChild(PolyNode& child)
+{
+ unsigned cnt = (unsigned)Childs.size();
+ Childs.push_back(&child);
+ child.Parent = this;
+ child.Index = cnt;
+}
+//------------------------------------------------------------------------------
+
+PolyNode* PolyNode::GetNext() const
+{
+ if (!Childs.empty())
+ return Childs[0];
+ else
+ return GetNextSiblingUp();
+}
+//------------------------------------------------------------------------------
+
+PolyNode* PolyNode::GetNextSiblingUp() const
+{
+ if (!Parent) //protects against PolyTree.GetNextSiblingUp()
+ return 0;
+ else if (Index == Parent->Childs.size() - 1)
+ return Parent->GetNextSiblingUp();
+ else
+ return Parent->Childs[Index + 1];
+}
+//------------------------------------------------------------------------------
+
+bool PolyNode::IsHole() const
+{
+ bool result = true;
+ PolyNode* node = Parent;
+ while (node)
+ {
+ result = !result;
+ node = node->Parent;
+ }
+ return result;
+}
+//------------------------------------------------------------------------------
+
+bool PolyNode::IsOpen() const
+{
+ return m_IsOpen;
+}
+//------------------------------------------------------------------------------
+
+#ifndef use_int32
+
+//------------------------------------------------------------------------------
+// Int128 class (enables safe math on signed 64bit integers)
+// eg Int128 val1((long64)9223372036854775807); //ie 2^63 -1
+// Int128 val2((long64)9223372036854775807);
+// Int128 val3 = val1 * val2;
+// val3.AsString => "85070591730234615847396907784232501249" (8.5e+37)
+//------------------------------------------------------------------------------
+
+class Int128
+{
+ public:
+ ulong64 lo;
+ long64 hi;
+
+ Int128(long64 _lo = 0)
+ {
+ lo = (ulong64)_lo;
+ if (_lo < 0) hi = -1; else hi = 0;
+ }
+
+
+ Int128(const Int128 &val): lo(val.lo), hi(val.hi){}
+
+ Int128(const long64& _hi, const ulong64& _lo): lo(_lo), hi(_hi){}
+
+ Int128& operator = (const long64 &val)
+ {
+ lo = (ulong64)val;
+ if (val < 0) hi = -1; else hi = 0;
+ return *this;
+ }
+
+ bool operator == (const Int128 &val) const
+ {return (hi == val.hi && lo == val.lo);}
+
+ bool operator != (const Int128 &val) const
+ { return !(*this == val);}
+
+ bool operator > (const Int128 &val) const
+ {
+ if (hi != val.hi)
+ return hi > val.hi;
+ else
+ return lo > val.lo;
+ }
+
+ bool operator < (const Int128 &val) const
+ {
+ if (hi != val.hi)
+ return hi < val.hi;
+ else
+ return lo < val.lo;
+ }
+
+ bool operator >= (const Int128 &val) const
+ { return !(*this < val);}
+
+ bool operator <= (const Int128 &val) const
+ { return !(*this > val);}
+
+ Int128& operator += (const Int128 &rhs)
+ {
+ hi += rhs.hi;
+ lo += rhs.lo;
+ if (lo < rhs.lo) hi++;
+ return *this;
+ }
+
+ Int128 operator + (const Int128 &rhs) const
+ {
+ Int128 result(*this);
+ result+= rhs;
+ return result;
+ }
+
+ Int128& operator -= (const Int128 &rhs)
+ {
+ *this += -rhs;
+ return *this;
+ }
+
+ Int128 operator - (const Int128 &rhs) const
+ {
+ Int128 result(*this);
+ result -= rhs;
+ return result;
+ }
+
+ Int128 operator-() const //unary negation
+ {
+ if (lo == 0)
+ return Int128(-hi, 0);
+ else
+ return Int128(~hi, ~lo + 1);
+ }
+
+ operator double() const
+ {
+ const double shift64 = 18446744073709551616.0; //2^64
+ if (hi < 0)
+ {
+ if (lo == 0) return (double)hi * shift64;
+ else return -(double)(~lo + ~hi * shift64);
+ }
+ else
+ return (double)(lo + hi * shift64);
+ }
+
+};
+//------------------------------------------------------------------------------
+
+Int128 Int128Mul (long64 lhs, long64 rhs)
+{
+ bool negate = (lhs < 0) != (rhs < 0);
+
+ if (lhs < 0) lhs = -lhs;
+ ulong64 int1Hi = ulong64(lhs) >> 32;
+ ulong64 int1Lo = ulong64(lhs & 0xFFFFFFFF);
+
+ if (rhs < 0) rhs = -rhs;
+ ulong64 int2Hi = ulong64(rhs) >> 32;
+ ulong64 int2Lo = ulong64(rhs & 0xFFFFFFFF);
+
+ //nb: see comments in clipper.pas
+ ulong64 a = int1Hi * int2Hi;
+ ulong64 b = int1Lo * int2Lo;
+ ulong64 c = int1Hi * int2Lo + int1Lo * int2Hi;
+
+ Int128 tmp;
+ tmp.hi = long64(a + (c >> 32));
+ tmp.lo = long64(c << 32);
+ tmp.lo += long64(b);
+ if (tmp.lo < b) tmp.hi++;
+ if (negate) tmp = -tmp;
+ return tmp;
+};
+#endif
+
+//------------------------------------------------------------------------------
+// Miscellaneous global functions
+//------------------------------------------------------------------------------
+
+bool Orientation(const Path &poly)
+{
+ return Area(poly) >= 0;
+}
+//------------------------------------------------------------------------------
+
+double Area(const Path &poly)
+{
+ int size = (int)poly.size();
+ if (size < 3) return 0;
+
+ double a = 0;
+ for (int i = 0, j = size -1; i < size; ++i)
+ {
+ a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y);
+ j = i;
+ }
+ return -a * 0.5;
+}
+//------------------------------------------------------------------------------
+
+double Area(const OutRec &outRec)
+{
+ OutPt *op = outRec.Pts;
+ if (!op) return 0;
+ double a = 0;
+ do {
+ a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y);
+ op = op->Next;
+ } while (op != outRec.Pts);
+ return a * 0.5;
+}
+//------------------------------------------------------------------------------
+
+bool PointIsVertex(const IntPoint &Pt, OutPt *pp)
+{
+ OutPt *pp2 = pp;
+ do
+ {
+ if (pp2->Pt == Pt) return true;
+ pp2 = pp2->Next;
+ }
+ while (pp2 != pp);
+ return false;
+}
+//------------------------------------------------------------------------------
+
+int PointInPolygon (const IntPoint &pt, const Path &path)
+{
+ //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
+ //See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos
+ //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf
+ int result = 0;
+ size_t cnt = path.size();
+ if (cnt < 3) return 0;
+ IntPoint ip = path[0];
+ for(size_t i = 1; i <= cnt; ++i)
+ {
+ IntPoint ipNext = (i == cnt ? path[0] : path[i]);
+ if (ipNext.Y == pt.Y)
+ {
+ if ((ipNext.X == pt.X) || (ip.Y == pt.Y &&
+ ((ipNext.X > pt.X) == (ip.X < pt.X)))) return -1;
+ }
+ if ((ip.Y < pt.Y) != (ipNext.Y < pt.Y))
+ {
+ if (ip.X >= pt.X)
+ {
+ if (ipNext.X > pt.X) result = 1 - result;
+ else
+ {
+ double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -
+ (double)(ipNext.X - pt.X) * (ip.Y - pt.Y);
+ if (!d) return -1;
+ if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result;
+ }
+ } else
+ {
+ if (ipNext.X > pt.X)
+ {
+ double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -
+ (double)(ipNext.X - pt.X) * (ip.Y - pt.Y);
+ if (!d) return -1;
+ if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result;
+ }
+ }
+ }
+ ip = ipNext;
+ }
+ return result;
+}
+//------------------------------------------------------------------------------
+
+int PointInPolygon (const IntPoint &pt, OutPt *op)
+{
+ //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
+ int result = 0;
+ OutPt* startOp = op;
+ for(;;)
+ {
+ if (op->Next->Pt.Y == pt.Y)
+ {
+ if ((op->Next->Pt.X == pt.X) || (op->Pt.Y == pt.Y &&
+ ((op->Next->Pt.X > pt.X) == (op->Pt.X < pt.X)))) return -1;
+ }
+ if ((op->Pt.Y < pt.Y) != (op->Next->Pt.Y < pt.Y))
+ {
+ if (op->Pt.X >= pt.X)
+ {
+ if (op->Next->Pt.X > pt.X) result = 1 - result;
+ else
+ {
+ double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
+ (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
+ if (!d) return -1;
+ if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
+ }
+ } else
+ {
+ if (op->Next->Pt.X > pt.X)
+ {
+ double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
+ (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
+ if (!d) return -1;
+ if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
+ }
+ }
+ }
+ op = op->Next;
+ if (startOp == op) break;
+ }
+ return result;
+}
+//------------------------------------------------------------------------------
+
+bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2)
+{
+ OutPt* op = OutPt1;
+ do
+ {
+ //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon
+ int res = PointInPolygon(op->Pt, OutPt2);
+ if (res >= 0) return res > 0;
+ op = op->Next;
+ }
+ while (op != OutPt1);
+ return true;
+}
+//----------------------------------------------------------------------
+
+bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
+{
+#ifndef use_int32
+ if (UseFullInt64Range)
+ return Int128Mul(e1.Delta.Y, e2.Delta.X) == Int128Mul(e1.Delta.X, e2.Delta.Y);
+ else
+#endif
+ return e1.Delta.Y * e2.Delta.X == e1.Delta.X * e2.Delta.Y;
+}
+//------------------------------------------------------------------------------
+
+bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
+ const IntPoint pt3, bool UseFullInt64Range)
+{
+#ifndef use_int32
+ if (UseFullInt64Range)
+ return Int128Mul(pt1.Y-pt2.Y, pt2.X-pt3.X) == Int128Mul(pt1.X-pt2.X, pt2.Y-pt3.Y);
+ else
+#endif
+ return (pt1.Y-pt2.Y)*(pt2.X-pt3.X) == (pt1.X-pt2.X)*(pt2.Y-pt3.Y);
+}
+//------------------------------------------------------------------------------
+
+bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
+ const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
+{
+#ifndef use_int32
+ if (UseFullInt64Range)
+ return Int128Mul(pt1.Y-pt2.Y, pt3.X-pt4.X) == Int128Mul(pt1.X-pt2.X, pt3.Y-pt4.Y);
+ else
+#endif
+ return (pt1.Y-pt2.Y)*(pt3.X-pt4.X) == (pt1.X-pt2.X)*(pt3.Y-pt4.Y);
+}
+//------------------------------------------------------------------------------
+
+inline bool IsHorizontal(TEdge &e)
+{
+ return e.Delta.Y == 0;
+}
+//------------------------------------------------------------------------------
+
+inline double GetDx(const IntPoint pt1, const IntPoint pt2)
+{
+ return (pt1.Y == pt2.Y) ?
+ HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y);
+}
+//---------------------------------------------------------------------------
+
+inline void SetDx(TEdge &e)
+{
+ e.Delta.X = (e.Top.X - e.Bot.X);
+ e.Delta.Y = (e.Top.Y - e.Bot.Y);
+
+ if (e.Delta.Y == 0) e.Dx = HORIZONTAL;
+ else e.Dx = (double)(e.Delta.X) / e.Delta.Y;
+}
+//---------------------------------------------------------------------------
+
+inline void SwapSides(TEdge &Edge1, TEdge &Edge2)
+{
+ EdgeSide Side = Edge1.Side;
+ Edge1.Side = Edge2.Side;
+ Edge2.Side = Side;
+}
+//------------------------------------------------------------------------------
+
+inline void SwapPolyIndexes(TEdge &Edge1, TEdge &Edge2)
+{
+ int OutIdx = Edge1.OutIdx;
+ Edge1.OutIdx = Edge2.OutIdx;
+ Edge2.OutIdx = OutIdx;
+}
+//------------------------------------------------------------------------------
+
+inline cInt TopX(TEdge &edge, const cInt currentY)
+{
+ return ( currentY == edge.Top.Y ) ?
+ edge.Top.X : edge.Bot.X + Round(edge.Dx *(currentY - edge.Bot.Y));
+}
+//------------------------------------------------------------------------------
+
+void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip)
+{
+#ifdef use_xyz
+ ip.Z = 0;
+#endif
+
+ double b1, b2;
+ if (Edge1.Dx == Edge2.Dx)
+ {
+ ip.Y = Edge1.Curr.Y;
+ ip.X = TopX(Edge1, ip.Y);
+ return;
+ }
+ else if (Edge1.Delta.X == 0)
+ {
+ ip.X = Edge1.Bot.X;
+ if (IsHorizontal(Edge2))
+ ip.Y = Edge2.Bot.Y;
+ else
+ {
+ b2 = Edge2.Bot.Y - (Edge2.Bot.X / Edge2.Dx);
+ ip.Y = Round(ip.X / Edge2.Dx + b2);
+ }
+ }
+ else if (Edge2.Delta.X == 0)
+ {
+ ip.X = Edge2.Bot.X;
+ if (IsHorizontal(Edge1))
+ ip.Y = Edge1.Bot.Y;
+ else
+ {
+ b1 = Edge1.Bot.Y - (Edge1.Bot.X / Edge1.Dx);
+ ip.Y = Round(ip.X / Edge1.Dx + b1);
+ }
+ }
+ else
+ {
+ b1 = Edge1.Bot.X - Edge1.Bot.Y * Edge1.Dx;
+ b2 = Edge2.Bot.X - Edge2.Bot.Y * Edge2.Dx;
+ double q = (b2-b1) / (Edge1.Dx - Edge2.Dx);
+ ip.Y = Round(q);
+ if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
+ ip.X = Round(Edge1.Dx * q + b1);
+ else
+ ip.X = Round(Edge2.Dx * q + b2);
+ }
+
+ if (ip.Y < Edge1.Top.Y || ip.Y < Edge2.Top.Y)
+ {
+ if (Edge1.Top.Y > Edge2.Top.Y)
+ ip.Y = Edge1.Top.Y;
+ else
+ ip.Y = Edge2.Top.Y;
+ if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
+ ip.X = TopX(Edge1, ip.Y);
+ else
+ ip.X = TopX(Edge2, ip.Y);
+ }
+ //finally, don't allow 'ip' to be BELOW curr.Y (ie bottom of scanbeam) ...
+ if (ip.Y > Edge1.Curr.Y)
+ {
+ ip.Y = Edge1.Curr.Y;
+ //use the more vertical edge to derive X ...
+ if (std::fabs(Edge1.Dx) > std::fabs(Edge2.Dx))
+ ip.X = TopX(Edge2, ip.Y); else
+ ip.X = TopX(Edge1, ip.Y);
+ }
+}
+//------------------------------------------------------------------------------
+
+void ReversePolyPtLinks(OutPt *pp)
+{
+ if (!pp) return;
+ OutPt *pp1, *pp2;
+ pp1 = pp;
+ do {
+ pp2 = pp1->Next;
+ pp1->Next = pp1->Prev;
+ pp1->Prev = pp2;
+ pp1 = pp2;
+ } while( pp1 != pp );
+}
+//------------------------------------------------------------------------------
+
+void DisposeOutPts(OutPt*& pp)
+{
+ if (pp == 0) return;
+ pp->Prev->Next = 0;
+ while( pp )
+ {
+ OutPt *tmpPp = pp;
+ pp = pp->Next;
+ delete tmpPp;
+ }
+}
+//------------------------------------------------------------------------------
+
+inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt)
+{
+ std::memset(e, 0, sizeof(TEdge));
+ e->Next = eNext;
+ e->Prev = ePrev;
+ e->Curr = Pt;
+ e->OutIdx = Unassigned;
+}
+//------------------------------------------------------------------------------
+
+void InitEdge2(TEdge& e, PolyType Pt)
+{
+ if (e.Curr.Y >= e.Next->Curr.Y)
+ {
+ e.Bot = e.Curr;
+ e.Top = e.Next->Curr;
+ } else
+ {
+ e.Top = e.Curr;
+ e.Bot = e.Next->Curr;
+ }
+ SetDx(e);
+ e.PolyTyp = Pt;
+}
+//------------------------------------------------------------------------------
+
+TEdge* RemoveEdge(TEdge* e)
+{
+ //removes e from double_linked_list (but without removing from memory)
+ e->Prev->Next = e->Next;
+ e->Next->Prev = e->Prev;
+ TEdge* result = e->Next;
+ e->Prev = 0; //flag as removed (see ClipperBase.Clear)
+ return result;
+}
+//------------------------------------------------------------------------------
+
+inline void ReverseHorizontal(TEdge &e)
+{
+ //swap horizontal edges' Top and Bottom x's so they follow the natural
+ //progression of the bounds - ie so their xbots will align with the
+ //adjoining lower edge. [Helpful in the ProcessHorizontal() method.]
+ std::swap(e.Top.X, e.Bot.X);
+#ifdef use_xyz
+ std::swap(e.Top.Z, e.Bot.Z);
+#endif
+}
+//------------------------------------------------------------------------------
+
+void SwapPoints(IntPoint &pt1, IntPoint &pt2)
+{
+ IntPoint tmp = pt1;
+ pt1 = pt2;
+ pt2 = tmp;
+}
+//------------------------------------------------------------------------------
+
+bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a,
+ IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
+{
+ //precondition: segments are Collinear.
+ if (Abs(pt1a.X - pt1b.X) > Abs(pt1a.Y - pt1b.Y))
+ {
+ if (pt1a.X > pt1b.X) SwapPoints(pt1a, pt1b);
+ if (pt2a.X > pt2b.X) SwapPoints(pt2a, pt2b);
+ if (pt1a.X > pt2a.X) pt1 = pt1a; else pt1 = pt2a;
+ if (pt1b.X < pt2b.X) pt2 = pt1b; else pt2 = pt2b;
+ return pt1.X < pt2.X;
+ } else
+ {
+ if (pt1a.Y < pt1b.Y) SwapPoints(pt1a, pt1b);
+ if (pt2a.Y < pt2b.Y) SwapPoints(pt2a, pt2b);
+ if (pt1a.Y < pt2a.Y) pt1 = pt1a; else pt1 = pt2a;
+ if (pt1b.Y > pt2b.Y) pt2 = pt1b; else pt2 = pt2b;
+ return pt1.Y > pt2.Y;
+ }
+}
+//------------------------------------------------------------------------------
+
+bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2)
+{
+ OutPt *p = btmPt1->Prev;
+ while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Prev;
+ double dx1p = std::fabs(GetDx(btmPt1->Pt, p->Pt));
+ p = btmPt1->Next;
+ while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Next;
+ double dx1n = std::fabs(GetDx(btmPt1->Pt, p->Pt));
+
+ p = btmPt2->Prev;
+ while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Prev;
+ double dx2p = std::fabs(GetDx(btmPt2->Pt, p->Pt));
+ p = btmPt2->Next;
+ while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next;
+ double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt));
+ return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
+}
+//------------------------------------------------------------------------------
+
+OutPt* GetBottomPt(OutPt *pp)
+{
+ OutPt* dups = 0;
+ OutPt* p = pp->Next;
+ while (p != pp)
+ {
+ if (p->Pt.Y > pp->Pt.Y)
+ {
+ pp = p;
+ dups = 0;
+ }
+ else if (p->Pt.Y == pp->Pt.Y && p->Pt.X <= pp->Pt.X)
+ {
+ if (p->Pt.X < pp->Pt.X)
+ {
+ dups = 0;
+ pp = p;
+ } else
+ {
+ if (p->Next != pp && p->Prev != pp) dups = p;
+ }
+ }
+ p = p->Next;
+ }
+ if (dups)
+ {
+ //there appears to be at least 2 vertices at BottomPt so ...
+ while (dups != p)
+ {
+ if (!FirstIsBottomPt(p, dups)) pp = dups;
+ dups = dups->Next;
+ while (dups->Pt != pp->Pt) dups = dups->Next;
+ }
+ }
+ return pp;
+}
+//------------------------------------------------------------------------------
+
+bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1,
+ const IntPoint pt2, const IntPoint pt3)
+{
+ if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2))
+ return false;
+ else if (pt1.X != pt3.X)
+ return (pt2.X > pt1.X) == (pt2.X < pt3.X);
+ else
+ return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y);
+}
+//------------------------------------------------------------------------------
+
+bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
+{
+ if (seg1a > seg1b) std::swap(seg1a, seg1b);
+ if (seg2a > seg2b) std::swap(seg2a, seg2b);
+ return (seg1a < seg2b) && (seg2a < seg1b);
+}
+
+//------------------------------------------------------------------------------
+// ClipperBase class methods ...
+//------------------------------------------------------------------------------
+
+ClipperBase::ClipperBase() //constructor
+{
+ m_CurrentLM = m_MinimaList.begin(); //begin() == end() here
+ m_UseFullRange = false;
+}
+//------------------------------------------------------------------------------
+
+ClipperBase::~ClipperBase() //destructor
+{
+ Clear();
+}
+//------------------------------------------------------------------------------
+
+void RangeTest(const IntPoint& Pt, bool& useFullRange)
+{
+ if (useFullRange)
+ {
+ if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange)
+ throw "Coordinate outside allowed range";
+ }
+ else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange)
+ {
+ useFullRange = true;
+ RangeTest(Pt, useFullRange);
+ }
+}
+//------------------------------------------------------------------------------
+
+TEdge* FindNextLocMin(TEdge* E)
+{
+ for (;;)
+ {
+ while (E->Bot != E->Prev->Bot || E->Curr == E->Top) E = E->Next;
+ if (!IsHorizontal(*E) && !IsHorizontal(*E->Prev)) break;
+ while (IsHorizontal(*E->Prev)) E = E->Prev;
+ TEdge* E2 = E;
+ while (IsHorizontal(*E)) E = E->Next;
+ if (E->Top.Y == E->Prev->Bot.Y) continue; //ie just an intermediate horz.
+ if (E2->Prev->Bot.X < E->Bot.X) E = E2;
+ break;
+ }
+ return E;
+}
+//------------------------------------------------------------------------------
+
+TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward)
+{
+ TEdge *Result = E;
+ TEdge *Horz = 0;
+
+ if (E->OutIdx == Skip)
+ {
+ //if edges still remain in the current bound beyond the skip edge then
+ //create another LocMin and call ProcessBound once more
+ if (NextIsForward)
+ {
+ while (E->Top.Y == E->Next->Bot.Y) E = E->Next;
+ //don't include top horizontals when parsing a bound a second time,
+ //they will be contained in the opposite bound ...
+ while (E != Result && IsHorizontal(*E)) E = E->Prev;
+ }
+ else
+ {
+ while (E->Top.Y == E->Prev->Bot.Y) E = E->Prev;
+ while (E != Result && IsHorizontal(*E)) E = E->Next;
+ }
+
+ if (E == Result)
+ {
+ if (NextIsForward) Result = E->Next;
+ else Result = E->Prev;
+ }
+ else
+ {
+ //there are more edges in the bound beyond result starting with E
+ if (NextIsForward)
+ E = Result->Next;
+ else
+ E = Result->Prev;
+ MinimaList::value_type locMin;
+ locMin.Y = E->Bot.Y;
+ locMin.LeftBound = 0;
+ locMin.RightBound = E;
+ E->WindDelta = 0;
+ Result = ProcessBound(E, NextIsForward);
+ m_MinimaList.push_back(locMin);
+ }
+ return Result;
+ }
+
+ TEdge *EStart;
+
+ if (IsHorizontal(*E))
+ {
+ //We need to be careful with open paths because this may not be a
+ //true local minima (ie E may be following a skip edge).
+ //Also, consecutive horz. edges may start heading left before going right.
+ if (NextIsForward)
+ EStart = E->Prev;
+ else
+ EStart = E->Next;
+ if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge
+ {
+ if (EStart->Bot.X != E->Bot.X && EStart->Top.X != E->Bot.X)
+ ReverseHorizontal(*E);
+ }
+ else if (EStart->Bot.X != E->Bot.X)
+ ReverseHorizontal(*E);
+ }
+
+ EStart = E;
+ if (NextIsForward)
+ {
+ while (Result->Top.Y == Result->Next->Bot.Y && Result->Next->OutIdx != Skip)
+ Result = Result->Next;
+ if (IsHorizontal(*Result) && Result->Next->OutIdx != Skip)
+ {
+ //nb: at the top of a bound, horizontals are added to the bound
+ //only when the preceding edge attaches to the horizontal's left vertex
+ //unless a Skip edge is encountered when that becomes the top divide
+ Horz = Result;
+ while (IsHorizontal(*Horz->Prev)) Horz = Horz->Prev;
+ if (Horz->Prev->Top.X == Result->Next->Top.X)
+ {
+ if (!NextIsForward) Result = Horz->Prev;
+ }
+ else if (Horz->Prev->Top.X > Result->Next->Top.X) Result = Horz->Prev;
+ }
+ while (E != Result)
+ {
+ E->NextInLML = E->Next;
+ if (IsHorizontal(*E) && E != EStart &&
+ E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E);
+ E = E->Next;
+ }
+ if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Prev->Top.X)
+ ReverseHorizontal(*E);
+ Result = Result->Next; //move to the edge just beyond current bound
+ } else
+ {
+ while (Result->Top.Y == Result->Prev->Bot.Y && Result->Prev->OutIdx != Skip)
+ Result = Result->Prev;
+ if (IsHorizontal(*Result) && Result->Prev->OutIdx != Skip)
+ {
+ Horz = Result;
+ while (IsHorizontal(*Horz->Next)) Horz = Horz->Next;
+ if (Horz->Next->Top.X == Result->Prev->Top.X)
+ {
+ if (!NextIsForward) Result = Horz->Next;
+ }
+ else if (Horz->Next->Top.X > Result->Prev->Top.X) Result = Horz->Next;
+ }
+
+ while (E != Result)
+ {
+ E->NextInLML = E->Prev;
+ if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X)
+ ReverseHorizontal(*E);
+ E = E->Prev;
+ }
+ if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X)
+ ReverseHorizontal(*E);
+ Result = Result->Prev; //move to the edge just beyond current bound
+ }
+
+ return Result;
+}
+//------------------------------------------------------------------------------
+
+bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed)
+{
+#ifdef use_lines
+ if (!Closed && PolyTyp == ptClip)
+ throw clipperException("AddPath: Open paths must be subject.");
+#else
+ if (!Closed)
+ throw clipperException("AddPath: Open paths have been disabled.");
+#endif
+
+ int highI = (int)pg.size() -1;
+ if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI;
+ while (highI > 0 && (pg[highI] == pg[highI -1])) --highI;
+ if ((Closed && highI < 2) || (!Closed && highI < 1)) return false;
+
+ //create a new edge array ...
+ TEdge *edges = new TEdge [highI +1];
+
+ bool IsFlat = true;
+ //1. Basic (first) edge initialization ...
+ try
+ {
+ edges[1].Curr = pg[1];
+ RangeTest(pg[0], m_UseFullRange);
+ RangeTest(pg[highI], m_UseFullRange);
+ InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]);
+ InitEdge(&edges[highI], &edges[0], &edges[highI-1], pg[highI]);
+ for (int i = highI - 1; i >= 1; --i)
+ {
+ RangeTest(pg[i], m_UseFullRange);
+ InitEdge(&edges[i], &edges[i+1], &edges[i-1], pg[i]);
+ }
+ }
+ catch(...)
+ {
+ delete [] edges;
+ throw; //range test fails
+ }
+ TEdge *eStart = &edges[0];
+
+ //2. Remove duplicate vertices, and (when closed) collinear edges ...
+ TEdge *E = eStart, *eLoopStop = eStart;
+ for (;;)
+ {
+ //nb: allows matching start and end points when not Closed ...
+ if (E->Curr == E->Next->Curr && (Closed || E->Next != eStart))
+ {
+ if (E == E->Next) break;
+ if (E == eStart) eStart = E->Next;
+ E = RemoveEdge(E);
+ eLoopStop = E;
+ continue;
+ }
+ if (E->Prev == E->Next)
+ break; //only two vertices
+ else if (Closed &&
+ SlopesEqual(E->Prev->Curr, E->Curr, E->Next->Curr, m_UseFullRange) &&
+ (!m_PreserveCollinear ||
+ !Pt2IsBetweenPt1AndPt3(E->Prev->Curr, E->Curr, E->Next->Curr)))
+ {
+ //Collinear edges are allowed for open paths but in closed paths
+ //the default is to merge adjacent collinear edges into a single edge.
+ //However, if the PreserveCollinear property is enabled, only overlapping
+ //collinear edges (ie spikes) will be removed from closed paths.
+ if (E == eStart) eStart = E->Next;
+ E = RemoveEdge(E);
+ E = E->Prev;
+ eLoopStop = E;
+ continue;
+ }
+ E = E->Next;
+ if ((E == eLoopStop) || (!Closed && E->Next == eStart)) break;
+ }
+
+ if ((!Closed && (E == E->Next)) || (Closed && (E->Prev == E->Next)))
+ {
+ delete [] edges;
+ return false;
+ }
+
+ if (!Closed)
+ {
+ m_HasOpenPaths = true;
+ eStart->Prev->OutIdx = Skip;
+ }
+
+ //3. Do second stage of edge initialization ...
+ E = eStart;
+ do
+ {
+ InitEdge2(*E, PolyTyp);
+ E = E->Next;
+ if (IsFlat && E->Curr.Y != eStart->Curr.Y) IsFlat = false;
+ }
+ while (E != eStart);
+
+ //4. Finally, add edge bounds to LocalMinima list ...
+
+ //Totally flat paths must be handled differently when adding them
+ //to LocalMinima list to avoid endless loops etc ...
+ if (IsFlat)
+ {
+ if (Closed)
+ {
+ delete [] edges;
+ return false;
+ }
+ E->Prev->OutIdx = Skip;
+ if (E->Prev->Bot.X < E->Prev->Top.X) ReverseHorizontal(*E->Prev);
+ MinimaList::value_type locMin;
+ locMin.Y = E->Bot.Y;
+ locMin.LeftBound = 0;
+ locMin.RightBound = E;
+ locMin.RightBound->Side = esRight;
+ locMin.RightBound->WindDelta = 0;
+ while (E->Next->OutIdx != Skip)
+ {
+ E->NextInLML = E->Next;
+ if (E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E);
+ E = E->Next;
+ }
+ m_MinimaList.push_back(locMin);
+ m_edges.push_back(edges);
+ return true;
+ }
+
+ m_edges.push_back(edges);
+ bool leftBoundIsForward;
+ TEdge* EMin = 0;
+
+ //workaround to avoid an endless loop in the while loop below when
+ //open paths have matching start and end points ...
+ if (E->Prev->Bot == E->Prev->Top) E = E->Next;
+
+ for (;;)
+ {
+ E = FindNextLocMin(E);
+ if (E == EMin) break;
+ else if (!EMin) EMin = E;
+
+ //E and E.Prev now share a local minima (left aligned if horizontal).
+ //Compare their slopes to find which starts which bound ...
+ MinimaList::value_type locMin;
+ locMin.Y = E->Bot.Y;
+ if (E->Dx < E->Prev->Dx)
+ {
+ locMin.LeftBound = E->Prev;
+ locMin.RightBound = E;
+ leftBoundIsForward = false; //Q.nextInLML = Q.prev
+ } else
+ {
+ locMin.LeftBound = E;
+ locMin.RightBound = E->Prev;
+ leftBoundIsForward = true; //Q.nextInLML = Q.next
+ }
+ locMin.LeftBound->Side = esLeft;
+ locMin.RightBound->Side = esRight;
+
+ if (!Closed) locMin.LeftBound->WindDelta = 0;
+ else if (locMin.LeftBound->Next == locMin.RightBound)
+ locMin.LeftBound->WindDelta = -1;
+ else locMin.LeftBound->WindDelta = 1;
+ locMin.RightBound->WindDelta = -locMin.LeftBound->WindDelta;
+
+ E = ProcessBound(locMin.LeftBound, leftBoundIsForward);
+ if (E->OutIdx == Skip) E = ProcessBound(E, leftBoundIsForward);
+
+ TEdge* E2 = ProcessBound(locMin.RightBound, !leftBoundIsForward);
+ if (E2->OutIdx == Skip) E2 = ProcessBound(E2, !leftBoundIsForward);
+
+ if (locMin.LeftBound->OutIdx == Skip)
+ locMin.LeftBound = 0;
+ else if (locMin.RightBound->OutIdx == Skip)
+ locMin.RightBound = 0;
+ m_MinimaList.push_back(locMin);
+ if (!leftBoundIsForward) E = E2;
+ }
+ return true;
+}
+//------------------------------------------------------------------------------
+
+bool ClipperBase::AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed)
+{
+ bool result = false;
+ for (Paths::size_type i = 0; i < ppg.size(); ++i)
+ if (AddPath(ppg[i], PolyTyp, Closed)) result = true;
+ return result;
+}
+//------------------------------------------------------------------------------
+
+void ClipperBase::Clear()
+{
+ DisposeLocalMinimaList();
+ for (EdgeList::size_type i = 0; i < m_edges.size(); ++i)
+ {
+ //for each edge array in turn, find the first used edge and
+ //check for and remove any hiddenPts in each edge in the array.
+ TEdge* edges = m_edges[i];
+ delete [] edges;
+ }
+ m_edges.clear();
+ m_UseFullRange = false;
+ m_HasOpenPaths = false;
+}
+//------------------------------------------------------------------------------
+
+void ClipperBase::Reset()
+{
+ m_CurrentLM = m_MinimaList.begin();
+ if (m_CurrentLM == m_MinimaList.end()) return; //ie nothing to process
+ std::sort(m_MinimaList.begin(), m_MinimaList.end(), LocMinSorter());
+
+ //reset all edges ...
+ for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm)
+ {
+ TEdge* e = lm->LeftBound;
+ if (e)
+ {
+ e->Curr = e->Bot;
+ e->Side = esLeft;
+ e->OutIdx = Unassigned;
+ }
+
+ e = lm->RightBound;
+ if (e)
+ {
+ e->Curr = e->Bot;
+ e->Side = esRight;
+ e->OutIdx = Unassigned;
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperBase::DisposeLocalMinimaList()
+{
+ m_MinimaList.clear();
+ m_CurrentLM = m_MinimaList.begin();
+}
+//------------------------------------------------------------------------------
+
+void ClipperBase::PopLocalMinima()
+{
+ if (m_CurrentLM == m_MinimaList.end()) return;
+ ++m_CurrentLM;
+}
+//------------------------------------------------------------------------------
+
+IntRect ClipperBase::GetBounds()
+{
+ IntRect result;
+ MinimaList::iterator lm = m_MinimaList.begin();
+ if (lm == m_MinimaList.end())
+ {
+ result.left = result.top = result.right = result.bottom = 0;
+ return result;
+ }
+ result.left = lm->LeftBound->Bot.X;
+ result.top = lm->LeftBound->Bot.Y;
+ result.right = lm->LeftBound->Bot.X;
+ result.bottom = lm->LeftBound->Bot.Y;
+ while (lm != m_MinimaList.end())
+ {
+ result.bottom = std::max(result.bottom, lm->LeftBound->Bot.Y);
+ TEdge* e = lm->LeftBound;
+ for (;;) {
+ TEdge* bottomE = e;
+ while (e->NextInLML)
+ {
+ if (e->Bot.X < result.left) result.left = e->Bot.X;
+ if (e->Bot.X > result.right) result.right = e->Bot.X;
+ e = e->NextInLML;
+ }
+ result.left = std::min(result.left, e->Bot.X);
+ result.right = std::max(result.right, e->Bot.X);
+ result.left = std::min(result.left, e->Top.X);
+ result.right = std::max(result.right, e->Top.X);
+ result.top = std::min(result.top, e->Top.Y);
+ if (bottomE == lm->LeftBound) e = lm->RightBound;
+ else break;
+ }
+ ++lm;
+ }
+ return result;
+}
+
+//------------------------------------------------------------------------------
+// TClipper methods ...
+//------------------------------------------------------------------------------
+
+Clipper::Clipper(int initOptions) : ClipperBase() //constructor
+{
+ m_ActiveEdges = 0;
+ m_SortedEdges = 0;
+ m_ExecuteLocked = false;
+ m_UseFullRange = false;
+ m_ReverseOutput = ((initOptions & ioReverseSolution) != 0);
+ m_StrictSimple = ((initOptions & ioStrictlySimple) != 0);
+ m_PreserveCollinear = ((initOptions & ioPreserveCollinear) != 0);
+ m_HasOpenPaths = false;
+#ifdef use_xyz
+ m_ZFill = 0;
+#endif
+}
+//------------------------------------------------------------------------------
+
+Clipper::~Clipper() //destructor
+{
+ Clear();
+}
+//------------------------------------------------------------------------------
+
+#ifdef use_xyz
+void Clipper::ZFillFunction(TZFillCallback zFillFunc)
+{
+ m_ZFill = zFillFunc;
+}
+//------------------------------------------------------------------------------
+#endif
+
+void Clipper::Reset()
+{
+ ClipperBase::Reset();
+ m_Scanbeam = ScanbeamList();
+ m_ActiveEdges = 0;
+ m_SortedEdges = 0;
+ for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm)
+ InsertScanbeam(lm->Y);
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::Execute(ClipType clipType, Paths &solution,
+ PolyFillType subjFillType, PolyFillType clipFillType)
+{
+ if( m_ExecuteLocked ) return false;
+ if (m_HasOpenPaths)
+ throw clipperException("Error: PolyTree struct is need for open path clipping.");
+ m_ExecuteLocked = true;
+ solution.resize(0);
+ m_SubjFillType = subjFillType;
+ m_ClipFillType = clipFillType;
+ m_ClipType = clipType;
+ m_UsingPolyTree = false;
+ bool succeeded = ExecuteInternal();
+ if (succeeded) BuildResult(solution);
+ DisposeAllOutRecs();
+ m_ExecuteLocked = false;
+ return succeeded;
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
+ PolyFillType subjFillType, PolyFillType clipFillType)
+{
+ if( m_ExecuteLocked ) return false;
+ m_ExecuteLocked = true;
+ m_SubjFillType = subjFillType;
+ m_ClipFillType = clipFillType;
+ m_ClipType = clipType;
+ m_UsingPolyTree = true;
+ bool succeeded = ExecuteInternal();
+ if (succeeded) BuildResult2(polytree);
+ DisposeAllOutRecs();
+ m_ExecuteLocked = false;
+ return succeeded;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::FixHoleLinkage(OutRec &outrec)
+{
+ //skip OutRecs that (a) contain outermost polygons or
+ //(b) already have the correct owner/child linkage ...
+ if (!outrec.FirstLeft ||
+ (outrec.IsHole != outrec.FirstLeft->IsHole &&
+ outrec.FirstLeft->Pts)) return;
+
+ OutRec* orfl = outrec.FirstLeft;
+ while (orfl && ((orfl->IsHole == outrec.IsHole) || !orfl->Pts))
+ orfl = orfl->FirstLeft;
+ outrec.FirstLeft = orfl;
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::ExecuteInternal()
+{
+ bool succeeded = true;
+ try {
+ Reset();
+ if (m_CurrentLM == m_MinimaList.end()) return true;
+ cInt botY = PopScanbeam();
+ do {
+ InsertLocalMinimaIntoAEL(botY);
+ ClearGhostJoins();
+ ProcessHorizontals(false);
+ if (m_Scanbeam.empty()) break;
+ cInt topY = PopScanbeam();
+ succeeded = ProcessIntersections(botY, topY);
+ if (!succeeded) break;
+ ProcessEdgesAtTopOfScanbeam(topY);
+ botY = topY;
+ } while (!m_Scanbeam.empty() || m_CurrentLM != m_MinimaList.end());
+ }
+ catch(...)
+ {
+ succeeded = false;
+ }
+
+ if (succeeded)
+ {
+ //fix orientations ...
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ {
+ OutRec *outRec = m_PolyOuts[i];
+ if (!outRec->Pts || outRec->IsOpen) continue;
+ if ((outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0))
+ ReversePolyPtLinks(outRec->Pts);
+ }
+
+ if (!m_Joins.empty()) JoinCommonEdges();
+
+ //unfortunately FixupOutPolygon() must be done after JoinCommonEdges()
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ {
+ OutRec *outRec = m_PolyOuts[i];
+ if (outRec->Pts && !outRec->IsOpen)
+ FixupOutPolygon(*outRec);
+ }
+
+ if (m_StrictSimple) DoSimplePolygons();
+ }
+
+ ClearJoins();
+ ClearGhostJoins();
+ return succeeded;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::InsertScanbeam(const cInt Y)
+{
+ //if (!m_Scanbeam.empty() && Y == m_Scanbeam.top()) return;// avoid duplicates.
+ m_Scanbeam.push(Y);
+}
+//------------------------------------------------------------------------------
+
+cInt Clipper::PopScanbeam()
+{
+ const cInt Y = m_Scanbeam.top();
+ m_Scanbeam.pop();
+ while (!m_Scanbeam.empty() && Y == m_Scanbeam.top()) { m_Scanbeam.pop(); } // Pop duplicates.
+ return Y;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DisposeAllOutRecs(){
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ DisposeOutRec(i);
+ m_PolyOuts.clear();
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DisposeOutRec(PolyOutList::size_type index)
+{
+ OutRec *outRec = m_PolyOuts[index];
+ if (outRec->Pts) DisposeOutPts(outRec->Pts);
+ delete outRec;
+ m_PolyOuts[index] = 0;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::SetWindingCount(TEdge &edge)
+{
+ TEdge *e = edge.PrevInAEL;
+ //find the edge of the same polytype that immediately preceeds 'edge' in AEL
+ while (e && ((e->PolyTyp != edge.PolyTyp) || (e->WindDelta == 0))) e = e->PrevInAEL;
+ if (!e)
+ {
+ edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta);
+ edge.WindCnt2 = 0;
+ e = m_ActiveEdges; //ie get ready to calc WindCnt2
+ }
+ else if (edge.WindDelta == 0 && m_ClipType != ctUnion)
+ {
+ edge.WindCnt = 1;
+ edge.WindCnt2 = e->WindCnt2;
+ e = e->NextInAEL; //ie get ready to calc WindCnt2
+ }
+ else if (IsEvenOddFillType(edge))
+ {
+ //EvenOdd filling ...
+ if (edge.WindDelta == 0)
+ {
+ //are we inside a subj polygon ...
+ bool Inside = true;
+ TEdge *e2 = e->PrevInAEL;
+ while (e2)
+ {
+ if (e2->PolyTyp == e->PolyTyp && e2->WindDelta != 0)
+ Inside = !Inside;
+ e2 = e2->PrevInAEL;
+ }
+ edge.WindCnt = (Inside ? 0 : 1);
+ }
+ else
+ {
+ edge.WindCnt = edge.WindDelta;
+ }
+ edge.WindCnt2 = e->WindCnt2;
+ e = e->NextInAEL; //ie get ready to calc WindCnt2
+ }
+ else
+ {
+ //nonZero, Positive or Negative filling ...
+ if (e->WindCnt * e->WindDelta < 0)
+ {
+ //prev edge is 'decreasing' WindCount (WC) toward zero
+ //so we're outside the previous polygon ...
+ if (Abs(e->WindCnt) > 1)
+ {
+ //outside prev poly but still inside another.
+ //when reversing direction of prev poly use the same WC
+ if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
+ //otherwise continue to 'decrease' WC ...
+ else edge.WindCnt = e->WindCnt + edge.WindDelta;
+ }
+ else
+ //now outside all polys of same polytype so set own WC ...
+ edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta);
+ } else
+ {
+ //prev edge is 'increasing' WindCount (WC) away from zero
+ //so we're inside the previous polygon ...
+ if (edge.WindDelta == 0)
+ edge.WindCnt = (e->WindCnt < 0 ? e->WindCnt - 1 : e->WindCnt + 1);
+ //if wind direction is reversing prev then use same WC
+ else if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
+ //otherwise add to WC ...
+ else edge.WindCnt = e->WindCnt + edge.WindDelta;
+ }
+ edge.WindCnt2 = e->WindCnt2;
+ e = e->NextInAEL; //ie get ready to calc WindCnt2
+ }
+
+ //update WindCnt2 ...
+ if (IsEvenOddAltFillType(edge))
+ {
+ //EvenOdd filling ...
+ while (e != &edge)
+ {
+ if (e->WindDelta != 0)
+ edge.WindCnt2 = (edge.WindCnt2 == 0 ? 1 : 0);
+ e = e->NextInAEL;
+ }
+ } else
+ {
+ //nonZero, Positive or Negative filling ...
+ while ( e != &edge )
+ {
+ edge.WindCnt2 += e->WindDelta;
+ e = e->NextInAEL;
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::IsEvenOddFillType(const TEdge& edge) const
+{
+ if (edge.PolyTyp == ptSubject)
+ return m_SubjFillType == pftEvenOdd; else
+ return m_ClipFillType == pftEvenOdd;
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::IsEvenOddAltFillType(const TEdge& edge) const
+{
+ if (edge.PolyTyp == ptSubject)
+ return m_ClipFillType == pftEvenOdd; else
+ return m_SubjFillType == pftEvenOdd;
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::IsContributing(const TEdge& edge) const
+{
+ PolyFillType pft, pft2;
+ if (edge.PolyTyp == ptSubject)
+ {
+ pft = m_SubjFillType;
+ pft2 = m_ClipFillType;
+ } else
+ {
+ pft = m_ClipFillType;
+ pft2 = m_SubjFillType;
+ }
+
+ switch(pft)
+ {
+ case pftEvenOdd:
+ //return false if a subj line has been flagged as inside a subj polygon
+ if (edge.WindDelta == 0 && edge.WindCnt != 1) return false;
+ break;
+ case pftNonZero:
+ if (Abs(edge.WindCnt) != 1) return false;
+ break;
+ case pftPositive:
+ if (edge.WindCnt != 1) return false;
+ break;
+ default: //pftNegative
+ if (edge.WindCnt != -1) return false;
+ }
+
+ switch(m_ClipType)
+ {
+ case ctIntersection:
+ switch(pft2)
+ {
+ case pftEvenOdd:
+ case pftNonZero:
+ return (edge.WindCnt2 != 0);
+ case pftPositive:
+ return (edge.WindCnt2 > 0);
+ default:
+ return (edge.WindCnt2 < 0);
+ }
+ break;
+ case ctUnion:
+ switch(pft2)
+ {
+ case pftEvenOdd:
+ case pftNonZero:
+ return (edge.WindCnt2 == 0);
+ case pftPositive:
+ return (edge.WindCnt2 <= 0);
+ default:
+ return (edge.WindCnt2 >= 0);
+ }
+ break;
+ case ctDifference:
+ if (edge.PolyTyp == ptSubject)
+ switch(pft2)
+ {
+ case pftEvenOdd:
+ case pftNonZero:
+ return (edge.WindCnt2 == 0);
+ case pftPositive:
+ return (edge.WindCnt2 <= 0);
+ default:
+ return (edge.WindCnt2 >= 0);
+ }
+ else
+ switch(pft2)
+ {
+ case pftEvenOdd:
+ case pftNonZero:
+ return (edge.WindCnt2 != 0);
+ case pftPositive:
+ return (edge.WindCnt2 > 0);
+ default:
+ return (edge.WindCnt2 < 0);
+ }
+ break;
+ case ctXor:
+ if (edge.WindDelta == 0) //XOr always contributing unless open
+ switch(pft2)
+ {
+ case pftEvenOdd:
+ case pftNonZero:
+ return (edge.WindCnt2 == 0);
+ case pftPositive:
+ return (edge.WindCnt2 <= 0);
+ default:
+ return (edge.WindCnt2 >= 0);
+ }
+ else
+ return true;
+ break;
+ default:
+ return true;
+ }
+}
+//------------------------------------------------------------------------------
+
+OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
+{
+ OutPt* result;
+ TEdge *e, *prevE;
+ if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx ))
+ {
+ result = AddOutPt(e1, Pt);
+ e2->OutIdx = e1->OutIdx;
+ e1->Side = esLeft;
+ e2->Side = esRight;
+ e = e1;
+ if (e->PrevInAEL == e2)
+ prevE = e2->PrevInAEL;
+ else
+ prevE = e->PrevInAEL;
+ } else
+ {
+ result = AddOutPt(e2, Pt);
+ e1->OutIdx = e2->OutIdx;
+ e1->Side = esRight;
+ e2->Side = esLeft;
+ e = e2;
+ if (e->PrevInAEL == e1)
+ prevE = e1->PrevInAEL;
+ else
+ prevE = e->PrevInAEL;
+ }
+
+ if (prevE && prevE->OutIdx >= 0 &&
+ (TopX(*prevE, Pt.Y) == TopX(*e, Pt.Y)) &&
+ SlopesEqual(*e, *prevE, m_UseFullRange) &&
+ (e->WindDelta != 0) && (prevE->WindDelta != 0))
+ {
+ OutPt* outPt = AddOutPt(prevE, Pt);
+ AddJoin(result, outPt, e->Top);
+ }
+ return result;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
+{
+ AddOutPt( e1, Pt );
+ if (e2->WindDelta == 0) AddOutPt(e2, Pt);
+ if( e1->OutIdx == e2->OutIdx )
+ {
+ e1->OutIdx = Unassigned;
+ e2->OutIdx = Unassigned;
+ }
+ else if (e1->OutIdx < e2->OutIdx)
+ AppendPolygon(e1, e2);
+ else
+ AppendPolygon(e2, e1);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::AddEdgeToSEL(TEdge *edge)
+{
+ //SEL pointers in PEdge are reused to build a list of horizontal edges.
+ //However, we don't need to worry about order with horizontal edge processing.
+ if( !m_SortedEdges )
+ {
+ m_SortedEdges = edge;
+ edge->PrevInSEL = 0;
+ edge->NextInSEL = 0;
+ }
+ else
+ {
+ edge->NextInSEL = m_SortedEdges;
+ edge->PrevInSEL = 0;
+ m_SortedEdges->PrevInSEL = edge;
+ m_SortedEdges = edge;
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::CopyAELToSEL()
+{
+ TEdge* e = m_ActiveEdges;
+ m_SortedEdges = e;
+ while ( e )
+ {
+ e->PrevInSEL = e->PrevInAEL;
+ e->NextInSEL = e->NextInAEL;
+ e = e->NextInAEL;
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt)
+{
+ Join* j = new Join;
+ j->OutPt1 = op1;
+ j->OutPt2 = op2;
+ j->OffPt = OffPt;
+ m_Joins.push_back(j);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::ClearJoins()
+{
+ for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
+ delete m_Joins[i];
+ m_Joins.resize(0);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::ClearGhostJoins()
+{
+ for (JoinList::size_type i = 0; i < m_GhostJoins.size(); i++)
+ delete m_GhostJoins[i];
+ m_GhostJoins.resize(0);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt)
+{
+ Join* j = new Join;
+ j->OutPt1 = op;
+ j->OutPt2 = 0;
+ j->OffPt = OffPt;
+ m_GhostJoins.push_back(j);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::InsertLocalMinimaIntoAEL(const cInt botY)
+{
+ while (m_CurrentLM != m_MinimaList.end() && (m_CurrentLM->Y == botY))
+ {
+ TEdge* lb = m_CurrentLM->LeftBound;
+ TEdge* rb = m_CurrentLM->RightBound;
+ PopLocalMinima();
+ OutPt *Op1 = 0;
+ if (!lb)
+ {
+ //nb: don't insert LB into either AEL or SEL
+ InsertEdgeIntoAEL(rb, 0);
+ SetWindingCount(*rb);
+ if (IsContributing(*rb))
+ Op1 = AddOutPt(rb, rb->Bot);
+ }
+ else if (!rb)
+ {
+ InsertEdgeIntoAEL(lb, 0);
+ SetWindingCount(*lb);
+ if (IsContributing(*lb))
+ Op1 = AddOutPt(lb, lb->Bot);
+ InsertScanbeam(lb->Top.Y);
+ }
+ else
+ {
+ InsertEdgeIntoAEL(lb, 0);
+ InsertEdgeIntoAEL(rb, lb);
+ SetWindingCount( *lb );
+ rb->WindCnt = lb->WindCnt;
+ rb->WindCnt2 = lb->WindCnt2;
+ if (IsContributing(*lb))
+ Op1 = AddLocalMinPoly(lb, rb, lb->Bot);
+ InsertScanbeam(lb->Top.Y);
+ }
+
+ if (rb)
+ {
+ if(IsHorizontal(*rb)) AddEdgeToSEL(rb);
+ else InsertScanbeam( rb->Top.Y );
+ }
+
+ if (!lb || !rb) continue;
+
+ //if any output polygons share an edge, they'll need joining later ...
+ if (Op1 && IsHorizontal(*rb) &&
+ m_GhostJoins.size() > 0 && (rb->WindDelta != 0))
+ {
+ for (JoinList::size_type i = 0; i < m_GhostJoins.size(); ++i)
+ {
+ Join* jr = m_GhostJoins[i];
+ //if the horizontal Rb and a 'ghost' horizontal overlap, then convert
+ //the 'ghost' join to a real join ready for later ...
+ if (HorzSegmentsOverlap(jr->OutPt1->Pt.X, jr->OffPt.X, rb->Bot.X, rb->Top.X))
+ AddJoin(jr->OutPt1, Op1, jr->OffPt);
+ }
+ }
+
+ if (lb->OutIdx >= 0 && lb->PrevInAEL &&
+ lb->PrevInAEL->Curr.X == lb->Bot.X &&
+ lb->PrevInAEL->OutIdx >= 0 &&
+ SlopesEqual(*lb->PrevInAEL, *lb, m_UseFullRange) &&
+ (lb->WindDelta != 0) && (lb->PrevInAEL->WindDelta != 0))
+ {
+ OutPt *Op2 = AddOutPt(lb->PrevInAEL, lb->Bot);
+ AddJoin(Op1, Op2, lb->Top);
+ }
+
+ if(lb->NextInAEL != rb)
+ {
+
+ if (rb->OutIdx >= 0 && rb->PrevInAEL->OutIdx >= 0 &&
+ SlopesEqual(*rb->PrevInAEL, *rb, m_UseFullRange) &&
+ (rb->WindDelta != 0) && (rb->PrevInAEL->WindDelta != 0))
+ {
+ OutPt *Op2 = AddOutPt(rb->PrevInAEL, rb->Bot);
+ AddJoin(Op1, Op2, rb->Top);
+ }
+
+ TEdge* e = lb->NextInAEL;
+ if (e)
+ {
+ while( e != rb )
+ {
+ //nb: For calculating winding counts etc, IntersectEdges() assumes
+ //that param1 will be to the Right of param2 ABOVE the intersection ...
+ IntersectEdges(rb , e , lb->Curr); //order important here
+ e = e->NextInAEL;
+ }
+ }
+ }
+
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DeleteFromAEL(TEdge *e)
+{
+ TEdge* AelPrev = e->PrevInAEL;
+ TEdge* AelNext = e->NextInAEL;
+ if( !AelPrev && !AelNext && (e != m_ActiveEdges) ) return; //already deleted
+ if( AelPrev ) AelPrev->NextInAEL = AelNext;
+ else m_ActiveEdges = AelNext;
+ if( AelNext ) AelNext->PrevInAEL = AelPrev;
+ e->NextInAEL = 0;
+ e->PrevInAEL = 0;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DeleteFromSEL(TEdge *e)
+{
+ TEdge* SelPrev = e->PrevInSEL;
+ TEdge* SelNext = e->NextInSEL;
+ if( !SelPrev && !SelNext && (e != m_SortedEdges) ) return; //already deleted
+ if( SelPrev ) SelPrev->NextInSEL = SelNext;
+ else m_SortedEdges = SelNext;
+ if( SelNext ) SelNext->PrevInSEL = SelPrev;
+ e->NextInSEL = 0;
+ e->PrevInSEL = 0;
+}
+//------------------------------------------------------------------------------
+
+#ifdef use_xyz
+void Clipper::SetZ(IntPoint& pt, TEdge& e1, TEdge& e2)
+{
+ if (pt.Z != 0 || !m_ZFill) return;
+ else if (pt == e1.Bot) pt.Z = e1.Bot.Z;
+ else if (pt == e1.Top) pt.Z = e1.Top.Z;
+ else if (pt == e2.Bot) pt.Z = e2.Bot.Z;
+ else if (pt == e2.Top) pt.Z = e2.Top.Z;
+ else (*m_ZFill)(e1.Bot, e1.Top, e2.Bot, e2.Top, pt);
+}
+//------------------------------------------------------------------------------
+#endif
+
+void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &Pt)
+{
+ bool e1Contributing = ( e1->OutIdx >= 0 );
+ bool e2Contributing = ( e2->OutIdx >= 0 );
+
+#ifdef use_xyz
+ SetZ(Pt, *e1, *e2);
+#endif
+
+#ifdef use_lines
+ //if either edge is on an OPEN path ...
+ if (e1->WindDelta == 0 || e2->WindDelta == 0)
+ {
+ //ignore subject-subject open path intersections UNLESS they
+ //are both open paths, AND they are both 'contributing maximas' ...
+ if (e1->WindDelta == 0 && e2->WindDelta == 0) return;
+
+ //if intersecting a subj line with a subj poly ...
+ else if (e1->PolyTyp == e2->PolyTyp &&
+ e1->WindDelta != e2->WindDelta && m_ClipType == ctUnion)
+ {
+ if (e1->WindDelta == 0)
+ {
+ if (e2Contributing)
+ {
+ AddOutPt(e1, Pt);
+ if (e1Contributing) e1->OutIdx = Unassigned;
+ }
+ }
+ else
+ {
+ if (e1Contributing)
+ {
+ AddOutPt(e2, Pt);
+ if (e2Contributing) e2->OutIdx = Unassigned;
+ }
+ }
+ }
+ else if (e1->PolyTyp != e2->PolyTyp)
+ {
+ //toggle subj open path OutIdx on/off when Abs(clip.WndCnt) == 1 ...
+ if ((e1->WindDelta == 0) && abs(e2->WindCnt) == 1 &&
+ (m_ClipType != ctUnion || e2->WindCnt2 == 0))
+ {
+ AddOutPt(e1, Pt);
+ if (e1Contributing) e1->OutIdx = Unassigned;
+ }
+ else if ((e2->WindDelta == 0) && (abs(e1->WindCnt) == 1) &&
+ (m_ClipType != ctUnion || e1->WindCnt2 == 0))
+ {
+ AddOutPt(e2, Pt);
+ if (e2Contributing) e2->OutIdx = Unassigned;
+ }
+ }
+ return;
+ }
+#endif
+
+ //update winding counts...
+ //assumes that e1 will be to the Right of e2 ABOVE the intersection
+ if ( e1->PolyTyp == e2->PolyTyp )
+ {
+ if ( IsEvenOddFillType( *e1) )
+ {
+ int oldE1WindCnt = e1->WindCnt;
+ e1->WindCnt = e2->WindCnt;
+ e2->WindCnt = oldE1WindCnt;
+ } else
+ {
+ if (e1->WindCnt + e2->WindDelta == 0 ) e1->WindCnt = -e1->WindCnt;
+ else e1->WindCnt += e2->WindDelta;
+ if ( e2->WindCnt - e1->WindDelta == 0 ) e2->WindCnt = -e2->WindCnt;
+ else e2->WindCnt -= e1->WindDelta;
+ }
+ } else
+ {
+ if (!IsEvenOddFillType(*e2)) e1->WindCnt2 += e2->WindDelta;
+ else e1->WindCnt2 = ( e1->WindCnt2 == 0 ) ? 1 : 0;
+ if (!IsEvenOddFillType(*e1)) e2->WindCnt2 -= e1->WindDelta;
+ else e2->WindCnt2 = ( e2->WindCnt2 == 0 ) ? 1 : 0;
+ }
+
+ PolyFillType e1FillType, e2FillType, e1FillType2, e2FillType2;
+ if (e1->PolyTyp == ptSubject)
+ {
+ e1FillType = m_SubjFillType;
+ e1FillType2 = m_ClipFillType;
+ } else
+ {
+ e1FillType = m_ClipFillType;
+ e1FillType2 = m_SubjFillType;
+ }
+ if (e2->PolyTyp == ptSubject)
+ {
+ e2FillType = m_SubjFillType;
+ e2FillType2 = m_ClipFillType;
+ } else
+ {
+ e2FillType = m_ClipFillType;
+ e2FillType2 = m_SubjFillType;
+ }
+
+ cInt e1Wc, e2Wc;
+ switch (e1FillType)
+ {
+ case pftPositive: e1Wc = e1->WindCnt; break;
+ case pftNegative: e1Wc = -e1->WindCnt; break;
+ default: e1Wc = Abs(e1->WindCnt);
+ }
+ switch(e2FillType)
+ {
+ case pftPositive: e2Wc = e2->WindCnt; break;
+ case pftNegative: e2Wc = -e2->WindCnt; break;
+ default: e2Wc = Abs(e2->WindCnt);
+ }
+
+ if ( e1Contributing && e2Contributing )
+ {
+ if ((e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) ||
+ (e1->PolyTyp != e2->PolyTyp && m_ClipType != ctXor) )
+ {
+ AddLocalMaxPoly(e1, e2, Pt);
+ }
+ else
+ {
+ AddOutPt(e1, Pt);
+ AddOutPt(e2, Pt);
+ SwapSides( *e1 , *e2 );
+ SwapPolyIndexes( *e1 , *e2 );
+ }
+ }
+ else if ( e1Contributing )
+ {
+ if (e2Wc == 0 || e2Wc == 1)
+ {
+ AddOutPt(e1, Pt);
+ SwapSides(*e1, *e2);
+ SwapPolyIndexes(*e1, *e2);
+ }
+ }
+ else if ( e2Contributing )
+ {
+ if (e1Wc == 0 || e1Wc == 1)
+ {
+ AddOutPt(e2, Pt);
+ SwapSides(*e1, *e2);
+ SwapPolyIndexes(*e1, *e2);
+ }
+ }
+ else if ( (e1Wc == 0 || e1Wc == 1) && (e2Wc == 0 || e2Wc == 1))
+ {
+ //neither edge is currently contributing ...
+
+ cInt e1Wc2, e2Wc2;
+ switch (e1FillType2)
+ {
+ case pftPositive: e1Wc2 = e1->WindCnt2; break;
+ case pftNegative : e1Wc2 = -e1->WindCnt2; break;
+ default: e1Wc2 = Abs(e1->WindCnt2);
+ }
+ switch (e2FillType2)
+ {
+ case pftPositive: e2Wc2 = e2->WindCnt2; break;
+ case pftNegative: e2Wc2 = -e2->WindCnt2; break;
+ default: e2Wc2 = Abs(e2->WindCnt2);
+ }
+
+ if (e1->PolyTyp != e2->PolyTyp)
+ {
+ AddLocalMinPoly(e1, e2, Pt);
+ }
+ else if (e1Wc == 1 && e2Wc == 1)
+ switch( m_ClipType ) {
+ case ctIntersection:
+ if (e1Wc2 > 0 && e2Wc2 > 0)
+ AddLocalMinPoly(e1, e2, Pt);
+ break;
+ case ctUnion:
+ if ( e1Wc2 <= 0 && e2Wc2 <= 0 )
+ AddLocalMinPoly(e1, e2, Pt);
+ break;
+ case ctDifference:
+ if (((e1->PolyTyp == ptClip) && (e1Wc2 > 0) && (e2Wc2 > 0)) ||
+ ((e1->PolyTyp == ptSubject) && (e1Wc2 <= 0) && (e2Wc2 <= 0)))
+ AddLocalMinPoly(e1, e2, Pt);
+ break;
+ case ctXor:
+ AddLocalMinPoly(e1, e2, Pt);
+ }
+ else
+ SwapSides( *e1, *e2 );
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::SetHoleState(TEdge *e, OutRec *outrec)
+{
+ bool IsHole = false;
+ TEdge *e2 = e->PrevInAEL;
+ while (e2)
+ {
+ if (e2->OutIdx >= 0 && e2->WindDelta != 0)
+ {
+ IsHole = !IsHole;
+ if (! outrec->FirstLeft)
+ outrec->FirstLeft = m_PolyOuts[e2->OutIdx];
+ }
+ e2 = e2->PrevInAEL;
+ }
+ if (IsHole) outrec->IsHole = true;
+}
+//------------------------------------------------------------------------------
+
+OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2)
+{
+ //work out which polygon fragment has the correct hole state ...
+ if (!outRec1->BottomPt)
+ outRec1->BottomPt = GetBottomPt(outRec1->Pts);
+ if (!outRec2->BottomPt)
+ outRec2->BottomPt = GetBottomPt(outRec2->Pts);
+ OutPt *OutPt1 = outRec1->BottomPt;
+ OutPt *OutPt2 = outRec2->BottomPt;
+ if (OutPt1->Pt.Y > OutPt2->Pt.Y) return outRec1;
+ else if (OutPt1->Pt.Y < OutPt2->Pt.Y) return outRec2;
+ else if (OutPt1->Pt.X < OutPt2->Pt.X) return outRec1;
+ else if (OutPt1->Pt.X > OutPt2->Pt.X) return outRec2;
+ else if (OutPt1->Next == OutPt1) return outRec2;
+ else if (OutPt2->Next == OutPt2) return outRec1;
+ else if (FirstIsBottomPt(OutPt1, OutPt2)) return outRec1;
+ else return outRec2;
+}
+//------------------------------------------------------------------------------
+
+bool Param1RightOfParam2(OutRec* outRec1, OutRec* outRec2)
+{
+ do
+ {
+ outRec1 = outRec1->FirstLeft;
+ if (outRec1 == outRec2) return true;
+ } while (outRec1);
+ return false;
+}
+//------------------------------------------------------------------------------
+
+OutRec* Clipper::GetOutRec(int Idx)
+{
+ OutRec* outrec = m_PolyOuts[Idx];
+ while (outrec != m_PolyOuts[outrec->Idx])
+ outrec = m_PolyOuts[outrec->Idx];
+ return outrec;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
+{
+ //get the start and ends of both output polygons ...
+ OutRec *outRec1 = m_PolyOuts[e1->OutIdx];
+ OutRec *outRec2 = m_PolyOuts[e2->OutIdx];
+
+ OutRec *holeStateRec;
+ if (Param1RightOfParam2(outRec1, outRec2))
+ holeStateRec = outRec2;
+ else if (Param1RightOfParam2(outRec2, outRec1))
+ holeStateRec = outRec1;
+ else
+ holeStateRec = GetLowermostRec(outRec1, outRec2);
+
+ //get the start and ends of both output polygons and
+ //join e2 poly onto e1 poly and delete pointers to e2 ...
+
+ OutPt* p1_lft = outRec1->Pts;
+ OutPt* p1_rt = p1_lft->Prev;
+ OutPt* p2_lft = outRec2->Pts;
+ OutPt* p2_rt = p2_lft->Prev;
+
+ EdgeSide Side;
+ //join e2 poly onto e1 poly and delete pointers to e2 ...
+ if( e1->Side == esLeft )
+ {
+ if( e2->Side == esLeft )
+ {
+ //z y x a b c
+ ReversePolyPtLinks(p2_lft);
+ p2_lft->Next = p1_lft;
+ p1_lft->Prev = p2_lft;
+ p1_rt->Next = p2_rt;
+ p2_rt->Prev = p1_rt;
+ outRec1->Pts = p2_rt;
+ } else
+ {
+ //x y z a b c
+ p2_rt->Next = p1_lft;
+ p1_lft->Prev = p2_rt;
+ p2_lft->Prev = p1_rt;
+ p1_rt->Next = p2_lft;
+ outRec1->Pts = p2_lft;
+ }
+ Side = esLeft;
+ } else
+ {
+ if( e2->Side == esRight )
+ {
+ //a b c z y x
+ ReversePolyPtLinks(p2_lft);
+ p1_rt->Next = p2_rt;
+ p2_rt->Prev = p1_rt;
+ p2_lft->Next = p1_lft;
+ p1_lft->Prev = p2_lft;
+ } else
+ {
+ //a b c x y z
+ p1_rt->Next = p2_lft;
+ p2_lft->Prev = p1_rt;
+ p1_lft->Prev = p2_rt;
+ p2_rt->Next = p1_lft;
+ }
+ Side = esRight;
+ }
+
+ outRec1->BottomPt = 0;
+ if (holeStateRec == outRec2)
+ {
+ if (outRec2->FirstLeft != outRec1)
+ outRec1->FirstLeft = outRec2->FirstLeft;
+ outRec1->IsHole = outRec2->IsHole;
+ }
+ outRec2->Pts = 0;
+ outRec2->BottomPt = 0;
+ outRec2->FirstLeft = outRec1;
+
+ int OKIdx = e1->OutIdx;
+ int ObsoleteIdx = e2->OutIdx;
+
+ e1->OutIdx = Unassigned; //nb: safe because we only get here via AddLocalMaxPoly
+ e2->OutIdx = Unassigned;
+
+ TEdge* e = m_ActiveEdges;
+ while( e )
+ {
+ if( e->OutIdx == ObsoleteIdx )
+ {
+ e->OutIdx = OKIdx;
+ e->Side = Side;
+ break;
+ }
+ e = e->NextInAEL;
+ }
+
+ outRec2->Idx = outRec1->Idx;
+}
+//------------------------------------------------------------------------------
+
+OutRec* Clipper::CreateOutRec()
+{
+ OutRec* result = new OutRec;
+ result->IsHole = false;
+ result->IsOpen = false;
+ result->FirstLeft = 0;
+ result->Pts = 0;
+ result->BottomPt = 0;
+ result->PolyNd = 0;
+ m_PolyOuts.push_back(result);
+ result->Idx = (int)m_PolyOuts.size()-1;
+ return result;
+}
+//------------------------------------------------------------------------------
+
+OutPt* Clipper::AddOutPt(TEdge *e, const IntPoint &pt)
+{
+ bool ToFront = (e->Side == esLeft);
+ if( e->OutIdx < 0 )
+ {
+ OutRec *outRec = CreateOutRec();
+ outRec->IsOpen = (e->WindDelta == 0);
+ OutPt* newOp = new OutPt;
+ outRec->Pts = newOp;
+ newOp->Idx = outRec->Idx;
+ newOp->Pt = pt;
+ newOp->Next = newOp;
+ newOp->Prev = newOp;
+ if (!outRec->IsOpen)
+ SetHoleState(e, outRec);
+ e->OutIdx = outRec->Idx;
+ return newOp;
+ } else
+ {
+ OutRec *outRec = m_PolyOuts[e->OutIdx];
+ //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
+ OutPt* op = outRec->Pts;
+
+ if (ToFront && (pt == op->Pt)) return op;
+ else if (!ToFront && (pt == op->Prev->Pt)) return op->Prev;
+
+ OutPt* newOp = new OutPt;
+ newOp->Idx = outRec->Idx;
+ newOp->Pt = pt;
+ newOp->Next = op;
+ newOp->Prev = op->Prev;
+ newOp->Prev->Next = newOp;
+ op->Prev = newOp;
+ if (ToFront) outRec->Pts = newOp;
+ return newOp;
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::ProcessHorizontals(bool IsTopOfScanbeam)
+{
+ TEdge* horzEdge = m_SortedEdges;
+ while(horzEdge)
+ {
+ DeleteFromSEL(horzEdge);
+ ProcessHorizontal(horzEdge, IsTopOfScanbeam);
+ horzEdge = m_SortedEdges;
+ }
+}
+//------------------------------------------------------------------------------
+
+inline bool IsMinima(TEdge *e)
+{
+ return e && (e->Prev->NextInLML != e) && (e->Next->NextInLML != e);
+}
+//------------------------------------------------------------------------------
+
+inline bool IsMaxima(TEdge *e, const cInt Y)
+{
+ return e && e->Top.Y == Y && !e->NextInLML;
+}
+//------------------------------------------------------------------------------
+
+inline bool IsIntermediate(TEdge *e, const cInt Y)
+{
+ return e->Top.Y == Y && e->NextInLML;
+}
+//------------------------------------------------------------------------------
+
+TEdge *GetMaximaPair(TEdge *e)
+{
+ TEdge* result = 0;
+ if ((e->Next->Top == e->Top) && !e->Next->NextInLML)
+ result = e->Next;
+ else if ((e->Prev->Top == e->Top) && !e->Prev->NextInLML)
+ result = e->Prev;
+
+ if (result && (result->OutIdx == Skip ||
+ //result is false if both NextInAEL & PrevInAEL are nil & not horizontal ...
+ (result->NextInAEL == result->PrevInAEL && !IsHorizontal(*result))))
+ return 0;
+ return result;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::SwapPositionsInAEL(TEdge *Edge1, TEdge *Edge2)
+{
+ //check that one or other edge hasn't already been removed from AEL ...
+ if (Edge1->NextInAEL == Edge1->PrevInAEL ||
+ Edge2->NextInAEL == Edge2->PrevInAEL) return;
+
+ if( Edge1->NextInAEL == Edge2 )
+ {
+ TEdge* Next = Edge2->NextInAEL;
+ if( Next ) Next->PrevInAEL = Edge1;
+ TEdge* Prev = Edge1->PrevInAEL;
+ if( Prev ) Prev->NextInAEL = Edge2;
+ Edge2->PrevInAEL = Prev;
+ Edge2->NextInAEL = Edge1;
+ Edge1->PrevInAEL = Edge2;
+ Edge1->NextInAEL = Next;
+ }
+ else if( Edge2->NextInAEL == Edge1 )
+ {
+ TEdge* Next = Edge1->NextInAEL;
+ if( Next ) Next->PrevInAEL = Edge2;
+ TEdge* Prev = Edge2->PrevInAEL;
+ if( Prev ) Prev->NextInAEL = Edge1;
+ Edge1->PrevInAEL = Prev;
+ Edge1->NextInAEL = Edge2;
+ Edge2->PrevInAEL = Edge1;
+ Edge2->NextInAEL = Next;
+ }
+ else
+ {
+ TEdge* Next = Edge1->NextInAEL;
+ TEdge* Prev = Edge1->PrevInAEL;
+ Edge1->NextInAEL = Edge2->NextInAEL;
+ if( Edge1->NextInAEL ) Edge1->NextInAEL->PrevInAEL = Edge1;
+ Edge1->PrevInAEL = Edge2->PrevInAEL;
+ if( Edge1->PrevInAEL ) Edge1->PrevInAEL->NextInAEL = Edge1;
+ Edge2->NextInAEL = Next;
+ if( Edge2->NextInAEL ) Edge2->NextInAEL->PrevInAEL = Edge2;
+ Edge2->PrevInAEL = Prev;
+ if( Edge2->PrevInAEL ) Edge2->PrevInAEL->NextInAEL = Edge2;
+ }
+
+ if( !Edge1->PrevInAEL ) m_ActiveEdges = Edge1;
+ else if( !Edge2->PrevInAEL ) m_ActiveEdges = Edge2;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2)
+{
+ if( !( Edge1->NextInSEL ) && !( Edge1->PrevInSEL ) ) return;
+ if( !( Edge2->NextInSEL ) && !( Edge2->PrevInSEL ) ) return;
+
+ if( Edge1->NextInSEL == Edge2 )
+ {
+ TEdge* Next = Edge2->NextInSEL;
+ if( Next ) Next->PrevInSEL = Edge1;
+ TEdge* Prev = Edge1->PrevInSEL;
+ if( Prev ) Prev->NextInSEL = Edge2;
+ Edge2->PrevInSEL = Prev;
+ Edge2->NextInSEL = Edge1;
+ Edge1->PrevInSEL = Edge2;
+ Edge1->NextInSEL = Next;
+ }
+ else if( Edge2->NextInSEL == Edge1 )
+ {
+ TEdge* Next = Edge1->NextInSEL;
+ if( Next ) Next->PrevInSEL = Edge2;
+ TEdge* Prev = Edge2->PrevInSEL;
+ if( Prev ) Prev->NextInSEL = Edge1;
+ Edge1->PrevInSEL = Prev;
+ Edge1->NextInSEL = Edge2;
+ Edge2->PrevInSEL = Edge1;
+ Edge2->NextInSEL = Next;
+ }
+ else
+ {
+ TEdge* Next = Edge1->NextInSEL;
+ TEdge* Prev = Edge1->PrevInSEL;
+ Edge1->NextInSEL = Edge2->NextInSEL;
+ if( Edge1->NextInSEL ) Edge1->NextInSEL->PrevInSEL = Edge1;
+ Edge1->PrevInSEL = Edge2->PrevInSEL;
+ if( Edge1->PrevInSEL ) Edge1->PrevInSEL->NextInSEL = Edge1;
+ Edge2->NextInSEL = Next;
+ if( Edge2->NextInSEL ) Edge2->NextInSEL->PrevInSEL = Edge2;
+ Edge2->PrevInSEL = Prev;
+ if( Edge2->PrevInSEL ) Edge2->PrevInSEL->NextInSEL = Edge2;
+ }
+
+ if( !Edge1->PrevInSEL ) m_SortedEdges = Edge1;
+ else if( !Edge2->PrevInSEL ) m_SortedEdges = Edge2;
+}
+//------------------------------------------------------------------------------
+
+TEdge* GetNextInAEL(TEdge *e, Direction dir)
+{
+ return dir == dLeftToRight ? e->NextInAEL : e->PrevInAEL;
+}
+//------------------------------------------------------------------------------
+
+void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right)
+{
+ if (HorzEdge.Bot.X < HorzEdge.Top.X)
+ {
+ Left = HorzEdge.Bot.X;
+ Right = HorzEdge.Top.X;
+ Dir = dLeftToRight;
+ } else
+ {
+ Left = HorzEdge.Top.X;
+ Right = HorzEdge.Bot.X;
+ Dir = dRightToLeft;
+ }
+}
+//------------------------------------------------------------------------
+
+/*******************************************************************************
+* Notes: Horizontal edges (HEs) at scanline intersections (ie at the Top or *
+* Bottom of a scanbeam) are processed as if layered. The order in which HEs *
+* are processed doesn't matter. HEs intersect with other HE Bot.Xs only [#] *
+* (or they could intersect with Top.Xs only, ie EITHER Bot.Xs OR Top.Xs), *
+* and with other non-horizontal edges [*]. Once these intersections are *
+* processed, intermediate HEs then 'promote' the Edge above (NextInLML) into *
+* the AEL. These 'promoted' edges may in turn intersect [%] with other HEs. *
+*******************************************************************************/
+
+void Clipper::ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam)
+{
+ Direction dir;
+ cInt horzLeft, horzRight;
+
+ GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
+
+ TEdge* eLastHorz = horzEdge, *eMaxPair = 0;
+ while (eLastHorz->NextInLML && IsHorizontal(*eLastHorz->NextInLML))
+ eLastHorz = eLastHorz->NextInLML;
+ if (!eLastHorz->NextInLML)
+ eMaxPair = GetMaximaPair(eLastHorz);
+
+ for (;;)
+ {
+ bool IsLastHorz = (horzEdge == eLastHorz);
+ TEdge* e = GetNextInAEL(horzEdge, dir);
+ while(e)
+ {
+ //Break if we've got to the end of an intermediate horizontal edge ...
+ //nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal.
+ if (e->Curr.X == horzEdge->Top.X && horzEdge->NextInLML &&
+ e->Dx < horzEdge->NextInLML->Dx) break;
+
+ TEdge* eNext = GetNextInAEL(e, dir); //saves eNext for later
+
+ if ((dir == dLeftToRight && e->Curr.X <= horzRight) ||
+ (dir == dRightToLeft && e->Curr.X >= horzLeft))
+ {
+ //so far we're still in range of the horizontal Edge but make sure
+ //we're at the last of consec. horizontals when matching with eMaxPair
+ if(e == eMaxPair && IsLastHorz)
+ {
+
+ if (horzEdge->OutIdx >= 0)
+ {
+ OutPt* op1 = AddOutPt(horzEdge, horzEdge->Top);
+ TEdge* eNextHorz = m_SortedEdges;
+ while (eNextHorz)
+ {
+ if (eNextHorz->OutIdx >= 0 &&
+ HorzSegmentsOverlap(horzEdge->Bot.X,
+ horzEdge->Top.X, eNextHorz->Bot.X, eNextHorz->Top.X))
+ {
+ OutPt* op2 = AddOutPt(eNextHorz, eNextHorz->Bot);
+ AddJoin(op2, op1, eNextHorz->Top);
+ }
+ eNextHorz = eNextHorz->NextInSEL;
+ }
+ AddGhostJoin(op1, horzEdge->Bot);
+ AddLocalMaxPoly(horzEdge, eMaxPair, horzEdge->Top);
+ }
+ DeleteFromAEL(horzEdge);
+ DeleteFromAEL(eMaxPair);
+ return;
+ }
+ else if(dir == dLeftToRight)
+ {
+ IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y);
+ IntersectEdges(horzEdge, e, Pt);
+ }
+ else
+ {
+ IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y);
+ IntersectEdges( e, horzEdge, Pt);
+ }
+ SwapPositionsInAEL( horzEdge, e );
+ }
+ else if( (dir == dLeftToRight && e->Curr.X >= horzRight) ||
+ (dir == dRightToLeft && e->Curr.X <= horzLeft) ) break;
+ e = eNext;
+ } //end while
+
+ if (horzEdge->NextInLML && IsHorizontal(*horzEdge->NextInLML))
+ {
+ UpdateEdgeIntoAEL(horzEdge);
+ if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Bot);
+ GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
+ } else
+ break;
+ } //end for (;;)
+
+ if(horzEdge->NextInLML)
+ {
+ if(horzEdge->OutIdx >= 0)
+ {
+ OutPt* op1 = AddOutPt( horzEdge, horzEdge->Top);
+ if (isTopOfScanbeam) AddGhostJoin(op1, horzEdge->Bot);
+ UpdateEdgeIntoAEL(horzEdge);
+ if (horzEdge->WindDelta == 0) return;
+ //nb: HorzEdge is no longer horizontal here
+ TEdge* ePrev = horzEdge->PrevInAEL;
+ TEdge* eNext = horzEdge->NextInAEL;
+ if (ePrev && ePrev->Curr.X == horzEdge->Bot.X &&
+ ePrev->Curr.Y == horzEdge->Bot.Y && ePrev->WindDelta != 0 &&
+ (ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y &&
+ SlopesEqual(*horzEdge, *ePrev, m_UseFullRange)))
+ {
+ OutPt* op2 = AddOutPt(ePrev, horzEdge->Bot);
+ AddJoin(op1, op2, horzEdge->Top);
+ }
+ else if (eNext && eNext->Curr.X == horzEdge->Bot.X &&
+ eNext->Curr.Y == horzEdge->Bot.Y && eNext->WindDelta != 0 &&
+ eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y &&
+ SlopesEqual(*horzEdge, *eNext, m_UseFullRange))
+ {
+ OutPt* op2 = AddOutPt(eNext, horzEdge->Bot);
+ AddJoin(op1, op2, horzEdge->Top);
+ }
+ }
+ else
+ UpdateEdgeIntoAEL(horzEdge);
+ }
+ else
+ {
+ if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Top);
+ DeleteFromAEL(horzEdge);
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::UpdateEdgeIntoAEL(TEdge *&e)
+{
+ if( !e->NextInLML ) throw
+ clipperException("UpdateEdgeIntoAEL: invalid call");
+
+ e->NextInLML->OutIdx = e->OutIdx;
+ TEdge* AelPrev = e->PrevInAEL;
+ TEdge* AelNext = e->NextInAEL;
+ if (AelPrev) AelPrev->NextInAEL = e->NextInLML;
+ else m_ActiveEdges = e->NextInLML;
+ if (AelNext) AelNext->PrevInAEL = e->NextInLML;
+ e->NextInLML->Side = e->Side;
+ e->NextInLML->WindDelta = e->WindDelta;
+ e->NextInLML->WindCnt = e->WindCnt;
+ e->NextInLML->WindCnt2 = e->WindCnt2;
+ e = e->NextInLML;
+ e->Curr = e->Bot;
+ e->PrevInAEL = AelPrev;
+ e->NextInAEL = AelNext;
+ if (!IsHorizontal(*e)) InsertScanbeam(e->Top.Y);
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::ProcessIntersections(const cInt botY, const cInt topY)
+{
+ if( !m_ActiveEdges ) return true;
+ try {
+ BuildIntersectList(botY, topY);
+ size_t IlSize = m_IntersectList.size();
+ if (IlSize == 0) return true;
+ if (IlSize == 1 || FixupIntersectionOrder()) ProcessIntersectList();
+ else return false;
+ }
+ catch(...)
+ {
+ m_SortedEdges = 0;
+ DisposeIntersectNodes();
+ throw clipperException("ProcessIntersections error");
+ }
+ m_SortedEdges = 0;
+ return true;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DisposeIntersectNodes()
+{
+ for (size_t i = 0; i < m_IntersectList.size(); ++i )
+ delete m_IntersectList[i];
+ m_IntersectList.clear();
+}
+//------------------------------------------------------------------------------
+
+void Clipper::BuildIntersectList(const cInt botY, const cInt topY)
+{
+ if ( !m_ActiveEdges ) return;
+
+ //prepare for sorting ...
+ TEdge* e = m_ActiveEdges;
+ m_SortedEdges = e;
+ while( e )
+ {
+ e->PrevInSEL = e->PrevInAEL;
+ e->NextInSEL = e->NextInAEL;
+ e->Curr.X = TopX( *e, topY );
+ e = e->NextInAEL;
+ }
+
+ //bubblesort ...
+ bool isModified;
+ do
+ {
+ isModified = false;
+ e = m_SortedEdges;
+ while( e->NextInSEL )
+ {
+ TEdge *eNext = e->NextInSEL;
+ IntPoint Pt;
+ if(e->Curr.X > eNext->Curr.X)
+ {
+ IntersectPoint(*e, *eNext, Pt);
+ IntersectNode * newNode = new IntersectNode;
+ newNode->Edge1 = e;
+ newNode->Edge2 = eNext;
+ newNode->Pt = Pt;
+ m_IntersectList.push_back(newNode);
+
+ SwapPositionsInSEL(e, eNext);
+ isModified = true;
+ }
+ else
+ e = eNext;
+ }
+ if( e->PrevInSEL ) e->PrevInSEL->NextInSEL = 0;
+ else break;
+ }
+ while ( isModified );
+ m_SortedEdges = 0; //important
+}
+//------------------------------------------------------------------------------
+
+
+void Clipper::ProcessIntersectList()
+{
+ for (size_t i = 0; i < m_IntersectList.size(); ++i)
+ {
+ IntersectNode* iNode = m_IntersectList[i];
+ {
+ IntersectEdges( iNode->Edge1, iNode->Edge2, iNode->Pt);
+ SwapPositionsInAEL( iNode->Edge1 , iNode->Edge2 );
+ }
+ delete iNode;
+ }
+ m_IntersectList.clear();
+}
+//------------------------------------------------------------------------------
+
+bool IntersectListSort(IntersectNode* node1, IntersectNode* node2)
+{
+ return node2->Pt.Y < node1->Pt.Y;
+}
+//------------------------------------------------------------------------------
+
+inline bool EdgesAdjacent(const IntersectNode &inode)
+{
+ return (inode.Edge1->NextInSEL == inode.Edge2) ||
+ (inode.Edge1->PrevInSEL == inode.Edge2);
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::FixupIntersectionOrder()
+{
+ //pre-condition: intersections are sorted Bottom-most first.
+ //Now it's crucial that intersections are made only between adjacent edges,
+ //so to ensure this the order of intersections may need adjusting ...
+ CopyAELToSEL();
+ std::sort(m_IntersectList.begin(), m_IntersectList.end(), IntersectListSort);
+ size_t cnt = m_IntersectList.size();
+ for (size_t i = 0; i < cnt; ++i)
+ {
+ if (!EdgesAdjacent(*m_IntersectList[i]))
+ {
+ size_t j = i + 1;
+ while (j < cnt && !EdgesAdjacent(*m_IntersectList[j])) j++;
+ if (j == cnt) return false;
+ std::swap(m_IntersectList[i], m_IntersectList[j]);
+ }
+ SwapPositionsInSEL(m_IntersectList[i]->Edge1, m_IntersectList[i]->Edge2);
+ }
+ return true;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::DoMaxima(TEdge *e)
+{
+ TEdge* eMaxPair = GetMaximaPair(e);
+ if (!eMaxPair)
+ {
+ if (e->OutIdx >= 0)
+ AddOutPt(e, e->Top);
+ DeleteFromAEL(e);
+ return;
+ }
+
+ TEdge* eNext = e->NextInAEL;
+ while(eNext && eNext != eMaxPair)
+ {
+ IntersectEdges(e, eNext, e->Top);
+ SwapPositionsInAEL(e, eNext);
+ eNext = e->NextInAEL;
+ }
+
+ if(e->OutIdx == Unassigned && eMaxPair->OutIdx == Unassigned)
+ {
+ DeleteFromAEL(e);
+ DeleteFromAEL(eMaxPair);
+ }
+ else if( e->OutIdx >= 0 && eMaxPair->OutIdx >= 0 )
+ {
+ if (e->OutIdx >= 0) AddLocalMaxPoly(e, eMaxPair, e->Top);
+ DeleteFromAEL(e);
+ DeleteFromAEL(eMaxPair);
+ }
+#ifdef use_lines
+ else if (e->WindDelta == 0)
+ {
+ if (e->OutIdx >= 0)
+ {
+ AddOutPt(e, e->Top);
+ e->OutIdx = Unassigned;
+ }
+ DeleteFromAEL(e);
+
+ if (eMaxPair->OutIdx >= 0)
+ {
+ AddOutPt(eMaxPair, e->Top);
+ eMaxPair->OutIdx = Unassigned;
+ }
+ DeleteFromAEL(eMaxPair);
+ }
+#endif
+ else throw clipperException("DoMaxima error");
+}
+//------------------------------------------------------------------------------
+
+void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
+{
+ TEdge* e = m_ActiveEdges;
+ while( e )
+ {
+ //1. process maxima, treating them as if they're 'bent' horizontal edges,
+ // but exclude maxima with horizontal edges. nb: e can't be a horizontal.
+ bool IsMaximaEdge = IsMaxima(e, topY);
+
+ if(IsMaximaEdge)
+ {
+ TEdge* eMaxPair = GetMaximaPair(e);
+ IsMaximaEdge = (!eMaxPair || !IsHorizontal(*eMaxPair));
+ }
+
+ if(IsMaximaEdge)
+ {
+ TEdge* ePrev = e->PrevInAEL;
+ DoMaxima(e);
+ if( !ePrev ) e = m_ActiveEdges;
+ else e = ePrev->NextInAEL;
+ }
+ else
+ {
+ //2. promote horizontal edges, otherwise update Curr.X and Curr.Y ...
+ if (IsIntermediate(e, topY) && IsHorizontal(*e->NextInLML))
+ {
+ UpdateEdgeIntoAEL(e);
+ if (e->OutIdx >= 0)
+ AddOutPt(e, e->Bot);
+ AddEdgeToSEL(e);
+ }
+ else
+ {
+ e->Curr.X = TopX( *e, topY );
+ e->Curr.Y = topY;
+ }
+
+ if (m_StrictSimple)
+ {
+ TEdge* ePrev = e->PrevInAEL;
+ if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) &&
+ (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0))
+ {
+ IntPoint pt = e->Curr;
+#ifdef use_xyz
+ SetZ(pt, *ePrev, *e);
+#endif
+ OutPt* op = AddOutPt(ePrev, pt);
+ OutPt* op2 = AddOutPt(e, pt);
+ AddJoin(op, op2, pt); //StrictlySimple (type-3) join
+ }
+ }
+
+ e = e->NextInAEL;
+ }
+ }
+
+ //3. Process horizontals at the Top of the scanbeam ...
+ ProcessHorizontals(true);
+
+ //4. Promote intermediate vertices ...
+ e = m_ActiveEdges;
+ while(e)
+ {
+ if(IsIntermediate(e, topY))
+ {
+ OutPt* op = 0;
+ if( e->OutIdx >= 0 )
+ op = AddOutPt(e, e->Top);
+ UpdateEdgeIntoAEL(e);
+
+ //if output polygons share an edge, they'll need joining later ...
+ TEdge* ePrev = e->PrevInAEL;
+ TEdge* eNext = e->NextInAEL;
+ if (ePrev && ePrev->Curr.X == e->Bot.X &&
+ ePrev->Curr.Y == e->Bot.Y && op &&
+ ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y &&
+ SlopesEqual(*e, *ePrev, m_UseFullRange) &&
+ (e->WindDelta != 0) && (ePrev->WindDelta != 0))
+ {
+ OutPt* op2 = AddOutPt(ePrev, e->Bot);
+ AddJoin(op, op2, e->Top);
+ }
+ else if (eNext && eNext->Curr.X == e->Bot.X &&
+ eNext->Curr.Y == e->Bot.Y && op &&
+ eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y &&
+ SlopesEqual(*e, *eNext, m_UseFullRange) &&
+ (e->WindDelta != 0) && (eNext->WindDelta != 0))
+ {
+ OutPt* op2 = AddOutPt(eNext, e->Bot);
+ AddJoin(op, op2, e->Top);
+ }
+ }
+ e = e->NextInAEL;
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::FixupOutPolygon(OutRec &outrec)
+{
+ //FixupOutPolygon() - removes duplicate points and simplifies consecutive
+ //parallel edges by removing the middle vertex.
+ OutPt *lastOK = 0;
+ outrec.BottomPt = 0;
+ OutPt *pp = outrec.Pts;
+
+ for (;;)
+ {
+ if (pp->Prev == pp || pp->Prev == pp->Next )
+ {
+ DisposeOutPts(pp);
+ outrec.Pts = 0;
+ return;
+ }
+
+ //test for duplicate points and collinear edges ...
+ if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) ||
+ (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) &&
+ (!m_PreserveCollinear ||
+ !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt))))
+ {
+ lastOK = 0;
+ OutPt *tmp = pp;
+ pp->Prev->Next = pp->Next;
+ pp->Next->Prev = pp->Prev;
+ pp = pp->Prev;
+ delete tmp;
+ }
+ else if (pp == lastOK) break;
+ else
+ {
+ if (!lastOK) lastOK = pp;
+ pp = pp->Next;
+ }
+ }
+ outrec.Pts = pp;
+}
+//------------------------------------------------------------------------------
+
+int PointCount(OutPt *Pts)
+{
+ if (!Pts) return 0;
+ int result = 0;
+ OutPt* p = Pts;
+ do
+ {
+ result++;
+ p = p->Next;
+ }
+ while (p != Pts);
+ return result;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::BuildResult(Paths &polys)
+{
+ polys.reserve(m_PolyOuts.size());
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ {
+ if (!m_PolyOuts[i]->Pts) continue;
+ Path pg;
+ OutPt* p = m_PolyOuts[i]->Pts->Prev;
+ int cnt = PointCount(p);
+ if (cnt < 2) continue;
+ pg.reserve(cnt);
+ for (int i = 0; i < cnt; ++i)
+ {
+ pg.push_back(p->Pt);
+ p = p->Prev;
+ }
+ polys.push_back(pg);
+ }
+}
+//------------------------------------------------------------------------------
+
+void Clipper::BuildResult2(PolyTree& polytree)
+{
+ polytree.Clear();
+ polytree.AllNodes.reserve(m_PolyOuts.size());
+ //add each output polygon/contour to polytree ...
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
+ {
+ OutRec* outRec = m_PolyOuts[i];
+ int cnt = PointCount(outRec->Pts);
+ if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue;
+ FixHoleLinkage(*outRec);
+ PolyNode* pn = new PolyNode();
+ //nb: polytree takes ownership of all the PolyNodes
+ polytree.AllNodes.push_back(pn);
+ outRec->PolyNd = pn;
+ pn->Parent = 0;
+ pn->Index = 0;
+ pn->Contour.reserve(cnt);
+ OutPt *op = outRec->Pts->Prev;
+ for (int j = 0; j < cnt; j++)
+ {
+ pn->Contour.push_back(op->Pt);
+ op = op->Prev;
+ }
+ }
+
+ //fixup PolyNode links etc ...
+ polytree.Childs.reserve(m_PolyOuts.size());
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
+ {
+ OutRec* outRec = m_PolyOuts[i];
+ if (!outRec->PolyNd) continue;
+ if (outRec->IsOpen)
+ {
+ outRec->PolyNd->m_IsOpen = true;
+ polytree.AddChild(*outRec->PolyNd);
+ }
+ else if (outRec->FirstLeft && outRec->FirstLeft->PolyNd)
+ outRec->FirstLeft->PolyNd->AddChild(*outRec->PolyNd);
+ else
+ polytree.AddChild(*outRec->PolyNd);
+ }
+}
+//------------------------------------------------------------------------------
+
+void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2)
+{
+ //just swap the contents (because fIntersectNodes is a single-linked-list)
+ IntersectNode inode = int1; //gets a copy of Int1
+ int1.Edge1 = int2.Edge1;
+ int1.Edge2 = int2.Edge2;
+ int1.Pt = int2.Pt;
+ int2.Edge1 = inode.Edge1;
+ int2.Edge2 = inode.Edge2;
+ int2.Pt = inode.Pt;
+}
+//------------------------------------------------------------------------------
+
+inline bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2)
+{
+ if (e2.Curr.X == e1.Curr.X)
+ {
+ if (e2.Top.Y > e1.Top.Y)
+ return e2.Top.X < TopX(e1, e2.Top.Y);
+ else return e1.Top.X > TopX(e2, e1.Top.Y);
+ }
+ else return e2.Curr.X < e1.Curr.X;
+}
+//------------------------------------------------------------------------------
+
+bool GetOverlap(const cInt a1, const cInt a2, const cInt b1, const cInt b2,
+ cInt& Left, cInt& Right)
+{
+ if (a1 < a2)
+ {
+ if (b1 < b2) {Left = std::max(a1,b1); Right = std::min(a2,b2);}
+ else {Left = std::max(a1,b2); Right = std::min(a2,b1);}
+ }
+ else
+ {
+ if (b1 < b2) {Left = std::max(a2,b1); Right = std::min(a1,b2);}
+ else {Left = std::max(a2,b2); Right = std::min(a1,b1);}
+ }
+ return Left < Right;
+}
+//------------------------------------------------------------------------------
+
+inline void UpdateOutPtIdxs(OutRec& outrec)
+{
+ OutPt* op = outrec.Pts;
+ do
+ {
+ op->Idx = outrec.Idx;
+ op = op->Prev;
+ }
+ while(op != outrec.Pts);
+}
+//------------------------------------------------------------------------------
+
+void Clipper::InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge)
+{
+ if(!m_ActiveEdges)
+ {
+ edge->PrevInAEL = 0;
+ edge->NextInAEL = 0;
+ m_ActiveEdges = edge;
+ }
+ else if(!startEdge && E2InsertsBeforeE1(*m_ActiveEdges, *edge))
+ {
+ edge->PrevInAEL = 0;
+ edge->NextInAEL = m_ActiveEdges;
+ m_ActiveEdges->PrevInAEL = edge;
+ m_ActiveEdges = edge;
+ }
+ else
+ {
+ if(!startEdge) startEdge = m_ActiveEdges;
+ while(startEdge->NextInAEL &&
+ !E2InsertsBeforeE1(*startEdge->NextInAEL , *edge))
+ startEdge = startEdge->NextInAEL;
+ edge->NextInAEL = startEdge->NextInAEL;
+ if(startEdge->NextInAEL) startEdge->NextInAEL->PrevInAEL = edge;
+ edge->PrevInAEL = startEdge;
+ startEdge->NextInAEL = edge;
+ }
+}
+//----------------------------------------------------------------------
+
+OutPt* DupOutPt(OutPt* outPt, bool InsertAfter)
+{
+ OutPt* result = new OutPt;
+ result->Pt = outPt->Pt;
+ result->Idx = outPt->Idx;
+ if (InsertAfter)
+ {
+ result->Next = outPt->Next;
+ result->Prev = outPt;
+ outPt->Next->Prev = result;
+ outPt->Next = result;
+ }
+ else
+ {
+ result->Prev = outPt->Prev;
+ result->Next = outPt;
+ outPt->Prev->Next = result;
+ outPt->Prev = result;
+ }
+ return result;
+}
+//------------------------------------------------------------------------------
+
+bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b,
+ const IntPoint Pt, bool DiscardLeft)
+{
+ Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight);
+ Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight);
+ if (Dir1 == Dir2) return false;
+
+ //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we
+ //want Op1b to be on the Right. (And likewise with Op2 and Op2b.)
+ //So, to facilitate this while inserting Op1b and Op2b ...
+ //when DiscardLeft, make sure we're AT or RIGHT of Pt before adding Op1b,
+ //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.)
+ if (Dir1 == dLeftToRight)
+ {
+ while (op1->Next->Pt.X <= Pt.X &&
+ op1->Next->Pt.X >= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
+ op1 = op1->Next;
+ if (DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
+ op1b = DupOutPt(op1, !DiscardLeft);
+ if (op1b->Pt != Pt)
+ {
+ op1 = op1b;
+ op1->Pt = Pt;
+ op1b = DupOutPt(op1, !DiscardLeft);
+ }
+ }
+ else
+ {
+ while (op1->Next->Pt.X >= Pt.X &&
+ op1->Next->Pt.X <= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
+ op1 = op1->Next;
+ if (!DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
+ op1b = DupOutPt(op1, DiscardLeft);
+ if (op1b->Pt != Pt)
+ {
+ op1 = op1b;
+ op1->Pt = Pt;
+ op1b = DupOutPt(op1, DiscardLeft);
+ }
+ }
+
+ if (Dir2 == dLeftToRight)
+ {
+ while (op2->Next->Pt.X <= Pt.X &&
+ op2->Next->Pt.X >= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
+ op2 = op2->Next;
+ if (DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
+ op2b = DupOutPt(op2, !DiscardLeft);
+ if (op2b->Pt != Pt)
+ {
+ op2 = op2b;
+ op2->Pt = Pt;
+ op2b = DupOutPt(op2, !DiscardLeft);
+ };
+ } else
+ {
+ while (op2->Next->Pt.X >= Pt.X &&
+ op2->Next->Pt.X <= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
+ op2 = op2->Next;
+ if (!DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
+ op2b = DupOutPt(op2, DiscardLeft);
+ if (op2b->Pt != Pt)
+ {
+ op2 = op2b;
+ op2->Pt = Pt;
+ op2b = DupOutPt(op2, DiscardLeft);
+ };
+ };
+
+ if ((Dir1 == dLeftToRight) == DiscardLeft)
+ {
+ op1->Prev = op2;
+ op2->Next = op1;
+ op1b->Next = op2b;
+ op2b->Prev = op1b;
+ }
+ else
+ {
+ op1->Next = op2;
+ op2->Prev = op1;
+ op1b->Prev = op2b;
+ op2b->Next = op1b;
+ }
+ return true;
+}
+//------------------------------------------------------------------------------
+
+bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
+{
+ OutPt *op1 = j->OutPt1, *op1b;
+ OutPt *op2 = j->OutPt2, *op2b;
+
+ //There are 3 kinds of joins for output polygons ...
+ //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are a vertices anywhere
+ //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal).
+ //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same
+ //location at the Bottom of the overlapping segment (& Join.OffPt is above).
+ //3. StrictSimple joins where edges touch but are not collinear and where
+ //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point.
+ bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y);
+
+ if (isHorizontal && (j->OffPt == j->OutPt1->Pt) &&
+ (j->OffPt == j->OutPt2->Pt))
+ {
+ //Strictly Simple join ...
+ if (outRec1 != outRec2) return false;
+ op1b = j->OutPt1->Next;
+ while (op1b != op1 && (op1b->Pt == j->OffPt))
+ op1b = op1b->Next;
+ bool reverse1 = (op1b->Pt.Y > j->OffPt.Y);
+ op2b = j->OutPt2->Next;
+ while (op2b != op2 && (op2b->Pt == j->OffPt))
+ op2b = op2b->Next;
+ bool reverse2 = (op2b->Pt.Y > j->OffPt.Y);
+ if (reverse1 == reverse2) return false;
+ if (reverse1)
+ {
+ op1b = DupOutPt(op1, false);
+ op2b = DupOutPt(op2, true);
+ op1->Prev = op2;
+ op2->Next = op1;
+ op1b->Next = op2b;
+ op2b->Prev = op1b;
+ j->OutPt1 = op1;
+ j->OutPt2 = op1b;
+ return true;
+ } else
+ {
+ op1b = DupOutPt(op1, true);
+ op2b = DupOutPt(op2, false);
+ op1->Next = op2;
+ op2->Prev = op1;
+ op1b->Prev = op2b;
+ op2b->Next = op1b;
+ j->OutPt1 = op1;
+ j->OutPt2 = op1b;
+ return true;
+ }
+ }
+ else if (isHorizontal)
+ {
+ //treat horizontal joins differently to non-horizontal joins since with
+ //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt
+ //may be anywhere along the horizontal edge.
+ op1b = op1;
+ while (op1->Prev->Pt.Y == op1->Pt.Y && op1->Prev != op1b && op1->Prev != op2)
+ op1 = op1->Prev;
+ while (op1b->Next->Pt.Y == op1b->Pt.Y && op1b->Next != op1 && op1b->Next != op2)
+ op1b = op1b->Next;
+ if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon'
+
+ op2b = op2;
+ while (op2->Prev->Pt.Y == op2->Pt.Y && op2->Prev != op2b && op2->Prev != op1b)
+ op2 = op2->Prev;
+ while (op2b->Next->Pt.Y == op2b->Pt.Y && op2b->Next != op2 && op2b->Next != op1)
+ op2b = op2b->Next;
+ if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon'
+
+ cInt Left, Right;
+ //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges
+ if (!GetOverlap(op1->Pt.X, op1b->Pt.X, op2->Pt.X, op2b->Pt.X, Left, Right))
+ return false;
+
+ //DiscardLeftSide: when overlapping edges are joined, a spike will created
+ //which needs to be cleaned up. However, we don't want Op1 or Op2 caught up
+ //on the discard Side as either may still be needed for other joins ...
+ IntPoint Pt;
+ bool DiscardLeftSide;
+ if (op1->Pt.X >= Left && op1->Pt.X <= Right)
+ {
+ Pt = op1->Pt; DiscardLeftSide = (op1->Pt.X > op1b->Pt.X);
+ }
+ else if (op2->Pt.X >= Left&& op2->Pt.X <= Right)
+ {
+ Pt = op2->Pt; DiscardLeftSide = (op2->Pt.X > op2b->Pt.X);
+ }
+ else if (op1b->Pt.X >= Left && op1b->Pt.X <= Right)
+ {
+ Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.X > op1->Pt.X;
+ }
+ else
+ {
+ Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.X > op2->Pt.X);
+ }
+ j->OutPt1 = op1; j->OutPt2 = op2;
+ return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide);
+ } else
+ {
+ //nb: For non-horizontal joins ...
+ // 1. Jr.OutPt1.Pt.Y == Jr.OutPt2.Pt.Y
+ // 2. Jr.OutPt1.Pt > Jr.OffPt.Y
+
+ //make sure the polygons are correctly oriented ...
+ op1b = op1->Next;
+ while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Next;
+ bool Reverse1 = ((op1b->Pt.Y > op1->Pt.Y) ||
+ !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange));
+ if (Reverse1)
+ {
+ op1b = op1->Prev;
+ while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Prev;
+ if ((op1b->Pt.Y > op1->Pt.Y) ||
+ !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)) return false;
+ };
+ op2b = op2->Next;
+ while ((op2b->Pt == op2->Pt) && (op2b != op2))op2b = op2b->Next;
+ bool Reverse2 = ((op2b->Pt.Y > op2->Pt.Y) ||
+ !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange));
+ if (Reverse2)
+ {
+ op2b = op2->Prev;
+ while ((op2b->Pt == op2->Pt) && (op2b != op2)) op2b = op2b->Prev;
+ if ((op2b->Pt.Y > op2->Pt.Y) ||
+ !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)) return false;
+ }
+
+ if ((op1b == op1) || (op2b == op2) || (op1b == op2b) ||
+ ((outRec1 == outRec2) && (Reverse1 == Reverse2))) return false;
+
+ if (Reverse1)
+ {
+ op1b = DupOutPt(op1, false);
+ op2b = DupOutPt(op2, true);
+ op1->Prev = op2;
+ op2->Next = op1;
+ op1b->Next = op2b;
+ op2b->Prev = op1b;
+ j->OutPt1 = op1;
+ j->OutPt2 = op1b;
+ return true;
+ } else
+ {
+ op1b = DupOutPt(op1, true);
+ op2b = DupOutPt(op2, false);
+ op1->Next = op2;
+ op2->Prev = op1;
+ op1b->Prev = op2b;
+ op2b->Next = op1b;
+ j->OutPt1 = op1;
+ j->OutPt2 = op1b;
+ return true;
+ }
+ }
+}
+//----------------------------------------------------------------------
+
+static OutRec* ParseFirstLeft(OutRec* FirstLeft)
+{
+ while (FirstLeft && !FirstLeft->Pts)
+ FirstLeft = FirstLeft->FirstLeft;
+ return FirstLeft;
+}
+//------------------------------------------------------------------------------
+
+void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec)
+{
+ //tests if NewOutRec contains the polygon before reassigning FirstLeft
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ {
+ OutRec* outRec = m_PolyOuts[i];
+ if (!outRec->Pts || !outRec->FirstLeft) continue;
+ OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
+ if (firstLeft == OldOutRec)
+ {
+ if (Poly2ContainsPoly1(outRec->Pts, NewOutRec->Pts))
+ outRec->FirstLeft = NewOutRec;
+ }
+ }
+}
+//----------------------------------------------------------------------
+
+void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec)
+{
+ //reassigns FirstLeft WITHOUT testing if NewOutRec contains the polygon
+ for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
+ {
+ OutRec* outRec = m_PolyOuts[i];
+ if (outRec->FirstLeft == OldOutRec) outRec->FirstLeft = NewOutRec;
+ }
+}
+//----------------------------------------------------------------------
+
+void Clipper::JoinCommonEdges()
+{
+ for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
+ {
+ Join* join = m_Joins[i];
+
+ OutRec *outRec1 = GetOutRec(join->OutPt1->Idx);
+ OutRec *outRec2 = GetOutRec(join->OutPt2->Idx);
+
+ if (!outRec1->Pts || !outRec2->Pts) continue;
+
+ //get the polygon fragment with the correct hole state (FirstLeft)
+ //before calling JoinPoints() ...
+ OutRec *holeStateRec;
+ if (outRec1 == outRec2) holeStateRec = outRec1;
+ else if (Param1RightOfParam2(outRec1, outRec2)) holeStateRec = outRec2;
+ else if (Param1RightOfParam2(outRec2, outRec1)) holeStateRec = outRec1;
+ else holeStateRec = GetLowermostRec(outRec1, outRec2);
+
+ if (!JoinPoints(join, outRec1, outRec2)) continue;
+
+ if (outRec1 == outRec2)
+ {
+ //instead of joining two polygons, we've just created a new one by
+ //splitting one polygon into two.
+ outRec1->Pts = join->OutPt1;
+ outRec1->BottomPt = 0;
+ outRec2 = CreateOutRec();
+ outRec2->Pts = join->OutPt2;
+
+ //update all OutRec2.Pts Idx's ...
+ UpdateOutPtIdxs(*outRec2);
+
+ //We now need to check every OutRec.FirstLeft pointer. If it points
+ //to OutRec1 it may need to point to OutRec2 instead ...
+ if (m_UsingPolyTree)
+ for (PolyOutList::size_type j = 0; j < m_PolyOuts.size() - 1; j++)
+ {
+ OutRec* oRec = m_PolyOuts[j];
+ if (!oRec->Pts || ParseFirstLeft(oRec->FirstLeft) != outRec1 ||
+ oRec->IsHole == outRec1->IsHole) continue;
+ if (Poly2ContainsPoly1(oRec->Pts, join->OutPt2))
+ oRec->FirstLeft = outRec2;
+ }
+
+ if (Poly2ContainsPoly1(outRec2->Pts, outRec1->Pts))
+ {
+ //outRec2 is contained by outRec1 ...
+ outRec2->IsHole = !outRec1->IsHole;
+ outRec2->FirstLeft = outRec1;
+
+ //fixup FirstLeft pointers that may need reassigning to OutRec1
+ if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
+
+ if ((outRec2->IsHole ^ m_ReverseOutput) == (Area(*outRec2) > 0))
+ ReversePolyPtLinks(outRec2->Pts);
+
+ } else if (Poly2ContainsPoly1(outRec1->Pts, outRec2->Pts))
+ {
+ //outRec1 is contained by outRec2 ...
+ outRec2->IsHole = outRec1->IsHole;
+ outRec1->IsHole = !outRec2->IsHole;
+ outRec2->FirstLeft = outRec1->FirstLeft;
+ outRec1->FirstLeft = outRec2;
+
+ //fixup FirstLeft pointers that may need reassigning to OutRec1
+ if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2);
+
+ if ((outRec1->IsHole ^ m_ReverseOutput) == (Area(*outRec1) > 0))
+ ReversePolyPtLinks(outRec1->Pts);
+ }
+ else
+ {
+ //the 2 polygons are completely separate ...
+ outRec2->IsHole = outRec1->IsHole;
+ outRec2->FirstLeft = outRec1->FirstLeft;
+
+ //fixup FirstLeft pointers that may need reassigning to OutRec2
+ if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2);
+ }
+
+ } else
+ {
+ //joined 2 polygons together ...
+
+ outRec2->Pts = 0;
+ outRec2->BottomPt = 0;
+ outRec2->Idx = outRec1->Idx;
+
+ outRec1->IsHole = holeStateRec->IsHole;
+ if (holeStateRec == outRec2)
+ outRec1->FirstLeft = outRec2->FirstLeft;
+ outRec2->FirstLeft = outRec1;
+
+ //fixup FirstLeft pointers that may need reassigning to OutRec1
+ if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+// ClipperOffset support functions ...
+//------------------------------------------------------------------------------
+
+DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2)
+{
+ if(pt2.X == pt1.X && pt2.Y == pt1.Y)
+ return DoublePoint(0, 0);
+
+ double Dx = (double)(pt2.X - pt1.X);
+ double dy = (double)(pt2.Y - pt1.Y);
+ double f = 1 *1.0/ std::sqrt( Dx*Dx + dy*dy );
+ Dx *= f;
+ dy *= f;
+ return DoublePoint(dy, -Dx);
+}
+
+//------------------------------------------------------------------------------
+// ClipperOffset class
+//------------------------------------------------------------------------------
+
+ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance)
+{
+ this->MiterLimit = miterLimit;
+ this->ArcTolerance = arcTolerance;
+ m_lowest.X = -1;
+}
+//------------------------------------------------------------------------------
+
+ClipperOffset::~ClipperOffset()
+{
+ Clear();
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::Clear()
+{
+ for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
+ delete m_polyNodes.Childs[i];
+ m_polyNodes.Childs.clear();
+ m_lowest.X = -1;
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType)
+{
+ int highI = (int)path.size() - 1;
+ if (highI < 0) return;
+ PolyNode* newNode = new PolyNode();
+ newNode->m_jointype = joinType;
+ newNode->m_endtype = endType;
+
+ //strip duplicate points from path and also get index to the lowest point ...
+ if (endType == etClosedLine || endType == etClosedPolygon)
+ while (highI > 0 && path[0] == path[highI]) highI--;
+ newNode->Contour.reserve(highI + 1);
+ newNode->Contour.push_back(path[0]);
+ int j = 0, k = 0;
+ for (int i = 1; i <= highI; i++)
+ if (newNode->Contour[j] != path[i])
+ {
+ j++;
+ newNode->Contour.push_back(path[i]);
+ if (path[i].Y > newNode->Contour[k].Y ||
+ (path[i].Y == newNode->Contour[k].Y &&
+ path[i].X < newNode->Contour[k].X)) k = j;
+ }
+ if (endType == etClosedPolygon && j < 2)
+ {
+ delete newNode;
+ return;
+ }
+ m_polyNodes.AddChild(*newNode);
+
+ //if this path's lowest pt is lower than all the others then update m_lowest
+ if (endType != etClosedPolygon) return;
+ if (m_lowest.X < 0)
+ m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
+ else
+ {
+ IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X]->Contour[(int)m_lowest.Y];
+ if (newNode->Contour[k].Y > ip.Y ||
+ (newNode->Contour[k].Y == ip.Y &&
+ newNode->Contour[k].X < ip.X))
+ m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::AddPaths(const Paths& paths, JoinType joinType, EndType endType)
+{
+ for (Paths::size_type i = 0; i < paths.size(); ++i)
+ AddPath(paths[i], joinType, endType);
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::FixOrientations()
+{
+ //fixup orientations of all closed paths if the orientation of the
+ //closed path with the lowermost vertex is wrong ...
+ if (m_lowest.X >= 0 &&
+ !Orientation(m_polyNodes.Childs[(int)m_lowest.X]->Contour))
+ {
+ for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
+ {
+ PolyNode& node = *m_polyNodes.Childs[i];
+ if (node.m_endtype == etClosedPolygon ||
+ (node.m_endtype == etClosedLine && Orientation(node.Contour)))
+ ReversePath(node.Contour);
+ }
+ } else
+ {
+ for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
+ {
+ PolyNode& node = *m_polyNodes.Childs[i];
+ if (node.m_endtype == etClosedLine && !Orientation(node.Contour))
+ ReversePath(node.Contour);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::Execute(Paths& solution, double delta)
+{
+ solution.clear();
+ FixOrientations();
+ DoOffset(delta);
+
+ //now clean up 'corners' ...
+ Clipper clpr;
+ clpr.AddPaths(m_destPolys, ptSubject, true);
+ if (delta > 0)
+ {
+ clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
+ }
+ else
+ {
+ IntRect r = clpr.GetBounds();
+ Path outer(4);
+ outer[0] = IntPoint(r.left - 10, r.bottom + 10);
+ outer[1] = IntPoint(r.right + 10, r.bottom + 10);
+ outer[2] = IntPoint(r.right + 10, r.top - 10);
+ outer[3] = IntPoint(r.left - 10, r.top - 10);
+
+ clpr.AddPath(outer, ptSubject, true);
+ clpr.ReverseSolution(true);
+ clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
+ if (solution.size() > 0) solution.erase(solution.begin());
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::Execute(PolyTree& solution, double delta)
+{
+ solution.Clear();
+ FixOrientations();
+ DoOffset(delta);
+
+ //now clean up 'corners' ...
+ Clipper clpr;
+ clpr.AddPaths(m_destPolys, ptSubject, true);
+ if (delta > 0)
+ {
+ clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
+ }
+ else
+ {
+ IntRect r = clpr.GetBounds();
+ Path outer(4);
+ outer[0] = IntPoint(r.left - 10, r.bottom + 10);
+ outer[1] = IntPoint(r.right + 10, r.bottom + 10);
+ outer[2] = IntPoint(r.right + 10, r.top - 10);
+ outer[3] = IntPoint(r.left - 10, r.top - 10);
+
+ clpr.AddPath(outer, ptSubject, true);
+ clpr.ReverseSolution(true);
+ clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
+ //remove the outer PolyNode rectangle ...
+ if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0)
+ {
+ PolyNode* outerNode = solution.Childs[0];
+ solution.Childs.reserve(outerNode->ChildCount());
+ solution.Childs[0] = outerNode->Childs[0];
+ for (int i = 1; i < outerNode->ChildCount(); ++i)
+ solution.AddChild(*outerNode->Childs[i]);
+ }
+ else
+ solution.Clear();
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::DoOffset(double delta)
+{
+ m_destPolys.clear();
+ m_delta = delta;
+
+ //if Zero offset, just copy any CLOSED polygons to m_p and return ...
+ if (NEAR_ZERO(delta))
+ {
+ m_destPolys.reserve(m_polyNodes.ChildCount());
+ for (int i = 0; i < m_polyNodes.ChildCount(); i++)
+ {
+ PolyNode& node = *m_polyNodes.Childs[i];
+ if (node.m_endtype == etClosedPolygon)
+ m_destPolys.push_back(node.Contour);
+ }
+ return;
+ }
+
+ //see offset_triginometry3.svg in the documentation folder ...
+ if (MiterLimit > 2) m_miterLim = 2/(MiterLimit * MiterLimit);
+ else m_miterLim = 0.5;
+
+ double y;
+ if (ArcTolerance <= 0.0) y = def_arc_tolerance;
+ else if (ArcTolerance > std::fabs(delta) * def_arc_tolerance)
+ y = std::fabs(delta) * def_arc_tolerance;
+ else y = ArcTolerance;
+ //see offset_triginometry2.svg in the documentation folder ...
+ double steps = pi / std::acos(1 - y / std::fabs(delta));
+ if (steps > std::fabs(delta) * pi)
+ steps = std::fabs(delta) * pi; //ie excessive precision check
+ m_sin = std::sin(two_pi / steps);
+ m_cos = std::cos(two_pi / steps);
+ m_StepsPerRad = steps / two_pi;
+ if (delta < 0.0) m_sin = -m_sin;
+
+ m_destPolys.reserve(m_polyNodes.ChildCount() * 2);
+ for (int i = 0; i < m_polyNodes.ChildCount(); i++)
+ {
+ PolyNode& node = *m_polyNodes.Childs[i];
+ m_srcPoly = node.Contour;
+
+ int len = (int)m_srcPoly.size();
+ if (len == 0 || (delta <= 0 && (len < 3 || node.m_endtype != etClosedPolygon)))
+ continue;
+
+ m_destPoly.clear();
+ if (len == 1)
+ {
+ if (node.m_jointype == jtRound)
+ {
+ double X = 1.0, Y = 0.0;
+ for (cInt j = 1; j <= steps; j++)
+ {
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[0].X + X * delta),
+ Round(m_srcPoly[0].Y + Y * delta)));
+ double X2 = X;
+ X = X * m_cos - m_sin * Y;
+ Y = X2 * m_sin + Y * m_cos;
+ }
+ }
+ else
+ {
+ double X = -1.0, Y = -1.0;
+ for (int j = 0; j < 4; ++j)
+ {
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[0].X + X * delta),
+ Round(m_srcPoly[0].Y + Y * delta)));
+ if (X < 0) X = 1;
+ else if (Y < 0) Y = 1;
+ else X = -1;
+ }
+ }
+ m_destPolys.push_back(m_destPoly);
+ continue;
+ }
+ //build m_normals ...
+ m_normals.clear();
+ m_normals.reserve(len);
+ for (int j = 0; j < len - 1; ++j)
+ m_normals.push_back(GetUnitNormal(m_srcPoly[j], m_srcPoly[j + 1]));
+ if (node.m_endtype == etClosedLine || node.m_endtype == etClosedPolygon)
+ m_normals.push_back(GetUnitNormal(m_srcPoly[len - 1], m_srcPoly[0]));
+ else
+ m_normals.push_back(DoublePoint(m_normals[len - 2]));
+
+ if (node.m_endtype == etClosedPolygon)
+ {
+ int k = len - 1;
+ for (int j = 0; j < len; ++j)
+ OffsetPoint(j, k, node.m_jointype);
+ m_destPolys.push_back(m_destPoly);
+ }
+ else if (node.m_endtype == etClosedLine)
+ {
+ int k = len - 1;
+ for (int j = 0; j < len; ++j)
+ OffsetPoint(j, k, node.m_jointype);
+ m_destPolys.push_back(m_destPoly);
+ m_destPoly.clear();
+ //re-build m_normals ...
+ DoublePoint n = m_normals[len -1];
+ for (int j = len - 1; j > 0; j--)
+ m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y);
+ m_normals[0] = DoublePoint(-n.X, -n.Y);
+ k = 0;
+ for (int j = len - 1; j >= 0; j--)
+ OffsetPoint(j, k, node.m_jointype);
+ m_destPolys.push_back(m_destPoly);
+ }
+ else
+ {
+ int k = 0;
+ for (int j = 1; j < len - 1; ++j)
+ OffsetPoint(j, k, node.m_jointype);
+
+ IntPoint pt1;
+ if (node.m_endtype == etOpenButt)
+ {
+ int j = len - 1;
+ pt1 = IntPoint((cInt)Round(m_srcPoly[j].X + m_normals[j].X *
+ delta), (cInt)Round(m_srcPoly[j].Y + m_normals[j].Y * delta));
+ m_destPoly.push_back(pt1);
+ pt1 = IntPoint((cInt)Round(m_srcPoly[j].X - m_normals[j].X *
+ delta), (cInt)Round(m_srcPoly[j].Y - m_normals[j].Y * delta));
+ m_destPoly.push_back(pt1);
+ }
+ else
+ {
+ int j = len - 1;
+ k = len - 2;
+ m_sinA = 0;
+ m_normals[j] = DoublePoint(-m_normals[j].X, -m_normals[j].Y);
+ if (node.m_endtype == etOpenSquare)
+ DoSquare(j, k);
+ else
+ DoRound(j, k);
+ }
+
+ //re-build m_normals ...
+ for (int j = len - 1; j > 0; j--)
+ m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y);
+ m_normals[0] = DoublePoint(-m_normals[1].X, -m_normals[1].Y);
+
+ k = len - 1;
+ for (int j = k - 1; j > 0; --j) OffsetPoint(j, k, node.m_jointype);
+
+ if (node.m_endtype == etOpenButt)
+ {
+ pt1 = IntPoint((cInt)Round(m_srcPoly[0].X - m_normals[0].X * delta),
+ (cInt)Round(m_srcPoly[0].Y - m_normals[0].Y * delta));
+ m_destPoly.push_back(pt1);
+ pt1 = IntPoint((cInt)Round(m_srcPoly[0].X + m_normals[0].X * delta),
+ (cInt)Round(m_srcPoly[0].Y + m_normals[0].Y * delta));
+ m_destPoly.push_back(pt1);
+ }
+ else
+ {
+ k = 1;
+ m_sinA = 0;
+ if (node.m_endtype == etOpenSquare)
+ DoSquare(0, 1);
+ else
+ DoRound(0, 1);
+ }
+ m_destPolys.push_back(m_destPoly);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
+{
+ //cross product ...
+ m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y);
+ if (std::fabs(m_sinA * m_delta) < 1.0)
+ {
+ //dot product ...
+ double cosA = (m_normals[k].X * m_normals[j].X + m_normals[j].Y * m_normals[k].Y );
+ if (cosA > 0) // angle => 0 degrees
+ {
+ m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
+ Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
+ return;
+ }
+ //else angle => 180 degrees
+ }
+ else if (m_sinA > 1.0) m_sinA = 1.0;
+ else if (m_sinA < -1.0) m_sinA = -1.0;
+
+ if (m_sinA * m_delta < 0)
+ {
+ m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
+ Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
+ m_destPoly.push_back(m_srcPoly[j]);
+ m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
+ Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
+ }
+ else
+ switch (jointype)
+ {
+ case jtMiter:
+ {
+ double r = 1 + (m_normals[j].X * m_normals[k].X +
+ m_normals[j].Y * m_normals[k].Y);
+ if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k);
+ break;
+ }
+ case jtSquare: DoSquare(j, k); break;
+ case jtRound: DoRound(j, k); break;
+ }
+ k = j;
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::DoSquare(int j, int k)
+{
+ double dx = std::tan(std::atan2(m_sinA,
+ m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y) / 4);
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[j].X + m_delta * (m_normals[k].X - m_normals[k].Y * dx)),
+ Round(m_srcPoly[j].Y + m_delta * (m_normals[k].Y + m_normals[k].X * dx))));
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[j].X + m_delta * (m_normals[j].X + m_normals[j].Y * dx)),
+ Round(m_srcPoly[j].Y + m_delta * (m_normals[j].Y - m_normals[j].X * dx))));
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::DoMiter(int j, int k, double r)
+{
+ double q = m_delta / r;
+ m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + (m_normals[k].X + m_normals[j].X) * q),
+ Round(m_srcPoly[j].Y + (m_normals[k].Y + m_normals[j].Y) * q)));
+}
+//------------------------------------------------------------------------------
+
+void ClipperOffset::DoRound(int j, int k)
+{
+ double a = std::atan2(m_sinA,
+ m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y);
+ int steps = (int)Round(m_StepsPerRad * std::fabs(a));
+
+ double X = m_normals[k].X, Y = m_normals[k].Y, X2;
+ for (int i = 0; i < steps; ++i)
+ {
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[j].X + X * m_delta),
+ Round(m_srcPoly[j].Y + Y * m_delta)));
+ X2 = X;
+ X = X * m_cos - m_sin * Y;
+ Y = X2 * m_sin + Y * m_cos;
+ }
+ m_destPoly.push_back(IntPoint(
+ Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
+ Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
+}
+
+//------------------------------------------------------------------------------
+// Miscellaneous public functions
+//------------------------------------------------------------------------------
+
+void Clipper::DoSimplePolygons()
+{
+ PolyOutList::size_type i = 0;
+ while (i < m_PolyOuts.size())
+ {
+ OutRec* outrec = m_PolyOuts[i++];
+ OutPt* op = outrec->Pts;
+ if (!op) continue;
+ do //for each Pt in Polygon until duplicate found do ...
+ {
+ OutPt* op2 = op->Next;
+ while (op2 != outrec->Pts)
+ {
+ if ((op->Pt == op2->Pt) && op2->Next != op && op2->Prev != op)
+ {
+ //split the polygon into two ...
+ OutPt* op3 = op->Prev;
+ OutPt* op4 = op2->Prev;
+ op->Prev = op4;
+ op4->Next = op;
+ op2->Prev = op3;
+ op3->Next = op2;
+
+ outrec->Pts = op;
+ OutRec* outrec2 = CreateOutRec();
+ outrec2->Pts = op2;
+ UpdateOutPtIdxs(*outrec2);
+ if (Poly2ContainsPoly1(outrec2->Pts, outrec->Pts))
+ {
+ //OutRec2 is contained by OutRec1 ...
+ outrec2->IsHole = !outrec->IsHole;
+ outrec2->FirstLeft = outrec;
+ if (m_UsingPolyTree) FixupFirstLefts2(outrec2, outrec);
+ }
+ else
+ if (Poly2ContainsPoly1(outrec->Pts, outrec2->Pts))
+ {
+ //OutRec1 is contained by OutRec2 ...
+ outrec2->IsHole = outrec->IsHole;
+ outrec->IsHole = !outrec2->IsHole;
+ outrec2->FirstLeft = outrec->FirstLeft;
+ outrec->FirstLeft = outrec2;
+ if (m_UsingPolyTree) FixupFirstLefts2(outrec, outrec2);
+ }
+ else
+ {
+ //the 2 polygons are separate ...
+ outrec2->IsHole = outrec->IsHole;
+ outrec2->FirstLeft = outrec->FirstLeft;
+ if (m_UsingPolyTree) FixupFirstLefts1(outrec, outrec2);
+ }
+ op2 = op; //ie get ready for the Next iteration
+ }
+ op2 = op2->Next;
+ }
+ op = op->Next;
+ }
+ while (op != outrec->Pts);
+ }
+}
+//------------------------------------------------------------------------------
+
+void ReversePath(Path& p)
+{
+ std::reverse(p.begin(), p.end());
+}
+//------------------------------------------------------------------------------
+
+void ReversePaths(Paths& p)
+{
+ for (Paths::size_type i = 0; i < p.size(); ++i)
+ ReversePath(p[i]);
+}
+//------------------------------------------------------------------------------
+
+void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType)
+{
+ Clipper c;
+ c.StrictlySimple(true);
+ c.AddPath(in_poly, ptSubject, true);
+ c.Execute(ctUnion, out_polys, fillType, fillType);
+}
+//------------------------------------------------------------------------------
+
+void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType)
+{
+ Clipper c;
+ c.StrictlySimple(true);
+ c.AddPaths(in_polys, ptSubject, true);
+ c.Execute(ctUnion, out_polys, fillType, fillType);
+}
+//------------------------------------------------------------------------------
+
+void SimplifyPolygons(Paths &polys, PolyFillType fillType)
+{
+ SimplifyPolygons(polys, polys, fillType);
+}
+//------------------------------------------------------------------------------
+
+inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2)
+{
+ double Dx = ((double)pt1.X - pt2.X);
+ double dy = ((double)pt1.Y - pt2.Y);
+ return (Dx*Dx + dy*dy);
+}
+//------------------------------------------------------------------------------
+
+double DistanceFromLineSqrd(
+ const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2)
+{
+ //The equation of a line in general form (Ax + By + C = 0)
+ //given 2 points (x¹,y¹) & (x²,y²) is ...
+ //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0
+ //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹
+ //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²)
+ //see http://en.wikipedia.org/wiki/Perpendicular_distance
+ double A = double(ln1.Y - ln2.Y);
+ double B = double(ln2.X - ln1.X);
+ double C = A * ln1.X + B * ln1.Y;
+ C = A * pt.X + B * pt.Y - C;
+ return (C * C) / (A * A + B * B);
+}
+//---------------------------------------------------------------------------
+
+bool SlopesNearCollinear(const IntPoint& pt1,
+ const IntPoint& pt2, const IntPoint& pt3, double distSqrd)
+{
+ //this function is more accurate when the point that's geometrically
+ //between the other 2 points is the one that's tested for distance.
+ //ie makes it more likely to pick up 'spikes' ...
+ if (Abs(pt1.X - pt2.X) > Abs(pt1.Y - pt2.Y))
+ {
+ if ((pt1.X > pt2.X) == (pt1.X < pt3.X))
+ return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
+ else if ((pt2.X > pt1.X) == (pt2.X < pt3.X))
+ return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
+ else
+ return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
+ }
+ else
+ {
+ if ((pt1.Y > pt2.Y) == (pt1.Y < pt3.Y))
+ return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
+ else if ((pt2.Y > pt1.Y) == (pt2.Y < pt3.Y))
+ return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
+ else
+ return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
+ }
+}
+//------------------------------------------------------------------------------
+
+bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd)
+{
+ double Dx = (double)pt1.X - pt2.X;
+ double dy = (double)pt1.Y - pt2.Y;
+ return ((Dx * Dx) + (dy * dy) <= distSqrd);
+}
+//------------------------------------------------------------------------------
+
+OutPt* ExcludeOp(OutPt* op)
+{
+ OutPt* result = op->Prev;
+ result->Next = op->Next;
+ op->Next->Prev = result;
+ result->Idx = 0;
+ return result;
+}
+//------------------------------------------------------------------------------
+
+void CleanPolygon(const Path& in_poly, Path& out_poly, double distance)
+{
+ //distance = proximity in units/pixels below which vertices
+ //will be stripped. Default ~= sqrt(2).
+
+ size_t size = in_poly.size();
+
+ if (size == 0)
+ {
+ out_poly.clear();
+ return;
+ }
+
+ OutPt* outPts = new OutPt[size];
+ for (size_t i = 0; i < size; ++i)
+ {
+ outPts[i].Pt = in_poly[i];
+ outPts[i].Next = &outPts[(i + 1) % size];
+ outPts[i].Next->Prev = &outPts[i];
+ outPts[i].Idx = 0;
+ }
+
+ double distSqrd = distance * distance;
+ OutPt* op = &outPts[0];
+ while (op->Idx == 0 && op->Next != op->Prev)
+ {
+ if (PointsAreClose(op->Pt, op->Prev->Pt, distSqrd))
+ {
+ op = ExcludeOp(op);
+ size--;
+ }
+ else if (PointsAreClose(op->Prev->Pt, op->Next->Pt, distSqrd))
+ {
+ ExcludeOp(op->Next);
+ op = ExcludeOp(op);
+ size -= 2;
+ }
+ else if (SlopesNearCollinear(op->Prev->Pt, op->Pt, op->Next->Pt, distSqrd))
+ {
+ op = ExcludeOp(op);
+ size--;
+ }
+ else
+ {
+ op->Idx = 1;
+ op = op->Next;
+ }
+ }
+
+ if (size < 3) size = 0;
+ out_poly.resize(size);
+ for (size_t i = 0; i < size; ++i)
+ {
+ out_poly[i] = op->Pt;
+ op = op->Next;
+ }
+ delete [] outPts;
+}
+//------------------------------------------------------------------------------
+
+void CleanPolygon(Path& poly, double distance)
+{
+ CleanPolygon(poly, poly, distance);
+}
+//------------------------------------------------------------------------------
+
+void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance)
+{
+ for (Paths::size_type i = 0; i < in_polys.size(); ++i)
+ CleanPolygon(in_polys[i], out_polys[i], distance);
+}
+//------------------------------------------------------------------------------
+
+void CleanPolygons(Paths& polys, double distance)
+{
+ CleanPolygons(polys, polys, distance);
+}
+//------------------------------------------------------------------------------
+
+void Minkowski(const Path& poly, const Path& path,
+ Paths& solution, bool isSum, bool isClosed)
+{
+ int delta = (isClosed ? 1 : 0);
+ size_t polyCnt = poly.size();
+ size_t pathCnt = path.size();
+ Paths pp;
+ pp.reserve(pathCnt);
+ if (isSum)
+ for (size_t i = 0; i < pathCnt; ++i)
+ {
+ Path p;
+ p.reserve(polyCnt);
+ for (size_t j = 0; j < poly.size(); ++j)
+ p.push_back(IntPoint(path[i].X + poly[j].X, path[i].Y + poly[j].Y));
+ pp.push_back(p);
+ }
+ else
+ for (size_t i = 0; i < pathCnt; ++i)
+ {
+ Path p;
+ p.reserve(polyCnt);
+ for (size_t j = 0; j < poly.size(); ++j)
+ p.push_back(IntPoint(path[i].X - poly[j].X, path[i].Y - poly[j].Y));
+ pp.push_back(p);
+ }
+
+ solution.clear();
+ solution.reserve((pathCnt + delta) * (polyCnt + 1));
+ for (size_t i = 0; i < pathCnt - 1 + delta; ++i)
+ for (size_t j = 0; j < polyCnt; ++j)
+ {
+ Path quad;
+ quad.reserve(4);
+ quad.push_back(pp[i % pathCnt][j % polyCnt]);
+ quad.push_back(pp[(i + 1) % pathCnt][j % polyCnt]);
+ quad.push_back(pp[(i + 1) % pathCnt][(j + 1) % polyCnt]);
+ quad.push_back(pp[i % pathCnt][(j + 1) % polyCnt]);
+ if (!Orientation(quad)) ReversePath(quad);
+ solution.push_back(quad);
+ }
+}
+//------------------------------------------------------------------------------
+
+void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed)
+{
+ Minkowski(pattern, path, solution, true, pathIsClosed);
+ Clipper c;
+ c.AddPaths(solution, ptSubject, true);
+ c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
+}
+//------------------------------------------------------------------------------
+
+void TranslatePath(const Path& input, Path& output, IntPoint delta)
+{
+ //precondition: input != output
+ output.resize(input.size());
+ for (size_t i = 0; i < input.size(); ++i)
+ output[i] = IntPoint(input[i].X + delta.X, input[i].Y + delta.Y);
+}
+//------------------------------------------------------------------------------
+
+void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed)
+{
+ Clipper c;
+ for (size_t i = 0; i < paths.size(); ++i)
+ {
+ Paths tmp;
+ Minkowski(pattern, paths[i], tmp, true, pathIsClosed);
+ c.AddPaths(tmp, ptSubject, true);
+ if (pathIsClosed)
+ {
+ Path tmp2;
+ TranslatePath(paths[i], tmp2, pattern[0]);
+ c.AddPath(tmp2, ptClip, true);
+ }
+ }
+ c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
+}
+//------------------------------------------------------------------------------
+
+void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution)
+{
+ Minkowski(poly1, poly2, solution, false, true);
+ Clipper c;
+ c.AddPaths(solution, ptSubject, true);
+ c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
+}
+//------------------------------------------------------------------------------
+
+enum NodeType {ntAny, ntOpen, ntClosed};
+
+void AddPolyNodeToPaths(const PolyNode& polynode, NodeType nodetype, Paths& paths)
+{
+ bool match = true;
+ if (nodetype == ntClosed) match = !polynode.IsOpen();
+ else if (nodetype == ntOpen) return;
+
+ if (!polynode.Contour.empty() && match)
+ paths.push_back(polynode.Contour);
+ for (int i = 0; i < polynode.ChildCount(); ++i)
+ AddPolyNodeToPaths(*polynode.Childs[i], nodetype, paths);
+}
+//------------------------------------------------------------------------------
+
+void PolyTreeToPaths(const PolyTree& polytree, Paths& paths)
+{
+ paths.resize(0);
+ paths.reserve(polytree.Total());
+ AddPolyNodeToPaths(polytree, ntAny, paths);
+}
+//------------------------------------------------------------------------------
+
+void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths)
+{
+ paths.resize(0);
+ paths.reserve(polytree.Total());
+ AddPolyNodeToPaths(polytree, ntClosed, paths);
+}
+//------------------------------------------------------------------------------
+
+void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths)
+{
+ paths.resize(0);
+ paths.reserve(polytree.Total());
+ //Open paths are top level only, so ...
+ for (int i = 0; i < polytree.ChildCount(); ++i)
+ if (polytree.Childs[i]->IsOpen())
+ paths.push_back(polytree.Childs[i]->Contour);
+}
+//------------------------------------------------------------------------------
+
+std::ostream& operator <<(std::ostream &s, const IntPoint &p)
+{
+ s << "(" << p.X << "," << p.Y << ")";
+ return s;
+}
+//------------------------------------------------------------------------------
+
+std::ostream& operator <<(std::ostream &s, const Path &p)
+{
+ if (p.empty()) return s;
+ Path::size_type last = p.size() -1;
+ for (Path::size_type i = 0; i < last; i++)
+ s << "(" << p[i].X << "," << p[i].Y << "), ";
+ s << "(" << p[last].X << "," << p[last].Y << ")\n";
+ return s;
+}
+//------------------------------------------------------------------------------
+
+std::ostream& operator <<(std::ostream &s, const Paths &p)
+{
+ for (Paths::size_type i = 0; i < p.size(); i++)
+ s << p[i];
+ s << "\n";
+ return s;
+}
+//------------------------------------------------------------------------------
+
+#ifdef use_deprecated
+
+void OffsetPaths(const Paths &in_polys, Paths &out_polys,
+ double delta, JoinType jointype, EndType_ endtype, double limit)
+{
+ ClipperOffset co(limit, limit);
+ co.AddPaths(in_polys, jointype, (EndType)endtype);
+ co.Execute(out_polys, delta);
+}
+//------------------------------------------------------------------------------
+
+#endif
+
+
+} //ClipperLib namespace
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.hpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.hpp
new file mode 100644
index 00000000000..a00ce41b20d
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/clipper/clipper.hpp
@@ -0,0 +1,438 @@
+/*******************************************************************************
+* *
+* Author : Angus Johnson *
+* Version : 6.1.5 *
+* Date : 16 July 2014 *
+* Website : http://www.angusj.com *
+* Copyright : Angus Johnson 2010-2014 *
+* *
+* License: *
+* Use, modification & distribution is subject to Boost Software License Ver 1. *
+* http://www.boost.org/LICENSE_1_0.txt *
+* *
+* Attributions: *
+* The code in this library is an extension of Bala Vatti's clipping algorithm: *
+* "A generic solution to polygon clipping" *
+* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
+* http://portal.acm.org/citation.cfm?id=129906 *
+* *
+* Computer graphics and geometric modeling: implementation and algorithms *
+* By Max K. Agoston *
+* Springer; 1 edition (January 4, 2005) *
+* http://books.google.com/books?q=vatti+clipping+agoston *
+* *
+* See also: *
+* "Polygon Offsetting by Computing Winding Numbers" *
+* Paper no. DETC2005-85513 pp. 565-575 *
+* ASME 2005 International Design Engineering Technical Conferences *
+* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
+* September 24-28, 2005 , Long Beach, California, USA *
+* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
+* *
+*******************************************************************************/
+
+#ifndef clipper_hpp
+#define clipper_hpp
+
+#define CLIPPER_VERSION "6.1.5"
+
+//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
+//improve performance but coordinate values are limited to the range +/- 46340
+//#define use_int32
+
+//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
+#define use_xyz
+
+//use_lines: Enables line clipping. Adds a very minor cost to performance.
+#define use_lines
+
+//use_deprecated: Enables support for the obsolete OffsetPaths() function
+//which has been replace with the ClipperOffset class.
+//#define use_deprecated
+
+#include <vector>
+#include <set>
+#include <stdexcept>
+#include <cstring>
+#include <cstdlib>
+#include <ostream>
+#include <functional>
+#include <queue>
+#include "../src/types.h"
+
+namespace ClipperLib {
+
+enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
+enum PolyType { ptSubject, ptClip };
+//By far the most widely used winding rules for polygon filling are
+//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
+//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
+//see http://glprogramming.com/red/chapter11.html
+enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
+
+struct ZLabel {
+ ZLabel () : id(0), t(0) {}
+ ZLabel (Int32 ii) : id(ii), t(0) {}
+ ZLabel (Int32 ii, double tt) : id(ii), t(tt) {}
+ bool operator == (const ZLabel &l) const {return id == l.id;}
+ Int32 id;
+ double t;
+};
+
+inline std::ostream& operator << (std::ostream &os, const ZLabel &l) {
+ return os << l.id << ':' << l.t;
+}
+
+struct ZType {
+ ZType (UInt64 v) : label1(v >> 32), label2(v & 0xffffffff) {}
+ ZType (Int32 id1, Int32 id2) : label1(id1), label2(id2) {}
+ ZType (const ZLabel &l1, const ZLabel &l2) : label1(l1), label2(l2) {}
+ const ZLabel& minLabel () const {return (label1.id < label2.id) ? label1 : label2;}
+ const ZLabel& maxLabel () const {return (label1.id > label2.id) ? label1 : label2;}
+
+ const ZLabel& otherLabel (const ZLabel &l) const {
+ return (l.id == label1.id && l.t == label1.t) ? label2 : label1;
+ }
+
+ bool operator == (const ZType &p) const {return minLabel() == p.minLabel() && maxLabel() == p.maxLabel();}
+ operator UInt64 () const {return (UInt64(label1.id) << 32) & label2.id;}
+ ZLabel label1, label2;
+};
+
+inline std::ostream& operator << (std::ostream &os, const ZType &z) {
+ return os << '[' << z.label1 << '|' << z.label2 << ']';
+}
+
+#ifdef use_int32
+ typedef int cInt;
+ static cInt const loRange = 46340;
+ static cInt const hiRange = 46340;
+#else
+ typedef Int64 cInt;
+ static cInt const loRange = 0x3FFFFFFF;
+ static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
+ typedef signed long long long64; //used by Int128 class
+ typedef unsigned long long ulong64;
+
+#endif
+
+struct IntPoint {
+ cInt X;
+ cInt Y;
+#ifdef use_xyz
+ ZType Z;
+ IntPoint(cInt x = 0, cInt y = 0, ZType z = 0): X(x), Y(y), Z(z) {};
+#else
+ IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
+#endif
+
+ friend inline bool operator== (const IntPoint& a, const IntPoint& b)
+ {
+ return a.X == b.X && a.Y == b.Y;
+ }
+ friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
+ {
+ return a.X != b.X || a.Y != b.Y;
+ }
+};
+//------------------------------------------------------------------------------
+
+typedef std::vector< IntPoint > Path;
+typedef std::vector< Path > Paths;
+
+inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
+inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
+
+std::ostream& operator <<(std::ostream &s, const IntPoint &p);
+std::ostream& operator <<(std::ostream &s, const Path &p);
+std::ostream& operator <<(std::ostream &s, const Paths &p);
+
+struct DoublePoint
+{
+ double X;
+ double Y;
+ DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {}
+ DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {}
+};
+//------------------------------------------------------------------------------
+
+#ifdef use_xyz
+typedef void (*TZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
+#endif
+
+enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
+enum JoinType {jtSquare, jtRound, jtMiter};
+enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
+#ifdef use_deprecated
+ enum EndType_ {etClosed, etButt = 2, etSquare, etRound};
+#endif
+
+class PolyNode;
+typedef std::vector< PolyNode* > PolyNodes;
+
+class PolyNode
+{
+public:
+ PolyNode();
+ virtual ~PolyNode () {}
+ Path Contour;
+ PolyNodes Childs;
+ PolyNode* Parent;
+ PolyNode* GetNext() const;
+ bool IsHole() const;
+ bool IsOpen() const;
+ int ChildCount() const;
+private:
+ unsigned Index; //node index in Parent.Childs
+ bool m_IsOpen;
+ JoinType m_jointype;
+ EndType m_endtype;
+ PolyNode* GetNextSiblingUp() const;
+ void AddChild(PolyNode& child);
+ friend class Clipper; //to access Index
+ friend class ClipperOffset;
+};
+
+class PolyTree: public PolyNode
+{
+public:
+ ~PolyTree(){Clear();};
+ PolyNode* GetFirst() const;
+ void Clear();
+ int Total() const;
+private:
+ PolyNodes AllNodes;
+ friend class Clipper; //to access AllNodes
+};
+
+bool Orientation(const Path &poly);
+double Area(const Path &poly);
+int PointInPolygon(const IntPoint &pt, const Path &path);
+
+#ifdef use_deprecated
+ void OffsetPaths(const Paths &in_polys, Paths &out_polys,
+ double delta, JoinType jointype, EndType_ endtype, double limit = 0);
+#endif
+
+void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
+void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
+void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
+
+void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
+void CleanPolygon(Path& poly, double distance = 1.415);
+void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
+void CleanPolygons(Paths& polys, double distance = 1.415);
+
+void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
+void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
+void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
+
+void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
+void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
+void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
+
+void ReversePath(Path& p);
+void ReversePaths(Paths& p);
+
+struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
+
+//enums that are used internally ...
+enum EdgeSide { esLeft = 1, esRight = 2};
+
+//forward declarations (for stuff used internally) ...
+struct TEdge;
+struct IntersectNode;
+struct LocalMinimum;
+struct Scanbeam;
+struct OutPt;
+struct OutRec;
+struct Join;
+
+typedef std::vector < OutRec* > PolyOutList;
+typedef std::vector < TEdge* > EdgeList;
+typedef std::vector < Join* > JoinList;
+typedef std::vector < IntersectNode* > IntersectList;
+
+//------------------------------------------------------------------------------
+
+//ClipperBase is the ancestor to the Clipper class. It should not be
+//instantiated directly. This class simply abstracts the conversion of sets of
+//polygon coordinates into edge objects that are stored in a LocalMinima list.
+class ClipperBase
+{
+public:
+ ClipperBase();
+ virtual ~ClipperBase();
+ bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
+ bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
+ virtual void Clear();
+ IntRect GetBounds();
+ bool PreserveCollinear() {return m_PreserveCollinear;};
+ void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
+protected:
+ void DisposeLocalMinimaList();
+ TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
+ void PopLocalMinima();
+ virtual void Reset();
+ TEdge* ProcessBound(TEdge* E, bool IsClockwise);
+ void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed);
+ TEdge* DescendToMin(TEdge *&E);
+ void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
+
+ typedef std::vector<LocalMinimum> MinimaList;
+ MinimaList::iterator m_CurrentLM;
+ MinimaList m_MinimaList;
+
+ bool m_UseFullRange;
+ EdgeList m_edges;
+ bool m_PreserveCollinear;
+ bool m_HasOpenPaths;
+};
+//------------------------------------------------------------------------------
+
+class Clipper : public virtual ClipperBase
+{
+public:
+ Clipper(int initOptions = 0);
+ ~Clipper();
+ bool Execute(ClipType clipType,
+ Paths &solution,
+ PolyFillType subjFillType = pftEvenOdd,
+ PolyFillType clipFillType = pftEvenOdd);
+ bool Execute(ClipType clipType,
+ PolyTree &polytree,
+ PolyFillType subjFillType = pftEvenOdd,
+ PolyFillType clipFillType = pftEvenOdd);
+ bool ReverseSolution() {return m_ReverseOutput;};
+ void ReverseSolution(bool value) {m_ReverseOutput = value;};
+ bool StrictlySimple() {return m_StrictSimple;};
+ void StrictlySimple(bool value) {m_StrictSimple = value;};
+ //set the callback function for z value filling on intersections (otherwise Z is 0)
+#ifdef use_xyz
+ void ZFillFunction(TZFillCallback zFillFunc);
+#endif
+protected:
+ void Reset();
+ virtual bool ExecuteInternal();
+private:
+ PolyOutList m_PolyOuts;
+ JoinList m_Joins;
+ JoinList m_GhostJoins;
+ IntersectList m_IntersectList;
+ ClipType m_ClipType;
+ typedef std::priority_queue<cInt> ScanbeamList;
+ ScanbeamList m_Scanbeam;
+ TEdge *m_ActiveEdges;
+ TEdge *m_SortedEdges;
+ bool m_ExecuteLocked;
+ PolyFillType m_ClipFillType;
+ PolyFillType m_SubjFillType;
+ bool m_ReverseOutput;
+ bool m_UsingPolyTree;
+ bool m_StrictSimple;
+#ifdef use_xyz
+ TZFillCallback m_ZFill; //custom callback
+#endif
+ void SetWindingCount(TEdge& edge);
+ bool IsEvenOddFillType(const TEdge& edge) const;
+ bool IsEvenOddAltFillType(const TEdge& edge) const;
+ void InsertScanbeam(const cInt Y);
+ cInt PopScanbeam();
+ void InsertLocalMinimaIntoAEL(const cInt botY);
+ void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
+ void AddEdgeToSEL(TEdge *edge);
+ void CopyAELToSEL();
+ void DeleteFromSEL(TEdge *e);
+ void DeleteFromAEL(TEdge *e);
+ void UpdateEdgeIntoAEL(TEdge *&e);
+ void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
+ bool IsContributing(const TEdge& edge) const;
+ bool IsTopHorz(const cInt XPos);
+ void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
+ void DoMaxima(TEdge *e);
+ void ProcessHorizontals(bool IsTopOfScanbeam);
+ void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam);
+ void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
+ OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
+ OutRec* GetOutRec(int idx);
+ void AppendPolygon(TEdge *e1, TEdge *e2);
+ void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
+ OutRec* CreateOutRec();
+ OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
+ void DisposeAllOutRecs();
+ void DisposeOutRec(PolyOutList::size_type index);
+ bool ProcessIntersections(const cInt botY, const cInt topY);
+ void BuildIntersectList(const cInt botY, const cInt topY);
+ void ProcessIntersectList();
+ void ProcessEdgesAtTopOfScanbeam(const cInt topY);
+ void BuildResult(Paths& polys);
+ void BuildResult2(PolyTree& polytree);
+ void SetHoleState(TEdge *e, OutRec *outrec);
+ void DisposeIntersectNodes();
+ bool FixupIntersectionOrder();
+ void FixupOutPolygon(OutRec &outrec);
+ bool IsHole(TEdge *e);
+ bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
+ void FixHoleLinkage(OutRec &outrec);
+ void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
+ void ClearJoins();
+ void ClearGhostJoins();
+ void AddGhostJoin(OutPt *op, const IntPoint offPt);
+ bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
+ void JoinCommonEdges();
+ void DoSimplePolygons();
+ void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
+ void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
+#ifdef use_xyz
+ void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
+#endif
+};
+//------------------------------------------------------------------------------
+
+class ClipperOffset
+{
+public:
+ ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
+ ~ClipperOffset();
+ void AddPath(const Path& path, JoinType joinType, EndType endType);
+ void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
+ void Execute(Paths& solution, double delta);
+ void Execute(PolyTree& solution, double delta);
+ void Clear();
+ double MiterLimit;
+ double ArcTolerance;
+private:
+ Paths m_destPolys;
+ Path m_srcPoly;
+ Path m_destPoly;
+ std::vector<DoublePoint> m_normals;
+ double m_delta, m_sinA, m_sin, m_cos;
+ double m_miterLim, m_StepsPerRad;
+ IntPoint m_lowest;
+ PolyNode m_polyNodes;
+
+ void FixOrientations();
+ void DoOffset(double delta);
+ void OffsetPoint(int j, int& k, JoinType jointype);
+ void DoSquare(int j, int k);
+ void DoMiter(int j, int k, double r);
+ void DoRound(int j, int k);
+};
+//------------------------------------------------------------------------------
+
+class clipperException : public std::exception
+{
+ public:
+ clipperException(const char* description): m_descr(description) {}
+ virtual ~clipperException() throw() {}
+ virtual const char* what() const throw() {return m_descr.c_str();}
+ private:
+ std::string m_descr;
+};
+//------------------------------------------------------------------------------
+
+} //ClipperLib namespace
+
+#endif //clipper_hpp
+
+
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/config.h.in b/Build/source/texk/dvisvgm/dvisvgm-1.8/config.h.in
index fcd8cf41872..fcd8cf41872 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/config.h.in
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/config.h.in
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/configure.ac b/Build/source/texk/dvisvgm/dvisvgm-1.8/configure.ac
index 95df7c0c223..f867c8754be 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/configure.ac
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/configure.ac
@@ -4,8 +4,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([dvisvgm],[1.7],[martin.gieseking@uos.de])
-DATE="June 2014"
+AC_INIT([dvisvgm],[1.8],[martin.gieseking@uos.de])
+DATE="July 2014"
AC_CONFIG_SRCDIR(src)
AC_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
@@ -146,6 +146,7 @@ if test "$withval" != no; then
fi
fi
+
# Check if the kpathsea headers are C++ safe
AC_MSG_CHECKING([if the kpathsea headers are C++ safe])
AC_LANG_PUSH([C++])
@@ -161,6 +162,6 @@ AC_SUBST(DATE)
AC_SUBST(EXTRA_LIBS)
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_LDFLAGS)
-AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/dvisvgm.txt doc/Makefile])
+AC_CONFIG_FILES([Makefile clipper/Makefile src/Makefile tests/Makefile doc/dvisvgm.txt doc/Makefile])
AC_OUTPUT
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/Makefile.am
index 13254cb773a..13254cb773a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/Makefile.am
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/Makefile.am
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/README b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/README
new file mode 100644
index 00000000000..4ceb62ce402
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/README
@@ -0,0 +1,16 @@
+dvisvgm-1.7 (2014-06-18)
+- all DVI files are pre-processed now to allow the implementation of
+ advanced features that rely on data not available on the pages being
+ converted
+- added support for internal hyperref links across pages
+- added \special command dvisvgm:rawdef to insert raw SVG fragments to
+ the <defs> section
+- added the new \special commands dvisvgm:rawset, dvisvgm:endrawset, and
+ dvisvgm:rawput to assign and access a sequence of SVG fragments via an
+ identifier (LP feature request #1215878)
+- removed redundant <missing-glyph> elements from SVG files
+- fixed support of external fonts containing characters not mapped by the
+ embedded unicode tables (LP bug #1276689)
+- fixed incorrect extent values shown in conjunction with the preview package
+- many refactorings and code improvements
+
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.1 b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.1
index bcacdfcd0c8..0aa592262ae 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.1
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.1
@@ -2,12 +2,12 @@
.\" Title: dvisvgm
.\" Author: Martin Gieseking <martin.gieseking@uos.de>
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 06/18/2014
+.\" Date: 07/29/2014
.\" Manual: dvisvgm Manual
-.\" Source: dvisvgm 1.7
+.\" Source: dvisvgm 1.8
.\" Language: English
.\"
-.TH "DVISVGM" "1" "06/18/2014" "dvisvgm 1\&.7" "dvisvgm Manual"
+.TH "DVISVGM" "1" "07/29/2014" "dvisvgm 1\&.8" "dvisvgm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -185,6 +185,15 @@ to overwrite the default\&. Furthermore, it is also possible to disable the font
is omitted, dvisvgm prints the path of the default cache directory together with further information about the stored fonts\&. Additionally, outdated and corrupted cache files are removed\&.
.RE
.PP
+\fB\-j, \-\-clipjoin\fR
+.RS 4
+This option tells dvisvgm to compute the intersection of clipping paths itself if necessary, and not to delegate this task to the SVG renderer\&. The resulting SVG files are more portable because some SVG renderers don\(cqt support intersections of clipping paths which are defined by
+\fIclipPath\fR
+elements that contain a
+\fIclip\-path\fR
+attribute\&.
+.RE
+.PP
\fB\-\-color\fR
.RS 4
Enables colorization of messages printed during the conversion process\&. The colors can be customized via the environment variable
@@ -436,6 +445,13 @@ degrees around the page center\&. This option is equivalent to
\fB\-TR\fR\fIangle\fR\&.
.RE
.PP
+\fB\-R, \-\-relative\fR
+.RS 4
+SVG allows to define graphics paths by a sequence of absolute and/or relative commands, i\&.e\&. each command expects either absolute coordinates or coordinates relative to the current drawing position\&. By default, dvisvgm creates paths made up of absolute commands\&. If option
+\fB\-\-relative\fR
+is given, relative commands are created instead which slightly reduces the size of the SVG files in most cases\&.
+.RE
+.PP
\fB\-s, \-\-stdout\fR
.RS 4
Don\(cqt write the SVG output to a file but redirect it to
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.txt.in b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.txt.in
index 29c4ce750b0..173b0e5d39a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/doc/dvisvgm.txt.in
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/doc/dvisvgm.txt.in
@@ -137,6 +137,13 @@ dvisvgm prints the path of the default cache directory together with further inf
Additionally, outdated and corrupted cache files are removed.
+*-j, --clipjoin*::
+This option tells dvisvgm to compute the intersection of clipping paths itself if necessary,
+and not to delegate this task to the SVG renderer. The resulting SVG files are more portable
+because some SVG renderers don't support intersections of clipping paths which are defined by
+'clipPath' elements that contain a 'clip-path' attribute.
+
+
*--color*::
Enables colorization of messages printed during the conversion process. The colors can be customized
via the environment variable +DVISVGM_COLORS+. See the ENVIRONMENT section below for further information.
@@ -329,6 +336,14 @@ Rotates the page content clockwise by 'angle' degrees around the page center.
This option is equivalent to *-TR*'angle'.
+*-R, --relative*::
+SVG allows to define graphics paths by a sequence of absolute and/or relative commands,
+i.e. each command expects either absolute coordinates or coordinates relative to the
+current drawing position. By default, dvisvgm creates paths made up of absolute commands.
+If option *--relative* is given, relative commands are created instead which slightly reduces
+the size of the SVG files in most cases.
+
+
*-s, --stdout*::
Don't write the SVG output to a file but redirect it to *stdout*.
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.cpp
index 155e729c2e9..155e729c2e9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.h
index 0b810f6c1cd..0b810f6c1cd 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BasicDVIReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BasicDVIReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.cpp
new file mode 100644
index 00000000000..10201fa5062
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.cpp
@@ -0,0 +1,188 @@
+/*************************************************************************
+** Bezier.cpp **
+** **
+** This file is part of dvisvgm -- the DVI to SVG converter **
+** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include <utility>
+#include "Bezier.h"
+
+using namespace std;
+
+Bezier::Bezier () {
+ _points[0] = _points[1] = _points[2] = _points[3] = 0;
+}
+
+
+/** Creates a quadratic Bézier curve. internally, it's represented as a cubic one. */
+Bezier::Bezier (const DPair &p0, const DPair &p1, const DPair &p2) {
+ _points[0] = p0;
+ _points[1] = p0+(p1-p0)*2.0/3.0;
+ _points[2] = p2+(p1-p2)*2.0/3.0;
+ _points[3] = p2;
+}
+
+
+Bezier::Bezier (const DPair &p0, const DPair &p1, const DPair &p2, const DPair &p3) {
+ _points[0] = p0;
+ _points[1] = p1;
+ _points[2] = p2;
+ _points[3] = p3;
+}
+
+
+/** Creates a subcurve of a given Bézier curve.
+ * @param[in] source original curve to be clipped
+ * @param[in] t0 'time' parameter \f$\in[0,1]\f$ of source curve where the subcurve starts
+ * @param[in] t1 'time' parameter \f$\in[0,1]\f$ of source curve where the subcurve ends */
+Bezier::Bezier (const Bezier &source, double t0, double t1) {
+ if (t0 == t1)
+ _points[0] = _points[1] = _points[2] = _points[3] = source.pointAt(t0);
+ else {
+ if (t0 > t1)
+ swap(t0, t1);
+ if (t0 == 0)
+ source.subdivide(t1, this, 0);
+ else if (t1 == 1)
+ source.subdivide(t0, 0, this);
+ else {
+ Bezier subcurve;
+ source.subdivide(t0, 0, &subcurve);
+ subcurve.subdivide((t1-t0)/(1-t0), this, 0);
+ }
+ }
+}
+
+
+void Bezier::reverse() {
+ swap(_points[0], _points[3]);
+ swap(_points[1], _points[2]);
+}
+
+
+DPair Bezier::pointAt (double t) const {
+ const double s = 1-t;
+ return _points[0]*s*s*s + _points[1]*3.0*s*s*t + _points[2]*3.0*s*t*t + _points[3]*t*t*t;
+}
+
+
+/** Splits the curve at t into two sub-curves. */
+void Bezier::subdivide (double t, Bezier *bezier1, Bezier *bezier2) const {
+ const double s = 1-t;
+ DPair p01 = _points[0]*s + _points[1]*t;
+ DPair p12 = _points[1]*s + _points[2]*t;
+ DPair p23 = _points[2]*s + _points[3]*t;
+ DPair p012 = p01*s + p12*t;
+ DPair p123 = p12*s + p23*t;
+ DPair p0123 = p012*s + p123*t;
+ if (bezier1) {
+ bezier1->_points[0] = _points[0];
+ bezier1->_points[1] = p01;
+ bezier1->_points[2] = p012;
+ bezier1->_points[3] = p0123;
+ }
+ if (bezier2) {
+ bezier2->_points[0] = p0123;
+ bezier2->_points[1] = p123;
+ bezier2->_points[2] = p23;
+ bezier2->_points[3] = _points[3];
+ }
+}
+
+
+/** Approximates the current Bézier curve by a sequence of line segments.
+ * This is done by subdividing the curve several times using De Casteljau's algorithm.
+ * If a sub-curve is almost flat, i.e. \f$\sum\limits_{k=0}^2 |p_{k+1}-p_k| - |p_3-p_0| < \delta\f$,
+ * the curve is not further subdivided.
+ * @param[in] delta threshold where to stop further subdivisions (see description above)
+ * @param[out] p the resulting sequence of points defining the start/end points of the line segments
+ * @param[out] t corresponding curve parameters of the approximated points p: \f$ b(t_i)=p_i \f$
+ * @return number of points in vector p */
+int Bezier::approximate (double delta, std::vector<DPair> &p, vector<double> *t) const {
+ p.push_back(_points[0]);
+ if (t)
+ t->push_back(0);
+ return approximate(delta, 0, 1, p, t);
+}
+
+
+int Bezier::approximate (double delta, double t0, double t1, vector<DPair> &p, vector<double> *t) const {
+ // compute distance of adjacent control points
+ const double l01 = (_points[1]-_points[0]).length();
+ const double l12 = (_points[2]-_points[1]).length();
+ const double l23 = (_points[3]-_points[2]).length();
+ const double l03 = (_points[3]-_points[0]).length();
+ if (l01+l12+l23-l03 < delta) { // is curve flat enough?
+ p.push_back(_points[3]); // => store endpoint
+ if (t)
+ t->push_back(t1);
+ }
+ else {
+ // subdivide curve at b(0.5) and approximate the resulting parts separately
+ Bezier b1, b2;
+ subdivide(0.5, &b1, &b2);
+ double tmid = (t0+t1)/2;
+ b1.approximate(delta, t0, tmid, p, t);
+ b2.approximate(delta, tmid, t1, p, t);
+ }
+ return p.size();
+}
+
+
+static inline double signed_area (const DPair &p1, const DPair &p2, const DPair &p3) {
+ return (p2.x()-p1.x())*(p3.y()-p1.y()) - (p3.x()-p1.x())*(p2.y()-p1.y());
+}
+
+
+static inline double dot_prod (const DPair &p1, const DPair &p2) {
+ return p1.x()*p2.x() + p1.y()*p2.y();
+}
+
+
+static bool between (const DPair &p1, const DPair &p2, const DPair &p3, double delta) {
+ if (fabs(signed_area(p1, p2, p3)) < delta) {
+ double dotp = dot_prod(p2-p1, p3-p1);
+ return dotp > 0 && dotp < dot_prod(p2-p1, p2-p1);
+ }
+ return false;
+}
+
+
+static inline bool near (const DPair &p1, const DPair &p2, double delta) {
+ DPair diff = p2-p1;
+ return fabs(diff.x()) < delta && fabs(diff.y()) < delta;
+}
+
+
+int Bezier::reduceDegree (double delta, vector<DPair> &p) const {
+ if (near(_points[0], _points[1], delta) && near(_points[0], _points[2], delta) && near(_points[0], _points[3], delta))
+ p.push_back(_points[0]);
+ else if (between(_points[0], _points[1], _points[3], delta) && between(_points[0], _points[2], _points[3], delta)) {
+ p.push_back(_points[1]);
+ p.push_back(_points[3]);
+ }
+ else if (near((_points[1]-_points[0])*1.5+_points[0], (_points[2]-_points[3])*1.5+_points[3], delta)) {
+ p.push_back(_points[0]);
+ p.push_back((_points[1]-_points[0])*1.5 + _points[0]);
+ p.push_back(_points[3]);
+ }
+ else {
+ for (int i=0; i < 4; i++)
+ p.push_back(p[i]);
+ }
+ return p.size()-1;
+}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.h
new file mode 100644
index 00000000000..ee763ede172
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bezier.h
@@ -0,0 +1,48 @@
+/*************************************************************************
+** Bezier.h **
+** **
+** This file is part of dvisvgm -- the DVI to SVG converter **
+** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#ifndef DVISVGM_BEZIER_H
+#define DVISVGM_BEZIER_H
+
+#include <vector>
+#include "Pair.h"
+
+class Bezier
+{
+ public:
+ Bezier (const DPair &p0, const DPair &p1, const DPair &p2);
+ Bezier (const DPair &p0, const DPair &p1, const DPair &p2, const DPair &p3);
+ Bezier (const Bezier &source, double t0, double t1);
+ void reverse ();
+ DPair pointAt (double t) const;
+ void subdivide (double t, Bezier *bezier1, Bezier *bezier2) const;
+ int approximate (double delta, std::vector<DPair> &p, std::vector<double> *t=0) const;
+ const DPair& point (int i) const {return _points[i];}
+ int reduceDegree (double delta, std::vector<DPair> &p) const;
+
+ protected:
+ Bezier ();
+ int approximate (double delta, double t0, double t1, std::vector<DPair> &p, std::vector<double> *t) const;
+
+ private:
+ DPair _points[4];
+};
+
+#endif
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.cpp
index dd19e4b5f53..dd19e4b5f53 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.h
index edd764e86b2..edd764e86b2 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BgColorSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BgColorSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.cpp
index 265533b1ef5..265533b1ef5 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.h
index 0883688bd9a..0883688bd9a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Bitmap.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Bitmap.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.cpp
index f6c5d0b3b9b..f6c5d0b3b9b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.h
index 6d38edf6e3b..6d38edf6e3b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/BoundingBox.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/BoundingBox.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.cpp
index 6b940300f8e..6b940300f8e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.h
index 324c51800fa..324c51800fa 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMap.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMap.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.cpp
index eb73d72f3c4..eb73d72f3c4 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.h
index 6918ed93e98..6918ed93e98 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapManager.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapManager.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.cpp
index 502e42ef2e0..502e42ef2e0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.h
index d9567e79433..d9567e79433 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CMapReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CMapReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.cpp
index 3f85710c6b7..3f85710c6b7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.h
index 35cd4d4399a..35cd4d4399a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CRC32.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CRC32.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.cpp
index 12a35a35edd..12a35a35edd 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.h
index fdd4ed177d5..fdd4ed177d5 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Calculator.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Calculator.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.cpp
index 4c15abde98f..4c15abde98f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.h
index acc1a8482de..acc1a8482de 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CharMapID.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CharMapID.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Character.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Character.h
index a9d0f6a2d6d..a9d0f6a2d6d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Character.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Character.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.cpp
index 2c8d133cc97..2c8d133cc97 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.h
index 855186f9d4b..855186f9d4b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CmdLineParserBase.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CmdLineParserBase.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.cpp
index 94514c292a7..94514c292a7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.h
index 99d847560e0..99d847560e0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Color.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Color.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.cpp
index 937c0f42877..937c0f42877 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.h
index 6e7b0edf0f3..6e7b0edf0f3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ColorSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ColorSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.cpp
index 3147ea61c49..9395e9b770b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.cpp
@@ -16,6 +16,7 @@ using namespace std;
const CmdLineParserBase::Option CommandLine::_options[] = {
{'b', "bbox", ARG_REQUIRED, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_bbox)},
{'C', "cache", ARG_OPTIONAL, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_cache)},
+ {'j', "clipjoin", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_clipjoin)},
{'\0', "color", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_color)},
#if !defined(DISABLE_GS)
{'E', "eps", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_eps)},
@@ -38,6 +39,7 @@ const CmdLineParserBase::Option CommandLine::_options[] = {
{'p', "page", ARG_REQUIRED, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_page)},
{'d', "precision", ARG_REQUIRED, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_precision)},
{'P', "progress", ARG_OPTIONAL, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_progress)},
+ {'R', "relative", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_relative)},
{'r', "rotate", ARG_REQUIRED, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_rotate)},
{'c', "scale", ARG_REQUIRED, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_scale)},
{'s', "stdout", ARG_NONE, new OptionHandlerImpl<CommandLine>(&CommandLine::handle_stdout)},
@@ -61,6 +63,7 @@ void CommandLine::init () {
// disable all options by default
_bbox_given = false;
_cache_given = false;
+ _clipjoin_given = false;
_color_given = false;
#if !defined(DISABLE_GS)
_eps_given = false;
@@ -83,6 +86,7 @@ void CommandLine::init () {
_page_given = false;
_precision_given = false;
_progress_given = false;
+ _relative_given = false;
_rotate_given = false;
_scale_given = false;
_stdout_given = false;
@@ -132,9 +136,11 @@ const char** CommandLine::helplines (size_t *numlines) const {
#endif
"sSVG output options:",
"o-b, --bbox=size set size of bounding box [min]",
+ "o-j, --clipjoin compute intersection of clipping paths",
"o-L, --linkmark=style select how to mark hyperlinked areas [box]",
"o-o, --output=pattern set name pattern of output files",
"o-d, --precision=number set number of decimal points (0-6) [0]",
+ "o-R, --relative create relative path commands",
"o-s, --stdout write SVG output to stdout",
"o-n, --no-fonts[=variant] draw glyphs by using path elements [0]",
"o --no-styles don't use styles to reference fonts",
@@ -178,6 +184,10 @@ void CommandLine::handle_cache (InputReader &ir, const Option &opt, bool longopt
_cache_given = true;
}
+void CommandLine::handle_clipjoin (InputReader &ir, const Option &opt, bool longopt) {
+ _clipjoin_given = true;
+}
+
void CommandLine::handle_color (InputReader &ir, const Option &opt, bool longopt) {
_color_given = true;
}
@@ -265,6 +275,10 @@ void CommandLine::handle_progress (InputReader &ir, const Option &opt, bool long
_progress_given = true;
}
+void CommandLine::handle_relative (InputReader &ir, const Option &opt, bool longopt) {
+ _relative_given = true;
+}
+
void CommandLine::handle_rotate (InputReader &ir, const Option &opt, bool longopt) {
if (getDoubleArg(ir, opt, longopt, _rotate_arg))
_rotate_given = true;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.h
index 3ec040a6d88..9c86e2feb9c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/CommandLine.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/CommandLine.h
@@ -19,6 +19,7 @@ class CommandLine : public CmdLineParserBase
const std::string& bbox_arg () const {return _bbox_arg;}
bool cache_given () const {return _cache_given;}
const std::string& cache_arg () const {return _cache_arg;}
+ bool clipjoin_given () const {return _clipjoin_given;}
bool color_given () const {return _color_given;}
#if !defined(DISABLE_GS)
bool eps_given () const {return _eps_given;}
@@ -52,6 +53,7 @@ class CommandLine : public CmdLineParserBase
int precision_arg () const {return _precision_arg;}
bool progress_given () const {return _progress_given;}
double progress_arg () const {return _progress_arg;}
+ bool relative_given () const {return _relative_given;}
bool rotate_given () const {return _rotate_given;}
double rotate_arg () const {return _rotate_arg;}
bool scale_given () const {return _scale_given;}
@@ -77,6 +79,7 @@ class CommandLine : public CmdLineParserBase
const char** helplines (size_t *numlines) const;
void handle_bbox (InputReader &ir, const Option &opt, bool longopt);
void handle_cache (InputReader &ir, const Option &opt, bool longopt);
+ void handle_clipjoin (InputReader &ir, const Option &opt, bool longopt);
void handle_color (InputReader &ir, const Option &opt, bool longopt);
#if !defined(DISABLE_GS)
void handle_eps (InputReader &ir, const Option &opt, bool longopt);
@@ -99,6 +102,7 @@ class CommandLine : public CmdLineParserBase
void handle_page (InputReader &ir, const Option &opt, bool longopt);
void handle_precision (InputReader &ir, const Option &opt, bool longopt);
void handle_progress (InputReader &ir, const Option &opt, bool longopt);
+ void handle_relative (InputReader &ir, const Option &opt, bool longopt);
void handle_rotate (InputReader &ir, const Option &opt, bool longopt);
void handle_scale (InputReader &ir, const Option &opt, bool longopt);
void handle_stdout (InputReader &ir, const Option &opt, bool longopt);
@@ -116,6 +120,7 @@ class CommandLine : public CmdLineParserBase
std::string _bbox_arg;
bool _cache_given;
std::string _cache_arg;
+ bool _clipjoin_given;
bool _color_given;
#if !defined(DISABLE_GS)
bool _eps_given;
@@ -149,6 +154,7 @@ class CommandLine : public CmdLineParserBase
int _precision_arg;
bool _progress_given;
double _progress_arg;
+ bool _relative_given;
bool _rotate_given;
double _rotate_arg;
bool _scale_given;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.cpp
index 8f03d1a0b83..8f03d1a0b83 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.h
index de14be50495..de14be50495 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DLLoader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DLLoader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIActions.h
index 7a82d4456f1..7a82d4456f1 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIActions.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIActions.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.cpp
index 925efe0407b..925efe0407b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.h
index 366a110f531..366a110f531 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.cpp
index d4252961b11..d4252961b11 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.h
index 297aa5a1620..39f335a2907 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVG.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVG.h
@@ -37,11 +37,11 @@ class DVIToSVG : public DVIReader
DVIToSVG (std::istream &is, SVGOutputBase &out);
~DVIToSVG ();
void convert (const std::string &range, std::pair<int,int> *pageinfo=0);
- void setProcessSpecials (const char *ignorelist=0, bool pswarning=false);
void setPageSize (const std::string &name) {_bboxString = name;}
void setPageTransformation (const std::string &cmds) {_transCmds = cmds;}
void getPageTransformation (Matrix &matrix) const;
std::string getSVGFilename (unsigned pageno) const;
+ static void setProcessSpecials (const char *ignorelist=0, bool pswarning=false);
public:
static char TRACE_MODE;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.cpp
index ca716bf88f5..ca716bf88f5 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.h
index 72b61f7f0e2..2980fa2c657 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DVIToSVGActions.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DVIToSVGActions.h
@@ -66,7 +66,7 @@ class DVIToSVGActions : public DVIActions, public SpecialActions
void moveToX (double x);
void moveToY (double y);
void setFont (int num, const Font *font);
- void special (const std::string &s, double dvi2bp, bool preprocessing=false);
+ void special (const std::string &spc, double dvi2bp, bool preprocessing=false);
void preamble (const std::string &cmt);
void postamble ();
void beginPage (unsigned pageno, Int32 *c);
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.cpp
index 925b3065c8d..925b3065c8d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.h
index a10a26bd39c..a10a26bd39c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Directory.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Directory.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.cpp
index a3b2233e5b2..a3b2233e5b2 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.h
index 13c52718011..13c52718011 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/DvisvgmSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/DvisvgmSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.cpp
index aea2c9114c9..aea2c9114c9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.h
index 19b60a42797..19b60a42797 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSFile.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSFile.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.cpp
index 6e0188d1d6f..6e0188d1d6f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.h
index e6d654f595f..e6d654f595f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EPSToSVG.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EPSToSVG.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.cpp
index 2d944e9433d..2d944e9433d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.h
index 000277f6909..000277f6909 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EmSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EmSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.cpp
index 103090bc3e3..103090bc3e3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.h
index 5d15a48cfff..5d15a48cfff 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/EncFile.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/EncFile.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.cpp
index e8269991053..e8269991053 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.h
index e4a59c2346a..e4a59c2346a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileFinder.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileFinder.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.cpp
index 92922d99354..92922d99354 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.h
index c1c1bab7064..c1c1bab7064 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FilePath.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FilePath.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.cpp
index 398878853cd..398878853cd 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.h
index f60fcd0ac86..f60fcd0ac86 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FileSystem.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FileSystem.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.cpp
index 00d6b7fda9b..1fc51600929 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.cpp
@@ -392,7 +392,7 @@ int PhysicalFont::traceAllGlyphs (bool includeCached, GFGlyphTracer::Callback *c
tracer.setGlyph(glyph);
for (int i=fchar; i <= lchar; i++) {
if (includeCached || !_cache.getGlyph(i)) {
- glyph.newpath();
+ glyph.clear();
tracer.executeChar(i);
glyph.closeOpenSubPaths();
_cache.setGlyph(i, glyph);
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.h
index beba335793a..beba335793a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Font.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Font.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.cpp
index e617bc9fd34..e617bc9fd34 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.h
index 3afed5485a2..3afed5485a2 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontCache.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontCache.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.cpp
index a0fca850a98..a0fca850a98 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.h
index 4c366182632..4c366182632 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEncoding.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEncoding.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.cpp
index b1c6bee0c2d..621184ad943 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.cpp
@@ -110,6 +110,8 @@ void FontEngine::setDeviceResolution (int x, int y) {
* @param[in] fontindex index of font in font collection (multi-font files, like TTC)
* @return true on success */
bool FontEngine::setFont (const string &fname, int fontindex, const CharMapID &charMapID) {
+ if (_currentFace && FT_Done_Face(_currentFace))
+ Message::estream(true) << "FontEngine: error removing font\n";
if (FT_New_Face(_library, fname.c_str(), fontindex, &_currentFace)) {
Message::estream(true) << "FontEngine: error reading file " << fname << '\n';
return false;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.h
index 79a0916d04d..79a0916d04d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontEngine.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontEngine.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.cpp
index bb4288c57a4..bb4288c57a4 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.h
index c5ed1a35a97..c5ed1a35a97 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontManager.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontManager.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.cpp
index e885e0a38fa..e885e0a38fa 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.h
index bee44d8e6e7..bee44d8e6e7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMap.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMap.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.cpp
index 3920e4e6e76..3920e4e6e76 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.h
index 50207211d2c..50207211d2c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontMetrics.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontMetrics.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontStyle.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontStyle.h
index 932c09291cc..932c09291cc 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/FontStyle.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/FontStyle.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.cpp
index 58de265e740..e1d3f916241 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.cpp
@@ -88,6 +88,6 @@ void GFGlyphTracer::closePath () {
void GFGlyphTracer::endChar (UInt32 c) {
- _glyph->newpath();
+ _glyph->clear();
GFTracer::endChar(c);
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.h
index 57ed0362cc0..57ed0362cc0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFGlyphTracer.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFGlyphTracer.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.cpp
index 9b0a319733b..9b0a319733b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.h
index 1706acea126..1706acea126 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.cpp
index 89ff4359fda..89ff4359fda 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.h
index 617580636f0..617580636f0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GFTracer.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GFTracer.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.cpp
index de3ec1b7568..e204842bab9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.cpp
@@ -47,7 +47,7 @@ static string get_libgs (const string &fname) {
#ifdef MIKTEX
#if defined(__WIN64__)
const char *gsdll = "mgsdll64.dll";
-#elif defined(__WIN32__)
+#else
const char *gsdll = "mgsdll32.dll";
#endif
// try to look up the Ghostscript DLL coming with MiKTeX
@@ -76,7 +76,7 @@ static string get_libgs (const string &fname) {
// no appropriate library found
return "";
}
-#endif // HAVE_LIBGS
+#endif // !HAVE_LIBGS
/** Loads the Ghostscript library but does not create an instance. This
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.h
index 6200fa8d0a1..6200fa8d0a1 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Ghostscript.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Ghostscript.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Glyph.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Glyph.h
index 5a003a2196b..5a003a2196b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Glyph.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Glyph.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GlyphTracerMessages.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GlyphTracerMessages.h
index 6256bb843a0..6256bb843a0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GlyphTracerMessages.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GlyphTracerMessages.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GraphicPath.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GraphicPath.h
index 9e0d935acc6..dc3cb46852d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/GraphicPath.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/GraphicPath.h
@@ -21,6 +21,7 @@
#ifndef DVISVGM_GRAPHICPATH_H
#define DVISVGM_GRAPHICPATH_H
+#include <cctype>
#include <list>
#include <ostream>
#include <vector>
@@ -33,7 +34,9 @@
template <typename T>
class GraphicPath
{
+ friend class PathClipper;
public:
+ enum WindingRule {WR_EVEN_ODD, WR_NON_ZERO};
typedef Pair<T> Point;
struct Command {
@@ -90,6 +93,7 @@ class GraphicPath
virtual void closepath () {}
virtual void draw (char cmd, const Point *points, int n) {}
virtual bool quit () {return false;}
+ virtual void finished () {}
};
typedef typename std::vector<Command>::iterator Iterator;
@@ -97,21 +101,30 @@ class GraphicPath
typedef typename std::vector<Command>::const_reverse_iterator ConstRevIterator;
public:
- void newpath () {
+ GraphicPath (WindingRule wr=WR_NON_ZERO) : _windingRule(wr) {}
+
+ void setWindingRule (WindingRule wr) {_windingRule = wr;}
+ WindingRule windingRule () const {return _windingRule;}
+
+ void clear () {
_commands.clear();
}
- /// Returns true if path is empty (there is nothing to draw)
+ /// Returns true if the path is empty, i.e. there is nothing to draw
bool empty () const {
return _commands.empty();
}
-
/// Returns the number of path commands used to describe the path.
size_t size () const {
return _commands.size();
}
+ /// Insert another path at the beginning of this one.
+ void prepend (const GraphicPath &path) {
+ _commands.insert(_commands.begin(), path._commands.begin(), path._commands.end());
+ }
+
void moveto (const T &x, const T &y) {
moveto(Point(x, y));
}
@@ -184,27 +197,41 @@ class GraphicPath
* @param[in] sy vertical scale factor
* @param[in] dx horizontal translation in PS point units
* @param[in] dy vertical translation in PS point units */
- void writeSVG (std::ostream &os, double sx=1.0, double sy=1.0, double dx=0.0, double dy=0.0) const {
+ void writeSVG (std::ostream &os, bool relative, double sx=1.0, double sy=1.0, double dx=0.0, double dy=0.0) const {
struct WriteActions : Actions {
- WriteActions (std::ostream &os, double sx, double sy, double dx, double dy)
- : _os(os), _sx(sx), _sy(sy), _dx(dx), _dy(dy) {}
+ WriteActions (std::ostream &os, bool relative, double sx, double sy, double dx, double dy)
+ : _os(os), _relative(relative), _sx(sx), _sy(sy), _dx(dx), _dy(dy) {}
void draw (char cmd, const Point *points, int n) {
+ if (_relative)
+ cmd = tolower(cmd);
_os << cmd;
switch (cmd) {
+ case 'h': _os << XMLString(_sx*(points->x()-_currentPoint.x())+_dx); break;
+ case 'v': _os << XMLString(_sy*(points->y()-_currentPoint.y())+_dy); break;
+ case 'z': _currentPoint = _startPoint; break;
case 'H': _os << XMLString(_sx*points->x()+_dx); break;
case 'V': _os << XMLString(_sy*points->y()+_dy); break;
default :
for (int i=0; i < n; i++) {
if (i > 0)
_os << ' ';
- _os << XMLString(_sx*points[i].x()+_dx) << ' ' << XMLString(_sy*points[i].y()+_dy);
+ Point p = points[i];
+ if (_relative)
+ p -= _currentPoint;
+ _os << XMLString(_sx*p.x()+_dx) << ' ' << XMLString(_sy*p.y()+_dy);
}
}
+ if (cmd == 'm')
+ _startPoint = points[0];
+ if (islower(cmd) && n > 0)
+ _currentPoint = points[n-1];
}
std::ostream &_os;
+ bool _relative;
double _sx, _sy, _dx, _dy;
- } actions(os, sx, sy, dx, dy);
+ Point _startPoint, _currentPoint;
+ } actions(os, relative, sx, sy, dx, dy);
iterate(actions, true);
}
@@ -255,6 +282,7 @@ class GraphicPath
private:
std::vector<Command> _commands;
+ WindingRule _windingRule;
};
@@ -335,6 +363,7 @@ void GraphicPath<T>::iterate (Actions &actions, bool optimize) const {
cp = it->params[np-1];
prev = it;
}
+ actions.finished();
}
#endif
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.cpp
index dc419e8ebb8..dc419e8ebb8 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.h
index f1c3466bdaa..221c325185f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/HtmlSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/HtmlSpecialHandler.h
@@ -50,7 +50,7 @@ class HtmlSpecialHandler : public SpecialHandler, public DVIEndPageListener, pub
const char* info () const {return "hyperref specials";}
const char** prefixes () const;
- static bool setLinkMarker (const std::string &type);
+ static bool setLinkMarker (const std::string &marker);
protected:
void preprocessHrefAnchor (const std::string &uri);
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.cpp
index 154c60511bd..154c60511bd 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.h
index efcbc36ed74..efcbc36ed74 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputBuffer.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputBuffer.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.cpp
index f90bae04f8c..8a8709fe0f7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.cpp
@@ -87,8 +87,11 @@ int InputReader::compare (const char *s, bool consume) {
for (const char *p=s; *p; p++) {
int c = peek(count++);
if (c != *p)
- return *p < c ? -1 : 1;
+ return c < *p ? -1 : 1;
}
+ int c = peek(count);
+ if (c < 0 || !isspace(c))
+ return 1;
if (consume)
skip(count);
return 0;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.h
index d2eb5703211..d2eb5703211 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/InputReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/InputReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.cpp
index 89c4796616c..89c4796616c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.h
index 297ad6df710..297ad6df710 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/JFM.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/JFM.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.cpp
index 09951489ff6..09951489ff6 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.h
index 109cc2d2898..109cc2d2898 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Length.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Length.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Makefile.am
index 97f6a88d0bb..331ed44696e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Makefile.am
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Makefile.am
@@ -9,12 +9,14 @@ noinst_LIBRARIES = libdvisvgm.a
dvisvgm_SOURCES = gzstream.h \
dvisvgm.cpp gzstream.cpp
-dvisvgm_LDADD = $(noinst_LIBRARIES) @EXTRA_LIBS@
+dvisvgm_LDADD = $(noinst_LIBRARIES) @EXTRA_LIBS@ ../clipper/libclipper.a
dvisvgm_DEPENDENCIES = $(noinst_LIBRARIES) @EXTRA_LIBS@
libdvisvgm_a_SOURCES = \
BasicDVIReader.cpp \
BasicDVIReader.h \
+ Bezier.cpp \
+ Bezier.h \
BgColorSpecialHandler.cpp \
BgColorSpecialHandler.h \
Bitmap.cpp \
@@ -123,6 +125,8 @@ libdvisvgm_a_SOURCES = \
PageSize.cpp \
PageSize.h \
Pair.h \
+ PathClipper.cpp \
+ PathClipper.h \
PdfSpecialHandler.cpp \
PdfSpecialHandler.h \
PreScanDVIReader.cpp \
@@ -182,7 +186,7 @@ libdvisvgm_a_SOURCES = \
EXTRA_DIST = options.xml options.dtd iapi.h ierrors.h MiKTeXCom.h MiKTeXCom.cpp
-AM_CXXFLAGS = -Wall -Wnon-virtual-dtor
+AM_CXXFLAGS = -Wall -Wnon-virtual-dtor -I$(top_srcdir)/clipper
# the command-line parser is generated from options.xml by opt2cpp
CommandLine.cpp: options.xml
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.cpp
index d571d094890..d571d094890 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.h
index 2c1a53518fa..2c1a53518fa 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MapLine.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MapLine.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.cpp
index e0e301d281d..e0e301d281d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.h
index bcff8a57bad..bcff8a57bad 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Matrix.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Matrix.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.cpp
index c875109633f..c875109633f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.h
index 7c39127dbd4..7c39127dbd4 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Message.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Message.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MessageException.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MessageException.h
index 446c2e1282f..446c2e1282f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MessageException.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MessageException.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.cpp
index 6e955faeec5..6e955faeec5 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.h
index 8a59dc9d5d7..8a59dc9d5d7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MetafontWrapper.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MetafontWrapper.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.cpp
index bb4353f8ee4..bb4353f8ee4 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.h
index dcb6271a4bc..dcb6271a4bc 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/MiKTeXCom.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/MiKTeXCom.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.cpp
index 0a5119f6938..0a5119f6938 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.h
index 8af05f889a3..8af05f889a3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NoPsSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NoPsSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NumericRanges.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NumericRanges.h
index 7d810fb2a5d..7d810fb2a5d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/NumericRanges.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/NumericRanges.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSFilter.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSFilter.h
index e2c5c092dd3..e2c5c092dd3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSFilter.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSFilter.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.cpp
index 9ca5ed39c27..b1fa641fe46 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.cpp
@@ -263,6 +263,7 @@ void PSInterpreter::callActions (InputReader &in) {
} operators [] = {
{"applyscalevals", 3, &PSActions::applyscalevals},
{"clip", 0, &PSActions::clip},
+ {"clippath", 0, &PSActions::clippath},
{"closepath", 0, &PSActions::closepath},
{"curveto", 6, &PSActions::curveto},
{"eoclip", 0, &PSActions::eoclip},
@@ -275,7 +276,7 @@ void PSInterpreter::callActions (InputReader &in) {
{"lineto", 2, &PSActions::lineto},
{"makepattern", -1, &PSActions::makepattern},
{"moveto", 2, &PSActions::moveto},
- {"newpath", 0, &PSActions::newpath},
+ {"newpath", 1, &PSActions::newpath},
{"querypos", 2, &PSActions::querypos},
{"raw", -1, 0},
{"restore", 1, &PSActions::restore},
@@ -304,9 +305,9 @@ void PSInterpreter::callActions (InputReader &in) {
while (first <= last) {
int mid = first+(last-first)/2;
int cmp = in.compare(operators[mid].name);
- if (cmp > 0)
+ if (cmp < 0)
last = mid-1;
- else if (cmp < 0)
+ else if (cmp > 0)
first = mid+1;
else {
if (!operators[mid].op) { // raw string data received
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.h
index 2e98bf27e96..6d1794e5065 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSInterpreter.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSInterpreter.h
@@ -43,6 +43,7 @@ struct PSActions
virtual ~PSActions () {}
virtual void applyscalevals (std::vector<double> &p) =0;
virtual void clip (std::vector<double> &p) =0;
+ virtual void clippath (std::vector<double> &p) =0;
virtual void closepath (std::vector<double> &p) =0;
virtual void curveto (std::vector<double> &p) =0;
virtual void eoclip (std::vector<double> &p) =0;
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.cpp
index 107dac4f795..107dac4f795 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.h
index 96911b921da..96911b921da 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPattern.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPattern.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.cpp
index c9b3b080118..c9b3b080118 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.h
index 3e65ac9ba4c..3e65ac9ba4c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PSPreviewFilter.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PSPreviewFilter.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.cpp
index e19e679c67e..e19e679c67e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.h
index 3292986226d..3292986226d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageRanges.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageRanges.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.cpp
index 2cc3f36512d..2cc3f36512d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.h
index d63079ae784..d63079ae784 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PageSize.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PageSize.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Pair.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Pair.h
index 6183b3b97e3..6183b3b97e3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Pair.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Pair.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.cpp
new file mode 100644
index 00000000000..fcc231fb5fe
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.cpp
@@ -0,0 +1,343 @@
+/*************************************************************************
+** PathClipper.cpp **
+** **
+** This file is part of dvisvgm -- the DVI to SVG converter **
+** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include <config.h>
+#include "Bezier.h"
+#include "PathClipper.h"
+#include "types.h"
+
+using namespace std;
+using namespace ClipperLib;
+
+typedef ClipperLib::Path Polygon;
+typedef ClipperLib::Paths Polygons;
+typedef PathClipper::CurvedPath CurvedPath;
+
+const int SCALE_FACTOR = 1000;
+
+inline cInt to_cInt (double x) {
+ if (x < 0)
+ return static_cast<cInt>(x*SCALE_FACTOR - 0.5);
+ return static_cast<cInt>(x*SCALE_FACTOR + 0.5);
+}
+
+
+inline double to_double (cInt x) {
+ return static_cast<double>(x)/SCALE_FACTOR;
+}
+
+
+inline DPair to_DPair (const IntPoint &p) {
+ return DPair(to_double(p.X), to_double(p.Y));
+}
+
+
+/** In order to flatten a curved path, all path segements are processed sequentially.
+ * Depending on the type of the segment, one of the methods provided by this class
+ * is called. */
+class FlattenActions : public CurvedPath::Actions {
+ public:
+ FlattenActions (vector<Bezier> &curves, Polygons &polygons, int &numLines)
+ : _polygons(polygons), _curves(curves), _numLines(numLines) {}
+
+ void moveto (const CurvedPath::Point &p) {
+ if (p == _currentPoint && !_currentPoly.empty())
+ return;
+ closepath();
+ _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), 0));
+ _currentPoint = _startPoint = p;
+ }
+
+ void lineto (const CurvedPath::Point &p) {
+ if (p == _currentPoint && !_currentPoly.empty())
+ return;
+ if (_currentPoly.empty()) // this shouldn't happen but in case it does...
+ _currentPoly.push_back(IntPoint(0, 0, 0)); // ...add a start point first
+ _numLines--;
+ _currentPoly.back().Z.label2 = _numLines;
+ _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(_numLines, 0)));
+ _currentPoint = p;
+ }
+
+ void conicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2) {
+ Bezier bezier(_currentPoint, p1, p2);
+ addCurvePoints(bezier);
+ }
+
+ void cubicto (const CurvedPath::Point &p1, const CurvedPath::Point &p2, const CurvedPath::Point &p3) {
+ Bezier bezier(_currentPoint, p1, p2, p3);
+ addCurvePoints(bezier);
+ }
+
+ void closepath () {
+ if (_currentPoly.empty())
+ return;
+ _numLines--;
+ _currentPoly.back().Z.label2 = ZLabel(_numLines, 0);
+ _currentPoly.front().Z.label1 = ZLabel(_numLines, 0);
+ _polygons.push_back(_currentPoly);
+ _currentPoly.clear();
+ }
+
+ void finished () {
+ closepath();
+ }
+
+ protected:
+ void addCurvePoints (const Bezier &bezier) {
+ if (_currentPoly.empty()) // this shouldn't happen but in case it does, ...
+ _currentPoly.push_back(IntPoint(0, 0, 0)); // ...add a start point first
+ vector<DPair> points; // points of flattened curve
+ vector<double> t; // corresponding 'time' parameters
+ bezier.approximate(0.01, points, &t);
+ if (points.size() < 2)
+ return;
+ _curves.push_back(bezier);
+ for (size_t i=1; i < points.size(); i++) {
+ const DPair &p = points[i];
+ if (p == _currentPoint)
+ continue;
+ _currentPoly.back().Z.label2 = ZLabel(_curves.size(), t[i-1]);
+ ZLabel label(_curves.size(), t[i]);
+ _currentPoly.push_back(IntPoint(to_cInt(p.x()), to_cInt(p.y()), ZType(label, label)));
+ _currentPoint = p;
+ }
+ }
+
+ private:
+ CurvedPath::Point _startPoint, _currentPoint;
+ Polygon _currentPoly; ///< polygon being created
+ Polygons &_polygons; ///< all polygons created
+ vector<Bezier> &_curves;
+ int &_numLines;
+};
+
+
+/** Removes adjacent polygon vertices that equal their predecessor. */
+static void remove_redundant_vertices (Polygon &polygon) {
+ Polygon::iterator it1=polygon.begin();
+ while (it1 != polygon.end()) {
+ Polygon::iterator it2 = it1+1;
+ if (it2 == polygon.end())
+ it2 = polygon.begin();
+ if (it1 == it2)
+ return;
+
+ if (*it1 != *it2)
+ ++it1;
+ else {
+ it1->Z.label2 = it2->Z.label2;
+ polygon.erase(it2);
+ }
+ }
+}
+
+
+/** Approximates a curved path by a set of polygons and stores information
+ * to reconstruct the curved segments later. The z component of each
+ * polygon vertex holds two integers representing information about the two
+ * adjacent edges the vertex belongs to. This is required to identify the
+ * affected edges and thus the former (curve/line) segment of the path during
+ * the intersection process.
+ * @param[in] curvedPath curved path to be flattened
+ * @param[out] polygons the flattened path (set of polygons) */
+void PathClipper::flatten (const CurvedPath &curvedPath, Polygons &polygons) {
+ FlattenActions flattenActions(_curves, polygons, _numLines);
+ curvedPath.iterate(flattenActions, false);
+ for (size_t i=0; i < polygons.size(); i++)
+ remove_redundant_vertices(polygons[i]);
+}
+
+
+/** Returns the ID of the path segment the polygon edge defined by its start
+ * and end point belongs to. The z component of a polygon vertex holds a pair
+ * of labels that allows to identify the original path segments the point belongs to.
+ * Since always two adjacent segments share a point, each point gets two values assigned.
+ * Negative numbers denote line segments, positive ones Bézier curves.
+ * There are only these two segment types, so we don't need further flags in
+ * order to distinguish them. By comparing the labels of two adjacent polygon
+ * vertexes it's possible to identify the original path segment the corresponding
+ * edge belongs to.
+ * @param[in] p1 first of two adjacent vertices
+ * @param[in] p2 second of two adjacent vertices
+ * @param[out] t1 time paramater of p1
+ * @param[out] t2 time paramater of p2
+ * @return id of edge between p1 and p2, or 0 if it's not possible to identify the segment */
+static Int32 segment_id (const IntPoint &p1, const IntPoint &p2, double &t1, double &t2) {
+ const ZType &z1=p1.Z, &z2=p2.Z;
+ if (z1 == z2 && z1.minLabel().id < 0) return z1.minLabel().id;
+ if (z1.label1 == z2.label2) {t1=z1.label1.t; t2=z2.label2.t; return z1.label1.id;}
+ if (z1.label2 == z2.label1) {t1=z1.label2.t; t2=z2.label1.t; return z1.label2.id;}
+ if (z1.label1 == z2.label1) {t1=z1.label1.t; t2=z2.label1.t; return z1.label1.id;}
+ if (z1.label2 == z2.label2) {t1=z1.label2.t; t2=z2.label2.t; return z1.label2.id;}
+ // if we get here, it's not possible to identify the segment
+ // => the edge is going to be handled as line segment
+ return 0;
+}
+
+
+inline Int32 edge_id (const IntPoint &p1, const IntPoint &p2) {
+ double t;
+ return segment_id(p1, p2, t, t);
+}
+
+
+/** This function expects 3 colinear points p1, p2, and q where q lies between p1 and p2,
+ * i.e. q divides the line \f$ \overline{p_1 p_2} \f$ somewhere. The function returns
+ * the corresponding division ratio. */
+static double division_ratio (const IntPoint &p1, const IntPoint &p2, const IntPoint &q) {
+ if (p1 == p2 || q == p1)
+ return 0;
+ if (q == p2)
+ return 1;
+ if (p1.X == p2.X)
+ return double(q.Y-p1.Y)/(p2.Y-p1.Y);
+ return double(q.X-p1.X)/(p2.X-p1.X);
+}
+
+
+/** Returns the label of point q that lies on the line between points p1 and p2. */
+inline ZLabel division_label (const IntPoint &p1, const IntPoint &p2, const IntPoint &q) {
+ double t1, t2;
+ double s=0;
+ Int32 id = segment_id(p1, p2, t1, t2);
+ if (id > 0)
+ s = t1+(t2-t1)*division_ratio(p1, p2, q);
+ return ZLabel(id, s);
+}
+
+
+/** This method is called if the clipper library finds an intersection between two polygon edges.
+ * It populates the z coordinate of the intersection point with the idexes of the two edges.
+ * @param[in] e1bot first endpoint of edge 1
+ * @param[in] e1top second endpoint of edge 1
+ * @param[in] e2bot first endpoint of edge 2
+ * @param[in] e1top second endpoint of edge 2
+ * @param[in] ip intersection point of edge 1 and 2
+ * @param[in] userval pointer to PathClipper object set by ZFillFunction() */
+void PathClipper::callback (IntPoint &e1bot, IntPoint &e1top, IntPoint &e2bot, IntPoint &e2top, IntPoint &ip) {
+ ZLabel label1 = division_label(e1bot, e1top, ip);
+ ZLabel label2 = division_label(e2bot, e2top, ip);
+ ip.Z = ZType(label1, label2);
+}
+
+
+/** Iterates along the polygon edges until the endpoint of the current
+ * path segment is found and returns its vector index afterwards.
+ * @param[in] points the vertices of the polygon
+ * @param[in] start index of the vertex where the iteration starts
+ * @param[out] label if not 0, retrieves the label of the endpoint
+ * @param[in] startLabel if true, the found endpoint is treated as start point and
+ * parameter 'label' gets the corresponding value */
+static size_t find_segment_endpoint (const Polygon &polygon, size_t start, ZLabel *label=0, bool startLabel=false) {
+ if (polygon.empty())
+ return 0;
+
+ const size_t num_points = polygon.size();
+ int i = start%num_points;
+ double t1, t2; // time parameters of start and endpoint of current edge
+ Int32 id1 = segment_id(polygon[i], polygon[(i+1)%num_points], t1, t2);
+ Int32 id2 = id1;
+ double t = t2; // time parameter of resulting endpoint
+ for (size_t j=1; id1 == id2 && j < num_points; j++) {
+ t = t2;
+ i = (i+1)%num_points;
+ if (id1 == 0)
+ break;
+ id2 = segment_id(polygon[i], polygon[(i+1)%num_points], t1, t2);
+ }
+ if (label) {
+ *label = ZLabel(id1, id1 < 0 ? 0 : t);
+ if (startLabel && id1 != 0)
+ *label = polygon[i].Z.otherLabel(*label);
+ }
+ return i;
+}
+
+
+/** Reconstructs a curved path from the set of polygons.
+ * @param[in] polygons set of polygons to reconstruct
+ * @param[out] path the reconstructed curved path */
+void PathClipper::reconstruct (const Polygons &polygons, CurvedPath &path) {
+ for (size_t i=0; i < polygons.size(); i++)
+ reconstruct(polygons[i], path);
+}
+
+
+/** Reconstructs a curved path from a single polygon.
+ * @param[in] polygon polygon to reconstruct
+ * @param[out] path the reconstructed curved path */
+void PathClipper::reconstruct (const Polygon &polygon, CurvedPath &path) {
+ size_t num_points = polygon.size();
+ if (num_points < 2)
+ return;
+
+ ZLabel label1, label2; // labels of the current segment's start and endpoint
+ int index1 = find_segment_endpoint(polygon, 0, &label1, true);
+ int index2 = find_segment_endpoint(polygon, index1, &label2);
+ int diff = (num_points+index2-index1)%num_points;
+ path.moveto(to_DPair(polygon[index1]));
+ for (size_t count = diff; count <= num_points; count += diff) {
+ if (diff == 1 || label1.id <= 0) // line segment?
+ path.lineto(to_DPair(polygon[index2]));
+ else { // Bézier curve segment
+ Bezier bezier(_curves[label1.id-1], label1.t, label2.t);
+ if (label1.t > label2.t)
+ bezier.reverse();
+ path.cubicto(bezier.point(1), bezier.point(2), bezier.point(3));
+ }
+ if (label1.id == 0)
+ find_segment_endpoint(polygon, index2, &label1, true);
+ else
+ label1 = polygon[index2].Z.otherLabel(label2);
+ index1 = index2;
+ index2 = find_segment_endpoint(polygon, index1, &label2);
+ diff = (num_points+index2-index1)%num_points;
+ }
+ path.closepath();
+}
+
+
+inline PolyFillType polyFillType (CurvedPath::WindingRule wr) {
+ return (wr == CurvedPath::WR_NON_ZERO) ? pftNonZero : pftEvenOdd;
+}
+
+
+/** Computes the intersection of to curved path.
+ * @param[in] p1 first curved path
+ * @param[in] wr1 winding rule to be applied to p1
+ * @param[in] p2 second curved path
+ * @param[in] wr2 winding rule to be applied to p2
+ * @param[out] result intersection of p1 and p2 */
+void PathClipper::intersect (const CurvedPath &p1, const CurvedPath &p2, CurvedPath &result) {
+ if (p1.size() < 2 || p2.size() < 2)
+ return;
+ Clipper clipper;
+ Polygons polygons;
+ flatten(p1, polygons);
+ clipper.AddPaths(polygons, ptSubject, true);
+ polygons.clear();
+ flatten(p2, polygons);
+ clipper.AddPaths(polygons, ptClip, true);
+ clipper.ZFillFunction(callback);
+ Polygons flattenedPath;
+ clipper.Execute(ctIntersection, flattenedPath, polyFillType(p1.windingRule()), polyFillType(p2.windingRule()));
+ reconstruct(flattenedPath, result);
+}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.h
new file mode 100644
index 00000000000..c8aca25dbc1
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PathClipper.h
@@ -0,0 +1,60 @@
+/*************************************************************************
+** PathClipper.h **
+** **
+** This file is part of dvisvgm -- the DVI to SVG converter **
+** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#ifndef DVISVGM_PATHCLIPPER_H
+#define DVISVGM_PATHCLIPPER_H
+
+#include <clipper.hpp>
+#include <string>
+#include <vector>
+#include "Bezier.h"
+#include "GraphicPath.h"
+#include "MessageException.h"
+
+struct PathClipperException : public MessageException
+{
+ PathClipperException (const std::string &msg) : MessageException(msg) {}
+};
+
+
+using ClipperLib::IntPoint;
+
+class PathClipper
+{
+ public:
+ typedef GraphicPath<double> CurvedPath;
+
+ public:
+ PathClipper () : _numLines(0) {}
+ void intersect (const CurvedPath &p1, const CurvedPath &p2, CurvedPath &result);
+
+ protected:
+ void flatten (const CurvedPath &gp, ClipperLib::Paths &polygons);
+// void divide (IntPoint &p1, IntPoint &p2, IntPoint &ip);
+ void reconstruct (const ClipperLib::Path &polygon, CurvedPath &path);
+ void reconstruct (const ClipperLib::Paths &polygons, CurvedPath &path);
+ static void callback (IntPoint &e1bot, IntPoint &e1top, IntPoint &e2bot, IntPoint &e2top, IntPoint &pt);
+
+ private:
+ std::vector<Bezier> _curves;
+ int _numLines; ///< negative number of straight line segments in path been processed
+};
+
+#endif
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.cpp
index fb8e775759f..fb8e775759f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.h
index 6865a21d9be..6865a21d9be 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PdfSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PdfSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.cpp
index f88010b89ed..f88010b89ed 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.h
index 1e033e73fa6..1e033e73fa6 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PreScanDVIReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PreScanDVIReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.cpp
index 41c3bec0daa..41c3bec0daa 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.h
index 54f4ec611c3..54f4ec611c3 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Process.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Process.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.cpp
index 7c5753125fe..13b770a1db8 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.cpp
@@ -27,15 +27,18 @@
#include "FileFinder.h"
#include "Ghostscript.h"
#include "Message.h"
+#include "PathClipper.h"
#include "PSPattern.h"
#include "PSPreviewFilter.h"
#include "PsSpecialHandler.h"
#include "SpecialActions.h"
+#include "SVGTree.h"
#include "XMLNode.h"
#include "XMLString.h"
using namespace std;
+
static inline double str2double (const string &str) {
double ret;
istringstream iss(str);
@@ -44,6 +47,9 @@ static inline double str2double (const string &str) {
}
+bool PsSpecialHandler::COMPUTE_CLIPPATHS_INTERSECTIONS = false;
+
+
PsSpecialHandler::PsSpecialHandler () : _psi(this), _actions(0), _previewFilter(_psi), _psSection(PS_NONE), _xmlnode(0)
{
}
@@ -442,78 +448,80 @@ void PsSpecialHandler::closepath (vector<double> &p) {
/** Draws the current path recorded by previously executed path commands (moveto, lineto,...).
* @param[in] p not used */
void PsSpecialHandler::stroke (vector<double> &p) {
- if (!_path.empty() && _actions) {
- BoundingBox bbox;
- if (!_actions->getMatrix().isIdentity()) {
- _path.transform(_actions->getMatrix());
- if (!_xmlnode)
- bbox.transform(_actions->getMatrix());
- }
+ if ((_path.empty() && !_clipStack.clippathLoaded()) || !_actions)
+ return;
- XMLElementNode *path=0;
- Pair<double> point;
- if (_path.isDot(point)) { // zero-length path?
- if (_linecap == 1) { // round line ends? => draw dot
- double x = point.x();
- double y = point.y();
- double r = _linewidth/2.0;
- path = new XMLElementNode("circle");
- path->addAttribute("cx", x);
- path->addAttribute("cy", y);
- path->addAttribute("r", r);
- path->addAttribute("fill", _actions->getColor().rgbString());
- bbox = BoundingBox(x-r, y-r, x+r, y+r);
- }
+ BoundingBox bbox;
+ if (!_actions->getMatrix().isIdentity()) {
+ _path.transform(_actions->getMatrix());
+ if (!_xmlnode)
+ bbox.transform(_actions->getMatrix());
+ }
+ if (_clipStack.clippathLoaded() && _clipStack.top())
+ _path.prepend(*_clipStack.top());
+ XMLElementNode *path=0;
+ Pair<double> point;
+ if (_path.isDot(point)) { // zero-length path?
+ if (_linecap == 1) { // round line ends? => draw dot
+ double x = point.x();
+ double y = point.y();
+ double r = _linewidth/2.0;
+ path = new XMLElementNode("circle");
+ path->addAttribute("cx", x);
+ path->addAttribute("cy", y);
+ path->addAttribute("r", r);
+ path->addAttribute("fill", _actions->getColor().rgbString());
+ bbox = BoundingBox(x-r, y-r, x+r, y+r);
}
- else {
- // compute bounding box
- _path.computeBBox(bbox);
- bbox.expand(_linewidth/2);
+ }
+ else {
+ // compute bounding box
+ _path.computeBBox(bbox);
+ bbox.expand(_linewidth/2);
+ ostringstream oss;
+ _path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
+ path = new XMLElementNode("path");
+ path->addAttribute("d", oss.str());
+ path->addAttribute("stroke", _actions->getColor().rgbString());
+ path->addAttribute("fill", "none");
+ if (_linewidth != 1)
+ path->addAttribute("stroke-width", _linewidth);
+ if (_miterlimit != 4)
+ path->addAttribute("stroke-miterlimit", _miterlimit);
+ if (_linecap > 0) // default value is "butt", no need to set it explicitly
+ path->addAttribute("stroke-linecap", _linecap == 1 ? "round" : "square");
+ if (_linejoin > 0) // default value is "miter", no need to set it explicitly
+ path->addAttribute("stroke-linejoin", _linecap == 1 ? "round" : "bevel");
+ if (_opacityalpha < 1)
+ path->addAttribute("stroke-opacity", _opacityalpha);
+ if (!_dashpattern.empty()) {
ostringstream oss;
- _path.writeSVG(oss);
- path = new XMLElementNode("path");
- path->addAttribute("d", oss.str());
- path->addAttribute("stroke", _actions->getColor().rgbString());
- path->addAttribute("fill", "none");
- if (_linewidth != 1)
- path->addAttribute("stroke-width", _linewidth);
- if (_miterlimit != 4)
- path->addAttribute("stroke-miterlimit", _miterlimit);
- if (_linecap > 0) // default value is "butt", no need to set it explicitly
- path->addAttribute("stroke-linecap", _linecap == 1 ? "round" : "square");
- if (_linejoin > 0) // default value is "miter", no need to set it explicitly
- path->addAttribute("stroke-linejoin", _linecap == 1 ? "round" : "bevel");
- if (_opacityalpha < 1)
- path->addAttribute("stroke-opacity", _opacityalpha);
- if (!_dashpattern.empty()) {
- ostringstream oss;
- for (size_t i=0; i < _dashpattern.size(); i++) {
- if (i > 0)
- oss << ',';
- oss << XMLString(_dashpattern[i]);
- }
- path->addAttribute("stroke-dasharray", oss.str());
- if (_dashoffset != 0)
- path->addAttribute("stroke-dashoffset", _dashoffset);
+ for (size_t i=0; i < _dashpattern.size(); i++) {
+ if (i > 0)
+ oss << ',';
+ oss << XMLString(_dashpattern[i]);
}
+ path->addAttribute("stroke-dasharray", oss.str());
+ if (_dashoffset != 0)
+ path->addAttribute("stroke-dashoffset", _dashoffset);
}
- if (path && _clipStack.top()) {
- // assign clipping path and clip bounding box
- path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
- BoundingBox clipbox;
- _clipStack.top()->computeBBox(clipbox);
- bbox.intersect(clipbox);
- }
-
- if (_xmlnode)
- _xmlnode->append(path);
- else {
- _actions->appendToPage(path);
- _actions->embed(bbox);
- }
- _path.newpath();
}
+ if (path && _clipStack.top()) {
+ // assign clipping path and clip bounding box
+ path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ BoundingBox clipbox;
+ _clipStack.top()->computeBBox(clipbox);
+ bbox.intersect(clipbox);
+ _clipStack.setClippathLoaded(false);
+ }
+ if (_xmlnode)
+ _xmlnode->append(path);
+ else {
+ _actions->appendToPage(path);
+ _actions->embed(bbox);
+ }
+ _path.clear();
}
@@ -521,43 +529,47 @@ void PsSpecialHandler::stroke (vector<double> &p) {
* @param[in] p not used
* @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */
void PsSpecialHandler::fill (vector<double> &p, bool evenodd) {
- if (!_path.empty() && _actions) {
- // compute bounding box
- BoundingBox bbox;
- _path.computeBBox(bbox);
- if (!_actions->getMatrix().isIdentity()) {
- _path.transform(_actions->getMatrix());
- if (!_xmlnode)
- bbox.transform(_actions->getMatrix());
- }
+ if ((_path.empty() && !_clipStack.clippathLoaded()) || !_actions)
+ return;
- ostringstream oss;
- _path.writeSVG(oss);
- XMLElementNode *path = new XMLElementNode("path");
- path->addAttribute("d", oss.str());
- if (_pattern)
- path->addAttribute("fill", XMLString("url(#")+_pattern->svgID()+")");
- else if (_actions->getColor() != Color::BLACK || _savenode)
- path->addAttribute("fill", _actions->getColor().rgbString());
- if (_clipStack.top()) {
- // assign clipping path and clip bounding box
- path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
- BoundingBox clipbox;
- _clipStack.top()->computeBBox(clipbox);
- bbox.intersect(clipbox);
- }
- if (evenodd) // SVG default fill rule is "nonzero" algorithm
- path->addAttribute("fill-rule", "evenodd");
- if (_opacityalpha < 1)
- path->addAttribute("fill-opacity", _opacityalpha);
- if (_xmlnode)
- _xmlnode->append(path);
- else {
- _actions->appendToPage(path);
- _actions->embed(bbox);
- }
- _path.newpath();
+ // compute bounding box
+ BoundingBox bbox;
+ _path.computeBBox(bbox);
+ if (!_actions->getMatrix().isIdentity()) {
+ _path.transform(_actions->getMatrix());
+ if (!_xmlnode)
+ bbox.transform(_actions->getMatrix());
}
+ if (_clipStack.clippathLoaded() && _clipStack.top())
+ _path.prepend(*_clipStack.top());
+
+ ostringstream oss;
+ _path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
+ XMLElementNode *path = new XMLElementNode("path");
+ path->addAttribute("d", oss.str());
+ if (_pattern)
+ path->addAttribute("fill", XMLString("url(#")+_pattern->svgID()+")");
+ else if (_actions->getColor() != Color::BLACK || _savenode)
+ path->addAttribute("fill", _actions->getColor().rgbString());
+ if (_clipStack.top()) {
+ // assign clipping path and clip bounding box
+ path->addAttribute("clip-path", XMLString("url(#clip")+XMLString(_clipStack.topID())+")");
+ BoundingBox clipbox;
+ _clipStack.top()->computeBBox(clipbox);
+ bbox.intersect(clipbox);
+ _clipStack.setClippathLoaded(false);
+ }
+ if (evenodd) // SVG default fill rule is "nonzero" algorithm
+ path->addAttribute("fill-rule", "evenodd");
+ if (_opacityalpha < 1)
+ path->addAttribute("fill-opacity", _opacityalpha);
+ if (_xmlnode)
+ _xmlnode->append(path);
+ else {
+ _actions->appendToPage(path);
+ _actions->embed(bbox);
+ }
+ _path.clear();
}
@@ -658,45 +670,77 @@ void PsSpecialHandler::setpattern (vector<double> &p) {
/** Clears the current clipping path.
* @param[in] p not used */
-void PsSpecialHandler::initclip (vector<double> &p) {
- _clipStack.push(); // push empty path
+void PsSpecialHandler::initclip (vector<double> &) {
+ _clipStack.pushEmptyPath();
}
-/** Assigns a new clipping path.
+/** Assigns the current clipping path to the graphics path. */
+void PsSpecialHandler::clippath (std::vector<double>&) {
+ if (!_clipStack.empty()) {
+ _clipStack.setClippathLoaded(true);
+ _path.clear();
+ }
+}
+
+
+/** Assigns a new clipping path to the graphics state using the current path.
+ * If the graphics state already contains a clipping path, the new one is
+ * computed by intersecting the current clipping path with the current graphics
+ * path (see PS language reference, 3rd edition, pp. 193, 542)
* @param[in] p not used
* @param[in] evenodd true: use even-odd fill algorithm, false: use nonzero fill algorithm */
-void PsSpecialHandler::clip (vector<double> &p, bool evenodd) {
+void PsSpecialHandler::clip (vector<double> &, bool evenodd) {
// when this method is called, _path contains the clipping path
- if (!_path.empty() && _actions) {
- if (!_actions->getMatrix().isIdentity())
- _path.transform(_actions->getMatrix());
+ if (_path.empty() || !_actions)
+ return;
- int oldID = _clipStack.topID();
- _clipStack.replace(_path);
- int newID = _clipStack.topID();
+ Path::WindingRule windingRule = evenodd ? Path::WR_EVEN_ODD : Path::WR_NON_ZERO;
+ _path.setWindingRule(windingRule);
- ostringstream oss;
- _path.writeSVG(oss);
- XMLElementNode *path = new XMLElementNode("path");
- path->addAttribute("d", oss.str());
- if (evenodd)
- path->addAttribute("clip-rule", "evenodd");
+ if (!_actions->getMatrix().isIdentity())
+ _path.transform(_actions->getMatrix());
- XMLElementNode *clip = new XMLElementNode("clipPath");
- clip->addAttribute("id", XMLString("clip")+XMLString(newID));
- if (oldID)
- clip->addAttribute("clip-path", XMLString("url(#clip")+XMLString(oldID)+")");
+ int oldID = _clipStack.topID();
- clip->append(path);
- _actions->appendToDefs(clip);
+ ostringstream oss;
+ if (!COMPUTE_CLIPPATHS_INTERSECTIONS || oldID < 1) {
+ _clipStack.replace(_path);
+ _path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
}
+ else {
+ // compute the intersection of the current clipping path with the current graphics path
+ Path *oldPath = _clipStack.getPath(oldID);
+ Path intersectedPath(windingRule);
+ PathClipper clipper;
+ clipper.intersect(*oldPath, _path, intersectedPath);
+ _clipStack.replace(intersectedPath);
+ intersectedPath.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
+ }
+
+ XMLElementNode *pathElem = new XMLElementNode("path");
+ pathElem->addAttribute("d", oss.str());
+ if (evenodd)
+ pathElem->addAttribute("clip-rule", "evenodd");
+
+ int newID = _clipStack.topID();
+ XMLElementNode *clipElem = new XMLElementNode("clipPath");
+ clipElem->addAttribute("id", XMLString("clip")+XMLString(newID));
+ if (!COMPUTE_CLIPPATHS_INTERSECTIONS && oldID)
+ clipElem->addAttribute("clip-path", XMLString("url(#clip")+XMLString(oldID)+")");
+
+ clipElem->append(pathElem);
+ _actions->appendToDefs(clipElem);
}
/** Clears current path */
void PsSpecialHandler::newpath (vector<double> &p) {
- _path.newpath();
+ bool drawing = (p[0] > 0);
+ if (!drawing || !_clipStack.clippathLoaded()) {
+ _path.clear();
+ _clipStack.setClippathLoaded(false);
+ }
}
@@ -799,7 +843,7 @@ void PsSpecialHandler::executed () {
////////////////////////////////////////////
-void PsSpecialHandler::ClippingStack::push () {
+void PsSpecialHandler::ClippingStack::pushEmptyPath () {
if (!_stack.empty())
_stack.push(Entry(0, -1));
}
@@ -853,6 +897,24 @@ const PsSpecialHandler::Path* PsSpecialHandler::ClippingStack::top () const {
}
+PsSpecialHandler::Path* PsSpecialHandler::ClippingStack::getPath (size_t id) {
+ return (id > 0 && id <= _paths.size()) ? &_paths[id-1] : 0;
+}
+
+
+/** Returns true if the clipping path was loaded into the graphics path (via PS operator 'clippath') */
+bool PsSpecialHandler::ClippingStack::clippathLoaded () const {
+ return !_stack.empty() && _stack.top().cpathLoaded;
+}
+
+
+void PsSpecialHandler::ClippingStack::setClippathLoaded (bool loaded) {
+ if (_stack.empty())
+ return;
+ _stack.top().cpathLoaded = loaded;
+}
+
+
/** Pops all elements from the stack. */
void PsSpecialHandler::ClippingStack::clear() {
_paths.clear();
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.h
index 03d9d8bb7d1..10d091aa688 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/PsSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/PsSpecialHandler.h
@@ -42,21 +42,25 @@ class PsSpecialHandler : public SpecialHandler, public DVIEndPageListener, prote
class ClippingStack
{
public:
- void push ();
+ void pushEmptyPath ();
void push (const Path &path, int saveID=-1);
void replace (const Path &path);
void dup (int saveID=-1);
void pop (int saveID=-1, bool grestore=false);
void clear ();
bool empty () const {return _stack.empty();}
+ bool clippathLoaded () const;
+ void setClippathLoaded (bool loaded);
const Path* top () const;
+ Path* getPath (size_t id);
int topID () const {return _stack.empty() ? 0 : _stack.top().pathID;}
private:
struct Entry {
- int pathID; ///< index referencing a path of the pool
- int saveID; ///< if >=0, path was pushed by 'save', and saveID holds the ID of the
- Entry (int pid, int sid) : pathID(pid), saveID(sid) {}
+ int pathID; ///< index referencing a path of the pool
+ int saveID; ///< if >=0, path was pushed by 'save', and saveID holds the ID of the
+ bool cpathLoaded; ///< true if clipping path was loaded into current path
+ Entry (int pid, int sid) : pathID(pid), saveID(sid), cpathLoaded(false) {}
};
std::vector<Path> _paths; ///< pool of all clipping paths
std::stack<Entry> _stack;
@@ -75,6 +79,9 @@ class PsSpecialHandler : public SpecialHandler, public DVIEndPageListener, prote
void setDviScaleFactor (double dvi2bp) {_previewFilter.setDviScaleFactor(dvi2bp);}
void enterBodySection ();
+ public:
+ static bool COMPUTE_CLIPPATHS_INTERSECTIONS;
+
protected:
void initialize ();
void moveToDVIPos ();
@@ -88,6 +95,7 @@ class PsSpecialHandler : public SpecialHandler, public DVIEndPageListener, prote
void applyscalevals (std::vector<double> &p) {_sx = p[0]; _sy = p[1]; _cos = p[2];}
void clip (std::vector<double> &p) {clip(p, false);}
void clip (std::vector<double> &p, bool evenodd);
+ void clippath (std::vector<double> &p);
void closepath (std::vector<double> &p);
void curveto (std::vector<double> &p);
void eoclip (std::vector<double> &p) {clip(p, true);}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.cpp
index 74871a71e67..e3bfea44eef 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.cpp
@@ -71,7 +71,7 @@ bool RangeMap::Range::join (const Range &r) {
/** Adds a new number range. The range describes a mapping from c to v(c), where
- * c \in [cmin,cmax] and v(cmin):=vmin, v(c):=vmin+c-cmin.
+ * \f$c \in [cmin,cmax]\f$ and \f$v(cmin):=vmin, v(c):=vmin+c-cmin\f$.
* @param[in] cmin smallest number in the range
* @param[in] cmax largest number in the range
* @param[in] vmin map value of cmin */
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.h
index 60bf071aff0..60bf071aff0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/RangeMap.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/RangeMap.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGOutputBase.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGOutputBase.h
index cad892ea068..cad892ea068 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGOutputBase.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGOutputBase.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.cpp
index 2432ab42528..084f9f921a9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.cpp
@@ -38,6 +38,7 @@ using namespace std;
bool SVGTree::CREATE_STYLE=true;
bool SVGTree::USE_FONTS=true;
bool SVGTree::CREATE_USE_ELEMENTS=false;
+bool SVGTree::RELATIVE_PATH_CMDS=false;
double SVGTree::ZOOM_FACTOR=1.0;
@@ -232,7 +233,7 @@ void SVGTree::appendChar (int c, double x, double y, const Font &font) {
double sx = pf->scaledSize()/pf->unitsPerEm();
double sy = -sx;
ostringstream oss;
- glyph.writeSVG(oss, sx, sy, x, y);
+ glyph.writeSVG(oss, RELATIVE_PATH_CMDS, sx, sy, x, y);
XMLElementNode *glyph_node = new XMLElementNode("path");
glyph_node->addAttribute("d", oss.str());
if (!rotation.isIdentity())
@@ -321,7 +322,7 @@ static XMLElementNode* createGlyphNode (int c, const PhysicalFont &font, GFGlyph
sy = -sx;
}
ostringstream oss;
- glyph.writeSVG(oss, sx, sy);
+ glyph.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS, sx, sy);
glyph_node->addAttribute("d", oss.str());
return glyph_node;
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.h
index 6cd82f6ff39..e8d848aa0ec 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SVGTree.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SVGTree.h
@@ -88,10 +88,11 @@ class SVGTree
XMLElementNode* rootNode () const {return _root;}
public:
- static bool USE_FONTS; ///< if true, create font references and don't draw paths directly
- static bool CREATE_STYLE; ///< should style elements and class attributes be used to reference fonts?
+ static bool USE_FONTS; ///< if true, create font references and don't draw paths directly
+ static bool CREATE_STYLE; ///< use style elements and class attributes to reference fonts?
static bool CREATE_USE_ELEMENTS; ///< allow generation of <use/> elements?
- static double ZOOM_FACTOR; ///< factor applied to width/height attribute
+ static bool RELATIVE_PATH_CMDS; ///< relative path commands rather than absolute ones?
+ static double ZOOM_FACTOR; ///< factor applied to width/height attribute
protected:
void newTextNode (double x, double y);
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.cpp
index 6e91a05442d..6e91a05442d 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.h
index fa69e4129ed..fa69e4129ed 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SignalHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SignalHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialActions.h
index 0222a977955..0222a977955 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialActions.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialActions.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialHandler.h
index c9779836106..c9779836106 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.cpp
index 9c9b95f62ad..f10946b1d1e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.cpp
@@ -131,7 +131,6 @@ void SpecialManager::preprocess (const string &special, SpecialActions *actions)
* @param[in] special the special expression
* @param[in] dvi2bp factor to convert DVI units to PS points
* @param[in] actions actions the special handlers can perform
- * @param[in] listener object that wants to be notified about the processing state
* @return true if the special could be processed successfully
* @throw SpecialException in case of errors during special processing */
bool SpecialManager::process (const string &special, double dvi2bp, SpecialActions *actions) const {
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.h
index 2ea14da992b..2ea14da992b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/SpecialManager.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/SpecialManager.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.cpp
index 35a1cb1a583..35a1cb1a583 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.h
index 82679254cdc..82679254cdc 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.cpp
index 203a1788f87..203a1788f87 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.h
index f3ba391b044..f3ba391b044 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/StreamWriter.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/StreamWriter.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.cpp
index c37cd7e7eb6..c37cd7e7eb6 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.h
index eafa683e30b..eafa683e30b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Subfont.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Subfont.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.cpp
index 6769f843cae..6769f843cae 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.h
index 7200c93f291..7200c93f291 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/System.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/System.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.cpp
index db36b7f50b6..db36b7f50b6 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.h
index a7941874b30..a7941874b30 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TFM.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TFM.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.cpp
index e95111d196b..e95111d196b 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.h
index 08ac7e6300a..08ac7e6300a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Terminal.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Terminal.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.cpp
index 7e24fd6fcf7..5d5f1b23b76 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.cpp
@@ -78,7 +78,7 @@ static bool is_greater_or_equal (UInt32 a, UInt32 b) {return a >= b;}
/** Adds index to unicode mappings for a given range of character indexes.
* @param[in] minIndex lower bound of range to fill
* @param[in] maxIndex upper bound of range to fill
- * @param[in] value first unicode point to add (if possible)
+ * @param[in] ucp first unicode point to add (if possible)
* @param[in,out] used_ucps unicode points already in use
* @param[in] ascending if true, fill range from lower to upper bound
* @return true on success */
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.h
index 80ad10dc874..80ad10dc874 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ToUnicodeMap.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ToUnicodeMap.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.cpp
index 9f4d38d6189..c460542ca8e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.cpp
@@ -25,7 +25,9 @@
#include "Color.h"
#include "InputBuffer.h"
#include "InputReader.h"
+#include "GraphicPath.h"
#include "SpecialActions.h"
+#include "SVGTree.h"
#include "TpicSpecialHandler.h"
#include "XMLNode.h"
#include "XMLString.h"
@@ -118,56 +120,55 @@ void TpicSpecialHandler::drawLines (bool stroke, bool fill, double ddist, Specia
* @param[in] ddist length of dashes and gaps
* @param[in] actions object providing the actions that can be performed by the SpecialHandler */
void TpicSpecialHandler::drawSplines (double ddist, SpecialActions *actions) {
- if (actions && !_points.empty()) {
- const size_t size = _points.size();
- if (size < 3)
- drawLines(true, false, ddist, actions);
+ if (!actions || _points.empty())
+ return;
+ const size_t size = _points.size();
+ if (size < 3)
+ drawLines(true, false, ddist, actions);
+ else {
+ DPair p(actions->getX(), actions->getY());
+ GraphicPath<double> path;
+ path.moveto(p+_points[0]);
+ DPair mid = p+_points[0]+(_points[1]-_points[0])/2.0;
+ path.lineto(mid);
+ actions->embed(p+_points[0]);
+ for (size_t i=1; i < size-1; i++) {
+ const DPair p0 = p+_points[i-1];
+ const DPair p1 = p+_points[i];
+ const DPair p2 = p+_points[i+1];
+ mid = p1+(p2-p1)/2.0;
+ path.conicto(p1, mid);
+ actions->embed(mid);
+ actions->embed((p0+p1*6.0+p2)/8.0, _penwidth);
+ }
+ if (_points[0] == _points[size-1]) // closed path?
+ path.closepath();
else {
- double x = actions->getX();
- double y = actions->getY();
- DPair p(x,y);
- ostringstream oss;
- oss << 'M' << XMLString(x+_points[0].x()) << ',' << XMLString(y+_points[0].y());
- DPair mid = p+_points[0]+(_points[1]-_points[0])/2.0;
- oss << 'L' << XMLString(mid.x()) << ',' << XMLString(mid.y());
- actions->embed(p+_points[0]);
- for (size_t i=1; i < size-1; i++) {
- const DPair p0 = p+_points[i-1];
- const DPair p1 = p+_points[i];
- const DPair p2 = p+_points[i+1];
- mid = p1+(p2-p1)/2.0;
- oss << 'Q' << XMLString(p1.x()) << ',' << XMLString(p1.y())
- << ' ' << XMLString(mid.x()) << ',' << XMLString(mid.y());
- actions->embed(mid);
- actions->embed((p0+p1*6.0+p2)/8.0, _penwidth);
- }
- if (_points[0] == _points[size-1]) // closed path?
- oss << 'Z';
- else {
- oss << 'L' << XMLString(x+_points[size-1].x()) << ',' << XMLString(y+_points[size-1].y());
- actions->embed(p+_points[size-1]);
- }
-
- Color color = actions->getColor();
- color *= _fill;
- XMLElementNode *path = new XMLElementNode("path");
- if (_fill >= 0) {
- if (_points[0] != _points[size-1])
- oss << 'Z';
- path->addAttribute("fill", color.rgbString());
- }
- else
- path->addAttribute("fill", "none");
+ path.lineto(p+_points[size-1]);
+ actions->embed(p+_points[size-1]);
+ }
- path->addAttribute("d", oss.str());
- path->addAttribute("stroke", actions->getColor().rgbString());
- path->addAttribute("stroke-width", XMLString(_penwidth));
- if (ddist > 0)
- path->addAttribute("stroke-dasharray", XMLString(ddist));
- else if (ddist < 0)
- path->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist));
- actions->appendToPage(path);
+ Color color = actions->getColor();
+ color *= _fill;
+ XMLElementNode *pathElem = new XMLElementNode("path");
+ if (_fill >= 0) {
+ if (_points[0] != _points[size-1])
+ path.closepath();
+ pathElem->addAttribute("fill", color.rgbString());
}
+ else
+ pathElem->addAttribute("fill", "none");
+
+ ostringstream oss;
+ path.writeSVG(oss, SVGTree::RELATIVE_PATH_CMDS);
+ pathElem->addAttribute("d", oss.str());
+ pathElem->addAttribute("stroke", actions->getColor().rgbString());
+ pathElem->addAttribute("stroke-width", XMLString(_penwidth));
+ if (ddist > 0)
+ pathElem->addAttribute("stroke-dasharray", XMLString(ddist));
+ else if (ddist < 0)
+ pathElem->addAttribute("stroke-dasharray", XMLString(_penwidth) + ' ' + XMLString(-ddist));
+ actions->appendToPage(pathElem);
}
reset();
}
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.h
index 424721dbffc..424721dbffc 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/TpicSpecialHandler.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/TpicSpecialHandler.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.cpp
index f0fdde17898..f0fdde17898 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.h
index 41be47749cd..41be47749cd 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/Unicode.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/Unicode.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFActions.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFActions.h
index a8e86831fe9..a8e86831fe9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFActions.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFActions.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.cpp
index 45d0ed7da27..45d0ed7da27 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.h
index f6d9474ccbe..f6d9474ccbe 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VFReader.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VFReader.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VectorStream.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VectorStream.h
index 92ce8a68437..92ce8a68437 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/VectorStream.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/VectorStream.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.cpp
index caee2ec7439..caee2ec7439 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.h
index 4a2dd3e5318..4a2dd3e5318 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLDocument.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLDocument.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.cpp
index 1fb40368f19..1fb40368f19 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.h
index 2924e038adb..2924e038adb 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLNode.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLNode.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.cpp
index 4911b6c6a19..4911b6c6a19 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.h
index 311d7e535b9..311d7e535b9 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/XMLString.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/XMLString.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/dvisvgm.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/dvisvgm.cpp
index 1e76cf68f57..5af35683355 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/dvisvgm.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/dvisvgm.cpp
@@ -19,6 +19,7 @@
*************************************************************************/
#include <config.h>
+#include <clipper.hpp>
#include <cmath>
#include <fstream>
#include <iomanip>
@@ -43,6 +44,7 @@
#include "Message.h"
#include "PageSize.h"
#include "PSInterpreter.h"
+#include "PsSpecialHandler.h"
#include "SignalHandler.h"
#include "SpecialManager.h"
#include "SVGOutputBase.h"
@@ -276,6 +278,7 @@ static void print_version (bool extended) {
oss << " (" TARGET_SYSTEM ")";
int len = oss.str().length();
oss << "\n" << string(len, '-') << "\n"
+ "clipper: " << CLIPPER_VERSION "\n"
"freetype: " << FontEngine::version() << "\n";
Ghostscript gs;
@@ -333,8 +336,7 @@ int main (int argc, char *argv[]) {
return 0;
}
if (args.list_specials_given()) {
- SVGOutput out;
- DVIToSVG dvisvg(cin, out);
+ DVIToSVG::setProcessSpecials();
SpecialManager::instance().writeHandlerInfo(cout);
return 0;
}
@@ -368,11 +370,13 @@ int main (int argc, char *argv[]) {
SVGTree::USE_FONTS = !args.no_fonts_given();
SVGTree::CREATE_USE_ELEMENTS = args.no_fonts_arg() < 1;
SVGTree::ZOOM_FACTOR = args.zoom_arg();
+ SVGTree::RELATIVE_PATH_CMDS = args.relative_given();
DVIToSVG::TRACE_MODE = args.trace_all_given() ? (args.trace_all_arg() ? 'a' : 'm') : 0;
Message::LEVEL = args.verbosity_arg();
PhysicalFont::EXACT_BBOX = args.exact_given();
PhysicalFont::KEEP_TEMP_FILES = args.keep_given();
PhysicalFont::METAFONT_MAG = args.mag_arg();
+ PsSpecialHandler::COMPUTE_CLIPPATHS_INTERSECTIONS = args.clipjoin_given();
XMLString::DECIMAL_PLACES = max(0, min(6, args.precision_arg()));
if (!HtmlSpecialHandler::setLinkMarker(args.linkmark_arg()))
Message::wstream(true) << "invalid argument '"+args.linkmark_arg()+"' supplied for option --linkmark\n";
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.cpp
index 2893c299891..2893c299891 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.cpp
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.h
index 60f38c4fac7..60f38c4fac7 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/gzstream.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/gzstream.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/iapi.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/iapi.h
index 8e29d938d03..8e29d938d03 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/iapi.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/iapi.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ierrors.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ierrors.h
index 3184341177e..3184341177e 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/ierrors.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/ierrors.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/macros.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/macros.h
index 73217c763e0..73217c763e0 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/macros.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/macros.h
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.dtd b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.dtd
index d8444c94c9f..d8444c94c9f 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.dtd
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.dtd
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.xml b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.xml
index d1029f7768b..35b8618ff54 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/options.xml
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/options.xml
@@ -46,6 +46,9 @@
<arg type="string" name="size" default="min"/>
<description>set size of bounding box</description>
</option>
+ <option long="clipjoin" short="j">
+ <description>compute intersection of clipping paths</description>
+ </option>
<option long="linkmark" short="L">
<arg type="string" name="style" default="box"/>
<description>select how to mark hyperlinked areas</description>
@@ -58,6 +61,9 @@
<arg type="int" name="number" default="0"/>
<description>set number of decimal points (0-6)</description>
</option>
+ <option long="relative" short="R">
+ <description>create relative path commands</description>
+ </option>
<option long="stdout" short="s">
<description>write SVG output to stdout</description>
</option>
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.8/src/psdefs.cpp b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/psdefs.cpp
new file mode 100644
index 00000000000..a9fd027fc97
--- /dev/null
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/psdefs.cpp
@@ -0,0 +1,87 @@
+/*************************************************************************
+** psdefs.cpp **
+** **
+** This file is part of dvisvgm -- the DVI to SVG converter **
+** Copyright (C) 2005-2014 Martin Gieseking <martin.gieseking@uos.de> **
+** **
+** This program is free software; you can redistribute it and/or **
+** modify it under the terms of the GNU General Public License as **
+** published by the Free Software Foundation; either version 3 of **
+** the License, or (at your option) any later version. **
+** **
+** This program is distributed in the hope that it will be useful, but **
+** WITHOUT ANY WARRANTY; without even the implied warranty of **
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
+** GNU General Public License for more details. **
+** **
+** You should have received a copy of the GNU General Public License **
+** along with this program; if not, see <http://www.gnu.org/licenses/>. **
+*************************************************************************/
+
+#include "PSInterpreter.h"
+
+const char *PSInterpreter::PSDEFS =
+"3 dict dup begin/Install{matrix setmatrix}def/HWResolution[72 72]def/PageSize["
+"10000 10000]def end setpagedevice/@dodraw true store/@patcnt 0 store/@SD syste"
+"mdict def/@UD userdict def true setglobal @SD/:save @SD/save get put @SD/:rest"
+"ore @SD/restore get put @SD/:gsave @SD/gsave get put @SD/:grestore @SD/grestor"
+"e get put @SD/:grestoreall @SD/grestoreall get put @SD/:newpath @SD/newpath ge"
+"t put @SD/:stroke @SD/stroke get put @SD/:fill @SD/fill get put @SD/:eofill @S"
+"D/eofill get put @SD/:clip @SD/clip get put @SD/:eoclip @SD/eoclip get put @SD"
+"/:charpath @SD/charpath get put @SD/:show @SD/show get put @SD/.setopacityalph"
+"a known not{@SD/.setopacityalpha{pop}put}if @SD/prseq{-1 1{-1 roll =only( )pri"
+"nt}for(\\n)print}put @SD/prcmd{( )exch(\\ndvi.)3{print}repeat prseq}put @SD/cv"
+"xall{{cvx}forall}put @SD/defpr{[exch[/copy @SD]cvxall 5 -1 roll dup 6 1 roll[/"
+"get/exec]cvxall 6 -1 roll dup 7 1 roll 4 -1 roll dup 5 1 roll dup length strin"
+"g cvs/prcmd cvx]cvx def}put @SD/querypos{{currentpoint}stopped{$error/newerror"
+" false put}{2(querypos)prcmd}ifelse}put @SD/applyscalevals{1 0 transform 0 0 t"
+"ransform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 0 1 transform 0 0"
+" transform 3 -1 roll sub dup mul 3 1 roll sub dup mul add sqrt 1 0 transform d"
+"up mul exch dup dup mul 3 -1 roll add sqrt div 3(applyscalevals)prcmd}put @SD/"
+"prpath{{2(moveto)prcmd}{2(lineto)prcmd}{6(curveto)prcmd}{0(closepath)prcmd}pat"
+"hforall}put @SD/charpath{/@dodraw false store :charpath/@dodraw true store}put"
+" @SD/show{@dodraw{dup :gsave currentpoint :newpath moveto true charpath eofill"
+" :grestore/@dodraw false store :show/@dodraw true store}if}put @SD/newpath{:ne"
+"wpath 0 1(newpath)prcmd}put @SD/stroke{@dodraw{1 1(newpath)prcmd prpath 0(stro"
+"ke)prcmd :newpath}{:stroke}ifelse}put @SD/fill{@dodraw{1 1(newpath)prcmd prpat"
+"h 0(fill)prcmd :newpath}{:fill}ifelse}put @SD/eofill{@dodraw{1 1(newpath)prcmd"
+" prpath 0(eofill)prcmd :newpath}{:eofill}ifelse}put @SD/clip{:clip 0 1(newpath"
+")prcmd prpath 0(clip)prcmd}put @SD/eoclip{:eoclip 1 1(newpath)prcmd prpath 0(e"
+"oclip)prcmd}put @SD/bop{pop pop}put/@rect{4 -2 roll moveto exch dup 0 rlineto "
+"exch 0 exch rlineto neg 0 rlineto closepath}bind def/@rectcc{4 -2 roll moveto "
+"2 copy 0 lt exch 0 lt xor{dup 0 exch rlineto exch 0 rlineto neg 0 exch rlineto"
+"}{exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto}ifelse closepath}bind d"
+"ef @SD/rectclip{:newpath dup type/arraytype eq{aload length 4 idiv{@rectcc}rep"
+"eat}{@rectcc}ifelse clip :newpath}put @SD/rectfill{gsave :newpath dup type/arr"
+"aytype eq{aload length 4 idiv{@rectcc}repeat}{@rectcc}ifelse fill grestore}put"
+" @SD/rectstroke{gsave :newpath dup type/arraytype eq{aload length 4 idiv{@rect"
+"}repeat}{@rect}ifelse stroke grestore}put false setglobal @SD readonly pop/ini"
+"tclip 0 defpr/clippath 0 defpr/sysexec{@SD exch get exec}def/adddot{dup length"
+" 1 add string dup 0 46 put dup 3 -1 roll 1 exch putinterval}def/setlinewidth{d"
+"up/setlinewidth sysexec applyscalevals 1(setlinewidth)prcmd}def/setlinecap 1 d"
+"efpr/setlinejoin 1 defpr/setmiterlimit 1 defpr/setdash{mark 3 1 roll 2 copy/se"
+"tdash sysexec applyscalevals exch aload length 1 add -1 roll counttomark(setda"
+"sh)prcmd pop}def/setgstate{currentlinewidth 1(setlinewidth)prcmd currentlineca"
+"p 1(setlinecap)prcmd currentlinejoin 1(setlinejoin)prcmd currentmiterlimit 1(s"
+"etmiterlimit)prcmd currentrgbcolor 3(setrgbcolor)prcmd 6 array currentmatrix a"
+"load pop 6(setmatrix)prcmd currentdash mark 3 1 roll exch aload length 1 add -"
+"1 roll counttomark(setdash)prcmd pop}def/save{@UD begin/@saveID vmstatus pop p"
+"op def end :save @saveID 1(save)prcmd}def/restore{:restore setgstate @UD/@save"
+"ID known{@UD begin @saveID end}{0}ifelse 1(restore)prcmd}def/gsave 0 defpr/gre"
+"store{:grestore setgstate 0(grestore)prcmd}def/grestoreall{:grestoreall setsta"
+"te 0(grestoreall)prcmd}def/rotate{dup type/arraytype ne{dup 1(rotate)prcmd}if/"
+"rotate sysexec}def/scale{dup type/arraytype ne{2 copy 2(scale)prcmd}if/scale s"
+"ysexec}def/translate{dup type/arraytype ne{2 copy 2(translate)prcmd}if/transla"
+"te sysexec}def/setmatrix{dup/setmatrix sysexec aload pop 6(setmatrix)prcmd}def"
+"/initmatrix{matrix setmatrix}def/concat{matrix currentmatrix matrix concatmatr"
+"ix setmatrix}def/makepattern{gsave <</mx 3 -1 roll >> begin dup/XUID[1000000 @"
+"patcnt]put mx/makepattern sysexec dup dup begin PatternType @patcnt BBox aload"
+" pop XStep YStep PaintType mx aload pop 15(makepattern)prcmd :newpath matrix s"
+"etmatrix PaintProc 0 1(makepattern)prcmd end/@patcnt @patcnt 1 add store end g"
+"restore}def/setpattern{begin PatternType 1 eq{PaintType 1 eq{XUID aload pop ex"
+"ch pop 1}{:gsave[currentcolorspace aload length -1 roll pop]setcolorspace/setc"
+"olor sysexec XUID aload pop exch pop currentrgbcolor :grestore 4}ifelse(setpat"
+"tern)prcmd}{/setpattern sysexec}ifelse end}def/setcolor{dup type/dicttype eq{s"
+"etpattern}{/setcolor sysexec}ifelse}def/setgray 1 defpr/setcmykcolor 4 defpr/s"
+"ethsbcolor 3 defpr/setrgbcolor 3 defpr/.setopacityalpha{dup/.setopacityalpha s"
+"ysexec 1(setopacityalpha)prcmd}def ";
diff --git a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/types.h b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/types.h
index 1e1daef928c..1e1daef928c 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-1.7/src/types.h
+++ b/Build/source/texk/dvisvgm/dvisvgm-1.8/src/types.h
diff --git a/Build/source/texk/dvisvgm/version.ac b/Build/source/texk/dvisvgm/version.ac
index 8a58a3a8c3c..83c5f06fa1d 100644
--- a/Build/source/texk/dvisvgm/version.ac
+++ b/Build/source/texk/dvisvgm/version.ac
@@ -8,4 +8,4 @@ dnl
dnl --------------------------------------------------------
dnl
dnl m4-include this file to define the current dvisvgm version
-m4_define([dvisvgm_version], [1.7])
+m4_define([dvisvgm_version], [1.8])