static void Get(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("GET", url, handler, name); }; //<! Helper for mapping GET
int main(void) { Router *router = new Router(OrthogonalRouting); router->setRoutingParameter((RoutingParameter)0, 2); router->setRoutingParameter((RoutingParameter)1, 0); router->setRoutingParameter((RoutingParameter)2, 0); router->setRoutingParameter((RoutingParameter)3, 4000); router->setRoutingParameter((RoutingParameter)4, 9000); router->setRoutingParameter((RoutingParameter)5, 0); router->setRoutingParameter((RoutingParameter)6, 0); router->setRoutingParameter((RoutingParameter)7, 16); router->setRoutingParameter((RoutingParameter)8, 0); router->setRoutingOption((RoutingOption)0, false); router->setRoutingOption((RoutingOption)1, true); router->setRoutingOption((RoutingOption)2, false); router->setRoutingOption((RoutingOption)3, false); router->setRoutingOption((RoutingOption)4, true); router->setRoutingOption((RoutingOption)5, false); router->setRoutingOption((RoutingOption)6, true); Polygon polygon; ConnEnd srcPt; ConnEnd dstPt; ConnEnd heConnPt; PolyLine newRoute; ShapeConnectionPin *connPin = NULL; // shapeRef1 polygon = Polygon(4); polygon.ps[0] = Point(450, 330); polygon.ps[1] = Point(490, 330); polygon.ps[2] = Point(490, 450); polygon.ps[3] = Point(450, 450); ShapeRef *shapeRef1 = new ShapeRef(router, polygon, 1); connPin = new ShapeConnectionPin(shapeRef1, 1, 0, 0.333333, true, 10, (ConnDirFlags) 0); connPin->setExclusive(false); connPin = new ShapeConnectionPin(shapeRef1, 2, 0, 0.666667, true, 10, (ConnDirFlags) 0); connPin->setExclusive(false); connPin = new ShapeConnectionPin(shapeRef1, 3, 1, 0.5, true, 10, (ConnDirFlags) 0); connPin->setExclusive(false); connPin = new ShapeConnectionPin(shapeRef1, 4, 0.5, 0, true, 10, (ConnDirFlags) 0); connPin->setExclusive(false); // shapeRef8 polygon = Polygon(4); polygon.ps[0] = Point(502, 237.5); polygon.ps[1] = Point(502, 262.5); polygon.ps[2] = Point(438, 262.5); polygon.ps[3] = Point(438, 237.5); ShapeRef *shapeRef8 = new ShapeRef(router, polygon, 8); connPin = new ShapeConnectionPin(shapeRef8, 1, 0, 0.5, true, 1, (ConnDirFlags) 0); connPin = new ShapeConnectionPin(shapeRef8, 2, 1, 0.5, true, 1, (ConnDirFlags) 0); connPin = new ShapeConnectionPin(shapeRef8, 3, 0.5, 1, true, 1, (ConnDirFlags) 0); connPin = new ShapeConnectionPin(shapeRef8, 4, 0.5, 0, true, 1, (ConnDirFlags) 0); JunctionRef *junctionRef6 = new JunctionRef(router, Point(470, 300), 6); /* // This may be useful if junction pins are modified. connPin = new ShapeConnectionPin(junctionRef6, 2147483646, (ConnDirFlags) 15); */ // connRef9 ConnRef *connRef9 = new ConnRef(router, 9); srcPt = ConnEnd(junctionRef6); connRef9->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef8, 3); connRef9->setDestEndpoint(dstPt); connRef9->setRoutingType((ConnType)2); #if 1 // connRef10 - WITH BUG ConnRef *connRef10 = new ConnRef(router, 10); srcPt = ConnEnd(junctionRef6); connRef10->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef1, 4); connRef10->setDestEndpoint(dstPt); connRef10->setRoutingType((ConnType)2); #else // connRef10 - WITHOUT BUG ConnRef *connRef10 = new ConnRef(router, 10); srcPt = ConnEnd(shapeRef1, 4); connRef10->setSourceEndpoint(srcPt); dstPt = ConnEnd(junctionRef6); connRef10->setDestEndpoint(dstPt); connRef10->setRoutingType((ConnType)2); #endif // router->deleteConnector(connRef5); router->processTransaction(); ConnRef *mergedConn = junctionRef6->removeJunctionAndMergeConnectors(); router->processTransaction(); router->outputDiagram("output/removeJunctions01"); std::pair<ConnEnd, ConnEnd> ends = mergedConn->endpointConnEnds(); // Expected result: output images should be virtually identical. // Result: An endpoint seems to be disconnected from shapeRef8. bool isConnected = (ends.first.shape() == shapeRef8) || (ends.second.shape() == shapeRef8); delete router; return isConnected ? 0 : 1; };
/*! Map an URL. If method is left empty, it will match any method. Name is also optional, but needed if you want to find it for making URLs */ static void Map(const std::string& method, const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map(method, url, handler, name); };
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 200); router->setRoutingPenalty((PenaltyType)3, 4000); //router->setRoutingPenalty((PenaltyType)4, 110); router->setOrthogonalNudgeDistance(25); double buffer = 4; Polygon poly342721632(4); poly342721632.ps[0] = Point(51910, 50946); poly342721632.ps[1] = Point(51910, 51004); poly342721632.ps[2] = Point(51825, 51004); poly342721632.ps[3] = Point(51825, 50946); ShapeRef *shapeRef342721632 = new ShapeRef(router, poly342721632, 342721632); new ShapeConnectionPin(shapeRef342721632, 1, ATTACH_POS_LEFT, ATTACH_POS_CENTRE, buffer, ConnDirLeft); Polygon poly807558175(4); poly807558175.ps[0] = Point(51604, 51000); poly807558175.ps[1] = Point(51604, 51085); poly807558175.ps[2] = Point(51546, 51085); poly807558175.ps[3] = Point(51546, 51000); ShapeRef *shapeRef807558175 = new ShapeRef(router, poly807558175, 807558175); new ShapeConnectionPin(shapeRef807558175, 1, ATTACH_POS_CENTRE, ATTACH_POS_TOP, buffer, ConnDirNone); Polygon poly404900496(4); poly404900496.ps[0] = Point(51525, 50946); poly404900496.ps[1] = Point(51525, 51004); poly404900496.ps[2] = Point(51440, 51004); poly404900496.ps[3] = Point(51440, 50946); ShapeRef *shapeRef404900496 = new ShapeRef(router, poly404900496, 404900496); new ShapeConnectionPin(shapeRef404900496, 1, ATTACH_POS_RIGHT, ATTACH_POS_CENTRE, buffer, (ConnDirFlags) 8); JunctionRef *junctionRef265539540 = new JunctionRef(router, Point(51625, 50950), 265539540); ConnRef *connRef985644192 = new ConnRef(router, 985644192); ConnEnd srcPt985644192(shapeRef404900496, 1); connRef985644192->setSourceEndpoint(srcPt985644192); ConnEnd dstPt985644192(junctionRef265539540); connRef985644192->setDestEndpoint(dstPt985644192); connRef985644192->setRoutingType((ConnType)2); ConnRef *connRef467016913 = new ConnRef(router, 467016913); ConnEnd srcPt467016913(junctionRef265539540); connRef467016913->setSourceEndpoint(srcPt467016913); ConnEnd dstPt467016913(shapeRef807558175, 1); connRef467016913->setDestEndpoint(dstPt467016913); connRef467016913->setRoutingType((ConnType)2); ConnRef *connRef45740440 = new ConnRef(router, 45740440); ConnEnd srcPt45740440(shapeRef342721632, 1); connRef45740440->setSourceEndpoint(srcPt45740440); ConnEnd dstPt45740440(junctionRef265539540); connRef45740440->setDestEndpoint(dstPt45740440); connRef45740440->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("test-node1"); delete router; return 0; };
/** * Entry point into kwbrouter application. */ int main (int argc, char* argv[]) { int rc = eERR_NONE; bool end_application = false; options_t options; ioloop_t mainloop; do { // all logs on log_set_mask(0xFFFFFFFF); log_msg(KWB_LOG_INFO, "kwbrouter..."); // set default options for kwbrouter set_options(&options, "", // no serial device 57600, // baudrate, if not given "/tmp/kwbr.usk", // default address of kwbrouter socket 0); // port 0: use unix sockets // parse and validate commandline options if (parse_commandline_options(argc, argv, &options) == false || validate_options(&options) == false) { print_usage(); rc = eERR_BAD_PARAMETER; break; } ioloop_init(&mainloop); Router* router = new Router(); RConnSerial* serconn = new RConnSerial(&mainloop); serconn->Open(options.serial_device, options.serial_baudrate); router->AddConnection(serconn); // open new server and let-every connection auto-connect to router create_unix_socket_file(&options); SocketServer* server = new SocketServer(&mainloop, router); server->Open(options.router_address, options.router_port); // RConnSocketServer server = new /* route_init(&router); // initialize network routing msg_s_init(&msg_socket); if ((rc = msg_s_open_server(&msg_socket, &mainloop, "/tmp/kwb.usk", 0)) != eERR_NONE) { break; } msg_s_set_incomming_handler(&msg_socket, handle_incomming_msg, &router); msg_s_set_newconnection_handler(&msg_socket, handle_new_connection, &router); // add route for every client of unix socket ep = msg_s_get_endpoint(&msg_socket, 0, eMSG_EP_COMM); // initialize bus routing msg_b_init(&msg_bus, 0); if (options.serial_device_set) { address = options.serial_device; port = options.serial_baudrate; serial = true; } else { address = options.vbusd_address; port = options.vbusd_port; serial = false; } rc = msg_b_open(&msg_bus, &mainloop, options.own_node_address, serial, address, port); if (rc != eERR_NONE) break; msg_b_set_incomming_handler(&msg_bus, handle_incomming_msg, &router); route_add(&router, 1, 65535, address, port, eROUTE_TYPE_SERIAL, &msg_bus); */ log_msg(KWB_LOG_STATUS, "entering mainloop...\n"); while (!end_application) { ioloop_run_once(&mainloop); } server->Close(); delete server; router->RemoveConnection(serconn); serconn->Close(); delete serconn; delete router; } while (0); return rc; }
static void Any(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("", url, handler, name); }; //<! Helper for mapping any method
static void PrintRoutes(std::ostream &os) { router.printRoutes(os); }; //<! Prints all known routes to given output stream
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 200); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 9000); router->setRoutingPenalty((PenaltyType)5, 100); router->setRoutingOption((RoutingOption)0, false); router->setRoutingOption((RoutingOption)1, true); router->setRoutingOption((RoutingOption)2, true); router->setRoutingOption(improveHyperedgeRoutesMovingAddingAndDeletingJunctions, true); router->setRoutingParameter(idealNudgingDistance, 25); Polygon poly39761567(4); poly39761567.ps[0] = Point(50754, 50975); poly39761567.ps[1] = Point(50754, 51060); poly39761567.ps[2] = Point(50696, 51060); poly39761567.ps[3] = Point(50696, 50975); ShapeRef *shapeRef39761567 = new ShapeRef(router, poly39761567, 39761567); new ShapeConnectionPin(shapeRef39761567, 1, 0.5, 0, true, 10, (ConnDirFlags) 1); Polygon poly115776716(4); poly115776716.ps[0] = Point(51504, 50975); poly115776716.ps[1] = Point(51504, 51060); poly115776716.ps[2] = Point(51446, 51060); poly115776716.ps[3] = Point(51446, 50975); ShapeRef *shapeRef115776716 = new ShapeRef(router, poly115776716, 115776716); new ShapeConnectionPin(shapeRef115776716, 1, 0.5, 0, true, 10, (ConnDirFlags) 1); Polygon poly238475293(4); poly238475293.ps[0] = Point(50554, 50975); poly238475293.ps[1] = Point(50554, 51060); poly238475293.ps[2] = Point(50496, 51060); poly238475293.ps[3] = Point(50496, 50975); ShapeRef *shapeRef238475293 = new ShapeRef(router, poly238475293, 238475293); new ShapeConnectionPin(shapeRef238475293, 1, 0.5, 0, true, 10, (ConnDirFlags) 1); Polygon poly430971008(4); poly430971008.ps[0] = Point(51004, 50975); poly430971008.ps[1] = Point(51004, 51060); poly430971008.ps[2] = Point(50946, 51060); poly430971008.ps[3] = Point(50946, 50975); ShapeRef *shapeRef430971008 = new ShapeRef(router, poly430971008, 430971008); new ShapeConnectionPin(shapeRef430971008, 1, 0.5, 0, true, 10, (ConnDirFlags) 1); JunctionRef *junctionRef513246008 = new JunctionRef(router, Point(50925, 50725), 513246008); /* // This may be useful if junction pins are modified. new ShapeConnectionPin(junctionRef513246008, 2147483646, (ConnDirFlags) 15); */ ConnRef *connRef513246009 = new ConnRef(router, 513246009); ConnEnd srcPt513246009(shapeRef39761567, 1); connRef513246009->setSourceEndpoint(srcPt513246009); ConnEnd dstPt513246009(junctionRef513246008); connRef513246009->setDestEndpoint(dstPt513246009); connRef513246009->setRoutingType((ConnType)2); ConnRef *connRef513246010 = new ConnRef(router, 513246010); ConnEnd srcPt513246010(junctionRef513246008); connRef513246010->setSourceEndpoint(srcPt513246010); ConnEnd dstPt513246010(shapeRef430971008, 1); connRef513246010->setDestEndpoint(dstPt513246010); connRef513246010->setRoutingType((ConnType)2); ConnRef *connRef513246011 = new ConnRef(router, 513246011); ConnEnd srcPt513246011(junctionRef513246008); connRef513246011->setSourceEndpoint(srcPt513246011); ConnEnd dstPt513246011(shapeRef238475293, 1); connRef513246011->setDestEndpoint(dstPt513246011); connRef513246011->setRoutingType((ConnType)2); ConnRef *connRef513246012 = new ConnRef(router, 513246012); ConnEnd srcPt513246012(shapeRef115776716, 1); connRef513246012->setSourceEndpoint(srcPt513246012); ConnEnd dstPt513246012(junctionRef513246008); connRef513246012->setDestEndpoint(dstPt513246012); connRef513246012->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("output/improveHyperedge03"); bool overlaps = router->existsOrthogonalSegmentOverlap(true); delete router; return (overlaps) ? 1 : 0; };
void Admin::GetOperation(const Operation & op, OpVector & res) { const std::vector<Root> & args = op->getArgs(); if (args.empty()) { error(op, "Get has no args.", res, getId()); return; } const Root & arg = args.front(); if (!arg->hasAttrFlag(Atlas::Objects::OBJTYPE_FLAG)) { error(op, "Get arg has no objtype.", res, getId()); return; } const std::string & objtype = arg->getObjtype(); if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) { error(op, "Get arg has no id.", res, getId()); return; } const std::string & id = arg->getId(); if (id.empty()) { error(op, "Get arg id empty", res, getId()); return; } Info info; if (objtype == "object" || objtype == "obj") { if (m_connection == 0) { return; } long intId = integerId(id); const RouterMap & OOGDict = m_connection->m_server.getObjects(); RouterMap::const_iterator J = OOGDict.find(intId); const EntityDict & worldDict = m_connection->m_server.m_world.getEntities(); EntityDict::const_iterator K = worldDict.find(intId); if (J != OOGDict.end()) { Router * obj = J->second; Anonymous info_arg; obj->addToEntity(info_arg); info->setArgs1(info_arg); } else if (K != worldDict.end()) { Anonymous info_arg; K->second->addToEntity(info_arg); info->setArgs1(info_arg); } else { clientError(op, compose("Unknown object id \"%1\" requested", id), res, getId()); return; } } else if (objtype == "class" || objtype == "meta" || objtype == "op_definition") { const Root & o = Inheritance::instance().getClass(id); if (!o.isValid()) { clientError(op, compose("Unknown type definition for \"%1\" " "requested", id), res); return; } info->setArgs1(o); } else { error(op, compose("Unknown object type \"%1\" requested for \"%2\"", objtype, id), res, getId()); return; } res.push_back(info); }
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 0); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 110); router->setOrthogonalNudgeDistance(25); Polygon poly143407352(4); poly143407352.ps[0] = Point(6035, 4390); poly143407352.ps[1] = Point(6035, 5085); poly143407352.ps[2] = Point(5675, 5085); poly143407352.ps[3] = Point(5675, 4390); new ShapeRef(router, poly143407352, 143407352); Polygon poly124950386(4); poly124950386.ps[0] = Point(4900, 4090); poly124950386.ps[1] = Point(4900, 4785); poly124950386.ps[2] = Point(4540, 4785); poly124950386.ps[3] = Point(4540, 4090); new ShapeRef(router, poly124950386, 124950386); ConnRef *connRef373967044 = new ConnRef(router, 373967044); ConnEnd srcPt373967044(Point(4890, 4250), 8); connRef373967044->setSourceEndpoint(srcPt373967044); ConnEnd dstPt373967044(Point(5685, 4550), 4); connRef373967044->setDestEndpoint(dstPt373967044); connRef373967044->setRoutingType((ConnType)2); ConnRef *connRef681881486 = new ConnRef(router, 681881486); ConnEnd srcPt681881486(Point(4890, 4325), 8); connRef681881486->setSourceEndpoint(srcPt681881486); ConnEnd dstPt681881486(Point(5685, 4625), 4); connRef681881486->setDestEndpoint(dstPt681881486); connRef681881486->setRoutingType((ConnType)2); ConnRef *connRef829752 = new ConnRef(router, 829752); ConnEnd srcPt829752(Point(4890, 4400), 8); connRef829752->setSourceEndpoint(srcPt829752); ConnEnd dstPt829752(Point(5685, 4700), 4); connRef829752->setDestEndpoint(dstPt829752); connRef829752->setRoutingType((ConnType)2); ConnRef *connRef17625739 = new ConnRef(router, 17625739); ConnEnd srcPt17625739(Point(4890, 4475), 8); connRef17625739->setSourceEndpoint(srcPt17625739); ConnEnd dstPt17625739(Point(5685, 4775), 4); connRef17625739->setDestEndpoint(dstPt17625739); connRef17625739->setRoutingType((ConnType)2); ConnRef *connRef223864175 = new ConnRef(router, 223864175); ConnEnd srcPt223864175(Point(4890, 4550), 8); connRef223864175->setSourceEndpoint(srcPt223864175); ConnEnd dstPt223864175(Point(5685, 4850), 4); connRef223864175->setDestEndpoint(dstPt223864175); connRef223864175->setRoutingType((ConnType)2); ConnRef *connRef98144280 = new ConnRef(router, 98144280); ConnEnd srcPt98144280(Point(4890, 4625), 8); connRef98144280->setSourceEndpoint(srcPt98144280); ConnEnd dstPt98144280(Point(5685, 4925), 4); connRef98144280->setDestEndpoint(dstPt98144280); connRef98144280->setRoutingType((ConnType)2); ConnRef *connRef283100856 = new ConnRef(router, 283100856); ConnEnd srcPt283100856(Point(4890, 4700), 8); connRef283100856->setSourceEndpoint(srcPt283100856); ConnEnd dstPt283100856(Point(5685, 5000), 4); connRef283100856->setDestEndpoint(dstPt283100856); connRef283100856->setRoutingType((ConnType)2); ConnRef *connRef387080925 = new ConnRef(router, 387080925); ConnEnd srcPt387080925(Point(5685, 4475), 4); connRef387080925->setSourceEndpoint(srcPt387080925); ConnEnd dstPt387080925(Point(4890, 4175), 8); connRef387080925->setDestEndpoint(dstPt387080925); connRef387080925->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("test-orthordering-02"); int crossings = router->existsOrthogonalCrossings(); delete router; return (crossings > 0) ? 1 : 0; };
void NetworkTreeNode::inferRouters() { if(inferredRouters.size() > 0) { return; } list<InetAddress*> interfaces = this->listInterfaces(); // Remove duplicata (possible because ingress interface of neighborhood can be a contra-pivot) InetAddress previous(0); bool previousAssigned = false; for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { InetAddress *current = (*i); if(current == NULL) continue; if(previousAssigned && (*current) == previous) interfaces.erase(i--); previous = (*current); if(!previousAssigned) previousAssigned = true; } // First compute the smallest gap between IP IDs. unsigned short smallestGap = 65335; bool noHostNames = true; for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { for(list<InetAddress*>::iterator j = i; j != interfaces.end(); ++j) { if((*i) == (*j)) continue; if(!(*i)->getStoredHostName().empty() && !(*j)->getStoredHostName().empty()) noHostNames = false; if((*i)->hasIPIdentifier() && (*j)->hasIPIdentifier()) { unsigned short thisGap = 0; unsigned short IPId1 = (*i)->getIPIdentifier(); unsigned short IPId2 = (*j)->getIPIdentifier(); if(IPId1 > IPId2) thisGap = IPId1 - IPId2; else thisGap = IPId2 - IPId1; if(thisGap > (65535 - MAX_IP_ID_DIFFERENCE)) { if(IPId1 > 60000) thisGap = (65535 - IPId1) + IPId2; else thisGap = (65535 - IPId2) + IPId1; } if(thisGap < smallestGap) smallestGap = thisGap; } } } // If not enough host names, above a threshold (for the gap), infers a router per interface. if(noHostNames && smallestGap > NO_ASSOCIATION_THRESHOLD) { for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { Router *curRouter = new Router(); curRouter->addInterface(InetAddress(*(*i))); inferredRouters.push_back(curRouter); } /* * Some post-processing: removes the routers consisting of a single interface which happens * to be a candidate contra-pivot of an ODD subnet. * * N.B.: checking the interface appears in the subnet responsive IPs list is enough, as the * pivots were not listed at all in the potential interfaces. */ for(list<Router*>::iterator i = inferredRouters.begin(); i != inferredRouters.end(); ++i) { if((*i)->getNbInterfaces() == 1) { InetAddress singleInterface = (*i)->getInterfacesList()->front(); for(list<NetworkTreeNode*>::iterator j = children.begin(); j != children.end(); ++j) { if((*j)->getType() == NetworkTreeNode::T_SUBNET) { SubnetSite *ss = (*j)->getAssociatedSubnet(); if(ss->getStatus() == SubnetSite::ODD_SUBNET && ss->hasLiveInterface(singleInterface)) { bool isALabel = false; for(list<InetAddress>::iterator k = labels.begin(); k != labels.end(); ++k) { if((*k) == singleInterface) { isALabel = true; break; } } if(!isALabel) { delete (*i); inferredRouters.erase(i--); break; } } } } } } return; } // Computes the delta between two interfaces to associates them. unsigned short delta = MAX_IP_ID_DIFFERENCE; if(smallestGap > delta) { delta = smallestGap + 5 * (smallestGap / MAX_IP_ID_DIFFERENCE); } // The maximum difference between two probes token is the size of the set. unsigned int deltaTokens = (unsigned int) interfaces.size(); /* * Before association, we re-order the interfaces such that the interfaces with host names are * treated first. */ list<InetAddress*> reOrdered; for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { InetAddress *cur = (*i); if(!cur->getStoredHostName().empty()) { reOrdered.push_back(cur); interfaces.erase(i--); } } for(list<InetAddress*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { reOrdered.push_back((*i)); interfaces.erase(i--); } // Starts association... while(reOrdered.size() > 0) { InetAddress *cur = reOrdered.front(); string curHostName = cur->getStoredHostName(); bool testCur = cur->hasIPIdentifier(); reOrdered.pop_front(); if(!testCur && curHostName.empty()) { Router *curRouter = new Router(); curRouter->addInterface(InetAddress(*cur)); inferredRouters.push_back(curRouter); continue; } Router *curRouter = new Router(); curRouter->addInterface(InetAddress(*cur)); unsigned int curProbeToken = cur->getProbeToken(); unsigned short curIPId = cur->getIPIdentifier(); for(list<InetAddress*>::iterator i = reOrdered.begin(); i != reOrdered.end(); ++i) { string hostName = (*i)->getStoredHostName(); bool testI = (*i)->hasIPIdentifier(); // Association by host names if(!curHostName.empty() && !hostName.empty()) { list<string> chnChunks; list<string> hnChunks; string element; stringstream chn(curHostName); while (std::getline(chn, element, '.')) { chnChunks.push_front(element); } stringstream hn(hostName); while (std::getline(hn, element, '.')) { hnChunks.push_front(element); } if(chnChunks.size() == hnChunks.size()) { unsigned short size = (unsigned short) chnChunks.size(); unsigned short similarities = 0; list<string>::iterator itBis = hnChunks.begin(); for(list<string>::iterator it = chnChunks.begin(); it != chnChunks.end(); ++it) { if((*it).compare((*itBis)) == 0) { similarities++; itBis++; } else break; } if(similarities >= (size - 1)) { curRouter->addInterface(InetAddress(*(*i))); reOrdered.erase(i--); } } } // Association by IP IDs (when one of both IPs does not have a host name) else if((curHostName.empty() || hostName.empty()) && testI && testCur) { unsigned int probeToken = (*i)->getProbeToken(); unsigned short IPId = (*i)->getIPIdentifier(); unsigned int diffProbeToken = 0; unsigned short diffIPId = 0; if(curProbeToken > probeToken) diffProbeToken = curProbeToken - probeToken; else diffProbeToken = probeToken - curProbeToken; if(curIPId > IPId) diffIPId = curIPId - IPId; else diffIPId = IPId - curIPId; if(diffIPId > (65535 - MAX_IP_ID_DIFFERENCE)) { if(curIPId > 60000) diffIPId = (65535 - curIPId) + IPId; else diffIPId = (65535 - IPId) + curIPId; } if(diffProbeToken <= deltaTokens && diffIPId <= delta) { curRouter->addInterface(InetAddress(*(*i))); reOrdered.erase(i--); } } } inferredRouters.push_back(curRouter); } /* * Some post-processing: removes the routers consisting of a single interface which happens * to be a candidate contra-pivot of an ODD subnet, except if it is among the labels of this * node. * * N.B.: checking the interface appears in the subnet responsive IPs list is enough, as the * pivots were not listed at all in the potential interfaces. */ for(list<Router*>::iterator i = inferredRouters.begin(); i != inferredRouters.end(); ++i) { if((*i)->getNbInterfaces() == 1) { InetAddress singleInterface = (*i)->getInterfacesList()->front(); for(list<NetworkTreeNode*>::iterator j = children.begin(); j != children.end(); ++j) { if((*j)->getType() == NetworkTreeNode::T_SUBNET) { SubnetSite *ss = (*j)->getAssociatedSubnet(); if(ss->getStatus() == SubnetSite::ODD_SUBNET && ss->hasLiveInterface(singleInterface)) { bool isALabel = false; for(list<InetAddress>::iterator k = labels.begin(); k != labels.end(); ++k) { if((*k) == singleInterface) { isALabel = true; break; } } if(!isALabel) { delete (*i); inferredRouters.erase(i--); break; } } } } } } }
void main() { Router router; router.Run(); }
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 200); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 110); router->setRoutingParameter(idealNudgingDistance, 25); Polygon poly282634758(4); poly282634758.ps[0] = Point(51360, 50215); poly282634758.ps[1] = Point(51360, 50460); poly282634758.ps[2] = Point(51075, 50460); poly282634758.ps[3] = Point(51075, 50215); new ShapeRef(router, poly282634758, 282634758); Polygon poly69386928(4); poly69386928.ps[0] = Point(51050, 50415); poly69386928.ps[1] = Point(51050, 50735); poly69386928.ps[2] = Point(50690, 50735); poly69386928.ps[3] = Point(50690, 50415); new ShapeRef(router, poly69386928, 69386928); Polygon poly11958280(4); poly11958280.ps[0] = Point(50460, 50490); poly11958280.ps[1] = Point(50460, 50660); poly11958280.ps[2] = Point(50290, 50660); poly11958280.ps[3] = Point(50290, 50490); new ShapeRef(router, poly11958280, 11958280); Polygon poly50591298(4); poly50591298.ps[0] = Point(51260, 50015); poly50591298.ps[1] = Point(51260, 50185); poly50591298.ps[2] = Point(51075, 50185); poly50591298.ps[3] = Point(51075, 50015); new ShapeRef(router, poly50591298, 50591298); ConnRef *connRef355676284 = new ConnRef(router, 355676284); ConnEnd srcPt355676284(Point(51040, 50575), 8); connRef355676284->setSourceEndpoint(srcPt355676284); ConnEnd dstPt355676284(Point(51085, 50300), 4); connRef355676284->setDestEndpoint(dstPt355676284); connRef355676284->setRoutingType((ConnType)2); ConnRef *connRef33653259 = new ConnRef(router, 33653259); ConnEnd srcPt33653259(Point(51040, 50650), 8); connRef33653259->setSourceEndpoint(srcPt33653259); ConnEnd dstPt33653259(Point(51085, 50375), 4); connRef33653259->setDestEndpoint(dstPt33653259); connRef33653259->setRoutingType((ConnType)2); ConnRef *connRef421608980 = new ConnRef(router, 421608980); ConnEnd srcPt421608980(Point(51040, 50500), 8); connRef421608980->setSourceEndpoint(srcPt421608980); ConnEnd dstPt421608980(Point(51085, 50100), 4); connRef421608980->setDestEndpoint(dstPt421608980); connRef421608980->setRoutingType((ConnType)2); router->processTransaction(); router->outputDiagram("output/restrictedNudging"); bool overlap = router->existsOrthogonalTouchingPaths(); delete router; return (overlap) ? 1 : 0; };
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 0); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 110); router->setOrthogonalNudgeDistance(25); Polygon poly426345871(4); poly426345871.ps[0] = Point(7200, 5240); poly426345871.ps[1] = Point(7200, 5660); poly426345871.ps[2] = Point(6690, 5660); poly426345871.ps[3] = Point(6690, 5240); ShapeRef *shapeRef426345871 = new ShapeRef(router, poly426345871, 426345871); router->addShape(shapeRef426345871); Polygon poly596896212(4); poly596896212.ps[0] = Point(7200, 5740); poly596896212.ps[1] = Point(7200, 6160); poly596896212.ps[2] = Point(6690, 6160); poly596896212.ps[3] = Point(6690, 5740); ShapeRef *shapeRef596896212 = new ShapeRef(router, poly596896212, 596896212); router->addShape(shapeRef596896212); ConnRef *connRef20026701 = new ConnRef(router, 20026701); ConnEnd srcPt20026701(Point(7190, 5600), 8); connRef20026701->setSourceEndpoint(srcPt20026701); ConnEnd dstPt20026701(Point(7190, 5800), 8); connRef20026701->setDestEndpoint(dstPt20026701); connRef20026701->setRoutingType((ConnType)2); ConnRef *connRef124776000 = new ConnRef(router, 124776000); ConnEnd srcPt124776000(Point(7190, 5550), 8); connRef124776000->setSourceEndpoint(srcPt124776000); ConnEnd dstPt124776000(Point(7190, 5850), 8); connRef124776000->setDestEndpoint(dstPt124776000); connRef124776000->setRoutingType((ConnType)2); ConnRef *connRef162425002 = new ConnRef(router, 162425002); ConnEnd srcPt162425002(Point(7190, 5500), 8); connRef162425002->setSourceEndpoint(srcPt162425002); ConnEnd dstPt162425002(Point(7190, 5900), 8); connRef162425002->setDestEndpoint(dstPt162425002); connRef162425002->setRoutingType((ConnType)2); ConnRef *connRef445102866 = new ConnRef(router, 445102866); ConnEnd srcPt445102866(Point(7190, 5450), 8); connRef445102866->setSourceEndpoint(srcPt445102866); ConnEnd dstPt445102866(Point(7190, 5950), 8); connRef445102866->setDestEndpoint(dstPt445102866); connRef445102866->setRoutingType((ConnType)2); ConnRef *connRef472520508 = new ConnRef(router, 472520508); ConnEnd srcPt472520508(Point(7190, 5400), 8); connRef472520508->setSourceEndpoint(srcPt472520508); ConnEnd dstPt472520508(Point(7190, 6000), 8); connRef472520508->setDestEndpoint(dstPt472520508); connRef472520508->setRoutingType((ConnType)2); ConnRef *connRef406587600 = new ConnRef(router, 406587600); ConnEnd srcPt406587600(Point(7190, 5350), 8); connRef406587600->setSourceEndpoint(srcPt406587600); ConnEnd dstPt406587600(Point(7190, 6050), 8); connRef406587600->setDestEndpoint(dstPt406587600); connRef406587600->setRoutingType((ConnType)2); ConnRef *connRef41657796 = new ConnRef(router, 41657796); ConnEnd srcPt41657796(Point(7190, 5300), 8); connRef41657796->setSourceEndpoint(srcPt41657796); ConnEnd dstPt41657796(Point(7190, 6100), 8); connRef41657796->setDestEndpoint(dstPt41657796); connRef41657796->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("test-nudgeold"); delete router; return 0; };
static void Patch(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("PATCH", url, handler, name); }; //<! Helper for mapping PATCH
int main(void) { Router *router = new Router(OrthogonalRouting); router->setRoutingParameter((RoutingParameter)0, 10); router->setRoutingParameter((RoutingParameter)1, 0); router->setRoutingParameter((RoutingParameter)2, 1000); router->setRoutingParameter((RoutingParameter)3, 4000); router->setRoutingParameter((RoutingParameter)4, 0); router->setRoutingParameter((RoutingParameter)5, 100); router->setRoutingParameter((RoutingParameter)6, 1); router->setRoutingParameter((RoutingParameter)7, 10); router->setRoutingParameter(reverseDirectionPenalty, 500); router->setRoutingOption((RoutingOption)0, false); router->setRoutingOption((RoutingOption)1, true); router->setRoutingOption((RoutingOption)2, false); router->setRoutingOption((RoutingOption)3, false); router->setRoutingOption((RoutingOption)4, true); router->setRoutingOption((RoutingOption)5, true); Polygon polygon; ConnRef *connRef = NULL; ConnEnd srcPt; ConnEnd dstPt; PolyLine newRoute; // shapeRef1 polygon = Polygon(4); polygon.ps[0] = Point(0, 0); polygon.ps[1] = Point(0, 0); polygon.ps[2] = Point(0, 0); polygon.ps[3] = Point(0, 0); new ShapeRef(router, polygon, 1); // shapeRef2 polygon = Polygon(4); polygon.ps[0] = Point(0, 0); polygon.ps[1] = Point(0, 0); polygon.ps[2] = Point(0, 0); polygon.ps[3] = Point(0, 0); new ShapeRef(router, polygon, 2); // shapeRef3 polygon = Polygon(4); polygon.ps[0] = Point(0, 0); polygon.ps[1] = Point(0, 0); polygon.ps[2] = Point(0, 0); polygon.ps[3] = Point(0, 0); new ShapeRef(router, polygon, 3); // shapeRef4 polygon = Polygon(4); polygon.ps[0] = Point(0, 0); polygon.ps[1] = Point(0, 0); polygon.ps[2] = Point(0, 0); polygon.ps[3] = Point(0, 0); new ShapeRef(router, polygon, 4); // shapeRef5 polygon = Polygon(4); polygon.ps[0] = Point(501, 345); polygon.ps[1] = Point(501, 404); polygon.ps[2] = Point(421, 404); polygon.ps[3] = Point(421, 345); ShapeRef *shapeRef5 = new ShapeRef(router, polygon, 5); new ShapeConnectionPin(shapeRef5, 5, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef5, 6, 0, 0.79096, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef5, 7, 0, 0.514124, true, 0, (ConnDirFlags) 4); // shapeRef6 polygon = Polygon(4); polygon.ps[0] = Point(94, 251.5); polygon.ps[1] = Point(94, 315.5); polygon.ps[2] = Point(12, 315.5); polygon.ps[3] = Point(12, 251.5); ShapeRef *shapeRef6 = new ShapeRef(router, polygon, 6); new ShapeConnectionPin(shapeRef6, 8, 1, 0.640625, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef6, 9, 0, 0.640625, true, 0, (ConnDirFlags) 4); // shapeRef7 polygon = Polygon(4); polygon.ps[0] = Point(634.366, 262); polygon.ps[1] = Point(634.366, 305); polygon.ps[2] = Point(416.366, 305); polygon.ps[3] = Point(416.366, 262); ShapeRef *shapeRef7 = new ShapeRef(router, polygon, 7); new ShapeConnectionPin(shapeRef7, 10, 1, 0.709302, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef7, 11, 0, 0.709302, true, 0, (ConnDirFlags) 4); // shapeRef8 polygon = Polygon(4); polygon.ps[0] = Point(324, 147.167); polygon.ps[1] = Point(324, 206.167); polygon.ps[2] = Point(236, 206.167); polygon.ps[3] = Point(236, 147.167); ShapeRef *shapeRef8 = new ShapeRef(router, polygon, 8); new ShapeConnectionPin(shapeRef8, 12, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef8, 13, 0, 0.79096, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef8, 14, 0, 0.514124, true, 0, (ConnDirFlags) 4); // shapeRef9 polygon = Polygon(4); polygon.ps[0] = Point(816, 353.167); polygon.ps[1] = Point(816, 412.167); polygon.ps[2] = Point(735, 412.167); polygon.ps[3] = Point(735, 353.167); ShapeRef *shapeRef9 = new ShapeRef(router, polygon, 9); new ShapeConnectionPin(shapeRef9, 15, 1, 0.514124, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef9, 16, 1, 0.79096, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef9, 17, 0, 0.79096, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef9, 18, 0, 0.514124, true, 0, (ConnDirFlags) 4); // shapeRef10 polygon = Polygon(4); polygon.ps[0] = Point(981, 263.833); polygon.ps[1] = Point(981, 321.833); polygon.ps[2] = Point(828, 321.833); polygon.ps[3] = Point(828, 263.833); ShapeRef *shapeRef10 = new ShapeRef(router, polygon, 10); new ShapeConnectionPin(shapeRef10, 19, 0, 0.655172, true, 0, (ConnDirFlags) 4); // shapeRef11 polygon = Polygon(4); polygon.ps[0] = Point(1011.49, 361.833); polygon.ps[1] = Point(1011.49, 419.833); polygon.ps[2] = Point(834.489, 419.833); polygon.ps[3] = Point(834.489, 361.833); ShapeRef *shapeRef11 = new ShapeRef(router, polygon, 11); new ShapeConnectionPin(shapeRef11, 20, 0, 0.655172, true, 0, (ConnDirFlags) 4); // shapeRef12 polygon = Polygon(4); polygon.ps[0] = Point(511, 155.333); polygon.ps[1] = Point(511, 214.333); polygon.ps[2] = Point(422, 214.333); polygon.ps[3] = Point(422, 155.333); ShapeRef *shapeRef12 = new ShapeRef(router, polygon, 12); new ShapeConnectionPin(shapeRef12, 21, 1, 0.514124, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef12, 22, 1, 0.79096, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef12, 23, 0, 0.79096, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef12, 24, 0, 0.514124, true, 0, (ConnDirFlags) 4); // shapeRef13 polygon = Polygon(4); polygon.ps[0] = Point(690, 66); polygon.ps[1] = Point(690, 124); polygon.ps[2] = Point(523, 124); polygon.ps[3] = Point(523, 66); ShapeRef *shapeRef13 = new ShapeRef(router, polygon, 13); new ShapeConnectionPin(shapeRef13, 25, 0, 0.655172, true, 0, (ConnDirFlags) 4); // shapeRef14 polygon = Polygon(4); polygon.ps[0] = Point(720.212, 164); polygon.ps[1] = Point(720.212, 222); polygon.ps[2] = Point(529.212, 222); polygon.ps[3] = Point(529.212, 164); ShapeRef *shapeRef14 = new ShapeRef(router, polygon, 14); new ShapeConnectionPin(shapeRef14, 26, 0, 0.655172, true, 0, (ConnDirFlags) 4); // shapeRef15 polygon = Polygon(4); polygon.ps[0] = Point(217, 336.833); polygon.ps[1] = Point(217, 395.833); polygon.ps[2] = Point(98, 395.833); polygon.ps[3] = Point(98, 336.833); ShapeRef *shapeRef15 = new ShapeRef(router, polygon, 15); new ShapeConnectionPin(shapeRef15, 27, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef15, 28, 0, 0.652542, true, 0, (ConnDirFlags) 4); // shapeRef16 polygon = Polygon(4); polygon.ps[0] = Point(413, 147.167); polygon.ps[1] = Point(413, 206.167); polygon.ps[2] = Point(336, 206.167); polygon.ps[3] = Point(336, 147.167); ShapeRef *shapeRef16 = new ShapeRef(router, polygon, 16); new ShapeConnectionPin(shapeRef16, 29, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef16, 30, 0, 0.652542, true, 0, (ConnDirFlags) 4); // shapeRef17 polygon = Polygon(4); polygon.ps[0] = Point(306, 336.833); polygon.ps[1] = Point(306, 395.833); polygon.ps[2] = Point(229, 395.833); polygon.ps[3] = Point(229, 336.833); ShapeRef *shapeRef17 = new ShapeRef(router, polygon, 17); new ShapeConnectionPin(shapeRef17, 31, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef17, 32, 0, 0.652542, true, 0, (ConnDirFlags) 4); // shapeRef18 polygon = Polygon(4); polygon.ps[0] = Point(175, 139); polygon.ps[1] = Point(175, 198); polygon.ps[2] = Point(98, 198); polygon.ps[3] = Point(98, 139); ShapeRef *shapeRef18 = new ShapeRef(router, polygon, 18); new ShapeConnectionPin(shapeRef18, 33, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef18, 34, 0, 0.652542, true, 0, (ConnDirFlags) 4); // shapeRef19 polygon = Polygon(4); polygon.ps[0] = Point(409, 399.333); polygon.ps[1] = Point(409, 458.333); polygon.ps[2] = Point(298, 458.333); polygon.ps[3] = Point(298, 399.333); ShapeRef *shapeRef19 = new ShapeRef(router, polygon, 19); new ShapeConnectionPin(shapeRef19, 35, 1, 0.652542, true, 0, (ConnDirFlags) 8); // shapeRef20 polygon = Polygon(4); polygon.ps[0] = Point(224, 40); polygon.ps[1] = Point(224, 99); polygon.ps[2] = Point(106, 99); polygon.ps[3] = Point(106, 40); ShapeRef *shapeRef20 = new ShapeRef(router, polygon, 20); new ShapeConnectionPin(shapeRef20, 36, 1, 0.652542, true, 0, (ConnDirFlags) 8); // shapeRef21 polygon = Polygon(4); polygon.ps[0] = Point(604, 345); polygon.ps[1] = Point(604, 404); polygon.ps[2] = Point(513, 404); polygon.ps[3] = Point(513, 345); ShapeRef *shapeRef21 = new ShapeRef(router, polygon, 21); new ShapeConnectionPin(shapeRef21, 37, 1, 0.652542, true, 0, (ConnDirFlags) 8); new ShapeConnectionPin(shapeRef21, 38, 0, 0.652542, true, 0, (ConnDirFlags) 4); // connRef1 connRef = new ConnRef(router, 1); srcPt = ConnEnd(shapeRef5, 5); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef21, 38); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef2 connRef = new ConnRef(router, 2); srcPt = ConnEnd(shapeRef6, 8); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef18, 34); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef3 connRef = new ConnRef(router, 3); srcPt = ConnEnd(shapeRef6, 8); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef15, 28); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef4 connRef = new ConnRef(router, 4); srcPt = ConnEnd(shapeRef6, 8); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef12, 23); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef5 connRef = new ConnRef(router, 5); srcPt = ConnEnd(shapeRef6, 8); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef7, 11); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef6 connRef = new ConnRef(router, 6); srcPt = ConnEnd(shapeRef7, 10); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef9, 17); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); ConnRef *connector6 = connRef; // connRef7 connRef = new ConnRef(router, 7); srcPt = ConnEnd(shapeRef8, 12); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef16, 30); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef8 connRef = new ConnRef(router, 8); srcPt = ConnEnd(shapeRef9, 15); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef10, 19); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef9 connRef = new ConnRef(router, 9); srcPt = ConnEnd(shapeRef9, 16); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef11, 20); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef10 connRef = new ConnRef(router, 10); srcPt = ConnEnd(shapeRef12, 21); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef13, 25); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef11 connRef = new ConnRef(router, 11); srcPt = ConnEnd(shapeRef12, 22); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef14, 26); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef12 connRef = new ConnRef(router, 12); srcPt = ConnEnd(shapeRef15, 27); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef17, 32); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef13 connRef = new ConnRef(router, 13); srcPt = ConnEnd(shapeRef16, 29); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef12, 24); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef14 connRef = new ConnRef(router, 14); srcPt = ConnEnd(shapeRef17, 31); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef5, 7); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef15 connRef = new ConnRef(router, 15); srcPt = ConnEnd(shapeRef18, 33); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef8, 14); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef16 connRef = new ConnRef(router, 16); srcPt = ConnEnd(shapeRef19, 35); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef5, 7); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef17 connRef = new ConnRef(router, 17); srcPt = ConnEnd(shapeRef20, 36); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef8, 14); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); // connRef18 connRef = new ConnRef(router, 18); srcPt = ConnEnd(shapeRef21, 37); connRef->setSourceEndpoint(srcPt); dstPt = ConnEnd(shapeRef9, 18); connRef->setDestEndpoint(dstPt); connRef->setRoutingType((ConnType)2); router->processTransaction(); // Test that connector 6 has three segments and doesnt loop right // around the shapes on the right due to the crossing penalty. bool suceeds = (connector6->displayRoute().size() == 4); //router->outputInstanceToSVG("output/forwardFlowingConnectors01"); delete router; return (suceeds ? 0 : 1); };
static void Delete(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("DELETE", url, handler, name); }; //<! Helper for mapping DELETE
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 200); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 110); router->setRoutingPenalty((PenaltyType)5, 100); router->setRoutingOption((RoutingOption)0, false); router->setRoutingOption((RoutingOption)1, true); router->setRoutingParameter(idealNudgingDistance, 25); Polygon poly3075375(4); poly3075375.ps[0] = Point(51925, 52070); poly3075375.ps[1] = Point(51925, 52130); poly3075375.ps[2] = Point(51725, 52130); poly3075375.ps[3] = Point(51725, 52070); new ShapeRef(router, poly3075375, 3075375); Polygon poly101599344(4); poly101599344.ps[0] = Point(50275, 52410); poly101599344.ps[1] = Point(50275, 52490); poly101599344.ps[2] = Point(50075, 52490); poly101599344.ps[3] = Point(50075, 52410); new ShapeRef(router, poly101599344, 101599344); Polygon poly127957550(4); poly127957550.ps[0] = Point(52010, 51617); poly127957550.ps[1] = Point(52010, 51683); poly127957550.ps[2] = Point(51890, 51683); poly127957550.ps[3] = Point(51890, 51617); ShapeRef *shapeRef127957550 = new ShapeRef(router, poly127957550, 127957550); new ShapeConnectionPin(shapeRef127957550, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 1); new ShapeConnectionPin(shapeRef127957550, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 2); new ShapeConnectionPin(shapeRef127957550, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef127957550, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 8); Polygon poly129612347(4); poly129612347.ps[0] = Point(51900, 51696); poly129612347.ps[1] = Point(51900, 51754); poly129612347.ps[2] = Point(51815, 51754); poly129612347.ps[3] = Point(51815, 51696); new ShapeRef(router, poly129612347, 129612347); Polygon poly203389050(4); poly203389050.ps[0] = Point(51825, 52260); poly203389050.ps[1] = Point(51825, 52340); poly203389050.ps[2] = Point(51625, 52340); poly203389050.ps[3] = Point(51625, 52260); new ShapeRef(router, poly203389050, 203389050); Polygon poly208676910(4); poly208676910.ps[0] = Point(51950, 51760); poly208676910.ps[1] = Point(51950, 51840); poly208676910.ps[2] = Point(51750, 51840); poly208676910.ps[3] = Point(51750, 51760); new ShapeRef(router, poly208676910, 208676910); Polygon poly219117032(4); poly219117032.ps[0] = Point(50225, 52070); poly219117032.ps[1] = Point(50225, 52130); poly219117032.ps[2] = Point(50025, 52130); poly219117032.ps[3] = Point(50025, 52070); new ShapeRef(router, poly219117032, 219117032); Polygon poly258454350(4); poly258454350.ps[0] = Point(50185, 51617); poly258454350.ps[1] = Point(50185, 51683); poly258454350.ps[2] = Point(50065, 51683); poly258454350.ps[3] = Point(50065, 51617); ShapeRef *shapeRef258454350 = new ShapeRef(router, poly258454350, 258454350); new ShapeConnectionPin(shapeRef258454350, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 1); new ShapeConnectionPin(shapeRef258454350, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 2); new ShapeConnectionPin(shapeRef258454350, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 4); new ShapeConnectionPin(shapeRef258454350, 2147483646, 0.5, 0.5, true, 0, (ConnDirFlags) 8); Polygon poly274504590(4); poly274504590.ps[0] = Point(51400, 52470); poly274504590.ps[1] = Point(51400, 52530); poly274504590.ps[2] = Point(51150, 52530); poly274504590.ps[3] = Point(51150, 52470); new ShapeRef(router, poly274504590, 274504590); Polygon poly320957826(4); poly320957826.ps[0] = Point(50275, 51910); poly320957826.ps[1] = Point(50275, 51990); poly320957826.ps[2] = Point(50075, 51990); poly320957826.ps[3] = Point(50075, 51910); new ShapeRef(router, poly320957826, 320957826); Polygon poly368436384(4); poly368436384.ps[0] = Point(50325, 51696); poly368436384.ps[1] = Point(50325, 51754); poly368436384.ps[2] = Point(50240, 51754); poly368436384.ps[3] = Point(50240, 51696); new ShapeRef(router, poly368436384, 368436384); Polygon poly381499178(4); poly381499178.ps[0] = Point(51850, 51345); poly381499178.ps[1] = Point(51850, 51405); poly381499178.ps[2] = Point(51650, 51405); poly381499178.ps[3] = Point(51650, 51345); new ShapeRef(router, poly381499178, 381499178); Polygon poly426410694(4); poly426410694.ps[0] = Point(50325, 52270); poly426410694.ps[1] = Point(50325, 52330); poly426410694.ps[2] = Point(50125, 52330); poly426410694.ps[3] = Point(50125, 52270); new ShapeRef(router, poly426410694, 426410694); Polygon poly428912890(4); poly428912890.ps[0] = Point(51825, 51510); poly428912890.ps[1] = Point(51825, 51590); poly428912890.ps[2] = Point(51625, 51590); poly428912890.ps[3] = Point(51625, 51510); new ShapeRef(router, poly428912890, 428912890); Polygon poly468897320(4); poly468897320.ps[0] = Point(50425, 51520); poly468897320.ps[1] = Point(50425, 51580); poly468897320.ps[2] = Point(50225, 51580); poly468897320.ps[3] = Point(50225, 51520); new ShapeRef(router, poly468897320, 468897320); Polygon poly517518507(4); poly517518507.ps[0] = Point(51925, 51910); poly517518507.ps[1] = Point(51925, 51990); poly517518507.ps[2] = Point(51725, 51990); poly517518507.ps[3] = Point(51725, 51910); new ShapeRef(router, poly517518507, 517518507); Polygon poly565878858(4); poly565878858.ps[0] = Point(51160, 52500); poly565878858.ps[1] = Point(51160, 52810); poly565878858.ps[2] = Point(50890, 52810); poly565878858.ps[3] = Point(50890, 52500); new ShapeRef(router, poly565878858, 565878858); Polygon poly706147100(4); poly706147100.ps[0] = Point(51160, 50990); poly706147100.ps[1] = Point(51160, 51300); poly706147100.ps[2] = Point(50890, 51300); poly706147100.ps[3] = Point(50890, 50990); new ShapeRef(router, poly706147100, 706147100); Polygon poly746254622(4); poly746254622.ps[0] = Point(50275, 51760); poly746254622.ps[1] = Point(50275, 51840); poly746254622.ps[2] = Point(50075, 51840); poly746254622.ps[3] = Point(50075, 51760); new ShapeRef(router, poly746254622, 746254622); Polygon poly829835240(4); poly829835240.ps[0] = Point(50425, 51360); poly829835240.ps[1] = Point(50425, 51440); poly829835240.ps[2] = Point(50225, 51440); poly829835240.ps[3] = Point(50225, 51360); new ShapeRef(router, poly829835240, 829835240); Polygon poly157548160(4); poly157548160.ps[0] = Point(51550, 51500); poly157548160.ps[1] = Point(51550, 52225); poly157548160.ps[2] = Point(50525, 52225); poly157548160.ps[3] = Point(50525, 51500); new ShapeRef(router, poly157548160, 157548160); ConnRef *connRef6675422 = new ConnRef(router, 6675422); ConnEnd srcPt6675422(Point(51100, 51290), 2); connRef6675422->setSourceEndpoint(srcPt6675422); ConnEnd dstPt6675422(Point(51150, 51510), 1); connRef6675422->setDestEndpoint(dstPt6675422); connRef6675422->setRoutingType((ConnType)2); ConnRef *connRef13259320 = new ConnRef(router, 13259320); ConnEnd srcPt13259320(Point(50535, 51675), 4); connRef13259320->setSourceEndpoint(srcPt13259320); ConnEnd dstPt13259320(Point(50315, 51725), 8); connRef13259320->setDestEndpoint(dstPt13259320); connRef13259320->setRoutingType((ConnType)2); ConnRef *connRef17108208 = new ConnRef(router, 17108208); ConnEnd srcPt17108208(Point(51540, 52050), 8); connRef17108208->setSourceEndpoint(srcPt17108208); ConnEnd dstPt17108208(Point(51735, 52100), 4); connRef17108208->setDestEndpoint(dstPt17108208); connRef17108208->setRoutingType((ConnType)2); ConnRef *connRef41442471 = new ConnRef(router, 41442471); ConnEnd srcPt41442471(Point(51075, 52215), 2); connRef41442471->setSourceEndpoint(srcPt41442471); ConnEnd dstPt41442471(Point(51050, 52510), 1); connRef41442471->setDestEndpoint(dstPt41442471); connRef41442471->setRoutingType((ConnType)2); ConnRef *connRef45863720 = new ConnRef(router, 45863720); ConnEnd srcPt45863720(Point(51660, 51375), 4); connRef45863720->setSourceEndpoint(srcPt45863720); ConnEnd dstPt45863720(Point(51300, 51510), 1); connRef45863720->setDestEndpoint(dstPt45863720); connRef45863720->setRoutingType((ConnType)2); ConnRef *connRef52653348 = new ConnRef(router, 52653348); ConnEnd srcPt52653348(Point(50535, 52050), 4); connRef52653348->setSourceEndpoint(srcPt52653348); ConnEnd dstPt52653348(Point(50215, 52100), 8); connRef52653348->setDestEndpoint(dstPt52653348); connRef52653348->setRoutingType((ConnType)2); ConnRef *connRef57649636 = new ConnRef(router, 57649636); ConnEnd srcPt57649636(Point(51540, 52125), 8); connRef57649636->setSourceEndpoint(srcPt57649636); ConnEnd dstPt57649636(Point(51915, 52100), 8); connRef57649636->setDestEndpoint(dstPt57649636); connRef57649636->setRoutingType((ConnType)2); ConnRef *connRef64735671 = new ConnRef(router, 64735671); ConnEnd srcPt64735671(Point(51375, 52215), 2); connRef64735671->setSourceEndpoint(srcPt64735671); ConnEnd dstPt64735671(Point(51815, 52300), 8); connRef64735671->setDestEndpoint(dstPt64735671); connRef64735671->setRoutingType((ConnType)2); ConnRef *connRef81789576 = new ConnRef(router, 81789576); ConnEnd srcPt81789576(Point(50950, 51290), 2); connRef81789576->setSourceEndpoint(srcPt81789576); ConnEnd dstPt81789576(Point(50925, 51510), 1); connRef81789576->setDestEndpoint(dstPt81789576); connRef81789576->setRoutingType((ConnType)2); ConnRef *connRef87742344 = new ConnRef(router, 87742344); ConnEnd srcPt87742344(Point(51540, 51600), 8); connRef87742344->setSourceEndpoint(srcPt87742344); ConnEnd dstPt87742344(shapeRef127957550, 2147483646); connRef87742344->setDestEndpoint(dstPt87742344); connRef87742344->setRoutingType((ConnType)2); ConnRef *connRef92624219 = new ConnRef(router, 92624219); ConnEnd srcPt92624219(Point(51450, 52215), 2); connRef92624219->setSourceEndpoint(srcPt92624219); ConnEnd dstPt92624219(Point(51635, 52300), 4); connRef92624219->setDestEndpoint(dstPt92624219); connRef92624219->setRoutingType((ConnType)2); ConnRef *connRef126568050 = new ConnRef(router, 126568050); ConnEnd srcPt126568050(Point(51540, 51975), 8); connRef126568050->setSourceEndpoint(srcPt126568050); ConnEnd dstPt126568050(Point(51915, 51950), 8); connRef126568050->setDestEndpoint(dstPt126568050); connRef126568050->setRoutingType((ConnType)2); ConnRef *connRef128113340 = new ConnRef(router, 128113340); ConnEnd srcPt128113340(Point(51300, 52215), 2); connRef128113340->setSourceEndpoint(srcPt128113340); ConnEnd dstPt128113340(Point(51390, 52500), 8); connRef128113340->setDestEndpoint(dstPt128113340); connRef128113340->setRoutingType((ConnType)2); ConnRef *connRef157642749 = new ConnRef(router, 157642749); ConnEnd srcPt157642749(Point(51225, 52215), 2); connRef157642749->setSourceEndpoint(srcPt157642749); // Problem point: ConnEnd dstPt157642749(Point(51160, 52500), 4); connRef157642749->setDestEndpoint(dstPt157642749); connRef157642749->setRoutingType((ConnType)2); ConnRef *connRef182970626 = new ConnRef(router, 182970626); ConnEnd srcPt182970626(Point(51000, 52215), 2); connRef182970626->setSourceEndpoint(srcPt182970626); ConnEnd dstPt182970626(Point(51000, 52510), 1); connRef182970626->setDestEndpoint(dstPt182970626); connRef182970626->setRoutingType((ConnType)2); ConnRef *connRef191618599 = new ConnRef(router, 191618599); ConnEnd srcPt191618599(Point(50535, 51900), 4); connRef191618599->setSourceEndpoint(srcPt191618599); ConnEnd dstPt191618599(Point(50265, 51950), 8); connRef191618599->setDestEndpoint(dstPt191618599); connRef191618599->setRoutingType((ConnType)2); ConnRef *connRef215646300 = new ConnRef(router, 215646300); ConnEnd srcPt215646300(Point(50415, 51400), 8); connRef215646300->setSourceEndpoint(srcPt215646300); ConnEnd dstPt215646300(Point(50775, 51510), 1); connRef215646300->setDestEndpoint(dstPt215646300); connRef215646300->setRoutingType((ConnType)2); ConnRef *connRef217181718 = new ConnRef(router, 217181718); ConnEnd srcPt217181718(Point(51000, 51290), 2); connRef217181718->setSourceEndpoint(srcPt217181718); ConnEnd dstPt217181718(Point(51000, 51510), 1); connRef217181718->setDestEndpoint(dstPt217181718); connRef217181718->setRoutingType((ConnType)2); ConnRef *connRef217236398 = new ConnRef(router, 217236398); ConnEnd srcPt217236398(Point(50700, 52215), 2); connRef217236398->setSourceEndpoint(srcPt217236398); ConnEnd dstPt217236398(Point(50135, 52300), 4); connRef217236398->setDestEndpoint(dstPt217236398); connRef217236398->setRoutingType((ConnType)2); ConnRef *connRef227676560 = new ConnRef(router, 227676560); ConnEnd srcPt227676560(Point(50850, 51510), 1); connRef227676560->setSourceEndpoint(srcPt227676560); ConnEnd dstPt227676560(Point(50235, 51400), 4); connRef227676560->setDestEndpoint(dstPt227676560); connRef227676560->setRoutingType((ConnType)2); ConnRef *connRef235740708 = new ConnRef(router, 235740708); ConnEnd srcPt235740708(Point(51540, 51675), 8); connRef235740708->setSourceEndpoint(srcPt235740708); ConnEnd dstPt235740708(Point(51870, 51725), 8); connRef235740708->setDestEndpoint(dstPt235740708); connRef235740708->setRoutingType((ConnType)2); ConnRef *connRef307166980 = new ConnRef(router, 307166980); ConnEnd srcPt307166980(Point(50925, 52215), 2); connRef307166980->setSourceEndpoint(srcPt307166980); ConnEnd dstPt307166980(Point(50950, 52510), 1); connRef307166980->setDestEndpoint(dstPt307166980); connRef307166980->setRoutingType((ConnType)2); ConnRef *connRef314353850 = new ConnRef(router, 314353850); ConnEnd srcPt314353850(Point(51050, 51290), 2); connRef314353850->setSourceEndpoint(srcPt314353850); ConnEnd dstPt314353850(Point(51075, 51510), 1); connRef314353850->setDestEndpoint(dstPt314353850); connRef314353850->setRoutingType((ConnType)2); ConnRef *connRef356343444 = new ConnRef(router, 356343444); ConnEnd srcPt356343444(Point(50625, 51510), 1); connRef356343444->setSourceEndpoint(srcPt356343444); ConnEnd dstPt356343444(Point(50415, 51550), 8); connRef356343444->setDestEndpoint(dstPt356343444); connRef356343444->setRoutingType((ConnType)2); ConnRef *connRef401560509 = new ConnRef(router, 401560509); ConnEnd srcPt401560509(Point(50625, 52215), 2); connRef401560509->setSourceEndpoint(srcPt401560509); ConnEnd dstPt401560509(Point(50315, 52300), 8); connRef401560509->setDestEndpoint(dstPt401560509); connRef401560509->setRoutingType((ConnType)2); ConnRef *connRef413072940 = new ConnRef(router, 413072940); ConnEnd srcPt413072940(Point(51840, 51375), 8); connRef413072940->setSourceEndpoint(srcPt413072940); ConnEnd dstPt413072940(Point(51225, 51510), 1); connRef413072940->setDestEndpoint(dstPt413072940); connRef413072940->setRoutingType((ConnType)2); ConnRef *connRef413766381 = new ConnRef(router, 413766381); ConnEnd srcPt413766381(Point(50535, 51750), 4); connRef413766381->setSourceEndpoint(srcPt413766381); ConnEnd dstPt413766381(Point(50265, 51800), 8); connRef413766381->setDestEndpoint(dstPt413766381); connRef413766381->setRoutingType((ConnType)2); ConnRef *connRef422359365 = new ConnRef(router, 422359365); ConnEnd srcPt422359365(Point(50535, 51825), 4); connRef422359365->setSourceEndpoint(srcPt422359365); ConnEnd dstPt422359365(Point(50085, 51800), 4); connRef422359365->setDestEndpoint(dstPt422359365); connRef422359365->setRoutingType((ConnType)2); ConnRef *connRef427415850 = new ConnRef(router, 427415850); ConnEnd srcPt427415850(Point(50775, 52215), 2); connRef427415850->setSourceEndpoint(srcPt427415850); ConnEnd dstPt427415850(Point(50265, 52450), 8); connRef427415850->setDestEndpoint(dstPt427415850); connRef427415850->setRoutingType((ConnType)2); ConnRef *connRef444649182 = new ConnRef(router, 444649182); ConnEnd srcPt444649182(Point(51540, 51750), 8); connRef444649182->setSourceEndpoint(srcPt444649182); ConnEnd dstPt444649182(Point(51760, 51800), 4); connRef444649182->setDestEndpoint(dstPt444649182); connRef444649182->setRoutingType((ConnType)2); ConnRef *connRef505297694 = new ConnRef(router, 505297694); ConnEnd srcPt505297694(Point(50700, 51510), 1); connRef505297694->setSourceEndpoint(srcPt505297694); ConnEnd dstPt505297694(Point(50235, 51550), 4); connRef505297694->setDestEndpoint(dstPt505297694); connRef505297694->setRoutingType((ConnType)2); ConnRef *connRef528809632 = new ConnRef(router, 528809632); ConnEnd srcPt528809632(Point(51540, 51900), 8); connRef528809632->setSourceEndpoint(srcPt528809632); ConnEnd dstPt528809632(Point(51735, 51950), 4); connRef528809632->setDestEndpoint(dstPt528809632); connRef528809632->setRoutingType((ConnType)2); ConnRef *connRef548127810 = new ConnRef(router, 548127810); ConnEnd srcPt548127810(Point(50535, 51975), 4); connRef548127810->setSourceEndpoint(srcPt548127810); ConnEnd dstPt548127810(Point(50085, 51950), 4); connRef548127810->setDestEndpoint(dstPt548127810); connRef548127810->setRoutingType((ConnType)2); ConnRef *connRef648819584 = new ConnRef(router, 648819584); ConnEnd srcPt648819584(Point(51540, 51825), 8); connRef648819584->setSourceEndpoint(srcPt648819584); ConnEnd dstPt648819584(Point(51940, 51800), 8); connRef648819584->setDestEndpoint(dstPt648819584); connRef648819584->setRoutingType((ConnType)2); ConnRef *connRef651183694 = new ConnRef(router, 651183694); ConnEnd srcPt651183694(Point(51635, 51550), 4); connRef651183694->setSourceEndpoint(srcPt651183694); ConnEnd dstPt651183694(Point(51450, 51510), 1); connRef651183694->setDestEndpoint(dstPt651183694); connRef651183694->setRoutingType((ConnType)2); ConnRef *connRef655025700 = new ConnRef(router, 655025700); ConnEnd srcPt655025700(Point(51150, 52215), 2); connRef655025700->setSourceEndpoint(srcPt655025700); ConnEnd dstPt655025700(Point(51100, 52510), 1); connRef655025700->setDestEndpoint(dstPt655025700); connRef655025700->setRoutingType((ConnType)2); ConnRef *connRef662151765 = new ConnRef(router, 662151765); ConnEnd srcPt662151765(Point(50535, 51600), 4); connRef662151765->setSourceEndpoint(srcPt662151765); ConnEnd dstPt662151765(shapeRef258454350, 2147483646); connRef662151765->setDestEndpoint(dstPt662151765); connRef662151765->setRoutingType((ConnType)2); ConnRef *connRef678159455 = new ConnRef(router, 678159455); ConnEnd srcPt678159455(Point(51815, 51550), 8); connRef678159455->setSourceEndpoint(srcPt678159455); ConnEnd dstPt678159455(Point(51375, 51510), 1); connRef678159455->setDestEndpoint(dstPt678159455); connRef678159455->setRoutingType((ConnType)2); ConnRef *connRef803304040 = new ConnRef(router, 803304040); ConnEnd srcPt803304040(Point(50850, 52215), 2); connRef803304040->setSourceEndpoint(srcPt803304040); ConnEnd dstPt803304040(Point(50085, 52450), 4); connRef803304040->setDestEndpoint(dstPt803304040); connRef803304040->setRoutingType((ConnType)2); ConnRef *connRef960638799 = new ConnRef(router, 960638799); ConnEnd srcPt960638799(Point(50535, 52125), 4); connRef960638799->setSourceEndpoint(srcPt960638799); ConnEnd dstPt960638799(Point(50035, 52100), 4); connRef960638799->setDestEndpoint(dstPt960638799); connRef960638799->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("output/validPaths01"); int result = router->existsInvalidOrthogonalPaths(); delete router; return result; };
static bool Route(Request *req, THandlerFunction& handler) { return router.route(req, handler); }; //<! Performs routing based on req->url.path
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 0); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 110); router->setOrthogonalNudgeDistance(12); Polygon poly21424960(4); poly21424960.ps[0] = Point(29950, 27210); poly21424960.ps[1] = Point(29950, 27290); poly21424960.ps[2] = Point(29700, 27290); poly21424960.ps[3] = Point(29700, 27210); new ShapeRef(router, poly21424960, 21424960); Polygon poly435105790(4); poly435105790.ps[0] = Point(29950, 27110); poly435105790.ps[1] = Point(29950, 27190); poly435105790.ps[2] = Point(29700, 27190); poly435105790.ps[3] = Point(29700, 27110); new ShapeRef(router, poly435105790, 435105790); Polygon poly40787191(4); poly40787191.ps[0] = Point(29950, 27010); poly40787191.ps[1] = Point(29950, 27090); poly40787191.ps[2] = Point(29700, 27090); poly40787191.ps[3] = Point(29700, 27010); new ShapeRef(router, poly40787191, 40787191); Polygon poly76911264(4); poly76911264.ps[0] = Point(29950, 26910); poly76911264.ps[1] = Point(29950, 26990); poly76911264.ps[2] = Point(29700, 26990); poly76911264.ps[3] = Point(29700, 26910); new ShapeRef(router, poly76911264, 76911264); Polygon poly506213376(4); poly506213376.ps[0] = Point(29925, 26820); poly506213376.ps[1] = Point(29925, 26880); poly506213376.ps[2] = Point(29675, 26880); poly506213376.ps[3] = Point(29675, 26820); new ShapeRef(router, poly506213376, 506213376); Polygon poly134604636(4); poly134604636.ps[0] = Point(29925, 26720); poly134604636.ps[1] = Point(29925, 26780); poly134604636.ps[2] = Point(29675, 26780); poly134604636.ps[3] = Point(29675, 26720); new ShapeRef(router, poly134604636, 134604636); Polygon poly14353632(4); poly14353632.ps[0] = Point(29600, 26590); poly14353632.ps[1] = Point(29600, 27660); poly14353632.ps[2] = Point(28440, 27660); poly14353632.ps[3] = Point(28440, 26590); new ShapeRef(router, poly14353632, 14353632); ConnRef *connRef70269732 = new ConnRef(router, 70269732); ConnEnd srcPt70269732(Point(29590, 26700), 8); connRef70269732->setSourceEndpoint(srcPt70269732); ConnEnd dstPt70269732(Point(29915, 26750), 8); connRef70269732->setDestEndpoint(dstPt70269732); connRef70269732->setRoutingType((ConnType)2); ConnRef *connRef371572709 = new ConnRef(router, 371572709); ConnEnd srcPt371572709(Point(29590, 26800), 8); connRef371572709->setSourceEndpoint(srcPt371572709); ConnEnd dstPt371572709(Point(29915, 26850), 8); connRef371572709->setDestEndpoint(dstPt371572709); connRef371572709->setRoutingType((ConnType)2); ConnRef *connRef876797766 = new ConnRef(router, 876797766); ConnEnd srcPt876797766(Point(29590, 26900), 8); connRef876797766->setSourceEndpoint(srcPt876797766); ConnEnd dstPt876797766(Point(29940, 26950), 8); connRef876797766->setDestEndpoint(dstPt876797766); connRef876797766->setRoutingType((ConnType)2); ConnRef *connRef134423590 = new ConnRef(router, 134423590); ConnEnd srcPt134423590(Point(29590, 27000), 8); connRef134423590->setSourceEndpoint(srcPt134423590); ConnEnd dstPt134423590(Point(29940, 27050), 8); connRef134423590->setDestEndpoint(dstPt134423590); connRef134423590->setRoutingType((ConnType)2); ConnRef *connRef872586669 = new ConnRef(router, 872586669); ConnEnd srcPt872586669(Point(29590, 27100), 8); connRef872586669->setSourceEndpoint(srcPt872586669); ConnEnd dstPt872586669(Point(29940, 27150), 8); connRef872586669->setDestEndpoint(dstPt872586669); connRef872586669->setRoutingType((ConnType)2); ConnRef *connRef23601612 = new ConnRef(router, 23601612); ConnEnd srcPt23601612(Point(29590, 27200), 8); connRef23601612->setSourceEndpoint(srcPt23601612); ConnEnd dstPt23601612(Point(29940, 27250), 8); connRef23601612->setDestEndpoint(dstPt23601612); connRef23601612->setRoutingType((ConnType)2); ConnRef *connRef737483980 = new ConnRef(router, 737483980); ConnEnd srcPt737483980(Point(29685, 26750), 4); connRef737483980->setSourceEndpoint(srcPt737483980); ConnEnd dstPt737483980(Point(29590, 26650), 8); connRef737483980->setDestEndpoint(dstPt737483980); connRef737483980->setRoutingType((ConnType)2); ConnRef *connRef410784855 = new ConnRef(router, 410784855); ConnEnd srcPt410784855(Point(29685, 26850), 4); connRef410784855->setSourceEndpoint(srcPt410784855); ConnEnd dstPt410784855(Point(29590, 26750), 8); connRef410784855->setDestEndpoint(dstPt410784855); connRef410784855->setRoutingType((ConnType)2); ConnRef *connRef15771480 = new ConnRef(router, 15771480); ConnEnd srcPt15771480(Point(29710, 26950), 4); connRef15771480->setSourceEndpoint(srcPt15771480); ConnEnd dstPt15771480(Point(29590, 26850), 8); connRef15771480->setDestEndpoint(dstPt15771480); connRef15771480->setRoutingType((ConnType)2); ConnRef *connRef34657402 = new ConnRef(router, 34657402); ConnEnd srcPt34657402(Point(29710, 27050), 4); connRef34657402->setSourceEndpoint(srcPt34657402); ConnEnd dstPt34657402(Point(29590, 26950), 8); connRef34657402->setDestEndpoint(dstPt34657402); connRef34657402->setRoutingType((ConnType)2); ConnRef *connRef98191218 = new ConnRef(router, 98191218); ConnEnd srcPt98191218(Point(29710, 27150), 4); connRef98191218->setSourceEndpoint(srcPt98191218); ConnEnd dstPt98191218(Point(29590, 27050), 8); connRef98191218->setDestEndpoint(dstPt98191218); connRef98191218->setRoutingType((ConnType)2); ConnRef *connRef23433311 = new ConnRef(router, 23433311); ConnEnd srcPt23433311(Point(29710, 27250), 4); connRef23433311->setSourceEndpoint(srcPt23433311); ConnEnd dstPt23433311(Point(29590, 27150), 8); connRef23433311->setDestEndpoint(dstPt23433311); connRef23433311->setRoutingType((ConnType)2); router->processTransaction(); router->outputInstanceToSVG("output/orneroverlap01"); bool touching = router->existsOrthogonalTouchingPaths(); delete router; return (touching) ? 1 : 0; };
static std::pair<std::string, std::string> URLFor(const std::string &name, const strstr_map_t& arguments) { return router.urlFor(name,arguments); }; //<! Generates url from named route and arguments. Missing arguments are assumed empty
int main(void) { Router *router = new Router(OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 0); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 105); router->setOrthogonalNudgeDistance(25); Rectangle rect478845150(Point(50695, 51070), Point(50705, 51080)); ShapeRef *shapeRef478845150 = new ShapeRef(router, rect478845150, 478845150); ShapeConnectionPin *pin = new Avoid::ShapeConnectionPin(shapeRef478845150, Avoid::CONNECTIONPIN_CENTRE, Avoid::ATTACH_POS_CENTRE, Avoid::ATTACH_POS_CENTRE); pin->setExclusive(false); router->addShape(shapeRef478845150); Rectangle rect92712048(Point(51246, 50475), Point(51304, 50585)); ShapeRef *shapeRef92712048 = new ShapeRef(router, rect92712048, 92712048); router->addShape(shapeRef92712048); Rectangle rect23127921(Point(50365, 50766), Point(50485, 50834)); ShapeRef *shapeRef23127921 = new ShapeRef(router, rect23127921, 23127921); router->addShape(shapeRef23127921); Rectangle rect159957148(Point(51740, 50891), Point(51860, 50959)); ShapeRef *shapeRef159957148 = new ShapeRef(router, rect159957148, 159957148); router->addShape(shapeRef159957148); Rectangle rect1350214(Point(50375, 51015), Point(50625, 51135)); ShapeRef *shapeRef1350214 = new ShapeRef(router, rect1350214, 1350214); router->addShape(shapeRef1350214); Rectangle rect247197258(Point(50265, 51046), Point(50375, 51104)); ShapeRef *shapeRef247197258 = new ShapeRef(router, rect247197258, 247197258); router->addShape(shapeRef247197258); Rectangle rect281096654(Point(50700, 50390), Point(51000, 50610)); ShapeRef *shapeRef281096654 = new ShapeRef(router, rect281096654, 281096654); router->addShape(shapeRef281096654); ConnEnd srcPt342420237(Point(50425, 50800), 15); ConnEnd dstPt342420237(Point(50710, 50450), 4); new ConnRef(router, srcPt342420237, dstPt342420237, 342420237); ConnEnd srcPt352019675(Point(50990, 50500), 8); ConnEnd dstPt352019675(shapeRef478845150, Avoid::CONNECTIONPIN_CENTRE); //ConnEnd dstPt352019675(Point(50700, 51075), 15); new ConnRef(router, srcPt352019675, dstPt352019675, 352019675); ConnEnd srcPt42699400(shapeRef478845150, Avoid::CONNECTIONPIN_CENTRE); //ConnEnd srcPt42699400(Point(50700, 51075), 15); ConnEnd dstPt42699400(Point(50615, 51075), 8); new ConnRef(router, srcPt42699400, dstPt42699400, 42699400); ConnEnd srcPt94712625(Point(50710, 50550), 4); ConnEnd dstPt94712625(shapeRef478845150, Avoid::CONNECTIONPIN_CENTRE); //ConnEnd dstPt94712625(Point(50700, 51075), 15); new ConnRef(router, srcPt94712625, dstPt94712625, 94712625); ConnEnd srcPt92802970(Point(50990, 50450), 8); ConnEnd dstPt92802970(Point(51275, 50485), 1); new ConnRef(router, srcPt92802970, dstPt92802970, 92802970); ConnEnd srcPt716502036(Point(50710, 50500), 4); ConnEnd dstPt716502036(Point(51800, 50925), 15); new ConnRef(router, srcPt716502036, dstPt716502036, 716502036); router->processTransaction(); router->outputInstanceToSVG("test-junction01"); delete router; return 0; };
int main(void) { Router *router = new Router( PolyLineRouting | OrthogonalRouting); router->setRoutingParameter((RoutingParameter)0, 50); router->setRoutingParameter((RoutingParameter)1, 0); router->setRoutingParameter((RoutingParameter)2, 0); router->setRoutingParameter((RoutingParameter)3, 4000); router->setRoutingParameter((RoutingParameter)4, 0); router->setRoutingParameter((RoutingParameter)5, 100); router->setRoutingParameter((RoutingParameter)6, 0); router->setRoutingParameter((RoutingParameter)7, 4); router->setRoutingOption((RoutingOption)0, true); router->setRoutingOption((RoutingOption)1, true); router->setRoutingOption((RoutingOption)2, false); router->setRoutingOption((RoutingOption)3, false); Polygon poly41(4); poly41.ps[0] = Point(918.6758458220888, 441.0752314081785); poly41.ps[1] = Point(918.6758458220888, 503.0752314081785); poly41.ps[2] = Point(856.6758458220888, 503.0752314081785); poly41.ps[3] = Point(856.6758458220888, 441.0752314081785); new ShapeRef(router, poly41, 41); Polygon poly43(4); poly43.ps[0] = Point(710.6758458200889, 441.0752314081785); poly43.ps[1] = Point(710.6758458200889, 461.0752314081785); poly43.ps[2] = Point(678.6758458200889, 461.0752314081785); poly43.ps[3] = Point(678.6758458200889, 441.0752314081785); new ShapeRef(router, poly43, 43); Polygon poly44(4); poly44.ps[0] = Point(710.6758458200889, 483.0752314081785); poly44.ps[1] = Point(710.6758458200889, 503.0752314081785); poly44.ps[2] = Point(678.6758458200889, 503.0752314081785); poly44.ps[3] = Point(678.6758458200889, 483.0752314081785); new ShapeRef(router, poly44, 44); ConnRef *connRef149 = new ConnRef(router, 149); ConnEnd srcPt149(Point(709.6758458200889, 451.0752314081785), 8); connRef149->setSourceEndpoint(srcPt149); ConnEnd dstPt149(Point(887.6758458220888, 472.0752314081786), 15); connRef149->setDestEndpoint(dstPt149); connRef149->setRoutingType((ConnType)2); std::vector<Checkpoint> checkpoints149(1); checkpoints149[0] = Checkpoint(Point(732.6758458200889, 472.0752314081785), (ConnDirFlags) 15, (ConnDirFlags) 8); connRef149->setRoutingCheckpoints(checkpoints149); ConnRef *connRef150 = new ConnRef(router, 150); ConnEnd srcPt150(Point(709.6758458200889, 493.0752314081785), 8); connRef150->setSourceEndpoint(srcPt150); ConnEnd dstPt150(Point(887.6758458220888, 472.0752314081786), 15); connRef150->setDestEndpoint(dstPt150); connRef150->setRoutingType((ConnType)2); std::vector<Checkpoint> checkpoints150(1); checkpoints150[0] = Checkpoint(Point(732.6758458200889, 472.0752314081785), (ConnDirFlags) 15, (ConnDirFlags) 8); connRef150->setRoutingCheckpoints(checkpoints150); router->processTransaction(); router->outputDiagram("output/checkpoints03"); bool succeeded = true; Avoid::PolyLine route149 = connRef149->displayRoute(); Avoid::PolyLine route150 = connRef150->displayRoute(); if (route149.size() > 4 || route150.size() > 4) { // Five segments weren't merged into three. The segments in the shape // on right weren't shifted to align with the segments going through // the checkpoint. succeeded = false; } if (succeeded == true) { // The segments were merged by were not centred around the // checkpoint. double checkpointY = 472.0752314081785; if (fabs(route149.ps[route149.size() - 1].y - checkpointY) < 2) { succeeded = false; } if (fabs(route150.ps[route150.size() - 1].y - checkpointY) < 2) { succeeded = false; } } delete router; return (succeeded) ? 0 : 1; };
int main(void) { Router *router = new Router(OrthogonalRouting); router->setRoutingPenalty((PenaltyType)0, 50); router->setRoutingPenalty((PenaltyType)1, 0); router->setRoutingPenalty((PenaltyType)2, 0); router->setRoutingPenalty((PenaltyType)3, 4000); router->setRoutingPenalty((PenaltyType)4, 105); router->setRoutingParameter(idealNudgingDistance, 25); JunctionRef *junction478845150 = new JunctionRef(router, Point(50700, 51075)); Rectangle rect92712048(Point(51246, 50475), Point(51304, 50585)); new ShapeRef(router, rect92712048, 92712048); Rectangle rect23127921(Point(50365, 50766), Point(50485, 50834)); new ShapeRef(router, rect23127921, 23127921); Rectangle rect159957148(Point(51740, 50891), Point(51860, 50959)); new ShapeRef(router, rect159957148, 159957148); Rectangle rect1350214(Point(50375, 51015), Point(50625, 51135)); new ShapeRef(router, rect1350214, 1350214); Rectangle rect247197258(Point(50265, 51046), Point(50375, 51104)); new ShapeRef(router, rect247197258, 247197258); Rectangle rect281096654(Point(50700, 50390), Point(51000, 50610)); new ShapeRef(router, rect281096654, 281096654); ConnEnd srcPt342420237(Point(50425, 50800), 15); ConnEnd dstPt342420237(Point(50710, 50450), 4); new ConnRef(router, srcPt342420237, dstPt342420237, 342420237); ConnEnd srcPt352019675(Point(50990, 50500), 8); ConnEnd dstPt352019675(junction478845150); //ConnEnd dstPt352019675(Point(50700, 51075), 15); new ConnRef(router, srcPt352019675, dstPt352019675, 352019675); ConnEnd srcPt42699400(junction478845150); //ConnEnd srcPt42699400(Point(50700, 51075), 15); ConnEnd dstPt42699400(Point(50615, 51075), 8); new ConnRef(router, srcPt42699400, dstPt42699400, 42699400); ConnEnd srcPt94712625(Point(50710, 50550), 4); ConnEnd dstPt94712625(junction478845150); //ConnEnd dstPt94712625(Point(50700, 51075), 15); new ConnRef(router, srcPt94712625, dstPt94712625, 94712625); ConnEnd srcPt92802970(Point(50990, 50450), 8); ConnEnd dstPt92802970(Point(51275, 50485), 1); new ConnRef(router, srcPt92802970, dstPt92802970, 92802970); ConnEnd srcPt716502036(Point(50710, 50500), 4); ConnEnd dstPt716502036(Point(51800, 50925), 15); new ConnRef(router, srcPt716502036, dstPt716502036, 716502036); router->processTransaction(); router->outputInstanceToSVG("output/junction02-1"); router->moveJunction(junction478845150, 585, 0); router->processTransaction(); router->outputInstanceToSVG("output/junction02-2"); delete router; return 0; };