Changeset 2854


Ignore:
Timestamp:
01/15/10 11:23:20 (15 years ago)
Author:
Mathieu Morlighem
Message:

replaced all asserts by throw errorexception

Location:
issm/trunk/src/c/Bamgx
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Bamgx/QuadTree.h

    r2841 r2854  
     1#include "../shared/shared.h"
     2#include "../include/macros.h"
     3#include "../toolkits/toolkits.h"
     4
    15namespace bamg {
    26
     
    5862  void  Add( Vertex & w);
    5963
    60   QuadTreeBox* NewQuadTreeBox()
    61   {
    62     ///cout << "NewQuadTreeBox " << sb << " " << sb->bc << " "
    63     //<< sb->be << " " <<lenStorageQuadTreeBox <<endl;
     64  QuadTreeBox* NewQuadTreeBox(){
    6465    if(! (sb->bc<sb->be))
    65         sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb);
     66          sb=new StorageQuadTreeBox(lenStorageQuadTreeBox,sb);
    6667
    67     assert(sb && (sb->bc->n == 0));
     68         if (!sb || (sb->bc->n != 0)){
     69                 throw ErrorException(__FUNCT__,exprintf("!sb || (sb->bc->n != 0)"));
     70         }
    6871    NbQuadTreeBox++;
    6972    return sb->bc++;
  • issm/trunk/src/c/Bamgx/objects/GeometricalEdge.cpp

    r2850 r2854  
    88#include "../QuadTree.h"
    99#include "../SetOfE4.h"
     10
     11#include "../../shared/shared.h"
     12#include "../../include/macros.h"
     13#include "../../toolkits/toolkits.h"
    1014
    1115#undef __FUNCT__
     
    2731                // Real8 t1t1 = t1*t1;
    2832                Real8 tt = theta*theta;
    29                 assert( theta >=0);
    30                 assert( theta <=1);
     33                if ( theta<0){
     34                        throw ErrorException(__FUNCT__,exprintf("theta<0"));
     35                }
     36                if ( theta>1){
     37                        throw ErrorException(__FUNCT__,exprintf("theta>1"));
     38                }
    3139                if (TgA())
    3240                 if (TgB()) // interpolation d'hermite
     
    92100          { R2 A=v[0]->r,B=v[1]->r;
    93101                Real8 ca,cb,cta,ctb;
    94                 assert( theta >=-1e-12);
    95                 assert( theta <=1+1e-12);
     102                if ( theta<-1e-12){
     103                        throw ErrorException(__FUNCT__,exprintf("theta<-1e-12"));
     104                }
     105                if ( theta>1+1e-12){
     106                        throw ErrorException(__FUNCT__,exprintf("theta>1+1e-12"));
     107                }
    96108                if (TgA())
    97109                 if (TgB()) // interpolation d'hermite
  • issm/trunk/src/c/Bamgx/objects/Geometry.cpp

    r2850 r2854  
    4242                for (i=0;i<NbSubDomains;i++)
    4343                 subdomains[i].Set(Gh.subdomains[i],Gh,*this);
    44 
    45                 //    for (i=0;i<nbt;i++)
    46                 //      triangles[i].Set(Gh.triangles[i],Gh,*this);
    47                 assert(!nbt);   
     44                if (nbt);  {
     45                        throw ErrorException(__FUNCT__,exprintf("nbt"));
     46                }
    4847        }
    4948        /*}}}1*/
     
    5251                long int verbosity=0;
    5352
    54                 assert(NbRef<=0);
     53                if (NbRef>0){
     54                        throw ErrorException(__FUNCT__,exprintf("NbRef>0"));
     55                }
    5556                if(verbosity>9)
    5657                 cout << "DELETE      ~Geometry "<< this  << endl;
     
    512513                //  cout << P ;
    513514                int k=0;
    514                 while(pon != on)
    515                   { 
     515                while(pon != on)
     516                        k++;
    516517                        pon = on;
    517                         assert(k++<100);
     518                        if (k>=100){
     519                                throw ErrorException(__FUNCT__,exprintf("k>=100"));
     520                        }
    518521                        R2 A= (*on)[0];
    519522                        R2 B= (*on)[1];
     
    538541retry:   
    539542                s=save_s;
    540                 GeometricalEdge * on = e.on;
    541                 assert(on);
    542                 assert( e[0].on &&  e[1].on);
     543                GeometricalEdge* on = e.on;
     544                if (!on){
     545                        throw ErrorException(__FUNCT__,exprintf("!on"));
     546                }
     547                if (!e[0].on ||  !e[1].on){
     548                        throw ErrorException(__FUNCT__,exprintf("!e[0].on ||  !e[1].on"));
     549                }
    543550                const Vertex &v0=e[0],&v1=e[1];
    544551                V.m = Metric(1.0-s, v0,s, v1);
     
    586593                                        Number(eg0->Adj[1]) <<"," ;
    587594                                ge[--bge] =eg0 = eg0->Adj[sens0];
    588                                 assert(bge>=0 && bge <= mxe);
     595                                if (bge<0 || bge>mxe){
     596                                        throw ErrorException(__FUNCT__,exprintf("bge<0 || bge>mxe"));
     597                                }
    589598                                sens0 = 1-( sensge[bge] = tmpge->SensAdj[sens0]);
    590599                                if(NbTry)
     
    615624                        ge[++tge] =eg1 = eg1->Adj[sens1];
    616625                        sensge[tge]= sens1 = 1-tmpge->SensAdj[sens1];
    617                         assert(tge>=0 && tge <= mxe);
     626                        if (tge<0 || tge>mxe){
     627                                throw ErrorException(__FUNCT__,exprintf("(tge<0 || tge>mxe)"));
     628                        }
    618629                        if(NbTry)
    619630                         cout << "  Edge "  <<  Number(eg1) << " " << sens1 << " S "
     
    648659                        int i=bge;
    649660                        Real8 ll=0;
    650                         for(i=bge;i<tge;i++)
    651                           {
    652                                 assert( i>=0 && i <= mxe);
     661                        for(i=bge;i<tge;i++){
     662                                if ( i<0 || i>mxe){
     663                                        throw ErrorException(__FUNCT__,exprintf("i<0 || i>mxe"));
     664                                }
    653665                                BB =  (*ge[i])[sensge[i]];
    654666                                lge[i]=ll += Norme2(AA-BB);
     
    660672                                //           <<" on = " << Number(ge[tge]) <<  " sens= " << sensge[tge] << endl;
    661673                                // search the geometrical edge
    662                                 assert(s <= 1.0);
     674                                if (s>1.0){
     675                                        throw ErrorException(__FUNCT__,exprintf("s>1.0"));
     676                                }
    663677                                Real8 ls= s*ll;
    664678                                on =0;
     
    668682                                i=bge;
    669683                                while (  (l1=lge[i]) < ls ) {
    670                                         assert(i >= 0 && i <= mxe);
     684                                        if (i<0 || i>mxe){
     685                                                throw ErrorException(__FUNCT__,exprintf("i<0 || i>mxe"));
     686                                        }
    671687                                        i++,s0=1-(s1=sensge[i]),l0=l1;}
    672688                                        on=ge[i];
     
    679695                                        sg =  s0 * (1.0-s) +  s * s1;   
    680696                }
    681                 assert(on);
    682                 // assert(sg && sg-1);
     697                if (!on){
     698                        throw ErrorException(__FUNCT__,exprintf("!on"));
     699                }
    683700                V.r= on->F(sg);
    684701                //  if (eg0 != eg1)
     
    716733                                GeometricalVertex * vg = (GeometricalVertex  *) (void *) v;
    717734                                int j = vg-v0g;
    718                                 assert( v ==  & (Vertex &) vertices[j]);
     735                                if ( v !=  &(Vertex &) vertices[j]){
     736                                        throw ErrorException(__FUNCT__,exprintf(" v !=  &(Vertex &) vertices[j]"));
     737                                }
    719738                                vertices[i].link = vertices + j;
    720739                                k++;         
     
    949968                                          }
    950969
    951                                   }}
    952                                  assert(nbgem && nbe);
     970                                  }
     971                         }
     972                        if (nbgem==0 || nbe==0){
     973                                throw ErrorException(__FUNCT__,exprintf("nbgem==0 || nbe==0"));
     974                        }
    953975
    954976                                 if(step==0) {
     
    961983                        //GeometricalEdge * ee=curves[i].ee, *eqee=be->link;
    962984                        curves[i].master=true;
    963                         if(be->Equi() || be->ReverseEqui() )
    964                           {
    965                                 assert(eqbe);
     985                        if(be->Equi() || be->ReverseEqui() ){
     986                                if (!eqbe){
     987                                        throw ErrorException(__FUNCT__,exprintf("!eqbe"));
     988                                }
    966989                                int nc = eqbe->CurveNumber;
    967                                 assert(i!=nc);
     990                                if (i==nc){
     991                                        throw ErrorException(__FUNCT__,exprintf("i==nc"));
     992                                }
    968993                                curves[i].next=curves[nc].next;
    969994                                curves[i].master=false;
  • issm/trunk/src/c/Bamgx/objects/ListofIntersectionTriangles.cpp

    r2850 r2854  
    6767                        while (t->det <0) { // intersection boundary edge and a,b,
    6868                                k=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
    69                                 assert(k>=0);
     69                                if (k<0){
     70                                        throw ErrorException(__FUNCT__,exprintf("k<0"));
     71                                }
    7072                                ocut = OppositeEdge[k];
    7173                                i=VerticesOfTriangularEdge[ocut][0];
     
    114116                                j=VerticesOfTriangularEdge[iedge][1];
    115117                                Real8 dij = detj-deti;
    116                                 assert(i+j+k == 0 + 1 +2);
     118                                if (i+j+k != 0 + 1 +2){
     119                                        throw ErrorException(__FUNCT__,exprintf("i+j+k != 0 + 1 +2"));
     120                                }
    117121                                ba[j] =  detj/dij;
    118122                                ba[i] = -deti/dij;
     
    268272        Real8  ListofIntersectionTriangles::Length(){
    269273                //  cout << " n= " << Size << ":" ;
    270                 assert(Size>0);
     274                if (Size<=0){
     275                        throw ErrorException(__FUNCT__,exprintf("Size<=0"));
     276                }
    271277                // computation of the length     
    272278                R2 C;
  • issm/trunk/src/c/Bamgx/objects/MetricAnIso.cpp

    r2850 r2854  
    88#include "../QuadTree.h"
    99#include "../SetOfE4.h"
     10
     11#include "../../shared/shared.h"
     12#include "../../include/macros.h"
     13#include "../../toolkits/toolkits.h"
    1014
    1115#undef __FUNCT__
     
    206210                }
    207211                // warning for optimisation S is in [0:0.5] not in [0:1]
    208                 assert(i<512);
     212                if (i>=512){
     213                        throw ErrorException(__FUNCT__,exprintf("i>=512"));
     214                }
    209215                LastMetricInterpole.lab=l;
    210216                LastMetricInterpole.opt=i;
     
    243249                         r =  2*(S[i]*(L[j]-l)+ S[j]*(l-L[i]))/(L[j]-L[i]);
    244250                  }
    245                 assert(r<=1 && r>=0);
     251                if (r>1 || r<0){
     252                        throw ErrorException(__FUNCT__,exprintf("r>1 || r<0"));
     253                }
    246254                return r ;
    247255        }
  • issm/trunk/src/c/Bamgx/objects/QuadTree.cpp

    r2850 r2854  
    55#include "../Mesh2.h"
    66#include "../QuadTree.h"
     7
     8#include "../../shared/shared.h"
     9#include "../../include/macros.h"
     10#include "../../toolkits/toolkits.h"
    711
    812#undef __FUNCT__
     
    3337         sb =new StorageQuadTreeBox(lenStorageQuadTreeBox);
    3438         root=NewQuadTreeBox();
    35          assert( MaxISize > MaxICoor);
     39         if ( MaxISize <= MaxICoor){
     40                 throw ErrorException(__FUNCT__,exprintf("MaxISize <= MaxICoor"));
     41         }
    3642         for (Int4 i=0;i<nbv;i++)
    3743          Add(t->vertices[i]);
     
    373379                        if (b->n > 0 &&  b->v[0] == &w) return;
    374380                }
    375                 assert(l);
     381                if (l==0){
     382                        throw ErrorException(__FUNCT__,exprintf("l==0"));
     383                }
    376384                while ((b= *pb) && (b->n == 4)) // the QuadTreeBox is full
    377385                  {
     
    412420                bc =b;
    413421                be = b +ll;
    414                 assert(b);
     422                if (!b){
     423                        throw ErrorException(__FUNCT__,exprintf("!b"));
     424                }
    415425        }
    416426        /*}}}1*/
  • issm/trunk/src/c/Bamgx/objects/Triangle.cpp

    r2850 r2854  
    3737                        t = ttc;
    3838                        j = NextEdge[jc];
    39                         assert(k<2000);
     39                        if (k>=2000){
     40                                throw ErrorException(__FUNCT__,exprintf("k>=2000"));
     41                        }
    4042                  } while ( (this!= t));
    4143                return TriangleAdjacent(0,0);
  • issm/trunk/src/c/Bamgx/objects/Triangles.cpp

    r2853 r2854  
    24542454                Int4 BeginNewPoint[3];
    24552455                Int4 EndNewPoint[3];
    2456 #ifdef TRACETRIANGLE
    2457                 Int4 trace=0;
    2458 #endif
    24592456                int step[3];
    24602457                Int4 *first_np_or_next_t = new Int4[nbtx];
     
    24802477                        i=Headt;
    24812478                        next_t=-first_np_or_next_t[i];
    2482                         for(t=&triangles[i];i<nbt;t=&triangles[i=next_t],next_t=-first_np_or_next_t[i])
    2483                           { // for each triangle  t
     2479                        for(t=&triangles[i];i<nbt;t=&triangles[i=next_t],next_t=-first_np_or_next_t[i]) { // for each triangle  t
    24842480                                // we can change first_np_or_next_t[i]
    2485 #ifdef TRACETRIANGLE
    2486                                 trace =  TRACETRIANGLE <0 ? 1 : i == TRACETRIANGLE;
    2487 #endif
    2488                                 assert(i>=0 && i < nbt );
     2481                                if (i<0 || i >= nbt ){
     2482                                        throw ErrorException(__FUNCT__,exprintf("i<0 || i >= nbt"));
     2483                                }
    24892484                                first_np_or_next_t[i] = nbv; // to save the fist new point of triangle
    24902485                                for(j=0;j<3;j++)
     
    25002495                                        Vertex & vB = * tj.EdgeVertex(1);
    25012496
    2502 #ifdef TRACETRIANGLE
    2503                                         if(trace) {
    2504                                                 cout << " i " << Number(vA) <<" j "<<  Number(vB)
    2505                                                   << " "  << t->Locked(j) ;
    2506                                         }
    2507 #endif
    25082497                                        if (!t->link) continue;// boundary
    25092498                                        if (t->det <0) continue;
     
    25232512                                        const Vertex & vC2 = *tadjj.OppositeVertex();
    25242513
    2525 #ifdef TRACETRIANGLE
    2526                                         trace = trace || k == TRACETRIANGLE;
    2527                                         if(trace) {
    2528                                                 cout << "Test Arete " << i << " AB = " << A << B
    2529                                                   << "i "  <<Number(vA)<< "j" <<Number(vB);
    2530                                                 cout << " link" <<(int)t->link << " ta=" << Number( ta)
    2531                                                   << " det " <<ta->det ;
    2532                                                 cout << " hA = " <<vA.m.h << " hB = " <<vB.m.h ;
    2533                                                 cout << " loc " << ta->Locked(j) << endl;
    2534                                         }
    2535 #endif
    2536 
    25372514                                        if(first_np_or_next_t[k]>0) { // this edge is done before
    25382515                                                // find the color of the edge and begin , end of newpoint
    25392516                                                register int kk = t->NuEdgeTriangleAdj(j);
    2540                                                 assert ((*t)(VerticesOfTriangularEdge[j][0]) == (*ta)(VerticesOfTriangularEdge[kk][1]));
    2541                                                 assert ((*t)(VerticesOfTriangularEdge[j][1]) == (*ta)(VerticesOfTriangularEdge[kk][0]));
     2517                                                if ((*t)(VerticesOfTriangularEdge[j][0]) != (*ta)(VerticesOfTriangularEdge[kk][1])){
     2518                                                        throw ErrorException(__FUNCT__,exprintf("(*t)(VerticesOfTriangularEdge[j][0]) != (*ta)(VerticesOfTriangularEdge[kk][1])"));
     2519                                                }
     2520                                                if ((*t)(VerticesOfTriangularEdge[j][1]) != (*ta)(VerticesOfTriangularEdge[kk][0])){
     2521                                                        throw ErrorException(__FUNCT__,exprintf("(*t)(VerticesOfTriangularEdge[j][1]) != (*ta)(VerticesOfTriangularEdge[kk][0])"));
     2522                                                }
    25422523                                                register Int4 kolor =3*k + kk;
    25432524                                                ColorEdge[j]=kolor;
     
    25782559                                        EndNewPoint[j] = nbv-1;
    25792560                                  } // end loop for each edge
    2580 
    2581 #ifdef TRACETRIANGLE
    2582                                 if(trace) {
    2583                                         // verification des point cree
    2584                                         cout << "\n ------------ " << t->link << " " << t->det
    2585                                           << " b " << BeginNewPoint[0] << " " << BeginNewPoint[1]
    2586                                           << " " << BeginNewPoint[2] << " "
    2587                                           << " e " << EndNewPoint[0] << " " << EndNewPoint[1]
    2588                                           << " " << EndNewPoint[2] << " "
    2589                                           << " s " << step[0] << " " << step[1] << " " << step[2] << " "
    2590                                           <<  endl;
    2591                                 }
    2592 #endif
    25932561
    25942562                                if (!t->link) continue;// boundary
     
    26642632                                         Int4 i1;
    26652633                                         kstack =0;
    2666                                          while( (i1=stack[kstack++]) >= 0)
    2667                                                 { // the two parameter is i0 and i1
    2668                                                  assert(i1 < nbv && i1 >= 0);
    2669                                                  assert(i0 < nbv && i0 >= 0);
    2670                                                  assert(i1 != i0);
     2634                                         while( (i1=stack[kstack++]) >= 0){ // the two parameter is i0 and i1
     2635                                                 if (i1 >= nbv || i1 < 0){
     2636                                                         throw ErrorException(__FUNCT__,exprintf("i1 >= nbv || i1 < 0"));
     2637                                                 }
     2638                                                 if (i0 >= nbv || i0 < 0){
     2639                                                         throw ErrorException(__FUNCT__,exprintf("i0 >= nbv || i0 < 0"));
     2640                                                 }
     2641                                                 if (i1 == i0){
     2642                                                         throw ErrorException(__FUNCT__,exprintf("i1 == i0"));
     2643                                                 }
    26712644                                                 R2 v01 = (R2) vertices[i1]- (R2) vertices[i0];
    26722645                                                 Real8 d01 = (vertices[i0].m(v01) + vertices[i1].m(v01));
    2673 
    2674 
    2675 #ifdef TRACETRIANGLE
    2676                                                  if(trace) {
    2677                                                          cout << "\n test j" << j <<" "  << i0
    2678                                                                 << " " << i1 << " d01=" << d01 <<endl;}
    2679 #endif
    2680                                                  assert (i0 >= nbvold);
    2681                                                  assert (i1 >= nbvold);
    2682                                                  assert(i0 != i1);
     2646                                                 if (i0< nbvold || i1<nbvold){
     2647                                                         throw ErrorException(__FUNCT__,exprintf("i0< nbvold || i1<nbvold"));
     2648                                                 }
    26832649                                                 if (d01 == 0)
    26842650                                                  break;
     
    27082674                                                          =  vertices[i0].r *w0 + vertices[i1].r* w1;
    27092675
    2710 #ifdef TRACETRIANGLE
    2711                                                           if(trace) {
    2712                                                                   cout << "\n ref = "<< vertices[i0].ref << " " <<vertices[i1].ref <<endl;
    2713                                                           }
    2714 #endif   
    27152676                                                          // update the new point points of the list
    27162677                                                          for  (ip0=i0;i0 != (ipp0 = vertices[ip0].ReferenceNumber);ip0=ipp0)
     
    27672728
    27682729                                        quadtree->Add(*vi); //
    2769                                         assert (tcvi->det >= 0) ;// internal
     2730                                        if (tcvi->det<0){// internal
     2731                                                throw ErrorException(__FUNCT__,exprintf("tcvi->det<0"));
     2732                                        }
    27702733                                        Add(*vi,tcvi,dete),NbSwap += vi->Optim(1);         
    27712734                                  } 
     
    27912754                                        if (first_np_or_next_t[kt]>0)
    27922755                                         first_np_or_next_t[kt]=-Headt,Headt=kt;
    2793                                         assert( ta.EdgeVertex(0) == s);
     2756                                        if (ta.EdgeVertex(0) != s){
     2757                                                throw ErrorException(__FUNCT__,exprintf("ta.EdgeVertex(0) != s"));
     2758                                        }
    27942759                                        ta = Next(Adj(ta));
    27952760                                } while ( (tbegin != (Triangle*) ta));
     
    30983063                                                //    else if(mark[it] == -2 ) triangles[it].Draw(999);
    30993064                                                it++;} // end white (it<nbt)
    3100                                                 assert(k== NbSubDomains);
     3065                                                if (k!=NbSubDomains){
     3066                                                        throw ErrorException(__FUNCT__,exprintf("k!=NbSubDomains"));
     3067                                                }
    31013068                                                if(OutSide)
    31023069                                                  {
     
    31793146                                        // see routine MakeGeometricalEdgeToEdge
    31803147                                        Edge &e = *GeometricalEdgetoEdge[Gh.Number(eg)];
    3181                                         assert(&e);
     3148                                        if (&e==NULL){
     3149                                                throw ErrorException(__FUNCT__,exprintf("&e==NULL"));
     3150                                        }
    31823151                                        Vertex * v0 =  e(0),*v1 = e(1);
    31833152                                        Triangle *t  = v0->t;
     
    31863155                                        //      cout << " geom edge = " <<  Gh.Number(eg) <<" @" << &eg << " ref = " << subdomains[i].ref
    31873156                                        //     << " ref edge =" << eg.ref << " sens " << sens ;
    3188                                         if (((eg[0].r-eg[1].r),(e[0].r-e[1].r))<0)
    3189                                          sens = -sens ;
     3157                                        if (((eg[0].r-eg[1].r),(e[0].r-e[1].r))<0) sens = -sens ;
    31903158                                        subdomains[i].sens = sens;
    31913159                                        subdomains[i].edge = &e;
    3192                                         //      cout << " sens " << sens << " in geom " << eg[0].r << eg[1].r << " in mesh  " << e[0].r << e[1].r << endl;
    3193                                         //      cout << "  v0 , v1 = " << Number(v0) << " "  << Number(v1) << endl;
    3194                                         assert(t && sens);
     3160                                        if (!t || !sens){
     3161                                                throw ErrorException(__FUNCT__,exprintf("!t || !sens"));
     3162                                        }
    31953163
    31963164                                        TriangleAdjacent  ta(t,EdgesVertexTriangle[v0->vint][0]);// previous edges
    31973165
    31983166                                        while (1) {
    3199                                                 assert( v0 == ta.EdgeVertex(1) );
     3167                                                if ( v0 != ta.EdgeVertex(1) ){
     3168                                                        throw ErrorException(__FUNCT__,exprintf("v0 != ta.EdgeVertex(1)"));
     3169                                                }
    32003170                                                //       cout << " recherche " << Number( ta.EdgeVertex(0)) << endl;
    32013171                                                if (ta.EdgeVertex(0) == v1) { // ok we find the edge
     
    32253195                                                          {
    32263196                                                                kkk++;
    3227                                                                 assert(mark[Number(tt)]<0);
     3197                                                                if (mark[Number(tt)]>=0){
     3198                                                                        throw ErrorException(__FUNCT__,exprintf("mark[Number(tt)]>=0"));
     3199                                                                }
    32283200                                                                mark[Number(tt)]=i;
    32293201                                                                tt=tt->link;
     
    33443316                  {
    33453317                        t=t0=subdomains[i].head;
    3346                         assert(t0); // no empty sub domain
     3318                        if (!t0){ // not empty sub domain
     3319                                throw ErrorException(__FUNCT__,exprintf("!t0"));
     3320                        }
    33473321                        do {
    33483322                                Int4 kt = Number(t);
    3349                                 assert(kt>=0 && kt < nbt );
    3350                                 assert(renu[kt]==-1);
     3323                                if (kt<0 || kt >= nbt ){
     3324                                        throw ErrorException(__FUNCT__,exprintf("kt<0 || kt >= nbt"));
     3325                                }
     3326                                if (renu[kt]!=-1){
     3327                                        throw ErrorException(__FUNCT__,exprintf("renu[kt]!=-1"));
     3328                                }
    33513329                                renu[kt]=k++;
    33523330                        }
     
    33623340
    33633341                // put the outside triangles at the end
    3364                 for ( it=0;it<nbt;it++)
    3365                  if (renu[it]==-1)
    3366                   renu[it]=k++;
    3367 
    3368                 assert(k == nbt);
     3342                for ( it=0;it<nbt;it++){
     3343                        if (renu[it]==-1) renu[it]=k++;
     3344                }
     3345                if (k != nbt){
     3346                        throw ErrorException(__FUNCT__,exprintf("k != nbt"));
     3347                }
    33693348                // do the change on all the pointeur
    33703349                for ( it=0;it<nbt;it++)
     
    33963375        /*}}}1*/
    33973376        /*FUNCTION Triangles::ConsRefTriangle{{{1*/
    3398         Int4  Triangles::ConsRefTriangle(Int4 *reft) const {
     3377        Int4  Triangles::ConsRefTriangle(Int4* reft) const {
    33993378                long int verbosity=0;
    3400                 assert(reft);
    34013379                register Triangle *t0,*t;
    34023380                register Int4 k=0, num;   
    3403                 for (Int4 it=0;it<nbt;it++)
    3404                  reft[it]=-1; // outside triangle
    3405                 for (Int4 i=0;i<NbSubDomains;i++)
    3406                   {
     3381                for (Int4 it=0;it<nbt;it++) reft[it]=-1; // outside triangle
     3382                for (Int4 i=0;i<NbSubDomains;i++){
    34073383                        t=t0=subdomains[i].head;
    3408                         assert(t0); // no empty sub domain
     3384                        if (!t0){ // no empty sub domai{
     3385                                throw ErrorException(__FUNCT__,exprintf("!t0"));
     3386                        }
    34093387                        // register Int4 color=i+1;// because the color 0 is outside triangle
    34103388                        do { k++;
    34113389                                num = Number(t);
    3412                                 assert(num>=0 &&num < nbt);
     3390                                if (num<0 || num>=nbt){
     3391                                        throw ErrorException(__FUNCT__,exprintf("num<0 || num>=nbt"));
     3392                                }
    34133393                                reft[num]=i;
    3414                                 //  cout << Number(t0) << " " <<Number(t)<< " "  << i << endl;
    34153394                        }
    34163395                        while (t0 != (t=t->link));
     
    344634251 on GeometricalEdge + abcisse
    344734262 internal
    3448 
    34493427                 *************************************************************************/
    3450                 assert(&BTh.Gh == &Gh);
     3428                if (&BTh.Gh != &Gh){
     3429                        throw ErrorException(__FUNCT__,exprintf("&BTh.Gh != &Gh"));
     3430                }
    34513431
    34523432                long int verbosity=0;
     
    34813461                        throw ErrorException(__FUNCT__,exprintf("too many vertices on geometry: %i >= %i",NbVerticesOnGeomVertex,nbvx));
    34823462                }
    3483                 assert(vertices);
    3484                 for (i=0;i<Gh.nbv;i++)
    3485                  if (Gh[i].Required()) {//Gh  vertices Required
    3486                          vertices[nbv] =  Gh[i];
    3487                          vertices[nbv].i = I2(0,0);
    3488                          Gh[i].to = vertices + nbv;// save Geom -> Th
    3489                          VerticesOnGeomVertex[nbv]= VertexOnGeom(vertices[nbv],Gh[i]);
    3490                          // cout << "--------- "  <<Number(Gh[i].to) << " " << Gh[i].to << " " << i << endl;
    3491                          nbv++;}
    3492                  else Gh[i].to=0;
    3493                 //
    3494                 for (i=0;i<BTh.NbVerticesOnGeomVertex;i++)
    3495                   {
     3463                if (vertices==NULL){
     3464                        throw ErrorException(__FUNCT__,exprintf("vertices==NULL"));
     3465                }
     3466                for (i=0;i<Gh.nbv;i++){
     3467                        if (Gh[i].Required()) {//Gh  vertices Required
     3468                                vertices[nbv] =  Gh[i];
     3469                                vertices[nbv].i = I2(0,0);
     3470                                Gh[i].to = vertices + nbv;// save Geom -> Th
     3471                                VerticesOnGeomVertex[nbv]= VertexOnGeom(vertices[nbv],Gh[i]);
     3472                                // cout << "--------- "  <<Number(Gh[i].to) << " " << Gh[i].to << " " << i << endl;
     3473                                nbv++;
     3474                        }
     3475                        else Gh[i].to=0;
     3476                }
     3477                for (i=0;i<BTh.NbVerticesOnGeomVertex;i++){
    34963478                        VertexOnGeom & vog = BTh.VerticesOnGeomVertex[i];
    34973479                        if (vog.IsRequiredVertex()) {
    34983480                                GeometricalVertex * gv = vog;
    34993481                                Vertex *bv = vog;
    3500                                 assert(gv->to);// use of Geom -> Th
     3482                                if (!gv->to){// use of Geom -> Th
     3483                                        throw ErrorException(__FUNCT__,exprintf("!gv->to"));
     3484                                }
    35013485                                VertexOnBThVertex[NbVertexOnBThVertex++] = VertexOnVertex(gv->to,bv);
    35023486                                gv->to->m = bv->m; // for taking the metrix of the background mesh
    3503                                 ;}
     3487                                ;
     3488                        }
    35043489                  }
    3505                 assert(NbVertexOnBThVertex == NbVerticesOnGeomVertex);
     3490                if (NbVertexOnBThVertex != NbVerticesOnGeomVertex){
     3491                        throw ErrorException(__FUNCT__,exprintf("NbVertexOnBThVertex != NbVerticesOnGeomVertex"));
     3492                }
    35063493                // new stuff FH with curve
    35073494                //  find the begin of the curve in BTh
    3508                   {
    35093495                        Gh.UnMarkEdges();       
    35103496                        int bfind=0;
     
    35433529                                        }
    35443530                          }
    3545                         assert( bfind==Gh.NbOfCurves);
    3546                   }         
     3531                        if ( bfind!=Gh.NbOfCurves){
     3532                                throw ErrorException(__FUNCT__,exprintf("bfind!=Gh.NbOfCurves"));
     3533                        }
     3534
    35473535                // method in 2 + 1 step
    35483536                //  0.0) compute the length and the number of vertex to do allocation
     
    36103598                                                VertexOnGeom *GA1;
    36113599                                                Edge * PreviousNewEdge = 0;
    3612                                                 //  cout << "  --------------New Curve phase " << phase
    3613                                                 //       << "---------- A0=" << *A0 << ei[k0]  <<endl;
    3614                                                 assert (A0-vertices>=0 && A0-vertices <nbv);
     3600                                                // New Curve phase
     3601                                                if (A0-vertices<0 || A0-vertices>=nbv){
     3602                                                        throw ErrorException(__FUNCT__,exprintf("A0-vertices<0 || A0-vertices>=nbv"));
     3603                                                }
    36153604                                                if(ongequi->Required() )
    36163605                                                  {
     
    36193608                                                  }       
    36203609                                                else
    3621                                                  for(;;)
    3622                                                         {
    3623                                                          //   assert(pe && BTh.Number(pe)>=0 && BTh.Number(pe)<=BTh.nbe);
     3610                                                 for(;;){
    36243611                                                         Edge &ee=*pe;
    36253612                                                         Edge &eeequi=*peequi;
     
    36273614                                                         k1equi= 1 - k0equi;
    36283615
    3629                                                          assert(pe  && ee.on);
     3616                                                         if (!pe  || !ee.on){
     3617                                                                 throw ErrorException(__FUNCT__,exprintf("!pe  || !ee.on"));
     3618                                                         }
    36303619                                                         ee.on->SetMark();
    36313620                                                         Vertex & v0=ee[0], & v1=ee[1];
     
    36363625                                                         if (phase) {// computation of the new points
    36373626                                                                 while ((i!=NbCreatePointOnCurve) && sNew <= L) {
    3638                                                                          //    cout  << " L0= " << L0 << " L " << L << " sN="
    3639                                                                          //         << sNew << " LAB=" << LAB << " NBPC =" <<NbCreatePointOnCurve<< " i " << i  << endl;
    3640                                                                          assert (sNew >= L0);
    3641                                                                          assert(LAB);
    3642 
    3643 
    3644                                                                          assert(vertices && nbv<nbvx);
    3645                                                                          assert(edges && nbe < nbex);
    3646                                                                          assert(VerticesOnGeomEdge && NbVerticesOnGeomEdge < NbVerticesOnGeomEdgex);
     3627                                                                         if (sNew<L0){
     3628                                                                                 throw ErrorException(__FUNCT__,exprintf("sNew<L0"));
     3629                                                                         }
     3630                                                                         if (!LAB){
     3631                                                                                 throw ErrorException(__FUNCT__,exprintf("!LAB"));
     3632                                                                         }
     3633                                                                         if (!vertices || nbv>=nbvx){
     3634                                                                                 throw ErrorException(__FUNCT__,exprintf("!vertices || nbv>=nbvx"));
     3635                                                                         }
     3636                                                                         if (!edges || nbe>=nbex){
     3637                                                                                 throw ErrorException(__FUNCT__,exprintf("!edges || nbe>=nbex"));
     3638                                                                         }
     3639                                                                         if (!VerticesOnGeomEdge || NbVerticesOnGeomEdge>=NbVerticesOnGeomEdgex){
     3640                                                                                 throw ErrorException(__FUNCT__,exprintf("!VerticesOnGeomEdge || NbVerticesOnGeomEdge>=NbVerticesOnGeomEdgex"));
     3641                                                                         }
    36473642                                                                         // new vertex on edge
    36483643                                                                         A1=vertices+nbv++;
     
    36503645                                                                         Edge *e = edges + nbe++;
    36513646                                                                         Real8 se= (sNew-L0)/LAB;
    3652                                                                          assert(se>=0 && se < 1.000000001);
     3647                                                                         if (se<0 || se>=1.000000001){
     3648                                                                                 throw ErrorException(__FUNCT__,exprintf("se<0 || se>=1.000000001"));
     3649                                                                         }
    36533650                                                                         se =  abscisseInterpole(v0.m,v1.m,AB,se,1);
    3654                                                                          assert(se>=0 && se <= 1);
     3651                                                                         if (se<0 || se>1){
     3652                                                                                 throw ErrorException(__FUNCT__,exprintf("se<0 || se>1"));
     3653                                                                         }
    36553654                                                                         //((k1==1) != (k1==k1equi))
    36563655                                                                         se = k1 ? se : 1. - se;
     
    36833682
    36843683                                                         }               
    3685                                                          assert(ee.on->CurveNumber==ei.on->CurveNumber);
     3684                                                         if (ee.on->CurveNumber!=ei.on->CurveNumber){
     3685                                                                 throw ErrorException(__FUNCT__,exprintf("ee.on->CurveNumber!=ei.on->CurveNumber"));
     3686                                                         }
    36863687                                                         if(verbosity>98) cout <<  BTh.Number(ee) << " " << " on=" << *ee[k1].on << " "<< ee[k1].on->IsRequiredVertex() <<  endl;
    36873688                                                         if ( ee[k1].on->IsRequiredVertex()) {
    3688                                                                  assert(eeequi[k1equi].on->IsRequiredVertex());
     3689                                                                 if (!eeequi[k1equi].on->IsRequiredVertex()){
     3690                                                                         throw ErrorException(__FUNCT__,exprintf("!eeequi[k1equi].on->IsRequiredVertex()"));
     3691                                                                 }
    36893692                                                                 register GeometricalVertex * GA1 = *eeequi[k1equi].on;
    36903693                                                                 A1=GA1->to;// the vertex in new mesh
    3691                                                                  assert (A1-vertices>=0 && A1-vertices <nbv);
     3694                                                                 if (A1-vertices<0 || A1-vertices>=nbv){
     3695                                                                         throw ErrorException(__FUNCT__,exprintf("A1-vertices<0 || A1-vertices>=nbv"));
     3696                                                                 }
    36923697                                                                 break;}
    36933698                                                                 if (!ee.adj[k1]) {
     
    37173722                                                        PreviousNewEdge = e;
    37183723
    3719                                                         assert(i==NbCreatePointOnCurve);
     3724                                                        if (i!=NbCreatePointOnCurve){
     3725                                                                throw ErrorException(__FUNCT__,exprintf("i!=NbCreatePointOnCurve"));
     3726                                                        }
    37203727
    37213728                                                  }
     
    37633770                  }
    37643771                  } // for(step;;)
    3765                 assert(nbe);
    3766 
     3772                if (nbe==0){
     3773                        throw ErrorException(__FUNCT__,exprintf("nbe==0"));
     3774                }
    37673775                delete [] bcurve;
    37683776
     
    38093817                         nbv++;
    38103818                 }
    3811                 //  assert( Gh.nbv < nbvx);
    38123819
    38133820                // Method in 2 step:  0 and 1
     
    38153822                // 2) construct the edge   
    38163823                // generation of the curves
    3817                 assert(! edges);
     3824                if (edges){
     3825                        throw ErrorException(__FUNCT__,exprintf("edges"));
     3826                }
    38183827                // 2 step
    38193828                // --step=0 to compute the number of edges + alloc at end
     
    38493858                                                                a=ei(0)->The();
    38503859                                                                b=ei(1)->The();
    3851                                                                 assert(edges);
     3860                                                                if (!edges){
     3861                                                                        throw ErrorException(__FUNCT__,exprintf("!edges"));
     3862                                                                }
    38523863                                                                edges[nbe].v[0]=a->to;
    38533864                                                                edges[nbe].v[1]=b->to;;
     
    38683879                                                          NbNewPoints=0;
    38693880                                                          NbEdgeCurve=0;
    3870                                                           assert(nbvend < nbvx);
     3881                                                          if (nbvend>=nbvx){
     3882                                                                  throw ErrorException(__FUNCT__,exprintf("nbvend>=nbvx"));
     3883                                                          }
    38713884                                                          lcurve =0;
    38723885                                                          s = lstep;
     
    39343947                                                                                  else
    39353948                                                                                        kk0=kkk,ll0=llk;}
    3936                                                                                   assert(kk1 != kk0);
     3949                                                                                  if (kk1 == kk0){
     3950                                                                                          throw ErrorException(__FUNCT__,exprintf("kk1 == kk0"));
     3951                                                                                  }
    39373952
    39383953                                                                                  Real8 sbb = (ss-ll0  )/(ll1-ll0);
     
    39723987                                                                  k = e->SensAdj[kprev];// next vertices
    39733988                                                                  e = e->Adj[kprev];
    3974                                                                   assert(e);
     3989                                                                  if (!e){
     3990                                                                          throw ErrorException(__FUNCT__,exprintf("!e"));
     3991                                                                  }
    39753992                                                                 }// for(;;)
    39763993                                                          vb = b->to;
     
    40064023                        } // for (i=0;i<nbe;i++)
    40074024                        if(!step) {
    4008                                 // cout << "edges " << edges << " VerticesOnGeomEdge " <<VerticesOnGeomEdge << endl;
    4009                                 assert(!edges);
    4010                                 assert(!VerticesOnGeomEdge);
     4025                                if (edges){
     4026                                        throw ErrorException(__FUNCT__,exprintf("edges"));
     4027                                }
     4028                                if (VerticesOnGeomEdge){
     4029                                        throw ErrorException(__FUNCT__,exprintf("VerticesOnGeomEdge"));
     4030                                }
    40114031                                edges = new Edge[nbex=nbe];
    40124032                                if(NbVerticesOnGeomEdge0)
    40134033                                 VerticesOnGeomEdge = new VertexOnGeom[NbVerticesOnGeomEdge0];
    4014                                 assert(edges);
    4015                                 assert(VerticesOnGeomEdge || NbVerticesOnGeomEdge0 ==0);
     4034                                if (!VerticesOnGeomEdge && NbVerticesOnGeomEdge0!=0){
     4035                                        throw ErrorException(__FUNCT__,exprintf("!VerticesOnGeomEdge && NbVerticesOnGeomEdge0!=0"));
     4036                                }
    40164037                                // do the vertex on a geometrical vertex
    40174038                                NbVerticesOnGeomEdge0 = NbVerticesOnGeomEdge;       
    40184039                        }
    4019                         else
    4020                          assert(NbVerticesOnGeomEdge == NbVerticesOnGeomEdge0);
    4021                         //     cout << " Nb of Curves = " << NbOfCurves << "nbe = " << nbe
    4022                         //        << "== " << nbex << "  nbv = " << nbv <<  endl;
    4023                         assert(nbex=nbe);
     4040                        else if (NbVerticesOnGeomEdge != NbVerticesOnGeomEdge0){
     4041                                throw ErrorException(__FUNCT__,exprintf("NbVerticesOnGeomEdge != NbVerticesOnGeomEdge0"));
     4042                        }
    40244043                  } // for (step=0;step<2;step++)
    40254044
     
    40354054        /*FUNCTION Triangles::MakeGeometricalEdgeToEdge{{{1*/
    40364055        Edge** Triangles::MakeGeometricalEdgeToEdge() {
    4037                 assert(Gh.nbe);
     4056                if (!Gh.nbe){
     4057                        throw ErrorException(__FUNCT__,exprintf("!Gh.nbe"));
     4058                }
    40384059                Edge **e= new (Edge* [Gh.nbe]);
    40394060
     
    40724093                          cerr << " Bug -- the geometrical edge " << i << " is on no edge curve = " << Gh.edges[i].CurveNumber
    40734094                                 << " s0 " << Gh.Number( Gh.edges[i][0]) << " s1  " << Gh.Number( Gh.edges[i][1]) << endl;
    4074                           //     assert( e[i]);
    40754095                  }
    40764096                if(kk) throw ErrorException(__FUNCT__,exprintf("See above"));
     
    40964116                pmax = pmax+DD;
    40974117                coefIcoor= (MaxICoor)/(Max(pmax.x-pmin.x,pmax.y-pmin.y));
    4098                 assert(coefIcoor >0);
     4118                if (coefIcoor<=0){
     4119                        throw ErrorException(__FUNCT__,exprintf("coefIcoor<=0"));
     4120                }
    40994121
    41004122                // generation of integer coord 
     
    41424164
    41434165                        //initialize ordre
    4144                         assert(ordre);
     4166                        if (!ordre){
     4167                                throw ErrorException(__FUNCT__,exprintf("!ordre"));
     4168                        }
    41454169                        for (i=0;i<nbv;i++) ordre[i]=0;
    41464170
     
    41744198                                        }
    41754199                                        else if(st[k]>=0) {
    4176                                                 assert( ! triangles[i].TriangleAdj(j) && !triangles[st[k] / 3].TriangleAdj((int) (st[k]%3)));
     4200                                                if (triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3))){
     4201                                                        throw ErrorException(__FUNCT__,exprintf("(triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3)))"));
     4202                                                }
    41774203
    41784204                                                triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3));
     
    43294355                                                                 Vertex *v1= ta.EdgeVertex(1);
    43304356                                                                 Int4 k =edge4->addtrie(v0?Number(v0):nbv,v1? Number(v1):nbv);
    4331                                                                  assert(st[k] >=0);
     4357                                                                 if (st[k]<0){
     4358                                                                         throw ErrorException(__FUNCT__,exprintf("st[k]<0"));
     4359                                                                 }
    43324360                                                                 tta.SetAdj2(ja,savetriangles + st[k] / 3,(int) (st[k]%3));
    43334361                                                                 ta.SetLock();
     
    43484376                                                }
    43494377                                 }
    4350                                  // cout <<      savenbt+NbTfillHoll << " " <<  savenbtx  << endl;
    4351                                  assert(savenbt+NbTfillHoll <= savenbtx );
     4378                                 if (savenbt+NbTfillHoll>savenbtx ){
     4379                                         throw ErrorException(__FUNCT__,exprintf("savenbt+NbTfillHoll>savenbtx"));
     4380                                 }
    43524381                                 // copy of the outside triangles in saveTriangles
    43534382                                 for (i=0;i<nbt;i++){
     
    44424471                          {
    44434472                                NbSwap++;
    4444                                 assert(k++<20000);
     4473                                k++;
     4474                                if (k>=20000){
     4475                                        throw ErrorException(__FUNCT__,exprintf("k>=20000"));
     4476                                }
    44454477                                t=  tp->at[jp];      // set unchange t qnd j for previous triangles
    44464478                                j=  NextEdge[tp->aa[jp]&3];
     
    46414673        /*FUNCTION Triangles::Crack{{{1*/
    46424674        int  Triangles::Crack() {
    4643                 assert(NbCrackedEdges ==0 || NbCrackedVertices >0);
    4644                 for (int i=0;i<NbCrackedEdges;i++)
    4645                  CrackedEdges[i].Crack();
     4675                if (NbCrackedEdges!=0 && NbCrackedVertices<=0);{
     4676                        throw ErrorException(__FUNCT__,exprintf("NbCrackedEdges!=0 && NbCrackedVertices<=0"));
     4677                }
     4678                for (int i=0;i<NbCrackedEdges;i++) CrackedEdges[i].Crack();
    46464679                return NbCrackedEdges;
    46474680        }
     
    46494682        /*FUNCTION Triangles::UnCrack{{{1*/
    46504683        int Triangles::UnCrack() {
    4651                 assert(NbCrackedEdges ==0 || NbCrackedVertices >0);
     4684                if (NbCrackedEdges!=0 && NbCrackedVertices<=0);{
     4685                        throw ErrorException(__FUNCT__,exprintf("NbCrackedEdges ==0 || NbCrackedVertices >0"));
     4686                }
    46524687                for (int i=0;i<NbCrackedEdges;i++)
    46534688                 CrackedEdges[i].UnCrack();
     
    47034738                        Triangle * tbegin = v.t;
    47044739                        int i  = v.vint;       
    4705                         assert(tbegin && (i >= 0 ) && (i <3));
     4740                        if (!tbegin || (i<0) || (i>=3)){
     4741                                throw ErrorException(__FUNCT__,exprintf("!tbegin || (i<0) || (i>=3)"));
     4742                        }
    47064743                        // turn around the vertex v
    47074744                        TriangleAdjacent ta(tbegin,EdgesVertexTriangle[i][0]);// previous edge
     
    47144751                                  {   
    47154752                                        TriangleAdjacent tta=(ta.Adj());
    4716                                         assert(tta.Cracked());
     4753                                        if (!tta.Cracked()){
     4754                                                throw ErrorException(__FUNCT__,exprintf("!tta.Cracked()"));
     4755                                        }
    47174756                                        if ( kk == 0) tbegin=ta,kkk=0;  //  begin by a cracked edge  => restart               
    47184757                                        if (  kkk ) { kc =1;vv = vlast++;  kkk = 0; } // new vertex if use
     
    47214760                                if ( tt->link ) { // if good triangles store the value
    47224761                                        int it = Number(tt);
    4723                                         assert(it < nt);
     4762                                        if (it>=nt){
     4763                                                throw ErrorException(__FUNCT__,exprintf("(it>=nt)"));
     4764                                        }
    47244765                                        (*tt)(kv)= vv; //   Change the vertex of triangle
    47254766                                        if(vv<vend) {*vv= v;vv->ReferenceNumber=iv;} // copy the vertex value + store the old vertex number in ref
     
    47324773                                ta = Next(ta).Adj();
    47334774                        } while ( (tbegin != ta));
    4734                         assert(k);
     4775                        if (!k){
     4776                                throw ErrorException(__FUNCT__,exprintf("!k"));
     4777                        }
    47354778                        if (kc)  nbcrakev++;
    47364779                  }
     
    47994842                Triangle * t=0;
    48004843                int j,jp,jn,jj;
    4801                 if (tstart)
    4802                  t=tstart;
    4803                 else
    4804                   {
    4805                         assert(quadtree);
     4844                if (tstart) t=tstart;
     4845                else {
     4846                        if (!quadtree){
     4847                                throw ErrorException(__FUNCT__,exprintf("!quadtree"));
     4848                        }
    48064849                        Vertex *a = quadtree->NearestVertex(B.x,B.y) ;
    48074850
     
    48124855                                throw ErrorException(__FUNCT__,exprintf("problem in Triangles::FindTriangleContening"));
    48134856                        }
    4814                         assert(a>= vertices && a < vertices+nbv);
    4815                         //  int k=0;
     4857                        if (a<vertices || a>=vertices+nbv){
     4858                                throw ErrorException(__FUNCT__,exprintf("a<vertices || a>=vertices+nbv"));
     4859                        }
    48164860                        t = a->t;
    4817                         assert(t>= triangles && t < triangles+nbt);
    4818 
    4819                   }
     4861                        if (t<triangles || t>=triangles+nbt){
     4862                                throw ErrorException(__FUNCT__,exprintf("t<triangles || t>=triangles+nbt"));
     4863                        }
     4864                }
    48204865                Icoor2  detop ;
    48214866                int kkkk =0; // number of test triangle
    48224867
    4823                 while ( t->det < 0)
    4824                   { // the initial triangles is outside 
     4868                while ( t->det < 0){ // the initial triangles is outside 
    48254869                        int k0=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
    4826                         assert(k0>=0); // k0 the NULL  vertex
     4870                        if (k0<0){ // k0 the NULL  vertex
     4871                                throw ErrorException(__FUNCT__,exprintf("k0<0"));
     4872                        }
    48274873                        int k1=NextVertex[k0],k2=PreviousVertex[k0];
    48284874                        dete[k0]=det(B,(*t)[k1],(*t)[k2]);
     
    48314877                         return t;
    48324878                        t = t->TriangleAdj(OppositeEdge[k0]);
    4833                         assert(kkkk++ < 2);
     4879                        kkkk++;
     4880                        if (kkkk>=2){
     4881                                throw ErrorException(__FUNCT__,exprintf("kkkk>=2"));
     4882                        }
    48344883                  }
    48354884
     
    48374886                detop = det(*(*t)(VerticesOfTriangularEdge[jj][0]),*(*t)(VerticesOfTriangularEdge[jj][1]),B);
    48384887
    4839                 while(t->det  > 0 )
    4840                   {
    4841                         assert( kkkk++ < 2000 );
     4888                while(t->det  > 0 ) {
     4889                        kkkk++;
     4890                        if (kkkk>=2000){
     4891                                throw ErrorException(__FUNCT__,exprintf("kkkk>=2000"));
     4892                        }
    48424893                        j= OppositeVertex[jj];
    48434894                        dete[j] = detop;  //det(*b,*s1,*s2);
     
    48564907                        // 2 => two way go in way 1 or 2 randomly
    48574908
    4858                         if (k==0)
    4859                          break;
    4860                         if (k == 2 && BinaryRand())
    4861                          Exchange(ii[0],ii[1]);
    4862                         assert ( k  < 3);
     4909                        if (k==0) break;
     4910                        if (k == 2 && BinaryRand()) Exchange(ii[0],ii[1]);
     4911                        if ( k>=3){
     4912                                throw ErrorException(__FUNCT__,exprintf("k>=3"));
     4913                        }
    48634914                        TriangleAdjacent t1 = t->Adj(jj=ii[0]);
    48644915                        if ((t1.det() < 0 ) && (k == 2))
     
    48874938                Real8 hmin = Gh.MinimalHmin();
    48884939                Real8 maxaniso = 1e6;
    4889                 assert(hmax>0);
     4940                if (hmax<=0){
     4941                        throw ErrorException(__FUNCT__,exprintf("hmax<=0"));
     4942                }
    48904943                SetVertexFieldOn();
    48914944                if (errC > 1) errC = 1;
     
    49024955                                 Real8 s = GV;
    49034956                                 R2 tg;
    4904                                  //        cerr << i << " " << j << " " << Number(V) << " on = "
    4905                                  //     << Gh.Number(eg) << " at s = " << s << " " << endl;
    49064957                                 Real8  R1= eg->R1tg(s,tg);
    4907                                  // cerr << " R = " << 1/Max(R1,1e-20) << tg << " on x "
    4908                                  //    << V.r << errC/ Max(R1,1e-20) <<  " hold=" <<V.m(tg) << " "  << endl;
    49094958                                 Real8 ht = hmax;
    4910                                  if (R1>1.0e-20)
    4911                                         {  // err relative to the length of the edge
     4959                                 if (R1>1.0e-20) {  // err relative to the length of the edge
    49124960                                         ht = Min(Max(errC/R1,hmin),hmax);
    49134961                                        }
    49144962                                 Real8 hn = iso? ht : Min(hmax,ht*maxaniso);
    4915                                  //cerr << ht << " " << hn << "m=" << edges[i][j].m <<  endl;
    4916                                  assert(ht>0 && hn>0);
     4963                                 if (ht<=0 || hn<=0){
     4964                                         throw ErrorException(__FUNCT__,exprintf("ht<=0 || hn<=0"));
     4965                                 }
    49174966                                 MatVVP2x2 Vp(1/(ht*ht),1/(hn*hn),tg);
    49184967                                 //cerr << " : " ;
     
    52175266                                                 Real8 cAB   =  det3x3(taa[0],taa[1],bb);
    52185267
    5219                                                  assert(det33);
    5220                                                  //     det33=1;
    5221                                                  // verif
    5222                                                  //     cout << " " << (taa[0][0]*cBC +  taa[1][0]*cCA + taa[2][0] * cAB)/det33 << " == " << bb[0] ;
    5223                                                  //     cout << " " << (taa[0][1]*cBC +  taa[1][1]*cCA + taa[2][1] * cAB)/det33 << " == " << bb[1];
    5224                                                  //     cout << " " << (taa[0][2]*cBC +  taa[1][2]*cCA + taa[2][2] * cAB)/det33 << " == " << bb[2]
    5225                                                  //          << "  -- " ;
    5226                                                  //cout << lla*sA + llb*sB+llc*sC+ (lla*llb* cAB +  llb*llc* cBC + llc*lla*cCA)/det33
    5227                                                  //   << " == " << llf <<  endl;
     5268                                                 if (!det33){
     5269                                                         throw ErrorException(__FUNCT__,exprintf("!det33"));
     5270                                                 }
    52285271                                                 // computation of the gradient in the element
    52295272
     
    55145557                while (Head0>=0&& kk++<100) {
    55155558                        kch=0;
    5516                         for (i=Head0;i>=0;i=first_np_or_next_t0[ip=i],first_np_or_next_t0[ip]=-1)
    5517                           {  //  pour tous les triangles autour du sommet s
     5559                        for (i=Head0;i>=0;i=first_np_or_next_t0[ip=i],first_np_or_next_t0[ip]=-1) {
     5560                                //  pour tous les triangles autour du sommet s
    55185561                                //      cout << kk << " i = " << i << " " << ip << endl;
    5519                                 register Triangle * t= vertices[i].t;
    5520                                 assert(t);
     5562                                register Triangle* t= vertices[i].t;
     5563                                if (!t){
     5564                                        throw ErrorException(__FUNCT__,exprintf("!t"));
     5565                                }
    55215566                                Vertex & vi = vertices[i];
    55225567                                TriangleAdjacent ta(t,EdgesVertexTriangle[vertices[i].vint][0]);
    55235568                                Vertex *pvj0 = ta.EdgeVertex(0);
    55245569                                while (1) {
    5525                                         //        cout << i << " " <<  Number(ta.EdgeVertex(0)) << " "
    5526                                         //      << Number(ta.EdgeVertex(1)) << "  ---> " ;
    55275570                                        ta=Previous(Adj(ta));
    5528                                         // cout <<  Number(ta.EdgeVertex(0)) << " " << Number(ta.EdgeVertex(1)) << endl;
    5529                                         assert(vertices+i == ta.EdgeVertex(1));
     5571                                        if (vertices+i != ta.EdgeVertex(1)){
     5572                                                throw ErrorException(__FUNCT__,exprintf("vertices+i != ta.EdgeVertex(1)"));
     5573                                        }
    55305574                                        Vertex & vj = *(ta.EdgeVertex(0));
    55315575                                        if ( &vj ) {
    55325576                                                j= &vj-vertices;
    5533                                                 assert(j>=0 && j < nbv);
     5577                                                if (j<0 || j >= nbv){
     5578                                                        throw ErrorException(__FUNCT__,exprintf("j<0 || j >= nbv"));
     5579                                                }
    55345580                                                R2 Aij = (R2) vj - (R2) vi;
    55355581                                                Real8 ll =  Norme2(Aij);
     
    56115657                if (inbvx) {
    56125658                        vertices=new Vertex[nbvx];
    5613                         assert(vertices);
     5659                        if (!vertices){
     5660                                throw ErrorException(__FUNCT__,exprintf("!vertices"));
     5661                        }
    56145662                        ordre=new (Vertex* [nbvx]);
    5615                         assert(ordre);
     5663                        if (!ordre){
     5664                                throw ErrorException(__FUNCT__,exprintf("!ordre"));
     5665                        }
    56165666                        triangles=new Triangle[nbtx];
    5617                         assert(triangles);}
     5667                        if (!triangles){
     5668                                throw ErrorException(__FUNCT__,exprintf("!triangles"));
     5669                        }
     5670                }
    56185671                else {
    56195672                        vertices=0;
     
    56225675                        nbtx=0;
    56235676                }
    5624                 if ( name || inbvx)
    5625                   {
     5677                if ( name || inbvx) {
    56265678                        time_t timer =time(0);
    56275679                        char buf[70];     
     
    57135765        Int4 FindTriangle(Triangles &Th, Real8 x, Real8 y, double* a,int & inside){
    57145766                CurrentTh=&Th;
    5715                 assert(&Th);
    57165767                I2 I = Th.toI2(R2(Min(Max(Th.pmin.x,x),Th.pmax.x),Min(Max(Th.pmin.y,y),Th.pmax.y)));
    57175768                Icoor2 dete[3];
     
    57385789                                k = ta;
    57395790                                Exchange(aa,bb);
    5740                                 assert(tc->link);
     5791                                if (!tc->link){
     5792                                        throw ErrorException(__FUNCT__,exprintf("!tc->link"));
     5793                                }
    57415794                          }
    57425795                        a[VerticesOfTriangularEdge[k][0]] = aa;
     
    57515804                int k=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
    57525805                int dir=0;
    5753                 assert(k>=0);
     5806                if (k<0){
     5807                        throw ErrorException(__FUNCT__,exprintf("k<0"));
     5808                }
    57545809                int kkk=0; 
    57555810                Icoor2 IJ_IA,IJ_AJ;
    57565811                TriangleAdjacent edge(t,OppositeEdge[k]);         
    5757                 for (;;edge = dir >0 ? Next(Adj(Next(edge))) : Previous(Adj(Previous(edge))))
    5758                   { 
    5759 
    5760                         assert(kkk++<1000);     
     5812                for (;;edge = dir >0 ? Next(Adj(Next(edge))) : Previous(Adj(Previous(edge)))) { 
     5813                        kkk++;
     5814                        if (kkk>=1000){
     5815                                throw ErrorException(__FUNCT__,exprintf("kkk>=1000"));
     5816                        }
    57615817                        Vertex  &vI =  *edge.EdgeVertex(0);
    57625818                        Vertex  &vJ =  *edge.EdgeVertex(1);
     
    57745830                                                        continue;}}// go in direction j
    57755831                                                        double IJ2 = IJ_IA + IJ_AJ;
    5776                                                         assert(IJ2);
     5832                                                        if (IJ2==0){
     5833                                                                throw ErrorException(__FUNCT__,exprintf("IJ2==0"));
     5834                                                        }
    57775835                                                        a= IJ_AJ/IJ2;
    57785836                                                        b= IJ_IA/IJ2;
     
    57905848                // restart:
    57915849                //   int dir=0;
    5792                 assert(t->link == 0);
     5850                if (t->link != 0){
     5851                        throw ErrorException(__FUNCT__,exprintf("t->link != 0"));
     5852                }
    57935853                // to have a starting edges
    57945854                // try the 3 edge bourna-- in case of internal hole
     
    58645924                          }
    58655925                  }
    5866                 assert(cas !=-2);
     5926                if (cas ==-2){
     5927                        throw ErrorException(__FUNCT__,exprintf("cas==-2"));
     5928                }
    58675929                // l1 = ||C s1||  , l0 = ||C s0||
    58685930                // where s0,s1 are the vertex of the edge er
     
    58775939
    58785940                        Triangle * tt=t=edge=Adj(Previous(edge));
    5879                         do  {  // loop around vertex s
    5880 
    5881                                 assert(edge.EdgeVertex(0)==s && kkk++<10000);
     5941                        do  {  // loop over vertex s
     5942                                kkk++;
     5943                                if (edge.EdgeVertex(0)!=s && kkk>=10000){
     5944                                        throw ErrorException(__FUNCT__,exprintf("edge.EdgeVertex(0)!=s && kkk>=10000"));
     5945                                }
    58825946
    58835947                                int link = tt->link == 0;
     
    59095973                        } while (t!=tt);
    59105974
    5911                         assert((Triangle *) er);
     5975                        if (!(Triangle *) er){
     5976                                throw ErrorException(__FUNCT__,exprintf("!(Triangle *) er"));
     5977                        }
    59125978                        I2 A((I2)*er.EdgeVertex(0));
    59135979                        I2 B((I2)*er.EdgeVertex(1));
     
    59806046                Triangle *t1=tt1,*t2=tt2;// les 2 triangles adjacent
    59816047                Int1 a1=tt1,a2=tt2;// les 2 numero de l arete dans les 2 triangles
    5982                 assert ( a1 >= 0 && a1 < 3 );
     6048                if ( a1<0 || a1>=3 ){
     6049                        throw ErrorException(__FUNCT__,exprintf("a1<0 || a1>=3"));
     6050                }
    59836051
    59846052                Vertex & sa= (* t1)[VerticesOfTriangularEdge[a1][0]];
     
    59906058                Icoor2 det1=t1->det , det2=t2->det ;
    59916059                Icoor2 detT = det1+det2;
    5992                 assert((det1>0 ) && (det2 > 0));
    5993                 assert ( (detsa < 0) && (detsb >0) ); // [a,b] cut infinite line va,bb
     6060                if ((det1<=0 ) || (det2<=0)){
     6061                        throw ErrorException(__FUNCT__,exprintf("(det1<=0 ) || (det2<=0)"));
     6062                }
     6063                if ( (detsa>=0) || (detsb<=0) ){ // [a,b] cut infinite line va,bb
     6064                        throw ErrorException(__FUNCT__,exprintf("(detsa>=0) || (detsb<=0)"));
     6065                }
    59946066                Icoor2 ndet1 = bamg::det(s1,sa,s2);
    59956067                Icoor2 ndet2 = detT - ndet1;
     
    60526124        int ForceEdge(Vertex &a, Vertex & b,TriangleAdjacent & taret)  {
    60536125                int NbSwap =0;
    6054                 assert(a.t && b.t); // the 2 vertex is in a mesh
     6126                if (!a.t || !b.t){ // the 2 vertex is in a mesh
     6127                        throw ErrorException(__FUNCT__,exprintf("!a.t || !b.t"));
     6128                }
    60556129                int k=0;
    60566130                taret=TriangleAdjacent(0,0); // erreur
     
    60676141                        v2 = tta.EdgeVertex(0);
    60686142                        vbegin =v2;
    6069                         assert(v2);
     6143                        if (!v2){
     6144                                throw ErrorException(__FUNCT__,exprintf("!v2"));
     6145                        }
    60706146                        det2 = det(*v2,a,b);
    60716147                        //   cout << " No Change try the next" << endl;
     
    60836159                                Vertex * va = &a, *vb = &b;
    60846160                                tc = Previous(tc);
    6085                                 assert ( v1 && v2);
     6161                                if (!v1 || !v2){
     6162                                        throw ErrorException(__FUNCT__,exprintf("!v1 || !v2"));
     6163                                }
    60866164                                Icoor2 detss = 0,l=0,ks;
    60876165                                // cout << "Real ForcingEdge " << *va << *vb << detss << endl;
     
    61056183                        }
    61066184                        tta = tc;
    6107                         assert(k++<2000);
     6185                        k++;
     6186                        if (k>=2000){
     6187                                throw ErrorException(__FUNCT__,exprintf("k>=2000"));
     6188                        }
    61086189                        if ( vbegin == v2 ) return -1;// error
    61096190                }
  • issm/trunk/src/c/Bamgx/objects/Vertex.cpp

    r2850 r2854  
    2828                register int k=0,kk=0,j = EdgesVertexTriangle[vint][0],jc;
    2929                R2 P(s->r),PNew(0,0);
    30                 //  cout << BTh.quadtree << " " <<  BTh.quadtree->root << endl;
    31                 // assert(BTh.quadtree && BTh.quadtree->root);
    3230                do {
    3331                        k++;
     
    4644                        tria = ttc;
    4745                        j = NextEdge[jc];
    48                         assert(k<2000);
     46                        if (k>=2000){
     47                                throw ErrorException(__FUNCT__,exprintf("k>=2000"));
     48                        }
    4949                } while ( tbegin != tria);
    5050                if (kk<4) return 0;
     
    117117                                tria = ttc;
    118118                                j = NextEdge[jc];
    119                                 assert(k<2000);
     119                                if (k>=2000){
     120                                        throw ErrorException(__FUNCT__,exprintf("k>=2000"));
     121                                }
    120122                        } while ( tbegin != tria);
    121123                        if (ok && loop) vP=vPsave; // no move
Note: See TracChangeset for help on using the changeset viewer.