Skip to content

Commit 1da4055

Browse files
committed
corrections following second CoPilot review
1 parent 8c063cf commit 1da4055

6 files changed

Lines changed: 48 additions & 17 deletions

File tree

src/tools_lgpl/matlab/quickplot/progsrc/private/int_lntri.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@
191191
if all(noNeighborDefined)
192192
% no intersections with points or lines at all
193193
% search triangle for one point
194-
[Ti,p] = tsearch_safe(xyMesh,TRI,xi(1),yi(1));
194+
[Ti,p] = tsearch_safe(xyMesh,TRI,xIntersect(1),yIntersect(1));
195195
if ~isnan(Ti) % inside a mesh face
196196
triSegment(:) = Ti;
197197
weightsIntersect(1,:) = p;
198198
nodesIntersect(1,:) = TRI(Ti,:);
199199
for i = 2:nIntersections
200-
[~,p] = tsearch_safe(xyMesh,TRI(Ti,:),xi(1),yi(1));
200+
[~,p] = tsearch_safe(xyMesh,TRI(Ti,:),xIntersect(i),yIntersect(i));
201201
weightsIntersect(i,:) = p;
202202
nodesIntersect(i,:) = TRI(Ti,:);
203203
end

src/tools_lgpl/matlab/quickplot/progsrc/private/md_print.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,12 @@
422422

423423
% Apply BlackAxesWhiteFig unless we're saving the figure meta data
424424
ih = get(fig,'inverthardcopy');
425-
set(fig,'inverthardcopy','off')
426425
colorChange = cell(0,3);
427426
switch printObj.Name
428427
case {'MATLAB fig file','QUICKPLOT session file'}
429428
% in this case we want to save the figure as is
430429
otherwise
430+
set(fig,'inverthardcopy','off')
431431
if isfield(printObj,'BlackAxesWhiteFig') && printObj.BlackAxesWhiteFig
432432
% support for "inverthardcopy" was dropped in MATLAB 2025a
433433
colorChange = cell(100,3);

src/tools_lgpl/matlab/quickplot/progsrc/private/qp_time2str.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@
5959
else
6060
datefmt = 'dd-MMM-yyyy G HH:mm:ss';
6161
end
62-
Date = datetime(timeValue,'ConvertFrom','datenum');
63-
timeString = char(Date,datefmt);
62+
try
63+
Date = datetime(timeValue,'ConvertFrom','datenum');
64+
timeString = char(Date,datefmt);
65+
catch % older than version 2014b
66+
timeString = datestr(timeValue,0);
67+
end
6468
case {3,4} % day h:m:s
6569
% 3: discrete, 4: continuous
6670
timeString=cat(2,repmat('day ',nTimes,1),num2str(floor(timeValue)), ...

src/tools_lgpl/matlab/quickplot/progsrc/private/tecplot.m

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,25 @@
232232
end
233233
end
234234

235+
function [int_values,file] = get_int_list(file,nValues)
236+
int_values = zeros(1,nValues);
237+
i = 0;
238+
if nValues == 0
239+
readFromCurrentLineOnly = true;
240+
else
241+
readFromCurrentLineOnly = false;
242+
end
243+
while i < nValues || readFromCurrentLineOnly
244+
i = i+1;
245+
try
246+
[int_values(i),file] = get_int(file, readFromCurrentLineOnly);
247+
catch err
248+
if readFromCurrentLineOnly
249+
break
250+
end
251+
end
252+
end
253+
235254
function FI=open_ascii(FI,file)
236255
zone_found = false;
237256
in_record = 'HEADER';
@@ -511,9 +530,9 @@
511530
nVar = length(FI.Variables);
512531
%
513532
if strcmpi(Zone.Type,'ORDERED')
514-
if isfield(Zone,'kMax') % 3D
533+
if isfield(Zone,'KMax') % 3D
515534
blockSize = [Zone.IMax Zone.JMax Zone.KMax];
516-
elseif isfield(Zone,'jMax') % 2D
535+
elseif isfield(Zone,'JMax') % 2D
517536
blockSize = [Zone.IMax Zone.JMax];
518537
else % 1D
519538
blockSize = Zone.IMax;
@@ -543,7 +562,7 @@
543562
FI.Zone(z).Data = data;
544563
%
545564
if ~strcmpi(Zone.Type,'ORDERED')
546-
if isfield(Zone,'elementSize') && ~isempty(Zone.ElementSize)
565+
if isfield(Zone,'ElementSize') && ~isempty(Zone.ElementSize)
547566
blockSize = [Zone.ElementSize FI.Zone(z).NElements];
548567
[topo,nRead] = fscanf(file.fid,'%i',prod(blockSize));
549568
if nRead < prod(blockSize)
@@ -609,6 +628,7 @@
609628
value = value * 10^exponent;
610629
end
611630
newData = cat(1,newData(1:end-1),repmat(value,newData(end),1));
631+
nRead = length(newData);
612632

613633
otherwise
614634
if nTotalRead+nRead < numValues

src/tools_lgpl/matlab/quickplot/progsrc/private/tecplotfil.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@
162162
Out=cell2struct(DataProps,PropNames,2);
163163

164164
if strcmpi(Zone.Type,'ORDERED')
165-
if isfield(Zone,'iMax')
165+
if isfield(Zone,'IMax')
166166
Out.DimFlag(M_) = 1;
167167
end
168-
if isfield(Zone,'jMax')
168+
if isfield(Zone,'JMax')
169169
Out.DimFlag(N_) = 1;
170170
end
171-
if isfield(Zone,'kMax')
171+
if isfield(Zone,'KMax')
172172
Out.DimFlag(K_) = 1;
173173
end
174174
else

src/tools_lgpl/matlab/quickplot/progsrc/qp_gridview.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,19 @@
133133
XY(j,2) = Y(MN(1),MN(2));
134134
for i = 2:size(GRID.Selected.Range,1)
135135
dMN = GRID.Selected.Range(i,:) - MN;
136-
sMN = sign(dMN);
137-
for d = 1:max(abs(dMN))
138-
MN = MN + sMN;
139-
j = j + 1;
140-
XY(j,1) = X(MN(1),MN(2));
141-
XY(j,2) = Y(MN(1),MN(2));
136+
% follow Bresenham-style stepping in case
137+
% abs(dMN(1)) ~= abs(dMN(2))
138+
% which should never be the case.
139+
nSteps = max(abs(dMN));
140+
if nSteps > 0
141+
steps = (1:nSteps)';
142+
pathMN = round(repmat(MN,nSteps,1) + steps*(dMN/nSteps));
143+
for d = 1:nSteps
144+
MN = pathMN(d,:);
145+
j = j + 1;
146+
XY(j,1) = X(MN(1),MN(2));
147+
XY(j,2) = Y(MN(1),MN(2));
148+
end
142149
end
143150
end
144151
case 'ugrid'

0 commit comments

Comments
 (0)