Changeset 5018
- Timestamp:
- 08/06/10 11:17:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Bamg/Triangles.cpp
r5016 r5018 2632 2632 Triangle * t=0; 2633 2633 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*/ 2635 2641 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*/ 2639 2647 MeshVertex *a = quadtree->NearestVertex(B.x,B.y) ; 2640 2648 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*/ 2650 2655 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 2656 2659 Icoor2 detop ; 2657 2660 2658 / / number of test triangle2659 int kkkk=0;2660 2661 / / if the initial triangles is outside2662 while ( 2663 int k0=(*t)(0) ? (( (*t)(1) ? ( (*t)(2) ? -1 : 2) : 1 )) : 0; 2664 if (k0<0){ // k0 the NULL vertex2665 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 2667 2670 int k1=NextVertex[k0],k2=PreviousVertex[k0]; 2668 2671 dete[k0]=det(B,(*t)[k1],(*t)[k2]); … … 2671 2674 return t; 2672 2675 t = t->TriangleAdj(OppositeEdge[k0]); 2673 kkkk++; 2674 if (kkkk>=2){ 2675 ISSMERROR("kkkk>=2"); 2676 } 2676 counter++; 2677 ISSMASSERT(counter<2); 2677 2678 } 2678 2679 … … 2680 2681 detop = det(*(*t)(VerticesOfTriangularEdge[jj][0]),*(*t)(VerticesOfTriangularEdge[jj][1]),B); 2681 2682 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 2687 2688 j= OppositeVertex[jj]; 2688 2689 dete[j] = detop; //det(*b,*s1,*s2); … … 2717 2718 if (t->det<0) // outside triangle 2718 2719 dete[0]=dete[1]=dete[2]=-1,dete[OppositeVertex[jj]]=detop; 2719 // NbOfTriangleSearchFind += kkkk;2720 // NbOfTriangleSearchFind += counter; 2720 2721 return t; 2721 2722 }
Note:
See TracChangeset
for help on using the changeset viewer.