Changeset 2855
- Timestamp:
- 01/15/10 11:38:50 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Bamgx.cpp
r2806 r2855 19 19 #include <setjmp.h> 20 20 #include <new> 21 #include <cassert>22 21 #include <iomanip> 23 22 #include <fstream> -
issm/trunk/src/c/Bamgx/Mesh2.h
r2852 r2855 1 // -*- Mode : c++ -*-2 //3 // SUMMARY :4 // USAGE :5 // ORG :6 // AUTHOR : Frederic Hecht7 // E-MAIL : hecht@ann.jussieu.fr8 //9 10 /*11 12 This file is part of Freefem++13 14 Freefem++ is free software; you can redistribute it and/or modify15 it under the terms of the GNU Lesser General Public License as published by16 the Free Software Foundation; either version 2.1 of the License, or17 (at your option) any later version.18 19 Freefem++ is distributed in the hope that it will be useful,20 but WITHOUT ANY WARRANTY; without even the implied warranty of21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the22 GNU Lesser General Public License for more details.23 24 You should have received a copy of the GNU Lesser General Public License25 along with Freefem++; if not, write to the Free Software26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA27 */28 1 #ifndef _MESH2_H_ 29 2 #define _MESH2_H_ 30 3 31 4 #include "../objects/objects.h" 5 #include "../shared/shared.h" 6 #include "../include/macros.h" 7 #include "../toolkits/toolkits.h" 32 8 33 9 //From MeshIo … … 38 14 #include <cstdlib> 39 15 #include <cctype> 40 using namespace std;41 42 16 #include <stdlib.h> 43 17 #include <math.h> 44 18 #include <limits.h> 45 19 #include <time.h> 20 46 21 #if (defined(unix) || defined(__unix)) && !defined(__AIX) 47 22 #define SYSTIMES … … 53 28 #include "R2.h" 54 29 30 using namespace std; 55 31 namespace bamg { 56 32 … … 262 238 // on the curve edge a t in [0:1] 263 239 Edge * adj[2]; // the 2 adj edges if on the same curve 240 264 241 int Intersection(const Edge & e) const { 265 if (!(adj[0]==&e || adj[1]==&e)) 266 std::cerr << "Bug : Intersection " << (void*) &e << " " 267 << adj[0] << " " << adj[1] << std::endl; 268 assert(adj[0]==&e || adj[1]==&e); 269 return adj[0]==&e ? 0 : 1;} 242 if (!(adj[0]==&e || adj[1]==&e)){ 243 throw ErrorException(__FUNCT__,exprintf("Intersection bug")); 244 } 245 if (adj[0]!=&e && adj[1]!=&e){ 246 throw ErrorException(__FUNCT__,exprintf("adj[0]!=&e && adj[1]!=&e")); 247 } 248 return adj[0]==&e ? 0 : 1; 249 } 270 250 Real8 MetricLength() const ; 271 251 inline void Set(const Triangles &,Int4,Triangles &); … … 285 265 void Set(){cas=0;} 286 266 GeometricalVertex() :cas(0), link(this) {}; 287 GeometricalVertex * The() { assert(link); return link;}// return a unique vertices 267 268 GeometricalVertex * The() { 269 if (!link){ 270 throw ErrorException(__FUNCT__,exprintf("!link")); 271 } 272 return link; 273 }// return a unique vertices 274 288 275 int IsThe() const { return link == this;} 289 276 … … 496 483 R2 F(Real8 s){ 497 484 Real8 c01=lEnd-lBegin, c0=(lEnd-s)/c01, c1=(s-lBegin)/c01; 498 assert(lBegin<= s && s <=lEnd); 485 if (lBegin>s || s>lEnd){ 486 throw ErrorException(__FUNCT__,exprintf("lBegin>s || s>lEnd")); 487 } 499 488 return e->F(sBegin*c0+sEnd*c1);} 500 489 }; … … 534 523 int mneo= MaxNbSeg; 535 524 MaxNbSeg *= 2; 536 if (verbosity>3) 537 std::cout <<" reshape lSegsI from " << mneo << " to "538 << MaxNbSeg <<std::endl;525 if (verbosity>3){ 526 printf(" reshape lSegsI from %i to %i\n",mneo,MaxNbSeg); 527 } 539 528 SegInterpolation * lEn = new SegInterpolation[MaxNbSeg]; 540 assert(lSegsI && NbSeg < MaxNbSeg); 529 if (!lSegsI || NbSeg>=MaxNbSeg){ 530 throw ErrorException(__FUNCT__,exprintf("!lSegsI || NbSeg>=MaxNbSeg")); 531 } 541 532 for (int i=0;i< NbSeg;i++) 542 533 lEn[i] = lSegsI[MaxNbSeg]; // copy old to new … … 557 548 void ReShape() { 558 549 register int newsize = MaxSize*2; 559 IntersectionTriangles * nw = new IntersectionTriangles[newsize]; 560 assert(nw); 550 IntersectionTriangles* nw = new IntersectionTriangles[newsize]; 551 if (!nw){ 552 throw ErrorException(__FUNCT__,exprintf("!nw")); 553 } 561 554 for (int i=0;i<MaxSize;i++) // recopy 562 555 nw[i] = lIntTria[i]; … … 672 665 int i0=VerticesOfTriangularEdge[i][0]; 673 666 int i1=VerticesOfTriangularEdge[i][0]; 674 assert(New[0] && New[1]); 667 if (!New[0] && !New[1]){ 668 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]")); 669 } 675 670 T(i0) = New[0]; 676 671 T(i1) = New[1];} … … 679 674 int i0=VerticesOfTriangularEdge[i][0]; 680 675 int i1=VerticesOfTriangularEdge[i][0]; 681 assert(New[0] && New[1]); 676 if (!New[0] && !New[1]){ 677 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]")); 678 } 682 679 T(i0) = TheVertex(T(i0)); 683 680 T(i1) = TheVertex(T(i1));} … … 1068 1065 { 1069 1066 *this = Th.subdomains[i]; 1070 assert( head - Th.triangles >=0 && head - Th.triangles < Th.nbt); 1067 if ( head-Th.triangles<0 || head-Th.triangles>=Th.nbt){ 1068 throw ErrorException(__FUNCT__,exprintf("head-Th.triangles<0 || head-Th.triangles>=Th.nbt")); 1069 } 1071 1070 head = ThNew.triangles + Th.Number(head) ; 1072 assert(edge - Th.edges >=0 && edge - Th.edges < Th.nbe); 1071 if (edge-Th.edges<0 || edge-Th.edges>=Th.nbe);{ 1072 throw ErrorException(__FUNCT__,exprintf("edge-Th.edges<0 || edge-Th.edges>=Th.nbe")); 1073 } 1073 1074 edge = ThNew.edges+ Th.Number(edge); 1074 1075 } … … 1208 1209 Vertex *v=Th->vertices; 1209 1210 Int4 nbv = Th->nbv; 1210 assert(i >=0 && j >=0 && k >=0); 1211 assert(i < nbv && j < nbv && k < nbv); 1211 if (i<0 || j<0 || k<0){ 1212 throw ErrorException(__FUNCT__,exprintf("i<0 || j<0 || k<0")); 1213 } 1214 if (i>=nbv || j>=nbv || k>=nbv){ 1215 throw ErrorException(__FUNCT__,exprintf("i>=nbv || j>=nbv || k>=nbv")); 1216 } 1212 1217 ns[0]=v+i; 1213 1218 ns[1]=v+j; … … 1282 1287 int i = a->vint; 1283 1288 TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge 1284 assert(t && i>=0 && i < 3); 1285 assert( a == (*t)(i)); 1289 if (!t || i<0 || i>=3){ 1290 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3")); 1291 } 1292 if ( a!=(*t)(i)){ 1293 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)")); 1294 } 1286 1295 int k=0; 1287 1296 do { // turn around vertex in direct sens (trigo) 1288 k++;assert(k< 20000); 1297 k++; 1298 if (k>=20000){ 1299 throw ErrorException(__FUNCT__,exprintf("k>=20000")); 1300 } 1289 1301 // in no crack => ta.EdgeVertex(1) == a otherwise ??? 1290 1302 if (ta.EdgeVertex(1) == a && ta.EdgeVertex(0) == b) return ta; // find … … 1293 1305 --ta; 1294 1306 } while (t != (Triangle *)ta); 1295 assert(0);1296 return TriangleAdjacent(0,0);// error1307 throw ErrorException(__FUNCT__,exprintf("FindTriangleAdjacent: triangle not found")); 1308 return TriangleAdjacent(0,0);//for compiler 1297 1309 } 1298 1310 … … 1303 1315 int i = a->vint; 1304 1316 TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge 1305 assert(t && i>=0 && i < 3); 1306 assert( a == (*t)(i)); 1317 if (!t || i<0 || i>=3){ 1318 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3")); 1319 } 1320 if ( a!=(*t)(i)){ 1321 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)")); 1322 } 1307 1323 int k=0; 1308 1324 do { // turn around vertex in direct sens (trigo) 1309 k++;assert(k< 20000); 1325 k++; 1326 if (k>=20000){ 1327 throw ErrorException(__FUNCT__,exprintf("k>=20000")); 1328 } 1310 1329 // in no crack => ta.EdgeVertex(1) == a 1311 1330 if ((rr=ta.EdgeVertex(0)) < r) r = rr;
Note:
See TracChangeset
for help on using the changeset viewer.