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

iso-surface finalist with caps, slices & spaceframe display on uniform or non-uniform coordinates #3438

Merged
merged 169 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from 165 commits
Commits
Show all changes
169 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
dd2d8ea
towards isosurface with no dep module
archmoj Jan 2, 2019
bc8c7de
prep for draw cubes
archmoj Jan 2, 2019
26aa9a7
compact code before extending tri > tetra
archmoj Jan 3, 2019
b64ebe4
progress on expanding tetra draw
archmoj Jan 3, 2019
e9b001f
major improvement
archmoj Jan 3, 2019
d775525
fix timeout
archmoj Jan 3, 2019
2d9cfce
prototype for volume data
archmoj Jan 3, 2019
996d0b4
translate opacity to mesh
archmoj Jan 4, 2019
4c88b47
fixed opacity calc
archmoj Jan 10, 2019
296b636
bring in section functions
archmoj Jan 10, 2019
34ebfb1
new tri function
archmoj Jan 10, 2019
ddda735
removed old tri function
archmoj Jan 10, 2019
b6ec3ab
groups & sections
archmoj Jan 10, 2019
1ab207f
slices and only draw crossing try
archmoj Jan 10, 2019
c32cfee
added new functions
archmoj Jan 11, 2019
ae220b7
added a recursive solver
archmoj Jan 11, 2019
5e28df3
put the iso-surface mock back
archmoj Jan 11, 2019
1b582cf
fixup
archmoj Jan 11, 2019
57e937f
fixed few more things
archmoj Jan 11, 2019
9bd799e
transparent baseline
archmoj Jan 12, 2019
a26f3b5
progress...
archmoj Jan 12, 2019
722a6f3
plus plus
archmoj Jan 12, 2019
d44dca0
refactor
archmoj Jan 12, 2019
29de897
simplified and more functional
archmoj Jan 12, 2019
4cee4a9
defined new control attributes
archmoj Jan 13, 2019
6b227ee
new baseline with transparency and new attributes
archmoj Jan 13, 2019
c9597ea
separated isosurface volume and cap opacity values
archmoj Jan 13, 2019
a0593a4
various improvements: opacity > fill, etc.
archmoj Jan 13, 2019
784bde4
added slicing types
archmoj Jan 13, 2019
2015d3c
added edit types for fill attributes
archmoj Jan 13, 2019
deedc91
display minimal volume based on tetras
archmoj Jan 13, 2019
e9f48ba
updated baseline with minimal volume lines
archmoj Jan 13, 2019
3e387a2
easy control over caps slices iso-surfaces and volume elements
archmoj Jan 14, 2019
8b77ca6
revised grouping etc.
archmoj Jan 14, 2019
ba0c476
revised attributes
archmoj Jan 14, 2019
c7694fd
minor fixes
archmoj Jan 14, 2019
d33e47b
forEach tables > simple for
archmoj Jan 14, 2019
f34004f
Revert "forEach tables > simple for"
archmoj Jan 14, 2019
2c0d40f
orders
archmoj Jan 14, 2019
7b5e927
added second mock
archmoj Jan 14, 2019
8ac7688
edit mocks and editType
archmoj Jan 14, 2019
e69337f
Merge remote-tracking branch 'origin/master' into isosurface-volume
archmoj Jan 14, 2019
f7340f1
applied gl3d reversescale fixup PR 3418 to resolve conflict from the …
archmoj Jan 14, 2019
e4c86dd
added new baseline
archmoj Jan 14, 2019
2ea382f
updated baseline
archmoj Jan 14, 2019
e3271c7
edge cases
archmoj Jan 14, 2019
de800c0
fixed slice and rect draw
archmoj Jan 14, 2019
0bddc23
major fixup for isosurfaces when isomin is close to isomax
archmoj Jan 14, 2019
da66c2c
opacity > fill etc.
archmoj Jan 15, 2019
03660f6
solving cap edges with recursive draws
archmoj Jan 15, 2019
814b5b0
revised vertex indexing
archmoj Jan 15, 2019
816044d
updated iso-surface baselines
archmoj Jan 15, 2019
7a58fc0
apply the third power in mock z-axis and using reverscale true
archmoj Jan 15, 2019
fae95e8
new baseline to lock reversescale gl3d issue
archmoj Jan 15, 2019
236bb3e
hover display
archmoj Jan 15, 2019
3876831
edit before fixing caps
archmoj Jan 15, 2019
df82f92
caps getting better
archmoj Jan 15, 2019
05ca035
pass min max to the functions
archmoj Jan 15, 2019
26b2969
improved caps creation and more
archmoj Jan 15, 2019
d7a59d9
fixes pass 1
archmoj Jan 15, 2019
3106130
fixed second pass cap interpolation added mock and removed min max fu…
archmoj Jan 16, 2019
cb0ee0a
new baseline
archmoj Jan 16, 2019
6f6b578
removed ref to width height and depth attributes
archmoj Jan 16, 2019
180350c
Merge remote-tracking branch 'origin/master' into isosurface-volume
archmoj Jan 16, 2019
a90227c
improved lighting and surface material for mocks
archmoj Jan 16, 2019
8cfe2a7
correct baselines using new gl-mesh3d lighting
archmoj Jan 16, 2019
54f400c
added a new mock with a log axis and horizontal slices
archmoj Jan 16, 2019
4f03deb
added new baseline
archmoj Jan 16, 2019
5b00901
mocks with hover and different aspect ratio
archmoj Jan 16, 2019
f32731b
corrected baseline now using different scene aspect ratio
archmoj Jan 16, 2019
a525261
improved cap ceration for tiny cases
archmoj Jan 17, 2019
c46eced
new mock for thin caps and different width X height X depths
archmoj Jan 17, 2019
46aaad3
new baselines with new algo for caps and sections
archmoj Jan 17, 2019
935e155
new baseline with improved caps algo
archmoj Jan 17, 2019
98a2c09
debug > style now could pass as first argument to every draw function
archmoj Jan 17, 2019
3b1e94d
volume > brace and slices at desired locations
archmoj Jan 17, 2019
07eefa7
new baseline showing slices on desired locations
archmoj Jan 17, 2019
5c0907e
fix and test mock for edge case scenario mentioned by Etienne on PR 2752
archmoj Jan 17, 2019
e389106
new baseline to lock out of iso-range case
archmoj Jan 17, 2019
e8aca82
added 4th dimension to the hover and removed vertices when no face cr…
archmoj Jan 17, 2019
c0def68
fixed syntax
archmoj Jan 17, 2019
cd291b3
applied to precision 6 for value on hover
archmoj Jan 17, 2019
4a6462e
fixes and added surface pattern option and mock
archmoj Jan 18, 2019
e5c645b
added new baseline for pattern option
archmoj Jan 18, 2019
c2dd4d8
fixed pattern styling check
archmoj Jan 18, 2019
2a7062c
added checker pattern options too
archmoj Jan 18, 2019
ceab6af
added a mock to display the usecase of volume braces and iso-surface …
archmoj Jan 18, 2019
29bebd0
baseline to display the usecase of volume braces and iso-surface chec…
archmoj Jan 18, 2019
52c2faa
brace > spaceframe
archmoj Jan 18, 2019
99fdb28
refactor to have more functional main program - added the option to c…
archmoj Jan 18, 2019
16ab1a1
baseline with multiple iso-surface sentions
archmoj Jan 18, 2019
e0a2845
fixed single surface case and mock order
archmoj Jan 18, 2019
07708c3
added new baseline for single iso-surface 3d section
archmoj Jan 18, 2019
06e8c09
correct baseline title
archmoj Jan 18, 2019
bae7b56
fix isomin > isomax case by setting to defaults
archmoj Jan 18, 2019
ea34a2d
added jasmine tests for defaults and restyle only
archmoj Jan 18, 2019
e575082
fill descriptions
archmoj Jan 18, 2019
a7373a3
added a note for slice locations
archmoj Jan 18, 2019
31fb0b7
overrideAll calcs
archmoj Jan 18, 2019
4aa489f
reusing mesh3d lighting attributes
archmoj Jan 18, 2019
392fdd6
using mockAxis
archmoj Jan 18, 2019
28fbc25
removed toPrecision
archmoj Jan 18, 2019
324e69b
fixed jasmine default sync calls
archmoj Jan 18, 2019
bc48eea
checker > check
archmoj Jan 20, 2019
6d61e43
revised few function names
archmoj Jan 20, 2019
40c7fb6
improved log mock
archmoj Jan 20, 2019
94b4f5e
reduced num lines
archmoj Jan 20, 2019
436c0d9
now can interpolate for slices on locations between two axis points
archmoj Jan 20, 2019
4b21f13
fixed a typo and updated the baseline
archmoj Jan 20, 2019
0c346aa
fix noting that ceil is applied not floor
archmoj Jan 20, 2019
a9bf42c
updated log baseline to lock horizontal and vertical slicings between…
archmoj Jan 20, 2019
e6e8070
added a check to not allow ceil id to be 0
archmoj Jan 21, 2019
b55854e
fixed hover and added jasmine test for hover
archmoj Jan 21, 2019
05f3c0d
added noCI flag for hover test i.e. similar to streamtube
archmoj Jan 21, 2019
eb0fb94
improved patterns
archmoj Jan 21, 2019
722bade
baseline showing an example of improved triangular patterns
archmoj Jan 21, 2019
9ec9f06
used flaglist also check1 > odd and check2 > even
archmoj Jan 21, 2019
13c313b
added new mock and fixed gl defaults in jasmine test files
archmoj Jan 21, 2019
1089724
added baseline for new mock
archmoj Jan 21, 2019
c66a2bb
one big change for the API
archmoj Jan 21, 2019
bc8334b
applied distinctVals
archmoj Jan 21, 2019
d82f091
description edit - fixed hover - simplified again finding nearest on …
archmoj Jan 21, 2019
ea8dccd
fix react-noop test
etpinard Jan 21, 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-2019, 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');
25 changes: 24 additions & 1 deletion src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ function render(scene) {
}

