Skip to content
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

New code for isosurface trace #3340

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
71ae66e
new isosurface traces
archmoj Dec 16, 2018
be3c5a5
using full data cube
archmoj Dec 16, 2018
dfe2a85
use data cube dimensions i.e. width and height
archmoj Dec 16, 2018
251b2d4
value > volume
archmoj Dec 16, 2018
cd86716
revised x y z
archmoj Dec 16, 2018
66bf59d
updated baseline
archmoj Dec 16, 2018
dee7c8e
handle non-uniform space pass 1 for integers
archmoj Dec 17, 2018
b2b7bc0
real world translation
archmoj Dec 17, 2018
0ac65d9
fixed interpolation
archmoj Dec 17, 2018
f5c6052
using isovalueand improved the mock
archmoj Dec 17, 2018
e5c7ff0
multiple isovalues could be applied with one trace
archmoj Dec 17, 2018
e60de84
http > https
archmoj Dec 17, 2018
0a9bf1d
fixed update for redraw
archmoj Dec 17, 2018
eecd804
fixed colorscale
archmoj Dec 17, 2018
b1f7939
corrected new isosurface baseline with colorscale
archmoj Dec 17, 2018
8779a6a
set intensity an internal value for iso-surface traces
archmoj Dec 17, 2018
2a4b9fb
correct baseline with colorscale
archmoj Dec 17, 2018
08e1508
added option to control which iso-surface meshing algorithm to use
archmoj Dec 18, 2018
4b49dc4
fixed scale tranform
archmoj Dec 18, 2018
07e11c0
isosurface baseline with correct x y z scales
archmoj Dec 18, 2018
06531f8
separate meshing record process
archmoj Dec 18, 2018
87ae392
improved isosurface mock to have both sides
archmoj Dec 18, 2018
af9294b
new two-sided isosurface baseline
archmoj Dec 18, 2018
f141098
fixed scales for negative ranges and prepration for isocaps
archmoj Dec 19, 2018
04cc4b4
more optimized code base for iso caps
archmoj Dec 19, 2018
a10b365
removed unused mock
archmoj Dec 19, 2018
16208cb
debug and fixed cap interpolation
archmoj Dec 19, 2018
b2f84be
removed debug opt
archmoj Dec 19, 2018
605ce44
updated isosurface mock with caps
archmoj Dec 19, 2018
56b4df1
volume > value and added checks to make trace invisible in case of em…
archmoj Dec 19, 2018
5311b01
reduced tolerance ratio
archmoj Dec 20, 2018
0171bf6
iso-surface baseline with reduced error for caps
archmoj Dec 21, 2018
1da04df
xyzw > xyzv
archmoj Dec 22, 2018
4ac90eb
may help handle parametric x y z coordinates
archmoj Dec 22, 2018
49aa746
reduced color attributes
archmoj Dec 31, 2018
d9c1fa7
intensity > value
archmoj Dec 31, 2018
79fdb19
more intensity to value
archmoj Dec 31, 2018
de20714
separate interpolatoin and extrapolation
archmoj Dec 31, 2018
341ba29
Merge remote-tracking branch 'origin/master' into isosurface-new
archmoj Jan 1, 2019
dac7f9d
apply new syntax rules for camelCase and one var per variable
archmoj Jan 1, 2019
94f0767
2018 > 2019 for isosurface
archmoj Jan 1, 2019
7c7bbe5
reduce vertex ids on each cap
archmoj Jan 2, 2019
9e5441d
reduced number of vertices of iso-surface and smoothing
archmoj Jan 2, 2019
940b41f
smooth isosurface baseline
archmoj Jan 2, 2019
dd08cd4
removed surfaceNets and marchingTetrahedra algorithms
archmoj Jan 2, 2019
530cdb4
revised to be more functional
archmoj Jan 2, 2019
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 @@ -25,6 +25,7 @@ Plotly.register([

require('./scatter3d'),
require('./surface'),
require('./isosurface'),
require('./mesh3d'),
require('./cone'),
require('./streamtube'),
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');
4 changes: 4 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",
"isosurface": "git://github.com/archmoj/isosurface.git#e2c41594417a2ba363bb430c7d38adfe18312fc5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"gl-cone3d": "^1.2.1",
"gl-contour2d": "^1.1.4",
"gl-error3d": "^1.0.9",
Expand Down
184 changes: 184 additions & 0 deletions src/traces/isosurface/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/**
* 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 surfaceAtts = require('../surface/attributes');
var baseAttrs = require('../../plots/attributes');

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

module.exports = extendFlat({
x: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the X coordinates of the vertices on X axis.'
].join(' ')
},
y: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the Y coordinates of the vertices on Y axis.'
].join(' ')
},
z: {
valType: 'data_array',
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the Z coordinates of the vertices on Z axis.'
].join(' ')
},
volume: {
archmoj marked this conversation as resolved.
Show resolved Hide resolved
valType: 'data_array',
role: 'info',
editType: 'calc',
description: [
'Sets the 4th dimension of the vertices.'
].join(' ')
},
isocap: {
valType: 'boolean',
role: 'info',
editType: 'calc',
dflt: false,
description: [
'Enable caps between minimum and maximum iso values.'
].join(' ')
},
isovalue: {
valType: 'data_array',
role: 'info',
editType: 'calc',
dflt: [0],
description: [
'Sets iso surface boundaries.'
].join(' ')
},
meshalgo: {
archmoj marked this conversation as resolved.
Show resolved Hide resolved
valType: 'string',
role: 'info',
dflt: 'MarchingCubes',
editType: 'calc',
description: [
'Sets the isosurface polygonizer algorithm:',
'including: `MarchingCubes` (i.e. default),',
'`MarchingTetrahedra` or `SurfaceNets`.'
].join(' ')
},

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

// Color field
color: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need color, vertexcolor and facecolor? Should applying a colorscale to value (your volume) be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced color attributes in 49aa746

valType: 'color',
role: 'style',
editType: 'calc',
description: 'Sets the color of the whole isosurface'
},
vertexcolor: {
valType: 'data_array',
role: 'style',
editType: 'calc',
description: [
'Sets the color of each vertex',
'Overrides *color*.'
].join(' ')
},
facecolor: {
valType: 'data_array',
role: 'style',
editType: 'calc',
description: [
'Sets the color of each face',
'Overrides *color* and *vertexcolor*.'
].join(' ')
},
transforms: undefined
},

colorscaleAttrs('', {
colorAttr: '`intensity`',
archmoj marked this conversation as resolved.
Show resolved Hide resolved
showScaleDflt: true,
editTypeOverride: 'calc'
}), {

colorbar: colorbarAttrs,

opacity: surfaceAtts.opacity,

// Flat shaded mode
flatshading: {
valType: 'boolean',
role: 'style',
dflt: false,
editType: 'calc',
description: [
'Determines whether or not normal smoothing is applied to the isosurfaces,',
'creating isosurfaces with an angular, low-poly look via flat reflections.'
].join(' ')
},

contour: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contour doesn't appear to have been implemented (which is fine 😄 ) - let's 🔪 these attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contours seem to be working on hover namely on caps.

show: extendFlat({}, surfaceAtts.contours.x.show, {
description: [
'Sets whether or not dynamic contours are shown on hover'
].join(' ')
}),
color: surfaceAtts.contours.x.color,
width: surfaceAtts.contours.x.width,
editType: 'calc'
},

lightposition: {
x: extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
y: extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
z: extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0}),
editType: 'calc'
},
lighting: extendFlat({
vertexnormalsepsilon: {
valType: 'number',
role: 'style',
min: 0.00,
max: 1,
dflt: 1e-12, // otherwise finely tessellated things eg. the brain will have no specular light reflection
editType: 'calc',
description: 'Epsilon for vertex normals calculation avoids math issues arising from degenerate geometry.'
},
facenormalsepsilon: {
valType: 'number',
role: 'style',
min: 0.00,
max: 1,
dflt: 1e-6, // even the brain model doesn't appear to need finer than this
editType: 'calc',
description: 'Epsilon for face normals calculation avoids math issues arising from degenerate geometry.'
},
editType: 'calc'
}, surfaceAtts.lighting),

hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {editType: 'calc'})
});
19 changes: 19 additions & 0 deletions src/traces/isosurface/calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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) {
colorscaleCalc(gd, trace, {
vals: trace.isovalue,
containerStr: '',
cLetter: 'c'
});
};
Loading