Beispiel #1
1
BOOL CHMMDemoView::OnEraseBkgnd(CDC* pDC)
{
    CImage& img = Camera().GetFrame();
    CRect ir( 0, 0, img.Width(), img.Height() );
    CRect r;
    pDC->GetClipBox( &r );

    if( ir.PtInRect( r.TopLeft()) && ir.PtInRect( r.BottomRight()))
        return TRUE;

    return CView::OnEraseBkgnd(pDC);
}
Beispiel #2
0
void CMainWindow::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	if(nSBCode==8)
		return;

	int tmp_pos=nPos;
	if(nSBCode==3){
		tmp_pos=pScrollBar->GetScrollPos()+m_vscroll_page_size-2*NETWORKCELLHEIGHT;	
	}
	else if(nSBCode==2){
		tmp_pos=pScrollBar->GetScrollPos()-(m_vscroll_page_size-2*NETWORKCELLHEIGHT);
	}
	tmp_pos=max(0,tmp_pos);
	tmp_pos=min(tmp_pos,pScrollBar->GetScrollLimit());
	nPos=tmp_pos;
	m_vscroll_pos=nPos;



	//invalidate the part of the screen that may change
	CRect client_rect;
	this->GetClientRect(&client_rect);
	CRect ir(0,0,350,client_rect.bottom-0);
	this->InvalidateRect(&ir,TRUE);

	pScrollBar->SetScrollPos(nPos,TRUE);

	this->SetFocus();
}
void FilteredImage::setSource(const QString &source)
{
    if(m_source != source)
    {
        m_source = source;

        QImageReader ir(m_source);
        QByteArray format(ir.format());

        m_image = ir.read();

        NemoImageMetadata meta(m_source, format);

        if (meta.orientation() != NemoImageMetadata::TopLeft)
        {
            m_image = rotate(m_image, meta.orientation());
        }

        setImplicitWidth((qreal)m_image.width());
        setImplicitHeight((qreal)m_image.height());

        m_imageChanged = true;
        emit sourceChanged(m_source);
        emit imageChanged(m_image);
    }
}
Beispiel #4
0
void AISTargetQueryDialog::UpdateText()
{
    wxString html;

    if( !m_pQueryTextCtl ) return;

    DimeControl( this );
    wxColor bg = GetBackgroundColour();
    m_pQueryTextCtl->SetBackgroundColour( bg );
    SetBackgroundColour( bg );

//    if( m_MMSI == 0 ) { //  Faulty MMSI could be reported as 0
    AIS_Target_Data *td = g_pAIS->Get_Target_Data_From_MMSI( m_MMSI );
    if( td )
    {
        if( td->b_PersistTrack )
        {
            m_createTrkBtn->SetLabel(_("Stop Tracking"));
        }
        else
        {
            m_createTrkBtn->SetLabel(_("Record Track"));
        }
        wxFont *dFont = FontMgr::Get().GetFont( _("AISTargetQuery") );
        wxString face = dFont->GetFaceName();
        int sizes[7];
        for( int i=-2; i<5; i++ ) {
            sizes[i+2] = dFont->GetPointSize() + i + (i>0?i:0);
        }

        html.Printf( _T("<html><body bgcolor=#%02x%02x%02x><center>"), bg.Red(), bg.Green(), bg.Blue() );

        html << td->BuildQueryResult();
        html << _T("</center></font></body></html>");

        m_pQueryTextCtl->SetFonts( face, face, sizes );
        m_pQueryTextCtl->SetPage( html );

        // Try to create a min size that works across font sizes.
        wxSize sz;
        if( ! IsShown() ) {
            sz = m_pQueryTextCtl->GetVirtualSize();
            sz.x = 300;
            m_pQueryTextCtl->SetSize( sz );
        }
        m_pQueryTextCtl->Layout();
        wxSize ir(m_pQueryTextCtl->GetInternalRepresentation()->GetWidth(),
                  m_pQueryTextCtl->GetInternalRepresentation()->GetHeight() );
        sz.x = wxMax( m_pQueryTextCtl->GetSize().x, ir.x );
        sz.y = wxMax( m_pQueryTextCtl->GetSize().y, ir.y );
        m_pQueryTextCtl->SetMinSize( sz );
        Fit();
        sz -= wxSize( 200, 200 );
        m_pQueryTextCtl->SetMinSize( sz );

        m_createWptBtn->Enable( td->b_positionOnceValid );
        m_createTrkBtn->Enable( td->b_show_track );
    }
    //  }
}
void AISTargetQueryDialog::SetBestSize( void )
{
    // Try to create a min size that works across font sizes.
    wxSize sz;
/*    
    if( ! IsShown() ) {
        sz = m_pQueryTextCtl->GetVirtualSize();
        sz.x = 300;
        m_pQueryTextCtl->SetSize( sz );
    }
*/    
    m_pQueryTextCtl->Layout();
    wxSize ir(m_pQueryTextCtl->GetInternalRepresentation()->GetWidth(),
              m_pQueryTextCtl->GetInternalRepresentation()->GetHeight() );
    sz.x = wxMax( m_pQueryTextCtl->GetSize().x, ir.x );
    sz.y = wxMax( m_pQueryTextCtl->GetSize().y, ir.y );
    sz.x += 100;         // fluff, to try and avoid scrollbars
    sz.y += 20;         // fluff
    
    m_pQueryTextCtl->SetMinSize( sz );
    Fit();
    
    sz -= wxSize( 200, 200 );
    m_pQueryTextCtl->SetMinSize( sz );
    
}
Beispiel #6
0
hrCacheItem* hrCache::Load(const QString &name) const
{
    hrCacheItem *item = new hrCacheItem();

    QImageReader ir("vfs:/" + name);
    QImage im;
    if (ir.read(&im))
    {
        item->addFrame(Load(im));
    }
    for (int i = 1; ir.jumpToImage(i); i++)
        if (ir.read(&im))
        {
            item->addFrame(Load(im));
        }

    item->setSize(im.size());

    if (ir.error())
    {
        qFatal("hrCache: %s", qPrintable(ir.errorString() + name));
    }

    return item;
}
Beispiel #7
0
void TensorDerivative(Mode m, Mode mj, Geometry geo, Vec df, Vec vpsibra, Vec vIpsi, int ih){
	double mjc = get_c(mj);
	dcomp mw = get_w(m), yw = gamma_w(m, geo) ;

	Vecfun f, H, psibra;
	CreateVecfun(&f, geo->vf);
	CreateVecfun(&H, geo->vH);
	CreateVecfun(&psibra, vpsibra);

	Complexfun psi;
	CreateComplexfun(&psi, m->vpsi, vIpsi);

	int i;
	for(i=f.ns; i<f.ne; i++){
		if( valr(&f, i) == 0.0) continue;		
		dcomp ket_term = -csqr(mw ) * sqr(mjc) * 2.0
			* sqr(valr(&H, i) ) * geo->D * valr(&f, i) * yw * valc(&psi, i);	
		double val = valr(&psibra, i) * (ir(geo, i)? cimag(ket_term) : creal(ket_term) );
	
		VecSetValue(df, i+offset(geo, ih), val, INSERT_VALUES);
		// df is assembled in SetJacobian
	}
	DestroyVecfun(&f);
	DestroyVecfun(&H);
	DestroyVecfun(&psibra);
	DestroyComplexfun(&psi);
}
Beispiel #8
0
HBITMAP imageFromSelection(Frame* frame, bool forceBlackText)
{
    frame->view()->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly);
    FloatRect fr = frame->selectionRect();
    IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()),
               static_cast<int>(fr.width()), static_cast<int>(fr.height()));

    void* bits;
    HDC hdc = CreateCompatibleDC(0);
    int w = ir.width();
    int h = ir.height();
    BITMAPINFO bmp = { { sizeof(BITMAPINFOHEADER), w, h, 1, 32 } };

    HBITMAP hbmp = CreateDIBSection(0, &bmp, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0);
    HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp));
    CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(static_cast<void*>(bits), w, h,
        8, w * sizeof(RGBQUAD), deviceRGB, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
    CGColorSpaceRelease(deviceRGB);
    CGContextSaveGState(context);

    GraphicsContext gc(context);

    frame->document()->updateLayout();
    drawRectIntoContext(ir, frame->view(), &gc);

    CGContextRelease(context);
    SelectObject(hdc, hbmpOld);
    DeleteDC(hdc);

    frame->view()->setPaintRestriction(PaintRestrictionNone);

    return hbmp;
}
int main (int argc,  const char* argv[] ) {
  ucam::util::initLogger ( argc, argv );
  FORCELINFO ( argv[0] << " starts!" );
  ucam::util::RegistryPO rg ( argc, argv );
  FORCELINFO ( rg.dump ( "CONFIG parameters:\n=====================",
                         "=====================" ) )  ;
  ucam::util::PatternAddress<unsigned> pi (rg.get<std::string>
      (HifstConstants::kInput) );
  ucam::util::PatternAddress<unsigned> po (rg.get<std::string>
      (HifstConstants::kOutput) );
  for ( ucam::util::IntRangePtr ir (ucam::util::IntRangeFactory ( rg,
                                    HifstConstants::kRangeOne ) );
        !ir->done();
        ir->next() ) {
    fst::VectorFst<fst::StdArc> *mfst = fst::VectorFstRead<fst::StdArc> (pi (
                                          ir->get() ) );
    if (!mfst) return 1;
    TopSort (mfst);
    boost::multiprecision::uint128_t j =
      countstrings<fst::StdArc, boost::multiprecision::uint128_t> (*mfst);
    std::stringstream ss;
    ss << j;
    ucam::util::oszfstream o (po (ir->get() ), true);
    o << ss.str()  << std::endl;
    LINFO ( pi (ir->get() ) << ":" << ss.str() ) ;
    o.close();
    delete mfst;
  }
  FORCELINFO ( argv[0] << " ends!" );
}
void run(ucam::util::RegistryPO const &rg) {

  ucam::util::PatternAddress<unsigned> pi (rg.get<std::string>
      (HifstConstants::kInput) );
  ucam::util::PatternAddress<unsigned> po (rg.get<std::string>
      (HifstConstants::kOutput) );
  for ( ucam::util::IntRangePtr ir (ucam::util::IntRangeFactory ( rg,
                                    HifstConstants::kRangeOne ) );
        !ir->done();
        ir->next() ) {
    fst::VectorFst<Arc> *mfst = fst::VectorFstRead<Arc> (pi (
                                          ir->get() ) );
    if (!mfst) {
      LERROR("Could not read file:" << ir->get());
      exit(EXIT_FAILURE);
    }
    TopSort (mfst);
    boost::multiprecision::uint128_t j =
      countstrings<Arc, boost::multiprecision::uint128_t> (*mfst);
    std::stringstream ss;
    ss << j;
    ucam::util::oszfstream o (po (ir->get() ), true);
    o << ss.str()  << std::endl;
    LINFO ( pi (ir->get() ) << ":" << ss.str() ) ;
    o.close();
    delete mfst;
  }
}
Beispiel #11
0
// Add preheader and loop exit blocks; after this pass,
// dominators are not valid anymore
void LoopFinder::insert_blocks(LoopList* loops) {
  if (LIRCacheLocals) {
    intStack* tags = new intStack(max_blocks(), -1);
    int i;

    for (i = 0; i < loops->length(); i++) {
      Tagger t(tags, i);
      loops->at(i)->blocks()->iterate_forward(&t);
    }

    PairCollector pc(tags);
    ir()->iterate_preorder(&pc);

    BlockPairList* pairs = pc.pairs();

    pairs->sort(sort_by_block_ids);

    BlockPair* last_pair = NULL;
    for (i = 0; i < pairs->length(); i++) {
      BlockPair* p = pairs->at(i);
      if (last_pair != NULL && p->is_same(last_pair)) {
        // last_pair is not null and p is same as last_pair -> skip inserting of blocks
      } else {
        insert_caching_block(loops, p->from(), p->to());
        last_pair = p;
      }
    }
    
  }
}
Beispiel #12
0
  void Lidar::
  StepUpdate(const Line & line)
  {
    double phi(m_global_pose->Theta() + phi0);
    double const dphi(phirange / (nscans - 1));
    Ray ray(m_global_pose->X(), m_global_pose->Y(), phi);

    for(size_t ir(0); ir < nscans; ++ir){
      
      const double true_rr(ray.Intersect(line));
      if((true_rr > 0) && (true_rr < m_true_rho[ir])){
	m_true_rho[ir] = true_rr;
	if( ! m_noise_model)
	  m_noisy_rho[ir] = true_rr;
      }
      
      if(m_noise_model){
	const double noisy_rr((*m_noise_model)(true_rr));
	if((noisy_rr > 0) && (noisy_rr < m_noisy_rho[ir]))
	  m_noisy_rho[ir] = noisy_rr;
      }
      
      phi += dphi;
      ray.SetAngle(phi);
    }
  }
