From 574af4f3b4410e6755d0c581fc092f3693462322 Mon Sep 17 00:00:00 2001 From: Nataliya Perevoshchikova <47018678+NataCalc@users.noreply.github.com> Date: Fri, 3 Jun 2022 09:37:56 +1000 Subject: [PATCH] Add files via upload --- ...olate_LegOuterSkinSurface_LegMuscles_vs1.m | 123 ++++++++++++++---- 1 file changed, 96 insertions(+), 27 deletions(-) diff --git a/mcode/C_BodyParts3D_isolate_LegOuterSkinSurface_LegMuscles_vs1.m b/mcode/C_BodyParts3D_isolate_LegOuterSkinSurface_LegMuscles_vs1.m index bc26788..6b19d8c 100644 --- a/mcode/C_BodyParts3D_isolate_LegOuterSkinSurface_LegMuscles_vs1.m +++ b/mcode/C_BodyParts3D_isolate_LegOuterSkinSurface_LegMuscles_vs1.m @@ -27,11 +27,12 @@ pointSpacing=4; cutHeight=810; +cutHeight1=860; saveOn=1; -Select_layer='outer_muscles_surface';%'outer_skin_surface';'outer_muscles_surface' -switch Select_layer +Select_layer='outer_skin_surface';%'outer_skin_surface';'outer_muscles_surface' +switch Select_layer case 'outer_skin_surface' %% Original fileName_mat=fullfile(loadFolder,[fileName_FMA,'.mat']); @@ -54,6 +55,7 @@ axisGeom; camlight headlight; drawnow; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Cut again preserving only right leg optionStruct.outputType='label'; @@ -62,14 +64,14 @@ logicKeep=G==indMax; Fs=Fs(logicKeep,:); [Fs,Vs]=patchCleanUnused(Fs,Vs); - + cFigure; hold on; gpatch(Fs,Vs,'w','none',0.25); axis off; axisGeom; camlight headlight; drawnow; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Slice the surface of the right leg at cutHeight %% to detect all edges to form the list of curves within the slice @@ -100,12 +102,13 @@ VTc=Vc(indCurveNow,:); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Forming the 2D convex hull around the curve - [V_slice_curve]=convexhull_curve(VTc,200); + [VT0]=convexhull_curve(VTc,200); [Fc,Vc]=patchCleanUnused(Fc(logicSide,:),Vc); + VT0(:,3)=VT0(:,3)+25; cFigure; hold on; gpatch(Fc,Vc,'w','none',0.25); - plotV(V_slice_curve,'k-','LineWidth',4); + plotV(VT0,'k-','LineWidth',4); axis off; axisGeom; camlight headlight; @@ -116,8 +119,8 @@ %Set-up orientation and location of cutting plane snapTolerance=mean(patchEdgeLengths(Fc,Vc))/100; %Tolerance for surface slicing n=vecnormalize([0 0 1]); %Normal direction to plane - Q1=euler2DCM([0.4*pi 0 0.8*pi]); - + Q1=euler2DCM([0.38*pi 0 0.8*pi]); + n=n*Q1; P_cut=[0 0 0]+n*306; %Point on plane %Slicing surface @@ -125,24 +128,90 @@ %Compose isolated cut geometry and boundary curves [Fe,Ve]=patchCleanUnused(Fd(logicSide==1,:),Vd); - + Ebs=patchBoundary(Fe); + groupStruct.outputType='label'; + [G,~,groupSize]=tesgroup(Ebs,groupStruct); + + logicKeep=G==1; + Eb_keep=Ebs(logicKeep,:); + indCutLine=edgeListToCurve(Eb_keep); + + %Smoothen line + logicRigid=true(size(Ve,1),1); + logicRigid(indCutLine)=0; + + cPar.n=10; + cPar.Method='LAP'; + cPar.RigidConstraints=find(logicRigid); + [Ve]=patchSmooth(Ebs,Ve,[],cPar); + + %Smoothen mesh + logicTouch=any(ismember(Fe,indCutLine),2); + indTouch=unique(Fe(logicTouch,:)); + + for q=1:1:2 + logicTouch=any(ismember(Fe,indTouch),2); + indTouch=unique(Fe(logicTouch,:)); + end + %Smoothen line + logicRigid=true(size(Ve,1),1); + logicRigid(indTouch)=0; + logicRigid(indCutLine)=1; + %Smoothen mesh + clear cPar; + cPar.n=100; + cPar.Method='HC'; + cPar.RigidConstraints=find(logicRigid); + [Ve]=patchSmooth(Fe,Ve,[],cPar); + + VT=Ve(indCutLine,:); + + VT0=evenlySampleCurve(VT0,size(VT,1),'pchip',1); + VT0=VT0(1:end-1,:); + indCurve_S=(linspace(1,size(VT0,1),size(VT0,1))); + indCurve_S=indCurve_S(1:end-1); + indCurve_L=indCurve_S; + %% Reorder curves + [~,indMin]=minDist(VT(indCurve_L(1),:),VT0(indCurve_S,:)); + + if indMin>1 + indCurve_S=[indCurve_S(indMin:end) indCurve_S(1:indMin-1)]; + end + + D1=sum(sqrt(sum((VT(indCurve_L,:)-VT0(indCurve_S,:)).^2,2))); + D2=sum(sqrt(sum((VT(indCurve_L,:)-VT0(flip(indCurve_S),:)).^2,2))); + + if D2