Changeset 2853


Ignore:
Timestamp:
01/15/10 09:52:53 (15 years ago)
Author:
Mathieu Morlighem
Message:

began to replace all asserts

File:
1 edited

Legend:

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

    r2851 r2853  
    9595                                nbv++;
    9696                          }
    97                   assert(inbvx == nbv);
     97                  if (inbvx != nbv){
     98                          throw ErrorException(__FUNCT__,exprintf("inbvx != nbv"));
     99                  }
    98100                  for (i=0;i<Tho.nbt;i++)
    99101                        if(  reft[i] >=0 && flag[i])
     
    103105                                int i1 = Tho.Number(t[1]);
    104106                                int i2 = Tho.Number(t[2]);
    105                                 assert(i0>=0 && i1 >= 0 && i2  >= 0);
    106                                 assert(i0<Tho.nbv && i1 <Tho.nbv && i2  <Tho.nbv);
    107                                 // cout <<i<< " F" <<  flag[i] << " T " << nbt << "   = " <<  kk[i0] << " " << kk[i1] << " " << kk[i2] ;
    108                                 // cout << " OT  " <<  i0 << " "  << i1 << " " << i2  << " " << reft[i] << endl;
     107                                if (i0<0 || i1<0 || i2<0){
     108                                        throw ErrorException(__FUNCT__,exprintf("i0<0 || i1<0 || i2< 0"));
     109                                }
     110                                if (i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv){
     111                                        throw ErrorException(__FUNCT__,exprintf("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv"));
     112                                }
    109113                                triangles[nbt] = Triangle(this,kk[i0],kk[i1],kk[i2]);
    110114                                triangles[nbt].color = Tho.subdomains[reft[i]].ref;
    111115                                nbt++;           
    112116                          }
    113                   assert(kt==nbt);
    114                   if (nbt ==0 && nbv ==0) {
     117                  if (kt!=nbt){
     118                          throw ErrorException(__FUNCT__,exprintf("kt!=nbt"));
     119                  }
     120                  if (nbt==0 && nbv==0) {
    115121                          throw ErrorException(__FUNCT__,exprintf("All triangles have been removed"));
    116122                  }
     
    124130                  FillHoleInMesh();
    125131
    126                   assert(NbSubDomains);
    127                   assert(subdomains[0].head && subdomains[0].head->link);
     132                  if (!NbSubDomains){
     133                          throw ErrorException(__FUNCT__,exprintf("NbSubDomains==0"));
     134                  }
     135                  if (!subdomains[0].head || !subdomains[0].head->link){
     136                          throw ErrorException(__FUNCT__,exprintf("!subdomains[0].head || !subdomains[0].head->link"));
     137                  }
    128138
    129139          }
     
    132142        Triangles::~Triangles() {
    133143                long int verbosity=2;
    134                 //assert(NbRef<=0);
    135144                if (CurrentTh == this) CurrentTh=0;
    136145                //if(vertices)  delete [] vertices; //TEST  crash if not commented
     
    189198                  if (NbVerticesOnGeomEdge)
    190199                        VerticesOnGeomEdge = new VertexOnGeom[NbVerticesOnGeomEdge] ;
    191                   if (& BTh == & Th.BTh) // same back ground
    192                          {
     200                  if (& BTh == & Th.BTh){ // same background
    193201                          BTh.NbRef++;
    194202                          NbVertexOnBThVertex = Th.NbVertexOnBThVertex;
     
    199207                                VertexOnBThEdge = new VertexOnEdge[NbVertexOnBThEdge];
    200208                         }
    201                   else
    202                          { // no add on back ground mesh
     209                  else { // no add on background mesh
    203210                          BTh.NbRef++;
    204211                          NbVertexOnBThVertex=0;
     
    206213                          NbVertexOnBThEdge=0;
    207214                          VertexOnBThEdge=0;
    208                           //       assert (& BTh == this); // --- a voir
    209 
    210215                         }
    211216
     
    232237                  quadtree=0;
    233238
    234 
    235                   //  assert(!OutSidesTriangles);
    236239          }
    237240        /*}}}1*/
     
    409412                                                j0 =  i0%2;
    410413                                                i0 =  i0/2;
    411                                                 assert( v ==  edges[i0 ].v[j0]);
     414                                                if (v!=edges[i0 ].v[j0]){
     415                                                        throw ErrorException(__FUNCT__,exprintf("v!=edges[i0 ].v[j0]"));
     416                                                }
    412417                                                edges[i ].adj[ j ] =edges +i0;
    413418                                                edges[i0].adj[ j0] =edges +i ;
    414                                                 assert(edges[i0].v[j0] == v);
    415419                                                v->color = -3;
    416420                                        }
     
    777781                                if(st[k]==-1) st[k]=3*i+j;
    778782                                else if(st[k]>=0) {
    779                                         assert( ! triangles[i].TriangleAdj(j) && !triangles[st[k] / 3].TriangleAdj((int) (st[k]%3)));
     783                                        if (triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))){
     784                                                throw ErrorException(__FUNCT__,exprintf("triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))"));
     785                                        }
    780786                                        triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3));
    781787                                        if (invisible)  triangles[i].SetHidden(j);
     
    873879                                          }
    874880                                  }
    875                                 assert(k==nbe);
     881                                if (k!=nbe){
     882                                        throw ErrorException(__FUNCT__,exprintf("k!=nbe"));
     883                                }
    876884                                if (edgessave) delete [] edgessave;
    877885                          }
     
    898906                                         j0 =  i0%2;
    899907                                         i0 =  i0/2;
    900                                          assert( v ==  edges[i0 ].v[j0]);
     908                                         if (v!=edges[i0 ].v[j0]){
     909                                                 throw ErrorException(__FUNCT__,exprintf("v!=edges[i0 ].v[j0]"));
     910                                         }
    901911                                         edges[i ].adj[ j ] =edges +i0;
    902912                                         edges[i0].adj[ j0] =edges +i ;
    903                                          assert(edges[i0].v[j0] == v);
    904                                          //         if(verbosity>8)
    905                                          //  cout << " edges adj " << i0 << " "<< j0 << " <-->  "  << i << " " << j << endl;
    906913                                         v->color = -3;}
    907914                                }
    908915                        // now reconstruct the sub domain info
    909                         assert(!NbSubDomains);
     916                        if (NbSubDomains){
     917                                throw ErrorException(__FUNCT__,exprintf("NbSubDomains should be 0"));
     918                        }
    910919                        NbSubDomains=0;
    911920
     
    972981                                                }
    973982                                        } 
    974                                 assert(k== NbSubDomains);
     983                                if (k!= NbSubDomains){
     984                                        throw ErrorException(__FUNCT__,exprintf("k!= NbSubDomains"));
     985                                }
    975986
    976987                                delete [] colorT;
     
    10381049
    10391050                        Gh.coefIcoor= (MaxICoor)/(Max(Gh.pmax.x-Gh.pmin.x,Gh.pmax.y-Gh.pmin.y));
    1040                         assert(Gh.coefIcoor >0);
     1051                        if (Gh.coefIcoor<=0){
     1052                                throw ErrorException(__FUNCT__,exprintf("Gh.coefIcoor<=0"));
     1053                        }
    10411054
    10421055                        Real8 hmin = HUGE_VAL;
     
    10681081                                                 Gh.edges[i].SetReverseEqui();
    10691082                                                Gh.edges[i].link= & Gh.edges[j];
    1070                                                 //assert(sens==0);//  meme sens pour l'instant
    10711083                                        }
    10721084
     
    10871099                                len[j1] += l12;
    10881100                                hmin = Min(hmin,l12);
    1089 
    10901101                                Gh.edges[i].ref  = edges[i].ref;
    10911102
    10921103                                k = edge4->addtrie(i0,i1);
    1093 
    1094                                 assert(k == i);
     1104                                if (k != i){
     1105                                        throw ErrorException(__FUNCT__,exprintf("k != i"));
     1106                                }
    10951107
    10961108                          }
     
    11601172                }
    11611173                Edge * e = &BhAB;
    1162                 assert( pA && pB && e);
     1174                if (!pA || !pB || !e){
     1175                        throw ErrorException(__FUNCT__,exprintf("!pA || !pB || !e"));
     1176                }
    11631177                // be carefull the back ground edge e is on same geom edge
    11641178                // of the initiale edge def by the 2 vertex A B;
    1165                 assert(e>=BTh.edges && e<BTh.edges+BTh.nbe);// Is a background Mesh;   
     1179                //check Is a background Mesh;   
     1180                if (e<BTh.edges || e>=BTh.edges+BTh.nbe){
     1181                        throw ErrorException(__FUNCT__,exprintf("e<BTh.edges || e>=BTh.edges+BTh.nbe"));
     1182                }
    11661183                // walk on BTh edge
    1167                 //assert(0 /* not finish ProjectOnCurve with BackGround Mesh*/);
     1184                //not finish ProjectOnCurve with BackGround Mesh);
    11681185                // 1 first find a back ground edge contening the vertex A
    11691186                // 2 walk n back gound boundary to find the final vertex B
     
    11851202                        // cout << " EXCHANGE  A et B) " << endl;
    11861203                  }
    1187                 else
    1188                   { // do the search by walking
    1189                         assert(0 /* A FAIRE */);
     1204                else{ // do the search by walking
     1205                        throw ErrorException(__FUNCT__,exprintf("case not supported yet"));
    11901206                  }
    11911207
     
    12141230                        for ( eee=e,iii=sens,te0=tA;
    12151231                                                eee && ((( void*) eee) != pB) && (( void*) (v1=&((*eee)[iii]))) != pB ;
    1216                                                 neee = eee->adj[iii],iii = 1-neee->Intersection(*eee),eee = neee,v0=v1,te0=1-iii )   
    1217                           {
     1232                                                neee = eee->adj[iii],iii = 1-neee->Intersection(*eee),eee = neee,v0=v1,te0=1-iii ) {
    12181233                                //      cout << kkk << " eee = " << BTh.Number(eee) << "  v0=  "
    12191234                                //     << BTh.Number(v0) << " v1 = " << BTh.Number(v1) << endl;
    12201235
    1221                                 assert(kkk++<100);
    1222                                 assert(eee);
     1236                                kkk=kkk+1;
     1237                                if (kkk>=100){
     1238                                        throw ErrorException(__FUNCT__,exprintf("kkk>=100"));
     1239                                }
     1240                                if (!eee){
     1241                                        throw ErrorException(__FUNCT__,exprintf("!eee"));
     1242                                }
    12231243                                Real8 lg0 = lg;
    12241244                                Real8 dp = LengthInterpole(v0->m,v1->m,(R2) *v1 - (R2) *v0);
    12251245                                lg += dp;
    1226                                 if (cas && abscisse <= lg)
    1227                                   { // ok we find the geom edge
     1246                                if (cas && abscisse <= lg) { // ok we find the geom edge
    12281247                                        Real8 sss  =   (abscisse-lg0)/dp;
    12291248                                        Real8 thetab = te0*(1-sss)+ sss*iii;
    1230                                         assert(thetab>=0 && thetab<=1);
     1249                                        if (thetab<0 || thetab>1){
     1250                                                throw ErrorException(__FUNCT__,exprintf("thetab<0 || thetab>1"));
     1251                                        }
    12311252                                        BR = VertexOnEdge(&R,eee,thetab);
    1232 
    1233                                         // cout << Number(R) << " = " <<  thetab << " on  " <<  BTh.Number(eee)
    1234                                         //       << " = " << R << endl;
    1235 
    12361253                                        return  Gh.ProjectOnCurve(*eee,thetab,R,GR);
    1237 
    12381254                                  }
    12391255                          }
    12401256                        // we find the end
    1241                         if (v1 != pvB)
    1242                           {
     1257                        if (v1 != pvB){
    12431258                                if (( void*) v1 == pB)
    12441259                                 tB = iii;
    12451260
    12461261                                Real8 lg0 = lg;
    1247                                 assert(eee);
     1262                                if (!eee){
     1263                                        throw ErrorException(__FUNCT__,exprintf("!eee"));
     1264                                }
    12481265                                v1 = pvB;
    12491266                                Real8 dp = LengthInterpole(v0->m,v1->m,(R2) *v1 - (R2) *v0);
     
    12541271                                        Real8 sss  =   (abscisse-lg0)/dp;
    12551272                                        Real8 thetab = te0*(1-sss)+ sss*tB;
    1256                                         assert(thetab>=0 && thetab<=1);
     1273                                        if (thetab<0 || thetab>1){
     1274                                                throw ErrorException(__FUNCT__,exprintf("thetab<0 || thetab>1"));
     1275                                        }
    12571276                                        BR = VertexOnEdge(&R,eee,thetab);
    12581277                                        return  Gh.ProjectOnCurve(*eee,thetab,R,GR);
     
    14041423                        if (ong) // a geometrical edges
    14051424                          {
    1406                                 if (withBackground)
    1407                                   {
     1425                                if (withBackground){
    14081426                                        // walk on back ground mesh
    14091427                                        //  newVertexOnBThEdge[ibe++] = VertexOnEdge(vertices[k],bedge,absicsseonBedge);
    14101428                                        // a faire -- difficile
    14111429                                        // the first PB is to now a background edge between the 2 vertices
    1412                                         assert(edgesGtoB);
     1430                                        if (!edgesGtoB){
     1431                                                throw ErrorException(__FUNCT__,exprintf("!edgesGtoB"));
     1432                                        }
    14131433                                        // cout << " ie = " << ie <<"  v0 = " <<  Number(newedges[ie][0]) << endl;
    14141434                                        ong= ProjectOnCurve(*edgesGtoB[Gh.Number(edges[i].on)],
     
    14881508                for (i=0;i<nbt;i++) {
    14891509                        Triangle & t = triangles[i];
    1490                         assert(t.link);
     1510                        if (!t.link){
     1511                                throw ErrorException(__FUNCT__,exprintf("!t.link"));
     1512                        }
    14911513                        for(int j=0;j<3;j++)
    14921514                          {
     
    15861608
    15871609                          }
    1588                         assert (nbinvisible<2);
     1610                        if (nbinvisible>=2){
     1611                                throw ErrorException(__FUNCT__,exprintf("nbinvisible>=2"));
     1612                        }
    15891613                        // cout << " " <<  nbinvisible << " " <<  nbsplitedge << endl;
    15901614                        switch (nbsplitedge) {
     
    15971621                                                  break;
    15981622                        }
    1599                         assert(ksplit[i]>=40);
     1623                        if (ksplit[i]<40){
     1624                                throw ErrorException(__FUNCT__,exprintf("ksplit[i]<40"));
     1625                        }
    16001626                  }
    16011627                //  now do the element split
     
    16171643                        Int4 kk=ksplit[i]/10;
    16181644                        int  ke=(int) (ksplit[i]%10);
    1619                         assert(kk<7 && kk >0);
     1645                        if (kk>=7 || kk<=0){
     1646                                throw ErrorException(__FUNCT__,exprintf("kk>=7 || kk<=0"));
     1647                        }
    16201648
    16211649                        // def the numbering   k (edge) i vertex
     
    16321660                        Vertex * v2=t0(i2);
    16331661
    1634                         // cout << "nbmkadj " << nbmkadj << " it=" << i <<endl;
    1635                         assert(nbmkadj< 10);
     1662                        if (nbmkadj>=10){
     1663                                throw ErrorException(__FUNCT__,exprintf("nbmkadj>=10"));
     1664                        }
    16361665                        // --------------------------
    16371666                        TriangleAdjacent ta0(t0.Adj(i0)),ta1(t0.Adj(i1)),ta2(t0.Adj(i2));
     
    16491678                                                        Triangle &t1=triangles[kkk++];
    16501679                                                        t1=t0;
    1651                                                         assert (kedge[3*i+i0]>=0);
     1680                                                        if (kedge[3*i+i0]<0){
     1681                                                                throw ErrorException(__FUNCT__,exprintf("kedge[3*i+i0]<0"));
     1682                                                        }
    16521683                                                        Vertex * v3 = vertices + kedge[3*i+k0];
    16531684
     
    16631694                                                        Triangle &t2=triangles[kkk++];
    16641695                                                        t2=t1=t0;
    1665                                                         assert (kedge[3*i+k1]>=0);
    1666                                                         assert (kedge[3*i+k2]>=0);
     1696                                                        if (kedge[3*i+k1]<0){
     1697                                                                throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k1]<0"));
     1698                                                        }
     1699                                                        if (kedge[3*i+k2]<0){
     1700                                                                throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k2]<0"));
     1701                                                        }
    16671702
    16681703                                                        Vertex * v01 = vertices + kedge[3*i+k2];
     
    16861721                                                        Triangle &t3=triangles[kkk++];
    16871722                                                        t3=t2=t1=t0;
    1688                                                         assert(kedge[3*i+k0] >=0 && kedge[3*i+k1] >=0 && kedge[3*i+k2] >=0);
     1723                                                        if (kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0){
     1724                                                                throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0"));
     1725                                                        }
    16891726                                                        Vertex * v12 = vertices + kedge[3*i+k0];
    16901727                                                        Vertex * v02 = vertices + kedge[3*i+k1];
     
    17671804                                }
    17681805                        // cout << "  -- " << i << " " << nbmkadj << endl;
    1769                         assert(nbmkadj<=13);// 13 = 6 + 4 + 3
     1806                        if (nbmkadj>13){// 13 = 6 + 4 +
     1807                                throw ErrorException(__FUNCT__,exprintf("nbmkadj>13"));
     1808                        }
    17701809
    17711810                        if (kk==6)  newNbOfQuad+=3;
     
    21032142                                        int rswap =tt[izerodet]->swap(iedge);
    21042143
    2105                                         if (!rswap)
    2106                                           {
    2107                                                 cout << " Pb swap the point s is on a edge =>swap " << iedge << " "  << *tt[izerodet] << endl;
    2108                                           }
    2109                                         assert(rswap);
     2144                                        if (!rswap) {
     2145                                                throw ErrorException(__FUNCT__,exprintf("swap the point s is on a edge"));
     2146                                        }
    21102147                                }
    21112148        }
     
    21662203
    21672204                                quadtree->Add(vi);
    2168                                 assert (tcvi && tcvi->det >= 0) ;// internal
     2205                                if (!tcvi || tcvi->det<0){// internal
     2206                                        throw ErrorException(__FUNCT__,exprintf("!tcvi || tcvi->det < 0"));
     2207                                }
    21692208                                Add(vi,tcvi,dete);
    21702209                                NbSwap += vi.Optim(1);         
     
    22242263                                        Vertex & vj = vertices[iv];
    22252264                                        Int4 j = vj.ReferenceNumber;
    2226                                         assert( &vj== ordre[j]);
     2265                                        if ( &vj!= ordre[j]){
     2266                                                throw ErrorException(__FUNCT__,exprintf("&vj!= ordre[j]"));
     2267                                        }
    22272268                                        if(i!=j)
    22282269                                          { //  for valgring
     
    22312272                                          }
    22322273                                        vj.ReferenceNumber=0;
    2233                                         //      cout << " Add " << Number(vj) << " " << vj
    2234                                         // << "   " <<  Number(vi) << " <--> " << Number(vj) <<endl;
    22352274                                        Triangle *tcvj = FindTriangleContening(vj.i,dete);
    22362275                                        if (tcvj && !tcvj->link){
     
    22382277                                        }
    22392278                                        quadtree->Add(vj);
    2240                                         assert (tcvj && tcvj->det >= 0) ;// internal
    22412279                                        Add(vj,tcvj,dete);
    22422280                                        NbSwap += vj.Optim(1);         
     
    23172355                                // we can change first_np_or_next_t[i]
    23182356                                //      cout << " Do the triangle " << i << " Next_t=" << next_t << endl;
    2319                                 assert(i>=0 && i < nbt );
     2357                                if (i<0 || i>=nbt ){
     2358                                        throw ErrorException(__FUNCT__,exprintf("i<0 || i>=nbt"));
     2359                                }
    23202360                                first_np_or_next_t[i] = iter;
    23212361                                for(j=0;j<3;j++)
     
    23662406                                        if (first_np_or_next_t[kt]>0)
    23672407                                         first_np_or_next_t[kt]=-Headt,Headt=kt;
    2368                                         assert( ta.EdgeVertex(0) == s);
     2408                                        if (ta.EdgeVertex(0)!=s){
     2409                                                throw ErrorException(__FUNCT__,exprintf("ta.EdgeVertex(0)!=s"));
     2410                                        }
    23692411                                        ta = Next(Adj(ta));
    23702412                                } while ( (tbegin != (Triangle*) ta));
     
    24442486                                trace =  TRACETRIANGLE <0 ? 1 : i == TRACETRIANGLE;
    24452487#endif
    2446                                 //      cout << " Do the triangle " << i << " Next_t=" << next_t << endl;
    24472488                                assert(i>=0 && i < nbt );
    24482489                                first_np_or_next_t[i] = nbv; // to save the fist new point of triangle
Note: See TracChangeset for help on using the changeset viewer.