Changeset 2977
- Timestamp:
- 02/08/10 08:41:51 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r2970 r2977 478 478 void Triangles::WriteMesh(BamgMesh* bamgmesh,BamgOpts* bamgopts){ 479 479 480 int i,j ;480 int i,j,k,num; 481 481 int verbose; 482 482 … … 507 507 bamgmesh->NumEdges=nbe; 508 508 xfree((void**)&bamgmesh->Edges); 509 int NumSegments=0; 509 510 if (nbe){ 510 511 bamgmesh->Edges=(double*)xmalloc(3*nbe*sizeof(double)); … … 513 514 bamgmesh->Edges[i*3+1]=Number(edges[i][1])+1; //back to M indexing 514 515 bamgmesh->Edges[i*3+2]=edges[i].ref; 515 /*if(edges[i].onGeometry){516 printf("ref = %i [%i %i]\n",edges[i].ref,Number(edges[i][0])+1,Number(edges[i][1])+1);517 } */516 if(edges[i].onGeometry){ 517 NumSegments++; 518 } 518 519 } 519 520 } 520 521 else{ 521 522 bamgmesh->Edges=NULL; 523 } 524 525 //Segments 526 if(verbose>3) printf(" writing Segments\n"); 527 //chaining algorithm 528 int head_v[nbv]; 529 int next_p[3*nbt]; 530 for (i=0;i<nbv;i++) head_v[i]=-1; 531 k=0; 532 for (i=0;i<nbt;i++) { 533 //Do not take into account outside triangles (reft<0) 534 if (reft[i]>=0){ 535 for (j=0;j<3;j++){ 536 int v=Number(triangles[i][j]); //jth vertex of the ith triangle 537 next_p[k]=head_v[v]; 538 head_v[v]=k++; 539 } 540 } 541 } 542 xfree((void**)&bamgmesh->Segments); 543 xfree((void**)&bamgmesh->SegmentsMarkers); 544 bamgmesh->NumSegments=NumSegments; 545 bamgmesh->Segments=(double*)xmalloc(3*NumSegments*sizeof(double)); 546 bamgmesh->SegmentsMarkers=(double*)xmalloc(1*NumSegments*sizeof(double)); 547 num=0; 548 for (i=0;i<nbe;i++){ 549 if(edges[i].onGeometry){ 550 //build segment 551 int i1=Number(edges[i][0]); 552 int i2=Number(edges[i][1]); 553 bool stop=false; 554 for(j=head_v[i1];j!=-1;j=next_p[j]){ 555 for(k=0;k<3;k++){ 556 if (Number(triangles[(int)j/3][k])==i1){ 557 if (Number(triangles[(int)j/3][(int)((k+1)%3)])==i2){ 558 bamgmesh->Segments[num*3+0]=Number(edges[i][0])+1; //back to M indexing 559 bamgmesh->Segments[num*3+1]=Number(edges[i][1])+1; //back to M indexing 560 bamgmesh->Segments[num*3+2]=(int)j/3+1; //back to M indexing 561 bamgmesh->SegmentsMarkers[num]=edges[i].ref; 562 num+=1; 563 stop=true; 564 break; 565 } 566 if (Number(triangles[(int)j/3][(int)((k+2)%3)])==i2){ 567 bamgmesh->Segments[num*3+0]=Number(edges[i][1])+1; //back to M indexing 568 bamgmesh->Segments[num*3+1]=Number(edges[i][0])+1; //back to M indexing 569 bamgmesh->Segments[num*3+2]=(int)j/3+1; //back to M indexing 570 bamgmesh->SegmentsMarkers[num]=edges[i].ref; 571 num+=1; 572 stop=true; 573 break; 574 } 575 } 576 } 577 if(stop) break; 578 } 579 if (!stop){ 580 throw ErrorException(__FUNCT__,exprintf("Element holding segment [%i %i] not found...",i1+1,i2+1)); 581 } 582 } 522 583 } 523 584 … … 539 600 //Triangles 540 601 if(verbose>3) printf(" writing Triangles\n"); 541 Int4k=nbInT-NbOfQuad*2;542 Int4num=0;602 k=nbInT-NbOfQuad*2; 603 num=0; 543 604 bamgmesh->NumTriangles=k; 544 605 xfree((void**)&bamgmesh->Triangles); -
issm/trunk/src/c/objects/BamgMesh.h
r2794 r2977 16 16 int NumEdges; 17 17 double* Edges; 18 19 int NumSegments; 20 double* Segments; 21 double* SegmentsMarkers; 18 22 19 23 int NumCrackedEdges; -
issm/trunk/src/m/classes/public/bamg.m
r2969 r2977 141 141 142 142 %call Bamg 143 [triangles vertices metric]=Bamg(bamg_mesh,bamg_geometry,bamg_options);143 [triangles vertices segments segmentsmarkers metric]=Bamg(bamg_mesh,bamg_geometry,bamg_options); 144 144 145 145 % plug results onto model … … 147 147 md.y=vertices(:,2); 148 148 md.elements=triangles(:,1:3); 149 md.segments=segments; 150 md.segmentmarkers=segmentsmarkers; 149 151 md.dummy=metric; 150 152 … … 159 161 md.elementonbed=ones(md.numberofelements,1); 160 162 md.elementonsurface=ones(md.numberofelements,1); 161 162 %Now, build the connectivity tables for this mesh.163 md.nodeconnectivity=NodeConnectivity(md.elements,md.numberofgrids);164 md.elementconnectivity=ElementConnectivity(md.elements,md.nodeconnectivity);165 166 %recreate segments167 md.segments=findsegments(md);168 163 md.gridonboundary=zeros(md.numberofgrids,1); md.gridonboundary(md.segments(:,1:2))=1; 164 md.counter=1; -
issm/trunk/src/mex/Bamg/Bamg.cpp
r2960 r2977 107 107 bamgmesh.NumEdges=0; 108 108 bamgmesh.Edges=NULL; 109 bamgmesh.NumSegments=0; 110 bamgmesh.Segments=NULL; 111 bamgmesh.SegmentsMarkers=NULL; 109 112 FetchData(&NumCrackedEdgesMesh,mxGetField(BAMGMESH,0,"NumCrackedEdges")); 110 113 bamgmesh.NumCrackedEdges=NumCrackedEdgesMesh; … … 175 178 WriteData(TRIANGLESOUT,bamgmesh.Triangles,bamgmesh.NumTriangles,4); 176 179 WriteData(VERTICESOUT,bamgmesh.Vertices,bamgmesh.NumVertices,3); 180 WriteData(SEGMENTSOUT,bamgmesh.Segments,bamgmesh.NumSegments,3); 181 WriteData(SEGMENTSMARKERSOUT,bamgmesh.SegmentsMarkers,bamgmesh.NumSegments,1); 177 182 WriteData(METRICOUT,bamgopts.metric,nods,3); 178 183 -
issm/trunk/src/mex/Bamg/Bamg.h
r2899 r2977 23 23 24 24 /* serial output macros: */ 25 #define TRIANGLESOUT (mxArray**)&plhs[0] 26 #define VERTICESOUT (mxArray**)&plhs[1] 27 #define METRICOUT (mxArray**)&plhs[2] 25 #define TRIANGLESOUT (mxArray**)&plhs[0] 26 #define VERTICESOUT (mxArray**)&plhs[1] 27 #define SEGMENTSOUT (mxArray**)&plhs[2] 28 #define SEGMENTSMARKERSOUT (mxArray**)&plhs[3] 29 #define METRICOUT (mxArray**)&plhs[4] 28 30 29 31 /* serial arg counts: */ 30 32 #undef NLHS 31 #define NLHS 333 #define NLHS 5 32 34 #undef NRHS 33 35 #define NRHS 3
Note:
See TracChangeset
for help on using the changeset viewer.