Changeset 2944 for issm/trunk


Ignore:
Timestamp:
02/02/10 16:59:40 (15 years ago)
Author:
Mathieu Morlighem
Message:

minor

Location:
issm/trunk/src/c/Bamgx/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Bamgx/objects/Triangles.cpp

    r2942 r2944  
    26282628                //initialize this
    26292629                PreInit(inbvx);
    2630 
    2631                 //build background mesh flag (1 if background, else 0)
    2632                 int  background = &BTh != this;
    26332630                nbv=0;
    26342631                NbVerticesOnGeomVertex=0;
    26352632                NbVerticesOnGeomEdge=0;
    26362633
     2634                //build background mesh flag (1 if background, else 0)
     2635                int  background=(&BTh != this);
     2636
    26372637                //Compute number of vertices on geometrical vertex
    26382638                for (i=0;i<Gh.nbv;i++){
    2639                         if (Gh[i].Required() && Gh[i].IsThe() ) NbVerticesOnGeomVertex++;
     2639                        if (Gh[i].Required() && Gh[i].IsThe()) NbVerticesOnGeomVertex++;
    26402640                }
    26412641
     
    27012701                                // a good curve (not dup)
    27022702                                if (!ei.Dup()){
     2703
    27032704                                        for(int j=0;j<2;j++) {
     2705
    27042706                                                if (!ei.Mark() && ei[j].Required()) {
    27052707                                                        // warning ei.Mark() can be change in loop for(j=0;j<2;j++)
     
    28102812                                                                                                VerticesOnGeomEdge[NbVerticesOnGeomEdge++]= VertexOnGeom(*vb,*e,abcisse);       
    28112813
    2812                                                                                                 // to take into account the sens of the edge
     2814                                                                                                // to take into account the direction of the edge
    28132815                                                                                                s += lstep;
    28142816                                                                                                edges[nbe].v[0]=va;
     
    33073309                long int verbosity=2;
    33083310                if (verbosity>2) printf("   Insert initial %i vertices\n",nbv);
    3309                 Triangles * OldCurrentTh =CurrentTh;
    3310 
     3311                Triangles* OldCurrentTh=CurrentTh;
    33113312                CurrentTh=this;
    33123313                SetIntCoor();
    33133314                Int4 i;
     3315
     3316                //fill out ordre with the adresses of each vertex
    33143317                for (i=0;i<nbv;i++) ordre[i]= &vertices[i] ;
    33153318
    3316                 // construction d'un ordre aleatoire
     3319                //Build a random order
    33173320                const Int4 PrimeNumber= AGoodNumberPrimeWith(nbv) ;
    33183321                Int4 k3 = rand()%nbv ;
     
    33253328                        }
    33263329                }
    3327                 // echange i et 2 dans ordre afin
    3328                 // que les 3 premiers ne soit pas aligne
    3329                 Exchange( ordre[2], ordre[i]);
    3330 
    3331                 // on ajoute un point a l'infini pour construire le maillage
    3332                 // afin d'avoir une definition simple des aretes frontieres
     3330                // 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
    33333336                nbt = 2;
    33343337
    3335                 // on construit un maillage trivale forme
    3336                 // d'une arete et de 2 triangles
    3337                 // construit avec le 2 aretes orientes et
     3338                // We build a trivial mesh from one edge
     3339                // and 2 triangles built with the 2 oriented
     3340                // et
    33383341                Vertex *  v0=ordre[0], *v1=ordre[1];
    33393342
    3340                 triangles[0](0) = 0; // sommet pour infini
     3343                triangles[0](0) = 0; //infinite vertex
    33413344                triangles[0](1) = v0;
    33423345                triangles[0](2) = v1;
    33433346
    3344                 triangles[1](0) = 0;// sommet pour infini
     3347                triangles[1](0) = 0;//infinite vertex
    33453348                triangles[1](2) = v0;
    33463349                triangles[1](1) = v1;
     
    33523355                triangles[0].SetAdj2(e2, &triangles[1] ,e1);
    33533356
    3354                 triangles[0].det = -1;  // faux triangles
    3355                 triangles[1].det = -1;  // faux triangles
     3357                triangles[0].det = -1;  //boundary triangle: det = -1
     3358                triangles[1].det = -1;  //boundary triangle: det = -1
    33563359
    33573360                triangles[0].SetTriangleContainingTheVertex();
     
    33613364                triangles[1].link=&triangles[0];
    33623365
    3363                 //  nbtf = 2;
    3364                 if (  !quadtree )  quadtree = new QuadTree(this,0);
     3366                //build quadtree
     3367                if (!quadtree)  quadtree = new QuadTree(this,0);
    33653368                quadtree->Add(*v0);
    33663369                quadtree->Add(*v1);
     
    33733376
    33743377                for (Int4 icount=2; icount<nbv; icount++) {
    3375                         Vertex *vi  = ordre[icount];
     3378                        Vertex *vi=ordre[icount];
    33763379                        Icoor2 dete[3];
    33773380                        Triangle *tcvi = FindTriangleContening(vi->i,dete);
     
    38743877                triangles=0;
    38753878                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);
    38963879        }
    38973880
  • issm/trunk/src/c/Bamgx/objects/Vertex.cpp

    r2941 r2944  
    1919        /*Methods*/
    2020        /*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;
    2323                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;
    2726
    2827                register int k=0,kk=0,j = EdgesVertexTriangle[vint][0],jc;
     
    3130                        k++;
    3231
    33                         if (!tria->Hidden(j))
    34                           {
     32                        if (!tria->Hidden(j)){
    3533                                Vertex &vQ = (*tria)[VerticesOfTriangularEdge[j][0]];
    3634
     
    3937                                PNew += Q+QP/Max(lQP,1e-20);
    4038                                kk ++;
    41                           }
     39                        }
    4240                        ttc =  tria->TriangleAdj(j);
    4341                        jc = NextEdge[tria->NuEdgeTriangleAdj(j)];
     
    5452                Real8 delta=Norme2_2(Xmove);
    5553
    56 
    57                 //
    5854                Icoor2 deta[3];
    5955                I2 IBTh  = BTh.toI2(PNew);
     
    6157                tstart=BTh.FindTriangleContening(IBTh,deta,tstart); 
    6258
    63                 if (tstart->det <0)
    64                   { // outside
     59                if (tstart->det <0){ // outside
    6560                        double ba,bb;
    6661                        TriangleAdjacent edge= CloseBoundaryEdge(IBTh,tstart,ba,bb) ;
    6762                        tstart = edge;
    6863                        vP.m= Metric(ba,*edge.EdgeVertex(0),bb,*edge.EdgeVertex(1));
    69                   }
    70                 else
    71                   { // inside
     64                }
     65                else { // inside
    7266                        Real8   aa[3];
    7367                        Real8 s = deta[0]+deta[1]+deta[2];
     
    7670                        aa[2]=deta[2]/s;
    7771                        vP.m = Metric(aa,(*tstart)[0],(*tstart)[1],(*tstart)[2]);
    78                   }
     72                }
    7973
    8074                // recompute the det of the triangle
     
    8882                int loop=1;
    8983                k=0;
    90                 while (ok)
    91                   {
     84                while (ok){
    9285                        ok =0;
    9386                        do {
     
    9588                                double detold = tria->det;
    9689                                tria->det =  bamg::det( (*tria)[0],(*tria)[1]  ,(*tria)[2]);
    97                                 if (loop)
    98                                   {
     90                                if (loop) {
    9991                                        Vertex *v0,*v1,*v2,*v3;
    10092                                        if (tria->det<0) ok =1;                       
     
    109101                                        else if ( (double)tria->det < detold/2 ) ok=1;
    110102
    111                                   }
     103                                }
    112104                                tria->SetUnMarkUnSwap(0);
    113105                                tria->SetUnMarkUnSwap(1);
     
    120112                                        throw ErrorException(__FUNCT__,exprintf("k>=2000"));
    121113                                }
    122                         } while ( tbegin != tria);
     114                        }while ( tbegin != tria);
     115
    123116                        if (ok && loop) vP=vPsave; // no move
    124117                        loop=0;
    125                   }
     118                }
    126119                return delta;
    127120        }
Note: See TracChangeset for help on using the changeset viewer.