-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: draft high-level plotting function as described in [#10]
- Loading branch information
Showing
1 changed file
with
23 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |