|
9 | 9 | % This code requires the GIBBON MATLAB toolbox |
10 | 10 | % <www.gibboncode.org> |
11 | 11 |
|
| 12 | +%colors |
| 13 | +green = 1/255*[0, 100, 0]; |
12 | 14 | %% Control parameters |
13 | 15 |
|
14 | 16 | projectFolder = fileparts(fileparts(mfilename('fullpath'))); |
|
145 | 147 | %% |
146 | 148 | % Visualization |
147 | 149 |
|
148 | | -cFigure; hold on; |
149 | | -%title('Cut features'); |
150 | | -% gpatch(FT,VT,'w','none',0.1); |
151 | | -gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
152 | | -axisGeom; axis off; camlight headlight; |
153 | | -colormap gjet; %icolorbar; |
154 | | -gdrawnow; |
| 150 | +% cFigure; hold on; |
| 151 | +% %title('Cut features'); |
| 152 | +% % gpatch(FT,VT,'w','none',0.1); |
| 153 | +% gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
| 154 | +% gpatch(FT{1},VT{1},'w','none',0.25); |
| 155 | +% plotV(V_bone_femur(I_min_femur,:),'k.','MarkerSize',100); |
| 156 | +% axisGeom; axis off; camlight headlight; |
| 157 | +% colormap gjet; %icolorbar; |
| 158 | +% gdrawnow; |
155 | 159 |
|
156 | 160 | %% Set up skin taper parameterisation |
157 | 161 | switch select_amputation_case |
|
175 | 179 | %Muscle |
176 | 180 | Fm=FT_amp{6}; |
177 | 181 | Vm=VT_amp{6}; |
178 | | -end |
| 182 | + %Get cut bone end curve |
| 183 | + Ebt=patchBoundary(Ft,Vt); |
| 184 | + indBt=edgeListToCurve(Ebt); |
| 185 | + indBt=indBt(1:end-1); |
| 186 | + P_end_centroid=mean(Vt(indBt,:),1); |
179 | 187 |
|
180 | | - |
| 188 | +end |
| 189 | + |
181 | 190 | %Get cut bone end curve |
182 | 191 | Ebt=patchBoundary(Ft,Vt); |
183 | 192 | indBt=edgeListToCurve(Ebt); |
184 | 193 | indBt=indBt(1:end-1); |
185 | 194 | P_end_centroid=mean(Vt(indBt,:),1); |
| 195 | + |
186 | 196 | %Skin |
187 | 197 | D=Vs(:,3)-(min(Vs(:,3))+taperHeigth); |
188 | 198 | D(D>0)=0; |
|
191 | 201 | D=D.^2; |
192 | 202 |
|
193 | 203 | [Dp,indMin]=minDist(Vs(:,[1 2]),Vt(indBt,[1 2])); |
194 | | - |
195 | 204 | Dp(Dp<=taperThreshold)=taperThreshold; |
196 | 205 | Dp=Dp-min(Dp); |
197 | 206 | Dp=Dp./max(Dp); |
|
215 | 224 | VT_amp{5}=Vs; |
216 | 225 | end |
217 | 226 |
|
| 227 | +F_skin_ref=FT_amp{2}; |
| 228 | +V_skin_ref=VT_amp{2}; |
218 | 229 | cFigure; hold on; |
219 | | -title('taper morphing'); |
220 | | -gpatch(FT_amp,VT_amp,'w','none',0.5); |
221 | | -% gpatch(Fs,Vs,'w','none',0.5); |
| 230 | +%title('taper morphing'); |
| 231 | +gpatch(FT_amp{2},VT_amp{2},'w','none',0.5); |
| 232 | +%gpatch(FT_amp,VT_amp,'w','none',0.5); |
| 233 | + |
| 234 | +%gpatch(Fs,Vs,'r','none',0.5); |
222 | 235 | quiverVec(Vs1,R); |
223 | 236 | colormap gjet; colorbar; |
224 | | -axisGeom; camlight headlight; |
| 237 | +axisGeom; axis off; camlight headlight; |
| 238 | +set(gca,'FontSize',35); |
225 | 239 | gdrawnow; |
226 | 240 |
|
227 | | - |
228 | 241 | %% Process skin distal end closure |
229 | 242 | P_end=P_end_centroid-[0 0 distalExcess]; |
230 | 243 | Ebs=patchBoundary(Fs,Vs); |
|
234 | 247 | % Visualization |
235 | 248 |
|
236 | 249 | cFigure; hold on; |
237 | | -title('Distal end closure'); |
238 | | -gpatch(FT_amp,VT_amp,'w','none',1); |
| 250 | +%title('Distal end closure'); |
| 251 | +%gpatch(FT_amp{2},VT_amp{2},'w','none',0.5); |
| 252 | +gpatch(FT_amp,VT_amp,'w','none',0.5); |
239 | 253 | %gpatch(Fs,Vs,'w','none',0.25); |
240 | 254 | hp=gpatch(Fsb,Vsb,Vsb(:,3),'none',1); hp.FaceColor='interp'; |
241 | 255 | % gpatch(Ebs,Vs,'none','b',1,3); |
|
277 | 291 | CT_amp{5}=5*ones(size(Fs,1),1); |
278 | 292 | end |
279 | 293 |
|
280 | | - |
281 | 294 | cFigure; |
282 | 295 | subplot(1,2,1); hold on; |
283 | 296 | % gpatch(FT,VT,'w','none',0.25); |
|
290 | 303 | axisGeom; axis off; camlight headlight; |
291 | 304 | gdrawnow; |
292 | 305 |
|
| 306 | +% cFigure; hold on; |
| 307 | +% gpatch(FT_amp{2},VT_amp{2},'w','k',1); |
| 308 | +% axisGeom; axis off; camlight headlight; |
| 309 | +% gdrawnow; |
293 | 310 |
|
294 | 311 | %% Process muscle taper |
295 | 312 | Dm=Vm(:,3)-(min(Vm(:,3))+taperHeigth); |
|
324 | 341 | end |
325 | 342 |
|
326 | 343 | cFigure; hold on; |
327 | | -title('taper morphing'); |
| 344 | +%title('taper morphing'); |
| 345 | +%gpatch(FT_amp{3},VT_amp{3},'w','none',0.5); |
328 | 346 | gpatch(FT_amp,VT_amp,'w','none',0.5); |
329 | 347 | quiverVec(Vm1,Rm); |
330 | 348 | colormap gjet; colorbar; |
331 | | -axisGeom; camlight headlight; |
| 349 | +axisGeom; axis off; camlight headlight; |
| 350 | +set(gca,'FontSize',35); |
332 | 351 | gdrawnow; |
333 | 352 |
|
334 | 353 | %% Process muscle distal end closure |
|
338 | 357 | %% |
339 | 358 | % Visualization |
340 | 359 | cFigure; hold on; |
341 | | -title('Distal end closure'); |
| 360 | +%title('Distal end closure'); |
| 361 | +%gpatch(FT_amp{3},VT_amp{3},'w','none',0.25); |
342 | 362 | gpatch(FT_amp,VT_amp,'w','none',0.25); |
343 | | -gpatch(Fm,Vm,'w','none',1); |
| 363 | +gpatch(Fm,Vm,'w','none',0.5); |
344 | 364 | hp=gpatch(Fmb,Vmb,Vmb(:,3),'none',1); hp.FaceColor='interp'; |
345 | 365 |
|
346 | 366 | quiverVec(Vm(indBm,:),Nd(indBm,:),radiusEnd/4,'k'); |
|
353 | 373 | end |
354 | 374 |
|
355 | 375 | plotV(P_end,'k.','MarkerSize',25); |
356 | | - |
| 376 | +axis off; |
357 | 377 | axisGeom; camlight headlight; |
358 | 378 | gdrawnow; |
359 | 379 |
|
|
393 | 413 | axisGeom; axis off; camlight headlight; |
394 | 414 | gdrawnow; |
395 | 415 |
|
| 416 | +% |
| 417 | +% % |
| 418 | +% cFigure; hold on; |
| 419 | +% gpatch(FT_amp{3},VT_amp{3},'w','k',1); |
| 420 | +% axisGeom; axis off; camlight headlight; |
| 421 | +% gdrawnow; |
| 422 | + |
| 423 | + |
396 | 424 | %% Process femur taper |
397 | 425 | switch select_amputation_case |
398 | 426 | case 'tf' |
|
417 | 445 | %% |
418 | 446 | % Visualization |
419 | 447 | cFigure; hold on; |
420 | | -gpatch(Ft,Vt,'w','none',0.25); |
| 448 | +gpatch(Ft,Vt,'w','none',0.5); |
421 | 449 | gpatch(Ebs,Vt,'none','b',1,3); |
422 | 450 | hp=gpatch(Fsb,Vsb,'w','k',1,1); |
423 | 451 | % hp.FaceColor='interp'; |
|
431 | 459 | for q=1:size(XB,2) |
432 | 460 | plotV([XB(:,q) YB(:,q) ZB(:,q)],'k.-','LineWidth',0.5,'MarkerSize',5); |
433 | 461 | end |
434 | | - |
| 462 | +axis off; |
435 | 463 | axisGeom; camlight headlight; |
436 | 464 | gdrawnow; |
437 | 465 |
|
|
458 | 486 |
|
459 | 487 | %% |
460 | 488 |
|
| 489 | +% cFigure;hold on; |
| 490 | +% gpatch(Ft,Vt,'w','k',1); |
| 491 | +% axisGeom; axis off; camlight headlight; |
| 492 | +% gdrawnow; |
| 493 | + |
| 494 | + |
461 | 495 | cFigure; |
462 | 496 | subplot(1,2,1); hold on; |
463 | 497 | % gpatch(FT,VT,'w','none',0.25); |
|
476 | 510 | % gpatch(FT,VT,'w','none',0.25); |
477 | 511 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
478 | 512 | axisGeom; axis off; camlight headlight; |
479 | | -colormap gjet; %icolorbar; |
| 513 | +colormap gjet; icolorbar; |
| 514 | +set(gca,'FontSize',35); |
480 | 515 | gdrawnow; |
481 | 516 |
|
482 | 517 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
807 | 842 | colormap gjet; icolorbar; |
808 | 843 | gdrawnow; |
809 | 844 |
|
| 845 | + %Save original skin surface for socket design |
| 846 | + F_skin_original=FT_amp{2}; |
| 847 | + V_skin_original=VT_amp{2}; |
810 | 848 | %Cut the top skin surface |
811 | 849 | Fs=FT_amp{2}; |
812 | 850 | Vs=VT_amp{2}; |
|
851 | 889 |
|
852 | 890 | %% |
853 | 891 | cFigure;hold on; |
854 | | - gpatch(Fc_skin,Vc_skin,'gw','k',1); |
855 | | - gpatch(Fc_muscle,Vc_muscle,'rw','k',1); |
856 | | - gpatch(Fsm,Vsm,'bw','k',0.6); |
857 | | - plotV(Vc_skin(indBs_skin,:),'r-','LineWidth',4); |
858 | | - plotV(Vc_muscle(indBs_muscle,:),'g-','LineWidth',4); |
| 892 | + gpatch(Fc_skin,Vc_skin,green,'none',0.5); |
| 893 | + gpatch(Fc_muscle,Vc_muscle,'rw','none',0.5); |
| 894 | + gpatch(Fsm,Vsm,'w','k',0.6); |
| 895 | + gpatch(Ftt,Vtt,'w','k',0.6); |
| 896 | + |
| 897 | + |
| 898 | + plotV(Vc_skin(indBs_skin,:),'k-','LineWidth',4); |
| 899 | + plotV(Vc_muscle(indBs_muscle,:),'r-','LineWidth',4); |
| 900 | + plotV(Vc_femur(indBs_femur,:),'b-','LineWidth',4); |
| 901 | + |
859 | 902 |
|
860 | 903 | colormap gjet; |
861 | | - axisGeom; camlight headlight; |
| 904 | + axisGeom; axis off;camlight headlight; |
862 | 905 | gdrawnow; |
863 | 906 |
|
864 | 907 |
|
|
874 | 917 | %% |
875 | 918 | cFigure; hold on; |
876 | 919 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
877 | | - patchNormPlot(FT_amp,VT_amp); |
| 920 | + %patchNormPlot(FT_amp,VT_amp); |
878 | 921 | axisGeom; axis off; camlight headlight; |
879 | | - colormap gjet; %icolorbar; |
| 922 | + colormap gjet; icolorbar; |
880 | 923 | gdrawnow; |
| 924 | + |
881 | 925 |
|
| 926 | + |
| 927 | + FT_amp{6}=F_skin_original; |
| 928 | + VT_amp{6}=V_skin_original; |
| 929 | + CT_amp{6}=6*ones(size(F_skin_original,1),1); |
| 930 | + |
882 | 931 | % stlwrite(triangulation(VT_amp{1},FT_amp{1}),fullfile(saveFolder_stl,'femur_tf.stl'),'binary'); |
883 | 932 | % stlwrite(triangulation(VT_amp{2},FT_amp{2}),fullfile(saveFolder_stl,'skin_tf.stl'),'binary'); |
884 | 933 | % stlwrite(triangulation(VT_amp{3},FT_amp{3}),fullfile(saveFolder_stl,'muscle_tf.stl'),'binary'); |
|
0 commit comments