Changeset 4144
- Timestamp:
- Jan 8, 2007, 3:20:41 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 5 deleted
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/alpha_shape/alpha_shape.py
r4142 r4144 179 179 180 180 ## Build Delaunay triangulation 181 import anuga.mesh_engine.triang as triang181 from anuga.mesh_engine.mesh_engine import generate_mesh 182 182 points = [] 183 183 seglist = [] … … 186 186 pointattlist = [] 187 187 segattlist = [] 188 trilist = []189 188 190 189 points = [(pt[0], pt[1]) for pt in self.points] … … 192 191 mode = "Qzcn" 193 192 #print "computing delaunay triangulation ... \n" 194 tridata = triang.genMesh(points,seglist,holelist,regionlist,195 pointattlist,segattlist, trilist,mode)193 tridata = generate_mesh(points,seglist,holelist,regionlist, 194 pointattlist,segattlist,mode) 196 195 #print tridata 197 196 #print "point attlist: ", tridata['generatedpointattributelist'],"\n" -
anuga_core/source/anuga/fit_interpolate/test_fit.py
r4135 r4144 271 271 272 272 f = fit_to_mesh(vertices, triangles,fileName, 273 alpha=0.0, max_read_lines=2) 273 alpha=0.0, max_read_lines=2)#, verbose=True) 274 274 answer = linear_function(vertices) 275 275 #print "f\n",f -
anuga_core/source/anuga/mesh_engine/compile.py
r4142 r4144 319 319 print "********** Manually doing dependencies **************" 320 320 compile(['triang.c','triangle.c']) 321 elif filename == 'mesh_engine.c': # not part of ANUGA 322 continue 321 elif filename == 'mesh_engine_c_layer.c': 323 322 #print "********** Manually doing dependencies **************" 324 #compile(['mesh_engine.c','triangle.c'])323 compile(['mesh_engine_c_layer.c','triangle.c']) 325 324 326 325 else: -
anuga_core/source/anuga/mesh_engine/me_compile.py
r4142 r4144 315 315 print '--------------- Trying to compile c-extension %s' %filename 316 316 try: 317 if filename == 'mesh_engine .c':317 if filename == 'mesh_engine_c_layer.c': 318 318 print "********** Manually doing dependencies **************" 319 compile(['mesh_engine .c','triangle.c'])319 compile(['mesh_engine_c_layer.c','triangle.c']) 320 320 else: 321 321 compile(filename) -
anuga_core/source/anuga/mesh_engine/test_generate_mesh.py
r4139 r4144 522 522 suite = unittest.makeSuite(triangTestCase,'test') 523 523 #suite = unittest.makeSuite(triangTestCase,'test_lone_verts4') 524 # ##suite = unittest.makeSuite(triangTestCase,'testrectangleII')524 #suite = unittest.makeSuite(triangTestCase,'testrectangleIIb') 525 525 runner = unittest.TextTestRunner() #verbosity=2) 526 526 runner.run(suite) -
anuga_core/source/anuga/pmesh/mesh.py
r4142 r4144 5 5 Note: A .index attribute is added to objects such as vertices and 6 6 segments, often when reading and writing to files. This information 7 should not be used as per cistant information. It is not the 'index' of7 should not be used as persistant information. It is not the 'index' of 8 8 an element in a list. 9 9 … … 16 16 import sys 17 17 import math 18 import anuga.mesh_engine.triang as triang19 18 import re 20 19 import os … … 23 22 import types 24 23 import exceptions 25 26 import load_mesh 24 from Numeric import array, Float, Int 25 26 27 #import load_mesh 27 28 from anuga.coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE 28 29 from anuga.utilities.polygon import point_in_polygon 29 30 import load_mesh.loadASCII 30 31 import anuga.alpha_shape.alpha_shape 31 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_geospatial, ensure_absolute 32 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_geospatial, ensure_absolute, ensure_numeric 33 from anuga.mesh_engine.mesh_engine import generate_mesh 34 35 #import anuga.mesh_engine_b.mesh_engine as triang 32 36 33 37 try: … … 467 471 Segment.set_default_tag("") 468 472 473 class Rigid_triangulation: 474 """ 475 This is a triangulation that can't have triangles added or taken away. 476 477 It just represents the triangulation, not the mesh outline needed to 478 build the triangulation. 479 480 This is the guts of the data structure; 481 generated vertex list: [(x1,y1),(x2,y2),...] (Tuples of doubles) 482 generated segment list: [(point1,point2),(p3,p4),...] 483 (Tuples of integers) 484 generated segment tag list: [tag,tag,...] list of strings 485 486 generated triangle list: [(p1,p2,p3), (p4,p5,p6),....] tuple of points 487 488 generated triangle attribute list: [s1,s2,...] list of strings 489 490 generated triangle neighbor list: [(t1,t2,t3), (t4,t5,t6),....] 491 tuple of triangles 492 493 Should I do the basic structure like triangle, general 494 mesh or something else? How about like triangle, since 495 that's where the info is from, and it'll fit easier into 496 this file.. 497 498 Removing the loners is difficult, since all the vert's 499 after it must be removed. 500 501 This happens in set_triangulation. 502 503 """ 504 505 def __init__(self, 506 triangles, 507 segments, 508 vertices, 509 triangle_tags, 510 triangle_neighbor, 511 segment_tags, 512 ): 513 514 self.triangles=ensure_numeric(triangles) 515 self.triangle_neighbor=ensure_numeric(triangle_neighbor) 516 self.triangle_tags=triangle_tags 517 self.segments=ensure_numeric(segments) 518 519 self.segment_tags=segment_tags # string 520 self.vertices=ensure_numeric(vertices) 521 522 523 469 524 class Mesh: 470 525 """ … … 1054 1109 #print "mesh#generateMesh# self.mode",self.mode 1055 1110 meshDict = self.Mesh2triangList() 1111 1112 #FIXME (DSG-DSG) move below section into generate_mesh.py 1113 # & 4 functions eg segment_strings2ints 1056 1114 #print "*************************!@!@ This is going to triangle !@!@" 1057 1115 #print meshDict … … 1067 1125 #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%regionlist",meshDict['regionlist'] 1068 1126 #print "meshDict['segmenttaglist']", meshDict['segmenttaglist' 1069 generatedMesh = triang.genMesh(1127 generatedMesh = generate_mesh( 1070 1128 meshDict['pointlist'], 1071 1129 meshDict['segmentlist'], … … 1074 1132 meshDict['pointattributelist'], 1075 1133 meshDict['segmenttaglist'], 1076 [], # since the trianglelist isn't used1077 self.mode)1134 self.mode, 1135 meshDict['pointlist']) 1078 1136 #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%generated",generatedMesh 1079 1137 generatedMesh['generatedsegmentmarkerlist'] = \ … … 1081 1139 segconverter) 1082 1140 #print "processed gen",generatedMesh['generatedsegmentmarkerlist'] 1141 #print "generatedtriangleattributelist",generatedMesh['generatedtriangleattributelist'] 1083 1142 generatedMesh['generatedtriangleattributelist'] = \ 1084 1143 region_ints2strings(generatedMesh['generatedtriangleattributelist'], 1085 1144 regionconverter) 1086 1145 1146 #FIXME (DSG-DSG) move above section into generate_mesh.py 1087 1147 1088 1148 if len(generatedMesh['generatedpointattributelist'][0])==0: … … 1400 1460 -1 means there's no triangle neighbor 1401 1461 triangle attribute list: [(T1att), (T2att), ...] 1462 1463 1402 1464 (list of a list of strings) 1403 1465 lone point list:[point1, ...] (list of integers) -
anuga_core/source/anuga/pmesh/test_mesh.py
r4142 r4144 1068 1068 , 1069 1069 'exported Ascii xya file is wrong') 1070 1070 1071 def test_lone_vert_in_mesh_gen_c_layer(self): 1072 # currently just a copy of the above test 1073 a = Vertex (0,0) 1074 b = Vertex (0,3) 1075 c = Vertex (3,3) 1076 d = Vertex (1,2) 1077 e = Vertex (3,1) 1078 #f = Vertex (3,1) 1079 1080 s1 = Segment(a,b, tag = 50) 1081 s2 = Segment(b,c, tag = 40) 1082 s3 = Segment(c,a, tag = 30) 1083 1084 r1 = Region(2, 1,tag = 1.3) 1085 h1 = Hole(1,4) 1086 # Warning mesh can't produce this type of data structure its self 1087 m = Mesh(userVertices=[a,b,c,d,e], 1088 userSegments=[s1,s2,s3], 1089 regions=[r1], 1090 holes = [h1]) 1091 1092 fileName = tempfile.mktemp(".xya") 1093 #fileName = 't.xya' 1094 #os.remove(fileName) 1095 m.exportPointsFile(fileName) 1096 file = open(fileName) 1097 lFile = file.read().split('\n') 1098 file.close() 1099 1100 os.remove(fileName) 1101 self.failUnless(lFile[0] == "" and 1102 lFile[1] == "0,0" and 1103 lFile[2] == "0,3" and 1104 lFile[3] == "3,3" 1105 , 1106 'exported Ascii xya file is wrong') 1107 self.failUnless(lFile[4] == "1,2" and 1108 lFile[5] == "3,1" 1109 , 1110 'exported Ascii xya file is wrong') 1111 1112 # vertex e is outside of the outline, so 1113 # it is a loner and it is removed. 1114 m.generateMesh("Q", maxArea = 2.1) 1115 fileName = tempfile.mktemp(".xya") 1116 #fileName = 't.xya' 1117 #m.export_mesh_file('m.tsh') 1118 m.exportPointsFile(fileName) 1119 file = open(fileName) 1120 lFile = file.read().split('\n') 1121 file.close() 1122 os.remove(fileName) 1123 1124 self.failUnless(lFile[0] == "" and 1125 lFile[1] == "0.0,0.0" and 1126 lFile[2] == "0.0,3.0" and 1127 lFile[3] == "3.0,3.0" and 1128 lFile[4] == "1.0,2.0" 1129 , 1130 'exported Ascii xya file is wrong') 1131 1071 1132 def test_exportPointsFilefile2(self): 1072 1133 m = Mesh() … … 2276 2337 if __name__ == "__main__": 2277 2338 suite = unittest.makeSuite(meshTestCase,'test') 2278 #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segments') 2339 #suite = unittest.makeSuite(meshTestCase,'test_exportASCIIsegmentoutlinefile') 2340 #suite = unittest.makeSuite(meshTestCase,'test_e') 2279 2341 runner = unittest.TextTestRunner() #verbosity=2) 2280 2342 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.