Ignore:
Timestamp:
Jan 8, 2007, 11:35:06 AM (18 years ago)
Author:
duncan
Message:

Undoing change committed in r303.

Location:
anuga_core/source/anuga/pmesh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/pmesh/mesh.py

    r4139 r4142  
    55   Note: A .index attribute is added to objects such as vertices and
    66   segments, often when reading and writing to files.  This information
    7    should not be used as persistant information.  It is not the 'index' of
     7   should not be used as percistant information.  It is not the 'index' of
    88   an element in a list.
    99
     
    1616import sys
    1717import math
     18import anuga.mesh_engine.triang as triang
    1819import re
    1920import os
     
    2223import types
    2324import exceptions
    24 from Numeric import array, Float, Int
    25 
    26 
    27 #import load_mesh
     25
     26import load_mesh
    2827from anuga.coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE
    2928from anuga.utilities.polygon import point_in_polygon
    3029import load_mesh.loadASCII
    3130import anuga.alpha_shape.alpha_shape
    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
     31from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_geospatial, ensure_absolute
    3632
    3733try: 
     
    471467Segment.set_default_tag("")       
    472468
    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        
    524469class Mesh:
    525470    """
     
    11091054        #print "mesh#generateMesh# self.mode",self.mode 
    11101055        meshDict = self.Mesh2triangList()
    1111 
    1112         #FIXME (DSG-DSG)  move below section into generate_mesh.py
    1113         #                  & 4 functions eg segment_strings2ints
    11141056        #print "*************************!@!@ This is going to triangle   !@!@"
    11151057        #print meshDict
     
    11251067        #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%regionlist",meshDict['regionlist']
    11261068        #print "meshDict['segmenttaglist']", meshDict['segmenttaglist'
    1127         generatedMesh = generate_mesh(
     1069        generatedMesh = triang.genMesh(
    11281070                              meshDict['pointlist'],
    11291071                              meshDict['segmentlist'],
     
    11321074                              meshDict['pointattributelist'],
    11331075                              meshDict['segmenttaglist'],
    1134                               self.mode,
    1135                               meshDict['pointlist'])
     1076                              [],  # since the trianglelist isn't used
     1077                              self.mode)
    11361078        #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%generated",generatedMesh
    11371079        generatedMesh['generatedsegmentmarkerlist'] = \
     
    11391081                                  segconverter)
    11401082        #print "processed gen",generatedMesh['generatedsegmentmarkerlist']
    1141         #print "generatedtriangleattributelist",generatedMesh['generatedtriangleattributelist']
    11421083        generatedMesh['generatedtriangleattributelist'] = \
    11431084         region_ints2strings(generatedMesh['generatedtriangleattributelist'],
    11441085                                  regionconverter)
    11451086
    1146         #FIXME (DSG-DSG)  move above section into generate_mesh.py
    11471087
    11481088        if len(generatedMesh['generatedpointattributelist'][0])==0:
     
    14601400            -1 means there's no triangle neighbor
    14611401        triangle attribute list: [(T1att), (T2att), ...]
    1462 
    1463 
    14641402            (list of a list of strings)
    14651403        lone point list:[point1, ...] (list of integers)
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r4139 r4142  
    10681068                        ,
    10691069                        'exported Ascii xya file is wrong')
    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        
     1070           
    11321071    def test_exportPointsFilefile2(self):
    11331072        m = Mesh()
     
    23372276if __name__ == "__main__":
    23382277    suite = unittest.makeSuite(meshTestCase,'test')
    2339     #suite = unittest.makeSuite(meshTestCase,'test_exportASCIIsegmentoutlinefile')
    2340     #suite = unittest.makeSuite(meshTestCase,'test_e')
     2278    #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segments')
    23412279    runner = unittest.TextTestRunner() #verbosity=2)
    23422280    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.