int main(int argc, char **argv)
{
  ros::init (argc, argv, "PhidgetsIR");
  ros::NodeHandle nh;
  ros::NodeHandle nh_private("~");
  phidgets::IRRosI ir(nh, nh_private);
  ros::spin();
  return 0;
}
Beispiel #14
0
    void process_line(const std::string& line, T& dest)
    {
        csv_separator sep;
        Tokenizer tok(line, sep);
        Tokenizer::iterator s = tok.begin();

        ItemWalker ir(s, tok.end());
        tuple_for_each(ir, dest);
    }
void plugin_load(char *filename, option_block *opts)
{
    plugin_init ir;
    char fileline[8192] = {0};
    int  length         = strcspn(filename+1, " \n\r");
    
    if( length > 8191 )
    {
        file_error("filename for plugin is too large!", opts);
        return;
    }
    
    strncpy(fileline, filename+1, length);

    if( plugin_handle != NULL )
    {
        file_error("limit 1 plugin per script!", opts);
        return;
    }
    
    plugin_handle = sfuzz_dlopen(fileline, RTLD_NOW);
    if(plugin_handle == NULL)
    {
        file_error("Unable to open plugin (check the search path?).", opts);
        return;
    }
    
    ir = (plugin_init)dlsym(plugin_handle, "plugin_init");
    if(ir == NULL)
    {
        fprintf(stderr, "--- plugin loading: [%s][%s] ---\n", fileline,
                dlerror());
        file_error("unable to locate entrypoint in plugin", opts);
        return;
    }

    g_plugin = (plugin_provisor*)malloc(sizeof(plugin_provisor));
    
    if(g_plugin == NULL)
    {
        file_error("unable to allocate plugin descriptor", opts);
        return;
    }

    memset(g_plugin, 0, sizeof(plugin_provisor));
    
    ir(g_plugin);

    if(g_plugin->name == NULL || g_plugin->version == NULL)
    {
        file_error("plugin is invalid!", opts);
        return;
    }

    plugin_sanity(opts);
}
Beispiel #16
0
tgt::ivec3 Flow3D::getNearestVoxelPos(const tgt::vec3& r) const {
    tgt::ivec3 ir(0, 0, 0);
    for (size_t i = 0; i < 3; ++i) {
        //ir[i] = (r[i] <= 0.0f) ? 0 : static_cast<int>(r[i]);// cut off fractional part (floor)
        ir[i] = (r[i] <= 0.0f) ? 0 : static_cast<int>((r[i] + 0.5f));
        if (ir[i] >= dimensions_[i])
            ir[i] = (dimensions_[i] - 1);
    }
    return ir;
}
Beispiel #17
0
tgt::ivec3 Flow3D::clampToFlowDimensions(const tgt::ivec3& r) const {
    tgt::ivec3 ir(r);
    for (size_t i = 0; i < 3; ++i) {
        if (ir[i] < 0)
            ir[i] = 0;
        else if (ir[i] >= dimensions_[i])
            ir[i] = (dimensions_[i] - 1);
    }
    return ir;
}
Beispiel #18
0
 void Lidar::
 InitUpdate()
 {
   *m_global_pose = *mount;
   owner->GetPose().To(*m_global_pose);
   for(size_t ir(0); ir < nscans; ++ir){
     m_true_rho[ir] = rhomax;
     m_noisy_rho[ir] = rhomax;
   }
 }
