Skip to content

Commit 084dfe1

Browse files
authored
Add files via upload
1 parent 88c510b commit 084dfe1

1 file changed

Lines changed: 72 additions & 29 deletions

File tree

mcode/C_BodyParts3D_isolate_LegOuterSkinSurface_LegMuscles_vs1.m

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
saveOn=1;
3131

3232

33-
Select_layer='outer_skin_surface';%'outer_skin_surface';'outer_muscles_surface'
33+
Select_layer='outer_muscles_surface';%'outer_skin_surface';'outer_muscles_surface'
3434
switch Select_layer
3535
case 'outer_skin_surface'
3636
%% Original
@@ -87,7 +87,7 @@
8787
gpatch(F,V,'w','none',0.25);
8888
gpatch(Fe,Ve,'rw','none',1);
8989
plotV(V_slice_curve,'k-','LineWidth',4);
90-
90+
axis off;
9191
axisGeom;
9292
camlight headlight;
9393
drawnow;
@@ -113,11 +113,13 @@
113113
subplot(1,2,1); hold on;
114114
gpatch(F,V,'w','none',0.25);
115115
gpatch(Fn,Vn,'bw','none');
116+
axis off;
116117
axisGeom;
117118
camlight headlight;
118119

119120
subplot(1,2,2); hold on;
120121
gpatch(Fn,Vn,'bw','k',1,lineWidth);
122+
axis off;
121123
axisGeom;
122124
camlight headlight;
123125
gdrawnow;
@@ -207,28 +209,54 @@
207209
P(:,3)=P(:,3)-6;
208210
[Ff,Vf,~,logicSide,Eb]=triSurfSlice(Fe,Ve,[],P,n,snapTolerance);
209211
groupStruct.outputType='label';
210-
[G,~,groupSize]=tesgroup(Eb,groupStruct);
211-
[~,indKeep]=max(groupSize);
212-
indKeep=2;
213-
logicKeep=G==indKeep;
214-
Eb_keep=Eb(logicKeep,:);
215-
indCurveNow=edgeListToCurve(Eb_keep);
216-
VT=Vf(indCurveNow,:);
217-
[V_slice_curve]=convexhull_curve(VT,numPoints);
212+
[G,~,groupSize]=tesgroup(Eb,groupStruct);
213+
for i=1:size(groupSize,2)
214+
logicKeep=G==i;
215+
Eb_keep=Eb(logicKeep,:);
216+
indCurveNow=edgeListToCurve(Eb_keep);
217+
VT=Vf(indCurveNow,:);
218+
[V_slice_curve]=convexhull_curve(VT,numPoints);
219+
Vcc{i}=V_slice_curve;
220+
end
221+
%
222+
% %first_min_value
223+
% for i=1:size(groupSize,2)
224+
% [val(i),idx(i)] = min([Vcc{i}(:,1)]);
225+
% end
226+
% [~,idx_a]=min(val(:));
227+
% Vcc{idx_a} = NaN;
228+
% %second_min_value
229+
% for i=1:size(Vcc,2)
230+
% [val(i),idx(i)] = min([Vcc{i}(:,1)]);
231+
% end
232+
% [~,idx_a]=min(val(:));
233+
% Vcc{idx_a} = NaN;
234+
% %third_min_value
235+
% for i=1:size(Vcc,2)
236+
% [val(i),idx(i)] = min([Vcc{i}(:,1)]);
237+
% end
238+
% [~,idx_a]=min(val(:));
239+
idx_a=3;
240+
V_slice_curve=Vcc{idx_a};
218241
VC{q}=V_slice_curve;
219242
FL=[];
220243
VL=V_slice_curve;
221-
244+
[~,indStart]=max(VL(:,1));
245+
if indStart>1
246+
VL=[VL(indStart:end,:); VL(1:indStart-1,:)];
247+
end
248+
222249
[Fh,Vh]=regionTriMesh3D({VL},[],0,'linear');
223250
Fh=fliplr(Fh);
224251

225252

226253
cFigure;hold on;
227254
gpatch(Ff(logicSide,:),Vf,'w','none',1);
228255
gpatch(Ff(~logicSide,:),Vf,'w','none',0.25);
256+
%gpatch(Fh,Vh,'w','k',0.25);
229257
gpatch(Eb,Vf,'none','b',1,3);
230-
plotV(VL,'r-','LineWidth',4);
231-
axisGeom; axis manual; camlight headligth;
258+
plotV(VL,'k-','LineWidth',4);
259+
axisGeom; axis off;axis manual; camlight headligth;
232260
set(gca,'FontSize',25);
233261
gdrawnow;
234262

@@ -238,6 +266,16 @@
238266
groupStruct.outputType='label';
239267
[G,~,groupSize]=tesgroup(Eb,groupStruct);
240268