var tx;
var vectorTx = [];

if(trace.type === 'cone' || trace.type === 'streamtube') {
var vectorTx = [];
if(isHoverinfoAll || hoverinfoParts.indexOf('u') !== -1) {
vectorTx.push('u: ' + formatter('xaxis', selection.traceCoordinate[3]));
}
Expand All @@ -110,6 +110,12 @@ function render(scene) {
vectorTx.push(selection.textLabel);
}
tx = vectorTx.join('<br>');
} else if(trace.type === 'isosurface') {
vectorTx.push('value: ' + Axes.tickText(scene.mockAxis, scene.mockAxis.d2l(selection.traceCoordinate[3]), 'hover').text);
if(selection.textLabel) {
vectorTx.push(selection.textLabel);
}
tx = vectorTx.join('<br>');
} else {
tx = selection.textLabel;
}
Expand Down Expand Up @@ -271,6 +277,8 @@ function initializeGLPlot(scene, canvas, gl) {
// List of scene objects
scene.traces = {};

scene.make4thDimension();

return true;
}

Expand Down Expand Up @@ -855,4 +863,19 @@ proto.setConvert = function() {
}
};

proto.make4thDimension = function() {

var _this = this;
var gd = _this.graphDiv;
var fullLayout = gd._fullLayout;

// mock axis for hover formatting
_this.mockAxis = {
type: 'linear',
showexponent: 'all',
exponentformat: 'B'
};
Axes.setConvert(_this.mockAxis, fullLayout);
};

