Ignore:
Timestamp:
May 12, 2010, 2:45:56 PM (15 years ago)
Author:
James Hudson
Message:

Additional documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geometry/quad.py

    r7720 r7721  
    22
    33This is a generic structure that can be used to store any geometry in a quadtree.
    4 
     4It is naive, and does not exploit any coherency - it merely tests a bounding
     5box against all other bounding boxes in its heirarchy.
     6
     7It returns a list of bounding boxes which intersect with the test box, which
     8must then be iterated over to detect actual intersections.
    59
    610"""
     
    1519    """class Cell
    1620
    17     One cell in the plane delimited by southern, northern,
    18     western, eastern boundaries.
     21    One cell in the plane.
    1922    """
    2023 
    2124    def __init__(self, extents, parent,
    2225         name = 'cell'):
     26        """ Construct a new cell.
     27            extents is an AABB defining a region on the plane.
     28            parent is the node above this one, or None if it is root.
     29        """
    2330 
    2431        # Initialise base classes
     
    6269
    6370    def insert(self, new_leaf):
    64         # process list items sequentially
     71        """ Insert a leaf into the quadtree.
     72            new_leaf is a tuple of (AABB extents, data), where data can
     73                     be any user data (geometry, triangle index, etc.).
     74        """
    6575        if type(new_leaf)==type(list()):
    6676            for leaf in new_leaf:
     
    7181
    7282    def _insert(self, new_leaf):   
     83        """ Internal recursive insert.
     84            new_leaf is a tuple of (AABB extents, data), where data can
     85                     be any user data (geometry, triangle index, etc.).       
     86        """
    7387        new_region, data = new_leaf
    7488       
     
    93107                    #return               
    94108
    95             # option 2 - try splitting 2 ways
     109            # option 2 - try splitting 2 ways - no diff noticed in practise
    96110            if subregion1.is_trivial_in(new_region):
    97111                self.children = [Cell(subregion1, self), Cell(subregion2, self)]   
     
    108122     
    109123    def retrieve(self):
    110         """Get all leaves from this tree. """
     124        """Get all leaves from this tree.
     125           return a traversal of the entire tree.
     126        """
    111127       
    112128        leaves_found = list(self.leaves)
     
    121137
    122138    def count(self):
    123         """Count all leaves from this tree. """
     139        """Count all leaves from this tree.
     140           return num of leaves in the tree.
     141        """
    124142       
    125143        leaves_found = len(self.leaves)
     
    134152
    135153    def show(self, depth=0):
    136         """Traverse tree below self
     154        """Traverse tree below self, dumping all information.
    137155        """
    138156        if depth == 0:
     
    159177 
    160178    def test_leaves(self, x):
     179        """ Test all leaves to see if they intersect x.
     180            x is a point to test
     181            return a list of leaves that intersect x
     182        """
    161183        intersecting_regions = []
    162184       
     
    171193 
    172194    def get_siblings(self):
    173         """ return parent and siblings of this node.
     195        """ return siblings of this node. If there is no parent, it
     196                   returns an empty list.
    174197        """
    175198        if not self.parent:
Note: See TracChangeset for help on using the changeset viewer.