-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added and rendered license boiler plate on codes and documentation
- Loading branch information
1 parent
033dde5
commit 6264a3e
Showing
27 changed files
with
1,331 additions
and
1,157 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,2 @@ | ||
# Ignore temporary matlab ASV files | ||
*.asv |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,69 @@ | ||
clear; close all; clc; | ||
|
||
%% | ||
|
||
toolboxPath=fileparts(fileparts(fileparts(mfilename('fullpath')))); | ||
docPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'docs'); | ||
libPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'mcode'); | ||
docToolsPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'docs','docTools'); | ||
|
||
pathNames={docToolsPath,libPath,docPath}; | ||
|
||
%% Prepare boilerplate | ||
|
||
licenseBoilerPlate=fullfile(toolboxPath,'licenseBoilerPlate.txt'); | ||
[T]=txtfile2cell(licenseBoilerPlate); | ||
|
||
footerTargetText='% _*SimuLimb footer text*_ '; | ||
|
||
%% | ||
|
||
licenseLink='https://github.com/SimuLimb/simulateAmputation.m/blob/main/LICENSE'; | ||
|
||
%Add comment symbols | ||
for q=1:1:numel(T) | ||
T{q}=['% ',T{q}]; | ||
end | ||
|
||
%Add target header | ||
T=[{'%% '};{footerTargetText};{'% '};{['% License: <',licenseLink,'>']};T(1:end)]; | ||
|
||
%% | ||
|
||
fileExtension='.m'; | ||
|
||
%% | ||
|
||
numPaths=numel(pathNames); | ||
for q_path=1:1:numPaths | ||
pathName=pathNames{q_path}; | ||
files = dir(fullfile(pathName,'*.m')); | ||
files={files(1:end).name}; | ||
files=sort(files(:)); | ||
numFiles=numel(files); | ||
for q_file=1:1:numFiles | ||
fileName=fullfile(pathName,files{q_file}); | ||
[T_now]=txtfile2cell(fileName); | ||
T_now(end+1:end+numel(T))=T; | ||
cell2txtfile(fileName,T_now,0); | ||
end | ||
end | ||
|
||
%% | ||
% _*SimuLimb footer text*_ | ||
% | ||
% License: <https://github.com/SimuLimb/simulateAmputation.m/blob/main/LICENSE> | ||
% | ||
% Copyright (C) 2006-2021 Kevin Mattheus Moerman and the SimuLimb contributors | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); | ||
% you may not use this file except in compliance with the License. | ||
% You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
% See the License for the specific language governing permissions and | ||
% limitations under the License. |
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,58 @@ | ||
clear; close all; clc; | ||
|
||
%% Path names | ||
|
||
toolboxPath=fileparts(fileparts(fileparts(mfilename('fullpath')))); | ||
docPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'docs'); | ||
libPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'mcode'); | ||
docToolsPath=fullfile(fileparts(fileparts(fileparts(mfilename('fullpath')))),'docs','docTools'); | ||
|
||
pathNames={docToolsPath,libPath,docPath}; | ||
|
||
%% | ||
|
||
fileExtension='.m'; %Extension to remove boilerplate from | ||
|
||
footerTargetStart='% _*SimuLimb footer text*_ '; %Target for removal | ||
|
||
%N.B. Removal is up to end from the start so make sure the target is | ||
%appropriately set!!!!! | ||
|
||
%% Removing footer text | ||
|
||
numPaths=numel(pathNames); | ||
for q_path=1:1:numPaths | ||
pathName=pathNames{q_path}; | ||
files = dir(fullfile(pathName,'*.m')); | ||
files={files(1:end).name}; | ||
files=sort(files(:)); | ||
numFiles=numel(files); | ||
for q_file=1:1:numFiles | ||
fileName=fullfile(pathName,files{q_file}); | ||
[T_now]=txtfile2cell(fileName); | ||
targetStartIndex = find(strcmp(footerTargetStart,T_now)); | ||
if ~isempty(targetStartIndex) | ||
targetStartIndex=targetStartIndex(end); %Keep last occurance | ||
T_now=T_now(1:targetStartIndex-1-1); %NB -1 is used to remove %% above target | ||
cell2txtfile(fileName,T_now,0,0); | ||
end | ||
end | ||
end | ||
%% | ||
% _*SimuLimb footer text*_ | ||
% | ||
% License: <https://github.com/SimuLimb/simulateAmputation.m/blob/main/LICENSE> | ||
% | ||
% Copyright (C) 2006-2021 Kevin Mattheus Moerman and the SimuLimb contributors | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); | ||
% you may not use this file except in compliance with the License. | ||
% You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
% See the License for the specific language governing permissions and | ||
% limitations under the License. |
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,14 @@ | ||
|
||
Copyright (C) 2006-2021 Kevin Mattheus Moerman and the SimuLimb contributors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,69 +1,87 @@ | ||
clear; close all; clc; | ||
|
||
%% Description | ||
% This code parses all STL files in the /stl folder and exports them as MAT | ||
% files to the /mat folder. | ||
% | ||
% This code requires the GIBBON MATLAB toolbox | ||
% <www.gibboncode.org> | ||
|
||
%% Control parameters | ||
|
||
% Path names | ||
projectFolder = fileparts(fileparts(mfilename('fullpath'))); %Main code path | ||
loadFolder=fullfile(projectFolder,'data','BodyParts3D','stl'); %The STL loading folder | ||
saveFolder=fullfile(projectFolder,'data','BodyParts3D','mat'); %The MAT saving folder | ||
|
||
%% | ||
|
||
%Get list of all STL files | ||
fileList = dir(fullfile(loadFolder,['*','stl'])); | ||
fileList={fileList(1:end).name}; | ||
|
||
Dc=readtable(fullfile(projectFolder,'data','BodyParts3D','FMA_ID_label_obj.csv')); | ||
P=lower(Dc.FMAID); | ||
|
||
%Convert all STL files to MAT | ||
numFiles=numel(fileList); %Number of files to parse | ||
for q=1:1:numFiles %Loop over all files | ||
%Get file name | ||
[~,fileNameClean,~]=fileparts(fileList{q}); %File name without path or extension | ||
|
||
%Prepare STL file name | ||
fileNameLoad=fullfile(loadFolder,fileList{q}); %STL file name | ||
|
||
%Prepare save file name | ||
fileNameSave=fullfile(saveFolder,[fileNameClean,'.mat']); %MAT file name | ||
|
||
%Get FMAID code | ||
FMAID=sscanf(fileNameClean,'FMA%d'); | ||
|
||
%Get preferred name | ||
logicFMAID=P==FMAID; | ||
preferredName=Dc.preferredName{logicFMAID}; | ||
|
||
%Parse STL import | ||
disp(['Parsing file ', num2str(q),' of ',num2str(numFiles),', ',sprintf('%3.0f',round(100*q/numFiles)),'% done, ',fileNameClean,', ',preferredName]) | ||
try %MATLAB's stlread | ||
TR = stlread(fileNameLoad); | ||
v=TR.Points; | ||
f=TR.ConnectivityList; | ||
catch %GIBBON's importer | ||
[stlStruct] = import_STL_bin(fileNameLoad); | ||
v=stlStruct.solidVertices{1}; | ||
f=stlStruct.solidFaces{1}; | ||
end | ||
|
||
%Merge vertices | ||
[f,v]=mergeVertices(f,v); | ||
|
||
%Build model structure | ||
model.sourceName=fileList{q}; | ||
model.preferredName=preferredName; | ||
model.faces=f; | ||
model.vertices=v; | ||
|
||
%Export MAT file | ||
save(fileNameSave,'-struct','model'); | ||
end | ||
|
||
clear; close all; clc; | ||
|
||
%% Description | ||
% This code parses all STL files in the /stl folder and exports them as MAT | ||
% files to the /mat folder. | ||
% | ||
% This code requires the GIBBON MATLAB toolbox | ||
% <www.gibboncode.org> | ||
|
||
%% Control parameters | ||
|
||
% Path names | ||
projectFolder = fileparts(fileparts(mfilename('fullpath'))); %Main code path | ||
loadFolder=fullfile(projectFolder,'data','BodyParts3D','stl'); %The STL loading folder | ||
saveFolder=fullfile(projectFolder,'data','BodyParts3D','mat'); %The MAT saving folder | ||
|
||
%% | ||
|
||
%Get list of all STL files | ||
fileList = dir(fullfile(loadFolder,['*','stl'])); | ||
fileList={fileList(1:end).name}; | ||
|
||
Dc=readtable(fullfile(projectFolder,'data','BodyParts3D','FMA_ID_label_obj.csv')); | ||
P=lower(Dc.FMAID); | ||
|
||
%Convert all STL files to MAT | ||
numFiles=numel(fileList); %Number of files to parse | ||
for q=1:1:numFiles %Loop over all files | ||
%Get file name | ||
[~,fileNameClean,~]=fileparts(fileList{q}); %File name without path or extension | ||
|
||
%Prepare STL file name | ||
fileNameLoad=fullfile(loadFolder,fileList{q}); %STL file name | ||
|
||
%Prepare save file name | ||
fileNameSave=fullfile(saveFolder,[fileNameClean,'.mat']); %MAT file name | ||
|
||
%Get FMAID code | ||
FMAID=sscanf(fileNameClean,'FMA%d'); | ||
|
||
%Get preferred name | ||
logicFMAID=P==FMAID; | ||
preferredName=Dc.preferredName{logicFMAID}; | ||
|
||
%Parse STL import | ||
disp(['Parsing file ', num2str(q),' of ',num2str(numFiles),', ',sprintf('%3.0f',round(100*q/numFiles)),'% done, ',fileNameClean,', ',preferredName]) | ||
try %MATLAB's stlread | ||
TR = stlread(fileNameLoad); | ||
v=TR.Points; | ||
f=TR.ConnectivityList; | ||
catch %GIBBON's importer | ||
[stlStruct] = import_STL_bin(fileNameLoad); | ||
v=stlStruct.solidVertices{1}; | ||
f=stlStruct.solidFaces{1}; | ||
end | ||
|
||
%Merge vertices | ||
[f,v]=mergeVertices(f,v); | ||
|
||
%Build model structure | ||
model.sourceName=fileList{q}; | ||
model.preferredName=preferredName; | ||
model.faces=f; | ||
model.vertices=v; | ||
|
||
%Export MAT file | ||
save(fileNameSave,'-struct','model'); | ||
end | ||
|
||
%% | ||
% _*SimuLimb footer text*_ | ||
% | ||
% License: <https://github.com/SimuLimb/simulateAmputation.m/blob/main/LICENSE> | ||
% | ||
% Copyright (C) 2006-2021 Kevin Mattheus Moerman and the SimuLimb contributors | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); | ||
% you may not use this file except in compliance with the License. | ||
% You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
% See the License for the specific language governing permissions and | ||
% limitations under the License. |
Oops, something went wrong.