-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a28a79a
commit 3ce1590
Showing
32 changed files
with
5,158 additions
and
4,700 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function tNew = addtrirep(varargin) | ||
%ADDTRIREP creates a new TriRep that contains tA and tB. | ||
% Usage: | ||
% tNew = addtrirep(tA, tB, tC ....) | ||
% tNew = addtrirep({tA, tB, tC ...}) | ||
% Where: | ||
% tA,tB etc are TriRep | ||
% | ||
% ADDTRIREP creates a new TriRep that contains tA and tB. | ||
% | ||
% Author: Nick Linton (2011) | ||
% Modifications - | ||
|
||
if nargin == 1 | ||
tCell = varargin{1}; | ||
else | ||
tCell = varargin; | ||
end | ||
|
||
nV = 0; | ||
nT = 0; | ||
for i = 1:length(tCell) | ||
if ~isa(tCell{i},'TriRep') | ||
error('ADDTRIREP: the input must be TriRep objects or a cell array of TriRep objects.') | ||
end | ||
nV = nV + size(tCell{i}.X,1); | ||
nT = nT + size(tCell{i}.Triangulation,1); | ||
end | ||
|
||
newT = zeros(nT,3); | ||
newX = zeros(nV,3); | ||
|
||
currentV = 1; | ||
currentT = 1; | ||
for i = 1:length(tCell) | ||
if ~isa(tCell{i},'TriRep') | ||
error('ADDTRIREP: the input must be TriRep objects or a cell array of TriRep objects.') | ||
end | ||
nV = size(tCell{i}.X,1); | ||
nT = size(tCell{i}.Triangulation,1); | ||
newX(currentV:(currentV+nV-1),:) = tCell{i}.X; | ||
newT(currentT:(currentT+nT-1),:) = tCell{i}.Triangulation + currentV-1; | ||
currentV = currentV+nV; | ||
currentT = currentT+nT; | ||
end | ||
|
||
tNew = TriRep(newT, newX); | ||
|
||
end | ||
|
||
|
||
|
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function rgb = colorBrewer(name) | ||
% COLORBREWER Returns RGB data for the nice colors | ||
% | ||
% Usage: | ||
% rgb = colorBrewer(name) | ||
% Where: | ||
% name - is 'r'|'g'|'b'|'p'|'o'|'y' | ||
% rgb - is the RGB colorspec | ||
% | ||
% COLORBREWER See http://colorbrewer2.org/ | ||
% | ||
% Author: Steven Williams (2014) | ||
% Modifications - | ||
% | ||
% Info on Code Testing: | ||
% --------------------------------------------------------------- | ||
% test code | ||
% --------------------------------------------------------------- | ||
% | ||
% --------------------------------------------------------------- | ||
% code | ||
% --------------------------------------------------------------- | ||
|
||
if isnumeric(name) | ||
if name==1 | ||
rgb = [228 26 28]/256; | ||
elseif name==2 | ||
rgb = [55 126 184]/256; | ||
elseif name==3 | ||
rgb = [77 175 74]/256; | ||
elseif name==4 | ||
rgb = [152 78 163]/256; | ||
elseif name==5 | ||
rgb = [255 127 0]/256; | ||
elseif name==6 | ||
rgb = [255 255 51]/256; | ||
elseif name==7 | ||
rgb = [166 86 40]/256; | ||
elseif name==8 | ||
rgb = [247 129 191]/256; | ||
elseif name==9 | ||
rgb = [153 153 153]/256; | ||
end | ||
else | ||
switch name | ||
case 'r' | ||
rgb = [228 26 28]/256; | ||
case 'g' | ||
rgb = [77 175 74]/256; | ||
case 'b' | ||
rgb = [55 126 184]/256; | ||
case 'p' | ||
rgb = [152 78 163]/256; | ||
case 'o' | ||
rgb = [255 127 0]/256; | ||
case 'y' | ||
rgb = [255 255 51]/256; | ||
case 'g1' | ||
rgb = [27 158 119]/256; | ||
case 'o1' | ||
rgb = [217 95 2]/256; | ||
case 'p1' | ||
rgb = [117 112 179]/256; | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function deleteFolder( folderPath, varargin ) | ||
% DELETEFOLDER Deletes the folder folderPath | ||
% | ||
% Usage: | ||
% deleteFolder( folderPath ) | ||
% Where: | ||
% folderPath - the full path to the folder | ||
% | ||
% DELETEFOLDER Detailed description goes here | ||
% | ||
% DELETEFOLDER accepts the following parameter-value pairs | ||
% 'verbose' {false}|true | ||
% | ||
% Author: Steven Williams (2020) | ||
% Modifications - | ||
% | ||
% Info on Code Testing: | ||
% --------------------------------------------------------------- | ||
% test code | ||
% --------------------------------------------------------------- | ||
% | ||
% --------------------------------------------------------------- | ||
% code | ||
% --------------------------------------------------------------- | ||
|
||
% Parse input | ||
nStandardArgs = 1; % UPDATE VALUE | ||
verbose = false; | ||
if nargin > nStandardArgs | ||
for i = nStandardArgs+1:2:nargin | ||
switch varargin{i} | ||
case 'verbose' | ||
verbose = varargin{i+1}; | ||
end | ||
end | ||
end | ||
|
||
% Check to make sure that folder actually exists. Warn user if it doesn't. | ||
if ~isdir(folderPath) | ||
error('DELETEFOLDER: Specified path does not exist') | ||
return; | ||
end | ||
|
||
% Get a list of all files in the folder with the desired file name pattern. | ||
theFiles = nameFiles(folderPath); | ||
|
||
% Delete each file one by one | ||
for k = 1 : length(theFiles) | ||
fullFileName = fullfile(folderPath, theFiles{k}); | ||
if verbose | ||
fprintf(1, 'Now deleting %s\n', fullFileName); | ||
end | ||
delete(fullFileName); | ||
end | ||
|
||
% Remove the directory | ||
rmdir(folderPath) | ||
|
||
end |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function cmdout = du( argument ) | ||
% DU is a wrapper function for the Unix file system tool du | ||
% | ||
% Usage: | ||
% cmdout = du(argument) | ||
% Where: | ||
% argument - is the input provided to do | ||
% cmdout - is the information returned by du in a string | ||
% | ||
% DU Detailed description goes here | ||
% | ||
% Author: Steven Williams (2020) | ||
% Modifications - | ||
% | ||
% Info on Code Testing: | ||
% --------------------------------------------------------------- | ||
% test code | ||
% --------------------------------------------------------------- | ||
% | ||
% --------------------------------------------------------------- | ||
% code | ||
% --------------------------------------------------------------- | ||
|
||
%create the system call | ||
arg = ['du ' argument]; | ||
|
||
%system call | ||
[status, cmdout] = system(arg); | ||
|
||
%remove the carriage return from the end of cmdout | ||
cmdout(end) = []; | ||
|
||
end |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
function [tr2, isVertUsed] = editTriangulation(tr) | ||
% EDITTRIANGULATION Graphically remove triangles from a TriRep object | ||
% | ||
% Usage: | ||
% tr2 = editTriangulation(tr) | ||
% Where: | ||
% tr - is the original triangulation | ||
% tr2 - is the new triangulation with elements removed | ||
% isVertUsed - indexes into tr.X for vertices that are used in the new | ||
% triangulation, tr2 | ||
% | ||
% EDITTRIANGULATION uses GET3DFACES to remove triangles from a TriRep | ||
% object. Controls: | ||
% Left click - select triangles to remove | ||
% Shift-Left click - select triangles to keep | ||
% Ctrl-Left click - select area up to the boundary | ||
% d - done | ||
% | ||
% Author: Steven Williams (2013) | ||
% Modifications - | ||
% 2016 - refactored by moving userdata manipulation into a separate fcn | ||
% | ||
% Info on Code Testing: | ||
% --------------------- | ||
% | ||
% --------------------- | ||
% | ||
% --------------------------------------------------------------- | ||
% code | ||
% --------------------------------------------------------------- | ||
|
||
% Edit to remove the valve orifice | ||
disp('E D I T T R I A N G U L A T I O N'); | ||
disp('-----------------------------------'); | ||
disp('Left click - select triangles to remove (shift to undo)'); | ||
disp('Cltr-left - select area'); | ||
disp('Press d when done'); | ||
disp(''); | ||
|
||
editFig = figure; | ||
|
||
% Construct the trirep | ||
no = tr.X; %node | ||
el = tr.Triangulation; %element | ||
|
||
hP = trisurf(tr); | ||
set(hP, 'FaceVertexCData', zeros(length(tr.Triangulation),3)+0.7 ... | ||
,'FaceColor', 'flat' ... | ||
); | ||
axis equal vis3d | ||
light | ||
|
||
get3dfaces(hP,'on'); | ||
|
||
%Wait until a key is pressed, then only progressif it was 'd' | ||
key = get(editFig, 'CurrentCharacter'); | ||
while ~strcmpi(key, 'd') | ||
pause; | ||
key = get(editFig, 'CurrentCharacter'); | ||
end | ||
|
||
% Now, continue by creating the new TriRep | ||
iRemove = get3dfaces(hP); | ||
close(editFig); | ||
|
||
el(iRemove, :) = []; | ||
tr2 = repack(TriRep(el, no)); | ||
|
||
[tr2, isVertUsed] = repack(tr2); | ||
end |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function [x,y,z] = extract_coordinates_from_path(path) | ||
|
||
%this elegant way is incompatible with the older versions of matlab | ||
% x = cellfun(@(p) p.x, path); %the simplest way to extract coordinates from the path | ||
% y = cellfun(@(p) p.y, path); %if it looks complicated, you can use "for" similar to example1.m | ||
% z = cellfun(@(p) p.z, path); | ||
|
||
x = zeros(length(path),1); | ||
y = x; | ||
z = y; | ||
|
||
for i=1:length(path) | ||
x(i) = path{i}.x; | ||
y(i) = path{i}.y; | ||
z(i) = path{i}.z; | ||
end; | ||
|
Oops, something went wrong.