Skip to content

Isosurface integration #3311

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

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
892e7ed
initial scaffold for isosurface traces
kig Jun 18, 2018
f6aba79
first working version of the isosurface plot
kig Jun 22, 2018
639c287
fix isosurface meshgrid construction
kig Jun 23, 2018
6b2dbac
fix lint errors
kig Jun 25, 2018
98ad6b0
Merge branch 'master' into isosurface-traces
etpinard Jul 10, 2018
6b87ed7
add gl-isosurface3d to package-lock
etpinard Jul 10, 2018
1c4ec62
fixup post merge-master
etpinard Jul 10, 2018
d417e6e
isosurface trace [xyz](min|max) bounds
kig Aug 12, 2018
88cad83
add npm gl-isosurface to package.json
kig Aug 12, 2018
c3df068
isosurface hovertext hack in spirit of src/plots/gl3d/scene.js:91
kig Aug 24, 2018
f7eb951
Compute bounds for isosurface
kig Aug 24, 2018
604a2d9
update example to implicit bounds, 2x size
kig Aug 27, 2018
f761b09
Isosurface attributes add roles, tweak descriptions
kig Sep 10, 2018
eb5221d
isosurface eslint fixes
kig Sep 10, 2018
e75e9d7
isosurface single-color surface
kig Sep 10, 2018
2ee5f60
isosurface lint fixes
kig Sep 13, 2018
c884c89
isosurface lint fixes 2/2
kig Sep 13, 2018
c611b63
changes to package lock
archmoj Nov 5, 2018
0667ef5
fetched master
archmoj Nov 5, 2018
fa0716e
changes to package lock - adding gl-isosurface3d
archmoj Nov 5, 2018
4de0659
added a mock for isosurface3d
archmoj Nov 5, 2018
023469d
corrected the mock for isosurface3d
archmoj Nov 5, 2018
17dfbd4
Merge remote-tracking branch 'origin/master' into isosurface-traces_f…
archmoj Nov 5, 2018
2d7b7db
updated baseline image
archmoj Nov 5, 2018
09211ba
clip and support for reversed bounds
archmoj Nov 5, 2018
f50b820
correct image with reversed bound
archmoj Nov 5, 2018
5b8a58b
Merge remote-tracking branch 'origin/master' v.1.42.3 into isosurface…
archmoj Nov 7, 2018
a3f7fdf
using refactored module pass 1
archmoj Nov 7, 2018
78eca55
using the new module pass 2
archmoj Nov 7, 2018
ca7519e
renamed the mock and baseline
archmoj Nov 9, 2018
f161a06
http to https
archmoj Nov 21, 2018
51a77dc
using revised gl-isosurface code
archmoj Dec 3, 2018
931de37
updated mock
archmoj Dec 6, 2018
0227262
updated isosurface baseline
archmoj Dec 6, 2018
eaa2e81
apply changes in gl-isosurfcae3d
archmoj Dec 6, 2018
4c243c9
fetch master
archmoj Dec 6, 2018
6f546f0
fixes regarding surfacecolor PR to solve merge conflicts
archmoj Dec 6, 2018
817cc29
lower resoultion mock
archmoj Dec 6, 2018
b313470
new baseline and comments
archmoj Dec 6, 2018
961dd16
few more items to resolve the conflict
archmoj Dec 6, 2018
a0421c2
fixes to past the tests
archmoj Dec 6, 2018
fd29638
removed unused code block
archmoj Dec 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Plotly.register([
require('./mesh3d'),
require('./cone'),
require('./streamtube'),
require('./isosurface'),

require('./scattergeo'),
require('./choropleth'),
Expand Down
11 changes: 11 additions & 0 deletions lib/isosurface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = require('../src/traces/isosurface');
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"es6-promise": "^3.0.2",
"fast-isnumeric": "^1.1.2",
"font-atlas-sdf": "^1.3.3",
"gl-isosurface3d": "git://github.com/gl-vis/gl-isosurface3d.git#33711824b895b7af1abc59b6d8dc0bbdaeda1b21",
"gl-cone3d": "^1.2.1",
"gl-contour2d": "^1.1.4",
"gl-error3d": "^1.0.9",
Expand Down
168 changes: 168 additions & 0 deletions src/traces/isosurface/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var colorscaleAttrs = require('../../components/colorscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var mesh3dAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

var extendFlat = require('../../lib/extend').extendFlat;

var attrs = {
x: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the x coordinates of the volume data',
'(from which the isosurface will be calculated)'
].join(' ')
},
y: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the y coordinates of the volume data',
'(from which the isosurface will be calculated)'
].join(' ')
},
z: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the z coordinates of the volume data',
'(from which the isosurface will be calculated)'
].join(' ')
},