269+
270+
for q=1:1:max(size(groupSize))
271+
logicKeep=G==q;
272+
Eb_keep=Eb(logicKeep,:);
273+
indCurveNow=edgeListToCurve(Eb_keep);
274+
VT=Vf(indCurveNow,:);
275+
[V_slice_curve]=convexhull_curve(VT,numPoints);
276+
Vcc{i}=V_slice_curve;
277+
end
278+
241279
VT={};
242280
for q=1:1:max(size(groupSize))
243281
logicKeep=G==q;
@@ -272,15 +310,15 @@
272310

273311

274312
FL=[FL;f];
275-
VL=[VL;V_slice_curve];
313+
VL=[VL;V_slice_curve;];
276314
VC{i}=V_slice_curve;
277315

278316
% cFigure;hold on;
279317
% gpatch(Ff(logicSide,:),Vf,'w','none',1);
280318
% gpatch(Ff(~logicSide,:),Vf,'w','none',0.25);
281319
% gpatch(Eb,Vf,'none','b',1,3);
282320
% plotV(VL,'r-','LineWidth',4);
283-
% axisGeom; axis manual; camlight headligth;
321+
% axisGeom; axis off;axis manual; camlight headligth;
284322
% set(gca,'FontSize',25);
285323
% gdrawnow;
286324
end
@@ -290,21 +328,27 @@
290328
if dot(ne,[0 0 1])>0
291329
Fg=fliplr(Fg);
292330
end
293-
331+
332+
%VL0=VL;
294333
[FL,VL]=subQuad(FL,VL,3,3);
334+
%[FL,VL]=subQuadCatmullClark(FL,VL,2,1);
295335
[FL,VL]=quad2tri(FL,VL,'a');
296336
FL=fliplr(FL);
297337

298338
cFigure;
299339
subplot(1,2,1); hold on;
300-
gpatch(Fe,Ve,'rw','none',1);
301-
axisGeom;
340+
%gpatch(Fe,Ve,'rw','none',1);
341+
gpatch(Ff(logicSide,:),Vf,'w','none',1);
342+
gpatch(Ff(~logicSide,:),Vf,'w','none',0.25);
343+
%gpatch(Eb,Vf,'none','b',1,3);
344+
plotV(VL,'k-','LineWidth',4);
345+
axisGeom;axis off;
302346
camlight headligth;
303347
set(gca,'FontSize',25);
304348

305349
subplot(1,2,2); hold on;
306-
plotV(P0,'g.','MarkerSize',30);
307-
plotV(PA,'g.','MarkerSize',30);
350+
%plotV(P0,'g.','MarkerSize',30);
351+
%plotV(PA,'g.','MarkerSize',30);
308352
gpatch(Fg,Vg,'w','k',1);
309353
%patchNormPlot(Fg,Vg);
310354

@@ -313,26 +357,24 @@
313357

314358
gpatch(FL,VL,'bw','k',1);
315359
%patchNormPlot(FL,VL);
316-
317360
gpatch(Ff,Vf,'w','none',0.25);
318-
319-
361+
%plotV(VL0,'k-','LineWidth',4);
320362
nn=size(VC);
321363
for q=1:1:nn(1)
322364
Vpp=VC{q};
323365
plotV(Vpp([1:size(Vpp,1) 1],:),'k-','LineWidth',4);
324366
end
325367

326-
axisGeom; axis manual; camlight headligth;
368+
axisGeom; axis off;axis manual; camlight headligth;
327369
set(gca,'FontSize',25);
328370
gdrawnow;
329-
371+
330372
% Join and merge surfaces
331373
[F_muscles,V_muscles,C_muscles]=joinElementSets({Fg,FL,Fh},{Vg,VL,Vh});
332374
[F_muscles,V_muscles]=mergeVertices(F_muscles,V_muscles);
333375

334376
cFigure; hold on;
335-
title('Completed skin+fat surface');
377+
%title('Completed skin+fat surface');
336378
gpatch(Ff,Vf,'w','none',0.5);
337379
gpatch(F_muscles,V_muscles,C_muscles,'none',1);
338380

@@ -355,11 +397,12 @@
355397
[Fn,Vn]=ggremesh(F_muscles,V_muscles_smoothed,optionStructRemesh);
356398

357399
cFigure;hold on;
358-
gpatch(Fn,Vn,'w','k',1);
359-
axisGeom; axis manual; camlight headligth;
400+
gpatch(Fe,Ve,'w','none',1);
401+
gpatch(Fn,Vn,'r','k',1);
402+
axisGeom; axis off; axis manual; camlight headligth;
360403
set(gca,'FontSize',25);
361404
gdrawnow;
362-
405+
363406
%% Store model in structure
364407
modelNew.source=fileName_FMA_refined;
365408
modelNew.faces=Fn;

0 commit comments

Comments
 (0)