Changeset 3325
- Timestamp:
- 03/24/10 09:37:10 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx/objects
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/CrackedEdge.cpp
r3263 r3325 14 14 15 15 /*Methods*/ 16 /*FUNCTION CrackedEdge::Crack {{{1*/17 void CrackedEdge::Crack() {18 a.Crack();19 b.Crack();20 }21 /*}}}*/22 /*FUNCTION CrackedEdge::UnCrack {{{1*/23 void CrackedEdge::UnCrack() {24 a.UnCrack();25 b.UnCrack();26 }27 /*}}}*/28 /*FUNCTION {{{1*/29 void CrackedEdge::Set(){30 a.Set();31 b.Set();}32 /*}}}*/33 16 34 17 } -
issm/trunk/src/c/Bamgx/objects/CrackedEdge.h
r3280 r3325 21 21 class CrackedEdge { 22 22 23 friend class Triangles; 24 25 class CrackedTriangle { 26 friend class Triangles; 27 friend class CrackedEdge; 28 Triangle* t; // edge of triangle t 29 int i; // edge number of in triangle 30 Edge *edge; // the 2 edge 31 Vertex *New[2]; // new vertex number 32 33 //Constructors 34 CrackedTriangle() : t(0),i(0),edge(0) { New[0]=New[1]=0;} 35 CrackedTriangle(Edge * a) : t(0),i(0),edge(a) { New[0]=New[1]=0;} 36 37 //Methods 38 void Crack(); 39 void UnCrack(); 40 void Set(); 41 }; 42 43 public: 44 CrackedTriangle a,b; 23 Triangle a,b; 45 24 46 25 //Constructors 47 26 CrackedEdge() :a(),b() {} 48 CrackedEdge(Edge * start, long i,long j) : a(start+i),b(start+j) {};49 CrackedEdge(Edge * e0, Edge * e1 ) : a(e0),b(e1) {};50 27 51 28 //Methods 52 void Crack();53 void UnCrack();54 void Set();55 29 }; 56 57 /*Intermediary*/58 inline TriangleAdjacent FindTriangleAdjacent(Edge &E){59 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp)*/60 61 Vertex * a = E.v[0];62 Vertex * b = E.v[1];63 64 Triangle * t = a->t;65 int i = a->vint;66 TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge67 if (!t || i<0 || i>=3){68 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3"));69 }70 if ( a!=(*t)(i)){71 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)"));72 }73 int k=0;74 do { // turn around vertex in direct sens (trigo)75 k++;76 if (k>=20000){77 throw ErrorException(__FUNCT__,exprintf("k>=20000"));78 }79 // in no crack => ta.EdgeVertex(1) == a otherwise ???80 if (ta.EdgeVertex(1) == a && ta.EdgeVertex(0) == b) return ta; // find81 ta = ta.Adj();82 if (ta.EdgeVertex(0) == a && ta.EdgeVertex(1) == b) return ta; // find83 --ta;84 } while (t != (Triangle *)ta);85 throw ErrorException(__FUNCT__,exprintf("FindTriangleAdjacent: triangle not found"));86 return TriangleAdjacent(0,0);//for compiler87 }88 inline Vertex* TheVertex(Vertex * a){// for remove crak in mesh89 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp)*/90 91 // give a unique vertex with smallest number92 // in case on crack in mesh93 Vertex * r(a), *rr;94 Triangle * t = a->t;95 int i = a->vint;96 TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge97 if (!t || i<0 || i>=3){98 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3"));99 }100 if ( a!=(*t)(i)){101 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)"));102 }103 int k=0;104 do { // turn around vertex in direct sens (trigo)105 k++;106 if (k>=20000){107 throw ErrorException(__FUNCT__,exprintf("k>=20000"));108 }109 // in no crack => ta.EdgeVertex(1) == a110 if ((rr=ta.EdgeVertex(0)) < r) r = rr;111 ta = ta.Adj();112 if ((rr=ta.EdgeVertex(1)) < r) r =rr;113 --ta;114 } while (t != (Triangle*) ta);115 return r;116 }117 30 118 31 } -
issm/trunk/src/c/Bamgx/objects/CrackedTriangle.cpp
r3263 r3325 14 14 15 15 /*Methods*/ 16 /*FUNCTION CrackedEdge::CrackedTriangle::Crack{{{1*/17 void CrackedEdge::CrackedTriangle::Crack(){18 Triangle & T(*t);19 int i0=VerticesOfTriangularEdge[i][0];20 int i1=VerticesOfTriangularEdge[i][0];21 if (!New[0] && !New[1]){22 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]"));23 }24 T(i0) = New[0];25 T(i1) = New[1];26 }27 /*}}}*/28 /*FUNCTION CrackedEdge::CrackedTriangle::UnCrack {{{1*/29 void CrackedEdge::CrackedTriangle::UnCrack(){30 Triangle & T(*t);31 int i0=VerticesOfTriangularEdge[i][0];32 int i1=VerticesOfTriangularEdge[i][0];33 if (!New[0] && !New[1]){34 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]"));35 }36 T(i0) = TheVertex(T(i0));37 T(i1) = TheVertex(T(i1));38 }39 /*}}}*/40 /*FUNCTION CrackedEdge::CrackedTriangle::Set {{{1*/41 void CrackedEdge::CrackedTriangle::Set(){42 TriangleAdjacent ta( FindTriangleAdjacent(*edge));43 t = ta;44 i = ta;45 46 New[0] = ta.EdgeVertex(0);47 New[1] = ta.EdgeVertex(1);48 // warning the ref49 }50 /*}}}*/51 16 52 17 } -
issm/trunk/src/c/Bamgx/objects/Geometry.cpp
r3322 r3325 182 182 } 183 183 184 //CrackedEdges185 if (bamggeom->CrackedEdges){186 if(verbose>5) printf(" processing CrackedEdges\n");187 for (i=0;i<bamggeom->CrackedEdgesSize[0];i++){188 throw ErrorException(__FUNCT__,exprintf("Not implemented yet"));189 }190 }191 else{192 if(verbose>5) printf(" no CrackedEdges found\n");193 }194 195 184 //hVertices 196 185 if(bamggeom->hVertices){ … … 202 191 } 203 192 } 204 else{205 if(verbose>5) printf(" no hVertices found\n");206 }207 193 208 194 //MetricVertices … … 212 198 vertices[i].m = Metric((double)bamggeom->MetricVertices[i*3+0],(double)bamggeom->MetricVertices[i*3+1],(double)bamggeom->MetricVertices[i*3+2]); 213 199 } 214 }215 else{216 if(verbose>5) printf(" no MetricVertices found\n");217 200 } 218 201 … … 229 212 } 230 213 } 231 else{232 if(verbose>5) printf(" no h1h2VpVertices found\n");233 }234 214 235 215 //MaximalAngleOfCorner … … 237 217 if(verbose>5) printf(" processing MaximalAngleOfCorner\n"); 238 218 MaximalAngleOfCorner=bamgopts->MaximalAngleOfCorner*Pi/180; 239 }240 else{241 if(verbose>5) printf(" no MaximalAngleOfCorner found\n");242 219 } 243 220 … … 260 237 edges[i].tg[j] = tg; 261 238 } 262 }263 else{264 if(verbose>5) printf(" no TangentAtEdges found\n");265 239 } 266 240 … … 278 252 vertices[j].SetRequired(); } 279 253 } 280 else{281 if(verbose>5) printf(" no Corners found\n");282 }283 254 284 255 //RequiredVertices … … 294 265 vertices[j].SetRequired(); } 295 266 } 296 else{297 if(verbose>5) printf(" no RequiredVertices found\n");298 }299 267 300 268 //RequiredEdges … … 310 278 edges[j].SetRequired(); 311 279 } 312 }313 else{314 if(verbose>5) printf(" no RequiredEdges found\n");315 280 } 316 281 … … 334 299 } 335 300 } 336 else{337 if(verbose>5) printf(" no SubDomains found\n");338 }339 301 } 340 302 /*}}}1*/ … … 384 346 //update counters 385 347 if (edges[i].Required()) nbreq++; 386 if (edges[i].Cracked()){387 if (i<=Number(edges[i].link)) nbcracked++;388 }389 348 if (edges[i].TgA() && edges[i][0].Corner()) nbtan++; 390 349 if (edges[i].TgB() && edges[i][1].Corner()) nbtan++; 391 }392 }393 394 /*CrackedEdges*/395 if(verbose>5) printf(" writing CrackedEdges\n");396 bamggeom->CrackedEdgesSize[0]=nbcracked;397 bamggeom->CrackedEdgesSize[1]=2;398 if (nbcracked){399 bamggeom->CrackedEdges=(double*)xmalloc(2*nbcracked*sizeof(double));400 count=0;401 for (i=0;i<nbe;i++){402 if (edges[i].Cracked()){403 if (i<=Number(edges[i].link)){404 bamggeom->CrackedEdges[count*2+0]=i+1; //back to Matlab indexing405 bamggeom->CrackedEdges[count*2+1]=Number(edges[i].link)+1; //back to Matlab indexing406 count=count+1;407 }408 }409 350 } 410 351 } … … 543 484 } 544 485 throw ErrorException(__FUNCT__,exprintf("See above")); 545 }546 547 // verification of cracked edge (to be completed)548 for (i=0;i<nbe;i++){549 if (edges[i].Cracked() ) {550 // verification of crack551 GeometricalEdge & e1=edges[i];552 GeometricalEdge & e2=*e1.link;553 if ( e1[0].The() == e2[0].The() && e1[1].The() == e2[1].The() )554 {555 //nothing556 }557 else558 if ( e1[0].The() == e2[1].The() && e1[1].The() == e2[0].The() )559 {560 //nothing561 }562 else {563 throw ErrorException(__FUNCT__,exprintf("Cracked edges with no same vertex"));564 }565 }566 486 } 567 487 -
issm/trunk/src/c/Bamgx/objects/TriangleAdjacent.cpp
r3263 r3325 27 27 } 28 28 /*}}}*/ 29 /*FUNCTION TriangleAdjacent::Cracked {{{1*/30 int TriangleAdjacent::Cracked() const {31 return t->TriaAdjSharedEdge[a] & 32;32 }33 /*}}}*/34 29 /*FUNCTION TriangleAdjacent::GetAllFlag_UnSwap {{{1*/ 35 30 int TriangleAdjacent::GetAllFlag_UnSwap() const { … … 41 36 void TriangleAdjacent::SetLock(){ 42 37 t->SetLocked(a); 43 }44 /*}}}*/45 /*FUNCTION TriangleAdjacent::SetCracked {{{1*/46 void TriangleAdjacent::SetCracked() {47 t->SetCracked(a);48 38 } 49 39 /*}}}*/ -
issm/trunk/src/c/Bamgx/objects/TriangleAdjacent.h
r3280 r3325 38 38 int Locked() const; 39 39 int MarkUnSwap() const; 40 int Cracked() const;41 40 int GetAllFlag_UnSwap() const; 42 41 void SetLock(); 43 void SetCracked();44 42 void SetAdj2(const TriangleAdjacent &ta, int l=0); 45 43 int swap(); -
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r3323 r3325 481 481 else{ 482 482 if(verbose>5) printf(" no Edges found\n"); 483 }484 485 //CrackedEdges486 if(bamgmesh->CrackedEdges){487 if(verbose>5) printf(" processing CrackedEdges\n");488 NbCrackedEdges=bamgmesh->CrackedEdgesSize[0];489 CrackedEdges=new CrackedEdge[NbCrackedEdges];490 for (i=0;i<NbCrackedEdges;i++){491 //CrackedEdges[i].a.edge=bamgmesh->CrackedEdges[i*2+0]-1; //C indexing492 //CrackedEdges[i].b.edge=bamgmesh->CrackedEdges[i*1+0]-1; //C indexing493 throw ErrorException(__FUNCT__,exprintf("not implemented yet"));494 }495 }496 else{497 if(verbose>5) printf(" no CrackedEdges found\n");498 483 } 499 484 … … 718 703 } 719 704 720 /*CrackedEdges*/721 if(verbose>5) printf(" writing CrackedEdges\n");722 bamgmesh->CrackedEdgesSize[0]=NbCrackedEdges;723 bamgmesh->CrackedEdgesSize[1]=2;724 if (NbCrackedEdges){725 bamgmesh->CrackedEdges=(double*)xmalloc(2*NbCrackedEdges*sizeof(double));726 for (i=0;i<NbCrackedEdges;i++){727 bamgmesh->CrackedEdges[i*2+0]=Number(CrackedEdges[i].a.edge)+1; //back to M indexing728 bamgmesh->CrackedEdges[i*2+1]=Number(CrackedEdges[i].b.edge)+1; //back to M indexing729 }730 }731 732 705 /*Triangles*/ 733 706 if(verbose>5) printf(" writing Triangles\n"); … … 2193 2166 } 2194 2167 /*}}}1*/ 2195 /*FUNCTION Triangles::Crack{{{1*/2196 int Triangles::Crack() {2197 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Crack)*/2198 if (NbCrackedEdges!=0 && NbCrackedVertices<=0);{2199 throw ErrorException(__FUNCT__,exprintf("NbCrackedEdges!=0 && NbCrackedVertices<=0"));2200 }2201 for (int i=0;i<NbCrackedEdges;i++) CrackedEdges[i].Crack();2202 return NbCrackedEdges;2203 }2204 /*}}}1*/2205 /*FUNCTION Triangles::CrackMesh{{{1*/2206 int Triangles::CrackMesh() {2207 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/CrackMesh)*/2208 2209 int verbosity=0;2210 int i,k;2211 // computed the number of cracked edge2212 for (k=i=0;i<nbe;i++)2213 if(edges[i].onGeometry->Cracked()) k++;2214 if( k==0) return 0;2215 printf(" number of Cracked Edges = %i\n",k);2216 NbCrackedEdges =k;2217 CrackedEdges = new CrackedEdge[k];2218 // new edge2219 Edge * e = new Edge[ nbe + k];2220 2221 // copy2222 for (i=0;i<nbe;i++)2223 e[i] = edges[i];2224 delete edges;2225 edges = e;2226 2227 const int nbe0 = nbe;2228 for (k=i=0;i<nbe0;i++) // on double les arete cracked2229 if(edges[i].onGeometry->Cracked())2230 {2231 e[nbe] = e[i];2232 // return the edge2233 e[nbe].v[0] = e[i].v[1];2234 e[nbe].v[1] = e[i].v[0];2235 e[nbe].onGeometry = e[i].onGeometry->link ; // faux2236 CrackedEdges[k++]=CrackedEdge(edges,i,nbe);2237 nbe++;2238 }2239 ReMakeTriangleContainingTheVertex() ;2240 //2241 int nbcrakev =0;2242 Vertex *vlast = vertices + nbv;2243 Vertex *vend = vertices + nbvx; // end of array2244 for (int iv=0;iv<nbv;iv++) // vertex2245 {2246 Vertex & v= vertices[iv];2247 Vertex * vv = & v;2248 int kk=0; // nb cracked2249 int kc=0;2250 int kkk =0; // nb triangle with same number2251 Triangle * tbegin = v.t;2252 int i = v.vint;2253 if (!tbegin || (i<0) || (i>=3)){2254 throw ErrorException(__FUNCT__,exprintf("!tbegin || (i<0) || (i>=3)"));2255 }2256 // turn around the vertex v2257 TriangleAdjacent ta(tbegin,EdgesVertexTriangle[i][0]);// previous edge2258 int k=0;2259 do {2260 int kv = VerticesOfTriangularEdge[ta][1];2261 k++;2262 Triangle * tt (ta);2263 if ( ta.Cracked() )2264 {2265 TriangleAdjacent tta=(ta.Adj());2266 if (!tta.Cracked()){2267 throw ErrorException(__FUNCT__,exprintf("!tta.Cracked()"));2268 }2269 if ( kk == 0) tbegin=ta,kkk=0; // begin by a cracked edge => restart2270 if ( kkk ) { kc =1;vv = vlast++; kkk = 0; } // new vertex if use2271 kk++;// number of cracked edge view2272 }2273 if ( tt->link ) { // if good triangles store the value2274 int it = Number(tt);2275 if (it>=nt){2276 throw ErrorException(__FUNCT__,exprintf("(it>=nt)"));2277 }2278 (*tt)(kv)= vv; // Change the vertex of triangle2279 if(vv<vend) {*vv= v;vv->ReferenceNumber=iv;} // copy the vertex value + store the old vertex number in ref2280 // tt->SetTriangleContainingTheVertex();2281 kkk++;2282 } else if (kk) { // crack + boundary2283 if ( kkk ) { kc =1;vv = vlast++; kkk = 0; } // new vertex if use2284 }2285 2286 ta = Next(ta).Adj();2287 } while ( (tbegin != ta));2288 if (!k){2289 throw ErrorException(__FUNCT__,exprintf("!k"));2290 }2291 if (kc) nbcrakev++;2292 }2293 2294 if ( nbcrakev )2295 for (int iec =0;iec < NbCrackedEdges; iec ++)2296 CrackedEdges[iec].Set();2297 2298 // set the ref2299 NbCrackedVertices = nbcrakev;2300 // int nbvo = nbv;2301 nbv = vlast - vertices;2302 int nbnewv = nbv - nbv; // nb of new vrtices2303 if (nbcrakev && verbosity > 1 ) printf(" number of Cracked vertices = %i, number of created vertices = %i\n",nbcrakev,nbnewv);2304 // all the new vertices are on geometry2305 if (nbnewv)2306 { //2307 long n = nbnewv+NbVerticesOnGeomVertex;2308 long i,j,k;2309 VertexOnGeom * vog = new VertexOnGeom[n];2310 for ( i =0; i<NbVerticesOnGeomVertex;i++)2311 vog[i]=VerticesOnGeomVertex[i];2312 delete [] VerticesOnGeomVertex;2313 VerticesOnGeomVertex = vog;2314 // loop on cracked edge2315 Vertex * LastOld = vertices + nbv - nbnewv;2316 for (int iec =0;iec < NbCrackedEdges; iec ++)2317 for (k=0;k<2;k++)2318 {2319 Edge & e = *( k ? CrackedEdges[iec].a.edge : CrackedEdges[iec].b.edge);2320 for (j=0;j<2;j++)2321 {2322 Vertex * v = e(j);2323 if ( v >= LastOld)2324 { // a new vertex2325 long old = v->ReferenceNumber ; // the old same vertex2326 long i = ( v - LastOld);2327 // if the old is on vertex => warning2328 // else the old is on edge => ok2329 vog[i] = vog[old];2330 // vog[i].mv = v;2331 //g[i].ge = ;2332 //og[i].abcisse = ;2333 }2334 2335 }2336 }2337 2338 NbVerticesOnGeomVertex = n;2339 }2340 SetVertexFieldOn();2341 2342 if (vlast >= vend) {2343 throw ErrorException(__FUNCT__,exprintf("Not enougth vertices: to crack the mesh we need %i vertices",nbv));2344 }2345 return NbCrackedVertices;2346 }2347 /*}}}1*/2348 2168 /*FUNCTION Triangles::ForceBoundary{{{1*/ 2349 2169 void Triangles::ForceBoundary() { … … 2381 2201 throw ErrorException(__FUNCT__,exprintf("Missing Edge %i, v0=%i,v1=%i",i,Number(edges[i][0]),Number(edges[i][1]))); 2382 2202 } 2383 if ( nbswp >=0 && edges[i].onGeometry->Cracked())2384 ta.SetCracked();2385 2203 } 2386 2204 … … 3928 3746 NbVertexOnBThVertex=0; 3929 3747 NbVertexOnBThEdge=0; 3930 VertexOnBThVertex= 0;3931 VertexOnBThEdge= 0;3748 VertexOnBThVertex=NULL; 3749 VertexOnBThEdge=NULL; 3932 3750 3933 3751 NbCrackedVertices=0; 3934 NbCrackedEdges =0;3935 CrackedEdges =0;3752 NbCrackedEdges =0; 3753 CrackedEdges =NULL; 3936 3754 nbe = 0; 3937 3755 … … 3951 3769 } 3952 3770 else { 3953 vertices= 0;3954 ordre= 0;3955 triangles= 0;3771 vertices=NULL; 3772 ordre=NULL; 3773 triangles=NULL; 3956 3774 nbtx=0; 3957 3775 } 3958 3776 3959 quadtree= 0;3960 edges= 0;3961 VerticesOnGeomVertex= 0;3962 VerticesOnGeomEdge= 0;3777 quadtree=NULL; 3778 edges=NULL; 3779 VerticesOnGeomVertex=NULL; 3780 VerticesOnGeomEdge=NULL; 3963 3781 NbVerticesOnGeomVertex=0; 3964 3782 NbVerticesOnGeomEdge=0; 3965 subdomains= 0;3783 subdomains=NULL; 3966 3784 NbSubDomains=0; 3967 3785 } … … 5467 5285 } 5468 5286 /*}}}1*/ 5469 /*FUNCTION Triangles::UnCrack{{{1*/5470 int Triangles::UnCrack() {5471 /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/UnCrack)*/5472 5473 if (NbCrackedEdges!=0 && NbCrackedVertices<=0);{5474 throw ErrorException(__FUNCT__,exprintf("NbCrackedEdges ==0 || NbCrackedVertices >0"));5475 }5476 for (int i=0;i<NbCrackedEdges;i++)5477 CrackedEdges[i].UnCrack();5478 return NbCrackedEdges;5479 }5480 /*}}}1*/5481 5287 5482 5288 /*Intermediary*/ -
issm/trunk/src/c/Bamgx/objects/Triangles.h
r3301 r3325 59 59 long NbCrackedVertices; 60 60 long NbCrackedEdges; 61 CrackedEdge *CrackedEdges;61 CrackedEdge* CrackedEdges; 62 62 R2 pmin,pmax; // extrema 63 63 double coefIcoor; // coef to integer Icoor1; … … 143 143 void AddGeometryMetric(BamgOpts* bamgopts); 144 144 int isCracked() const {return NbCrackedVertices != 0;} 145 int Crack();146 int UnCrack();147 145 void BuildGeometryFromMesh(BamgOpts* bamgopts=NULL); 148 146 void ReconstructExistingMesh(); 149 int CrackMesh();150 147 151 148 //Inline methods
Note:
See TracChangeset
for help on using the changeset viewer.