QImage NemoThumbnailProvider::generateThumbnail(const QString &id, const QByteArray &hashData, const QSize &requestedSize, bool crop)
{
    QImage img;
    QSize originalSize;
    QByteArray format;

    // image was not in cache thus we read it
    QImageReader ir(id);
    if (!ir.canRead())
        return img;

    originalSize = ir.size();
    format = ir.format();

    if (originalSize != requestedSize && originalSize.isValid()) {
        if (crop) {
            // scales arbitrary sized source image to requested size scaling either up or down
            // keeping aspect ratio of the original image intact by maximizing either width or height
            // and cropping the rest of the image away
            QSize scaledSize(originalSize);

            // now scale it filling the original rectangle by keeping aspect ratio, but expand if needed.
            scaledSize.scale(requestedSize, Qt::KeepAspectRatioByExpanding);

            // set the adjusted clipping rectangle in the center of the scaled image
            QPoint center((scaledSize.width() - 1) / 2, (scaledSize.height() - 1) / 2);
            QRect cr(0,0,requestedSize.width(), requestedSize.height());
            cr.moveCenter(center);
            ir.setScaledClipRect(cr);

            // set requested target size of a thumbnail
            ir.setScaledSize(scaledSize);
        } else {
            // Maintains correct aspect ratio without cropping, as such the final image may
            // be smaller than requested in one dimension.
            QSize scaledSize(originalSize);
            scaledSize.scale(requestedSize, Qt::KeepAspectRatio);
            ir.setScaledSize(scaledSize);
        }
    }
    img = ir.read();

    NemoImageMetadata meta(id, format);
    if (meta.orientation() != NemoImageMetadata::TopLeft)
        img = rotate(img, meta.orientation());

    // write the scaled image to cache
    if (meta.orientation() != NemoImageMetadata::TopLeft ||
        (originalSize != requestedSize && originalSize.isValid())) {
        writeCacheFile(hashData, img);
    }

    TDEBUG() << Q_FUNC_INFO << "Wrote " << id << " to cache";
    return img;
}
void LIR_OopMapGenerator::clear_all(int local_name) {
  // Have to clear out all slots corresponding to this local name
  WordSizeList* name_to_offset_map = ir()->local_name_to_offset_map();
  WordSize offset = name_to_offset_map->at(local_name);
  for (int i = 0; i < name_to_offset_map->length(); i++) {
    WordSize word = name_to_offset_map->at(i);
    if (word == offset) {
      clear(i);
    }
  }
}
Beispiel #21
0
HBITMAP imageFromSelection(Frame* frame, bool forceBlackText)
{
    frame->document()->updateLayout();

    frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
    FloatRect fr = frame->selection()->bounds();
    IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()),
               static_cast<int>(fr.width()), static_cast<int>(fr.height()));
    HBITMAP image = imageFromRect(frame, ir);
    frame->view()->setPaintBehavior(PaintBehaviorNormal);
    return image;
}
Beispiel #22
0
void CHMMDemoView::CheckUpdate()
{
    m_sel = NormalizeRect( m_tmp_sel );
    if( !Camera().IsRunning() )
    {
        CImage& img = Camera().GetFrame();
        CRect ir( 0, 0, img.Width(), img.Height() );

        InvalidateRect(&ir, FALSE);
        UpdateWindow();
    }
}
Beispiel #23
0
  /*
    Calculates the element matrix.

    Input is:
    the finite element: fel 
    the geometry of the element: eltrans
    
    Output is:
    the element matrix: elmat
    
    Efficient memorymanagement is provided my locheap
  */
  void MyLaplaceIntegrator ::
  CalcElementMatrix (const FiniteElement & base_fel,
		     const ElementTransformation & eltrans, 
		     FlatMatrix<double> elmat,
		     LocalHeap & lh) const
  {
    /*
      tell the compiler that we are expecting to get an scalar fe in 2D.
      if not, an exception will be raised
    */
    const ScalarFiniteElement<2> & fel =
      dynamic_cast<const ScalarFiniteElement<2> &> (base_fel);

    // number of element basis functions:
    int ndof = fel.GetNDof();

    elmat = 0;

    Matrix<> dshape_ref(ndof, 2); // gradient on reference element
    Matrix<> dshape(ndof, 2);     // gradient on mapped element

    /*
      get integration rule for element geometry, 
      integration order is 2 times element order
    */
    IntegrationRule ir(fel.ElementType(), 2*fel.Order());

    // loop over integration points
    for (int i = 0 ; i < ir.GetNIP(); i++)
      {
        // calculate Jacobi matrix in the integration point
        MappedIntegrationPoint<2,2> mip(ir[i], eltrans);

        // lambda(x)
        double lam = coef_lambda -> Evaluate (mip);

        /*
          gradient on reference element
          the i-th row of the matrix is the grad of the i-th shape function
        */
        fel.CalcDShape (ir[i], dshape_ref);
        
        // transform it for the mapped element
        dshape = dshape_ref * mip.GetJacobianInverse();
        
        // integration weight and Jacobi determinant
        double fac = mip.IP().Weight() * mip.GetMeasure();

        // elmat_{i,j} += (fac*lam) * InnerProduct (grad shape_i, grad shape_j)
        elmat += (fac*lam) * dshape * Trans(dshape);
      }     
  }
