Changeset 5673 for anuga_core/source


Ignore:
Timestamp:
Aug 22, 2008, 11:56:30 AM (17 years ago)
Author:
duncan
Message:

update to add_points_and_segments

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

Legend:

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

    r5209 r5673  
    872872
    873873    def add_points_and_segments(self, points,
    874                                   segments, segment_tags = None):
     874                                  segments=None, segment_tags = None):
    875875        """
    876876        Add an outline of the mesh.
    877         Vertices is a list of points/ a standard representation of points.
     877        Points is a list of points a standard representation of points.
    878878        Segments is a list of tuples of integers.  Each tuple defines the
    879            start and end of the segment by it's vertex index, in relation to
    880            the list of vertices.
     879           start and end of the segment by it's point index.
    881880        segment_tags is an optional dictionary which is used to add tags to
    882881           the segments.  The key is the tag name, value is the list of segment
     
    887886        #make sure the points are absolute
    888887        points = ensure_absolute(points)
    889        
     888
     889        if segments is None:
     890            segments = []
     891            for i in range(len(points)-1):
     892                segments.append([i, i+1])
     893           
    890894        #create points, segs and tags
    891895        region_dict = {}
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r5207 r5673  
    15001500        points =  [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
    15011501        segments = [[0, 1], [1, 2]]
    1502         segment_tags = {'do-op':[1]}
     1502        segment_tags = {'hair':[1]}
    15031503        m.add_points_and_segments(points,
    15041504                                    segments, segment_tags)
     
    15131513        self.failUnless(m.userSegments[0].tag =='food',
    15141514                        'Wrong segment tag length.')
    1515         self.failUnless(m.userSegments[1].tag =='do-op',
     1515        self.failUnless(m.userSegments[1].tag =='hair',
     1516                        'Wrong segment tag.')
     1517       
     1518    def test_add_points_and_segmentsII(self):
     1519        m = Mesh()
     1520        Segment.set_default_tag("food")
     1521        dict = {}
     1522        points =  [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]]
     1523        segments = None #[[0, 1], [1, 2]]
     1524        segment_tags = {'hair':[1]}
     1525        m.add_points_and_segments(points,
     1526                                    segments, segment_tags)
     1527        # have to reset this , since it's a class attribute
     1528        Segment.set_default_tag("")
     1529
     1530       
     1531        self.failUnless(len(m.userSegments) ==2,
     1532                        'Wrong segment list length.')
     1533        self.failUnless(len(m.userVertices) == 3,
     1534                        'Wrong vertex list length.')
     1535        self.failUnless(m.userSegments[0].tag =='food',
     1536                        'Wrong segment tag length.')
     1537        self.failUnless(m.userSegments[1].tag =='hair',
    15161538                        'Wrong segment tag.')
    15171539       
     
    18421864         
    18431865        self.failUnless(segs[2].tag=='bom',
    1844                         'FAILED!') 
     1866                        'FAILED!')
    18451867        self.failUnless(segs[3].tag=='',
    18461868                        'FAILED!')
     
    22872309    #suite = unittest.makeSuite(meshTestCase,'test_asciiFile')
    22882310    #suite = unittest.makeSuite(meshTestCase,'test_mesh2IO')
    2289     #suite = unittest.makeSuite(meshTestCase,'test_import_ungenerate_file')
     2311    #suite = unittest.makeSuite(meshTestCase,'test_add_points_and_segmentsII')
    22902312    runner = unittest.TextTestRunner() #verbosity=2)
    22912313    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.