-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Mesh3d cell data checks #3369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mesh3d cell data checks #3369
Changes from 1 commit
12f3e1f
33e2b9a
f1772a2
e531e4e
65a5806
e97f5ed
55e5e12
79deeae
bf51940
83060bc
a041e51
2b54f14
a9ab05f
ec502ee
fadce01
29f5a06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ var triangulate = require('delaunay-triangulate'); | |
| var alphaShape = require('alpha-shape'); | ||
| var convexHull = require('convex-hull'); | ||
|
|
||
| var isIndex = require('../../lib').isIndex; | ||
| var parseColorScale = require('../../lib/gl_format_color').parseColorScale; | ||
| var str2RgbaArray = require('../../lib/str2rgbarray'); | ||
| var zip3 = require('../../plots/gl3d/zip3'); | ||
|
|
@@ -91,12 +92,40 @@ function delaunayCells(delaunayaxis, positions) { | |
| return triangulate(b); | ||
| } | ||
|
|
||
| // validate indices | ||
| function hasValidIndices(list, numVertices) { | ||
| var len = list.length; | ||
| for(var i = 0; i < len; i++) { | ||
| if(!isIndex(list[i], numVertices)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| // avoid pointing to an identical vertex twice | ||
| function isTriangle(lists) { | ||
| var len = lists[0].length; | ||
| for(var i = 0; i < len; i++) { | ||
| if( | ||
| lists[0][i] === lists[1][i] || | ||
| lists[1][i] === lists[2][i] || | ||
| lists[2][i] === lists[0][i] | ||
| ) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| proto.update = function(data) { | ||
| var scene = this.scene; | ||
| var layout = scene.fullSceneLayout; | ||
|
|
||
| this.data = data; | ||
|
|
||
| var numVertices = data.x.length; | ||
|
|
||
| var positions = zip3( | ||
| toDataCoords(layout.xaxis, data.x, scene.dataScale[0], data.xcalendar), | ||
| toDataCoords(layout.yaxis, data.y, scene.dataScale[1], data.ycalendar), | ||
|
|
@@ -105,6 +134,18 @@ proto.update = function(data) { | |
|
|
||
| var cells; | ||
| if(data.i && data.j && data.k) { | ||
|
|
||
| if( | ||
| data.i.length !== data.j.length || | ||
| data.j.length !== data.k.length || | ||
| !hasValidIndices(data.i, numVertices) || | ||
| !hasValidIndices(data.j, numVertices) || | ||
| !hasValidIndices(data.k, numVertices) || | ||
| !isTriangle([data.i, data.j, data.k]) | ||
| ) { | ||
| data.visible = false; | ||
|
||
| return; | ||
| } | ||
| cells = zip3( | ||
| toIndex(data.i), | ||
| toIndex(data.j), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.