SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Additional structures for building random nets 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef NGRandomNetBuilder_h 00023 #define NGRandomNetBuilder_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include "NGNet.h" 00036 #include <map> 00037 00038 00039 // =========================================================================== 00040 // class definitions 00041 // =========================================================================== 00046 class TNeighbourDistribution { 00047 public: 00056 void add(int numNeighbours, SUMOReal ratio) ; 00057 00058 00064 int num() ; 00065 00066 00067 private: 00069 std::map<int, SUMOReal> myNeighbours; 00070 00071 }; 00072 00073 00080 class NGRandomNetBuilder { 00081 public: 00092 NGRandomNetBuilder(NGNet& net, SUMOReal minAngle, SUMOReal minDistance, SUMOReal maxDistance, SUMOReal connectivity, 00093 int numTries, const TNeighbourDistribution& neighborDist) ; 00094 00095 00096 00102 void createNet(int numNodes) ; 00103 00104 00105 private: 00110 void removeOuterNode(NGNode* node) ; 00111 00112 00120 bool checkAngles(NGNode* node) ; 00121 00122 00132 bool canConnect(NGNode* baseNode, NGNode* newNode) ; 00133 00134 00142 bool createNewNode(NGNode* baseNode) ; 00143 00144 00150 void findPossibleOuterNodes(NGNode* node) ; 00151 00152 00153 private: 00155 NGNet& myNet; 00156 00158 NGNodeList myOuterNodes; 00159 00161 NGEdgeList myOuterLinks; 00162 00163 // list of possible new connections 00164 NGNodeList myConNodes; 00165 00166 00168 00169 00171 SUMOReal myMinLinkAngle; 00172 00174 SUMOReal myMinDistance; 00175 00177 SUMOReal myMaxDistance; 00178 00180 SUMOReal myConnectivity; 00182 00183 00185 int myNumTries; 00186 00188 int myNumNodes; 00189 00191 TNeighbourDistribution myNeighbourDistribution; 00192 00193 private: 00195 NGRandomNetBuilder(const NGRandomNetBuilder&); 00196 00198 NGRandomNetBuilder& operator=(const NGRandomNetBuilder&); 00199 00200 }; 00201 00202 00203 #endif 00204 00205 /****************************************************************************/ 00206