Changeset 4901
- Timestamp:
- Jan 3, 2008, 9:58:32 PM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/pmesh2domain.py
r4098 r4901 190 190 """ 191 191 tri_atts = mesh_dict['triangle_tags'] 192 #print "tri_atts", tri_atts193 192 tagged_elements = {} 194 for tri_att_index in range(len(tri_atts)): 195 tagged_elements.setdefault(tri_atts[tri_att_index],[]).append(tri_att_index) 196 #print "DSG pm2do tagged_elements", tagged_elements 193 if tri_atts is None: 194 tagged_elements[''] = range(len(mesh_dict['triangles'])) 195 else: 196 for tri_att_index in range(len(tri_atts)): 197 tagged_elements.setdefault(tri_atts[tri_att_index], 198 []).append(tri_att_index) 197 199 return tagged_elements 198 200 -
anuga_core/source/anuga/load_mesh/loadASCII.py
r4899 r4901 21 21 segment_tags : [tag,tag,...] list of strings 22 22 triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points 23 triangle_tags: [s1,s2,...] A list of list of strings (probably not 24 neccecary. a list of string should be ok) 23 triangle_tags: [s1,s2,...] A list of strings 25 24 triangle_neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles 26 25 … … 512 511 # with triangle, and it seems to have the option of returning 513 512 # more than one value for triangle attributex 514 if triangles_attributes == [] or triangles_attributes[index] == ['']: 513 if triangles_attributes == None or \ 514 triangles_attributes == [] or \ 515 triangles_attributes[index] == ['']: 515 516 att = "" 516 517 else: -
anuga_core/source/anuga/mesh_engine/mesh_engine.py
r4900 r4901 148 148 #print "mesh eng generatedtrianglelist", trianglelist 149 149 #print "mesh eng mesh_dict['triangleattributelist'] ",mesh_dict['triangleattributelist'] 150 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 151 150 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 152 151 if True: 153 152 mesh_dict['generatedtriangleattributelist'] = triangleattributelist … … 155 154 if mesh_dict['generatedtriangleattributelist'].shape[1] == 0: 156 155 mesh_dict['generatedtriangleattributelist'] = None 156 157 157 if trianglelist.shape[0] == 0: 158 158 # There are no triangles. 159 159 # this is used by urs_ungridded2sww 160 160 raise NoTrianglesError 161 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 161 #print "mesh eng mesh_dict['generatedtriangleattributelist'] ", mesh_dict['generatedtriangleattributelist'] 162 163 # the structure of generatedtriangleattributelist is an list of 164 # list of integers. It is transformed into a list of list of 165 # strings later on. This is then inputted into an triangle 166 # object. The triangle object outputs a list of strings. Note 167 # the subtle change! How should I handle this? For my code, when 168 # the list of list of integers is transformed, transform it into a 169 # list of strings, not a list of list of strings. 162 170 163 171 return mesh_dict -
anuga_core/source/anuga/pmesh/graphical_mesh_generator.py
r4830 r4901 1083 1083 """ 1084 1084 if self.Visualise: 1085 for triangle in mesh.getTriangulation(): 1086 self.serial +=1 1087 self.uniqueID = 'M*%d' % self.serial 1088 self.Triangles.visualise(triangle, 1089 self.uniqueID, 1090 self.canvas, 1091 self.SCALE) 1092 1093 if self.Visualise: 1094 Triangles = mesh.sets[mesh.setID[self.selSet]] 1095 for triangle in Triangles: 1096 triangle.draw(self.canvas,1, 1097 scale = self.SCALE, 1098 colour = SET_COLOUR) 1085 mesh.tri_mesh.draw_triangulation(self.canvas, 1086 scale = self.SCALE) 1099 1087 1100 1088 for segment in mesh.getUserSegments(): -
anuga_core/source/anuga/pmesh/mesh.py
r4899 r4901 520 520 vertices, 521 521 triangle_tags, 522 triangle_neighbor ,522 triangle_neighbors, 523 523 segment_tags, 524 524 ): 525 525 526 self.triangles=ensure_numeric(triangles) 527 self.triangle_neighbor=ensure_numeric(triangle_neighbor) 528 self.triangle_tags=triangle_tags 529 self.segments=ensure_numeric(segments) 530 531 self.segment_tags=segment_tags # string 532 self.vertices=ensure_numeric(vertices) 533 534 526 self.triangles = ensure_numeric(triangles) 527 self.triangle_neighbors = ensure_numeric(triangle_neighbors) 528 self.triangle_tags = triangle_tags # list of strings 529 self.segments = ensure_numeric(segments) 530 531 self.segment_tags = segment_tags # list of strings 532 self.vertices = ensure_numeric(vertices) 533 534 535 def draw_triangulation(self, canvas, scale=1, xoffset=0, yoffset=0, 536 colour="green"): 537 """ 538 Draw a triangle, returning the objectID 539 """ 540 541 # FIXME(DSG-DSG) This could be a data structure that is 542 # remembered and doesn't have any duplicates. 543 # but I wouldn't be able to use create_polygon. 544 # regard it as drawing a heap of segments 545 546 for tri in self.triangles: 547 vertices = [] 548 for v_index in range(3): 549 vertices.append(self.vertices[tri[v_index]]) 550 551 objectID = canvas.create_polygon( 552 scale*(vertices[1][0] + xoffset), 553 scale*-1*(vertices[1][1] + yoffset), 554 scale*(vertices[0][0] + xoffset), 555 scale*-1*(vertices[0][1] + yoffset), 556 scale*(vertices[2][0] + xoffset), 557 scale*-1*(vertices[2][1] + yoffset), 558 outline = colour,fill = '' 559 ) 560 535 561 536 562 class Mesh: … … 575 601 self.meshVertices=[] 576 602 603 # Rigid 604 self.tri_mesh=None 605 577 606 self.setID={} 578 607 #a dictionary of names. … … 1211 1240 #print "generatedMesh",generatedMesh 1212 1241 #print "##################" 1213 1214 1242 self.setTriangulation(generatedMesh) 1215 1243 … … 1564 1592 self.meshTriangles[index].setAttribute("") 1565 1593 else: 1566 self.meshTriangles[index].setAttribute(att [0])1594 self.meshTriangles[index].setAttribute(att) 1567 1595 index += 1 1568 1596 … … 1588 1616 ObjectNeighbor[2]) 1589 1617 index += 1 1618 1619 # Setting up the rigid triangulation 1620 self.tri_mesh = Rigid_triangulation( 1621 genDict['generatedtrianglelist'] 1622 ,genDict['generatedsegmentlist'] 1623 ,genDict['generatedpointlist'] 1624 ,genDict['generatedtriangleattributelist'] 1625 ,genDict['generatedtriangleneighborlist'] 1626 ,genDict['generatedsegmentmarkerlist'] 1627 ) 1590 1628 1591 1629 def setMesh(self, genDict): … … 2206 2244 meshDict['triangle_neighbors'] = triangle_neighbors 2207 2245 2246 if self.tri_mesh is not None: 2247 meshDict['triangles'] = self.tri_mesh.triangles 2248 meshDict['triangle_tags'] = self.tri_mesh.triangle_tags 2249 #print "mesh meshDict['triangle_tags']", meshDict['triangle_tags'] 2250 meshDict['triangle_neighbors'] = self.tri_mesh.triangle_neighbors 2251 else: 2252 meshDict['triangles'] = [] 2253 meshDict['triangle_tags'] = [] 2254 meshDict['triangle_neighbors'] = [] 2208 2255 #print "mesh.Mesh2IOTriangulationDict*)*)" 2209 2256 #print meshDict … … 2288 2335 """ 2289 2336 #Clear the current generated mesh values 2290 self.meshTriangles=[] 2291 self.attributeTitles=[] 2292 self.meshSegments=[] 2293 self.meshVertices=[] 2294 2337 self.meshTriangles = [] 2338 self.attributeTitles = [] 2339 self.meshSegments = [] 2340 self.meshVertices = [] 2341 self.tri_mesh = None 2342 2295 2343 #print "mesh.setTriangulation@#@#@#" 2296 2344 #print genDict … … 2353 2401 index += 1 2354 2402 2403 self.tri_mesh = Rigid_triangulation( 2404 genDict['triangles'] 2405 ,genDict['segments'] 2406 ,genDict['vertices'] 2407 ,genDict['triangle_tags'] 2408 ,genDict['triangle_neighbors'] 2409 ,genDict['segment_tags'] 2410 ) 2355 2411 2356 2412 def IOOutline2Mesh(self, genDict): … … 3166 3222 for i in xrange(len(region_list)): 3167 3223 temp = region_list[i] 3168 returned_region_list.append( [convertint2string[int(temp[0])]])3224 returned_region_list.append(convertint2string[int(temp[0])]) 3169 3225 return returned_region_list 3170 3226 … … 3932 3988 # instead of functionName 3933 3989 if __name__ == "__main__": 3934 #from mesh import * 3935 # THIS CAN BE DELETED 3936 m = Mesh() 3937 dict = importUngenerateFile("ungen_test.txt") 3938 m.addVertsSegs(dict) 3939 print m3 3990 pass
Note: See TracChangeset
for help on using the changeset viewer.