VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
treeBalancer.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2001 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: treeBalancer.h,v $ $Revision: 1.11 $ $State: Exp $
7 *********************************************************************/
8 #ifndef treeBalancer_H_
9 #define treeBalancer_H_
10 
11 #include "gdb/gdbDefines.h"
12 #include "gdb/gdbNode.h"
13 #include "geometry/extent.h"
14 #include <vlutil/vlConfig.h>
15 #include <vector>
16 
17 // forward declarations
18 class DtGroup;
20 
21 //
22 // DtTreeBalancer defines a tool for balancing GDB node trees.
24 {
25 public:
26  typedef std::vector<DtGdbNode*> DtNodeContainer;
27  typedef DtNodeContainer::iterator DtNodeIterator;
28  typedef DtNodeContainer::const_iterator DtNodeConstIterator;
29 
30 
31  // default constructor
33 
34  // constructor with max number of children
35  DtTreeBalancer(unsigned int maxChildren);
36 
37  // constructor with max branching and maximum number of leaves
38  DtTreeBalancer(unsigned int maxBranching, unsigned int maxNumLeaves);
39 
40  // destructor
41  virtual ~DtTreeBalancer();
42 
43  // copy constructor
44  DtTreeBalancer(const DtTreeBalancer& orig);
45 
46  // assignment operator
47  DtTreeBalancer& operator=(const DtTreeBalancer& orig);
48 
49  // This method returns a balanced tree corresponding to the group. It
50  // uses the original leaves and builds a tree using new groups. The groups
51  // in the old tree are purged.
52  virtual DtGroup* balanceGroupAndPurge(DtGroup* originalGroup);
53 
54  // This method returns a balanced tree corresponding to the group. It
55  // uses the original leaves and builds a tree using new groups. The old
56  // tree is left intact.
57  virtual DtGroup* balanceGroup(DtGroup* originalGroup);
58 
59  // Get/set maximum branching
60  virtual void setMaxBranching(unsigned int value);
61  virtual unsigned int maxBranching() const;
62 
63  // Get/set maximum number of leaves
64  virtual void setMaxNumLeaves(unsigned int value);
65  virtual unsigned int maxNumLeaves() const;
66 
67 protected:
68 
69  // The following method adds all the GDB nodes in a list to group
70  virtual void addNodesToGroup(const DtNodeContainer& nodeContainer, DtGroup& group) const;
71 
72  // The following prints out extents for debugging
73  virtual void printExtents(const DtNodeContainer& nodeContainer) const;
74 
75  // Pack the nodes in the *from* list into the *to* list with at
76  // most groupSize nodes in each package.
77  virtual void packNodes(DtNodeContainer& toContainer,
78  DtNodeContainer& fromContainer,
79  unsigned int groupSize) const;
80 
81  // the following finds the node in a container of nodes that minimally
82  // increases the x-y area of the extent of a separate node.
83  virtual void findBestNode(DtGdbNode* comparator, DtNodeContainer& nodeContainer,
84  double& cost, DtGdbNode*& bestNode) const;
85 
86  // the following finds the north-west-most node in a list
87  // increases the x-y area of the extent of a separate node.
88  virtual DtGdbNode* findNorthWestNode(DtNodeContainer& nodeContainer) const;
89 
90  // the following balances the tree beneath each coordinate system
91  // in a list of coordinate systems.
92  virtual void balanceCoordinateSystems(DtGdbNode::DtFoundInstancesContainer& nodeInstances);
93 
94  // Balances the tree beneath a coordinate system node.
95  virtual void balanceCoordinateSystemNode(DtBaseCoordinateSystem* coordSys);
96 
97 protected:
98 
99  unsigned int myMaxBranching;
100  unsigned int myMaxNumLeaves;
103 
104  static const unsigned int groupSizeMultiplier;
105 };
106 
107 #endif
108 

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)