-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateNinjaCap_AVfile.m
93 lines (81 loc) · 2.99 KB
/
generateNinjaCap_AVfile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%% CODE FOR NINJACAP GENERATION
% Instructions to the user:
% 0. set up and install everything as described in the github HELP file
% here: https://github.com/neuluce/ninjaCap
% 1. provide probe file with name "probe.SD" in dir \userinput\probe.SD
% 2. run generate.m with head circumference(HC) in cm as input argument: e.g. generate(56)
% 3. when the files are generated, a blender workspace will be opened. Run
% the default python script (click <Text> -> <Run Script>, or press Alt+P.
% 4. your generated and assembled cap is saved in the folder \print\. Here
% you also find a default 3D printing profile for Cura LULZBOT TAZ 6 using
% ninjaflex.
function [] = generateNinjaCap_AVfile(target_circumference)
load('probe.SD','-mat')
dirSave = pwd;
rootDir = fileparts(which(mfilename));
%% Change the current folder to the folder of this m-file.
if(~isdeployed)
rootDir = fileparts(which(mfilename));
cd(rootDir);
end
current_cirucmference = calcRefptsCircumf_ninjaCap(SD.Landmarks)/10;
panel_AVfile(SD,target_circumference, current_cirucmference)
%% add this folder and subfolders to paths
% addpath(genpath(pwd))
%% AUTOMATED PANEL CREATION FROM SD FILES
% % if you renamed your files, update the path and names here
% if ~exist('HC','var')
% HC = 56; % default cap size
% end
% circumference = HC; % cm (actual circumference, correction applied automatically)
%% CHECK FOR EXISTING AltasViewer FILE?
% if exist([pwd filesep 'atlasViewer.mat'], 'file')
% disp('An "atlasViewer.mat" file already exists.');
% prompt = ['To overwrite file press Y/y otherwise N/n and confirm with Enter:'];
% x = input(prompt,'s');
% if (x == 'y') || (x=='Y')
% delete([pwd filesep 'atlasViewer.mat'])
% else
% error('Stopped')
% end
% end
%% PREARE ATLASVIEWER.MAT
% % launch AtlasViewer
% % DEPENDENCY HOMER 3 >> getAppDir()
% %AtlasViewerGUI(pwd, [getAppDir() 'PACKAGES' filesep 'AtlasViewerGUI' filesep 'Data' filesep 'Colin'], 'userargs');
% % appdir hardcoded
% avMainFilepath = which('AtlasViewerGUI.m');
% avAppDir = fileparts(avMainFilepath);
% avDataDir = filesepStandard([avAppDir, '/Data/Colin']);
% AtlasViewerGUI(pwd, avDataDir, 'userargs');
%
% % scale head to corrected circumference
% generateScaleCircumference(circumference);
%
% % load 10-10 points into AtlasViewer
% generateLoad10_5();
%
% % align to head surface
% generateRegisterProbe();
%
% % save state file
% generateSaveViewerState();
%% RUN PANEL.m
% cd(rootDir);
% copyfile( [dirSave filesep 'atlasViewer.mat'],'.' );
% panel('atlasViewer.mat', circumference);
drawnow
%% DELETE FILES
% delete([pwd filesep 'atlasViewer.mat']);
% delete([pwd filesep 'digpts.txt']);
% delete([pwd filesep 'digpts2mc.txt']);
%% RUN blender
system('wrkspace.blend')
%% COPY BLENDER OUTPUT TO WORKING DIRECTORY
if ~isdir([dirSave filesep 'print'])
mkdir([dirSave filesep 'print']);
end
copyfile( ['print' filesep '*.stl'], [dirSave filesep 'print'] );
copyfile( ['print' filesep '*.curaprofile'], [dirSave filesep 'print'] );
cd(dirSave)
end