Changeset 6312
- Timestamp:
- 10/15/10 09:32:48 (15 years ago)
- Location:
- issm/trunk/src/m/kml
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/kml/edgeadjacency.m
r6299 r6312 2 2 % create an edge adjacency table for the elements in the model. 3 3 % 4 % [edgeadj ,edgeuns,elemuns]=edgeadjacency(elem,nodecon)4 % [edgeadj]=edgeadjacency(elem,nodecon) 5 5 % 6 6 % where the required input is: … … 11 11 % edgeadj (numeric, edge adjacency array (elems x edges)) 12 12 % 13 % the optional output is: 14 % edgeuns (numeric, unshared edge list (edgeuns x 2)) 15 % elemuns (numeric, unshared edge element list (edgeuns x 1)) 16 % 17 function [edgeadj,edgeuns,elemuns]=edgeadjacency(elem,nodecon) 13 function [edgeadj]=edgeadjacency(elem,nodecon) 18 14 19 15 if ~nargin … … 49 45 end 50 46 51 %% create the unshared edge list52 53 if (nargout >= 2)54 [icol,irow]=find(edgeadj'==0);55 edgeuns=zeros(length(irow),2);56 if (nargout >= 3)57 elemuns=zeros(length(irow),1);58 end59 60 % loop over the edges61 62 for i=1:length(irow)63 edgeuns(i,1)=elem(irow(i),icol(i));64 edgeuns(i,2)=elem(irow(i),mod(icol(i),size(elem,2))+1);65 if (nargout >= 3)66 elemuns(i)=irow(i);67 end68 end69 47 end 70 71 end -
issm/trunk/src/m/kml/kml_mesh_write.m
r6302 r6312 295 295 if (~exist('prtplt','var') || strncmpi(prtplt,'on' ,2) || strncmpi(prtplt,'y',1)) && ... 296 296 md.npart 297 [edgeadj,edgeuns,elemuns]=edgeadjacency(md.elements,md.nodeconnectivity); 297 [edgeadj]=edgeadjacency(md.elements,md.nodeconnectivity); 298 [icol,irow]=find(edgeadj'==0); 299 edgeuns=zeros(length(irow),2); 300 for i=1:length(irow) 301 edgeuns(i,1)=md.elements(irow(i),icol(i)); 302 edgeuns(i,2)=md.elements(irow(i),mod(icol(i),size(md.elements,2))+1); 303 end 298 304 fprintf(fid,' <Folder>\n'); 299 305 fprintf(fid,' <name>Unshared Edges</name>\n'); … … 327 333 end 328 334 335 % write folder for partitions 336 337 fprintf(fid,' <Folder>\n'); 338 fprintf(fid,' <name>Partitions</name>\n'); 339 fprintf(fid,' <visibility>1</visibility>\n'); 340 fprintf(fid,' <description>Partitions=%d, Nodes=%d</description>\n',... 341 md.npart,md.numberofgrids); 342 343 % write each partition loop as a polygon 344 345 disp(['Writing ' num2str(md.npart) ' partitions as KML polygons.']); 346 epart=md.part(md.elements)+1; 347 for k=1:md.npart 348 [icol,irow]=find(epart'==k); 349 irow=unique(irow); 350 elem=md.elements(irow,:); 351 nodecon=NodeConnectivity(elem,md.numberofgrids); 352 [edgeper,elemper,iloop]=edgeperimeter(elem,nodecon); 353 iloop(end+1)=size(edgeper,1)+1; 354 for i=1:length(iloop)-1 355 fprintf(fid,' <Placemark>\n'); 356 if (length(iloop)-1 > 1) 357 fprintf(fid,' <name>Partition %d, Loop %d</name>\n',k,i); 358 else 359 fprintf(fid,' <name>Partition %d</name>\n',k); 360 end 361 fprintf(fid,' <visibility>1</visibility>\n'); 362 % if exist('edata','var') 363 % fprintf(fid,' <description>Element data: %g</description>\n',edata(i)); 364 % imap = fix((edata(i)-cmin)/(cmax-cmin)*size(cmap,1))+1; 365 % if (imap >= 1) && (imap <= size(cmap,1)) 366 % fprintf(fid,' <styleUrl>#MatlabColor%d</styleUrl>\n',imap); 367 % elseif (edata(i) == cmax) 368 % fprintf(fid,' <styleUrl>#MatlabColor%d</styleUrl>\n',size(cmap,1)); 369 % else 370 % fprintf(fid,' <styleUrl>#BlackLineEmptyPoly</styleUrl>\n'); 371 % end 372 % else 373 fprintf(fid,' <styleUrl>#BlackLineRandomPoly</styleUrl>\n'); 374 % end 375 fprintf(fid,' <Polygon>\n'); 376 fprintf(fid,' <extrude>1</extrude>\n'); 377 fprintf(fid,' <altitudeMode>relativeToGround</altitudeMode>\n'); 378 fprintf(fid,' <outerBoundaryIs>\n'); 379 fprintf(fid,' <LinearRing>\n'); 380 fprintf(fid,' <coordinates>\n'); 381 for j=iloop(i):iloop(i+1)-1 382 [lat(j),long(j)]=mapxy(md.x(edgeper(j,1)),md.y(edgeper(j,1)),'s'); 383 fprintf(fid,' %0.16g,%0.16g,%0.16g\n',long(j),lat(j),alt); 384 end 385 fprintf(fid,' %0.16g,%0.16g,%0.16g\n',long(iloop(i)),lat(iloop(i)),alt); 386 387 fprintf(fid,' </coordinates>\n'); 388 fprintf(fid,' </LinearRing>\n'); 389 fprintf(fid,' </outerBoundaryIs>\n'); 390 fprintf(fid,' </Polygon>\n'); 391 fprintf(fid,' </Placemark>\n'); 392 end 393 end 394 fprintf(fid,' </Folder>\n'); 395 329 396 % write trailer data 330 397
Note:
See TracChangeset
for help on using the changeset viewer.