value: {
valType: 'data_array',
role: 'info',
editType: 'calc',
description: 'Sets the intensity values of the volume data.'
},

isomin: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the minimum intensity bound of the isosurface.'
},

isomax: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the maximum intensity bound of the isosurface.'
},

xmin: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the minimum x bound of the isosurface.'
},

xmax: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the maximum x bound of the isosurface.'
},

ymin: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the minimum y bound of the isosurface.'
},

ymax: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the maximum y bound of the isosurface.'
},

zmin: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the minimum z bound of the isosurface.'
},

zmax: {
valType: 'number',
role: 'info',
editType: 'calc',
description: 'Sets the maximum z bound of the isosurface.'
},

smoothnormals: {
valType: 'boolean',
role: 'info',
editType: 'calc',
description: 'Smooth normals of the isosurface. By default this is set to true.'
},

isocaps: {
valType: 'boolean',
role: 'info',
editType: 'calc',
description: 'Whether to generate isocaps for the isosurface. By default this is set to true.'
},

surfacecolor: {
valType: 'data_array',
role: 'style',
editType: 'calc',
description: [
'Sets the color of the isosurface.',
'By default the isosurface color is computed from the colorscale.',
'Isocaps still use the colorscale colors even with this set.'
].join(' ')
},

text: {
valType: 'string',
role: 'info',
dflt: '',
arrayOk: true,
editType: 'calc',
description: [
'Sets the text elements associated with the isosurface points.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
}
};

extendFlat(attrs, colorscaleAttrs('', {
colorAttr: 'value',
showScaleDflt: true,
editTypeOverride: 'calc'
}), {
colorbar: colorbarAttrs
});

var fromMesh3d = ['opacity', 'lightposition', 'lighting'];
fromMesh3d.forEach(function(k) {
attrs[k] = mesh3dAttrs[k];
});

attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
editType: 'calc',
flags: ['x', 'y', 'z', 'value', 'text', 'name'],
dflt: 'x+y+z+value+text+name'
});

module.exports = attrs;
71 changes: 71 additions & 0 deletions src/traces/isosurface/calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var colorscaleCalc = require('../../components/colorscale/calc');

module.exports = function calc(gd, trace) {
var value = trace.value;
var len = value.length;
var vMax = -Infinity;
var vMin = Infinity;
var i = 0;

for(i = 0; i < len; i++) {
var v = value[i];
vMax = Math.max(vMax, v);
vMin = Math.min(vMin, v);
}

trace._vMax = vMax;

if(trace.surfacecolor) {
colorscaleCalc(gd, trace, {
vals: trace.surfacecolor,
containerStr: '',
cLetter: 'c'
});
} else {
colorscaleCalc(gd, trace, {
vals: [vMin, vMax],
containerStr: '',
cLetter: 'c'
});
}

var x = trace.x;
var y = trace.y;
var z = trace.z;

var xMax = -Infinity;
var xMin = Infinity;
var yMax = -Infinity;
var yMin = Infinity;
var zMax = -Infinity;
var zMin = Infinity;

for(i = 0; i < len; i++) {
var xx = x[i];
xMax = Math.max(xMax, xx);
xMin = Math.min(xMin, xx);

var yy = y[i];
yMax = Math.max(yMax, yy);
yMin = Math.min(yMin, yy);

var zz = z[i];
zMax = Math.max(zMax, zz);
zMin = Math.min(zMin, zz);
}

trace._xbnds = [xMin, xMax];
trace._ybnds = [yMin, yMax];
trace._zbnds = [zMin, zMax];

};
Loading