Changeset 2853
- Timestamp:
- 01/15/10 09:52:53 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/objects/Triangles.cpp
r2851 r2853 95 95 nbv++; 96 96 } 97 assert(inbvx == nbv); 97 if (inbvx != nbv){ 98 throw ErrorException(__FUNCT__,exprintf("inbvx != nbv")); 99 } 98 100 for (i=0;i<Tho.nbt;i++) 99 101 if( reft[i] >=0 && flag[i]) … … 103 105 int i1 = Tho.Number(t[1]); 104 106 int i2 = Tho.Number(t[2]); 105 assert(i0>=0 && i1 >= 0 && i2 >= 0); 106 assert(i0<Tho.nbv && i1 <Tho.nbv && i2 <Tho.nbv); 107 // cout <<i<< " F" << flag[i] << " T " << nbt << " = " << kk[i0] << " " << kk[i1] << " " << kk[i2] ; 108 // cout << " OT " << i0 << " " << i1 << " " << i2 << " " << reft[i] << endl; 107 if (i0<0 || i1<0 || i2<0){ 108 throw ErrorException(__FUNCT__,exprintf("i0<0 || i1<0 || i2< 0")); 109 } 110 if (i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv){ 111 throw ErrorException(__FUNCT__,exprintf("i0>=Tho.nbv || i1>=Tho.nbv || i2>=Tho.nbv")); 112 } 109 113 triangles[nbt] = Triangle(this,kk[i0],kk[i1],kk[i2]); 110 114 triangles[nbt].color = Tho.subdomains[reft[i]].ref; 111 115 nbt++; 112 116 } 113 assert(kt==nbt); 114 if (nbt ==0 && nbv ==0) { 117 if (kt!=nbt){ 118 throw ErrorException(__FUNCT__,exprintf("kt!=nbt")); 119 } 120 if (nbt==0 && nbv==0) { 115 121 throw ErrorException(__FUNCT__,exprintf("All triangles have been removed")); 116 122 } … … 124 130 FillHoleInMesh(); 125 131 126 assert(NbSubDomains); 127 assert(subdomains[0].head && subdomains[0].head->link); 132 if (!NbSubDomains){ 133 throw ErrorException(__FUNCT__,exprintf("NbSubDomains==0")); 134 } 135 if (!subdomains[0].head || !subdomains[0].head->link){ 136 throw ErrorException(__FUNCT__,exprintf("!subdomains[0].head || !subdomains[0].head->link")); 137 } 128 138 129 139 } … … 132 142 Triangles::~Triangles() { 133 143 long int verbosity=2; 134 //assert(NbRef<=0);135 144 if (CurrentTh == this) CurrentTh=0; 136 145 //if(vertices) delete [] vertices; //TEST crash if not commented … … 189 198 if (NbVerticesOnGeomEdge) 190 199 VerticesOnGeomEdge = new VertexOnGeom[NbVerticesOnGeomEdge] ; 191 if (& BTh == & Th.BTh) // same back ground 192 { 200 if (& BTh == & Th.BTh){ // same background 193 201 BTh.NbRef++; 194 202 NbVertexOnBThVertex = Th.NbVertexOnBThVertex; … … 199 207 VertexOnBThEdge = new VertexOnEdge[NbVertexOnBThEdge]; 200 208 } 201 else 202 { // no add on back ground mesh 209 else { // no add on background mesh 203 210 BTh.NbRef++; 204 211 NbVertexOnBThVertex=0; … … 206 213 NbVertexOnBThEdge=0; 207 214 VertexOnBThEdge=0; 208 // assert (& BTh == this); // --- a voir209 210 215 } 211 216 … … 232 237 quadtree=0; 233 238 234 235 // assert(!OutSidesTriangles);236 239 } 237 240 /*}}}1*/ … … 409 412 j0 = i0%2; 410 413 i0 = i0/2; 411 assert( v == edges[i0 ].v[j0]); 414 if (v!=edges[i0 ].v[j0]){ 415 throw ErrorException(__FUNCT__,exprintf("v!=edges[i0 ].v[j0]")); 416 } 412 417 edges[i ].adj[ j ] =edges +i0; 413 418 edges[i0].adj[ j0] =edges +i ; 414 assert(edges[i0].v[j0] == v);415 419 v->color = -3; 416 420 } … … 777 781 if(st[k]==-1) st[k]=3*i+j; 778 782 else if(st[k]>=0) { 779 assert( ! triangles[i].TriangleAdj(j) && !triangles[st[k] / 3].TriangleAdj((int) (st[k]%3))); 783 if (triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))){ 784 throw ErrorException(__FUNCT__,exprintf("triangles[i].TriangleAdj(j) || triangles[st[k]/3].TriangleAdj((int) (st[k]%3))")); 785 } 780 786 triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3)); 781 787 if (invisible) triangles[i].SetHidden(j); … … 873 879 } 874 880 } 875 assert(k==nbe); 881 if (k!=nbe){ 882 throw ErrorException(__FUNCT__,exprintf("k!=nbe")); 883 } 876 884 if (edgessave) delete [] edgessave; 877 885 } … … 898 906 j0 = i0%2; 899 907 i0 = i0/2; 900 assert( v == edges[i0 ].v[j0]); 908 if (v!=edges[i0 ].v[j0]){ 909 throw ErrorException(__FUNCT__,exprintf("v!=edges[i0 ].v[j0]")); 910 } 901 911 edges[i ].adj[ j ] =edges +i0; 902 912 edges[i0].adj[ j0] =edges +i ; 903 assert(edges[i0].v[j0] == v);904 // if(verbosity>8)905 // cout << " edges adj " << i0 << " "<< j0 << " <--> " << i << " " << j << endl;906 913 v->color = -3;} 907 914 } 908 915 // now reconstruct the sub domain info 909 assert(!NbSubDomains); 916 if (NbSubDomains){ 917 throw ErrorException(__FUNCT__,exprintf("NbSubDomains should be 0")); 918 } 910 919 NbSubDomains=0; 911 920 … … 972 981 } 973 982 } 974 assert(k== NbSubDomains); 983 if (k!= NbSubDomains){ 984 throw ErrorException(__FUNCT__,exprintf("k!= NbSubDomains")); 985 } 975 986 976 987 delete [] colorT; … … 1038 1049 1039 1050 Gh.coefIcoor= (MaxICoor)/(Max(Gh.pmax.x-Gh.pmin.x,Gh.pmax.y-Gh.pmin.y)); 1040 assert(Gh.coefIcoor >0); 1051 if (Gh.coefIcoor<=0){ 1052 throw ErrorException(__FUNCT__,exprintf("Gh.coefIcoor<=0")); 1053 } 1041 1054 1042 1055 Real8 hmin = HUGE_VAL; … … 1068 1081 Gh.edges[i].SetReverseEqui(); 1069 1082 Gh.edges[i].link= & Gh.edges[j]; 1070 //assert(sens==0);// meme sens pour l'instant1071 1083 } 1072 1084 … … 1087 1099 len[j1] += l12; 1088 1100 hmin = Min(hmin,l12); 1089 1090 1101 Gh.edges[i].ref = edges[i].ref; 1091 1102 1092 1103 k = edge4->addtrie(i0,i1); 1093 1094 assert(k == i); 1104 if (k != i){ 1105 throw ErrorException(__FUNCT__,exprintf("k != i")); 1106 } 1095 1107 1096 1108 } … … 1160 1172 } 1161 1173 Edge * e = &BhAB; 1162 assert( pA && pB && e); 1174 if (!pA || !pB || !e){ 1175 throw ErrorException(__FUNCT__,exprintf("!pA || !pB || !e")); 1176 } 1163 1177 // be carefull the back ground edge e is on same geom edge 1164 1178 // of the initiale edge def by the 2 vertex A B; 1165 assert(e>=BTh.edges && e<BTh.edges+BTh.nbe);// Is a background Mesh; 1179 //check Is a background Mesh; 1180 if (e<BTh.edges || e>=BTh.edges+BTh.nbe){ 1181 throw ErrorException(__FUNCT__,exprintf("e<BTh.edges || e>=BTh.edges+BTh.nbe")); 1182 } 1166 1183 // walk on BTh edge 1167 // assert(0 /* not finish ProjectOnCurve with BackGround Mesh*/);1184 //not finish ProjectOnCurve with BackGround Mesh); 1168 1185 // 1 first find a back ground edge contening the vertex A 1169 1186 // 2 walk n back gound boundary to find the final vertex B … … 1185 1202 // cout << " EXCHANGE A et B) " << endl; 1186 1203 } 1187 else 1188 { // do the search by walking 1189 assert(0 /* A FAIRE */); 1204 else{ // do the search by walking 1205 throw ErrorException(__FUNCT__,exprintf("case not supported yet")); 1190 1206 } 1191 1207 … … 1214 1230 for ( eee=e,iii=sens,te0=tA; 1215 1231 eee && ((( void*) eee) != pB) && (( void*) (v1=&((*eee)[iii]))) != pB ; 1216 neee = eee->adj[iii],iii = 1-neee->Intersection(*eee),eee = neee,v0=v1,te0=1-iii ) 1217 { 1232 neee = eee->adj[iii],iii = 1-neee->Intersection(*eee),eee = neee,v0=v1,te0=1-iii ) { 1218 1233 // cout << kkk << " eee = " << BTh.Number(eee) << " v0= " 1219 1234 // << BTh.Number(v0) << " v1 = " << BTh.Number(v1) << endl; 1220 1235 1221 assert(kkk++<100); 1222 assert(eee); 1236 kkk=kkk+1; 1237 if (kkk>=100){ 1238 throw ErrorException(__FUNCT__,exprintf("kkk>=100")); 1239 } 1240 if (!eee){ 1241 throw ErrorException(__FUNCT__,exprintf("!eee")); 1242 } 1223 1243 Real8 lg0 = lg; 1224 1244 Real8 dp = LengthInterpole(v0->m,v1->m,(R2) *v1 - (R2) *v0); 1225 1245 lg += dp; 1226 if (cas && abscisse <= lg) 1227 { // ok we find the geom edge 1246 if (cas && abscisse <= lg) { // ok we find the geom edge 1228 1247 Real8 sss = (abscisse-lg0)/dp; 1229 1248 Real8 thetab = te0*(1-sss)+ sss*iii; 1230 assert(thetab>=0 && thetab<=1); 1249 if (thetab<0 || thetab>1){ 1250 throw ErrorException(__FUNCT__,exprintf("thetab<0 || thetab>1")); 1251 } 1231 1252 BR = VertexOnEdge(&R,eee,thetab); 1232 1233 // cout << Number(R) << " = " << thetab << " on " << BTh.Number(eee)1234 // << " = " << R << endl;1235 1236 1253 return Gh.ProjectOnCurve(*eee,thetab,R,GR); 1237 1238 1254 } 1239 1255 } 1240 1256 // we find the end 1241 if (v1 != pvB) 1242 { 1257 if (v1 != pvB){ 1243 1258 if (( void*) v1 == pB) 1244 1259 tB = iii; 1245 1260 1246 1261 Real8 lg0 = lg; 1247 assert(eee); 1262 if (!eee){ 1263 throw ErrorException(__FUNCT__,exprintf("!eee")); 1264 } 1248 1265 v1 = pvB; 1249 1266 Real8 dp = LengthInterpole(v0->m,v1->m,(R2) *v1 - (R2) *v0); … … 1254 1271 Real8 sss = (abscisse-lg0)/dp; 1255 1272 Real8 thetab = te0*(1-sss)+ sss*tB; 1256 assert(thetab>=0 && thetab<=1); 1273 if (thetab<0 || thetab>1){ 1274 throw ErrorException(__FUNCT__,exprintf("thetab<0 || thetab>1")); 1275 } 1257 1276 BR = VertexOnEdge(&R,eee,thetab); 1258 1277 return Gh.ProjectOnCurve(*eee,thetab,R,GR); … … 1404 1423 if (ong) // a geometrical edges 1405 1424 { 1406 if (withBackground) 1407 { 1425 if (withBackground){ 1408 1426 // walk on back ground mesh 1409 1427 // newVertexOnBThEdge[ibe++] = VertexOnEdge(vertices[k],bedge,absicsseonBedge); 1410 1428 // a faire -- difficile 1411 1429 // the first PB is to now a background edge between the 2 vertices 1412 assert(edgesGtoB); 1430 if (!edgesGtoB){ 1431 throw ErrorException(__FUNCT__,exprintf("!edgesGtoB")); 1432 } 1413 1433 // cout << " ie = " << ie <<" v0 = " << Number(newedges[ie][0]) << endl; 1414 1434 ong= ProjectOnCurve(*edgesGtoB[Gh.Number(edges[i].on)], … … 1488 1508 for (i=0;i<nbt;i++) { 1489 1509 Triangle & t = triangles[i]; 1490 assert(t.link); 1510 if (!t.link){ 1511 throw ErrorException(__FUNCT__,exprintf("!t.link")); 1512 } 1491 1513 for(int j=0;j<3;j++) 1492 1514 { … … 1586 1608 1587 1609 } 1588 assert (nbinvisible<2); 1610 if (nbinvisible>=2){ 1611 throw ErrorException(__FUNCT__,exprintf("nbinvisible>=2")); 1612 } 1589 1613 // cout << " " << nbinvisible << " " << nbsplitedge << endl; 1590 1614 switch (nbsplitedge) { … … 1597 1621 break; 1598 1622 } 1599 assert(ksplit[i]>=40); 1623 if (ksplit[i]<40){ 1624 throw ErrorException(__FUNCT__,exprintf("ksplit[i]<40")); 1625 } 1600 1626 } 1601 1627 // now do the element split … … 1617 1643 Int4 kk=ksplit[i]/10; 1618 1644 int ke=(int) (ksplit[i]%10); 1619 assert(kk<7 && kk >0); 1645 if (kk>=7 || kk<=0){ 1646 throw ErrorException(__FUNCT__,exprintf("kk>=7 || kk<=0")); 1647 } 1620 1648 1621 1649 // def the numbering k (edge) i vertex … … 1632 1660 Vertex * v2=t0(i2); 1633 1661 1634 // cout << "nbmkadj " << nbmkadj << " it=" << i <<endl; 1635 assert(nbmkadj< 10); 1662 if (nbmkadj>=10){ 1663 throw ErrorException(__FUNCT__,exprintf("nbmkadj>=10")); 1664 } 1636 1665 // -------------------------- 1637 1666 TriangleAdjacent ta0(t0.Adj(i0)),ta1(t0.Adj(i1)),ta2(t0.Adj(i2)); … … 1649 1678 Triangle &t1=triangles[kkk++]; 1650 1679 t1=t0; 1651 assert (kedge[3*i+i0]>=0); 1680 if (kedge[3*i+i0]<0){ 1681 throw ErrorException(__FUNCT__,exprintf("kedge[3*i+i0]<0")); 1682 } 1652 1683 Vertex * v3 = vertices + kedge[3*i+k0]; 1653 1684 … … 1663 1694 Triangle &t2=triangles[kkk++]; 1664 1695 t2=t1=t0; 1665 assert (kedge[3*i+k1]>=0); 1666 assert (kedge[3*i+k2]>=0); 1696 if (kedge[3*i+k1]<0){ 1697 throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k1]<0")); 1698 } 1699 if (kedge[3*i+k2]<0){ 1700 throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k2]<0")); 1701 } 1667 1702 1668 1703 Vertex * v01 = vertices + kedge[3*i+k2]; … … 1686 1721 Triangle &t3=triangles[kkk++]; 1687 1722 t3=t2=t1=t0; 1688 assert(kedge[3*i+k0] >=0 && kedge[3*i+k1] >=0 && kedge[3*i+k2] >=0); 1723 if (kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0){ 1724 throw ErrorException(__FUNCT__,exprintf("kedge[3*i+k0] <0 || kedge[3*i+k1]<0 || kedge[3*i+k2]<0")); 1725 } 1689 1726 Vertex * v12 = vertices + kedge[3*i+k0]; 1690 1727 Vertex * v02 = vertices + kedge[3*i+k1]; … … 1767 1804 } 1768 1805 // cout << " -- " << i << " " << nbmkadj << endl; 1769 assert(nbmkadj<=13);// 13 = 6 + 4 + 3 1806 if (nbmkadj>13){// 13 = 6 + 4 + 1807 throw ErrorException(__FUNCT__,exprintf("nbmkadj>13")); 1808 } 1770 1809 1771 1810 if (kk==6) newNbOfQuad+=3; … … 2103 2142 int rswap =tt[izerodet]->swap(iedge); 2104 2143 2105 if (!rswap) 2106 { 2107 cout << " Pb swap the point s is on a edge =>swap " << iedge << " " << *tt[izerodet] << endl; 2108 } 2109 assert(rswap); 2144 if (!rswap) { 2145 throw ErrorException(__FUNCT__,exprintf("swap the point s is on a edge")); 2146 } 2110 2147 } 2111 2148 } … … 2166 2203 2167 2204 quadtree->Add(vi); 2168 assert (tcvi && tcvi->det >= 0) ;// internal 2205 if (!tcvi || tcvi->det<0){// internal 2206 throw ErrorException(__FUNCT__,exprintf("!tcvi || tcvi->det < 0")); 2207 } 2169 2208 Add(vi,tcvi,dete); 2170 2209 NbSwap += vi.Optim(1); … … 2224 2263 Vertex & vj = vertices[iv]; 2225 2264 Int4 j = vj.ReferenceNumber; 2226 assert( &vj== ordre[j]); 2265 if ( &vj!= ordre[j]){ 2266 throw ErrorException(__FUNCT__,exprintf("&vj!= ordre[j]")); 2267 } 2227 2268 if(i!=j) 2228 2269 { // for valgring … … 2231 2272 } 2232 2273 vj.ReferenceNumber=0; 2233 // cout << " Add " << Number(vj) << " " << vj2234 // << " " << Number(vi) << " <--> " << Number(vj) <<endl;2235 2274 Triangle *tcvj = FindTriangleContening(vj.i,dete); 2236 2275 if (tcvj && !tcvj->link){ … … 2238 2277 } 2239 2278 quadtree->Add(vj); 2240 assert (tcvj && tcvj->det >= 0) ;// internal2241 2279 Add(vj,tcvj,dete); 2242 2280 NbSwap += vj.Optim(1); … … 2317 2355 // we can change first_np_or_next_t[i] 2318 2356 // cout << " Do the triangle " << i << " Next_t=" << next_t << endl; 2319 assert(i>=0 && i < nbt ); 2357 if (i<0 || i>=nbt ){ 2358 throw ErrorException(__FUNCT__,exprintf("i<0 || i>=nbt")); 2359 } 2320 2360 first_np_or_next_t[i] = iter; 2321 2361 for(j=0;j<3;j++) … … 2366 2406 if (first_np_or_next_t[kt]>0) 2367 2407 first_np_or_next_t[kt]=-Headt,Headt=kt; 2368 assert( ta.EdgeVertex(0) == s); 2408 if (ta.EdgeVertex(0)!=s){ 2409 throw ErrorException(__FUNCT__,exprintf("ta.EdgeVertex(0)!=s")); 2410 } 2369 2411 ta = Next(Adj(ta)); 2370 2412 } while ( (tbegin != (Triangle*) ta)); … … 2444 2486 trace = TRACETRIANGLE <0 ? 1 : i == TRACETRIANGLE; 2445 2487 #endif 2446 // cout << " Do the triangle " << i << " Next_t=" << next_t << endl;2447 2488 assert(i>=0 && i < nbt ); 2448 2489 first_np_or_next_t[i] = nbv; // to save the fist new point of triangle
Note:
See TracChangeset
for help on using the changeset viewer.