Changeset 2783
- Timestamp:
- 01/08/10 07:01:25 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Mesh2.cpp
r2782 r2783 4131 4131 Triangles * OldCurrentTh =CurrentTh; 4132 4132 CurrentTh=this; 4133 int verbosity=1; 4133 4134 // Int4 NbTold = nbt; 4134 4135 // generation of the integer coor … … 4440 4441 // 4441 4442 4442 delete edge4; 4443 delete [] st; 4443 //delete edge4; //TESTESTESTSTSTSTSTST 4444 //delete [] st; //TESTESTESTSTSTSTSTST 4445 printf("ok1\n"); 4444 4446 for (i=0;i<nbv;i++) 4445 4447 quadtree->Add(vertices[i]); … … 4463 4465 } 4464 4466 } 4467 printf("ok2\n"); 4465 4468 CurrentTh=OldCurrentTh; 4466 4469 } -
issm/trunk/src/c/Bamgx/MeshRead.cpp
r2781 r2783 41 41 void Triangles::ReadFromMatlabMesh(BamgMesh* bamgmesh, BamgArgs* bamgargs){ 42 42 43 int verbos ity;44 Real8 hmin = HUGE_VAL;// the infinie value43 int verbose; 44 Real8 Hmin = HUGE_VAL;// the infinie value 45 45 Int4 i1,i2,i3,iref; 46 Int4 i ;46 Int4 i,j; 47 47 Int4 hvertices =0; 48 48 Int4 ifgeom=0; 49 49 Metric M1(1); 50 Int4 dim=2; 50 int Version=1,dim=2; 51 52 verbose=bamgargs->verbose; 51 53 52 54 nbv=bamgmesh->numberofnodes; 53 nbvx= bamgargs->maxnbv;55 nbvx=nbv; 54 56 nbt=bamgmesh->numberofelements; 55 nbtx=2*nbvx-2; // for filling The Holes and quadrilaterals56 57 nbiv=nbvx; 57 58 58 vertices=(Vertex*)xmalloc(nbv*sizeof(Vertex)); 59 ordre=(Vertex**)xmalloc(nbv*sizeof(Vertex*)); 60 61 /*Create Vertices*/ 62 for (i=0;i<bamgmesh->numberofnodes;i++){ 63 vertices[i].r.x=bamgmesh->x[i]; 64 vertices[i].r.y=bamgmesh->y[i]; 65 vertices[i].ReferenceNumber=1; 66 vertices[i].DirOfSearch =NoDirOfSearch; 67 vertices[i].m=M1; 68 vertices[i].color =0; 69 } 70 71 /*Create triangles*/ 72 triangles=(Triangle*)xmalloc(nbt*sizeof(Triangle)); 73 for (i=0;i<bamgmesh->numberofelements;i++){ 74 Triangle & t = triangles[i]; 75 i1=(Int4)bamgmesh->index[i*3+0]-1; //for C indexing 76 i2=(Int4)bamgmesh->index[i*3+1]-1; //for C indexing 77 i3=(Int4)bamgmesh->index[i*3+2]-1; //for C indexing 78 t=Triangle(this,i1,i2,i3); 79 t.color=1; 80 } 81 82 /*Recreate geometry: */ 83 ConsGeometry(-1); //MaximalAngleOfCorner is actually in BamgGeom... 84 Gh.AfterRead(); 59 //Vertices 60 if(bamgmesh->x){ 61 if(verbose>3) printf("Reading Vertices\n"); 62 63 vertices=(Vertex*)xmalloc(nbv*sizeof(Vertex)); 64 ordre=(Vertex**)xmalloc(nbv*sizeof(Vertex*)); 65 66 for (i=0;i<nbv;i++){ 67 vertices[i].r.x=bamgmesh->x[i]; 68 vertices[i].r.y=bamgmesh->y[i]; 69 vertices[i].ReferenceNumber=1; 70 vertices[i].DirOfSearch =NoDirOfSearch; 71 vertices[i].m=M1; 72 vertices[i].color =0; 73 } 74 nbtx=2*nbvx-2; // for filling The Holes and quadrilaterals 75 } 76 else{ 77 if(verbose>3) throw ErrorException(__FUNCT__,exprintf("no Vertices found in the initial mesh")); 78 } 79 80 //Triangles 81 if(bamgmesh->index){ 82 if(verbose>3) printf("Reading index\n"); 83 triangles =new Triangle[nbt]; 84 for (i=0;i<bamgmesh->numberofelements;i++){ 85 Triangle & t = triangles[i]; 86 i1=(Int4)bamgmesh->index[i*3+0]-1; //for C indexing 87 i2=(Int4)bamgmesh->index[i*3+1]-1; //for C indexing 88 i3=(Int4)bamgmesh->index[i*3+2]-1; //for C indexing 89 t=Triangle(this,i1,i2,i3); 90 t.color=1; //reference = 1 for all triangles since it has not been specified 91 } 92 } 93 else{ 94 if(verbose>3) throw ErrorException(__FUNCT__,exprintf("no Vertices found in the initial mesh")); 95 } 96 97 //Quadrilaterals 98 if(bamgmesh->Quadrilaterals){ 99 if(verbose>3) printf("Reading Quadrilaterals\n"); 100 Int4 i1,i2,i3,i4,iref; 101 triangles =new Triangle[nbt]; 102 for (i=0;i<bamgmesh->NumQuadrilaterals;i++){ 103 Triangle & t1 = triangles[2*i]; 104 Triangle & t2 = triangles[2*i+1]; 105 i1=(Int4)bamgmesh->Quadrilaterals[i*4+0]-1; //for C indexing 106 i2=(Int4)bamgmesh->Quadrilaterals[i*4+1]-1; //for C indexing 107 i3=(Int4)bamgmesh->Quadrilaterals[i*4+2]-1; //for C indexing 108 i4=(Int4)bamgmesh->Quadrilaterals[i*4+3]-1; //for C indexing 109 t1=Triangle(this,i1,i2,i3); 110 t2=Triangle(this,i3,i4,i1); 111 t1.color=1; //reference = 1 for all triangles since it has not been specified 112 t2.color=1; //reference = 1 for all triangles since it has not been specified 113 t1.SetHidden(OppositeEdge[1]); // two times because the adj was not created 114 t2.SetHidden(OppositeEdge[1]); 115 } 116 } 117 else{ 118 if(verbose>3) printf("No Quadrilaterals found\n"); 119 } 120 121 //hVertices 122 if(bamgmesh->hVertices){ 123 if(verbose>3) printf("Reading hVertices\n"); 124 hvertices=1; 125 for (i=0;i< nbv;i++){ 126 vertices[i].m=Metric((Real4)bamgmesh->hVertices[i]); 127 } 128 } 129 else{ 130 if(verbose>3) printf("No hVertices found\n"); 131 } 132 133 //VertexOnGeometricEdge 134 if(bamgmesh->VertexOnGeometricEdge){ 135 if(verbose>3) printf("Reading VertexOnGeometricEdge\n"); 136 NbVerticesOnGeomEdge=bamgmesh->NumVertexOnGeometricEdge; 137 VerticesOnGeomEdge= new VertexOnGeom[NbVerticesOnGeomEdge] ; 138 for (i=0;i<NbVerticesOnGeomEdge;i++){ 139 Int4 i1,i2; 140 Real8 s; 141 //VertexOnGeom & v =VerticesOnGeomVertex[i0]; 142 i1=(Int4)bamgmesh->VertexOnGeometricEdge[i*3+0]-1; //for C indexing 143 i2=(Int4)bamgmesh->VertexOnGeometricEdge[i*3+1]-1; //for C indexing 144 s =(Int4)bamgmesh->VertexOnGeometricEdge[i*3+2]; 145 VerticesOnGeomEdge[i]=VertexOnGeom(vertices[i1],Gh.edges[i2],s); 146 } 147 } 148 else{ 149 if(verbose>3) printf("No VertexOnGeometricEdge found\n"); 150 } 151 152 //Edges 153 if (bamgmesh->Edges){ 154 int i1,i2; 155 R2 zero2(0,0); 156 Real4 *len =0; 157 158 if(verbose>3) printf("Reading Edges\n"); 159 nbe=bamgmesh->NumEdges; 160 edges = new Edge[nbe]; 161 162 if (!hvertices) { 163 len = new Real4[nbv]; 164 for(i=0;i<nbv;i++) 165 len[i]=0; 166 } 167 168 for (i=0;i<nbe;i++){ 169 i1=(int)bamgmesh->Edges[i*3+0]-1; //-1 for C indexing 170 i2=(int)bamgmesh->Edges[i*3+1]-1; //-1 for C indexing 171 edges[i].v[0]= vertices +i1; 172 edges[i].v[1]= vertices +i2; 173 edges[i].adj[0]=0; 174 edges[i].adj[1]=0; 175 R2 x12 = vertices[i2].r-vertices[i1].r; 176 Real8 l12=sqrt( (x12,x12)); 177 178 if (!hvertices) { 179 vertices[i1].color++; 180 vertices[i2].color++; 181 len[i1]+= l12; 182 len[i2] += l12; 183 } 184 Hmin = Min(Hmin,l12); 185 } 186 187 // definition the default of the given mesh size 188 if (!hvertices){ 189 for (i=0;i<nbv;i++) 190 if (vertices[i].color > 0) 191 vertices[i].m= Metric(len[i] /(Real4) vertices[i].color); 192 else 193 vertices[i].m= Metric(Hmin); 194 delete [] len; 195 } 196 197 // construction of edges[].adj 198 for (i=0;i<nbv;i++){ 199 vertices[i].color = (vertices[i].color ==2) ? -1 : -2; 200 } 201 for (i=0;i<nbe;i++){ 202 for (j=0;j<2;j++) { 203 Vertex *v=edges[i].v[j]; 204 Int4 i0=v->color,j0; 205 if(i0==-1){ 206 v->color=i*2+j; 207 } 208 else if (i0>=0) {// i and i0 edge are adjacent by the vertex v 209 j0 = i0%2; 210 i0 = i0/2; 211 assert( v == edges[i0 ].v[j0]); 212 edges[i ].adj[ j ] =edges +i0; 213 edges[i0].adj[ j0] =edges +i ; 214 assert(edges[i0].v[j0] == v); 215 v->color = -3; 216 } 217 } 218 } 219 } 220 else{ 221 if(verbose>3) printf("No Edges found\n"); 222 } 223 224 //EdgeOnGeometricEdge 225 if(bamgmesh->EdgeOnGeometricEdge){ 226 if(verbose>3) printf("Reading EdgeOnGeometricEdge\n"); 227 int i1,i2,i,j; 228 i2=bamgmesh->NumEdgeOnGeometricEdge; 229 for (i1=0;i1<i2;i1++) { 230 i=(int)bamgmesh->EdgeOnGeometricEdge[i*2+0]; 231 j=(int)bamgmesh->EdgeOnGeometricEdge[i*2+1]; 232 if(!(i>0 && j >0 && i <= nbe && j <= Gh.nbe)) { 233 throw ErrorException(__FUNCT__,exprintf("EdgeOnGeometricEdge error: We must have : (i>0 && j >0 && i <= nbe && j <= Gh.nbe)")); 234 } 235 edges[i-1].on = Gh.edges + j-1; 236 } 237 } 238 else{ 239 if(verbose>3) printf("No EdgeOnGeometricEdge found\n"); 240 } 241 242 //SubDomain 243 if(bamgmesh->SubDomain){ 244 Int4 i3,head,sens; 245 if(verbose>3) printf("Reading SubDomain\n"); 246 NbSubDomains=bamgmesh->NumSubDomain; 247 subdomains = new SubDomain [ NbSubDomains ]; 248 for (i=0;i<NbSubDomains;i++) { 249 i3 =(int)bamgmesh->SubDomain[i*3+0]; 250 head=(int)bamgmesh->SubDomain[i*3+1]-1;//C indexing 251 sens=(int)bamgmesh->SubDomain[i*3+2]; 252 if (i3!=23) throw ErrorException(__FUNCT__,exprintf("Bad Subdomain definition: first number should be 3")); 253 if (head<0 || head>=nbt) throw ErrorException(__FUNCT__,exprintf("Bad Subdomain definition: head should in [1 %i] (triangle number)",nbt)); 254 //subdomains[i].head=i3; //TESTTESTETETETETETETETEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 255 } 256 } 257 else{ 258 if(verbose>3) printf("No SubDomain found\n"); 259 } 260 261 /*Recreate geometry if needed*/ 262 if(1!=0) { 263 printf("Warning: mesh present but no geometry found. Reconstructing...\n"); 264 /*Recreate geometry: */ 265 ConsGeometry(-1); //MaximalAngleOfCorner is actually in BamgGeom... 266 Gh.AfterRead(); 267 } 85 268 } 86 269 … … 419 602 } 420 603 } 421 422 423 604 424 605 … … 965 1146 966 1147 ReadFromMatlabMesh(bamgmesh,bamgargs); 967 printf("ok2\n");968 969 1148 SetIntCoor(); 970 971 1149 FillHoleInMesh(); 972 throw ErrorException(__FUNCT__,exprintf("test test")); 973 974 1150 throw ErrorException(__FUNCT__,exprintf("TEST")); 975 1151 } 976 1152 977 void Geometry::ReadGeometry(const char * filename) 978 { 1153 void Geometry::ReadGeometry(const char * filename) { 979 1154 long int verbosity=0; 980 1155 … … 1238 1413 } 1239 1414 } 1240 1241 1242 1415 1243 1416 void Geometry::ReadGeometry(MeshIstream & f_in,const char * filename)
Note:
See TracChangeset
for help on using the changeset viewer.