module.exports = Scene;
273 changes: 273 additions & 0 deletions src/traces/isosurface/attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
/**
* Copyright 2012-2019, 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 meshAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

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

function makeSliceAttr(axLetter) {
return {
show: {
etpinard marked this conversation as resolved.
Show resolved Hide resolved
valType: 'boolean',
role: 'info',
dflt: false,
description: [
'Determines whether or not slice planes about the', axLetter,
'dimension are drawn.'
].join(' ')
},
locations: {
valType: 'data_array',
dflt: [],
role: 'info',
description: [
'Specifies the location(s) of slices on the axis.',
'When not locations specified slices would be created for',
'all points of the axis', axLetter, 'except start and end.'
].join(' ')
},
fill: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 1,
description: [
'Sets the fill ratio of the `slices`. The default fill value of the',
'`slices` is 1 meaning that they are entirely shaded. On the other hand',
'Applying a `fill` ratio less than one would allow the creation of',
'openings parallel to the edges.'
].join(' ')
}
};
}

function makeCapAttr(axLetter) {
return {
show: {
valType: 'boolean',
role: 'info',
dflt: true,
description: [
'Sets the fill ratio of the `slices`. The default fill value of the', axLetter,
'`slices` is 1 meaning that they are entirely shaded. On the other hand',
'Applying a `fill` ratio less than one would allow the creation of',
'openings parallel to the edges.'
].join(' ')
},
fill: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 1,
description: [
'Sets the fill ratio of the `caps`. The default fill value of the',
'`caps` is 1 meaning that they are entirely shaded. On the other hand',
'Applying a `fill` ratio less than one would allow the creation of',
'openings parallel to the edges.'
].join(' ')
}
};
}

var attrs = module.exports = overrideAll(extendFlat({
x: {
valType: 'data_array',
role: 'info',
description: [
'Sets the X coordinates of the vertices on X axis.'
].join(' ')
},
y: {
valType: 'data_array',
role: 'info',
description: [
'Sets the Y coordinates of the vertices on Y axis.'
].join(' ')
},
z: {
valType: 'data_array',
role: 'info',
description: [
'Sets the Z coordinates of the vertices on Z axis.'
].join(' ')
},
value: {
valType: 'data_array',
role: 'info',
description: [
'Sets the 4th dimension of the vertices. It should be',
'one dimensional array containing n=X.length*Y.length*Z.length numbers.'
].join(' ')
},
isomin: {
valType: 'number',
role: 'info',
description: [
'Sets the minimum boundary for iso-surface plot.'
].join(' ')
},
isomax: {
valType: 'number',
role: 'info',
description: [
'Sets the maximum boundary for iso-surface plot.'
].join(' ')
},

surface: {
show: {
etpinard marked this conversation as resolved.
Show resolved Hide resolved
valType: 'boolean',
role: 'info',
dflt: true,
description: [
'Hides/displays surfaces between minimum and maximum iso-values.'
].join(' ')
},
count: {
valType: 'integer',
role: 'info',
dflt: 2,
min: 1,
description: [
'Sets the number of iso-surfaces between minimum and maximum iso-values.',
'By default this value is 2 meaning that only minimum and maximum surfaces',
'would be drawn.'
].join(' ')
},
fill: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 1,
description: [
'Sets the fill ratio of the iso-surface. The default fill value of the',
'surface is 1 meaning that they are entirely shaded. On the other hand',
'Applying a `fill` ratio less than one would allow the creation of',
'openings parallel to the edges.'
].join(' ')
},
pattern: {
valType: 'flaglist',
flags: ['A', 'B', 'C', 'D', 'E'],
extras: ['all', 'odd', 'even'],
dflt: 'all',
role: 'style',
description: [
'Sets the surface pattern of the iso-surface 3-D sections. The default pattern of',
'the surface is `all` meaning that the rest of surface elements would be shaded.',
'The check options (either 1 or 2) could be used to draw half of the squares',
'on the surface. Using various combinations of capital `A`, `B`, `C`, `D` and `E`',
'may also be used to reduce the number of triangles on the iso-surfaces and',
'creating other patterns of interest.'
].join(' ')
}
},

spaceframe: {
show: {
valType: 'boolean',
role: 'info',
dflt: false,
description: [
'Displays/hides tetrahedron shapes between minimum and',
'maximum iso-values. Often useful when either caps or',
'surfaces are disabled or filled with values less than 1.'
].join(' ')
},
fill: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 0.15,
description: [
'Sets the fill ratio of the `spaceframe` elements. The default fill value',
'is 0.15 meaning that only 15% of the area of every faces of tetras would be',
'shaded. Applying a greater `fill` ratio would allow the creation of stronger',
'elements or could be sued to have entirely closed areas (in case of using 1).'
].join(' ')
}
},

slices: {
x: makeSliceAttr('x'),
y: makeSliceAttr('y'),
z: makeSliceAttr('z')
},

caps: {
x: makeCapAttr('x'),
y: makeCapAttr('y'),
z: makeCapAttr('z')
},

text: {
valType: 'string',
role: 'info',
dflt: '',
arrayOk: true,
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(' ')
},
},

colorscaleAttrs('', {
colorAttr: '`value`',
showScaleDflt: true,
editTypeOverride: 'calc'
}), {

colorbar: colorbarAttrs,

// Flat shaded mode
flatshading: {
valType: 'boolean',
role: 'style',
dflt: false,
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: {
show: extendFlat({}, surfaceAtts.contours.x.show, {
description: [
'Sets whether or not dynamic contours are shown on hover.',
'Contours are more useful when hovering on caps and slices.'
].join(' ')
}),
color: surfaceAtts.contours.x.color,
width: surfaceAtts.contours.x.width
},

lightposition: {
x: extendFlat({}, surfaceAtts.lightposition.x, {dflt: 1e5}),
y: extendFlat({}, surfaceAtts.lightposition.y, {dflt: 1e5}),
z: extendFlat({}, surfaceAtts.lightposition.z, {dflt: 0})
},
lighting: meshAttrs.lighting,

hoverinfo: extendFlat({}, baseAttrs.hoverinfo)
}), 'calc', 'nested');

attrs.x.editType = attrs.y.editType = attrs.z.editType = attrs.value.editType = 'calc+clearAxisTypes';
attrs.transforms = undefined;
35 changes: 35 additions & 0 deletions src/traces/isosurface/calc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright 2012-2019, 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 min = Infinity;
var max = -Infinity;
var len = trace.value.length;
for(var i = 0; i < len; i++) {
var v = trace.value[i];
min = Math.min(min, v);
max = Math.max(max, v);
}

trace._minValues = min;
trace._maxValues = max;

trace._vMin = (trace.isomin === undefined || trace.isomin === null) ? min : trace.isomin;
trace._vMax = (trace.isomax === undefined || trace.isomin === null) ? max : trace.isomax;

colorscaleCalc(gd, trace, {
vals: [trace._vMin, trace._vMax],
containerStr: '',
cLetter: 'c'
});
};
Loading