/* Test the method 'getBoxBoundary'*/ TEST_F(PositionVectorTest, test_method_getBoxBoundary) { Boundary bound = vectorPolygon->getBoxBoundary(); EXPECT_DOUBLE_EQ(bound.xmax(), 4); EXPECT_DOUBLE_EQ(bound.xmin(), 0); EXPECT_DOUBLE_EQ(bound.ymax(), 4); EXPECT_DOUBLE_EQ(bound.ymin(), 0); }
std::vector<GUIGlID> GUISUMOAbstractView::getObjectsAtPosition(Position pos, SUMOReal radius) { Boundary selection; selection.add(pos); selection.grow(radius); const std::vector<GUIGlID> ids = getObjectsInBoundary(selection); std::vector<GUIGlID> result; // Interpret results for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) { GUIGlID id = *it; GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(id); if (o == 0) { continue; } if (o->getGlID() == 0) { continue; } //std::cout << "point selection hit " << o->getMicrosimID() << "\n"; GUIGlObjectType type = o->getType(); if (type != 0) { result.push_back(id); } GUIGlObjectStorage::gIDStorage.unblockObject(id); } return result; }
// =========================================================================== // method definitions // =========================================================================== bool TraCIServerAPI_GUI::processGet(TraCIServer& server, tcpip::Storage& inputStorage, tcpip::Storage& outputStorage) { // variable & id int variable = inputStorage.readUnsignedByte(); std::string id = inputStorage.readString(); // check variable if (variable != ID_LIST && variable != VAR_VIEW_ZOOM && variable != VAR_VIEW_OFFSET && variable != VAR_VIEW_SCHEMA && variable != VAR_VIEW_BOUNDARY) { return server.writeErrorStatusCmd(CMD_GET_GUI_VARIABLE, "Get GUI Variable: unsupported variable specified", outputStorage); } // begin response building tcpip::Storage tempMsg; // response-code, variableID, objectID tempMsg.writeUnsignedByte(RESPONSE_GET_GUI_VARIABLE); tempMsg.writeUnsignedByte(variable); tempMsg.writeString(id); // process request if (variable == ID_LIST) { std::vector<std::string> ids = getMainWindow()->getViewIDs(); tempMsg.writeUnsignedByte(TYPE_STRINGLIST); tempMsg.writeStringList(ids); } else { GUISUMOAbstractView* v = getNamedView(id); if (v == 0) { return server.writeErrorStatusCmd(CMD_GET_GUI_VARIABLE, "View '" + id + "' is not known", outputStorage); } switch (variable) { case VAR_VIEW_ZOOM: tempMsg.writeUnsignedByte(TYPE_DOUBLE); tempMsg.writeDouble(v->getChanger().getZoom()); break; case VAR_VIEW_OFFSET: tempMsg.writeUnsignedByte(POSITION_2D); tempMsg.writeDouble(v->getChanger().getXPos()); tempMsg.writeDouble(v->getChanger().getYPos()); break; case VAR_VIEW_SCHEMA: { FXComboBox& c = v->getColoringSchemesCombo(); tempMsg.writeUnsignedByte(TYPE_STRING); tempMsg.writeString((std::string)c.getItem(c.getCurrentItem()).text()); break; } case VAR_VIEW_BOUNDARY: { tempMsg.writeUnsignedByte(TYPE_BOUNDINGBOX); Boundary b = v->getVisibleBoundary(); tempMsg.writeDouble(b.xmin()); tempMsg.writeDouble(b.ymin()); tempMsg.writeDouble(b.xmax()); tempMsg.writeDouble(b.ymax()); break; } default: break; } } server.writeStatusCmd(CMD_GET_GUI_VARIABLE, RTYPE_OK, "", outputStorage); server.writeResponseWithLength(outputStorage, tempMsg); return true; }
void WaterPhysicsSystem::renderWireframe() { for (unsigned int i = 0; i != edges.size(); i++) { Edge* edge = edges[i]; glBegin(GL_LINES); { glColor3f(1,1,1); glVertex2f(edge->aPosition().x, edge->aPosition().y); glVertex2f(edge->bPosition().x, edge->bPosition().y); } glEnd(); glBegin(GL_POINTS); { glColor3f(1,0,0); glVertex2f(edge->aPosition().x, edge->aPosition().y); glVertex2f(edge->bPosition().x, edge->bPosition().y); } glEnd(); } glColor3f(0,0,1); for (unsigned int i = 0; i != volumes.size(); i++) { Volume* volume = volumes[i]; Vec2f center; center = volume->getLeft()->aPosition(); center += volume->getLeft()->bPosition(); center += volume->getRight()->aPosition(); center += volume->getRight()->bPosition(); center /= 4.0f; glBegin(GL_LINES); { glVertex2f(volume->getLeft()->aPosition().x, volume->getLeft()->aPosition().y); glVertex2f(center.x, center.y); glVertex2f(volume->getRight()->aPosition().x, volume->getRight()->aPosition().y); glVertex2f(center.x, center.y); glVertex2f(volume->getRight()->bPosition().x, volume->getRight()->bPosition().y); glVertex2f(center.x, center.y); glVertex2f(volume->getLeft()->bPosition().x, volume->getLeft()->bPosition().y); glVertex2f(center.x, center.y); } glEnd(); } glBegin(GL_LINES); glColor3f(1,1,0.5f); // for (Boundary* boundary = boundaries.front(); boundary; boundary = boundary->getNextObject()) for (unsigned int i = 0; i != boundaries.size(); i++) { Boundary* boundary = boundaries[i]; if (boundary) { Vec2f p = boundary->getLeftPosition(); glVertex2f(p.x, p.y); p = boundary->getRightPosition(); glVertex2f(p.x, p.y); } } glEnd(); }
Boundary GUIEdge::getBoundary() const { Boundary ret; if (getPurpose() != MSEdge::EDGEFUNCTION_DISTRICT) { for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { ret.add((*i)->getShape().getBoxBoundary()); } } else { // take the starting coordinates of all follower edges and the endpoints // of all successor edges for (MSEdgeVector::const_iterator it = mySuccessors.begin(); it != mySuccessors.end(); ++it) { const std::vector<MSLane*>& lanes = (*it)->getLanes(); for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) { ret.add((*it_lane)->getShape().front()); } } for (MSEdgeVector::const_iterator it = myPredecessors.begin(); it != myPredecessors.end(); ++it) { const std::vector<MSLane*>& lanes = (*it)->getLanes(); for (std::vector<MSLane*>::const_iterator it_lane = lanes.begin(); it_lane != lanes.end(); ++it_lane) { ret.add((*it_lane)->getShape().back()); } } } ret.grow(10); return ret; }
/* Test the method 'around'*/ TEST(Boundary, test_method_around) { Boundary *bound = new Boundary(1,2,3,6); EXPECT_TRUE(bound->around(Position(2,4))); EXPECT_FALSE(bound->around(Position(0,4))); EXPECT_FALSE(bound->around(Position(2,7))); EXPECT_TRUE(bound->around(Position(0,7),2)); }
void NIVissimNodeDef_Edges::searchAndSetConnections() { std::vector<int> connections; std::vector<int> edges; Boundary boundary; for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) { NIVissimNodeParticipatingEdge* edge = *i; NIVissimConnection* c = NIVissimConnection::dictionary(edge->getID()); NIVissimEdge* e = NIVissimEdge::dictionary(edge->getID()); if (c != 0) { connections.push_back(edge->getID()); boundary.add(c->getFromGeomPosition()); boundary.add(c->getToGeomPosition()); c->setNodeCluster(myID); } if (e != 0) { edges.push_back(edge->getID()); boundary.add(e->getGeomPosition(edge->getFromPos())); boundary.add(e->getGeomPosition(edge->getToPos())); } } NIVissimConnectionCluster* c = new NIVissimConnectionCluster(connections, boundary, myID, edges); for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) { NIVissimEdge* edge = NIVissimEdge::dictionary(*j); edge->myConnectionClusters.push_back(c); } }
Boundary GUIPolygon::getCenteringBoundary() const { Boundary b; b.add(myShape.getBoxBoundary()); b.grow(10); return b; }
bool PCPolyContainer::insert(const std::string& id, Polygon* poly, int layer, bool ignorePruning) { // check whether the polygon lies within the wished area // - if such an area was given if (myDoPrune && !ignorePruning) { Boundary b = poly->getShape().getBoxBoundary(); if (!b.partialWithin(myPruningBoundary)) { delete poly; return false; } } // check whether the polygon was named to be a removed one if (find(myRemoveByNames.begin(), myRemoveByNames.end(), id) != myRemoveByNames.end()) { delete poly; return false; } // PolyCont::iterator i = myPolyCont.find(id); if (i != myPolyCont.end()) { WRITE_ERROR("Polygon '" + id + "' could not be added."); delete poly; return false; } myPolyCont[id] = poly; myPolyLayerMap[poly] = layer; return true; }
/* Test the method 'overlapsWith'*/ TEST(Boundary, test_method_overlapsWith) { Boundary *bound = new Boundary(1,2,3,6); EXPECT_FALSE(bound->overlapsWith(Boundary(10,17,13,16))); EXPECT_TRUE(bound->overlapsWith(Boundary(-1,-7,2,4))); EXPECT_TRUE(bound->overlapsWith(Boundary(1,2,3,6))); EXPECT_TRUE(bound->overlapsWith(Boundary(4,2,5,7),1)); }
/* Test the method 'crosses'*/ TEST(Boundary, test_method_crosses) { Boundary *bound = new Boundary(1,2,3,6); EXPECT_TRUE(bound->crosses(Position(3,2),Position(4,2))); EXPECT_TRUE(bound->crosses(Position(2,1),Position(0,3))); EXPECT_TRUE(bound->crosses(Position(1,2),Position(3,6))); EXPECT_FALSE(bound->crosses(Position(0,0),Position(0,8))); }
bool save_bc(hid_t parent_group_id, Mesh *mesh) { herr_t status; // create main group hid_t group_id = H5Gcreate(parent_group_id, "bc", 0); // count hid_t dataspace_id = H5Screate(H5S_SCALAR); hid_t attr_count = H5Acreate(group_id, "count", H5T_NATIVE_UINT32, dataspace_id, H5P_DEFAULT); uint count = mesh->boundaries.count(); status = H5Awrite(attr_count, H5T_NATIVE_UINT32, &count); H5Aclose(attr_count); H5Sclose(dataspace_id); /// /// JudyArray<Boundary *> tri, quad; for (int i = 0; i < count; i++) { Boundary *bnd = mesh->boundaries[i]; switch (bnd->get_mode()) { case HERMES_MODE_TRIANGLE: tri.add(bnd); break; case HERMES_MODE_QUAD: quad.add(bnd); break; } } save_tri_bc(group_id, tri); save_quad_bc(group_id, quad); status = H5Gclose(group_id); // close the group }
void BinaryFormatter::writeAttr(std::ostream& into, const SumoXMLAttr attr, const Boundary& val) { BinaryFormatter::writeAttrHeader(into, attr, BF_BOUNDARY); FileHelpers::writeFloat(into, val.xmin()); FileHelpers::writeFloat(into, val.ymin()); FileHelpers::writeFloat(into, val.xmax()); FileHelpers::writeFloat(into, val.ymax()); }
void fillGraph_(Graph & graph, Cell & c, double slowness){ std::vector< Node * > ni(c.nodes()); for (Index i(0); i < c.boundaryCount(); i++){ Boundary *b = c.boundary(i); if (b){ for (auto & n : b->secondaryNodes()){ ni.push_back(n); } } else { log(Critical, "No boundary found."); } } for (auto & n : c.secondaryNodes()){ ni.push_back(n); } for (Index j = 0; j < ni.size()-1; j ++) { for (Index k = j + 1; k < ni.size(); k ++) { fillGraph_(graph, *ni[j], *ni[k], slowness, c.id()); } } }
/* Test the method 'partialWithin'*/ TEST(Boundary, test_method_partialWithin) { Boundary *bound = new Boundary(1,2,3,6); EXPECT_TRUE(bound->partialWithin(Boundary(1,2,1,2))); EXPECT_FALSE(bound->partialWithin(Boundary(10,17,13,16))); EXPECT_TRUE(bound->partialWithin(Boundary(1,2,3,6))); EXPECT_TRUE(bound->partialWithin(Boundary(4,2,5,7),1)); }
Boundary GUILane::getCenteringBoundary() const { Boundary b; b.add(myShape[0]); b.add(myShape[-1]); b.grow(20); return b; }
Position GUISUMOAbstractView::getPositionInformation() const { Boundary bound = myChanger->getViewport(); SUMOReal x = bound.xmin() + bound.getWidth() * myWindowCursorPositionX / getWidth(); // cursor origin is in the top-left corner SUMOReal y = bound.ymin() + bound.getHeight() * (getHeight() - myWindowCursorPositionY) / getHeight(); return Position(x, y); }
Boundary GUILaneWrapper::getCenteringBoundary() const throw() { Boundary b; b.add(myShape[0]); b.add(myShape[-1]); b.grow(20); return b; }
void NIVissimConnection::computeBounding() { Boundary *bound = new Boundary(); bound->add(myFromDef.getGeomPosition()); bound->add(myToDef.getGeomPosition()); assert(myBoundary==0); myBoundary = bound; }
Boundary GUIEdge::getCenteringBoundary() const { Boundary b = getBoundary(); // ensure that vehicles and persons on the side are drawn even if the edge // is outside the view b.grow(10); return b; }
Boundary GUIPointOfInterest::getCenteringBoundary() const { Boundary b; b.add(x(), y()); b.growWidth(myHalfImgWidth); b.growHeight(myHalfImgHeight); return b; }
double RD28Builder::integral(const Boundary& boundary) { CHECK( feq(boundary.l(0), 2.0) && feq(boundary.u(0), 1.0) && boundary.l(1) == -inf && feq(boundary.u(1), -1.0), "Unsupported boundary."); return -1.0; }
Boundary GUIPerson::getCenteringBoundary() const { Boundary b; // ensure that the vehicle is drawn, otherwise myPositionInVehicle will not be updated b.add(getPosition()); b.grow(MAX2(getVehicleType().getWidth(), getVehicleType().getLength())); return b; }
Boundary PositionVector::getBoxBoundary() const { Boundary ret; for (const_iterator i = begin(); i != end(); i++) { ret.add(*i); } return ret; }
Boundary GUIParkingArea::getCenteringBoundary() const { Boundary b = myShape.getBoxBoundary(); for (std::map<unsigned int, LotSpaceDefinition >::const_iterator i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) { b.add((*i).second.myPosition); } b.grow(20); return b; }
Boundary GUIEdge::getBoundary() const { Boundary ret; for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { ret.add((*i)->getShape().getBoxBoundary()); } ret.grow(10); return ret; }
void NBHeightMapper::addTriangle(PositionVector corners) { Triangle* triangle = new Triangle(corners); myTriangles.push_back(triangle); Boundary b = corners.getBoxBoundary(); const float cmin[2] = {(float) b.xmin(), (float) b.ymin()}; const float cmax[2] = {(float) b.xmax(), (float) b.ymax()}; myRTree.Insert(cmin, cmax, triangle); }
double G6Builder::integral(const Boundary& boundary) { CHECK( feq0(boundary.l(0)) && feq(boundary.u(0), 1.0) && feq0(boundary.l(1)) && feq(boundary.u(1), 1.0), InvalidValueError("Only unit square solution available.")); return ( exp(dC[0] * dx0[0]) - 1 ) / dC[0] * ( exp(dC[1] * dx0[1]) - 1 ) / dC[1]; }
// =========================================================================== // method definitions // =========================================================================== GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger( GUISUMOAbstractView& callBack, const Boundary& viewPort) : GUIPerspectiveChanger(callBack, viewPort), myOrigWidth(viewPort.getWidth()), myOrigHeight(viewPort.getHeight()), myRotation(0), myMouseButtonState(MOUSEBTN_NONE), myMoveOnClick(false), myDragDelay(0) {}
Boundary * findCommonBoundary(const Cell & c1, const Cell & c2){ for (Index i = 0; i < c1.boundaryCount(); i ++){ Boundary * b = findBoundary(c1.boundaryNodes(i)); if ((b->leftCell() == &c1 && b->rightCell() == &c2) || (b->leftCell() == &c2 && b->rightCell() == &c1)){ return b; } } return NULL; }