Beispiel #24
0
int main() {
	Object object;
	int n = object.faces.size();
	object.load("test_data/block.obj");
	object.meshSimplify(10000, false);
	return 0;
	
	
	RenderSetting rs("renderconfig2/render.cfg");
	ImageRenderer ir(&rs);
	ir.renderImage();
	return 0;
}
void LIR_OopMapGenerator::generate() {
  // Initialize by iterating down the method's signature and marking
  // oop locals in the state

  assert((int) oop_map()->size() == frame_map()->num_local_names(), "just checking");
  oop_map()->clear();
  ciSignature* sig = ir()->method()->signature();
  int idx = 0;
  // Handle receiver for non-static methods
  if (!ir()->method()->is_static()) {
    mark(frame_map()->name_for_argument(idx));
    ++idx;
  }
  for (int i = 0; i < sig->count(); i++) {
    ciType* type = sig->type_at(i);
    if (!type->is_primitive_type()) {
      mark(frame_map()->name_for_argument(idx));
    }
    idx += type->size();
  }

  // The start block contains a Base instruction, which causes the LIR
  // for ref-uninit conflicts to be generated. We need to handle this
  // block specially so we don't traverse its "osr_entry" successor,
  // because we don't know how to set up the state appropriately for
  // that entry point.
  _base = ir()->start()->end()->as_Base();

  // Always start iterating at the start (even for OSR compiles)
  merge_state(ir()->start());
  
  BlockBegin* block = work_list_dequeue();
  while (block != NULL) {
    oop_map()->set_from(*block->lir_oop_map());
    iterate_one(block);
    block = work_list_dequeue();
  }
}
Beispiel #26
0
int main(int argc, char const* argv[])
{
	iRemoconClient ir("192.168.0.3", 51013);
	Interpreter ip;

	if (!ip.learn_commands_from_xml("data/commands.xml")) {
		std::cerr << "Error: XML is invalid" << std::endl;
	}

	JuliusClient jc("192.168.0.10", 10500);
	jc.connect(ip, ir);

	return 0;
}
Beispiel #27
0
  void DGFiniteElement<D>:: 
  GetDiagMassMatrix (FlatVector<> mass) const
  {
#ifndef __CUDA_ARCH__
    IntegrationRule ir(this->ElementType(), 2*order);
    VectorMem<50> shape(ndof);
    mass = 0;
    for (int i = 0; i < ir.Size(); i++)
      {
        this -> CalcShape (ir[i], shape);
        for (int j = 0; j < ndof; j++)
          mass(j) += ir[i].Weight() * sqr (shape(j));
      }
#endif
  }
