bool OneOfMatches(const char* host, const char* ip, const char* hostlist) { std::stringstream hl(hostlist); std::string xhost; while (hl >> xhost) { if (match(host,xhost.c_str()) || match(ip,xhost.c_str(),true)) { return true; } } return false; }
bool OneOfMatches(const char* host, const char* ip, const std::string& hostlist) { std::stringstream hl(hostlist); std::string xhost; while (hl >> xhost) { if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map)) { return true; } } return false; }
void mm2_close(file_handle &file){ hold_lock hl(mmap_lock); bool changed = false; do{ changed = false; for(auto i = mmappings->begin(); i != mmappings->end(); ++i){ if(i->second.file.filedata == file.filedata){ mm2_closemap(i->first); changed = true; break; } } }while(changed); }
void ImageViewer_ex2::adjustImage(float w, float h) { Vector3f hl(3,1); hl = pinmanager->getHorizonLine().transpose(); hl = hl/ hl(2); MatrixXf temp(3,3); temp << 1, 0, 0, 0, 1, 0, hl(0), hl(1), hl(2); Hp = temp; H = Hp; Hi = H.inverse(); QSize imgSize(this->width(), this->height()); QVector<QPoint> areaRender; areaRender << QPoint(0,0) << QPoint(0, imgSize.height()) << QPoint(imgSize.width(), imgSize.height()) << QPoint(imgSize.width(), 0); showResult(imgSize, areaRender); imageBase = imageResult; pinmanager->setType(pinmanager->TYPE_FOUR); if(isDebug){ prepareDebug(); } }
void shm_close(uint64_t id){ hold_lock hl(shm_lock); shm_space *space = (*spaces)[id]; bool cont = true; while(cont){ for(auto i = mappings->begin(); i != mappings->end(); ++i){ if(i->second->space == space) { shm_close_map(i->first); break; } } cont = false; } for(auto i = space->pages.begin(); i != space->pages.end(); ++i){ physical_free(i->second); } delete (*spaces)[id]; spaces->erase(id); }
uint64_t mm2_mmap(char *ptr, file_handle &file, bt_filesize_t offset, size_t size){ dbgpf("MM2: Mapping %i bytes from file offset %i at %p.\n", (int)size, (int)offset, (void*)ptr); mmapping m; m.addr = ptr; m.file = file; m.offset = offset; m.size = size; m.pid = proc_current_pid; size_t asize = 0; if((uint32_t)ptr % MM2_Page_Size){ m.page_addr = (char*)(((uint32_t)ptr + MM2_Page_Size) & MM2_Address_Mask); m.pre = ((uint32_t)m.page_addr - (uint32_t)ptr); asize = size - m.pre; }else{ m.pre = 0; m.page_addr = ptr; asize = size; } m.page_offset = offset + m.pre; m.pages = asize / MM2_Page_Size; m.post = asize - (m.pages * MM2_Page_Size); //dbgpf("MM2: Mapping: pre: %i post: %i page_offset: %i page_addr: %p pages: %i. asize: %i\n", (int)m.pre, (int)m.post, (int)m.page_offset, (void*)m.page_addr, (int)m.pages, (int)asize); do_mapping(m); uint64_t id = ++counter; { hold_lock hl(mmap_lock); (*mmappings)[id] = m; } if(size > MM2_Page_Size){ if((uint32_t)ptr < MM2_Kernel_Boundary){ kernel_pagedir->add_region(m.page_addr, m.pages * MM2_Page_Size, &mmap_read, id); }else{ current_pagedir->add_region(m.page_addr, m.pages * MM2_Page_Size, &mmap_read, id); } } return id; }
QxListPopup::QxListPopup(QxControl* combo, int align) : combo_(combo), align_(align), itemList_(new ItemList), itemSeparators_(new ItemList), maxItemWidth_(0) { setWindowFlags(Qt::ToolTip); setAttribute(Qt::WA_ShowWithoutActivating); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_OpaquePaintEvent); setFocusPolicy(Qt::NoFocus); itemLayout_ = new QVBoxLayout; itemLayout_->setSpacing(0); itemLayout_->setMargin(0); #ifdef Q_WS_X11 { QGridLayout* grid = new QGridLayout; grid->setSpacing(0); grid->setMargin(0); grid->addWidget(hl(), 0, 0, 1, 2); grid->addWidget(vl(), 1, 0); grid->addWidget(vl(), 1, 2); grid->addLayout(itemLayout_, 1, 1); setLayout(grid); } #endif #ifdef Q_WS_MAC setLayout(itemLayout_); #endif itemList_->setObserver(this); qApp->installEventFilter(this); // qApp->installEventFilter(combo->window()); }
int main(int argc, char ** argv){ int opt, port; char *end; bool pers=false; while((opt=getopt(argc,argv,"p:nhs"))!=-1){ switch(opt){ case 'p': port=strtol(optarg,&end,10); if(port==0 || port<0 || port>65535){ fprintf(stderr,"wrong port number. enter a value between 1 and 65535!\n"); printHelp(argv); exit(-1); } break; case 'n': pers=false; break; case 's': pers=true; break; case 'h': printHelp(argv); exit(-1); default: printHelp(argv); exit(-1); } } if(optind<argc || argc<4){ printHelp(argv); exit(-1); } HTTPServer<HTTPProvider> hl(port,SOCK_STREAM,pers); hl.start(); return 0; }
static void shm_pf_handler(uint64_t id, void *addr){ //dbgpf("MM2: SHM mapping %i PF at %p.\n", (int)id, addr); hold_lock hl(shm_lock); if(!mappings->has_key(id)) panic("(MM2) Invalid mapping!"); shm_mapping *mapping = (*mappings)[id]; uint32_t space_addr = ((uint32_t)addr - (uint32_t)mapping->addr) + mapping->offset; uint32_t page_addr = space_addr & MM2_Address_Mask; shm_space *space = mapping->space; physical_page *page = (physical_page*)0xBADF00D; if(space->pages.has_key(page_addr)){ page = space->pages[page_addr]; }else{ page = physical_alloc(); space->pages[page_addr] = page; } void *addr_page = (void*)((uint32_t)addr & MM2_Address_Mask); //dbgpf("MM2: Mapping shared page %p from SHM mapping %i at address %p.\n", (void*)page->address(), (int)id, addr_page); uint32_t pageflags = MM2_PageFlags::Present | MM2_PageFlags::Usermode; if((space->owner == proc_current_pid || !(space->flags & btos_api::bt_shm_flags::ReadOnly)) && !(mapping->flags & btos_api::bt_shm_flags::ReadOnly)){ pageflags |= MM2_PageFlags::Writable; } current_pagedir->map_page_at(addr_page, page, MM2_PageFlags::Present | MM2_PageFlags::Writable | MM2_PageFlags::Usermode); }
size_t operator()(const std::pair<L, R> &n) const { hash<L> hl; return hash_combine(hl(n.first), n.second); }
// Wait until the next synchronous GC, a concurrent full gc request, // or a timeout, whichever is earlier. void ConcurrentMarkSweepThread::wait_on_cms_lock_for_scavenge(long t_millis) { // Wait time in millis or 0 value representing infinite wait for a scavenge assert(t_millis >= 0, "Wait time for scavenge should be 0 or positive"); GenCollectedHeap* gch = GenCollectedHeap::heap(); double start_time_secs = os::elapsedTime(); double end_time_secs = start_time_secs + (t_millis / ((double) MILLIUNITS)); // Total collections count before waiting loop unsigned int before_count; { MutexLockerEx hl(Heap_lock, Mutex::_no_safepoint_check_flag); before_count = gch->total_collections(); } unsigned int loop_count = 0; while(!_should_terminate) { double now_time = os::elapsedTime(); long wait_time_millis; if(t_millis != 0) { // New wait limit wait_time_millis = (long) ((end_time_secs - now_time) * MILLIUNITS); if(wait_time_millis <= 0) { // Wait time is over break; } } else { // No wait limit, wait if necessary forever wait_time_millis = 0; } // Wait until the next event or the remaining timeout { MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); if (_should_terminate || _collector->_full_gc_requested) { return; } set_CMS_flag(CMS_cms_wants_token); // to provoke notifies assert(t_millis == 0 || wait_time_millis > 0, "Sanity"); CGC_lock->wait(Mutex::_no_safepoint_check_flag, wait_time_millis); clear_CMS_flag(CMS_cms_wants_token); assert(!CMS_flag_is_set(CMS_cms_has_token | CMS_cms_wants_token), "Should not be set"); } // Extra wait time check before entering the heap lock to get the collection count if(t_millis != 0 && os::elapsedTime() >= end_time_secs) { // Wait time is over break; } // Total collections count after the event unsigned int after_count; { MutexLockerEx hl(Heap_lock, Mutex::_no_safepoint_check_flag); after_count = gch->total_collections(); } if(before_count != after_count) { // There was a collection - success break; } // Too many loops warning if(++loop_count == 0) { warning("wait_on_cms_lock_for_scavenge() has looped %u times", loop_count - 1); } } }
inline void loop::read(poller::event &e) { read( *( hl() [ poller::from(e) ] ), e); }
void MythRenderOpenGL2::DrawRoundRectPriv(const QRect &area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha) { int lineWidth = linePen.width(); int halfline = lineWidth / 2; int rad = cornerRadius - halfline; if ((area.width() / 2) < rad) rad = area.width() / 2; if ((area.height() / 2) < rad) rad = area.height() / 2; int dia = rad * 2; QRect r(area.left() + halfline, area.top() + halfline, area.width() - (halfline * 2), area.height() - (halfline * 2)); QRect tl(r.left(), r.top(), rad, rad); QRect tr(r.left() + r.width() - rad, r.top(), rad, rad); QRect bl(r.left(), r.top() + r.height() - rad, rad, rad); QRect br(r.left() + r.width() - rad, r.top() + r.height() - rad, rad, rad); SetBlend(true); DisableTextures(); m_glEnableVertexAttribArray(VERTEX_INDEX); if (fillBrush.style() != Qt::NoBrush) { // Get the shaders int elip = m_shaders[kShaderCircle]; int fill = m_shaders[kShaderSimple]; // Set the fill color m_glVertexAttrib4f(COLOR_INDEX, fillBrush.color().red() / 255.0, fillBrush.color().green() / 255.0, fillBrush.color().blue() / 255.0, (fillBrush.color().alpha() / 255.0) * (alpha / 255.0)); // Set the radius m_parameters[0][2] = rad; m_parameters[0][3] = rad - 1.0; // Enable the Circle shader SetShaderParams(elip, &m_projection[0][0], "u_projection"); // Draw the top left segment m_parameters[0][0] = tl.left() + rad; m_parameters[0][1] = tl.top() + rad; SetShaderParams(elip, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, tl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the top right segment m_parameters[0][0] = tr.left(); m_parameters[0][1] = tr.top() + rad; SetShaderParams(elip, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, tr); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the bottom left segment m_parameters[0][0] = bl.left() + rad; m_parameters[0][1] = bl.top(); SetShaderParams(elip, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, bl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the bottom right segment m_parameters[0][0] = br.left(); m_parameters[0][1] = br.top(); SetShaderParams(elip, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, br); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Fill the remaining areas QRect main(r.left() + rad, r.top(), r.width() - dia, r.height()); QRect left(r.left(), r.top() + rad, rad, r.height() - dia); QRect right(r.left() + r.width() - rad, r.top() + rad, rad, r.height() - dia); EnableShaderObject(fill); SetShaderParams(fill, &m_projection[0][0], "u_projection"); GetCachedVBO(GL_TRIANGLE_STRIP, main); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); GetCachedVBO(GL_TRIANGLE_STRIP, left); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); GetCachedVBO(GL_TRIANGLE_STRIP, right); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); m_glBindBuffer(GL_ARRAY_BUFFER, 0); } if (linePen.style() != Qt::NoPen) { // Get the shaders int edge = m_shaders[kShaderCircleEdge]; int vline = m_shaders[kShaderVertLine]; int hline = m_shaders[kShaderHorizLine]; // Set the line color m_glVertexAttrib4f(COLOR_INDEX, linePen.color().red() / 255.0, linePen.color().green() / 255.0, linePen.color().blue() / 255.0, (linePen.color().alpha() / 255.0) * (alpha / 255.0)); // Set the radius and width m_parameters[0][2] = rad - lineWidth / 2.0; m_parameters[0][3] = lineWidth / 2.0; // Enable the edge shader SetShaderParams(edge, &m_projection[0][0], "u_projection"); // Draw the top left edge segment m_parameters[0][0] = tl.left() + rad; m_parameters[0][1] = tl.top() + rad; SetShaderParams(edge, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, tl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the top right edge segment m_parameters[0][0] = tr.left(); m_parameters[0][1] = tr.top() + rad; SetShaderParams(edge, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, tr); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the bottom left edge segment m_parameters[0][0] = bl.left() + rad; m_parameters[0][1] = bl.top(); SetShaderParams(edge, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, bl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the bottom right edge segment m_parameters[0][0] = br.left(); m_parameters[0][1] = br.top(); SetShaderParams(edge, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, br); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Vertical lines SetShaderParams(vline, &m_projection[0][0], "u_projection"); m_parameters[0][1] = lineWidth / 2.0; QRect vl(r.left(), r.top() + rad, lineWidth, r.height() - dia); // Draw the left line segment m_parameters[0][0] = vl.left() + lineWidth; SetShaderParams(vline, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, vl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the right line segment vl.translate(r.width() - lineWidth, 0); m_parameters[0][0] = vl.left(); SetShaderParams(vline, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, vl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Horizontal lines SetShaderParams(hline, &m_projection[0][0], "u_projection"); QRect hl(r.left() + rad, r.top(), r.width() - dia, lineWidth); // Draw the top line segment m_parameters[0][0] = hl.top() + lineWidth; SetShaderParams(hline, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, hl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw the bottom line segment hl.translate(0, r.height() - lineWidth); m_parameters[0][0] = hl.top(); SetShaderParams(hline, &m_parameters[0][0], "u_parameters"); GetCachedVBO(GL_TRIANGLE_STRIP, hl); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); m_glBindBuffer(GL_ARRAY_BUFFER, 0); } m_glDisableVertexAttribArray(VERTEX_INDEX); }
void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const { osg::State & state = *renderInfo.getState(); unsigned int contextID = state.getContextID(); // ** save the previous modelview matrix osg::ref_ptr<osg::RefMatrix> previous(new osg::RefMatrix(state.getModelViewMatrix())); // ** get the modelview for this context osg::ref_ptr<osg::RefMatrix> modelview(new osg::RefMatrix(_autoTransformCache[contextID]._matrix)); // ** mult previous by the modelview for this context modelview->postMult(*previous.get()); // ** apply this new modelview matrix state.applyModelViewMatrix(modelview.get()); osg::GLBeginEndAdapter& gl = (state.getGLBeginEndAdapter()); if (_drawMode & BOUNDINGBOX) { if (_textBB.valid()) { osg::Vec3 c000(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMax())); osg::Vec3 c100(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMax())); osg::Vec3 c110(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMax())); osg::Vec3 c010(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMax())); osg::Vec3 c001(osg::Vec3(_textBB.xMin(),_textBB.yMin(),_textBB.zMin())); osg::Vec3 c101(osg::Vec3(_textBB.xMax(),_textBB.yMin(),_textBB.zMin())); osg::Vec3 c111(osg::Vec3(_textBB.xMax(),_textBB.yMax(),_textBB.zMin())); osg::Vec3 c011(osg::Vec3(_textBB.xMin(),_textBB.yMax(),_textBB.zMin())); gl.Begin(GL_LINE_LOOP); gl.Vertex3fv(c000.ptr()); gl.Vertex3fv(c100.ptr()); gl.Vertex3fv(c110.ptr()); gl.Vertex3fv(c010.ptr()); gl.End(); gl.Begin(GL_LINE_LOOP); gl.Vertex3fv(c001.ptr()); gl.Vertex3fv(c011.ptr()); gl.Vertex3fv(c111.ptr()); gl.Vertex3fv(c101.ptr()); gl.End(); gl.Begin(GL_LINES); gl.Vertex3fv(c000.ptr()); gl.Vertex3fv(c001.ptr()); gl.Vertex3fv(c100.ptr()); gl.Vertex3fv(c101.ptr()); gl.Vertex3fv(c110.ptr()); gl.Vertex3fv(c111.ptr()); gl.Vertex3fv(c010.ptr()); gl.Vertex3fv(c011.ptr()); gl.End(); } } if (_drawMode & ALIGNMENT) { float cursorsize = _characterHeight*0.5f; osg::Vec3 hl(osg::Vec3(_offset.x()-cursorsize,_offset.y(),_offset.z())); osg::Vec3 hr(osg::Vec3(_offset.x()+cursorsize,_offset.y(),_offset.z())); osg::Vec3 vt(osg::Vec3(_offset.x(),_offset.y()-cursorsize,_offset.z())); osg::Vec3 vb(osg::Vec3(_offset.x(),_offset.y()+cursorsize,_offset.z())); gl.Begin(GL_LINES); gl.Vertex3fv(hl.ptr()); gl.Vertex3fv(hr.ptr()); gl.Vertex3fv(vt.ptr()); gl.Vertex3fv(vb.ptr()); gl.End(); } if (_drawMode & TEXT) { renderInfo.getState()->disableAllVertexArrays(); #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) glPushAttrib(GL_TRANSFORM_BIT); glEnable(GL_RESCALE_NORMAL); #endif switch(_renderMode) { case PER_FACE: renderPerFace(*renderInfo.getState()); break; case PER_GLYPH: default: renderPerGlyph(*renderInfo.getState()); break; } #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE) glPopAttrib(); #endif } // restore the previous modelview matrix state.applyModelViewMatrix(previous.get()); }
void HeapInfoDCmd::execute(DCmdSource source, TRAPS) { MutexLocker hl(Heap_lock); Universe::heap()->print_on(output()); }
float BoundingTree<BoxType>::compute_signed_distance(const CGLA::Vec3f& p, float minmax) const { int N=100; vector<HE<Node> > Q(N); Q[0] = HE<Node>(p,root); HE<Node> *Q_beg = &Q[0]; int Q_end = 1; int pushes = 1; while(const IntNode* n = dynamic_cast<const IntNode*>(Q[0].get_node())) { float q0_max= Q[0].get_sq_dist_max(); //float q0_min= Q[0].get_sq_dist_min(); pop_heap(Q_beg, Q_beg + Q_end); --Q_end; HE<Node> hl(p,n->get_left()); if(hl.get_sq_dist_min() < (minmax + DIST_THRESH)) { if(hl.get_sq_dist_max() < minmax) minmax = hl.get_sq_dist_max(); Q[Q_end++] = hl; push_heap(Q_beg, Q_beg + Q_end); if(Q_end == N) { Q.resize(N=2*N); Q_beg = &Q[0]; } ++pushes; } HE<Node> hr(p,n->get_right()); if(hr.get_sq_dist_min() < (minmax + DIST_THRESH)) { if(hr.get_sq_dist_max() < minmax) minmax = hr.get_sq_dist_max(); Q[Q_end++] = hr; push_heap(Q_beg, Q_beg + Q_end); if(Q_end == N) { Q.resize(N=2*N); Q_beg = &Q[0]; } ++pushes; } // if((hr.get_sq_dist_min() > (q0_max + DIST_THRESH)) && // (hl.get_sq_dist_min() > (q0_max + DIST_THRESH)) ) // { // cout.precision(4); // cout << q0_min << " " << q0_max << endl; // cout << hl.get_sq_dist_min() << endl; // cout << hr.get_sq_dist_min() << endl; // cout << typeid(*n).name() << endl; // if(const LeafNode* ll =dynamic_cast<const LeafNode*>(hl.get_node())) // { // ll->get_tri().print(); // cout << sqr_length(p-ll->get_tri().get_v0()) << endl; // cout << sqr_length(p-ll->get_tri().get_v1()) << endl; // cout << sqr_length(p-ll->get_tri().get_v2()) << endl; // float d=FLT_MAX, s; // ll->get_tri().signed_distance(p,d,s); // cout << "Dist " << d << endl; // } // if(const LeafNode* lr =dynamic_cast<const LeafNode*>(hr.get_node())) // { // lr->get_tri().print(); // cout << sqr_length(p-lr->get_tri().get_v0()) << endl; // cout << sqr_length(p-lr->get_tri().get_v1()) << endl; // cout << sqr_length(p-lr->get_tri().get_v2()) << endl; // float d=FLT_MAX, s; // lr->get_tri().signed_distance(p,d,s); // cout << "Dist " << d << endl; // } // cout << "P=" << p<< endl; // } assert((hr.get_sq_dist_min() < (q0_max + DIST_THRESH)) || (hl.get_sq_dist_min() < (q0_max + DIST_THRESH)) ); assert(Q_end > 0); assert(Q_end <=N); } return Q[0].get_dist(); }
void FlowDirectionHandler::Pick(float x,float y ) { osgUtil::LineSegmentIntersector::Intersections intersection; //x , y 坐标值,intersection存放与法线相交的节点以及相交的节点路径等相关信息的列表 if (mViewer->computeIntersections(x,y,intersection))//使用computeIntersections计算当前场景中单击到了那些模型,结果存放在结果集内 { //使用迭代器取出这些模型,取出的结果是一个NodePath类对象,遍历该NodePath对象可以找到是否单击到了目标节点 for (osgUtil::LineSegmentIntersector::Intersections::iterator hiter=intersection.begin();hiter!=intersection.end();++hiter) { std::cout<<"scan the computeIntersections"<<std::endl; std::cout<<intersection.size(); if (!hiter->nodePath.empty()) { const osg::NodePath& np = hiter->nodePath; for (int i = np.size()-1;i>=0;--i) { osg::Node* nd = dynamic_cast<osg::Node*>(np[i]); if (nd) { if (nd->getName().find("ysgline_new") == 0) { osg::Geode* tmp = dynamic_cast<osg::Geode*>(nd); if(tmp) { osg::Vec4f color,colorEnd; osg::Geometry* tmpGeom = dynamic_cast<osg::Geometry*>(tmp->getDrawable(0)); if(tmpGeom) { osg::Vec4Array* tmpColorArray = dynamic_cast<osg::Vec4Array*>(tmpGeom->getColorArray()); if(tmpColorArray) { COLORREF cref = (*ppFlowDlg)->mColorPicker.GetColor(); BYTE r = GetRValue(cref); BYTE g = GetGValue(cref); BYTE b = GetBValue(cref); color.set(r/255,g/255,b/255,1); osg::Vec4Array::iterator iter = tmpColorArray->begin(); for(iter; iter!=tmpColorArray->end(); iter++) { iter->set(r/255,g/255,b/255,0.5); } } } DBConnection reader; makeSql ms; reader.ConnectToDB("localhost","5432","HRBPipe","postgres","123456"); string sql = ms.trackPipeSql(nd->getName()); PGresult* res = reader.ExecSQL(const_cast<char*>(sql.c_str())); int field_num=PQnfields(res); int tuple_num=PQntuples(res); float* fbzms = new float[tuple_num]; // { CString cs; cs.Format("共%d条管线!",tuple_num); (*ppFlowDlg)->mEdit.SetWindowTextA(cs); } //初始化list { (*ppFlowDlg)->m_list.DeleteAllItems(); for(int j=0;j<field_num;++j) { (*ppFlowDlg)->m_list.InsertColumn(j,PQfname(res,j), LVCFMT_LEFT, 80); } for(int j=0;j<tuple_num;++j) { char* s = PQgetvalue(res,j,0); int nRow = (*ppFlowDlg)->m_list.InsertItem(j, s);//插入行 for(int k=1;k<field_num;++k) { char* t = PQgetvalue(res,j,k); (*ppFlowDlg)->m_list.SetItemText(j, k, t);//设置数据 if(1==k) { char* s = PQfname(res,k); //ASSERT(PQfname(res,k) == "标识码"); fbzms[j] = atof(t);//查询到的标识码 } } } } //绘制整条流向管线 { for(std::vector<std::string>::iterator it=oldBzms.begin();it!=oldBzms.end();it++) { HighLightVisitor hl(*it,false); mViewer->getSceneData()->accept(hl); } oldBzms.erase(oldBzms.begin(),oldBzms.end()); ASSERT(oldBzms.empty()); /*ColorGradient g(color,colorEnd,tuple_num);*/ ColorGradient g(color,tuple_num); osg::Vec4f* colors = g.getColorArray(); for(int i=0;i<tuple_num;i++) { string s; ostringstream buf; buf<<"ysgline_new "<<fbzms[i]; s = buf.str(); HighLightVisitor hl(s,true,colors[i]); mViewer->getSceneData()->accept(hl); oldBzms.push_back(s); } } tmpGeom->dirtyDisplayList(); } return; } } } } } } }
inline void loop::write(poller::event &e) { write( *( hl() [ poller::from(e) ] ) ); }
// Report for the vm_info_cmd. This prints out the information above omitting // crash and thread specific information. If output is added above, it should be added // here also, if it is safe to call during a running process. void VMError::print_vm_info(outputStream* st) { char buf[O_BUFLEN]; report_vm_version(st, buf, sizeof(buf)); // STEP("printing summary") st->cr(); st->print_cr("--------------- S U M M A R Y ------------"); st->cr(); // STEP("printing VM option summary") // VM options Arguments::print_summary_on(st); st->cr(); // STEP("printing summary machine and OS info") os::print_summary_info(st, buf, sizeof(buf)); // STEP("printing date and time") os::print_date_and_time(st, buf, sizeof(buf)); // Skip: STEP("printing thread") // STEP("printing process") st->cr(); st->print_cr("--------------- P R O C E S S ---------------"); st->cr(); // STEP("printing number of OutOfMemoryError and StackOverflow exceptions") if (Exceptions::has_exception_counts()) { st->print_cr("OutOfMemory and StackOverflow Exception counts:"); Exceptions::print_exception_counts_on_error(st); st->cr(); } // STEP("printing compressed oops mode") if (UseCompressedOops) { Universe::print_compressed_oops_mode(st); if (UseCompressedClassPointers) { Metaspace::print_compressed_class_space(st); } st->cr(); } // STEP("printing heap information") if (Universe::is_fully_initialized()) { MutexLocker hl(Heap_lock); Universe::heap()->print_on_error(st); st->cr(); st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); st->cr(); } // STEP("printing code cache information") if (Universe::is_fully_initialized()) { // print code cache information before vm abort CodeCache::print_summary(st); st->cr(); } // STEP("printing ring buffers") Events::print_all(st); st->cr(); // STEP("printing dynamic libraries") // dynamic libraries, or memory map os::print_dll_info(st); st->cr(); // STEP("printing VM options") // VM options Arguments::print_on(st); st->cr(); // STEP("printing warning if internal testing API used") if (WhiteBox::used()) { st->print_cr("Unsupported internal testing APIs have been used."); st->cr(); } // STEP("printing log configuration") st->print_cr("Logging:"); LogConfiguration::describe(st); st->cr(); // STEP("printing all environment variables") os::print_environment_variables(st, env_list); st->cr(); // STEP("printing signal handlers") os::print_signal_handlers(st, buf, sizeof(buf)); st->cr(); // STEP("Native Memory Tracking") MemTracker::error_report(st); // STEP("printing system") st->cr(); st->print_cr("--------------- S Y S T E M ---------------"); st->cr(); // STEP("printing OS information") os::print_os_info(st); st->cr(); // STEP("printing CPU info") os::print_cpu_info(st, buf, sizeof(buf)); st->cr(); // STEP("printing memory info") os::print_memory_info(st); st->cr(); // STEP("printing internal vm info") st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); st->cr(); // print a defined marker to show that error handling finished correctly. // STEP("printing end marker") st->print_cr("END."); }