Changeset 5018


Ignore:
Timestamp:
08/06/10 11:17:37 (15 years ago)
Author:
Mathieu Morlighem
Message:

better error message

File:
1 edited

Legend:

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

    r5016 r5018  
    26322632                Triangle * t=0;
    26332633                int j,jp,jn,jj;
    2634                 if (tstart) t=tstart;
     2634                int counter;
     2635
     2636                /*Get starting triangle. Take tsart if provided*/
     2637                if (tstart){
     2638                        t=tstart;
     2639                }
     2640                /*Else find the closest Triangle using the quadtree*/
    26352641                else {
    2636                         if (!quadtree){
    2637                                 ISSMERROR("no starting triangle provided and no quadtree available");
    2638                         }
     2642
     2643                        /*Check that the quadtree does exist*/
     2644                        if (!quadtree) ISSMERROR("no starting triangle provided and no quadtree available");
     2645
     2646                        /*Call NearestVertex*/
    26392647                        MeshVertex *a = quadtree->NearestVertex(B.x,B.y) ;
    26402648
    2641                         if (!a || !a->t ) {
    2642                                 if (a) {
    2643                                         printf("TriangleContaining vertex number %i, another call to ReMakeTriangleContainingTheVertex was required\n", Number(a));
    2644                                 }
    2645                                 ISSMERROR("problem in Triangles::FindTriangleContaining");
    2646                         }
    2647                         if (a<vertices || a>=vertices+nbv){
    2648                                 ISSMERROR("a<vertices || a>=vertices+nbv");
    2649                         }
     2649                        /*Check output (Vertex a)*/
     2650                        if (!a)    ISSMERROR("problem while trying to find nearest vertex from a given point. No output found");
     2651                        if (!a->t) ISSMERROR("no triangle is associated to vertex number %i (another call to ReMakeTriangleContainingTheVertex is required)",Number(a)+1);
     2652                        ISSMASSERT(a>=vertices && a<vertices+nbv);
     2653
     2654                        /*Get starting triangle*/
    26502655                        t = a->t;
    2651                         if (t<triangles || t>=triangles+nbt){
    2652                                 a->Echo();
    2653                                 ISSMERROR("t<triangles || t>=triangles+nbt");
    2654                         }
    2655                 }
     2656                        ISSMASSERT(t>=triangles && t<triangles+nbt);
     2657                }
     2658
    26562659                Icoor2  detop ;
    26572660
    2658                 // number of test triangle
    2659                 int kkkk =0;
    2660 
    2661                 // if the initial triangles is outside 
    2662                 while ( t->det < 0){
    2663                         int k0=(*t)(0) ?  ((  (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1  )) : 0;
    2664                         if (k0<0){ // k0 the NULL vertex
    2665                                 ISSMERROR("k0<0");
    2666                         }
     2661                /*initialize number of test triangle*/
     2662                counter=0;
     2663
     2664                /*The initial triangle might be outside*/
     2665                while (t->det < 0){
     2666
     2667                        /*Get a real vertex from this triangle (k0)*/
     2668                        int k0=(*t)(0)?(((*t)(1)?((*t)(2)?-1:2):1)):0;
     2669                        ISSMASSERT(k0>=0);// k0 the NULL vertex
    26672670                        int k1=NextVertex[k0],k2=PreviousVertex[k0];
    26682671                        dete[k0]=det(B,(*t)[k1],(*t)[k2]);
     
    26712674                         return t;
    26722675                        t = t->TriangleAdj(OppositeEdge[k0]);
    2673                         kkkk++;
    2674                         if (kkkk>=2){
    2675                                 ISSMERROR("kkkk>=2");
    2676                         }
     2676                        counter++;
     2677                        ISSMASSERT(counter<2);
    26772678                }
    26782679
     
    26802681                detop = det(*(*t)(VerticesOfTriangularEdge[jj][0]),*(*t)(VerticesOfTriangularEdge[jj][1]),B);
    26812682
    2682                 while(t->det  > 0 ) {
    2683                         kkkk++;
    2684                         if (kkkk>=2000){
    2685                                 ISSMERROR("kkkk>=2000");
    2686                         }
     2683                while(t->det>0) {
     2684
     2685                        /*Increase counter*/
     2686                        if (++counter>=10000) ISSMERROR("Maximum number of iteration reached (threshold = %i).",counter);
     2687
    26872688                        j= OppositeVertex[jj];
    26882689                        dete[j] = detop;  //det(*b,*s1,*s2);
     
    27172718                if (t->det<0) // outside triangle
    27182719                 dete[0]=dete[1]=dete[2]=-1,dete[OppositeVertex[jj]]=detop;
    2719                 //  NbOfTriangleSearchFind += kkkk
     2720                //  NbOfTriangleSearchFind += counter
    27202721                return t;
    27212722        }
Note: See TracChangeset for help on using the changeset viewer.