├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── README.md ├── config ├── product.xcconfig ├── project.xcconfig ├── project_debug.xcconfig ├── project_release.xcconfig └── test.xcconfig ├── lib └── triangle │ ├── triangle.c │ └── triangle.h ├── other ├── conforming_delaynay.png └── voronoi.png ├── sample ├── Info.plist ├── product.xcconfig ├── triangulation.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── Application.xcscheme └── triangulation │ ├── app.cc │ ├── app.h │ └── main.cc ├── script ├── build.sh ├── copy_headers.sh ├── make_gitignore.sh └── setup.sh ├── src └── takram │ ├── triangulation.cc │ ├── triangulation.h │ └── triangulation │ ├── delaunay_triangulator.cc │ ├── delaunay_triangulator.h │ ├── edge.h │ ├── edge_iterator.cc │ ├── edge_iterator.h │ ├── library.h │ ├── point.h │ ├── result.cc │ ├── result.h │ ├── triangle_iterator.cc │ ├── triangle_iterator.h │ ├── triangulator.cc │ ├── triangulator.h │ ├── types.h │ ├── voronoi_triangulator.cc │ └── voronoi_triangulator.h ├── test └── test.cc ├── triangulation.sln ├── triangulation.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── triangulation ├── gtest.vcxproj ├── gtest.vcxproj.filters ├── gtest_main.vcxproj ├── gtest_main.vcxproj.filters ├── test.vcxproj ├── test.vcxproj.filters ├── triangulation.vcxproj └── triangulation.vcxproj.filters /.gitignore: -------------------------------------------------------------------------------- 1 | # https://github.com/github/gitignore/blob/master/Global/OSX.gitignore 2 | 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | # Thumbnails 11 | ._* 12 | 13 | # Files that might appear in the root of a volume 14 | .DocumentRevisions-V100 15 | .fseventsd 16 | .Spotlight-V100 17 | .TemporaryItems 18 | .Trashes 19 | .VolumeIcon.icns 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk 27 | 28 | # https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 29 | 30 | # Windows image file caches 31 | Thumbs.db 32 | ehthumbs.db 33 | 34 | # Folder config file 35 | Desktop.ini 36 | 37 | # Recycle Bin used on file shares 38 | $RECYCLE.BIN/ 39 | 40 | # Windows Installer files 41 | *.cab 42 | *.msi 43 | *.msm 44 | *.msp 45 | 46 | # Windows shortcuts 47 | *.lnk 48 | 49 | # https://github.com/github/gitignore/blob/master/Global/Xcode.gitignore 50 | 51 | # Xcode 52 | # 53 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 54 | 55 | ## Build generated 56 | build/ 57 | DerivedData/ 58 | 59 | ## Various settings 60 | *.pbxuser 61 | !default.pbxuser 62 | *.mode1v3 63 | !default.mode1v3 64 | *.mode2v3 65 | !default.mode2v3 66 | *.perspectivev3 67 | !default.perspectivev3 68 | xcuserdata/ 69 | 70 | ## Other 71 | *.moved-aside 72 | *.xccheckout 73 | *.xcscmblueprint 74 | 75 | # https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 76 | 77 | ## Ignore Visual Studio temporary files, build results, and 78 | ## files generated by popular Visual Studio add-ons. 79 | 80 | # User-specific files 81 | *.suo 82 | *.user 83 | *.userosscache 84 | *.sln.docstates 85 | 86 | # User-specific files (MonoDevelop/Xamarin Studio) 87 | *.userprefs 88 | 89 | # Build results 90 | [Dd]ebug/ 91 | [Dd]ebugPublic/ 92 | [Rr]elease/ 93 | [Rr]eleases/ 94 | x64/ 95 | x86/ 96 | bld/ 97 | [Bb]in/ 98 | [Oo]bj/ 99 | [Ll]og/ 100 | 101 | # Visual Studio 2015 cache/options directory 102 | .vs/ 103 | # Uncomment if you have tasks that create the project's static files in wwwroot 104 | #wwwroot/ 105 | 106 | # MSTest test Results 107 | [Tt]est[Rr]esult*/ 108 | [Bb]uild[Ll]og.* 109 | 110 | # NUNIT 111 | *.VisualState.xml 112 | TestResult.xml 113 | 114 | # Build Results of an ATL Project 115 | [Dd]ebugPS/ 116 | [Rr]eleasePS/ 117 | dlldata.c 118 | 119 | # DNX 120 | project.lock.json 121 | artifacts/ 122 | 123 | *_i.c 124 | *_p.c 125 | *_i.h 126 | *.ilk 127 | *.meta 128 | *.obj 129 | *.pch 130 | *.pdb 131 | *.pgc 132 | *.pgd 133 | *.rsp 134 | *.sbr 135 | *.tlb 136 | *.tli 137 | *.tlh 138 | *.tmp 139 | *.tmp_proj 140 | *.log 141 | *.vspscc 142 | *.vssscc 143 | .builds 144 | *.pidb 145 | *.svclog 146 | *.scc 147 | 148 | # Chutzpah Test files 149 | _Chutzpah* 150 | 151 | # Visual C++ cache files 152 | ipch/ 153 | *.aps 154 | *.ncb 155 | *.opendb 156 | *.opensdf 157 | *.sdf 158 | *.cachefile 159 | *.VC.db 160 | *.VC.VC.opendb 161 | 162 | # Visual Studio profiler 163 | *.psess 164 | *.vsp 165 | *.vspx 166 | *.sap 167 | 168 | # TFS 2012 Local Workspace 169 | $tf/ 170 | 171 | # Guidance Automation Toolkit 172 | *.gpState 173 | 174 | # ReSharper is a .NET coding add-in 175 | _ReSharper*/ 176 | *.[Rr]e[Ss]harper 177 | *.DotSettings.user 178 | 179 | # JustCode is a .NET coding add-in 180 | .JustCode 181 | 182 | # TeamCity is a build add-in 183 | _TeamCity* 184 | 185 | # DotCover is a Code Coverage Tool 186 | *.dotCover 187 | 188 | # NCrunch 189 | _NCrunch_* 190 | .*crunch*.local.xml 191 | nCrunchTemp_* 192 | 193 | # MightyMoose 194 | *.mm.* 195 | AutoTest.Net/ 196 | 197 | # Web workbench (sass) 198 | .sass-cache/ 199 | 200 | # Installshield output folder 201 | [Ee]xpress/ 202 | 203 | # DocProject is a documentation generator add-in 204 | DocProject/buildhelp/ 205 | DocProject/Help/*.HxT 206 | DocProject/Help/*.HxC 207 | DocProject/Help/*.hhc 208 | DocProject/Help/*.hhk 209 | DocProject/Help/*.hhp 210 | DocProject/Help/Html2 211 | DocProject/Help/html 212 | 213 | # Click-Once directory 214 | publish/ 215 | 216 | # Publish Web Output 217 | *.[Pp]ublish.xml 218 | *.azurePubxml 219 | # TODO: Comment the next line if you want to checkin your web deploy settings 220 | # but database connection strings (with potential passwords) will be unencrypted 221 | *.pubxml 222 | *.publishproj 223 | 224 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 225 | # checkin your Azure Web App publish settings, but sensitive information contained 226 | # in these scripts will be unencrypted 227 | PublishScripts/ 228 | 229 | # NuGet Packages 230 | *.nupkg 231 | # The packages folder can be ignored because of Package Restore 232 | **/packages/* 233 | # except build/, which is used as an MSBuild target. 234 | !**/packages/build/ 235 | # Uncomment if necessary however generally it will be regenerated when needed 236 | #!**/packages/repositories.config 237 | # NuGet v3's project.json files produces more ignoreable files 238 | *.nuget.props 239 | *.nuget.targets 240 | 241 | # Microsoft Azure Build Output 242 | csx/ 243 | *.build.csdef 244 | 245 | # Microsoft Azure Emulator 246 | ecf/ 247 | rcf/ 248 | 249 | # Windows Store app package directories and files 250 | AppPackages/ 251 | BundleArtifacts/ 252 | Package.StoreAssociation.xml 253 | _pkginfo.txt 254 | 255 | # Visual Studio cache files 256 | # files ending in .cache can be ignored 257 | *.[Cc]ache 258 | # but keep track of directories ending in .cache 259 | !*.[Cc]ache/ 260 | 261 | # Others 262 | ClientBin/ 263 | ~$* 264 | *~ 265 | *.dbmdl 266 | *.dbproj.schemaview 267 | *.pfx 268 | *.publishsettings 269 | node_modules/ 270 | orleans.codegen.cs 271 | 272 | # Since there are multiple workflows, uncomment next line to ignore bower_components 273 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 274 | #bower_components/ 275 | 276 | # RIA/Silverlight projects 277 | Generated_Code/ 278 | 279 | # Backup & report files from converting an old project file 280 | # to a newer Visual Studio version. Backup files are not needed, 281 | # because we have git ;-) 282 | _UpgradeReport_Files/ 283 | Backup*/ 284 | UpgradeLog*.XML 285 | UpgradeLog*.htm 286 | 287 | # SQL Server files 288 | *.mdf 289 | *.ldf 290 | 291 | # Business Intelligence projects 292 | *.rdl.data 293 | *.bim.layout 294 | *.bim_*.settings 295 | 296 | # Microsoft Fakes 297 | FakesAssemblies/ 298 | 299 | # GhostDoc plugin setting file 300 | *.GhostDoc.xml 301 | 302 | # Node.js Tools for Visual Studio 303 | .ntvs_analysis.dat 304 | 305 | # Visual Studio 6 build log 306 | *.plg 307 | 308 | # Visual Studio 6 workspace options file 309 | *.opt 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # JetBrains Rider 327 | .idea/ 328 | *.sln.iml 329 | 330 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/googletest"] 2 | path = lib/googletest 3 | url = git@github.com:google/googletest.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | compiler: 3 | - clang 4 | git: 5 | submodules: false 6 | before_install: 7 | - sed -i '' 's/git@github.com:/https:\/\/github.com\//' .gitmodules 8 | - git submodule update --init --recursive 9 | before_script: 10 | - git clone git://github.com/takram-design-engineering/takram-math.git ../takram-math 11 | - mkdir build 12 | - cd build 13 | - cmake .. 14 | script: 15 | - make 16 | - make test 17 | notifications: 18 | slack: 19 | secure: kD+DBYbJpPXW7X/kjWV4l/l0Esgz9+n8u/M9QTURWKHVMwqNAHW2PAyt2hSL/lqOaSi+xW7L60yOS0IJZYnfpqaX5DU+ONTQMK3XuK5CFXn641NpDx/QUecHzxCQFnQsmKMEC7DFpc7vUVRQIgba9cpYNHkCROFV+5tedk39dzF4CAb7q0ZAyfjPblCkBUqpgFWX7kC+hhm/AquICeLzYB/ekAd3GNhtf6k9xXpRXci+Bxeaf3n5rsHZte4uXsyedhyS5ppsuyAxjLkH5mfSjTuGVO4upQj8MEU8pUPdltKSlziVD5w/ioAPfktFg21lJELR74/1NCg1Kg55yNvKVwbGPOk/P91GwwLR58sX7IJ7r/2J/GBAzHSERqleOHHYV1/+odthz4z2EWx7k/AIq+Nb3TGYiAy3E3PTwGjMJ5uDyvPmo6N1SNAODaGMd+d9Z3h+lXlhHLKASA3eWQ9Rbl6QsnkTFMSnZQ0vheJk79x0JCPQSp0h28nxVlTMhwBzgylpQZQnhqYewVp1r5tK2ToPurQGhDTuAl9XVPPZswp2yMvQZa/6fbZsb9uYUbX+m2IukA9yVP7Aa4bs4bzsrxNFOy67LRnKs85gWjQ+6uNILJMf6hggH8cQT9QkJh9VlpXsn9AQ/ChGGLhtYgC/psidD6y4A7i2w0104nluqdk= 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # CMakeLists.txt 3 | # 4 | # The MIT License 5 | # 6 | # Copyright (C) 2014-2015 Shota Matsuda 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a 9 | # copy of this software and associated documentation files (the "Software"), 10 | # to deal in the Software without restriction, including without limitation 11 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | # and/or sell copies of the Software, and to permit persons to whom the 13 | # Software is furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | # DEALINGS IN THE SOFTWARE. 25 | # 26 | 27 | # Project settings 28 | cmake_minimum_required(VERSION 2.8) 29 | project(takram_triangulation CXX C) 30 | 31 | # Configuration types 32 | set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "configs" FORCE) 33 | if (DEFINED CMAKE_BUILD_TYPE) 34 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES}) 35 | endif() 36 | 37 | # Compiler flags 38 | set(CMAKE_C_FLAGS "-Wall") 39 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") 40 | set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG") 41 | set(CMAKE_CXX_FLAGS "-std=c++1y -stdlib=libc++ -Wall") 42 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") 43 | set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG") 44 | message(STATUS "") 45 | message(STATUS "Configuration: ${CMAKE_BUILD_TYPE}") 46 | message(STATUS "C++ flags (Release): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") 47 | message(STATUS "C++ flags (Debug): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") 48 | message(STATUS "C flags (Release): ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") 49 | message(STATUS "C flags (Debug): ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") 50 | message(STATUS "") 51 | 52 | # Run path 53 | set(CMAKE_MACOSX_RPATH ON) 54 | set(CMAKE_SKIP_BUILD_RPATH FALSE) 55 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 56 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") 57 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 58 | 59 | # Include directories 60 | include_directories("${${PROJECT_NAME}_SOURCE_DIR}/src") 61 | include_directories("${${PROJECT_NAME}_SOURCE_DIR}/lib") 62 | include_directories("${${PROJECT_NAME}_SOURCE_DIR}/../takram-math/src") 63 | 64 | # Library 65 | file(GLOB_RECURSE SOURCES "src/*.cc" "src/*.c") 66 | file(GLOB_RECURSE SOURCES "lib/triangle/triangle.c") 67 | set_source_files_properties("lib/triangle/triangle.c" PROPERTIES COMPILE_FLAGS "-DTRILIBRARY=1 -DANSI_DECLARATORS=1") 68 | add_library("${PROJECT_NAME}_static" STATIC ${SOURCES}) 69 | add_library("${PROJECT_NAME}_shared" SHARED ${SOURCES}) 70 | set_target_properties("${PROJECT_NAME}_static" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") 71 | set_target_properties("${PROJECT_NAME}_shared" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") 72 | 73 | # Unit test 74 | file(GLOB_RECURSE TESTS "test/*.cc") 75 | list(LENGTH TESTS TEST_COUNT) 76 | if (TEST_COUNT) 77 | enable_testing() 78 | add_subdirectory("lib/googletest/googletest") 79 | include_directories("lib/googletest/googletest/include") 80 | add_executable("${PROJECT_NAME}_test" ${TESTS}) 81 | target_link_libraries("${PROJECT_NAME}_test" "gtest" "gtest_main") 82 | target_link_libraries("${PROJECT_NAME}_test" "${PROJECT_NAME}_shared") 83 | add_test("${PROJECT_NAME}" "${PROJECT_NAME}_test") 84 | endif() 85 | 86 | # Install settings 87 | install(TARGETS "${PROJECT_NAME}_static" DESTINATION "lib") 88 | install(TARGETS "${PROJECT_NAME}_shared" DESTINATION "lib") 89 | install(DIRECTORY "src/takram" DESTINATION "include" FILES_MATCHING PATTERN "*.h") 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Triangulation 2 | ============= 3 | 4 | A C++ library to generate Delaunay and Voronoi triangulations 5 | 6 | [![Build Status](https://travis-ci.org/takram-design-engineering/takram-triangulation.svg)](https://travis-ci.org/takram-design-engineering/takram-triangulation) [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat 7 | )](http://mit-license.org) 8 | 9 | ## Classes 10 | 11 | - [`takram::triangulation::Triangulator`](src/takram/triangulation/triangulator.h) 12 | - [`takram::triangulation::DelaunayTriangulator`](src/takram/triangulation/delaunay_triangulator.h) 13 | - [`takram::triangulation::VoronoiTriangulator`](src/takram/triangulation/voronoi_triangulator.h) 14 | 15 | ## Example 16 | 17 | The following code outputs Voronoi lines and Delaunay triangles for randomly generated points. 18 | 19 | ```cc 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "takram/triangulation.h" 26 | 27 | namespace { 28 | 29 | struct Point { 30 | double x; 31 | double y; 32 | }; 33 | 34 | } // namespace 35 | 36 | int main() { 37 | std::random_device random_device; 38 | std::default_random_engine engine(random_device()); 39 | std::uniform_real_distribution<> distribution(0.0, 1.0); 40 | std::vector points(10); 41 | for (auto& point : points) { 42 | point.x = distribution(engine); 43 | point.y = distribution(engine); 44 | } 45 | takram::VoronoiTriangulator voronoi; 46 | if (voronoi(points)) { 47 | for (const auto& line : voronoi) { 48 | std::cout << line << std::endl; 49 | } 50 | } 51 | takram::DelaunayTriangulator delaunay; 52 | if (delaunay(points)) { 53 | for (const auto& triangle : delaunay) { 54 | std::cout << triangle << std::endl; 55 | } 56 | } 57 | return EXIT_SUCCESS; 58 | } 59 | ``` 60 | 61 | ## Parameters 62 | 63 | - *type* (Delaunay triangulation only) 64 | - `takram::DelaunayTriangulator::Type::DEFAULT` 65 | - Will generate a [Delaunay triangulation](http://www.cs.cmu.edu/~quake/triangle.defs.html#dt). 66 | - Equivalent to specifying neither [-p](http://www.cs.cmu.edu/~quake/triangle.p.html) nor [-D](http://www.cs.cmu.edu/~quake/triangle.switch.html) command line switch of Triangle library. 67 | - `takram::DelaunayTriangulator::Type::CONSTRAINED` 68 | - Will generate a [constrained Delaunay triangulation](http://www.cs.cmu.edu/~quake/triangle.defs.html#cdt). 69 | - Equivalent to the [-p](http://www.cs.cmu.edu/~quake/triangle.p.html) command line switch of Triangle library. 70 | - `takram::DelaunayTriangulator::Type::CONFORMING` 71 | - Will generate a [conforming Delaunay triangulation](http://www.cs.cmu.edu/~quake/triangle.defs.html#conform). 72 | - Equivalent to the [-D](http://www.cs.cmu.edu/~quake/triangle.switch.html) command line switch of Triangle library. 73 | - `takram::DelaunayTriangulator::Type::CONSTRAINED_CONFORMING` 74 | - Will generate a [constrained conforming Delaunay triangulation](http://www.cs.cmu.edu/~quake/triangle.defs.html#ccdt). 75 | - Equivalent to specifying both [-p](http://www.cs.cmu.edu/~quake/triangle.p.html) and [-D](http://www.cs.cmu.edu/~quake/triangle.switch.html) command line switch of Triangle library. 76 | - *min_angle* 77 | - Quality mesh generation with no angles smaller than 20 degrees. 78 | - Equivalent to the [-q](http://www.cs.cmu.edu/~quake/triangle.q.html) command line switch of Triangle library. 79 | - *max_area* 80 | - Imposes a maximum triangle area constraint. 81 | - Equivalent to the [-a](http://www.cs.cmu.edu/~quake/triangle.a.html) command line switch of Triangle library. 82 | - *max_steiner_points* 83 | - Specifies the maximum number of added [Steiner points](http://www.cs.cmu.edu/~quake/triangle.defs.html#steiner). 84 | - Equivalent to the [-S](http://www.cs.cmu.edu/~quake/triangle.S.html) command line switch of Triangle library. 85 | 86 | ## Setup Guide 87 | 88 | Run "setup.sh" inside "script" directory to initialize submodules and build dependant libraries. 89 | 90 | ### Dependencies 91 | 92 | - [Math](https://github.com/takram-design-engineering/takram-math) 93 | 94 | ### Submodules 95 | 96 | - [Google Test Framework](https://github.com/google/googletest) 97 | 98 | ## License 99 | 100 | The MIT License 101 | 102 | Copyright (C) 2014-2016 Shota Matsuda 103 | 104 | Permission is hereby granted, free of charge, to any person obtaining a copy 105 | of this software and associated documentation files (the "Software"), to deal 106 | in the Software without restriction, including without limitation the rights 107 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 108 | copies of the Software, and to permit persons to whom the Software is 109 | furnished to do so, subject to the following conditions: 110 | 111 | The above copyright notice and this permission notice shall be included in 112 | all copies or substantial portions of the Software. 113 | 114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 115 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 116 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 117 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 118 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 119 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 120 | THE SOFTWARE. 121 | 122 | --- 123 | 124 | Triangle
125 | A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.
126 | Version 1.6 127 | 128 | Copyright 1993, 1995, 1997, 1998, 2002, 2005 Jonathan Richard Shewchuk
129 | 2360 Woolsey #H
130 | Berkeley, California 94705-1927
131 | jrs@cs.berkeley.edu 132 | 133 | These programs may be freely redistributed under the condition that the 134 | copyright notices (including the copy of this notice in the code comments 135 | and the copyright notice printed when the `-h' switch is selected) are 136 | not removed, and no compensation is received. Private, research, and 137 | institutional use is free. You may distribute modified versions of this 138 | code UNDER THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT 139 | IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH 140 | SOURCE AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND 141 | CLEAR NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as 142 | part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT 143 | WITH THE AUTHOR. (If you are not directly supplying this code to a 144 | customer, and you are instead telling them how they can obtain it for 145 | free, then you are not required to make any arrangement with me.) 146 | -------------------------------------------------------------------------------- /config/product.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // product.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | // Search Paths 28 | USER_HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/src" "$(PROJECT_DIR)/lib" 29 | -------------------------------------------------------------------------------- /config/project.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // project.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2013-2016 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | // Deployment 28 | COMBINE_HIDPI_IMAGES = YES 29 | 30 | // Search Paths 31 | ALWAYS_SEARCH_USER_PATHS = NO 32 | 33 | // Apple LLVM - Code Generation 34 | GCC_DYNAMIC_NO_PIC = NO 35 | GCC_INLINES_ARE_PRIVATE_EXTERN = NO 36 | GCC_NO_COMMON_BLOCKS = YES 37 | GCC_SYMBOLS_PRIVATE_EXTERN = NO 38 | 39 | // Apple LLVM - Language 40 | GCC_C_LANGUAGE_STANDARD = gnu99 41 | 42 | // Apple LLVM - Language - C++ 43 | CLANG_CXX_LANGUAGE_STANDARD = gnu++14 44 | CLANG_CXX_LIBRARY = libc++ 45 | 46 | // Apple LLVM - Language - Modules 47 | CLANG_ENABLE_MODULES = YES 48 | 49 | // Apple LLVM - Language - Objective C 50 | CLANG_ENABLE_OBJC_ARC = YES 51 | 52 | // Apple LLVM - Preprocessing 53 | ENABLE_NS_ASSERTIONS = NO 54 | ENABLE_STRICT_OBJC_MSGSEND = YES 55 | 56 | // Apple LLVM - Warnings - All Languages 57 | GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 58 | GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES 59 | CLANG_WARN_DOCUMENTATION_COMMENTS = NO 60 | CLANG_WARN_EMPTY_BODY = YES 61 | GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES 62 | GCC_WARN_SHADOW = NO 63 | CLANG_WARN_BOOL_CONVERSION = YES 64 | CLANG_WARN_CONSTANT_CONVERSION = YES 65 | GCC_WARN_64_TO_32_BIT_CONVERSION = NO 66 | CLANG_WARN_ENUM_CONVERSION = YES 67 | CLANG_WARN_INT_CONVERSION = YES 68 | CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO 69 | CLANG_WARN_INFINITE_RECURSION = YES 70 | GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES 71 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR 72 | GCC_WARN_MISSING_PARENTHESES = YES 73 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES 74 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES 75 | GCC_WARN_ABOUT_MISSING_NEWLINE = NO 76 | CLANG_WARN_ASSIGN_ENUM = NO 77 | GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES 78 | GCC_WARN_SIGN_COMPARE = NO 79 | CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO 80 | GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = NO 81 | GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO 82 | GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES 83 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE 84 | GCC_WARN_UNKNOWN_PRAGMAS = NO 85 | CLANG_WARN_UNREACHABLE_CODE = YES 86 | GCC_WARN_UNUSED_FUNCTION = YES 87 | GCC_WARN_UNUSED_LABEL = YES 88 | GCC_WARN_UNUSED_PARAMETER = NO 89 | GCC_WARN_UNUSED_VALUE = YES 90 | GCC_WARN_UNUSED_VARIABLE = YES 91 | 92 | // Apple LLVM - Warnings - C++ 93 | CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO 94 | GCC_WARN_NON_VIRTUAL_DESTRUCTOR = NO 95 | GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO 96 | CLANG_WARN_SUSPICIOUS_MOVE = YES 97 | GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES 98 | CLANG_WARN_CXX0X_EXTENSIONS = YES 99 | 100 | // Apple LLVM - Warnings - Objective C 101 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR 102 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 103 | CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES 104 | CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = NO 105 | GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES 106 | GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO 107 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO 108 | GCC_WARN_STRICT_SELECTOR_MATCH = NO 109 | GCC_WARN_UNDECLARED_SELECTOR = YES 110 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR 111 | 112 | // User-Defined 113 | USE_HEADERMAP = NO 114 | -------------------------------------------------------------------------------- /config/project_debug.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // project_debug.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2013-2016 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "project.xcconfig" 28 | 29 | // Build Options 30 | DEBUG_INFORMATION_FORMAT = dwarf 31 | ENABLE_TESTABILITY = YES 32 | 33 | // Deployment 34 | COPY_PHASE_STRIP = NO 35 | 36 | // Apple LLVM - Code Generation 37 | GCC_OPTIMIZATION_LEVEL = 0 38 | GCC_FAST_MATH = NO 39 | 40 | // Apple LLVM - Preprocessing 41 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1 42 | 43 | // User-Defined 44 | MTL_ENABLE_DEBUG_INFO = YES 45 | -------------------------------------------------------------------------------- /config/project_release.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // project_release.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2013-2016 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "project.xcconfig" 28 | 29 | // Build Options 30 | DEBUG_INFORMATION_FORMAT = dwarf-with-dsym 31 | ENABLE_TESTABILITY = NO 32 | 33 | // Deployment 34 | COPY_PHASE_STRIP = YES 35 | 36 | // Apple LLVM - Code Generation 37 | GCC_OPTIMIZATION_LEVEL = s 38 | GCC_FAST_MATH = YES 39 | 40 | // Apple LLVM - Preprocessing 41 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1 42 | 43 | // User-Defined 44 | MTL_ENABLE_DEBUG_INFO = NO 45 | -------------------------------------------------------------------------------- /config/test.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // test.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | // Linking 28 | OTHER_LDFLAGS = $(inherited) "$(PROJECT_DIR)/build/googletest/libgtest.a" "$(PROJECT_DIR)/build/googletest/libgtest_main.a" 29 | 30 | // Search Paths 31 | USER_HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/lib/googletest/googletest/include" 32 | -------------------------------------------------------------------------------- /lib/triangle/triangle.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* */ 3 | /* (triangle.h) */ 4 | /* */ 5 | /* Include file for programs that call Triangle. */ 6 | /* */ 7 | /* Accompanies Triangle Version 1.6 */ 8 | /* July 28, 2005 */ 9 | /* */ 10 | /* Copyright 1996, 2005 */ 11 | /* Jonathan Richard Shewchuk */ 12 | /* 2360 Woolsey #H */ 13 | /* Berkeley, California 94705-1927 */ 14 | /* jrs@cs.berkeley.edu */ 15 | /* */ 16 | /*****************************************************************************/ 17 | 18 | /*****************************************************************************/ 19 | /* */ 20 | /* How to call Triangle from another program */ 21 | /* */ 22 | /* */ 23 | /* If you haven't read Triangle's instructions (run "triangle -h" to read */ 24 | /* them), you won't understand what follows. */ 25 | /* */ 26 | /* Triangle must be compiled into an object file (triangle.o) with the */ 27 | /* TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler */ 28 | /* switch). The makefile included with Triangle will do this for you if */ 29 | /* you run "make trilibrary". The resulting object file can be called via */ 30 | /* the procedure triangulate(). */ 31 | /* */ 32 | /* If the size of the object file is important to you, you may wish to */ 33 | /* generate a reduced version of triangle.o. The REDUCED symbol gets rid */ 34 | /* of all features that are primarily of research interest. Specifically, */ 35 | /* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */ 36 | /* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */ 37 | /* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */ 38 | /* eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches. */ 39 | /* */ 40 | /* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */ 41 | /* made in the makefile or in triangle.c itself. Putting these definitions */ 42 | /* in this file (triangle.h) will not create the desired effect. */ 43 | /* */ 44 | /* */ 45 | /* The calling convention for triangulate() follows. */ 46 | /* */ 47 | /* void triangulate(triswitches, in, out, vorout) */ 48 | /* char *triswitches; */ 49 | /* struct triangulateio *in; */ 50 | /* struct triangulateio *out; */ 51 | /* struct triangulateio *vorout; */ 52 | /* */ 53 | /* `triswitches' is a string containing the command line switches you wish */ 54 | /* to invoke. No initial dash is required. Some suggestions: */ 55 | /* */ 56 | /* - You'll probably find it convenient to use the `z' switch so that */ 57 | /* points (and other items) are numbered from zero. This simplifies */ 58 | /* indexing, because the first item of any type always starts at index */ 59 | /* [0] of the corresponding array, whether that item's number is zero or */ 60 | /* one. */ 61 | /* - You'll probably want to use the `Q' (quiet) switch in your final code, */ 62 | /* but you can take advantage of Triangle's printed output (including the */ 63 | /* `V' switch) while debugging. */ 64 | /* - If you are not using the `q', `a', `u', `D', `j', or `s' switches, */ 65 | /* then the output points will be identical to the input points, except */ 66 | /* possibly for the boundary markers. If you don't need the boundary */ 67 | /* markers, you should use the `N' (no nodes output) switch to save */ 68 | /* memory. (If you do need boundary markers, but need to save memory, a */ 69 | /* good nasty trick is to set out->pointlist equal to in->pointlist */ 70 | /* before calling triangulate(), so that Triangle overwrites the input */ 71 | /* points with identical copies.) */ 72 | /* - The `I' (no iteration numbers) and `g' (.off file output) switches */ 73 | /* have no effect when Triangle is compiled with TRILIBRARY defined. */ 74 | /* */ 75 | /* `in', `out', and `vorout' are descriptions of the input, the output, */ 76 | /* and the Voronoi output. If the `v' (Voronoi output) switch is not used, */ 77 | /* `vorout' may be NULL. `in' and `out' may never be NULL. */ 78 | /* */ 79 | /* Certain fields of the input and output structures must be initialized, */ 80 | /* as described below. */ 81 | /* */ 82 | /*****************************************************************************/ 83 | 84 | /*****************************************************************************/ 85 | /* */ 86 | /* The `triangulateio' structure. */ 87 | /* */ 88 | /* Used to pass data into and out of the triangulate() procedure. */ 89 | /* */ 90 | /* */ 91 | /* Arrays are used to store points, triangles, markers, and so forth. In */ 92 | /* all cases, the first item in any array is stored starting at index [0]. */ 93 | /* However, that item is item number `1' unless the `z' switch is used, in */ 94 | /* which case it is item number `0'. Hence, you may find it easier to */ 95 | /* index points (and triangles in the neighbor list) if you use the `z' */ 96 | /* switch. Unless, of course, you're calling Triangle from a Fortran */ 97 | /* program. */ 98 | /* */ 99 | /* Description of fields (except the `numberof' fields, which are obvious): */ 100 | /* */ 101 | /* `pointlist': An array of point coordinates. The first point's x */ 102 | /* coordinate is at index [0] and its y coordinate at index [1], followed */ 103 | /* by the coordinates of the remaining points. Each point occupies two */ 104 | /* REALs. */ 105 | /* `pointattributelist': An array of point attributes. Each point's */ 106 | /* attributes occupy `numberofpointattributes' REALs. */ 107 | /* `pointmarkerlist': An array of point markers; one int per point. */ 108 | /* */ 109 | /* `trianglelist': An array of triangle corners. The first triangle's */ 110 | /* first corner is at index [0], followed by its other two corners in */ 111 | /* counterclockwise order, followed by any other nodes if the triangle */ 112 | /* represents a nonlinear element. Each triangle occupies */ 113 | /* `numberofcorners' ints. */ 114 | /* `triangleattributelist': An array of triangle attributes. Each */ 115 | /* triangle's attributes occupy `numberoftriangleattributes' REALs. */ 116 | /* `trianglearealist': An array of triangle area constraints; one REAL per */ 117 | /* triangle. Input only. */ 118 | /* `neighborlist': An array of triangle neighbors; three ints per */ 119 | /* triangle. Output only. */ 120 | /* */ 121 | /* `segmentlist': An array of segment endpoints. The first segment's */ 122 | /* endpoints are at indices [0] and [1], followed by the remaining */ 123 | /* segments. Two ints per segment. */ 124 | /* `segmentmarkerlist': An array of segment markers; one int per segment. */ 125 | /* */ 126 | /* `holelist': An array of holes. The first hole's x and y coordinates */ 127 | /* are at indices [0] and [1], followed by the remaining holes. Two */ 128 | /* REALs per hole. Input only, although the pointer is copied to the */ 129 | /* output structure for your convenience. */ 130 | /* */ 131 | /* `regionlist': An array of regional attributes and area constraints. */ 132 | /* The first constraint's x and y coordinates are at indices [0] and [1], */ 133 | /* followed by the regional attribute at index [2], followed by the */ 134 | /* maximum area at index [3], followed by the remaining area constraints. */ 135 | /* Four REALs per area constraint. Note that each regional attribute is */ 136 | /* used only if you select the `A' switch, and each area constraint is */ 137 | /* used only if you select the `a' switch (with no number following), but */ 138 | /* omitting one of these switches does not change the memory layout. */ 139 | /* Input only, although the pointer is copied to the output structure for */ 140 | /* your convenience. */ 141 | /* */ 142 | /* `edgelist': An array of edge endpoints. The first edge's endpoints are */ 143 | /* at indices [0] and [1], followed by the remaining edges. Two ints per */ 144 | /* edge. Output only. */ 145 | /* `edgemarkerlist': An array of edge markers; one int per edge. Output */ 146 | /* only. */ 147 | /* `normlist': An array of normal vectors, used for infinite rays in */ 148 | /* Voronoi diagrams. The first normal vector's x and y magnitudes are */ 149 | /* at indices [0] and [1], followed by the remaining vectors. For each */ 150 | /* finite edge in a Voronoi diagram, the normal vector written is the */ 151 | /* zero vector. Two REALs per edge. Output only. */ 152 | /* */ 153 | /* */ 154 | /* Any input fields that Triangle will examine must be initialized. */ 155 | /* Furthermore, for each output array that Triangle will write to, you */ 156 | /* must either provide space by setting the appropriate pointer to point */ 157 | /* to the space you want the data written to, or you must initialize the */ 158 | /* pointer to NULL, which tells Triangle to allocate space for the results. */ 159 | /* The latter option is preferable, because Triangle always knows exactly */ 160 | /* how much space to allocate. The former option is provided mainly for */ 161 | /* people who need to call Triangle from Fortran code, though it also makes */ 162 | /* possible some nasty space-saving tricks, like writing the output to the */ 163 | /* same arrays as the input. */ 164 | /* */ 165 | /* Triangle will not free() any input or output arrays, including those it */ 166 | /* allocates itself; that's up to you. You should free arrays allocated by */ 167 | /* Triangle by calling the trifree() procedure defined below. (By default, */ 168 | /* trifree() just calls the standard free() library procedure, but */ 169 | /* applications that call triangulate() may replace trimalloc() and */ 170 | /* trifree() in triangle.c to use specialized memory allocators.) */ 171 | /* */ 172 | /* Here's a guide to help you decide which fields you must initialize */ 173 | /* before you call triangulate(). */ 174 | /* */ 175 | /* `in': */ 176 | /* */ 177 | /* - `pointlist' must always point to a list of points; `numberofpoints' */ 178 | /* and `numberofpointattributes' must be properly set. */ 179 | /* `pointmarkerlist' must either be set to NULL (in which case all */ 180 | /* markers default to zero), or must point to a list of markers. If */ 181 | /* `numberofpointattributes' is not zero, `pointattributelist' must */ 182 | /* point to a list of point attributes. */ 183 | /* - If the `r' switch is used, `trianglelist' must point to a list of */ 184 | /* triangles, and `numberoftriangles', `numberofcorners', and */ 185 | /* `numberoftriangleattributes' must be properly set. If */ 186 | /* `numberoftriangleattributes' is not zero, `triangleattributelist' */ 187 | /* must point to a list of triangle attributes. If the `a' switch is */ 188 | /* used (with no number following), `trianglearealist' must point to a */ 189 | /* list of triangle area constraints. `neighborlist' may be ignored. */ 190 | /* - If the `p' switch is used, `segmentlist' must point to a list of */ 191 | /* segments, `numberofsegments' must be properly set, and */ 192 | /* `segmentmarkerlist' must either be set to NULL (in which case all */ 193 | /* markers default to zero), or must point to a list of markers. */ 194 | /* - If the `p' switch is used without the `r' switch, then */ 195 | /* `numberofholes' and `numberofregions' must be properly set. If */ 196 | /* `numberofholes' is not zero, `holelist' must point to a list of */ 197 | /* holes. If `numberofregions' is not zero, `regionlist' must point to */ 198 | /* a list of region constraints. */ 199 | /* - If the `p' switch is used, `holelist', `numberofholes', */ 200 | /* `regionlist', and `numberofregions' is copied to `out'. (You can */ 201 | /* nonetheless get away with not initializing them if the `r' switch is */ 202 | /* used.) */ 203 | /* - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */ 204 | /* ignored. */ 205 | /* */ 206 | /* `out': */ 207 | /* */ 208 | /* - `pointlist' must be initialized (NULL or pointing to memory) unless */ 209 | /* the `N' switch is used. `pointmarkerlist' must be initialized */ 210 | /* unless the `N' or `B' switch is used. If `N' is not used and */ 211 | /* `in->numberofpointattributes' is not zero, `pointattributelist' must */ 212 | /* be initialized. */ 213 | /* - `trianglelist' must be initialized unless the `E' switch is used. */ 214 | /* `neighborlist' must be initialized if the `n' switch is used. If */ 215 | /* the `E' switch is not used and (`in->numberofelementattributes' is */ 216 | /* not zero or the `A' switch is used), `elementattributelist' must be */ 217 | /* initialized. `trianglearealist' may be ignored. */ 218 | /* - `segmentlist' must be initialized if the `p' or `c' switch is used, */ 219 | /* and the `P' switch is not used. `segmentmarkerlist' must also be */ 220 | /* initialized under these circumstances unless the `B' switch is used. */ 221 | /* - `edgelist' must be initialized if the `e' switch is used. */ 222 | /* `edgemarkerlist' must be initialized if the `e' switch is used and */ 223 | /* the `B' switch is not. */ 224 | /* - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/ 225 | /* */ 226 | /* `vorout' (only needed if `v' switch is used): */ 227 | /* */ 228 | /* - `pointlist' must be initialized. If `in->numberofpointattributes' */ 229 | /* is not zero, `pointattributelist' must be initialized. */ 230 | /* `pointmarkerlist' may be ignored. */ 231 | /* - `edgelist' and `normlist' must both be initialized. */ 232 | /* `edgemarkerlist' may be ignored. */ 233 | /* - Everything else may be ignored. */ 234 | /* */ 235 | /* After a call to triangulate(), the valid fields of `out' and `vorout' */ 236 | /* will depend, in an obvious way, on the choice of switches used. Note */ 237 | /* that when the `p' switch is used, the pointers `holelist' and */ 238 | /* `regionlist' are copied from `in' to `out', but no new space is */ 239 | /* allocated; be careful that you don't free() the same array twice. On */ 240 | /* the other hand, Triangle will never copy the `pointlist' pointer (or any */ 241 | /* others); new space is allocated for `out->pointlist', or if the `N' */ 242 | /* switch is used, `out->pointlist' remains uninitialized. */ 243 | /* */ 244 | /* All of the meaningful `numberof' fields will be properly set; for */ 245 | /* instance, `numberofedges' will represent the number of edges in the */ 246 | /* triangulation whether or not the edges were written. If segments are */ 247 | /* not used, `numberofsegments' will indicate the number of boundary edges. */ 248 | /* */ 249 | /*****************************************************************************/ 250 | 251 | struct triangulateio { 252 | REAL *pointlist; /* In / out */ 253 | REAL *pointattributelist; /* In / out */ 254 | int *pointmarkerlist; /* In / out */ 255 | int numberofpoints; /* In / out */ 256 | int numberofpointattributes; /* In / out */ 257 | 258 | int *trianglelist; /* In / out */ 259 | REAL *triangleattributelist; /* In / out */ 260 | REAL *trianglearealist; /* In only */ 261 | int *neighborlist; /* Out only */ 262 | int numberoftriangles; /* In / out */ 263 | int numberofcorners; /* In / out */ 264 | int numberoftriangleattributes; /* In / out */ 265 | 266 | int *segmentlist; /* In / out */ 267 | int *segmentmarkerlist; /* In / out */ 268 | int numberofsegments; /* In / out */ 269 | 270 | REAL *holelist; /* In / pointer to array copied out */ 271 | int numberofholes; /* In / copied out */ 272 | 273 | REAL *regionlist; /* In / pointer to array copied out */ 274 | int numberofregions; /* In / copied out */ 275 | 276 | int *edgelist; /* Out only */ 277 | int *edgemarkerlist; /* Not used with Voronoi diagram; out only */ 278 | REAL *normlist; /* Used only with Voronoi diagram; out only */ 279 | int numberofedges; /* Out only */ 280 | }; 281 | 282 | #ifdef ANSI_DECLARATORS 283 | void triangulate(char *, struct triangulateio *, struct triangulateio *, 284 | struct triangulateio *); 285 | void trifree(VOID *memptr); 286 | #else /* not ANSI_DECLARATORS */ 287 | void triangulate(); 288 | void trifree(); 289 | #endif /* not ANSI_DECLARATORS */ 290 | -------------------------------------------------------------------------------- /other/conforming_delaynay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takram-design-engineering/takram-triangulation/1b923de03cfda29d8319a49bce71da7f94220e69/other/conforming_delaynay.png -------------------------------------------------------------------------------- /other/voronoi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/takram-design-engineering/takram-triangulation/1b923de03cfda29d8319a49bce71da7f94220e69/other/voronoi.png -------------------------------------------------------------------------------- /sample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.takram.triangulation.$(PRODUCT_NAME:rfc1034identifier) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2014 takram design engineering. All rights reserved. 29 | 30 | 31 | -------------------------------------------------------------------------------- /sample/product.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // product.xcconfig 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014 Shota Matsuda 7 | // Copyright (C) 2014 takram design engineering 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | // Configuration for Xcode 6.1 29 | 30 | // Search Paths 31 | ALWAYS_SEARCH_USER_PATHS = NO 32 | 33 | // Linking 34 | OTHER_LDFLAGS = $(inherited) -framework Accelerate -framework AudioToolbox -framework AudioUnit -framework Cocoa -framework CoreAudio -framework CoreVideo -framework OpenGL -framework QTKit 35 | 36 | // Search Paths 37 | HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/../src" "$(PROJECT_DIR)/../../takram-math/src" "$(PROJECT_DIR)/../../takram-cocoa-cinder/include" "$(PROJECT_DIR)/../../takram-cocoa-cinder/cinder/include" "$(PROJECT_DIR)/../../takram-cocoa-cinder/cinder/boost" 38 | LIBRARY_SEARCH_PATHS = $(inherited) 39 | -------------------------------------------------------------------------------- /sample/triangulation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9301D5F81B31831100618CDF /* libtriangulation.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 9301D5EA1B317D2900618CDF /* libtriangulation.dylib */; }; 11 | 9301D5F91B31831800618CDF /* libtriangulation.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9301D5EA1B317D2900618CDF /* libtriangulation.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 12 | 930958FD1A505B8100D09023 /* app.cc in Sources */ = {isa = PBXBuildFile; fileRef = 930958FA1A505B8100D09023 /* app.cc */; }; 13 | 930959091A505C5800D09023 /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 930959081A505C5800D09023 /* main.cc */; }; 14 | 9309590A1A505C9900D09023 /* takram_cocoa_cinder.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 930955CC1A4FDBF000D09023 /* takram_cocoa_cinder.bundle */; }; 15 | 9309591B1A505E4800D09023 /* libtakram_cocoa_cinder.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 930958F61A505B4700D09023 /* libtakram_cocoa_cinder.dylib */; }; 16 | 9309595F1A50A2EF00D09023 /* libtakram_cocoa_cinder.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 930958F61A505B4700D09023 /* libtakram_cocoa_cinder.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 9301D5E91B317D2900618CDF /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */; 23 | proxyType = 2; 24 | remoteGlobalIDString = 9309550E1A4FB1FC00D09023; 25 | remoteInfo = triangulation_shared; 26 | }; 27 | 9301D5EB1B317D2900618CDF /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */; 30 | proxyType = 2; 31 | remoteGlobalIDString = 93C6B51519B22F5500A1CF93; 32 | remoteInfo = triangulation_static; 33 | }; 34 | 9301D5ED1B317D2900618CDF /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */; 37 | proxyType = 2; 38 | remoteGlobalIDString = 93F1B9F6180282B0002A5A5C; 39 | remoteInfo = triangulation_test; 40 | }; 41 | 9301D5F11B31830C00618CDF /* PBXContainerItemProxy */ = { 42 | isa = PBXContainerItemProxy; 43 | containerPortal = 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */; 44 | proxyType = 1; 45 | remoteGlobalIDString = 9309550D1A4FB1FC00D09023; 46 | remoteInfo = triangulation_shared; 47 | }; 48 | 930955C71A4FDBF000D09023 /* PBXContainerItemProxy */ = { 49 | isa = PBXContainerItemProxy; 50 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 51 | proxyType = 2; 52 | remoteGlobalIDString = 93C6B51519B22F5500A1CF93; 53 | remoteInfo = takram_cocoa_cinder_static; 54 | }; 55 | 930955C91A4FDBF000D09023 /* PBXContainerItemProxy */ = { 56 | isa = PBXContainerItemProxy; 57 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 58 | proxyType = 2; 59 | remoteGlobalIDString = 93F1B9F6180282B0002A5A5C; 60 | remoteInfo = takram_cocoa_cinder_test; 61 | }; 62 | 930955CB1A4FDBF000D09023 /* PBXContainerItemProxy */ = { 63 | isa = PBXContainerItemProxy; 64 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 65 | proxyType = 2; 66 | remoteGlobalIDString = 930BCB571A26177900ABC38D; 67 | remoteInfo = takram_cocoa_cinder_bundle; 68 | }; 69 | 930958F51A505B4700D09023 /* PBXContainerItemProxy */ = { 70 | isa = PBXContainerItemProxy; 71 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 72 | proxyType = 2; 73 | remoteGlobalIDString = 930955E91A504DE600D09023; 74 | remoteInfo = takram_cocoa_cinder_shared; 75 | }; 76 | 930959061A505C2A00D09023 /* PBXContainerItemProxy */ = { 77 | isa = PBXContainerItemProxy; 78 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 79 | proxyType = 1; 80 | remoteGlobalIDString = 930BCB561A26177900ABC38D; 81 | remoteInfo = takram_cocoa_cinder_bundle; 82 | }; 83 | 930959171A505E4200D09023 /* PBXContainerItemProxy */ = { 84 | isa = PBXContainerItemProxy; 85 | containerPortal = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 86 | proxyType = 1; 87 | remoteGlobalIDString = 930955E81A504DE600D09023; 88 | remoteInfo = takram_cocoa_cinder_shared; 89 | }; 90 | /* End PBXContainerItemProxy section */ 91 | 92 | /* Begin PBXCopyFilesBuildPhase section */ 93 | 930959591A50A2DC00D09023 /* CopyFiles */ = { 94 | isa = PBXCopyFilesBuildPhase; 95 | buildActionMask = 2147483647; 96 | dstPath = ""; 97 | dstSubfolderSpec = 10; 98 | files = ( 99 | 9301D5F91B31831800618CDF /* libtriangulation.dylib in CopyFiles */, 100 | 9309595F1A50A2EF00D09023 /* libtakram_cocoa_cinder.dylib in CopyFiles */, 101 | ); 102 | runOnlyForDeploymentPostprocessing = 0; 103 | }; 104 | /* End PBXCopyFilesBuildPhase section */ 105 | 106 | /* Begin PBXFileReference section */ 107 | 930958FA1A505B8100D09023 /* app.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = app.cc; path = triangulation/app.cc; sourceTree = ""; }; 108 | 930958FB1A505B8100D09023 /* app.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = app.h; path = triangulation/app.h; sourceTree = ""; }; 109 | 930958FC1A505B8100D09023 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 110 | 930959081A505C5800D09023 /* main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cc; path = triangulation/main.cc; sourceTree = ""; }; 111 | 930959221A505E7A00D09023 /* product.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = product.xcconfig; sourceTree = ""; }; 112 | 930959461A5064DA00D09023 /* project_debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = project_debug.xcconfig; path = ../config/project_debug.xcconfig; sourceTree = ""; }; 113 | 930959471A5064DA00D09023 /* project_release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = project_release.xcconfig; path = ../config/project_release.xcconfig; sourceTree = ""; }; 114 | 930959481A5064DA00D09023 /* project.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = project.xcconfig; path = ../config/project.xcconfig; sourceTree = ""; }; 115 | 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = takram_cocoa_cinder.xcodeproj; path = "../../takram-cocoa-cinder/takram_cocoa_cinder.xcodeproj"; sourceTree = SOURCE_ROOT; }; 116 | 937BFCCB1A2266D100DDAAE1 /* Triangulation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Triangulation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 117 | 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = triangulation.xcodeproj; path = ../triangulation.xcodeproj; sourceTree = SOURCE_ROOT; }; 118 | /* End PBXFileReference section */ 119 | 120 | /* Begin PBXFrameworksBuildPhase section */ 121 | 937BFCC81A2266D100DDAAE1 /* Frameworks */ = { 122 | isa = PBXFrameworksBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 9301D5F81B31831100618CDF /* libtriangulation.dylib in Frameworks */, 126 | 9309591B1A505E4800D09023 /* libtakram_cocoa_cinder.dylib in Frameworks */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXFrameworksBuildPhase section */ 131 | 132 | /* Begin PBXGroup section */ 133 | 9301D5E41B317D2900618CDF /* Products */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 9301D5EA1B317D2900618CDF /* libtriangulation.dylib */, 137 | 9301D5EC1B317D2900618CDF /* libtriangulation.a */, 138 | 9301D5EE1B317D2900618CDF /* triangulation_test */, 139 | ); 140 | name = Products; 141 | sourceTree = ""; 142 | }; 143 | 930955C21A4FDBF000D09023 /* Products */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 930955C81A4FDBF000D09023 /* libtakram_cocoa_cinder.a */, 147 | 930958F61A505B4700D09023 /* libtakram_cocoa_cinder.dylib */, 148 | 930955CA1A4FDBF000D09023 /* takram_cocoa_cinder_test */, 149 | 930955CC1A4FDBF000D09023 /* takram_cocoa_cinder.bundle */, 150 | ); 151 | name = Products; 152 | sourceTree = ""; 153 | }; 154 | 93F8AD6617C8B39800310877 = { 155 | isa = PBXGroup; 156 | children = ( 157 | 930959081A505C5800D09023 /* main.cc */, 158 | 930958FB1A505B8100D09023 /* app.h */, 159 | 930958FA1A505B8100D09023 /* app.cc */, 160 | 930959481A5064DA00D09023 /* project.xcconfig */, 161 | 930959461A5064DA00D09023 /* project_debug.xcconfig */, 162 | 930959471A5064DA00D09023 /* project_release.xcconfig */, 163 | 930959221A505E7A00D09023 /* product.xcconfig */, 164 | 930958FC1A505B8100D09023 /* Info.plist */, 165 | 93F8AD7017C8B39800310877 /* products */, 166 | 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */, 167 | 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */, 168 | ); 169 | sourceTree = ""; 170 | }; 171 | 93F8AD7017C8B39800310877 /* products */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | 937BFCCB1A2266D100DDAAE1 /* Triangulation.app */, 175 | ); 176 | name = products; 177 | sourceTree = ""; 178 | }; 179 | /* End PBXGroup section */ 180 | 181 | /* Begin PBXNativeTarget section */ 182 | 937BFCCA1A2266D100DDAAE1 /* Triangulation */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = 937BFCEB1A2266D100DDAAE1 /* Build configuration list for PBXNativeTarget "Triangulation" */; 185 | buildPhases = ( 186 | 937BFCC71A2266D100DDAAE1 /* Sources */, 187 | 937BFCC81A2266D100DDAAE1 /* Frameworks */, 188 | 937BFCC91A2266D100DDAAE1 /* Resources */, 189 | 930959591A50A2DC00D09023 /* CopyFiles */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | 9301D5F21B31830C00618CDF /* PBXTargetDependency */, 195 | 930959181A505E4200D09023 /* PBXTargetDependency */, 196 | 930959071A505C2A00D09023 /* PBXTargetDependency */, 197 | ); 198 | name = Triangulation; 199 | productName = Application; 200 | productReference = 937BFCCB1A2266D100DDAAE1 /* Triangulation.app */; 201 | productType = "com.apple.product-type.application"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | 93F8AD6717C8B39800310877 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastUpgradeCheck = 0610; 210 | ORGANIZATIONNAME = sgss; 211 | TargetAttributes = { 212 | 937BFCCA1A2266D100DDAAE1 = { 213 | CreatedOnToolsVersion = 6.1; 214 | }; 215 | }; 216 | }; 217 | buildConfigurationList = 93F8AD6A17C8B39800310877 /* Build configuration list for PBXProject "triangulation" */; 218 | compatibilityVersion = "Xcode 3.2"; 219 | developmentRegion = English; 220 | hasScannedForEncodings = 0; 221 | knownRegions = ( 222 | en, 223 | Base, 224 | ); 225 | mainGroup = 93F8AD6617C8B39800310877; 226 | productRefGroup = 93F8AD7017C8B39800310877 /* products */; 227 | projectDirPath = ""; 228 | projectReferences = ( 229 | { 230 | ProductGroup = 930955C21A4FDBF000D09023 /* Products */; 231 | ProjectRef = 937BFCBD1A22666400DDAAE1 /* takram_cocoa_cinder.xcodeproj */; 232 | }, 233 | { 234 | ProductGroup = 9301D5E41B317D2900618CDF /* Products */; 235 | ProjectRef = 93F8F3581A2846AB007DDBE4 /* triangulation.xcodeproj */; 236 | }, 237 | ); 238 | projectRoot = ""; 239 | targets = ( 240 | 937BFCCA1A2266D100DDAAE1 /* Triangulation */, 241 | ); 242 | }; 243 | /* End PBXProject section */ 244 | 245 | /* Begin PBXReferenceProxy section */ 246 | 9301D5EA1B317D2900618CDF /* libtriangulation.dylib */ = { 247 | isa = PBXReferenceProxy; 248 | fileType = "compiled.mach-o.dylib"; 249 | path = libtriangulation.dylib; 250 | remoteRef = 9301D5E91B317D2900618CDF /* PBXContainerItemProxy */; 251 | sourceTree = BUILT_PRODUCTS_DIR; 252 | }; 253 | 9301D5EC1B317D2900618CDF /* libtriangulation.a */ = { 254 | isa = PBXReferenceProxy; 255 | fileType = archive.ar; 256 | path = libtriangulation.a; 257 | remoteRef = 9301D5EB1B317D2900618CDF /* PBXContainerItemProxy */; 258 | sourceTree = BUILT_PRODUCTS_DIR; 259 | }; 260 | 9301D5EE1B317D2900618CDF /* triangulation_test */ = { 261 | isa = PBXReferenceProxy; 262 | fileType = "compiled.mach-o.executable"; 263 | path = triangulation_test; 264 | remoteRef = 9301D5ED1B317D2900618CDF /* PBXContainerItemProxy */; 265 | sourceTree = BUILT_PRODUCTS_DIR; 266 | }; 267 | 930955C81A4FDBF000D09023 /* libtakram_cocoa_cinder.a */ = { 268 | isa = PBXReferenceProxy; 269 | fileType = archive.ar; 270 | path = libtakram_cocoa_cinder.a; 271 | remoteRef = 930955C71A4FDBF000D09023 /* PBXContainerItemProxy */; 272 | sourceTree = BUILT_PRODUCTS_DIR; 273 | }; 274 | 930955CA1A4FDBF000D09023 /* takram_cocoa_cinder_test */ = { 275 | isa = PBXReferenceProxy; 276 | fileType = "compiled.mach-o.executable"; 277 | path = takram_cocoa_cinder_test; 278 | remoteRef = 930955C91A4FDBF000D09023 /* PBXContainerItemProxy */; 279 | sourceTree = BUILT_PRODUCTS_DIR; 280 | }; 281 | 930955CC1A4FDBF000D09023 /* takram_cocoa_cinder.bundle */ = { 282 | isa = PBXReferenceProxy; 283 | fileType = wrapper.cfbundle; 284 | path = takram_cocoa_cinder.bundle; 285 | remoteRef = 930955CB1A4FDBF000D09023 /* PBXContainerItemProxy */; 286 | sourceTree = BUILT_PRODUCTS_DIR; 287 | }; 288 | 930958F61A505B4700D09023 /* libtakram_cocoa_cinder.dylib */ = { 289 | isa = PBXReferenceProxy; 290 | fileType = "compiled.mach-o.dylib"; 291 | path = libtakram_cocoa_cinder.dylib; 292 | remoteRef = 930958F51A505B4700D09023 /* PBXContainerItemProxy */; 293 | sourceTree = BUILT_PRODUCTS_DIR; 294 | }; 295 | /* End PBXReferenceProxy section */ 296 | 297 | /* Begin PBXResourcesBuildPhase section */ 298 | 937BFCC91A2266D100DDAAE1 /* Resources */ = { 299 | isa = PBXResourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 9309590A1A505C9900D09023 /* takram_cocoa_cinder.bundle in Resources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXResourcesBuildPhase section */ 307 | 308 | /* Begin PBXSourcesBuildPhase section */ 309 | 937BFCC71A2266D100DDAAE1 /* Sources */ = { 310 | isa = PBXSourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 930959091A505C5800D09023 /* main.cc in Sources */, 314 | 930958FD1A505B8100D09023 /* app.cc in Sources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | /* End PBXSourcesBuildPhase section */ 319 | 320 | /* Begin PBXTargetDependency section */ 321 | 9301D5F21B31830C00618CDF /* PBXTargetDependency */ = { 322 | isa = PBXTargetDependency; 323 | name = triangulation_shared; 324 | targetProxy = 9301D5F11B31830C00618CDF /* PBXContainerItemProxy */; 325 | }; 326 | 930959071A505C2A00D09023 /* PBXTargetDependency */ = { 327 | isa = PBXTargetDependency; 328 | name = takram_cocoa_cinder_bundle; 329 | targetProxy = 930959061A505C2A00D09023 /* PBXContainerItemProxy */; 330 | }; 331 | 930959181A505E4200D09023 /* PBXTargetDependency */ = { 332 | isa = PBXTargetDependency; 333 | name = takram_cocoa_cinder_shared; 334 | targetProxy = 930959171A505E4200D09023 /* PBXContainerItemProxy */; 335 | }; 336 | /* End PBXTargetDependency section */ 337 | 338 | /* Begin XCBuildConfiguration section */ 339 | 937BFCE51A2266D100DDAAE1 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | baseConfigurationReference = 930959221A505E7A00D09023 /* product.xcconfig */; 342 | buildSettings = { 343 | INFOPLIST_FILE = Info.plist; 344 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 345 | PRODUCT_NAME = Triangulation; 346 | }; 347 | name = Debug; 348 | }; 349 | 937BFCE61A2266D100DDAAE1 /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | baseConfigurationReference = 930959221A505E7A00D09023 /* product.xcconfig */; 352 | buildSettings = { 353 | INFOPLIST_FILE = Info.plist; 354 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 355 | PRODUCT_NAME = Triangulation; 356 | }; 357 | name = Release; 358 | }; 359 | 93F8AD7617C8B39800310877 /* Debug */ = { 360 | isa = XCBuildConfiguration; 361 | baseConfigurationReference = 930959461A5064DA00D09023 /* project_debug.xcconfig */; 362 | buildSettings = { 363 | MACOSX_DEPLOYMENT_TARGET = 10.9; 364 | ONLY_ACTIVE_ARCH = YES; 365 | SDKROOT = macosx; 366 | }; 367 | name = Debug; 368 | }; 369 | 93F8AD7717C8B39800310877 /* Release */ = { 370 | isa = XCBuildConfiguration; 371 | baseConfigurationReference = 930959471A5064DA00D09023 /* project_release.xcconfig */; 372 | buildSettings = { 373 | MACOSX_DEPLOYMENT_TARGET = 10.9; 374 | ONLY_ACTIVE_ARCH = NO; 375 | SDKROOT = macosx; 376 | }; 377 | name = Release; 378 | }; 379 | /* End XCBuildConfiguration section */ 380 | 381 | /* Begin XCConfigurationList section */ 382 | 937BFCEB1A2266D100DDAAE1 /* Build configuration list for PBXNativeTarget "Triangulation" */ = { 383 | isa = XCConfigurationList; 384 | buildConfigurations = ( 385 | 937BFCE51A2266D100DDAAE1 /* Debug */, 386 | 937BFCE61A2266D100DDAAE1 /* Release */, 387 | ); 388 | defaultConfigurationIsVisible = 0; 389 | defaultConfigurationName = Release; 390 | }; 391 | 93F8AD6A17C8B39800310877 /* Build configuration list for PBXProject "triangulation" */ = { 392 | isa = XCConfigurationList; 393 | buildConfigurations = ( 394 | 93F8AD7617C8B39800310877 /* Debug */, 395 | 93F8AD7717C8B39800310877 /* Release */, 396 | ); 397 | defaultConfigurationIsVisible = 0; 398 | defaultConfigurationName = Release; 399 | }; 400 | /* End XCConfigurationList section */ 401 | }; 402 | rootObject = 93F8AD6717C8B39800310877 /* Project object */; 403 | } 404 | -------------------------------------------------------------------------------- /sample/triangulation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/triangulation.xcodeproj/xcshareddata/xcschemes/Application.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /sample/triangulation/app.cc: -------------------------------------------------------------------------------- 1 | // 2 | // app.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014 Shota Matsuda 7 | // Copyright (C) 2014 takram design engineering 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | #include "app.h" 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "cinder/Color.h" 37 | #include "cinder/gl/gl.h" 38 | #include "cinder/Vector.h" 39 | 40 | #include "takram/cinder.h" 41 | #include "takram/parameter.h" 42 | #include "takram/triangulation.h" 43 | 44 | namespace example { 45 | 46 | App::App() 47 | : needs_triangulation_(false), 48 | type_("Type"), 49 | min_angle_("Min Angle", 20.0, 0.0, 20.0), 50 | max_area_("Max Area", 100.0, 100.0, 10000.0), 51 | max_steiner_points_("Max Steiner Points", 0, 0, 10000), 52 | uses_min_angle_("Use Min Angle", false), 53 | uses_max_area_("Use Max Area", false), 54 | uses_max_steiner_points_("Use Max Steiner Points", false), 55 | clear_("Clear"), 56 | random_("Random") { 57 | type_->set_options({ 58 | std::make_pair(Type::VORONOI, "Voronoi"), 59 | std::make_pair(Type::DELAUNAY, "Delaunay"), 60 | std::make_pair(Type::CONSTRAINED_DELAUNAY, "Constrained Delaunay"), 61 | std::make_pair(Type::CONFORMING_DELAUNAY, "Conforming Delaunay"), 62 | std::make_pair(Type::CONSTRAINED_CONFORMING_DELAUNAY, 63 | "Constrained Conforming Delaunay") 64 | }); 65 | type_->set_allows_multiple(false); 66 | type_->set_allows_empty(false); 67 | type_.set_preferred_interface(takram::Parameter::Interface::POPUP_BUTTON); 68 | clear_.set_preferred_interface(takram::NumericParameter::Interface::BUTTON); 69 | random_.set_preferred_interface(takram::NumericParameter::Interface::BUTTON); 70 | } 71 | 72 | void App::update() { 73 | if (needs_triangulation_ && points_.size() > 2) { 74 | takram::Triangulator *triangulator; 75 | if (type_->has(Type::VORONOI)) { 76 | triangulator = &voronoi_; 77 | } else { 78 | triangulator = &delaunay_; 79 | using DelaunayType = takram::DelaunayTriangulator::Type; 80 | if (type_->has(Type::DELAUNAY)) { 81 | delaunay_.set_type(DelaunayType::DEFAULT); 82 | } else if (type_->has(Type::CONSTRAINED_DELAUNAY)) { 83 | delaunay_.set_type(DelaunayType::CONSTRAINED); 84 | } else if (type_->has(Type::CONFORMING_DELAUNAY)) { 85 | delaunay_.set_type(DelaunayType::CONFORMING); 86 | } else if (type_->has(Type::CONSTRAINED_CONFORMING_DELAUNAY)) { 87 | delaunay_.set_type(DelaunayType::CONSTRAINED_CONFORMING); 88 | } else { 89 | assert(false); 90 | } 91 | } 92 | if (uses_min_angle_) { 93 | triangulator->set_min_angle(min_angle_); 94 | } else { 95 | triangulator->set_min_angle(std::numeric_limits::quiet_NaN()); 96 | } 97 | if (uses_max_area_) { 98 | triangulator->set_max_area(max_area_); 99 | } else { 100 | triangulator->set_max_area(std::numeric_limits::quiet_NaN()); 101 | } 102 | if (uses_max_steiner_points_) { 103 | triangulator->set_max_steiner_points(max_steiner_points_); 104 | } else { 105 | triangulator->set_max_steiner_points(-1); 106 | } 107 | (*triangulator)(points_); 108 | needs_triangulation_ = false; 109 | } 110 | } 111 | 112 | void App::draw() { 113 | ci::gl::clear(ci::Color::white()); 114 | if (type_->has(Type::VORONOI)) { 115 | const auto diagonal = ci::gl::getViewport().getSize().length(); 116 | ci::Vec2f a, b; 117 | ci::gl::color(ci::ColorA(0.0, 0.0, 0.0, 0.2)); 118 | for (const auto& line : voronoi_) { 119 | a.set(line.a.x, line.a.y); 120 | if (line.finite) { 121 | b.set(line.b.x, line.b.y); 122 | } else { 123 | const auto normal = ci::Vec2d(line.b.x, line.b.y).normalized(); 124 | b.set(line.a.x + normal.x * diagonal, line.a.y + normal.y * diagonal); 125 | } 126 | ci::gl::drawLine(a, b); 127 | } 128 | } else { 129 | ci::Vec2f a, b, c; 130 | ci::gl::color(ci::ColorA(0.0, 0.0, 0.0, 0.1)); 131 | for (const auto& triangle : delaunay_) { 132 | a.set(triangle.a.x, triangle.a.y); 133 | b.set(triangle.b.x, triangle.b.y); 134 | c.set(triangle.c.x, triangle.c.y); 135 | ci::gl::drawLine(a, b); 136 | ci::gl::drawLine(b, c); 137 | ci::gl::drawLine(c, a); 138 | } 139 | } 140 | ci::gl::color(ci::Color::black()); 141 | for (const auto& point : points_) { 142 | ci::gl::drawSolidCircle(point, 2.0); 143 | } 144 | } 145 | 146 | void App::reshape(const ci::Area& viewport) { 147 | ci::gl::setMatricesWindow(viewport.getWidth(), viewport.getHeight()); 148 | size_ = viewport.getSize(); 149 | } 150 | 151 | void App::mouseDown(const takram::cinder::MouseEvent& event) { 152 | points_.emplace_back(event.getX(), event.getY()); 153 | needs_triangulation_ = true; 154 | } 155 | 156 | void App::mouseDrag(const takram::cinder::MouseEvent& event) { 157 | points_.emplace_back(event.getX(), event.getY()); 158 | needs_triangulation_ = true; 159 | } 160 | 161 | takram::ParameterGroups App::exposeParameters() { 162 | return takram::ParameterGroups{ 163 | std::make_pair("Triangulation", takram::Parameters{ 164 | &type_, 165 | &min_angle_, 166 | &max_area_, 167 | &max_steiner_points_, 168 | &uses_min_angle_, 169 | &uses_max_area_, 170 | &uses_max_steiner_points_, 171 | &clear_, 172 | &random_ 173 | }) 174 | }; 175 | } 176 | 177 | void App::parameterChange(const takram::ParameterBase& parameter) { 178 | if (¶meter == &clear_) { 179 | points_.clear(); 180 | voronoi_.clear(); 181 | delaunay_.clear(); 182 | } else if (¶meter == &random_) { 183 | std::random_device random_device; 184 | std::default_random_engine engine(random_device()); 185 | std::uniform_int_distribution<> x_distribution(0, size_.x); 186 | std::uniform_int_distribution<> y_distribution(0, size_.y); 187 | for (int i = 0, n = size_.x * size_.y / 10000; i < n; ++i) { 188 | points_.emplace_back(x_distribution(engine), y_distribution(engine)); 189 | } 190 | } 191 | needs_triangulation_ = true; 192 | } 193 | 194 | } // namespace example 195 | -------------------------------------------------------------------------------- /sample/triangulation/app.h: -------------------------------------------------------------------------------- 1 | // 2 | // app.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014 Shota Matsuda 7 | // Copyright (C) 2014 takram design engineering 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | #pragma once 29 | #ifndef EXAMPLE_APP_H_ 30 | #define EXAMPLE_APP_H_ 31 | 32 | #include 33 | 34 | #include "cinder/Vector.h" 35 | 36 | #include "takram/choice.h" 37 | #include "takram/cinder.h" 38 | #include "takram/parameter.h" 39 | #include "takram/triangulation.h" 40 | 41 | namespace example { 42 | 43 | class App : public takram::cinder::RunnableBase { 44 | public: 45 | enum class Type { 46 | VORONOI, 47 | DELAUNAY, 48 | CONSTRAINED_DELAUNAY, 49 | CONFORMING_DELAUNAY, 50 | CONSTRAINED_CONFORMING_DELAUNAY 51 | }; 52 | 53 | // Constructors 54 | App(); 55 | 56 | // Framework methods 57 | void update() override; 58 | void draw() override; 59 | void reshape(const ci::Area& viewport) override; 60 | void mouseDown(const takram::cinder::MouseEvent& event) override; 61 | void mouseDrag(const takram::cinder::MouseEvent& event) override; 62 | 63 | // List of parameter groups 64 | takram::ParameterGroups exposeParameters() override; 65 | 66 | // Callback for changes in parameters 67 | void parameterChange(const takram::ParameterBase& parameter) override; 68 | 69 | private: 70 | // Data members 71 | std::vector points_; 72 | takram::VoronoiTriangulator voronoi_; 73 | takram::DelaunayTriangulator delaunay_; 74 | ci::Vec2i size_; 75 | bool needs_triangulation_; 76 | 77 | // Parameters 78 | takram::ParameterT type_; 79 | takram::NumericParameterT min_angle_; 80 | takram::NumericParameterT max_area_; 81 | takram::NumericParameterT max_steiner_points_; 82 | takram::NumericParameterT uses_min_angle_; 83 | takram::NumericParameterT uses_max_area_; 84 | takram::NumericParameterT uses_max_steiner_points_; 85 | takram::NumericParameterT clear_; 86 | takram::NumericParameterT random_; 87 | }; 88 | 89 | } // namespace example 90 | 91 | #endif // EXAMPLE_APP_H_ 92 | -------------------------------------------------------------------------------- /sample/triangulation/main.cc: -------------------------------------------------------------------------------- 1 | // 2 | // main.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014 Shota Matsuda 7 | // Copyright (C) 2014 takram design engineering 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a 10 | // copy of this software and associated documentation files (the "Software"), 11 | // to deal in the Software without restriction, including without limitation 12 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | // and/or sell copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | // DEALINGS IN THE SOFTWARE. 26 | // 27 | 28 | #include "takram/cinder.h" 29 | 30 | #include "app.h" 31 | 32 | int main() { 33 | return takram::cinder::Run(); 34 | } 35 | -------------------------------------------------------------------------------- /script/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # build.sh 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (C) 2013-2015 Shota Matsuda 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a 10 | # copy of this software and associated documentation files (the "Software"), 11 | # to deal in the Software without restriction, including without limitation 12 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | # and/or sell copies of the Software, and to permit persons to whom the 14 | # Software is furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | # DEALINGS IN THE SOFTWARE. 26 | # 27 | 28 | readonly TYPE=$1 29 | readonly TARGET_PATH=$2 30 | readonly TARGET_BUILD_PATH=$3 31 | readonly OPTIONS=${@:4} 32 | 33 | readonly CMAKE=$(which cmake) 34 | readonly CLANG_CC=$(which clang) 35 | readonly CLANG_CXX=$(which clang++) 36 | 37 | if [[ ! -f "${CLANG_CC}" ]]; then 38 | echo "clang was not found." 39 | exit 1 40 | fi 41 | if [[ ! -f "${CLANG_CXX}" ]]; then 42 | echo "clang++ was not found." 43 | exit 1 44 | fi 45 | 46 | readonly PROJECT_DIR="$(cd "$(dirname "$0")/../"; pwd)" 47 | readonly TARGET_DIR="${PROJECT_DIR}/${TARGET_PATH}" 48 | readonly TARGET_BUILD_DIR="${PROJECT_DIR}/${TARGET_BUILD_PATH}" 49 | 50 | if [[ "${TYPE}" == "cmake" ]]; then 51 | if [[ ! -f "${CMAKE}" ]]; then 52 | echo "cmake was not found." 53 | exit 1 54 | fi 55 | mkdir -p "${TARGET_BUILD_DIR}" 56 | pushd "${TARGET_BUILD_DIR}" 57 | "${CMAKE}" -G "Unix Makefiles" \ 58 | -DCMAKE_BUILD_TYPE="RELEASE" \ 59 | -DCMAKE_C_COMPILER="${CLANG_CC}" \ 60 | -DCMAKE_CXX_COMPILER="${CLANG_CXX}" \ 61 | -DCMAKE_CXX_FLAGS="-stdlib=libc++" \ 62 | -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \ 63 | ${OPTIONS} \ 64 | "${TARGET_DIR}" 65 | make -j8 66 | popd 67 | elif [[ "${TYPE}" == "configure" && ! -d "${TARGET_BUILD_DIR}" ]]; then 68 | mkdir -p "${TARGET_BUILD_DIR}" 69 | pushd "${TARGET_BUILD_DIR}" 70 | "${TARGET_DIR}/configure" \ 71 | --prefix="${TARGET_BUILD_DIR}" \ 72 | CC="${CLANG_CC}" \ 73 | CXX="${CLANG_CXX}" \ 74 | CXXFLAGS="-stdlib=libc++" \ 75 | ${OPTIONS} 76 | make -j8 77 | make install 78 | make clean 79 | popd 80 | fi 81 | -------------------------------------------------------------------------------- /script/copy_headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # copy_headers.sh 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (C) 2013-2015 Shota Matsuda 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a 10 | # copy of this software and associated documentation files (the "Software"), 11 | # to deal in the Software without restriction, including without limitation 12 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | # and/or sell copies of the Software, and to permit persons to whom the 14 | # Software is furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | # DEALINGS IN THE SOFTWARE. 26 | # 27 | 28 | readonly PATHS=$@ 29 | 30 | for path in ${PATHS}; do 31 | cd "${PROJECT_DIR}/${path}" 32 | for header in $(find . -name "*.h"); do 33 | ditto "${header}" "${BUILT_PRODUCTS_DIR}/include/${header}" 34 | done 35 | done 36 | -------------------------------------------------------------------------------- /script/make_gitignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # make_gitignore.sh 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (C) 2014-2015 Shota Matsuda 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a 10 | # copy of this software and associated documentation files (the "Software"), 11 | # to deal in the Software without restriction, including without limitation 12 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | # and/or sell copies of the Software, and to permit persons to whom the 14 | # Software is furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | # DEALINGS IN THE SOFTWARE. 26 | # 27 | 28 | readonly PROJECT_DIR="$(cd "$(dirname "$0")/../"; pwd)" 29 | readonly FILES=("Global/OSX" "Global/Windows" "Global/Xcode" "VisualStudio") 30 | 31 | repository_dir=$(mktemp -d -t "com.takram.gitignore") 32 | 33 | concat_gitignore() { 34 | for file in "${FILES[@]}"; do 35 | echo "# https://github.com/github/gitignore/blob/master/${file}.gitignore" 36 | echo "" 37 | cat "${repository_dir}/${file}.gitignore" 38 | echo "" 39 | done 40 | } 41 | 42 | git clone "https://github.com/github/gitignore.git" "${repository_dir}" 43 | concat_gitignore > "${PROJECT_DIR}/.gitignore" 44 | rm -rf "${repository_dir}" 45 | -------------------------------------------------------------------------------- /script/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # setup.sh 4 | # 5 | # The MIT License 6 | # 7 | # Copyright (C) 2014-2016 Shota Matsuda 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a 10 | # copy of this software and associated documentation files (the "Software"), 11 | # to deal in the Software without restriction, including without limitation 12 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | # and/or sell copies of the Software, and to permit persons to whom the 14 | # Software is furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in 17 | # all copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | # DEALINGS IN THE SOFTWARE. 26 | # 27 | 28 | readonly PROJECT_DIR="$(cd "$(dirname "$0")/../"; pwd)" 29 | 30 | pushd "${PROJECT_DIR}" 31 | git submodule update --init 32 | "script/build.sh" cmake "lib/googletest/googletest" "build/googletest" 33 | popd 34 | -------------------------------------------------------------------------------- /src/takram/triangulation.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation.h" 28 | -------------------------------------------------------------------------------- /src/takram/triangulation.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_H_ 29 | #define TAKRAM_TRIANGULATION_H_ 30 | 31 | #include "takram/triangulation/types.h" 32 | #include "takram/triangulation/result.h" 33 | #include "takram/triangulation/delaunay_triangulator.h" 34 | #include "takram/triangulation/edge.h" 35 | #include "takram/triangulation/edge_iterator.h" 36 | #include "takram/triangulation/point.h" 37 | #include "takram/triangulation/triangle_iterator.h" 38 | #include "takram/triangulation/triangulator.h" 39 | #include "takram/triangulation/voronoi_triangulator.h" 40 | 41 | #endif // TAKRAM_TRIANGULATION_H_ 42 | -------------------------------------------------------------------------------- /src/takram/triangulation/delaunay_triangulator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/delaunay_triangulator.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/delaunay_triangulator.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "takram/triangulation/library.h" 38 | #include "takram/triangulation/triangle_iterator.h" 39 | #include "takram/triangulation/types.h" 40 | 41 | namespace takram { 42 | namespace triangulation { 43 | 44 | #pragma mark Triangulation 45 | 46 | bool DelaunayTriangulator::operator()(const std::vector& points) { 47 | const auto size = points.size() / 2; 48 | using Size = decltype(triangulateio::numberofpoints); 49 | if (size > std::numeric_limits::max()) { 50 | // Number of points exceeds the limit of triangle library 51 | return false; 52 | } else if (size < 3) { 53 | // Provided point must have at least 3 points 54 | return false; 55 | } 56 | // Prepare data 57 | result_ = std::make_shared(); 58 | struct triangulateio in; 59 | std::memset(&in, 0, sizeof(in)); 60 | std::vector mutable_points(points); 61 | in.pointlist = mutable_points.data(); 62 | in.numberofpoints = size; 63 | 64 | // Triangulation 65 | std::string options; 66 | std::vector segments; 67 | switch (type_) { 68 | case Type::DEFAULT: 69 | options = "zQ"; 70 | break; 71 | case Type::CONSTRAINED: 72 | options = "pzQ"; 73 | // Build edges including the one between front and back 74 | for (Size i = 0; i < size - 1; ++i) { 75 | segments.emplace_back(i); 76 | segments.emplace_back(i + 1); 77 | } 78 | segments.emplace_back(segments.back()); 79 | segments.emplace_back(segments.front()); 80 | in.segmentlist = segments.data(); 81 | in.numberofsegments = size; 82 | break; 83 | case Type::CONFORMING: 84 | options = "zDQ"; 85 | break; 86 | case Type::CONSTRAINED_CONFORMING: 87 | options = "pzDQ"; 88 | // Build edges including the one between front and back 89 | for (Size i = 0; i < size - 1; ++i) { 90 | segments.emplace_back(i); 91 | segments.emplace_back(i + 1); 92 | } 93 | segments.emplace_back(segments.back()); 94 | segments.emplace_back(segments.front()); 95 | in.segmentlist = segments.data(); 96 | in.numberofsegments = size; 97 | break; 98 | default: 99 | assert(false); 100 | break; 101 | } 102 | return Triangulator::operator()(options, &in, &**result_, nullptr); 103 | } 104 | 105 | #pragma mark Attributes 106 | 107 | std::size_t DelaunayTriangulator::size() const { 108 | if (!result_) { 109 | return 0; 110 | } 111 | return (*result_)->numberoftriangles; 112 | } 113 | 114 | #pragma mark Iterators 115 | 116 | TriangleIterator DelaunayTriangulator::begin() const { 117 | if (!result_) { 118 | return TriangleIterator(); 119 | } 120 | return TriangleIterator(result_); 121 | } 122 | 123 | TriangleIterator DelaunayTriangulator::end() const { 124 | if (!result_) { 125 | return TriangleIterator(); 126 | } 127 | const auto end = (*result_)->trianglelist + 128 | (*result_)->numberoftriangles * (*result_)->numberofcorners; 129 | return TriangleIterator(result_, end); 130 | } 131 | 132 | } // namespace triangulation 133 | } // namespace takram 134 | -------------------------------------------------------------------------------- /src/takram/triangulation/delaunay_triangulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/delaunay_triangulator.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_DELAUNAY_TRIANGULATOR_H_ 29 | #define TAKRAM_TRIANGULATION_DELAUNAY_TRIANGULATOR_H_ 30 | 31 | #include 32 | #include 33 | 34 | #include "takram/triangulation/triangle_iterator.h" 35 | #include "takram/triangulation/triangulator.h" 36 | #include "takram/triangulation/types.h" 37 | 38 | namespace takram { 39 | namespace triangulation { 40 | 41 | class DelaunayTriangulator : public Triangulator { 42 | public: 43 | enum class Type { 44 | DEFAULT = 0, 45 | CONSTRAINED, 46 | CONFORMING, 47 | CONSTRAINED_CONFORMING 48 | }; 49 | 50 | public: 51 | DelaunayTriangulator(); 52 | explicit DelaunayTriangulator(Type type); 53 | 54 | // Copy semantics 55 | DelaunayTriangulator(const DelaunayTriangulator&) = default; 56 | DelaunayTriangulator& operator=(const DelaunayTriangulator&) = default; 57 | 58 | // Triangulation 59 | using Triangulator::operator(); 60 | bool operator()(const std::vector& coordinates) override; 61 | 62 | // Parameters 63 | Type type() const { return type_; } 64 | void set_type(Type value) { type_ = value; } 65 | 66 | // Attributes 67 | std::size_t size() const override; 68 | 69 | // Iterator 70 | TriangleIterator begin() const; 71 | TriangleIterator end() const; 72 | 73 | private: 74 | Type type_; 75 | }; 76 | 77 | #pragma mark - 78 | 79 | inline DelaunayTriangulator::DelaunayTriangulator() : type_(Type::DEFAULT) {} 80 | 81 | inline DelaunayTriangulator::DelaunayTriangulator(Type type) : type_(type) {} 82 | 83 | } // namespace triangulation 84 | 85 | using triangulation::DelaunayTriangulator; 86 | 87 | } // namespace takram 88 | 89 | #endif // TAKRAM_TRIANGULATION_DELAUNAY_TRIANGULATOR_H_ 90 | -------------------------------------------------------------------------------- /src/takram/triangulation/edge.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/edge.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_EDGE_H_ 29 | #define TAKRAM_TRIANGULATION_EDGE_H_ 30 | 31 | #include "takram/triangulation/types.h" 32 | 33 | namespace takram { 34 | namespace triangulation { 35 | 36 | class Edge final { 37 | public: 38 | Edge(); 39 | 40 | // Copy semantics 41 | Edge(const Edge&) = default; 42 | Edge& operator=(const Edge&) = default; 43 | 44 | public: 45 | union { 46 | Line line; 47 | struct { Vec a; Vec b; }; 48 | struct { Real x1; Real y1; Real x2; Real y2; }; 49 | }; 50 | bool finite; 51 | }; 52 | 53 | #pragma mark - 54 | 55 | inline Edge::Edge() : finite() {} 56 | 57 | } // namespace triangulation 58 | } // namespace takram 59 | 60 | #endif // TAKRAM_TRIANGULATION_EDGE_H_ 61 | -------------------------------------------------------------------------------- /src/takram/triangulation/edge_iterator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/edge_iterator.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/edge_iterator.h" 28 | 29 | #include 30 | #include 31 | 32 | #include "takram/triangulation/edge.h" 33 | #include "takram/triangulation/library.h" 34 | #include "takram/triangulation/types.h" 35 | 36 | namespace takram { 37 | namespace triangulation { 38 | 39 | EdgeIterator::EdgeIterator(const std::shared_ptr& result) 40 | : result_(result), 41 | begin_((*result)->edgelist), 42 | current_(begin_), 43 | derived_() {} 44 | 45 | EdgeIterator::EdgeIterator(const std::shared_ptr& result, 46 | const int *current) 47 | : result_(result), 48 | begin_((*result)->edgelist), 49 | current_(current), 50 | derived_() {} 51 | 52 | #pragma mark Iterator 53 | 54 | const Edge& EdgeIterator::operator*() const { 55 | if (derived_ != current_) { 56 | const auto a = *(current_ + 0) * 2; 57 | const auto b = *(current_ + 1) * 2; 58 | const auto points = (*result_)->pointlist; 59 | const auto normals = (*result_)->normlist; 60 | if (b < 0) { 61 | // Infinite 62 | edge_.finite = false; 63 | edge_.line.set(Vec(points + a), Vec(normals + (current_ - begin_))); 64 | } else { 65 | // Finite 66 | edge_.finite = true; 67 | edge_.line.set(Vec(points + a), Vec(points + b)); 68 | } 69 | derived_ = current_; 70 | } 71 | return edge_; 72 | } 73 | 74 | } // namespace triangulation 75 | } // namespace takram 76 | -------------------------------------------------------------------------------- /src/takram/triangulation/edge_iterator.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/edge_iterator.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_EDGE_ITERATOR_H_ 29 | #define TAKRAM_TRIANGULATION_EDGE_ITERATOR_H_ 30 | 31 | #include 32 | #include 33 | 34 | #include "takram/triangulation/edge.h" 35 | #include "takram/triangulation/result.h" 36 | 37 | struct triangulateio; 38 | 39 | namespace takram { 40 | namespace triangulation { 41 | 42 | class EdgeIterator final 43 | : public std::iterator { 44 | public: 45 | EdgeIterator(); 46 | explicit EdgeIterator(const std::shared_ptr& result); 47 | EdgeIterator(const std::shared_ptr& result, const int *current); 48 | 49 | // Copy semantics 50 | EdgeIterator(const EdgeIterator&) = default; 51 | EdgeIterator& operator=(const EdgeIterator&) = default; 52 | 53 | // Comparison 54 | friend bool operator==(const EdgeIterator& lhs, const EdgeIterator& rhs); 55 | friend bool operator!=(const EdgeIterator& lhs, const EdgeIterator& rhs); 56 | 57 | // Iterator 58 | const Edge& operator*() const; 59 | const Edge * operator->() const { return &operator*(); } 60 | EdgeIterator& operator++(); 61 | EdgeIterator operator++(int); 62 | 63 | private: 64 | std::shared_ptr result_; 65 | const int * const begin_; 66 | const int *current_; 67 | 68 | // Cache 69 | mutable const int *derived_; 70 | mutable Edge edge_; 71 | }; 72 | 73 | #pragma mark - 74 | 75 | inline EdgeIterator::EdgeIterator() : begin_(), current_(), derived_() {} 76 | 77 | #pragma mark Comparison 78 | 79 | inline bool operator==(const EdgeIterator& lhs, const EdgeIterator& rhs) { 80 | return lhs.current_ == rhs.current_; 81 | } 82 | 83 | inline bool operator!=(const EdgeIterator& lhs, const EdgeIterator& rhs) { 84 | return !(lhs == rhs); 85 | } 86 | 87 | #pragma mark Iterator 88 | 89 | inline EdgeIterator& EdgeIterator::operator++() { 90 | current_ += 2; 91 | return *this; 92 | } 93 | 94 | inline EdgeIterator EdgeIterator::operator++(int) { 95 | EdgeIterator result(*this); 96 | operator++(); 97 | return result; 98 | } 99 | 100 | } // namespace triangulation 101 | } // namespace takram 102 | 103 | #endif // TAKRAM_TRIANGULATION_EDGE_ITERATOR_H_ 104 | -------------------------------------------------------------------------------- /src/takram/triangulation/library.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/library.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_LIBRARY_H_ 29 | #define TAKRAM_TRIANGULATION_LIBRARY_H_ 30 | 31 | extern "C" { 32 | 33 | #define VOID void 34 | #define REAL double 35 | #define ANSI_DECLARATORS 36 | #include "triangle/triangle.h" 37 | 38 | } // extern "C" 39 | 40 | #endif // TAKRAM_TRIANGULATION_LIBRARY_H_ 41 | -------------------------------------------------------------------------------- /src/takram/triangulation/point.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/point.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_POINT_H_ 29 | #define TAKRAM_TRIANGULATION_POINT_H_ 30 | 31 | #include "takram/triangulation/types.h" 32 | 33 | namespace takram { 34 | namespace triangulation { 35 | 36 | class Point final { 37 | public: 38 | Point(); 39 | 40 | // Copy semantics 41 | Point(const Point&) = default; 42 | Point& operator=(const Point&) = default; 43 | 44 | // Implicit conversions 45 | template 46 | Point(const T& other); 47 | 48 | union { 49 | Vec vector; 50 | struct { Real x; Real y; }; 51 | }; 52 | int index; 53 | }; 54 | 55 | #pragma mark - 56 | 57 | inline Point::Point() : vector(), index() {} 58 | 59 | #pragma mark Implicit conversions 60 | 61 | template 62 | inline Point::Point(const T& other) : vector(other.x, other.y), index() {} 63 | 64 | } // namespace triangulation 65 | } // namespace takram 66 | 67 | #endif // TAKRAM_TRIANGULATION_POINT_H_ 68 | -------------------------------------------------------------------------------- /src/takram/triangulation/result.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/result.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/result.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "takram/triangulation/library.h" 34 | 35 | namespace takram { 36 | namespace triangulation { 37 | 38 | Result::Result() : data_(std::make_unique()) { 39 | std::memset(data_.get(), 0, sizeof(*data_)); 40 | } 41 | 42 | Result::~Result() { 43 | std::free(data_->pointlist); 44 | std::free(data_->pointmarkerlist); 45 | std::free(data_->pointattributelist); 46 | std::free(data_->trianglelist); 47 | std::free(data_->triangleattributelist); 48 | std::free(data_->trianglearealist); 49 | std::free(data_->neighborlist); 50 | std::free(data_->segmentlist); 51 | std::free(data_->segmentmarkerlist); 52 | std::free(data_->holelist); 53 | std::free(data_->regionlist); 54 | std::free(data_->edgelist); 55 | std::free(data_->edgemarkerlist); 56 | std::free(data_->normlist); 57 | } 58 | 59 | } // namespace triangulation 60 | } // namespace takram 61 | -------------------------------------------------------------------------------- /src/takram/triangulation/result.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/result.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_RESULT_H_ 29 | #define TAKRAM_TRIANGULATION_RESULT_H_ 30 | 31 | #include 32 | 33 | struct triangulateio; 34 | 35 | namespace takram { 36 | namespace triangulation { 37 | 38 | class Result final { 39 | public: 40 | Result(); 41 | ~Result(); 42 | 43 | // Disallow copy semantics 44 | Result(const Result&) = delete; 45 | Result& operator=(const Result&) = delete; 46 | 47 | // Move semantics 48 | Result(Result&&) = default; 49 | 50 | // Operators 51 | struct triangulateio& operator*() { return *get(); } 52 | struct triangulateio * operator->() { return get(); } 53 | struct triangulateio * get() { return data_.get(); } 54 | 55 | private: 56 | std::unique_ptr data_; 57 | }; 58 | 59 | } // namespace triangulation 60 | } // namespace takram 61 | 62 | #endif // TAKRAM_TRIANGULATION_RESULT_H_ 63 | -------------------------------------------------------------------------------- /src/takram/triangulation/triangle_iterator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/triangle_iterator.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/triangle_iterator.h" 28 | 29 | #include 30 | 31 | #include "takram/triangulation/library.h" 32 | #include "takram/triangulation/types.h" 33 | 34 | namespace takram { 35 | namespace triangulation { 36 | 37 | TriangleIterator::TriangleIterator(const std::shared_ptr& result) 38 | : result_(result), 39 | begin_((*result)->trianglelist), 40 | current_(begin_), 41 | derived_() {} 42 | 43 | TriangleIterator::TriangleIterator(const std::shared_ptr& result, 44 | const int *current) 45 | : result_(result), 46 | begin_((*result)->trianglelist), 47 | current_(current), 48 | derived_() {} 49 | 50 | #pragma mark Iterator 51 | 52 | const Triangle& TriangleIterator::operator*() const { 53 | if (derived_ != current_) { 54 | const auto a = *(current_ + 0) * 2; 55 | const auto b = *(current_ + 1) * 2; 56 | const auto c = *(current_ + 2) * 2; 57 | const auto points = (*result_)->pointlist; 58 | triangle_.set(Vec(points + a), Vec(points + b), Vec(points + c)); 59 | derived_ = current_; 60 | } 61 | return triangle_; 62 | } 63 | 64 | } // namespace triangulation 65 | } // namespace takram 66 | -------------------------------------------------------------------------------- /src/takram/triangulation/triangle_iterator.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/triangle_iterator.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_TRIANGLE_ITERATOR_H_ 29 | #define TAKRAM_TRIANGULATION_TRIANGLE_ITERATOR_H_ 30 | 31 | #include 32 | #include 33 | 34 | #include "takram/triangulation/result.h" 35 | #include "takram/triangulation/types.h" 36 | 37 | namespace takram { 38 | namespace triangulation { 39 | 40 | class TriangleIterator final 41 | : public std::iterator { 42 | public: 43 | TriangleIterator(); 44 | explicit TriangleIterator(const std::shared_ptr& result); 45 | TriangleIterator(const std::shared_ptr& result, const int *current); 46 | 47 | // Copy semantics 48 | TriangleIterator(const TriangleIterator&) = default; 49 | TriangleIterator& operator=(const TriangleIterator&) = default; 50 | 51 | // Comparison 52 | friend bool operator==(const TriangleIterator& lhs, 53 | const TriangleIterator& rhs); 54 | friend bool operator!=(const TriangleIterator& lhs, 55 | const TriangleIterator& rhs); 56 | 57 | // Iterator 58 | const Triangle& operator*() const; 59 | const Triangle * operator->() const { return &operator*(); } 60 | TriangleIterator& operator++(); 61 | TriangleIterator operator++(int); 62 | 63 | private: 64 | std::shared_ptr result_; 65 | const int * const begin_; 66 | const int *current_; 67 | 68 | // Cache 69 | mutable const int *derived_; 70 | mutable Triangle triangle_; 71 | }; 72 | 73 | #pragma mark - 74 | 75 | inline TriangleIterator::TriangleIterator() 76 | : begin_(), 77 | current_(), 78 | derived_() {} 79 | 80 | #pragma mark Comparison 81 | 82 | inline bool operator==(const TriangleIterator& lhs, 83 | const TriangleIterator& rhs) { 84 | return lhs.current_ == rhs.current_; 85 | } 86 | 87 | inline bool operator!=(const TriangleIterator& lhs, 88 | const TriangleIterator& rhs) { 89 | return !(lhs == rhs); 90 | } 91 | 92 | #pragma mark Iterator 93 | 94 | inline TriangleIterator& TriangleIterator::operator++() { 95 | current_ += 3; 96 | return *this; 97 | } 98 | 99 | inline TriangleIterator TriangleIterator::operator++(int) { 100 | TriangleIterator result(*this); 101 | operator++(); 102 | return result; 103 | } 104 | 105 | } // namespace triangulation 106 | } // namespace takram 107 | 108 | #endif // TAKRAM_TRIANGULATION_TRIANGLE_ITERATOR_H_ 109 | -------------------------------------------------------------------------------- /src/takram/triangulation/triangulator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/triangulator.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/triangulator.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "takram/triangulation/library.h" 36 | #include "takram/triangulation/types.h" 37 | 38 | namespace takram { 39 | namespace triangulation { 40 | 41 | namespace { 42 | 43 | using PointRef = std::reference_wrapper; 44 | 45 | inline bool Identify(const PointRef& a, const PointRef& b) { 46 | return a.get().vector == b.get().vector; 47 | } 48 | 49 | inline bool Compare(const PointRef& a, const PointRef& b) { 50 | return a.get().vector < b.get().vector; 51 | } 52 | 53 | inline bool CompareIndex(const PointRef& a, const PointRef& b) { 54 | return a.get().index < b.get().index; 55 | } 56 | 57 | } // namespace 58 | 59 | #pragma mark Triangulation 60 | 61 | bool Triangulator::operator()(const std::vector& points) { 62 | // Sort and unique will remove lots of points we don't need 63 | std::vector refs(points.begin(), points.end()); 64 | std::sort(refs.begin(), refs.end(), Compare); 65 | refs.erase(std::unique(refs.begin(), refs.end(), Identify), refs.end()); 66 | 67 | // Sort again, now on their indexes 68 | std::sort(refs.begin(), refs.end(), CompareIndex); 69 | std::vector coordinates; 70 | for (const auto& ref : refs) { 71 | coordinates.emplace_back(ref.get().x); 72 | coordinates.emplace_back(ref.get().y); 73 | } 74 | return operator()(coordinates); 75 | } 76 | 77 | bool Triangulator::operator()(const std::string& options, 78 | struct triangulateio *in, 79 | struct triangulateio *out, 80 | struct triangulateio *voronoi) { 81 | std::string parameters; 82 | if (!std::isnan(min_angle_)) { 83 | parameters += "q" + std::to_string(min_angle_); 84 | } 85 | if (!std::isnan(max_area_)) { 86 | parameters += "a" + std::to_string(max_area_); 87 | } 88 | if (max_steiner_points_ >= 0) { 89 | parameters += "S" + std::to_string(max_steiner_points_); 90 | } 91 | std::vector switches(options.begin(), options.end()); 92 | switches.insert(switches.end(), parameters.begin(), parameters.end()); 93 | switches.emplace_back('\0'); 94 | ::triangulate(switches.data(), in, out, voronoi); 95 | return true; 96 | } 97 | 98 | } // namespace triangulation 99 | } // namespace takram 100 | -------------------------------------------------------------------------------- /src/takram/triangulation/triangulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/triangulator.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_TRIANGULATOR_H_ 29 | #define TAKRAM_TRIANGULATION_TRIANGULATOR_H_ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include "takram/triangulation/point.h" 40 | #include "takram/triangulation/result.h" 41 | #include "takram/triangulation/types.h" 42 | 43 | struct triangulateio; 44 | 45 | namespace takram { 46 | namespace triangulation { 47 | 48 | class Triangulator { 49 | public: 50 | Triangulator(); 51 | virtual ~Triangulator() = 0; 52 | 53 | // Copy semantics 54 | Triangulator(const Triangulator&) = default; 55 | Triangulator& operator=(const Triangulator&) = default; 56 | 57 | // Triangulation 58 | template 59 | bool operator()(const Container& container); 60 | bool operator()(std::vector&& points); 61 | bool operator()(const std::vector& points); 62 | virtual bool operator()(const std::vector& coordinates) = 0; 63 | void clear(); 64 | 65 | // Parameters 66 | Real min_angle() const; 67 | void set_min_angle(double value); 68 | Real max_area() const; 69 | void set_max_area(double value); 70 | int max_steiner_points() const; 71 | void set_max_steiner_points(int value); 72 | 73 | // Attributes 74 | bool empty() const { return !result_; } 75 | virtual std::size_t size() const = 0; 76 | 77 | protected: 78 | // Triangulation 79 | bool operator()(const std::string& options, 80 | struct triangulateio *in, 81 | struct triangulateio *out, 82 | struct triangulateio *voronoi); 83 | 84 | protected: 85 | std::shared_ptr result_; 86 | 87 | private: 88 | Real min_angle_; 89 | Real max_area_; 90 | int max_steiner_points_; 91 | }; 92 | 93 | #pragma mark - 94 | 95 | inline Triangulator::Triangulator() 96 | : min_angle_(std::numeric_limits::quiet_NaN()), 97 | max_area_(std::numeric_limits::quiet_NaN()), 98 | max_steiner_points_(-1) {} 99 | 100 | inline Triangulator::~Triangulator() {} 101 | 102 | #pragma mark Triangulation 103 | 104 | template 105 | inline bool Triangulator::operator()(const Container& container) { 106 | std::vector points(container.size()); 107 | std::copy(container.begin(), container.end(), points.begin()); 108 | return operator()(std::move(points)); 109 | } 110 | 111 | inline bool Triangulator::operator()(std::vector&& points) { 112 | std::size_t index{}; 113 | for (auto& point : points) { 114 | point.index = index++; 115 | } 116 | return operator()(points); 117 | } 118 | 119 | inline void Triangulator::clear() { 120 | result_.reset(nullptr); 121 | } 122 | 123 | #pragma mark Parameters 124 | 125 | inline Real Triangulator::min_angle() const { 126 | return min_angle_; 127 | } 128 | 129 | inline void Triangulator::set_min_angle(Real value) { 130 | min_angle_ = value; 131 | } 132 | 133 | inline Real Triangulator::max_area() const { 134 | return max_area_; 135 | } 136 | 137 | inline void Triangulator::set_max_area(Real value) { 138 | max_area_ = value; 139 | } 140 | 141 | inline int Triangulator::max_steiner_points() const { 142 | return max_steiner_points_; 143 | } 144 | 145 | inline void Triangulator::set_max_steiner_points(int value) { 146 | max_steiner_points_ = value; 147 | } 148 | 149 | } // namespace triangulation 150 | 151 | using triangulation::Triangulator; 152 | 153 | } // namespace takram 154 | 155 | #endif // TAKRAM_TRIANGULATION_TRIANGULATOR_H_ 156 | -------------------------------------------------------------------------------- /src/takram/triangulation/types.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/types.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_TYPES_H_ 29 | #define TAKRAM_TRIANGULATION_TYPES_H_ 30 | 31 | #include "takram/math/line2.h" 32 | #include "takram/math/triangle2.h" 33 | #include "takram/math/vector2.h" 34 | 35 | namespace takram { 36 | namespace triangulation { 37 | 38 | using Real = double; 39 | using Vec = Vec2; 40 | using Line = Line2; 41 | using Triangle = Triangle2; 42 | 43 | } // namespace triangulation 44 | } // namespace takram 45 | 46 | #endif // TAKRAM_TRIANGULATION_TYPES_H_ 47 | -------------------------------------------------------------------------------- /src/takram/triangulation/voronoi_triangulator.cc: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/voronoi_triangulator.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "takram/triangulation/voronoi_triangulator.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "takram/triangulation/edge_iterator.h" 38 | #include "takram/triangulation/library.h" 39 | #include "takram/triangulation/types.h" 40 | 41 | namespace takram { 42 | namespace triangulation { 43 | 44 | #pragma mark Triangulation 45 | 46 | bool VoronoiTriangulator::operator()(const std::vector& points) { 47 | const auto size = points.size() / 2; 48 | using Size = decltype(triangulateio::numberofpoints); 49 | if (size > std::numeric_limits::max()) { 50 | // Number of points exceeds the limit of triangle library 51 | return false; 52 | } else if (size < 3) { 53 | // Provided point must have at least 3 points 54 | return false; 55 | } 56 | // Prepare data 57 | result_ = std::make_shared(); 58 | Result out; 59 | struct triangulateio in; 60 | std::memset(&in, 0, sizeof(in)); 61 | std::vector mutable_points(points); 62 | in.pointlist = mutable_points.data(); 63 | in.numberofpoints = size; 64 | 65 | // Triangulation 66 | return Triangulator::operator()("vzQ", &in, &*out, &**result_); 67 | } 68 | 69 | #pragma mark Attributes 70 | 71 | std::size_t VoronoiTriangulator::size() const { 72 | if (!result_) { 73 | return 0; 74 | } 75 | return (*result_)->numberofedges; 76 | } 77 | 78 | #pragma mark Iterators 79 | 80 | EdgeIterator VoronoiTriangulator::begin() const { 81 | if (!result_) { 82 | return EdgeIterator(); 83 | } 84 | return EdgeIterator(result_); 85 | } 86 | 87 | EdgeIterator VoronoiTriangulator::end() const { 88 | if (!result_) { 89 | return EdgeIterator(); 90 | } 91 | const auto end = (*result_)->edgelist + (*result_)->numberofedges * 2; 92 | return EdgeIterator(result_, end); 93 | } 94 | 95 | } // namespace triangulation 96 | } // namespace takram 97 | -------------------------------------------------------------------------------- /src/takram/triangulation/voronoi_triangulator.h: -------------------------------------------------------------------------------- 1 | // 2 | // takram/triangulation/voronoi_triangulator.h 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2014-2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #pragma once 28 | #ifndef TAKRAM_TRIANGULATION_VORONOI_TRIANGULATOR_H_ 29 | #define TAKRAM_TRIANGULATION_VORONOI_TRIANGULATOR_H_ 30 | 31 | #include 32 | #include 33 | 34 | #include "takram/triangulation/edge_iterator.h" 35 | #include "takram/triangulation/triangulator.h" 36 | #include "takram/triangulation/types.h" 37 | 38 | namespace takram { 39 | namespace triangulation { 40 | 41 | class VoronoiTriangulator : public Triangulator { 42 | public: 43 | VoronoiTriangulator() = default; 44 | 45 | // Copy semantics 46 | VoronoiTriangulator(const VoronoiTriangulator&) = default; 47 | VoronoiTriangulator& operator=(const VoronoiTriangulator&) = default; 48 | 49 | // Triangulation 50 | using Triangulator::operator(); 51 | bool operator()(const std::vector& coordinates) override; 52 | 53 | // Attributes 54 | std::size_t size() const override; 55 | 56 | // Iterator 57 | EdgeIterator begin() const; 58 | EdgeIterator end() const; 59 | }; 60 | 61 | } // namespace triangulation 62 | 63 | using triangulation::VoronoiTriangulator; 64 | 65 | } // namespace takram 66 | 67 | #endif // TAKRAM_TRIANGULATION_VORONOI_TRIANGULATOR_H_ 68 | -------------------------------------------------------------------------------- /test/test.cc: -------------------------------------------------------------------------------- 1 | // 2 | // test.cc 3 | // 4 | // The MIT License 5 | // 6 | // Copyright (C) 2015 Shota Matsuda 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a 9 | // copy of this software and associated documentation files (the "Software"), 10 | // to deal in the Software without restriction, including without limitation 11 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | // and/or sell copies of the Software, and to permit persons to whom the 13 | // Software is furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | // DEALINGS IN THE SOFTWARE. 25 | // 26 | 27 | #include "gtest/gtest.h" 28 | 29 | #include "takram/triangulation.h" 30 | 31 | namespace takram { 32 | namespace triangulation { 33 | 34 | } // namespace triangulation 35 | } // namespace takram 36 | -------------------------------------------------------------------------------- /triangulation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "triangulation", "triangulation/triangulation.vcxproj", "{94341CDF-2064-48A1-BAFB-C21AC3DE3B84}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "triangulation/test.vcxproj", "{20291AD8-8E5C-4682-AE29-0D4230D24CC5}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7} = {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7} 11 | {3AF54C8A-10BF-4332-9147-F68ED9862032} = {3AF54C8A-10BF-4332-9147-F68ED9862032} 12 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84} = {94341CDF-2064-48A1-BAFB-C21AC3DE3B84} 13 | EndProjectSection 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "triangulation/gtest_main.vcxproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 16 | EndProject 17 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "triangulation/gtest.vcxproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|x64 = Debug|x64 22 | Debug|x86 = Debug|x86 23 | Release|x64 = Release|x64 24 | Release|x86 = Release|x86 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Debug|x64.ActiveCfg = Debug|x64 28 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Debug|x64.Build.0 = Debug|x64 29 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Debug|x86.ActiveCfg = Debug|Win32 30 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Debug|x86.Build.0 = Debug|Win32 31 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Release|x64.ActiveCfg = Release|x64 32 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Release|x64.Build.0 = Release|x64 33 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Release|x86.ActiveCfg = Release|Win32 34 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84}.Release|x86.Build.0 = Release|Win32 35 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Debug|x64.ActiveCfg = Debug|x64 36 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Debug|x64.Build.0 = Debug|x64 37 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Debug|x86.ActiveCfg = Debug|Win32 38 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Debug|x86.Build.0 = Debug|Win32 39 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Release|x64.ActiveCfg = Release|x64 40 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Release|x64.Build.0 = Release|x64 41 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Release|x86.ActiveCfg = Release|Win32 42 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5}.Release|x86.Build.0 = Release|Win32 43 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.ActiveCfg = Debug|x64 44 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x64.Build.0 = Debug|x64 45 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x86.ActiveCfg = Debug|Win32 46 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug|x86.Build.0 = Debug|Win32 47 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.ActiveCfg = Release|x64 48 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x64.Build.0 = Release|x64 49 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x86.ActiveCfg = Release|Win32 50 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release|x86.Build.0 = Release|Win32 51 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.ActiveCfg = Debug|x64 52 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x64.Build.0 = Debug|x64 53 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x86.ActiveCfg = Debug|Win32 54 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|x86.Build.0 = Debug|Win32 55 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.ActiveCfg = Release|x64 56 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x64.Build.0 = Release|x64 57 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x86.ActiveCfg = Release|Win32 58 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|x86.Build.0 = Release|Win32 59 | EndGlobalSection 60 | GlobalSection(SolutionProperties) = preSolution 61 | HideSolutionNode = FALSE 62 | EndGlobalSection 63 | EndGlobal 64 | -------------------------------------------------------------------------------- /triangulation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /triangulation/gtest.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7} 23 | Win32Proj 24 | 8.1 25 | 26 | 27 | 28 | StaticLibrary 29 | v140 30 | Unicode 31 | 32 | 33 | StaticLibrary 34 | v140 35 | Unicode 36 | 37 | 38 | StaticLibrary 39 | v140 40 | Unicode 41 | 42 | 43 | StaticLibrary 44 | v140 45 | Unicode 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | <_ProjectFileVersion>14.0.23107.0 65 | 66 | 67 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 68 | $(OutDir)$(ProjectName)\ 69 | 70 | 71 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 72 | $(OutDir)$(ProjectName)\ 73 | 74 | 75 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 76 | $(OutDir)$(ProjectName)\ 77 | 78 | 79 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 80 | $(OutDir)$(ProjectName)\ 81 | 82 | 83 | 84 | Disabled 85 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 86 | true 87 | EnableFastChecks 88 | MultiThreadedDebug 89 | 90 | Level3 91 | EditAndContinue 92 | 93 | 94 | 95 | 96 | Disabled 97 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 98 | EnableFastChecks 99 | MultiThreadedDebug 100 | 101 | 102 | Level3 103 | ProgramDatabase 104 | 105 | 106 | 107 | 108 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 109 | MultiThreaded 110 | 111 | Level3 112 | ProgramDatabase 113 | 114 | 115 | 116 | 117 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 118 | MultiThreaded 119 | 120 | 121 | Level3 122 | ProgramDatabase 123 | 124 | 125 | 126 | 127 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 128 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 129 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 130 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /triangulation/gtest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /triangulation/gtest_main.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {3AF54C8A-10BF-4332-9147-F68ED9862032} 23 | Win32Proj 24 | 8.1 25 | 26 | 27 | 28 | StaticLibrary 29 | v140 30 | Unicode 31 | 32 | 33 | StaticLibrary 34 | v140 35 | Unicode 36 | 37 | 38 | StaticLibrary 39 | v140 40 | Unicode 41 | 42 | 43 | StaticLibrary 44 | v140 45 | Unicode 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | <_ProjectFileVersion>14.0.23107.0 65 | 66 | 67 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 68 | $(OutDir)$(ProjectName)\ 69 | 70 | 71 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 72 | $(OutDir)$(ProjectName)\ 73 | 74 | 75 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 76 | $(OutDir)$(ProjectName)\ 77 | 78 | 79 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 80 | $(OutDir)$(ProjectName)\ 81 | 82 | 83 | 84 | Disabled 85 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 86 | true 87 | EnableFastChecks 88 | MultiThreadedDebug 89 | 90 | Level3 91 | EditAndContinue 92 | 93 | 94 | 95 | 96 | Disabled 97 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 98 | EnableFastChecks 99 | MultiThreadedDebug 100 | 101 | 102 | Level3 103 | ProgramDatabase 104 | 105 | 106 | 107 | 108 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 109 | MultiThreaded 110 | 111 | Level3 112 | ProgramDatabase 113 | 114 | 115 | 116 | 117 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 118 | MultiThreaded 119 | 120 | 121 | Level3 122 | ProgramDatabase 123 | 124 | 125 | 126 | 127 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 128 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 129 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 130 | $(SolutionDir)lib\googletest\googletest;$(SolutionDir)lib\googletest\googletest\include;%(AdditionalIncludeDirectories) 131 | 132 | 133 | 134 | 135 | {c8f6c172-56f2-4e76-b5fa-c3b423b31be7} 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /triangulation/gtest_main.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /triangulation/test.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | {20291AD8-8E5C-4682-AE29-0D4230D24CC5} 26 | math 27 | 8.1 28 | 29 | 30 | 31 | Application 32 | true 33 | v140 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v140 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v140 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v140 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 76 | $(OutDir)$(ProjectName)\ 77 | 78 | 79 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 80 | $(OutDir)$(ProjectName)\ 81 | 82 | 83 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 84 | $(OutDir)$(ProjectName)\ 85 | 86 | 87 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 88 | $(OutDir)$(ProjectName)\ 89 | 90 | 91 | 92 | Level3 93 | Disabled 94 | true 95 | MultiThreadedDebug 96 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)test;$(SolutionDir)..\takram-math\src;$(SolutionDir)lib\googletest\googletest\include 97 | 4068 98 | 99 | 100 | true 101 | %(AdditionalDependencies);triangulation.lib;gtest.lib;gtest_main.lib 102 | %(AdditionalLibraryDirectories);$(OutDir) 103 | Console 104 | 105 | 106 | 107 | 108 | Level3 109 | Disabled 110 | true 111 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)test;$(SolutionDir)..\takram-math\src;$(SolutionDir)lib\googletest\googletest\include 112 | MultiThreadedDebug 113 | 4068 114 | 115 | 116 | true 117 | %(AdditionalDependencies);triangulation.lib;gtest.lib;gtest_main.lib 118 | %(AdditionalLibraryDirectories);$(OutDir) 119 | Console 120 | 121 | 122 | 123 | 124 | Level3 125 | MaxSpeed 126 | true 127 | true 128 | true 129 | MultiThreaded 130 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)test;$(SolutionDir)..\takram-math\src;$(SolutionDir)lib\googletest\googletest\include 131 | 4068 132 | 133 | 134 | true 135 | true 136 | true 137 | %(AdditionalDependencies);triangulation.lib;gtest.lib;gtest_main.lib 138 | %(AdditionalLibraryDirectories);$(OutDir) 139 | Console 140 | 141 | 142 | 143 | 144 | Level3 145 | MaxSpeed 146 | true 147 | true 148 | true 149 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)test;$(SolutionDir)..\takram-math\src;$(SolutionDir)lib\googletest\googletest\include 150 | MultiThreaded 151 | 4068 152 | 153 | 154 | true 155 | true 156 | true 157 | %(AdditionalDependencies);triangulation.lib;gtest.lib;gtest_main.lib 158 | %(AdditionalLibraryDirectories);$(OutDir) 159 | Console 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /triangulation/test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {d0ef5992-5180-4d5a-869e-979f87215839} 6 | 7 | 8 | 9 | 10 | src 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /triangulation/triangulation.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | TRILIBRARY;ANSI_DECLARATORS;NO_TIMER;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 24 | TRILIBRARY;ANSI_DECLARATORS;NO_TIMER;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 25 | TRILIBRARY;ANSI_DECLARATORS;NO_TIMER;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 26 | TRILIBRARY;ANSI_DECLARATORS;NO_TIMER;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 27 | TurnOffAllWarnings 28 | TurnOffAllWarnings 29 | TurnOffAllWarnings 30 | TurnOffAllWarnings 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {94341CDF-2064-48A1-BAFB-C21AC3DE3B84} 56 | math 57 | 8.1 58 | 59 | 60 | 61 | StaticLibrary 62 | true 63 | v140 64 | Unicode 65 | 66 | 67 | StaticLibrary 68 | false 69 | v140 70 | true 71 | Unicode 72 | 73 | 74 | StaticLibrary 75 | true 76 | v140 77 | Unicode 78 | 79 | 80 | StaticLibrary 81 | false 82 | v140 83 | true 84 | Unicode 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 106 | $(OutDir)$(ProjectName)\ 107 | 108 | 109 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 110 | $(OutDir)$(ProjectName)\ 111 | 112 | 113 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 114 | $(OutDir)$(ProjectName)\ 115 | 116 | 117 | $(SolutionDir)build\$(Platform)\$(Configuration)\ 118 | $(OutDir)$(ProjectName)\ 119 | 120 | 121 | 122 | Level3 123 | Disabled 124 | true 125 | MultiThreadedDebug 126 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)lib;$(SolutionDir)..\takram-math\src 127 | 4068 128 | 129 | 130 | true 131 | 132 | 133 | 134 | 135 | Level3 136 | Disabled 137 | true 138 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)lib;$(SolutionDir)..\takram-math\src 139 | MultiThreadedDebug 140 | 4068 141 | 142 | 143 | true 144 | 145 | 146 | 147 | 148 | Level3 149 | MaxSpeed 150 | true 151 | true 152 | true 153 | MultiThreaded 154 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)lib;$(SolutionDir)..\takram-math\src 155 | 4068 156 | 157 | 158 | true 159 | true 160 | true 161 | 162 | 163 | 164 | 165 | Level3 166 | MaxSpeed 167 | true 168 | true 169 | true 170 | %(AdditionalIncludeDirectories);$(SolutionDir)src;$(SolutionDir)lib;$(SolutionDir)..\takram-math\src 171 | MultiThreaded 172 | 4068 173 | 174 | 175 | true 176 | true 177 | true 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /triangulation/triangulation.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {6e067234-9d9b-4b89-a47c-bf6f88215564} 6 | 7 | 8 | {bf4db00c-9534-4bd4-95e3-a8b685793abd} 9 | 10 | 11 | {97bf4ff5-76cf-4a85-b141-dde5d6425aeb} 12 | 13 | 14 | 15 | 16 | src 17 | 18 | 19 | src 20 | 21 | 22 | src 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | src 32 | 33 | 34 | src 35 | 36 | 37 | lib\triangle 38 | 39 | 40 | 41 | 42 | src 43 | 44 | 45 | src 46 | 47 | 48 | src 49 | 50 | 51 | src 52 | 53 | 54 | src 55 | 56 | 57 | src 58 | 59 | 60 | src 61 | 62 | 63 | src 64 | 65 | 66 | src 67 | 68 | 69 | src 70 | 71 | 72 | src 73 | 74 | 75 | lib\triangle 76 | 77 | 78 | --------------------------------------------------------------------------------