Changeset 721
- Timestamp:
- Dec 23, 2004, 11:14:48 AM (20 years ago)
- Location:
- inundation/ga/storm_surge/pmesh
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
r719 r721 336 336 else: 337 337 numVertAttrib = str(len(vertices_attributes[0])) 338 fd.write(numVert + " " + numVertAttrib + " # < vertex #> <x> <y> [attributes] ...Triangulation Vertices..." + "\n")338 fd.write(numVert + " " + numVertAttrib + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." + "\n") 339 339 340 340 #<vertex #> <x> <y> [attributes] … … 358 358 #<# of triangles> 359 359 n = len(triangles) 360 fd.write(str(n) + " # < triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." + "\n")360 fd.write(str(n) + " # <# of triangles>, next lines <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." + "\n") 361 361 362 362 # <triangle #> <vertex #> <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region] … … 391 391 #One line: <# of segments> 392 392 fd.write(str(len(segments)) + 393 " # < segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." + "\n")393 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." + "\n") 394 394 395 395 #Following lines: <segment #> <vertex #> <vertex #> [boundary marker] -
inundation/ga/storm_surge/pmesh/mesh.py
r719 r721 1514 1514 else: 1515 1515 numVertAttrib = str(len(userVertices[0].attributes)) 1516 fd.write(numVert + " " + numVertAttrib + " # < vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n")1516 fd.write(numVert + " " + numVertAttrib + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n") 1517 1517 1518 1518 # <x> <y> [attributes] … … 1532 1532 #One line: <# of segments> 1533 1533 fd.write(str(len(userSegments)) + 1534 " # < segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments..." + "\n")1534 " # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments..." + "\n") 1535 1535 1536 1536 #Following lines: <vertex #> <vertex #> [boundary marker] … … 1545 1545 #One line: <# of holes> 1546 1546 fd.write(str(len(holes)) + 1547 " # < Hole #> <x> <y> ...Mesh Holes..." + "\n")1547 " # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes..." + "\n") 1548 1548 # <x> <y> 1549 1549 index = 0 … … 1556 1556 #One line: <# of regions> 1557 1557 fd.write(str(len(regions)) + 1558 " # < Region #> <x> <y> <tag>...Mesh Regions..." + "\n")1558 " # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions..." + "\n") 1559 1559 # <index> <x> <y> <tag> 1560 1560 index = 0 … … 1571 1571 #One line: <# of regions> 1572 1572 fd.write(str(len(regions)) + 1573 " # < Region #> [Max Area] ...Mesh Regions..." + "\n")1573 " # <# of regions>, next lines <Region #> [Max Area] ...Mesh Regions..." + "\n") 1574 1574 for r in regions: 1575 1575 area = r.getMaxArea() -
inundation/ga/storm_surge/pmesh/meshHarness.py
r719 r721 490 490 #print "@^@^" 491 491 492 self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." 492 # no need to check the title again 493 #self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." 494 # ,'Ascii file is wrong, vertex title') 495 self.failUnless(lFile[1] == "0 0.0 0.0 " and #1.1 " and 496 lFile[2] == "1 0.0 4.0 " and #1.2 " and 497 lFile[3] == "2 4.0 0.0 " and #1.3 " and 498 lFile[4] == "3 1.0 1.0 " and #1.4 " and 499 lFile[5] == "4 2.0 2.0 " #1.25 " 500 , 501 'Ascii file is wrong, vertex') 502 503 #self.failUnless(lFile[6] == "# attribute column titles ...Triangulation Vertex Titles..." 504 # ,'Ascii file is wrong, attribute column title') 505 self.failUnless(lFile[8] == "0 3 2 4 -1 2 3 " and 506 lFile[9] == "1 1 0 3 3 2 -1 " and 507 lFile[10] == "2 3 4 1 -1 1 0 " and 508 lFile[11] == "3 2 3 0 1 -1 0 " 509 , 510 'Ascii file is wrong, triangle') 511 512 self.failUnless( lFile[13] == "0 0 1 exterior" and 513 lFile[14] == "1 1 4 exterior" and 514 lFile[15] == "2 2 0 exterior" and 515 lFile[16] == "3 0 3 " and 516 lFile[17] == "4 4 2 exterior" , 517 'Ascii file is wrong, segment') 518 519 # self.failUnless(lFile[18] == '4 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...', 520 # 'Ascii file is wrong, Mesh Vertices Title') 521 522 self.failUnless(lFile[19] == '0 0.0 0.0 ' and #1.1 ' and 523 lFile[20] == '1 0.0 4.0 ' and #1.2 ' and 524 lFile[21] == '2 4.0 0.0 ' and #1.3 ' and 525 lFile[22] == '3 1.0 1.0 ' #1.4 ' 526 , 527 'Ascii file is wrong, Mesh Vertices II') 528 529 self.failUnless(lFile[24] == '0 0 1 ' and 530 lFile[25] == '1 1 2 ' and 531 lFile[26] == '2 0 2 ' and 532 lFile[27] == '3 0 3 ' 533 ,'Ascii file is wrong, Mesh Segments') 534 535 536 def test_ascii_file(self): 537 538 a = Vertex (0.0, 0.0) #, attributes = [1.1]) 539 d = Vertex (0.0, 4.0) #, attributes = [1.2]) 540 f = Vertex (4.0,0.0) #, attributes = [1.3]) 541 e = Vertex (1.0,1.0) #, attributes = [1.4]) 542 543 s1 = Segment(a,d) 544 s2 = Segment(d,f) 545 s3 = Segment(a,f) 546 s4 = Segment(a,e) 547 548 m = Mesh(userVertices=[a,d,f,e], userSegments=[s1,s2,s3,s4]) 549 550 m.generateMesh("QApz", maxArea = 2.1 ) 551 552 seg = m.getMeshSegments() 553 554 fileName = tempfile.mktemp(".txt") 555 m.exportASCIItrianglulationfile(fileName) 556 file = open(fileName) 557 lFile = file.read().split('\n') 558 file.close() 559 os.remove(fileName) 560 561 print "@^@^" 562 for l in lFile: 563 print l,"<" 564 print "@^@^" 565 self.failUnless(lFile[0] == "5 0 # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." 493 566 , 494 567 'Ascii file is wrong, vertex title') … … 504 577 , 505 578 'Ascii file is wrong, attribute column title') 506 self.failUnless(lFile[7] == "4 # < triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and579 self.failUnless(lFile[7] == "4 # <# of triangles>, next lines <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and 507 580 lFile[8] == "0 3 2 4 -1 2 3 " and 508 581 lFile[9] == "1 1 0 3 3 2 -1 " and … … 512 585 'Ascii file is wrong, triangle') 513 586 514 self.failUnless(lFile[12] == "5 # < segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." and587 self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." and 515 588 lFile[13] == "0 0 1 exterior" and 516 589 lFile[14] == "1 1 4 exterior" and … … 520 593 'Ascii file is wrong, segment') 521 594 522 self.failUnless(lFile[18] == '4 0 # < vertex #> <x> <y> [attributes] ...Mesh Vertices...',595 self.failUnless(lFile[18] == '4 0 # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices...', 523 596 'Ascii file is wrong, Mesh Vertices Title') 524 597 … … 530 603 'Ascii file is wrong, Mesh Vertices II') 531 604 532 self.failUnless(lFile[23] == '4 # < segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments...' and605 self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments...' and 533 606 lFile[24] == '0 0 1 ' and 534 607 lFile[25] == '1 1 2 ' and 535 608 lFile[26] == '2 0 2 ' and 536 609 lFile[27] == '3 0 3 ' and 537 lFile[28] == '0 # <Hole #> <x> <y> ...Mesh Holes...' and 538 lFile[29] == '0 # <Region #> <x> <y> <tag>...Mesh Regions...' 539 , 540 'Ascii file is wrong, Mesh Segments') 541 542 543 def test_ascii_file(self): 544 545 a = Vertex (0.0, 0.0) #, attributes = [1.1]) 546 d = Vertex (0.0, 4.0) #, attributes = [1.2]) 547 f = Vertex (4.0,0.0) #, attributes = [1.3]) 548 e = Vertex (1.0,1.0) #, attributes = [1.4]) 549 550 s1 = Segment(a,d) 551 s2 = Segment(d,f) 552 s3 = Segment(a,f) 553 s4 = Segment(a,e) 554 555 m = Mesh(userVertices=[a,d,f,e], userSegments=[s1,s2,s3,s4]) 556 557 m.generateMesh("QApz", maxArea = 2.1 ) 558 559 seg = m.getMeshSegments() 560 561 fileName = tempfile.mktemp(".txt") 562 m.exportASCIItrianglulationfile(fileName) 563 file = open(fileName) 564 lFile = file.read().split('\n') 565 file.close() 566 os.remove(fileName) 567 568 #print "@^@^" 569 #for l in lFile: 570 # print l,"<" 571 #print "@^@^" 572 self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." 573 , 574 'Ascii file is wrong, vertex title') 575 self.failUnless(lFile[1] == "0 0.0 0.0 " and #1.1 " and 576 lFile[2] == "1 0.0 4.0 " and #1.2 " and 577 lFile[3] == "2 4.0 0.0 " and #1.3 " and 578 lFile[4] == "3 1.0 1.0 " and #1.4 " and 579 lFile[5] == "4 2.0 2.0 " #1.25 " 580 , 581 'Ascii file is wrong, vertex') 582 583 self.failUnless(lFile[6] == "# attribute column titles ...Triangulation Vertex Titles..." 584 , 585 'Ascii file is wrong, attribute column title') 586 self.failUnless(lFile[7] == "4 # <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and 587 lFile[8] == "0 3 2 4 -1 2 3 " and 588 lFile[9] == "1 1 0 3 3 2 -1 " and 589 lFile[10] == "2 3 4 1 -1 1 0 " and 590 lFile[11] == "3 2 3 0 1 -1 0 " 591 , 592 'Ascii file is wrong, triangle') 593 594 self.failUnless(lFile[12] == "5 # <segment #> <vertex #> <vertex #> [boundary marker] ...Triangulation Segments..." and 595 lFile[13] == "0 0 1 exterior" and 596 lFile[14] == "1 1 4 exterior" and 597 lFile[15] == "2 2 0 exterior" and 598 lFile[16] == "3 0 3 " and 599 lFile[17] == "4 4 2 exterior" , 600 'Ascii file is wrong, segment') 601 602 self.failUnless(lFile[18] == '4 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...', 603 'Ascii file is wrong, Mesh Vertices Title') 604 605 self.failUnless(lFile[19] == '0 0.0 0.0 ' and #1.1 ' and 606 lFile[20] == '1 0.0 4.0 ' and #1.2 ' and 607 lFile[21] == '2 4.0 0.0 ' and #1.3 ' and 608 lFile[22] == '3 1.0 1.0 ' #1.4 ' 609 , 610 'Ascii file is wrong, Mesh Vertices II') 611 612 self.failUnless(lFile[23] == '4 # <segment #> <vertex #> <vertex #> [boundary marker] ...Mesh Segments...' and 613 lFile[24] == '0 0 1 ' and 614 lFile[25] == '1 1 2 ' and 615 lFile[26] == '2 0 2 ' and 616 lFile[27] == '3 0 3 ' and 617 lFile[28] == '0 # <Hole #> <x> <y> ...Mesh Holes...' and 618 lFile[29] == '0 # <Region #> <x> <y> <tag>...Mesh Regions...' 610 lFile[28] == '0 # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes...' and 611 lFile[29] == '0 # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions...' 619 612 , 620 613 'Ascii file is wrong, Mesh Segments')
Note: See TracChangeset
for help on using the changeset viewer.