Beispiel #28
0
bool TImageReader::load(const TFilePath &path, TRasterP &raster)
{
	raster = TRasterP();
	TImageReaderP ir(path);
	if (!ir)
		return false;
	TImageP img = ir->load();
	if (!img)
		return false;

	TRasterImageP ri(img);
	if (!ri)
		return false;

	raster = ri->getRaster();
	return true;
}
int main()
{
	eventReceiver receiver;
	IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(1366, 768), 16,true, false, false,&receiver);
	device->setWindowCaption(L"(WhizGeek || Mclightning).com");
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	scene::ICameraSceneNode* kam= smgr->addCameraSceneNode(NULL,vector3df(0,0,200),vector3df(0,0,0));
	
	//kam->setPosition(vector3df(0,0,200));

	ISceneNode* kutu=smgr->addCubeSceneNode(50,0,2,vector3df(50,0,0));
	ISceneNode* kutu2=smgr->addCubeSceneNode(50,0,2,vector3df(-50,0,0));
	ITexture *duvar=driver->getTexture("wall.jpg");
	kutu->setMaterialTexture(0,duvar);
	kutu->setMaterialFlag(video::EMF_LIGHTING, false);
	kutu2->setMaterialTexture(0,duvar);
	kutu2->setMaterialFlag(video::EMF_LIGHTING, false);

		IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
		IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation(scene::EMAT_STAND);
		node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
		node->setRotation(vector3df(0,270,0));
		
	irFinder ir("test",true,230,255);
	CvPoint in;
	while(device->run())
	{		
		if(receiver.IsKeyDown(KEY_ESCAPE))
		{
			device->drop();
			return 0;
		}
		driver->beginScene(true, true, SColor(255,0,0,255));
		in=ir.yenile();
		//node->setPosition(vector3df(30*in.x/320,30*(240-in.y)/240,0));
		kam->setPosition(vector3df(in.x-160,(240-in.y),200));
		smgr->drawAll();
		driver->endScene();
	}
	device->drop();
}
Beispiel #30
-1
	/**
		 \todo Removals should be done "en vrac", not one by
		 one. Multiscanner::raw_scan_collection_t is bad because it uses
		 the robot's pose, not each sensor's at the time of capture.
	*/
	size_t Mapper2d::
	SwipedUpdate(const Frame & pose,
							 const Multiscanner::raw_scan_collection_t & scans,
							 double max_remove_distance,
							 draw_callback * cb)
	{
		m_freespace_buffer.clear();
		m_obstacle_buffer.clear();
		m_swipe_check_buffer.clear();
		swipe_cb swipe(m_swipe_check_buffer, m_freespace_buffer, *m_travmap);
		ssize_t const bbx0(m_travmap->grid.xbegin());
		ssize_t const bbx1(m_travmap->grid.xend());
		ssize_t const bby0(m_travmap->grid.ybegin());
		ssize_t const bby1(m_travmap->grid.yend());
		
		// compute sets of swiped and obstacle cells
		for (size_t is(0); is < scans.size(); ++is) {
			double const spx(scans[is]->scanner_pose.X());
			double const spy(scans[is]->scanner_pose.Y());
			double const spt(scans[is]->scanner_pose.Theta());
			Scan::array_t const & scan_data(scans[is]->data);
			const index_t i0(gridframe.GlobalIndex(spx, spy));
			
			for (size_t ir(0); ir < scan_data.size(); ++ir) {
				index_t const ihit(gridframe.GlobalIndex(scan_data[ir].globx, scan_data[ir].globy));
				index_t iswipe;
				if (scan_data[ir].rho <= max_remove_distance) {
					// swipe up to the laser point
					iswipe = ihit;
				}
				else {
					// swipe along ray, but stop after max_remove_distance
					double const theta(spt + scan_data[ir].phi);
					iswipe = gridframe.GlobalIndex(spx + max_remove_distance * cos(theta),
																				 spy + max_remove_distance * sin(theta));
				}
				gridframe.DrawDDALine(i0.v0, i0.v1, iswipe.v0, iswipe.v1,
															bbx0, bbx1, bby0, bby1,
															swipe);
				if (scan_data[ir].in_range) {
					// always insert them into m_obstacle_buffer, do not check
					// m_travmap->IsWObst(ihit.v0, ihit.v1), because otherwise
					// neighboring rays can erase known W-obstacles
					PDEBUG("in range W-obst: global %g  %g   index %zd %zd\n",
								 scan_data[ir].globx, scan_data[ir].globy,
								 ihit.v0, ihit.v1);
					m_obstacle_buffer.insert(ihit);
				}
			}
		}
		
		// remove new obstacles from swiped set (due to grid effects, it
		// would otherwise be possible for a later ray to erase an
		// obstacle seen by an earlier ray)
		for (index_buffer_t::const_iterator io(m_obstacle_buffer.begin());
				 io != m_obstacle_buffer.end(); ++io)
			m_freespace_buffer.erase(*io);
		
		return UpdateObstacles(&m_obstacle_buffer, false, &m_freespace_buffer, cb);
	}