00001 /****************************************************************************/ 00007 // Additional structures for building random nets 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef NGRandomNetBuilder_h 00020 #define NGRandomNetBuilder_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include "NGNet.h" 00033 #include <map> 00034 00035 00036 // =========================================================================== 00037 // class definitions 00038 // =========================================================================== 00043 class TNeighbourDistribution { 00044 public: 00053 void add(int numNeighbours, SUMOReal ratio) throw(); 00054 00055 00061 int num() throw(); 00062 00063 00064 private: 00066 std::map<int, SUMOReal> myNeighbours; 00067 00068 }; 00069 00070 00077 class NGRandomNetBuilder { 00078 public: 00089 NGRandomNetBuilder(NGNet &net, SUMOReal minAngle, SUMOReal minDistance, SUMOReal maxDistance, SUMOReal connectivity, 00090 int numTries, const TNeighbourDistribution &neighborDist) throw(); 00091 00092 00093 00099 void createNet(int numNodes) throw(); 00100 00101 00102 private: 00107 void removeOuterNode(NGNode *node) throw(); 00108 00109 00117 bool checkAngles(NGNode* node) throw(); 00118 00119 00129 bool canConnect(NGNode* baseNode, NGNode* newNode) throw(); 00130 00131 00139 bool createNewNode(NGNode *baseNode) throw(); 00140 00141 00147 void findPossibleOuterNodes(NGNode *node) throw(); 00148 00149 00150 private: 00152 NGNet &myNet; 00153 00155 NGNodeList myOuterNodes; 00156 00158 NGEdgeList myOuterLinks; 00159 00160 // list of possible new connections 00161 NGNodeList myConNodes; 00162 00163 00165 00166 00168 SUMOReal myMinLinkAngle; 00169 00171 SUMOReal myMinDistance; 00172 00174 SUMOReal myMaxDistance; 00175 00177 SUMOReal myConnectivity; 00179 00180 00182 int myNumTries; 00183 00185 int myNumNodes; 00186 00188 TNeighbourDistribution myNeighbourDistribution; 00189 00190 private: 00192 NGRandomNetBuilder(const NGRandomNetBuilder&); 00193 00195 NGRandomNetBuilder& operator=(const NGRandomNetBuilder&); 00196 00197 }; 00198 00199 00200 #endif 00201 00202 /****************************************************************************/ 00203
1.5.6