MCPcopy Index your code
hub / github.com/plotly/plotly.js / cdt2d

Function cdt2d

stackgl_modules/index.js:8068–8121  ·  view source on GitHub ↗
(points, edges, options)

Source from the content-addressed store, hash-verified

8066}
8067
8068function cdt2d(points, edges, options) {
8069
8070 if(!Array.isArray(edges)) {
8071 options = edges || {}
8072 edges = []
8073 } else {
8074 options = options || {}
8075 edges = edges || []
8076 }
8077
8078 //Parse out options
8079 var delaunay = !!getDefault(options, 'delaunay', true)
8080 var interior = !!getDefault(options, 'interior', true)
8081 var exterior = !!getDefault(options, 'exterior', true)
8082 var infinity = !!getDefault(options, 'infinity', false)
8083
8084 //Handle trivial case
8085 if((!interior && !exterior) || points.length === 0) {
8086 return []
8087 }
8088
8089 //Construct initial triangulation
8090 var cells = monotoneTriangulate(points, edges)
8091
8092 //If delaunay refinement needed, then improve quality by edge flipping
8093 if(delaunay || interior !== exterior || infinity) {
8094
8095 //Index all of the cells to support fast neighborhood queries
8096 var triangulation = makeIndex(points.length, canonicalizeEdges(edges))
8097 for(var i=0; i<cells.length; ++i) {
8098 var f = cells[i]
8099 triangulation.addTriangle(f[0], f[1], f[2])
8100 }
8101
8102 //Run edge flipping
8103 if(delaunay) {
8104 delaunayFlip(points, triangulation)
8105 }
8106
8107 //Filter points
8108 if(!exterior) {
8109 return filterTriangulation(triangulation, -1)
8110 } else if(!interior) {
8111 return filterTriangulation(triangulation, 1, infinity)
8112 } else if(infinity) {
8113 return filterTriangulation(triangulation, 0, infinity)
8114 } else {
8115 return triangulation.cells()
8116 }
8117
8118 } else {
8119 return cells
8120 }
8121}
8122
8123
8124/***/ }),

Callers 1

processPixelsImplFunction · 0.85

Calls 3

getDefaultFunction · 0.85
monotoneTriangulateFunction · 0.85
canonicalizeEdgesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…