Changeset 4901 for anuga_core/source/anuga/pmesh/mesh.py
 Timestamp:
 Jan 3, 2008, 9:58:32 PM (17 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

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(DSGDSG) 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.