Changeset 2944 for issm/trunk
- Timestamp:
- 02/02/10 16:59:40 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r2942 r2944 2628 2628 //initialize this 2629 2629 PreInit(inbvx); 2630 2631 //build background mesh flag (1 if background, else 0)2632 int background = &BTh != this;2633 2630 nbv=0; 2634 2631 NbVerticesOnGeomVertex=0; 2635 2632 NbVerticesOnGeomEdge=0; 2636 2633 2634 //build background mesh flag (1 if background, else 0) 2635 int background=(&BTh != this); 2636 2637 2637 //Compute number of vertices on geometrical vertex 2638 2638 for (i=0;i<Gh.nbv;i++){ 2639 if (Gh[i].Required() && Gh[i].IsThe() 2639 if (Gh[i].Required() && Gh[i].IsThe()) NbVerticesOnGeomVertex++; 2640 2640 } 2641 2641 … … 2701 2701 // a good curve (not dup) 2702 2702 if (!ei.Dup()){ 2703 2703 2704 for(int j=0;j<2;j++) { 2705 2704 2706 if (!ei.Mark() && ei[j].Required()) { 2705 2707 // warning ei.Mark() can be change in loop for(j=0;j<2;j++) … … 2810 2812 VerticesOnGeomEdge[NbVerticesOnGeomEdge++]= VertexOnGeom(*vb,*e,abcisse); 2811 2813 2812 // to take into account the sensof the edge2814 // to take into account the direction of the edge 2813 2815 s += lstep; 2814 2816 edges[nbe].v[0]=va; … … 3307 3309 long int verbosity=2; 3308 3310 if (verbosity>2) printf(" Insert initial %i vertices\n",nbv); 3309 Triangles * OldCurrentTh =CurrentTh; 3310 3311 Triangles* OldCurrentTh=CurrentTh; 3311 3312 CurrentTh=this; 3312 3313 SetIntCoor(); 3313 3314 Int4 i; 3315 3316 //fill out ordre with the adresses of each vertex 3314 3317 for (i=0;i<nbv;i++) ordre[i]= &vertices[i] ; 3315 3318 3316 // construction d'un ordre aleatoire3319 //Build a random order 3317 3320 const Int4 PrimeNumber= AGoodNumberPrimeWith(nbv) ; 3318 3321 Int4 k3 = rand()%nbv ; … … 3325 3328 } 3326 3329 } 3327 // e change i et 2 dans ordre afin3328 // que les 3 premiers ne soit pas aligne3329 Exchange( 3330 3331 // on ajoute un point a l'infini pour construire le maillage3332 // afin d'avoir une definition simple des aretes frontieres3330 // exchange i et 2 in "ordre" so that 3331 // the first 3 vertices are not aligned 3332 Exchange(ordre[2], ordre[i]); 3333 3334 // We add a vertex at the infinity to build the mesh 3335 // so that we have a simple definition of the boundary edges 3333 3336 nbt = 2; 3334 3337 3335 // on construit un maillage trivale forme3336 // d'une arete et de 2 triangles3337 // construit avec le 2 aretes orientes et3338 // We build a trivial mesh from one edge 3339 // and 2 triangles built with the 2 oriented 3340 // et 3338 3341 Vertex * v0=ordre[0], *v1=ordre[1]; 3339 3342 3340 triangles[0](0) = 0; // sommet pour infini3343 triangles[0](0) = 0; //infinite vertex 3341 3344 triangles[0](1) = v0; 3342 3345 triangles[0](2) = v1; 3343 3346 3344 triangles[1](0) = 0;// sommet pour infini3347 triangles[1](0) = 0;//infinite vertex 3345 3348 triangles[1](2) = v0; 3346 3349 triangles[1](1) = v1; … … 3352 3355 triangles[0].SetAdj2(e2, &triangles[1] ,e1); 3353 3356 3354 triangles[0].det = -1; // faux triangles3355 triangles[1].det = -1; // faux triangles3357 triangles[0].det = -1; //boundary triangle: det = -1 3358 triangles[1].det = -1; //boundary triangle: det = -1 3356 3359 3357 3360 triangles[0].SetTriangleContainingTheVertex(); … … 3361 3364 triangles[1].link=&triangles[0]; 3362 3365 3363 // nbtf = 2;3364 if ( !quadtree) quadtree = new QuadTree(this,0);3366 //build quadtree 3367 if (!quadtree) quadtree = new QuadTree(this,0); 3365 3368 quadtree->Add(*v0); 3366 3369 quadtree->Add(*v1); … … 3373 3376 3374 3377 for (Int4 icount=2; icount<nbv; icount++) { 3375 Vertex *vi =ordre[icount];3378 Vertex *vi=ordre[icount]; 3376 3379 Icoor2 dete[3]; 3377 3380 Triangle *tcvi = FindTriangleContening(vi->i,dete); … … 3874 3877 triangles=0; 3875 3878 nbtx=0; 3876 }3877 if ( name || inbvx) {3878 time_t timer =time(0);3879 char buf[70];3880 strftime(buf ,70,", Date: %y/%m/%d %H:%M %Ss",localtime(&timer));3881 counter++;3882 char countbuf[30];3883 sprintf(countbuf,"%d",counter);3884 int lg =0 ;3885 if (&BTh != this && BTh.name)3886 lg = strlen(BTh.name)+4;3887 identity = new char[ lg + strlen(buf) + strlen(countbuf)+ 2 + 10 + ( Gh.name ? strlen(Gh.name) + 4 : 0)];3888 identity[0]=0;3889 if (lg)3890 strcat(strcat(strcat(identity,"B="),BTh.name),", ");3891 3892 if (Gh.name)3893 strcat(strcat(identity,"G="),Gh.name);3894 strcat(strcat(identity,";"),countbuf);3895 strcat(identity,buf);3896 3879 } 3897 3880 -
issm/trunk/src/c/Bamgx/objects/Vertex.cpp
r2941 r2944 19 19 /*Methods*/ 20 20 /*FUNCTION Vertex::Smoothing{{{1*/ 21 Real8 Vertex::Smoothing(Triangles & Th,const Triangles & BTh,Triangle * &tstart ,Real8 omega){22 register Vertex * s =this;21 Real8 Vertex::Smoothing(Triangles &Th,const Triangles &BTh,Triangle* &tstart ,Real8 omega){ 22 register Vertex* s=this; 23 23 Vertex &vP = *s,vPsave=vP; 24 // if (vP.on) return 0;// Don't move boundary vertex 25 26 register Triangle * tbegin= t , *tria = t , *ttc; 24 25 register Triangle* tbegin= t , *tria = t , *ttc; 27 26 28 27 register int k=0,kk=0,j = EdgesVertexTriangle[vint][0],jc; … … 31 30 k++; 32 31 33 if (!tria->Hidden(j)) 34 { 32 if (!tria->Hidden(j)){ 35 33 Vertex &vQ = (*tria)[VerticesOfTriangularEdge[j][0]]; 36 34 … … 39 37 PNew += Q+QP/Max(lQP,1e-20); 40 38 kk ++; 41 39 } 42 40 ttc = tria->TriangleAdj(j); 43 41 jc = NextEdge[tria->NuEdgeTriangleAdj(j)]; … … 54 52 Real8 delta=Norme2_2(Xmove); 55 53 56 57 //58 54 Icoor2 deta[3]; 59 55 I2 IBTh = BTh.toI2(PNew); … … 61 57 tstart=BTh.FindTriangleContening(IBTh,deta,tstart); 62 58 63 if (tstart->det <0) 64 { // outside 59 if (tstart->det <0){ // outside 65 60 double ba,bb; 66 61 TriangleAdjacent edge= CloseBoundaryEdge(IBTh,tstart,ba,bb) ; 67 62 tstart = edge; 68 63 vP.m= Metric(ba,*edge.EdgeVertex(0),bb,*edge.EdgeVertex(1)); 69 } 70 else 71 { // inside 64 } 65 else { // inside 72 66 Real8 aa[3]; 73 67 Real8 s = deta[0]+deta[1]+deta[2]; … … 76 70 aa[2]=deta[2]/s; 77 71 vP.m = Metric(aa,(*tstart)[0],(*tstart)[1],(*tstart)[2]); 78 72 } 79 73 80 74 // recompute the det of the triangle … … 88 82 int loop=1; 89 83 k=0; 90 while (ok) 91 { 84 while (ok){ 92 85 ok =0; 93 86 do { … … 95 88 double detold = tria->det; 96 89 tria->det = bamg::det( (*tria)[0],(*tria)[1] ,(*tria)[2]); 97 if (loop) 98 { 90 if (loop) { 99 91 Vertex *v0,*v1,*v2,*v3; 100 92 if (tria->det<0) ok =1; … … 109 101 else if ( (double)tria->det < detold/2 ) ok=1; 110 102 111 103 } 112 104 tria->SetUnMarkUnSwap(0); 113 105 tria->SetUnMarkUnSwap(1); … … 120 112 throw ErrorException(__FUNCT__,exprintf("k>=2000")); 121 113 } 122 } while ( tbegin != tria); 114 }while ( tbegin != tria); 115 123 116 if (ok && loop) vP=vPsave; // no move 124 117 loop=0; 125 118 } 126 119 return delta; 127 120 }
Note:
See TracChangeset
for help on using the changeset viewer.