Skip to content

add quality and zmin parameter to improve elapsed time working with steamtube function #364

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion plotly/plotly_aux/plotly.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
%
% For full documentation and examples, see https://plot.ly/api
origin = 'plot';
offline = true;
offline = false;
struct_provided = false;

if isstruct(varargin{end})
Expand Down
8 changes: 8 additions & 0 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
obj.PlotOptions.AspectRatio = [];
obj.PlotOptions.CameraEye = [];
obj.PlotOptions.is_headmap_axis = false;
obj.PlotOptions.Quality = -1;
obj.PlotOptions.Zmin = [];

% offline options
obj.PlotOptions.Offline = true;
Expand Down Expand Up @@ -224,6 +226,12 @@
if(strcmpi(varargin{a},'CameraEye'))
obj.PlotOptions.CameraEye = varargin{a+1};
end
if(strcmpi(varargin{a},'Quality'))
obj.PlotOptions.Quality = varargin{a+1};
end
if(strcmpi(varargin{a},'Zmin'))
obj.PlotOptions.Zmin = varargin{a+1};
end
end
end

Expand Down
100 changes: 85 additions & 15 deletions plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function obj = updateStreamtube(obj, surfaceIndex)
if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface')
if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface')
updateSurfaceStreamtube(obj, surfaceIndex)
end
end
end

function updateSurfaceStreamtube(obj, surfaceIndex)
Expand Down Expand Up @@ -38,28 +38,45 @@ function updateSurfaceStreamtube(obj, surfaceIndex)

%---------------------------------------------------------------------%

%-format x an y data-%
ymax = 100;
%-getting plot data-%
x = image_data.XData;
y = image_data.YData;
z = image_data.ZData;
cdata = image_data.CData;

ysize = size(x,1);
xsize = size(x,2);
%-playing with level quality-%
quality = obj.PlotOptions.Quality/100;
apply_quality = quality > 0;

if ysize > ymax
ystep = round(ysize/ymax);
x = x(1:ystep:end, :);
y = y(1:ystep:end, :);
z = z(1:ystep:end, :);
cdata = cdata(1:ystep:end, :);
end
if apply_quality
x = imresize(x, quality);
y = imresize(y, quality);
z = imresize(z, quality);
cdata = imresize(cdata, quality);
end

if isvector(x)
[x, y] = meshgrid(x,y);
if ~isempty(obj.PlotOptions.Zmin)
if any(z < obj.PlotOptions.Zmin)
return;
end
end

xymax = 100;
xsize = size(x,2);
ysize = size(x,1);

xsize = min([xsize, xymax]);
ysize = min([ysize, xymax]);
x = imresize(x, [ysize, xsize]);
y = imresize(y, [ysize, xsize]);
z = imresize(z, [ysize, xsize]);
cdata = imresize(cdata, [ysize, xsize]);

%-optional-%
% if isvector(x)
% [x, y] = meshgrid(x,y);
% end

%---------------------------------------------------------------------%

%-surface x-%
Expand Down Expand Up @@ -105,6 +122,59 @@ function updateSurfaceStreamtube(obj, surfaceIndex)
obj.data{surfaceIndex}.contours.y.show = true;
obj.data{surfaceIndex}.contours.y.color = 'black';

%------------------------------------------------------------------------%

%-get data-%

%-aspect ratio-%
ar = obj.PlotOptions.AspectRatio;

if ~isempty(ar)
if ischar(ar)
scene.aspectmode = ar;
elseif isvector(ar) && length(ar) == 3
xar = ar(1);
yar = ar(2);
zar = ar(3);
end
else

%-define as default-%
xar = 0.5*max(x(:));
yar = 0.5*max(y(:));
zar = 0.4*max([xar, yar]);
end

scene.aspectratio.x = xar;
scene.aspectratio.y = yar;
scene.aspectratio.z = zar;

%---------------------------------------------------------------------%

%-camera eye-%
ey = obj.PlotOptions.CameraEye;

if ~isempty(ey)
if isvector(ey) && length(ey) == 3
scene.camera.eye.x = ey(1);
scene.camera.eye.y = ey(2);
scene.camera.eye.z = ey(3);
end
else

%-define as default-%
fac = 0.35;
xey = - xar; if xey>0 xfac = -fac; else xfac = fac; end
yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end
if zar>0 zfac = fac; else zfac = -fac; end

scene.camera.eye.x = xey + xfac*xey;
scene.camera.eye.y = yey + yfac*yey;
scene.camera.eye.z = zar + zfac*zar;
end

obj.layout = setfield(obj.layout,['scene'], scene);

%-------------------------------------------------------------------------%

%-image colorscale-%
Expand Down