How to combine multiple surfaces and extract data points (faces and vertices ) as one surface?
    6 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Faez Alkadi
 am 26 Okt. 2017
  
    
    
    
    
    Kommentiert: Faez Alkadi
 am 2 Nov. 2017
            I have 5 surfaces in one file as a (5x1 struct with 2 fields) format, as attached. each one is made of Points(vertices) and ConnectivityList (faces). I was able to trisurf them using for loop as shown in my code. What I want is to combine them as one surface(1x1 struct with 2 fields) which has only one field of Points and only one field of ConnectivityList. so I can trisurf it and deal with it as on surface without for loop.
Thank you so much
 SurfaceN.vertices=[];
 SurfaceN.faces=[];
 for N=1:length(Surfaces);  
 SurfaceN.vertices=Surfaces(N).Points;
 SurfaceN.faces=Surfaces(N).ConnectivityList;
 S=SurfaceN;trisurf(S.faces, S.vertices(:,1),S.vertices(:,2),S.vertices(:,3),'FaceAlpha', 0.5, 'FaceColor', 'r');
 hold on
 end
The 5 surfaces:

The 5 surfaces using trisurf with for loop

0 Kommentare
Akzeptierte Antwort
  KSSV
      
      
 am 27 Okt. 2017
        
      Bearbeitet: KSSV
      
      
 am 2 Nov. 2017
  
      load surfaces.mat ;
coor = cell(5,1) ; 
for N=1:length(Surfaces)
    S.vertices=Surfaces(N).Points;
    S.faces=Surfaces(N).ConnectivityList;
    coor{N} = S.vertices ;
    trisurf(S.faces, S.vertices(:,1),S.vertices(:,2),S.vertices(:,3),'FaceAlpha', 0.5, 'FaceColor', 'r');
    hold on
end
coor = cell2mat(coor) ;
coor = unique(coor,'rows') ;
%
dt = delaunayTriangulation(coor(:,1),coor(:,2)) ;
x = dt.Points(:,1) ; 
y = dt.Points(:,2) ; 
%
idx = knnsearch(coor(:,1:2),[x,y]) ;
z = coor(idx,3) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)
4 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


