VR-Forces 4.0.4 Class Documentation
include/gdb/treeBalancer.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2001 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: treeBalancer.h,v $ $Revision: 1.11 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef treeBalancer_H_
00009 #define treeBalancer_H_
00010 
00011 #include "gdb/gdbDefines.h"
00012 #include "gdb/gdbNode.h"
00013 #include "geometry/tdbextent.h"
00014 #include <vlutil/vlConfig.h>
00015 #include <vector>
00016 
00017 // forward declarations
00018 class DtGroup;
00019 class DtBaseCoordinateSystem;
00020 
00021 //
00022 // DtTreeBalancer defines a tool for balancing GDB node trees.
00023 class DT_DLL_gdb DtTreeBalancer 
00024 {
00025 public:
00026    typedef std::vector<DtGdbNode*> DtNodeContainer;
00027    typedef DtNodeContainer::iterator DtNodeIterator;
00028    typedef DtNodeContainer::const_iterator DtNodeConstIterator;
00029 
00030 
00031    // default constructor
00032    DtTreeBalancer();
00033 
00034    // constructor with max number of children
00035    DtTreeBalancer(unsigned int maxChildren);
00036 
00037    // constructor with max branching and maximum number of leaves
00038    DtTreeBalancer(unsigned int maxBranching, unsigned int maxNumLeaves);
00039 
00040    // destructor
00041    virtual ~DtTreeBalancer();
00042 
00043    // copy constructor
00044    DtTreeBalancer(const DtTreeBalancer& orig);
00045 
00046    // assignment operator
00047    DtTreeBalancer& operator=(const DtTreeBalancer& orig);
00048 
00049    // This method returns a balanced tree corresponding to the group.  It
00050    // uses the original leaves and builds a tree using new groups.  The groups
00051    // in the old tree are purged.
00052    virtual DtGroup* balanceGroupAndPurge(DtGroup* originalGroup);
00053 
00054    // This method returns a balanced tree corresponding to the group.  It
00055    // uses the original leaves and builds a tree using new groups.  The old
00056    // tree is left intact.
00057    virtual DtGroup* balanceGroup(DtGroup* originalGroup);
00058 
00059    // Get/set maximum branching
00060    virtual void setMaxBranching(unsigned int value);
00061    virtual unsigned int maxBranching() const;
00062 
00063    // Get/set maximum number of leaves
00064    virtual void setMaxNumLeaves(unsigned int value);
00065    virtual unsigned int maxNumLeaves() const;
00066 
00067 protected:
00068 
00069    // The following method adds all the GDB nodes in a list to group
00070    virtual void addNodesToGroup(const DtNodeContainer& nodeContainer, DtGroup& group) const;
00071 
00072    // The following prints out extents for debugging
00073    virtual void printExtents(const DtNodeContainer& nodeContainer) const;
00074 
00075    // Pack the nodes in the *from* list into the *to* list with at
00076    // most groupSize nodes in each package.
00077    virtual void packNodes(DtNodeContainer& toContainer, 
00078       DtNodeContainer& fromContainer, 
00079       unsigned int groupSize) const;
00080 
00081    // the following finds the node in a container of nodes that minimally 
00082    // increases the x-y area of the extent of a separate node.
00083    virtual void findBestNode(DtGdbNode* comparator, DtNodeContainer& nodeContainer, 
00084       double& cost, DtGdbNode*& bestNode) const;
00085 
00086    // the following finds the north-west-most node in a list 
00087    // increases the x-y area of the extent of a separate node.
00088    virtual DtGdbNode* findNorthWestNode(DtNodeContainer& nodeContainer) const;
00089 
00090    // the following balances the tree beneath each coordinate system
00091    // in a list of coordinate systems. 
00092    virtual void balanceCoordinateSystems(DtGdbNode::DtFoundInstancesContainer& nodeInstances);
00093 
00094    // Balances the tree beneath a coordinate system node.
00095    virtual void balanceCoordinateSystemNode(DtBaseCoordinateSystem* coordSys);
00096 
00097 protected:
00098 
00099    unsigned int myMaxBranching;
00100    unsigned int myMaxNumLeaves;
00101    bool myPurgeFlag;
00102    DtExtent myExtent;
00103 
00104    static const unsigned int groupSizeMultiplier;
00105 };
00106 
00107 #endif
00108 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)