VR-Forces 4.0.4 Class Documentation
include/gdb/vecNetwrk.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1999 MaK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: vecNetwrk.h,v $ $Revision: 1.35 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef vecNetwrk_H_
00009 #define vecNetwrk_H_
00010 
00011 #include "gdb/gdbDefines.h"
00012 #include "gdb/terFeat.h"
00013 #include "gdb/pointQTree.h"
00014 #include "gdb/segMxCifTree.h"
00015 #include "gdb/netwrkSpecEl.h"
00016 #include "geometry/surface.h"
00017 #include "gdb/specAttrib.h"
00018 #include "gdb/vecNwrkIntRec.h"
00019 #include <vlutil/vlConfig.h>
00020 #include <list>
00021 #include <vector>
00022 
00023 
00024 //forward declarations
00025 class DtNetworkSegment;
00026 class DtNetworkEdge;
00027 class DtNetworkNode;
00028 class DtNetworkNodeMetric;
00029 class DtNetworkAreaMetric;
00030 class DtSpecificationManager;
00031 class DtVectorNetworkRecord;
00032 class DtVectorNetworkIntersectionRecordList;
00033 
00034 
00035 //
00036 // DtVectorNetwork is used to represent networks of vector data. 
00037 class DT_DLL_gdb DtVectorNetwork
00038 {
00039 public:
00040 
00041    typedef std::vector<DtNetworkNode*> DtNodeContainer;
00042    typedef DtNodeContainer::iterator DtNodeIter;
00043    typedef DtNodeContainer::const_iterator DtNodeConstIter;
00044 
00045    typedef std::vector<DtNetworkEdge*> DtEdgeContainer;
00046    typedef DtEdgeContainer::iterator DtEdgeIter;
00047    typedef DtEdgeContainer::const_iterator DtEdgeConstIter;
00048 
00049 
00050    // constructor
00051    DtVectorNetwork();
00052 
00053    // destructor
00054    virtual ~DtVectorNetwork();
00055 
00056 private:
00057    // copy constructor - not implemented
00058    DtVectorNetwork(const DtVectorNetwork& orig);
00059 
00060    // assignment operator - not implemented
00061    DtVectorNetwork& operator=(const DtVectorNetwork& orig);
00062 
00063 public:
00064    
00065    virtual DtSpecificationManager& specificationManager();
00066    virtual const DtSpecificationManager& specificationManager() const;
00067    virtual void setSpecificationManager(const DtSpecificationManager& specManager);
00068 
00069    // \return The number of nodes
00070    // \note This \b includes nodes set as removed!
00071    virtual unsigned int numNodes() const;
00072 
00073    // \return The number of nodes not set as removed.
00074    virtual unsigned int numUnremovedNodes() const;
00075 
00076    // \return The maximum number of nodes
00077    virtual unsigned int maxNumNodes() const;
00078 
00079    // Expands the vector network to contain at least the specified number of 
00080    // network nodes.
00081    virtual bool extendMaxNumNodesTo(unsigned int val);
00082 
00083    // add/remove a new node
00084    typedef std::vector<DtNetworkElement*> DtElementContainer;
00085    typedef DtElementContainer::iterator DtElementIter;
00086    typedef DtElementContainer::const_iterator DtElementConstIter;
00087 
00088    // Removes all the elements in the specified container.  
00089    // \return A boolean indicating whether or not all of the specified elements
00090    // could be removed or not.
00091    // \note The elements \b must be owned by this vector network.
00092    //
00093    // \implementation Currently, the elements are not removed, but are actually
00094    // set to be removed, and thus ignored by vector network queries and the
00095    // terrain writer.  
00096    virtual bool removeElements(DtElementContainer& elementsToRemove);
00097    
00098    // Removes the specified network elements from the vector network.  See the
00099    // removeElements function for more information about the behavior when
00100    // removing different types of elements.
00101    //
00102    // \return A boolean indicating whether or the specified element could be 
00103    // removed or not.
00104    //
00105    // \note The element \b must be owned by this vector network.
00106    // 
00107    // \see removeElements
00108    virtual bool removeElement(DtNetworkElement* elementToRemove);
00109 
00110    virtual DtNetworkNode* newNode();
00111 
00112    // expands the vector network's extent to include the specified
00113    // node and adds the node to the vector network's quadtree.
00114    // Only necessary to call this when adding a new node to an existing
00115    // vector network, as calculate extent will also accomplish the same
00116    // goals.
00117    virtual void addOn(DtNetworkNode& node);
00118 
00119    // Sets the removed flag of the node so that it will not affect calculations.
00120    virtual void setAsRemoved(DtNetworkElement& elementToSet, bool onOff = true) const;
00121 
00122    // get a pointer to an existing node
00123    virtual const DtNetworkNode* node(unsigned int val) const;
00124    virtual DtNetworkNode* node(unsigned int val);
00125 
00126    // get/add/remove a new segment
00127    virtual void addOn(DtNetworkSegment& segment);
00128 
00129    // \return The number of edges
00130    // \note This \b includes edges marked as removed!
00131    virtual unsigned int numEdges() const;
00132 
00133    // \return The number of edges, excluding edges set as removed.
00134    virtual unsigned int numUnremovedEdges() const;
00135 
00136    // get the maximum number of edges
00137    virtual unsigned int maxNumEdges() const;
00138 
00139    // extend the maximum number of edges
00140    virtual bool extendMaxNumEdgesTo(unsigned int val);
00141 
00142    // get a new edge
00143    virtual DtNetworkEdge* newEdge();
00144 
00145    // get a pointer to an edge
00146    virtual const DtNetworkEdge* edge(unsigned int val) const;
00147    virtual DtNetworkEdge* edge(unsigned int val);
00148 
00149    // determine the extent of the network
00150    virtual DtExtent extent() const;
00151 
00152    // modify extent to include all points in the vector network
00153    virtual void expandExtent(DtExtent& otherExt) const;
00154 
00155    // In order to hide the implementation details, wrap the underlying structures'
00156    // containers in new typedefs.
00157    typedef DtPointQuadtreeNode::DtPtrConstNodeContainer DtPtrConstNodeContainer;
00158    typedef DtPointQuadtreeNode::DtPtrConstNodeConstIter DtPtrConstNodeConstIter;
00159    typedef DtPointQuadtreeNode::DtPtrConstNodeIter DtPtrConstNodeIter;
00160 
00161    typedef DtPointQuadtreeNode::DtPtrNodeContainer DtPtrNodeContainer;
00162    typedef DtPointQuadtreeNode::DtPtrNodeConstIter DtPtrNodeConstIter;
00163    typedef DtPointQuadtreeNode::DtPtrNodeIter DtPtrNodeIter;
00164 
00165    // collect all nodes that are validated by the metric
00166    virtual void collectAllNodes(DtNetworkNodeMetric& metric, 
00167       DtPtrConstNodeContainer& nodeContainer) const;
00168    virtual void collectAllNodes(DtNetworkNodeMetric& metric, 
00169       DtPtrNodeContainer& nodeContainer);
00170 
00171    // find the best valid node in the tree as measured by the metric
00172    virtual const DtNetworkNode* findBestNode(DtNetworkNodeMetric& metric) const;
00173 
00174    // In order to hide the implementation details, wrap the underlying structures'
00175    // containers in new typedefs.
00176    typedef DtSegmentMxCifTree::DtPtrConstSegmentContainer DtPtrConstSegmentContainer;
00177    typedef DtSegmentMxCifTree::DtPtrConstSegmentConstIter DtPtrConstSegmentConstIter;
00178    typedef DtSegmentMxCifTree::DtPtrConstSegmentIter DtPtrConstSegmentIter;
00179 
00180    typedef DtSegmentMxCifTree::DtPtrSegmentContainer DtPtrSegmentContainer;
00181    typedef DtSegmentMxCifTree::DtPtrSegmentConstIter DtPtrSegmentConstIter;
00182    typedef DtSegmentMxCifTree::DtPtrSegmentIter DtPtrSegmentIter;
00183 
00184    // collect all segments that are validated by the metric
00185    virtual void collectAllSegments(DtNetworkSegmentMetric& metric, 
00186       DtPtrConstSegmentContainer& segmentContainer) const;
00187    virtual void collectAllSegments(DtNetworkSegmentMetric& metric, 
00188       DtPtrSegmentContainer& segmentContainer);
00189 
00190    // find the best valid segment in the tree as measured by the metric
00191    virtual const DtNetworkSegment* findBestSegment(DtNetworkSegmentMetric& metric) const;
00192    
00193    // collect all areas in the network as measured by the metrics
00194    typedef std::list<const DtNetworkElement*> DtPtrConstAreaContainer;
00195    typedef std::list<DtNetworkElement*> DtPtrAreaContainer;
00196 
00197    virtual void collectAllAreas(DtNetworkAreaMetric& areaMetric, 
00198       DtPtrConstAreaContainer& networkElementList) const;
00199    virtual void collectAllAreas(DtNetworkAreaMetric& areaMetric, 
00200       DtPtrAreaContainer& networkElementList);
00201 
00202    // find the best area in the network as measured by the metrics
00203    virtual const DtNetworkNode* findBestArea(DtNetworkAreaMetric& areaMetric) const;
00204    
00205    // collect all features in the range and returns a list ordered by relevance / distance,
00206    // where relevance is defined by its location against other features in the same location 
00207    // and return true if it found something.
00208    // example: a bridge is more relevant than a river under it.
00209    // User is responsible for deleting each entry in the list
00210    virtual bool intersectVectors(const DtPoint& p, 
00211                                  DtList& list, 
00212                                  const DtVectorNetworkRecord& record);
00213    
00214    // find the best feature in the range and return true if it found something.
00215    // example: a bridge is more relevant than a river under it.
00216    virtual bool intersectVectors(const DtPoint& p, 
00217                                  DtVectorNetworkIntersectionRecord& intersectionRecord, 
00218                                  const DtVectorNetworkRecord& record);
00219 
00220    // collect all features in the range of the segment defined by p1 and p2
00221    // and returns a list ordered by distance,
00222    // and return true if it found something.
00223    // User is responsible for deleting each entry in the list
00224    virtual bool intersectVectors(const DtPoint& p1, 
00225                                  const DtPoint& p2, 
00226                                  DtList& list, 
00227                                  const DtVectorNetworkRecord& record,
00228                                  const DtTerrainDatabase& terrainDatabase);
00229 
00230    // collect all features in the range of the segment defined by p1 and p2
00231    // and returns a vectorNetworkIntersectionRecordList ordered by distance,
00232    // and return true if it found something.
00233    // User is responsible for allocating and deallocating the 
00234    // vectorNetworkIntersectionRecordList
00235    virtual bool intersectVectors(const DtPoint& p1, 
00236                                  const DtPoint& p2, 
00237                                  DtVectorNetworkIntersectionRecordList& vectorNetworkIntersectionRecordList, 
00238                                  const DtVectorNetworkRecord& record,
00239                                  const DtTerrainDatabase& terrainDatabase);
00240 
00241    // find if there is any feature in the range and return true if it found something.
00242    virtual bool intersectVectors(const DtPoint& p1, 
00243                                  const DtPoint& p2,
00244                                  DtVectorNetworkIntersectionRecord& intersectionRecord,
00245                                  const DtVectorNetworkRecord& record,
00246                                  const DtTerrainDatabase& terrainDatabase);
00247 
00248    // debugging aid
00249    virtual void dump(int indent_level) const;
00250 
00251    // debugging aid... dumps the vector network structure into a GraphViz
00252    // format file
00253    virtual void dump(const char* filename, DtString indent="") const;
00254 
00255    // Return the minimum terrain file version number that this Node can be
00256    // saved in.
00257    virtual DtTerrainFileVersionNumber minSaveVersion() const;
00258 
00259    // calculate and set the extent of the network
00260    virtual void calcExtent(); 
00261 
00262    // Merges this vector network with the specified vector network.
00263    // Adjusts such things as specification IDs as appropriate.
00264    // Returns true if the merge was successful.
00265    virtual bool merge(const DtVectorNetwork& networkToMerge);
00266 
00267 
00268    virtual void connectEdges(unsigned int startingNodeIndex,
00269                              unsigned int startingEdgeIndex);
00270 
00271    // Calls above connectEdges function with 0 for starting indices in order 
00272    // to process all nodes and edges
00273    virtual void connectEdges();
00274 
00275    // Copies the nodes in the input network into the network.
00276    // The specification ID Map specifies the offsets for each 
00277    // original specification ID to its copy in this network's
00278    // specification manager.  
00279    // 
00280    // Returns true if the copying was successful.
00281    // Returns false otherwise.
00282    virtual bool copyNodes(const DtVectorNetwork& inputNetwork, 
00283                           DtSpecificationID* specificationIDMap);
00284    
00285    // Same as the above function ,but assumes that the specification 
00286    // IDs of the copied nodes are the same as the input nodes.
00287    // NOTE:  only useful for copying nodes into an empty network
00288    virtual bool copyNodes(const DtVectorNetwork& inputNetwork);
00289 
00290    virtual bool copyEdges(const DtVectorNetwork& inputNetwork, 
00291                           DtSpecificationID* specificationIDMap);
00292 
00293    // this method joints all edges beyond iiStart to the node if 
00294    // appropriate (called from connectWithNodes).  Looks for edges that could
00295    // be connected and connects them.  Very expensive (n-cubed for number
00296    // of edges in db).
00297    virtual void joinEdges(unsigned int nodeIndex,
00298                           unsigned int startingEdgeIndex);
00299    virtual void joinEdges(DtNetworkNode& node,
00300                           unsigned int startingEdgeIndex);
00301 
00302    // Returns true if the network contains no data
00303    // (i.e. no nodes or edges, the specification manager is empty
00304    // etc. )
00305    virtual bool isEmpty() const;
00306 
00307    // check validity of the network
00308    virtual bool validity(bool removeInvalidSegments = false, bool* segmentsRemoved = 0);
00309 
00310    virtual int sizeInBytes() const;
00311 
00312    // These check if the specification id exists, if not add to specMgr
00313    virtual DtSpecificationID riverSpecificationId();
00314    virtual DtSpecificationID interchangeSpecificationId();
00315    virtual DtSpecificationID bridgeSpecificationId();
00316 
00317    virtual Coordinate_System* coordinateSystem();
00318    virtual Coordinate_System* coordinateSystem() const;
00319    virtual void setCoordinateSystem(Coordinate_System* cs);
00320 
00324    virtual void transformTo(Coordinate_System* newCoordSys, const DtVector* offset=0);
00325 
00326 protected:
00327 
00328    // Removes the specified point feature from the vector network.
00329    // \return A boolean indicating success or failure 
00330    virtual bool removePointFeature(DtNetworkElement* pointFeatureToRemove);
00331    virtual bool removeLinearFeature(DtNetworkElement* linearFeatureToRemove);
00332    virtual bool removeArealFeature(DtNetworkElement* arealFeatureToRemove);
00333 
00334    virtual bool removeNode(DtNetworkNode* nodeToRemove);
00335    virtual bool removeEdge(DtNetworkEdge* edgeToRemove);
00336 
00337    virtual bool testInvariant() const;
00338 
00339 
00340    virtual bool intersectInfoList(const DtPoint& p, 
00341                                   std::list<DtNetworkElement*>& list, 
00342                                   const DtVectorNetworkRecord& record);
00343 
00344    virtual bool intersectInfo(const DtPoint& p, 
00345                               const DtNetworkSpecElement*& element, 
00346                               const DtVectorNetworkRecord& record);
00347 
00348    virtual const DtNetworkNode* betterFeature(const DtNetworkNode* node1, 
00349                                               const DtNetworkNode* node2) const;
00350 
00351    // Dumps the specification manager's structure into a GraphViz format file
00352    virtual void dumpSpecs(FILE* fp, DtString indent="") const;
00353 
00354    // Dumps the node structure into a GraphViz format file
00355    virtual void dumpNodes(FILE* fp, DtString indent="") const;
00356 
00357    // Dumps the edge structure into a GraphViz format file
00358    virtual void dumpEdges(FILE* fp, DtString indent="") const;
00359 
00360 protected:
00361 
00362    // These specifications are used in planarization. 
00363    DtSpecificationID myRiverIntersectionSpecId;
00364    DtSpecificationID myInterchangeSpecId;
00365    DtSpecificationID myBridgeSpecId;
00366 
00367    bool myHaveRiverSpecId;
00368    bool myHaveInterchangeSpecId;
00369    bool myHaveBridgeSpecId;
00370 
00371    unsigned int            myMaxNumNodes;
00372    unsigned int            myMaxNumEdges;
00373 
00374    DtNodeContainer         myNodes;
00375    DtEdgeContainer         myEdges;
00376 
00377    DtPointQuadtreeNode     myPointQuadtree;
00378    DtSegmentMxCifTree      mySegmentMxCifTree;
00379    
00380    DtExtent                myExtent;
00381    
00382    DtSpecificationManager  mySpecificationManager;
00383    Coordinate_System*      myCoordinateSystem;
00384 };
00385 
00386 #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)