VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
segmentMxCifTree.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2001 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: segMxCifTree.h,v $ $Revision: 1.15 $ $State: Exp $
7 *********************************************************************/
8 #ifndef segmentMxCifTree_H_
9 #define segmentMxCifTree_H_
10 
11 // \file segMxDifTree.h
12 // \brief Contains the DtSegmentMxCifTree class declaration.
13 
14 #include "gdb/gdbDefines.h"
15 #include <stdio.h>
16 #include <vlutil/vlNetTypes.h>
17 #include <vlutil/vlConfig.h>
18 #include <list>
19 
20 class DtNetworkSegment;
22 
23 
24 //
25 // DtSegmentMxCifTree is a node for an MX-CIF Quadtree. The intended use is to
26 // spatially sort collection of network segments. It's depth is limited to prevent
27 // degenerate cases from causing excessive memory usage. Segments can be added
28 // and removed from the tree, but adding and removing will, over time, degrade
29 // the searching efficiency of the structure.
30 //
32 {
33 public:
34 
35  // enumerations for locale
36  enum DtLocale
37  {
42  MULTIPLE
43  };
44 
45  // default constructor
46  DtSegmentMxCifTree(unsigned int depth);
47 
48  // constructor with an extent
49  DtSegmentMxCifTree(double lowX, double highX, double lowY, double highY, unsigned int depth);
50 
51  // destructor
52  virtual ~DtSegmentMxCifTree();
53 
54 private:
55 
56  // copy constructor (not implemented)
58 
59  // assignment operator (not implemented)
60  DtSegmentMxCifTree& operator=(const DtSegmentMxCifTree& orig);
61 
62 public:
63 
64  typedef std::list<const DtNetworkSegment*> DtPtrConstSegmentContainer;
65  typedef DtPtrConstSegmentContainer::const_iterator DtPtrConstSegmentConstIter;
66  typedef DtPtrConstSegmentContainer::iterator DtPtrConstSegmentIter;
67 
68  typedef std::list<DtNetworkSegment*> DtPtrSegmentContainer;
69  typedef DtPtrSegmentContainer::const_iterator DtPtrSegmentConstIter;
70  typedef DtPtrSegmentContainer::iterator DtPtrSegmentIter;
71 
72 
73  // add a new element (the lower and left boundaries in
74  // each quad are closed)
75  virtual void add(DtNetworkSegment& segmentToAdd);
76 
77  // Remove the specified element, if it is contained.
78  virtual bool remove(const DtNetworkSegment& segmentToRemove);
79 
80  // collect all segments that are validated by the metric
81  virtual void collectAllSegments(const DtNetworkSegmentMetric& metric,
82  DtPtrConstSegmentContainer& segments) const;
83  virtual void collectAllSegments(const DtNetworkSegmentMetric& metric,
84  DtPtrSegmentContainer& segments);
85 
86  // find the best valid segment in the tree as measured by the metric
87  virtual const DtNetworkSegment* findBestSegment(const DtNetworkSegmentMetric& metric) const;
88 
89  // expand the extent. Only changes the pivot if there are no children.
90  virtual void expandXY(double lowX, double highX, double lowY, double highY);
91 
92  // Clears the instance, returning it to the same state as the *default constructor*.
93  virtual void clear();
94 
95  // \return A boolean indicating whether or not any elements are currently sorted
96  // in the structure or not.
97  virtual bool empty() const;
98 
99  virtual int size() const;
100 
101  virtual int sizeInBytes() const;
102 
103 protected:
104 
105  // Add the element to the specified destination. If the destination doesn't
106  // exist, create it using the specified boundaries.
107  void addElement(DtSegmentMxCifTree*& destination, double lowX, double highX,
108  double lowY, double highY, DtNetworkSegment& elementToAdd);
109 
110  // Remove the element from the specified destination, if it exists.
111  // \return True if the element was found and removed, and false otherwise.
112  bool removeElement(DtSegmentMxCifTree*& destination, const DtNetworkSegment& elementToRemove);
113 
114  // find the best valid segment in a subtree. pointer best must be valid.
115  virtual const DtNetworkSegment* findBestInSubtree(const DtNetworkSegmentMetric& metric,
116  double& bestCost) const;
117 
118  // calculate a segment's locale
119  DtLocale findLocale(const DtNetworkSegment& newNetworkSegment) const;
120 
121 
122 protected:
123 
129  double myPivotX;
130  double myPivotY;
131  double myLowY;
132  double myHighY;
133  double myLowX;
134  double myHighX;
135 
136  // If this is non-zero, then child segment trees will be created as appropriate
137  // for all locales, each one with a depth of one less.
138  // If it is zero, no child segment trees will be created.
139  unsigned int myDepth;
140 };
141 
142 #endif
DtPtrSegmentContainer::const_iterator DtPtrSegmentConstIter
Definition: segmentMxCifTree.h:69
double myHighY
Definition: segmentMxCifTree.h:132
unsigned int myDepth
Definition: segmentMxCifTree.h:139
std::list< const DtNetworkSegment * > DtPtrConstSegmentContainer
Definition: segmentMxCifTree.h:64
DtNetworkSegmentMetric is a metric for network segments.
Definition: networkSegmentMetric.h:18
double myLowX
Definition: segmentMxCifTree.h:133
voidpf void uLong size
Definition: ioapi.h:39
Definition: networkSegment.h:26
DtSegmentMxCifTree * myNE
Definition: segmentMxCifTree.h:127
#define DT_DLL_gdb
Definition: gdbDefines.h:25
Definition: segmentMxCifTree.h:31
Definition: segmentMxCifTree.h:41
double myPivotX
Definition: segmentMxCifTree.h:129
double myHighX
Definition: segmentMxCifTree.h:134
DtLocale
Definition: segmentMxCifTree.h:36
std::list< DtNetworkSegment * > DtPtrSegmentContainer
Definition: segmentMxCifTree.h:68
DtSegmentMxCifTree * myNW
Definition: segmentMxCifTree.h:128
Definition: segmentMxCifTree.h:40
Definition: segmentMxCifTree.h:39
DtPtrSegmentContainer::iterator DtPtrSegmentIter
Definition: segmentMxCifTree.h:70
DtSegmentMxCifTree * mySW
Definition: segmentMxCifTree.h:125
double myPivotY
Definition: segmentMxCifTree.h:130
Definition: segmentMxCifTree.h:38
DtPtrConstSegmentContainer::const_iterator DtPtrConstSegmentConstIter
Definition: segmentMxCifTree.h:65
DtPtrConstSegmentContainer::iterator DtPtrConstSegmentIter
Definition: segmentMxCifTree.h:66
DtSegmentMxCifTree * mySE
Definition: segmentMxCifTree.h:126
DtPtrSegmentContainer myElements
Definition: segmentMxCifTree.h:124
double myLowY
Definition: segmentMxCifTree.h:131

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)