VR-Forces 4.0.4 Class Documentation
include/gdb/segMxCifTree.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2001 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: segMxCifTree.h,v $ $Revision: 1.15 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef segMxCifTree_H_
00009 #define segMxCifTree_H_
00010 
00011 // \file segMxDifTree.h
00012 // \brief Contains the DtSegmentMxCifTree class declaration.
00013 
00014 #include "gdb/gdbDefines.h"
00015 #include <stdio.h>
00016 #include <vlutil/vlNetTypes.h>
00017 #include <vlutil/vlConfig.h>
00018 #include <list>
00019 
00020 class DtNetworkSegment;
00021 class DtNetworkSegmentMetric;
00022 
00023 
00024 //
00025 // DtSegmentMxCifTree is a node for an MX-CIF Quadtree.  The intended use is to
00026 // spatially sort collection of network segments.  It's depth is limited to prevent
00027 // degenerate cases from causing excessive memory usage.  Segments can be added
00028 // and removed from the tree, but adding and removing will, over time, degrade
00029 // the searching efficiency of the structure.
00030 //
00031 class DT_DLL_gdb DtSegmentMxCifTree
00032 {
00033 public:
00034 
00035    // enumerations for locale 
00036    enum DtLocale
00037    {
00038       SOUTHWEST,
00039       SOUTHEAST,
00040       NORTHEAST,
00041       NORTHWEST,
00042       MULTIPLE
00043    };
00044 
00045    // default constructor 
00046    DtSegmentMxCifTree(unsigned int depth);
00047 
00048    // constructor with an extent
00049    DtSegmentMxCifTree(double lowX, double highX, double lowY, double highY, unsigned int depth);
00050 
00051    // destructor
00052    virtual ~DtSegmentMxCifTree();
00053 
00054 private:
00055 
00056    // copy constructor (not implemented)
00057    DtSegmentMxCifTree(const DtSegmentMxCifTree& orig);
00058 
00059    // assignment operator (not implemented)
00060    DtSegmentMxCifTree& operator=(const DtSegmentMxCifTree& orig);
00061 
00062 public:
00063 
00064    typedef std::list<const DtNetworkSegment*> DtPtrConstSegmentContainer;
00065    typedef DtPtrConstSegmentContainer::const_iterator DtPtrConstSegmentConstIter;
00066    typedef DtPtrConstSegmentContainer::iterator DtPtrConstSegmentIter;
00067 
00068    typedef std::list<DtNetworkSegment*> DtPtrSegmentContainer;
00069    typedef DtPtrSegmentContainer::const_iterator DtPtrSegmentConstIter;
00070    typedef DtPtrSegmentContainer::iterator DtPtrSegmentIter;
00071 
00072 
00073    // add a new element (the lower and left boundaries in
00074    // each quad are closed)
00075    virtual void add(DtNetworkSegment& segmentToAdd);
00076 
00077    // Remove the specified element, if it is contained.
00078    virtual bool remove(const DtNetworkSegment& segmentToRemove);
00079 
00080    // collect all segments that are validated by the metric
00081    virtual void collectAllSegments(const DtNetworkSegmentMetric& metric, 
00082                                    DtPtrConstSegmentContainer& segments) const;
00083    virtual void collectAllSegments(const DtNetworkSegmentMetric& metric, 
00084                                    DtPtrSegmentContainer& segments);
00085 
00086    // find the best valid segment in the tree as measured by the metric
00087    virtual const DtNetworkSegment* findBestSegment(const DtNetworkSegmentMetric& metric) const;
00088 
00089    // expand the extent.  Only changes the pivot if there are no children.
00090    virtual void expandXY(double lowX, double highX, double lowY, double highY);
00091 
00092    // Clears the instance, returning it to the same state as the *default constructor*.
00093    virtual void clear();
00094 
00095    // \return A boolean indicating whether or not any elements are currently sorted
00096    // in the structure or not.
00097    virtual bool empty() const;
00098 
00099    virtual int size() const;
00100 
00101    virtual int sizeInBytes() const;
00102 
00103 protected:
00104    
00105    // Add the element to the specified destination.  If the destination doesn't
00106    // exist, create it using the specified boundaries.
00107    void addElement(DtSegmentMxCifTree*& destination, double lowX, double highX, 
00108       double lowY, double highY, DtNetworkSegment& elementToAdd);
00109 
00110    // Remove the element from the specified destination, if it exists.
00111    // \return True if the element was found and removed, and false otherwise.
00112    bool removeElement(DtSegmentMxCifTree*& destination, const DtNetworkSegment& elementToRemove);
00113 
00114    // find the best valid segment in a subtree. pointer best must be valid.  
00115    virtual const DtNetworkSegment* findBestInSubtree(const DtNetworkSegmentMetric& metric,
00116       double& bestCost) const;
00117 
00118    // calculate a segment's locale
00119    DtLocale findLocale(const DtNetworkSegment& newNetworkSegment) const;
00120 
00121 
00122 protected:
00123 
00124    DtPtrSegmentContainer myElements;
00125    DtSegmentMxCifTree*   mySW;
00126    DtSegmentMxCifTree*   mySE;
00127    DtSegmentMxCifTree*   myNE;
00128    DtSegmentMxCifTree*   myNW;
00129    double                myPivotX;
00130    double                myPivotY;
00131    double                myLowY;
00132    double                myHighY;
00133    double                myLowX;
00134    double                myHighX;
00135 
00136    // If this is non-zero, then child segment trees will be created as appropriate 
00137    // for all locales, each one with a depth of one less.
00138    // If it is zero, no child segment trees will be created.
00139    unsigned int          myDepth;
00140 };
00141 
00142 #endif

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)