Skip to content

Commit

Permalink
Refactor: draft high-level plotting function as described in [#10]
Browse files Browse the repository at this point in the history
  • Loading branch information
pausz committed Jun 19, 2020
1 parent 9271aab commit fc101eb
Showing 1 changed file with 23 additions and 41 deletions.
64 changes: 23 additions & 41 deletions visualisation/plot3d_streamparticles.m
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
function fig_handle = plot3d_streamparticles(params)
% Set info we need
%these_frames = params.stremalines.visualisation.particles.frames;
these_frames = [10];

% Load file handles
obj_flows = load_iomat_flows(params);
obj_streams = load_iomat_streams(params);

% Load info we need for visualisation
xyz_lims = obj_flows.xyz_lims;

for ff=1:length(these_frames)
stream_verts = get_verts(these_frames(ff));
fig_handle{ff} = figure('Name', 'nflows-flows-streamparticles')
axs_handle{ff} = p3_streamparticles(fig_handle, verts, xyz_lims)
end

function verts = get_verts(idx)
tmp = obj_streams.streamlines(1, idx);
verts = tmp.paths;
verts = make_streams_uniform(verts);
end % get_verts()

% Remove nan vertices from streamlines (points outside the convex hull)
verts = cellfun(@remove_nans, verts, 'UniformOutput', false);
% Make all streamlines of the same length so we can use streamparticles
stream_lengths = cellfun(@(c) size(c, 1), verts);
max_length = max(stream_lengths);
wrap_func = @(verts) add_vertices(verts, max_length);
verts = cellfun(wrap_func, dummy_cell, 'UniformOutput', false);

%verts = cellfun(@add_vertices, verts, 'UniformOutput', false);

sl = streamline(verts);
set(sl,'LineWidth',1);
set(sl,'Color',[0.5 0.5 0.5 0.5]);
%set(sl,'Visible','off');
% interpolated vertices
%iverts = interpstreamspeed(X, Y, Z, mfile_vel.ux(:, :, :, tt), ...
% mfile_vel.uy(:, :, :, tt), ....
% mfile_vel.uz(:, :, :, tt), verts,.5);
%
%axis tight; view(30,30);
haxes = gca;
%haxes.SortMethod = 'ChildOrder';
%camproj perspective; box on
%camva(44); camlookat; camdolly(0,0,.4, 'f');
%h = line;
haxes.XLim = [min(X(:)), max(X(:))];
haxes.YLim = [min(Y(:)), max(Y(:))];

haxes.ZLim = [min(Z(:)), max(Z(:))];

streamparticles(haxes, verts, 42, 'animate', Inf, 'ParticleAlignment', 'on', 'MarkerfaceColor', 'blue');

displaynow


end
end % function plot3d_streamparticles()


function x = remove_nans(x)
% Dummy function to be call by cellfun
x(isnan(x)) = [];

end

0 comments on commit fc101eb

Please sign in to comment.