Ejemplo n.º 1
0
int main( int argc, char** argv ) {
	idStr fileName, sourcePath;

	idLib::common = common;
	idLib::sys = sys;

	DmapCmdLine dmap(argc, argv);
	dmap.run();

	return 0;
}
Ejemplo n.º 2
0
void monster::AItime()
{
	CClientDC dc(hwnd);
	flag++;	if(flag==3)flag=0;
	flag2++;if(flag2==2)flag2=0;
	flag1++;if(flag1==3)flag1=0;
	dmap();
	dman();
	if		(mtime.move)	{gogogo();}
	//{AImoving();}
//	else if	(mtime.attack)	{}
//	else	{think();}
	dc.BitBlt(0,0,WIDTH,HEIGHT,mdc,0,0,SRCCOPY);
}
Ejemplo n.º 3
0
void monster::endheroturn2()
{
	CClientDC dc(hwnd);
	for(p1=hhead;p1!=0;p1=p1->next)
		p1->action=true;
		dmap();
		dman();
		mdc1->SelectObject(turn);
		mdc->BitBlt(5*32,6*32,WIDTH,HEIGHT,mdc1,0,0,SRCCOPY);
		SetBkMode(*mdc,TRANSPARENT);	
		SetTextColor(*mdc,RGB(255,255,255));
		CString cc="ENEMY";
		mdc->TextOut(7*32-4,7*32-8,cc);
		dc.BitBlt(0,0,WIDTH,HEIGHT,mdc,0,0,SRCCOPY);
		Sleep(500);
//		monturn();
		q=mhead;
		turntag=2;
}
Ejemplo n.º 4
0
CVBitmap<DepthInfo> FastVoxelView::getDepthMap()
{
  CVBitmap<DepthInfo> dmap(w,h,0);

  std::map<Pos2D,std::pair<int,Voxel*> >::iterator i=viewSpace.mViewSpace.begin();

  for(;i!=viewSpace.mViewSpace.end();i++)
    {
      if(i->second.second)
        {
          Pos3D p=i->second.second->pos;

          dmap.set(i->first,DepthInfo(i->second.first,projectShadow(p)));
        }
    }



  return dmap;
}
Ejemplo n.º 5
0
void monster::endmonturn()
{
	CClientDC dc(hwnd);
	for(q1=mhead;q1!=0;q1=q1->next)
		q1->action=true;
	dmap();
	dman();
	mdc1->SelectObject(turn);
	mdc->BitBlt(5*32,6*32,WIDTH,HEIGHT,mdc1,0,0,SRCCOPY);
	SetBkMode(*mdc,TRANSPARENT);	
	SetTextColor(*mdc,RGB(255,255,255));
	CString cc="HERO";
	mdc->TextOut(7*32,7*32-8,cc);
	dc.BitBlt(0,0,WIDTH,HEIGHT,mdc,0,0,SRCCOPY);
	Sleep(500);
	cur.x=hhead->x;cur.y=hhead->y;
	turntag=1;
	p1=hhead;
	cur_backpress(p1);
}
Ejemplo n.º 6
0
 icycle()
{
int op,a1,a2,x1,x2,i1,i2,setting,setmask,onemask,oldmask;
int 	ecd;		/* Error Code	*/	

	/*  setjmp(svstck) to save stack for return	*/
	/*  from possible segment and page faults	*/
	if((ecd=setjmp(svstck)) != 0) 
		{
		goto except;
		}

	ir = pm[cmap(pc)];
	pc++;
	/*  extract instruction fields into op, a1, a2;	*/
	/*  generate the eff. virtual addresses v1, v2	*/
	/*  using the algorithm in the Reference Manual	*/
	op = extract(ir,24,6);

	a1 = extract(ir,12,10);
	a2 = extract(ir,0,10);
	x1 = extract(ir,22,1);
	x2 = extract(ir,10,1);
	i1 = extract(ir,23,1);
	i2 = extract(ir,11,1);
	
 	v1 = a1;
	v2 = a2;	/*  address field forms initial value 	*/
	if (i1 == 1) v1 = pm[dmap(v1)];	/*  if indirection, get ind. loc */
	if (i2 == 1) v2 = pm[dmap(v2)];	
	if (x1 == 1) v1 = v1 + xr;	/*  if indexing specified, add xr */		
	if (x2 == 1) v2 = v2 + xr;

	

	switch(op)
	{
case 1:	gr = pm[dmap(v1)];		/*  gr load		*/
	break;
case 2: pm[dmap(v1)] = gr;		/*  gr store		*/
	break;
case 3: xr = pm[dmap(v1)];		/* xr load		*/
	break;
case 4: pm[dmap(v1)] = xr;		/* xr store		*/
	break;
case 5: sr = pm[dmap(v1)];		/* sr load		*/
	break;
case 6: pm[dmap(v1)] = sr;		/* sr store		*/
	break;
case 8: pm[dmap(v2)] = pm[dmap(v1)];	/* copy			*/
	break;
case 9: pm[dmap(v2)] += pm[dmap(v1)];	/* add			*/
	break;
case 10: pm[dmap(v2)] -= pm[dmap(v1)];	/* subtract		*/
	break;
case 11: pm[dmap(v2)] *= pm[dmap(v1)];	/* multiply		*/
	break;
case 12:				/* Divide		*/  
	if (pm[dmap(v1)] == 0)
		{
		ecd = ARITFLT;
		printf ("\nDivide Fault\n");
		goto except;
		}
        else 
		pm[dmap(v2)] /= pm[dmap(v1)];
        break;
case 13: pm[dmap(v2)] &= pm[dmap(v1)];	/* and			*/
	break;
case 14: pm[dmap(v2)] |= pm[dmap(v1)];	/* or			*/
	break;
case 16: pc = v1;			/* go to		*/
	break;
case 17: if (pm[dmap(v1)] != pm[dmap(v2)]) pc++;  /* if =	*/
	break;
case 18:  if (pm[dmap(v1)] == pm[dmap(v2)]) pc++; /* if !=	*/
	break;
case 19:  if (pm[dmap(v1)] >= pm[dmap(v2)]) pc++; /* if <	*/
	break;
case 20: if (pm[dmap(v1)] < pm[dmap(v2)]) pc++;	  /* if >=	*/
	break;
case 21: xr++;				/*  loop		*/
	 if (xr < pm[dmap(v1)]) pc = v2;
	break;
case 22: sr = pc;
	 pc = v1;			/* call			*/
	 break;
case 23:  pc = sr + pm[dmap(v1)];	/* return		*/
	 break;
case 26: xr = v1;			/* xr set		*/
	 break;
case 27: pm[dmap(v2)] = v1;		/* vm set		*/
	 break;
case 28: pm[dmap(v2)] = extract(pm[dmap(v1 + gr/4)],(gr%4)*8,8);	/* get byte	*/
	 break;
case 29:  setting =  extract(pm[dmap(v2)],0, 8); 	/* set byte */
	 /* Byte want to set in pos with 0s other */
	 setmask = setting << (gr%4)*8;			
 	 onemask = 0xFFFFFFFF - (0xFF <<  (gr%4) * 8);  /* mask with ones 'cept 0's in pos. */
	 oldmask = pm[dmap(v1+(gr/4))] & onemask;	/* old value of word with 0's in pos */
	 pm[dmap(v1+(gr/4))] = oldmask | setmask;	/* new word to write to memory */
	 break;

case 31: ;				/* noop			*/
	 break;

case 32: hlt = TRUE;			/* halt			*/
	 break;

case 33:				/* error		*/
	hlt = TRUE;
	/* A1 serves as error code */
	printf("\n ERROR:  %x\n",a1);		
	break;

case 34:				/* PmVmCp -- Primary Mem V Mem copy */
	if (md < 0) goto illins;
	pm [dmap(v2)] = pm [v1];
	break;
case 35:				/* VmPmCp		*/
	if (md < 0) goto illins;
	pm [v2] = pm[dmap(v1)];
	break;

case 36:				/* Arm			*/
	if (md < 0) goto illins;
	ar |= pm [dmap(v1)];
	break;

case 37:				/* Disarm		*/
	if (md < 0) goto illins;
	ar &= (-1-pm[dmap(v1)]);
	break;

case 38:				/* OS Call		*/
	if (md > 0) goto illins;
	ie |= EBIT;		/* set exception */
	pm [sp+PSR_ECD] = a1;	/* OS Call Number */
	break;

case 40:				/* Floppy IO		*/
	if (md < 0) goto illins;
	if (pm[LCL_FCP] < 0) { hlt = TRUE; break; }
	floppy_io ();
	break;
	
case 41:				/* Disk IO		*/
	if (md < 0) goto illins;
	if (pm[LCL_DCP] < 0) { hlt = TRUE; break; }
	disk_io ();
	break;

case 42:				/* Print IO		*/
	/* Advance one line and printf pm[v1] */
	if (md < 0) goto illins;
	fprintf (printer,"\t%s\t%8x\n",LP_STR,pm[v1]);
	fflush(printer);
	break;

case 43:				/* Log			*/
	if (md < 0) goto illins;
	log (v1, v2);
	break;

/* Cases 44 and 45 not written yet */

case 44:				/* TTY IN		*/
	if (md < 0) goto illins;
	break;

case 45:				/* TTY Out		*/
	if (md < 0) goto illins;
	break;
/*********************************************/
	
case 48:				/* Head Record		*/
	if (moverec(v1,v2,pm[dmap(v1)]))
		pc++;
	break;

case 49:				/* Move Record		*/
	if (moverec (v1, v2, xr))
		pc++;
	break;	

case 50:				/* Insert Record	*/
	if (xr < 0) break;
	insrec (v1, pm[dmap(v2)], xr);
	pc++;	
	break;

case 51:				/* Find Record		*/
	while (((pm[dmap(v1)+1] & pm[dmap(v2)]) != gr) && (pm[dmap(v1)] > 0))
		{
			v1 = pm[dmap(v1)];
		}
	if ((pm[dmap(v1)+1] & pm[dmap(v2)]) == gr)	
	{
		xr = v1;
		pc++;
	}
	break;

case 53:				/* Allocate		*/	
	if (allocate(v1,v2,gr)) pc++; 	
	break;	

case 54:				/* DeAllocate		*/
	if (deallocate(v1,v2,gr)) pc++;	
	break;

case 56:				/* SP Load		*/
	if (md < 0) goto illins;
	sp = pm [dmap(v1)];
	break;

case 57:				/* Switch Process	*/
	if (md < 0) goto illins;
	swcontxt (v1, v2);
	break;
case 60:				/* Send Message		*/
	if (md < 0) goto illins;
	if (pm [LCL_MSF] > 0)
		send_mesg ();
	break;		

case 61:				/* Receive Message	*/
	if (md < 0) goto illins;
	
	if (pm[dmap(sp + PSR_MSQ)] > 0)
		recv_mesg ();
	else	
		{
		/* reset M bit and switch to scheduler */
		pc--;
		pm[dmap(sp + PSR_STW)] |= MBIT;
		swcontxt (pm[LCL_SCH], pc);
		} 			
	break;

default:  hlt = TRUE;			/* Unused Op		*/
	break;

	}	/* End Case */

	goto realtm ;	/* Ready for real time section */

/* Real Time Code */
realtm:
	pm [LCL_TOD]++;			/* Increment Time of Day */
	pm [LCL_ALM]++;			/* Increment Alarm */
	
	if (pm [LCL_ALM] == 0)
		ie |= ABIT;		/* Set the Alarm */
	if (sp > 0)
		pm [sp+PSR_CPT]++;	/* Increment CPU time */

	if (fbsyrd)			/* Floppy busy? Get 2 wrds */
		{
		/* Read two words */
		/* is it pointing to the correct place? */
		if (fread (&pm[ftx], WD_B, 2, floppy) != 2)
			{
			fbsyrd = 0;
			pc --;
			}
		else
			{
			ftx += 2;
			if (ftx == ftul)
				{  fbsyrd = 0; ie |= FBIT; md &= ~(1<<FBIT);  }
			}
		}

	if (dbsyrd)		/* Disk Busy Reading ? Get 2 Words */ 
		{
		recv (dmasock, &pm[dtx], 2*WD_B, 0);
		dtx += 2;
		if (dtx == dtul)
			{ dbsyrd = 0; ie |= DBIT; md &= ~(1<<DBIT); }
		}

	else 
	  if (dbsywr)		/* Disk Writing (and not reading) Send 2 words */
		{
		write (dmasock, &pm[dtx], 2*WD_B);
		dtx += 2;
		if (dtx == dtul)
			{ dbsywr = 0; ie |= DBIT; md &= ~(1<<DBIT); }
		}		

/* Interrupt Handling */
if (ie != 0 && ar < 0)
	{
	int intr;
	int md_sign;
	int md_val;

	/* If something else running and this is not a greater one ignore for now */
	if ((extract (md,0,WD_L-1) != 0) && (md <= ie)) return;		/* Go away */

	/* Get sign bit */
	md_sign = (extract (md,(WD_L-1),1)) << (WD_L-1) ;	

	/* Get the rightmost interrupt and make sure it can execute */
	for (i=0; i< LEV_N; i++)
		{
		if ( (intr = (ffs (ie)-1)) != -1)	/* Find the int */ 
		 if (extract (ar,intr,1))		/* Is it armed? */
		  {	
		  if (sp > 0) 
		  /* Set the "return to" value to SP */
			pm [LCL_ITV + (2*intr) +1] = sp;
		  else 
			{ hlt = TRUE ; break ; }
		  ie &= ~(1<<intr);			/* Clear the int */
		  swcontxt (pm[LCL_ITV+(2*intr)], pc);	/* Switch to it */
		  md = (1 << intr);			/* Set mode register */
/*		  md = ((1<<intr) | md_sign);		/* Set mode register */
		  break;
		  }
		}
	}		
return;

/* Illegal instruction */	
illins:
	ecd = INSTFLT;
printf ("\n\nIll Ins ECD : %x\n\n", ecd);
	goto except;

/* Exception */
except:
	ie |= EBIT;
printf ("\nException Handler ECD : %x\n", ecd);
	if (sp > 0)
		pm [sp+PSR_ECD] = ecd;
	else
		hlt = TRUE;
	return;
}
Ejemplo n.º 7
0
int main(int argc, char ** argv) {
	
	std::string path, 
				rgbFilename("RGB_%07d.ppm"), 
				depthFilename("depth_%07d.pfm"),
				timeFilename("TimeSampling.dat");

	if (argc>1){
		path = argv[1];
	}
	else {
		std::cerr << "ERROR Usage : " << argv[0] << " pathname" << std::endl;
		return -1;
	}
	
	try {
    	Freenect::Freenect freenect;
    
    	vpKinect & kinect = freenect.createDevice<vpKinect>(0);
    	// Start acquisition thread with a depth map resolution of 480x640
    	kinect.start(vpKinect::DMAP_MEDIUM_RES); 
    
    	vpImage<unsigned char> Idmap(480,640);//for medium resolution
    	vpImage<float> dmap(480,640);//for medium resolution
    	vpImage<vpRGBa> Irgb(480,640);
    	
		  vpDisplayX display, displayRgb;
		  display.init(Idmap, 100, 200,"Depth map");
		  displayRgb.init(Irgb, 900, 200,"Color Image");

      //init val
      int index(0);
      struct timeval now ;
      
      //open time file
      std::string timeFullPath = path + "/"+ timeFilename; 
      std::ofstream file(timeFullPath.c_str(), std::ios::out);
      int precision(15);
       
      // A click to stop acquisition
      std::cout << "Click in one image to stop acquisition" << std::endl;
      while(!vpDisplay::getClick(Idmap,false) && !vpDisplay::getClick(Irgb,false)){
        kinect.getDepthMap(dmap);
        kinect.getDepthMap(dmap, Idmap);
        kinect.getRGB(Irgb);
        
        // get the current time
        gettimeofday(&now,NULL);
        double kinectTime = now.tv_sec + ((double)now.tv_usec)/1000000.0;
        
        if(file){
	  			    file << index << "\t";
              file << std::setprecision(precision) <<kinectTime << "\n";	 
			      }
 
        
        vpDisplay::display(Idmap);
        vpDisplay::flush(Idmap);
        vpDisplay::display(Irgb);
        vpDisplay::flush(Irgb);
        
        // save the depth image
        std::string depthPath = path+"/"+depthFilename;
        char buf[100];
        sprintf(buf,depthPath.c_str(),index);
        std::string depthFullPath(buf);
        std::cout << "Write in : " << depthFullPath << std::endl;
        try{
          vpImageIo::writePFM(dmap,depthFullPath.c_str());
        }
        catch(...){
              std::cout << "Catch an exception when writing image " << depthFullPath << std::endl;
        }
        //save the color image
        std::string rgbPath = path+"/"+rgbFilename;
        sprintf(buf,rgbPath.c_str(),index);
        std::string rgbFullPath(buf);
        std::cout << "Write in : " << rgbFullPath << std::endl;
        try{
          vpImageIo::writePPM(Irgb,rgbFullPath.c_str());
        }
        catch(...){
              std::cout << "Catch an exception when writing image " << rgbFullPath << std::endl;
        }
        
      index++;
		}
    
		std::cout << "Stop acquisition" << std::endl;
		kinect.stop(); // Stop acquisition thread
    if  (file) file.close();
		return 0;
	}	
	catch(vpException e) {
		std::cout << "Catch an exception: " << e << std::endl;
		return 1;
	}
	catch(...){
		std::cout << "Catch an exception " << std::endl;
		return 1;
	}
}
Ejemplo n.º 8
0
 icycle()
{
int op,a1,a2,x1,x2,i1,i2,setting,setmask,onemask,oldmask;
int fault;	
char pop [6];

	if((fault=setjmp(svstck)) != 0) 
		{ 
		if (fault == PAGEFLT)
			printf ("\nPage Fault.\n");
		if (fault == SEGMFLT)
			printf ("\nSegmentation Fault.\n");
		hlt = TRUE;
		return;
		}

	/*  setjmp(svstck) to save stack for return	*/
	/*  from possible segment and page faults	*/
	ir = pm[cmap(pc)];
	pc++;
	/*  extract instruction fields into op, a1, a2;	*/
	/*  generate the eff. virtual addresses v1, v2	*/
	/*  using the algorithm in the Reference Manual	*/
	op = extract(ir,24,6);
	strcpy(pop,ir_val[op]);
printf ("***** POP: %s\n",pop);
	a1 = extract(ir,12,10);
	a2 = extract(ir,0,10);
	x1 = extract(ir,22,1);
	x2 = extract(ir,10,1);
	i1 = extract(ir,23,1);
	i2 = extract(ir,11,1);
	
 	v1 = a1;
	v2 = a2;	/*  address field forms initial value 	*/
	if (i1 == 1) v1 = pm[dmap(v1)];	/*  if indirection, get ind. loc */
	if (i2 == 1) v2 = pm[dmap(v2)];	
	if (x1 == 1) v1 = v1 + xr;	/*  if indexing specified, add xr */		
	if (x2 == 1) v2 = v2 + xr;

	

	switch(op)
	{
case 1:	gr = pm[dmap(v1)];		/*  gr load		*/
	break;
case 2: pm[dmap(v1)] = gr;		/*  gr store		*/
	break;
case 3: xr = pm[dmap(v1)];		/* xr load		*/
	break;
case 4: pm[dmap(v1)] = xr;		/* xr store		*/
	break;
case 5: sr = pm[dmap(v1)];		/* sr load		*/
	break;
case 6: pm[dmap(v1)] = sr;		/* sr store		*/
	break;
case 8: pm[dmap(v2)] = pm[dmap(v1)];	/* copy			*/
	break;
case 9: pm[dmap(v2)] += pm[dmap(v1)];	/* add			*/
	break;
case 10: pm[dmap(v2)] -= pm[dmap(v1)];	/* subtract		*/
	break;
case 11: pm[dmap(v2)] *= pm[dmap(v1)];	/* multiply		*/
	break;
case 12:  if (pm[dmap(v1)] == 0) hlt=TRUE;      /*  divide      */
        else pm[dmap(v2)] /= pm[dmap(v1)];
        break;
case 13: pm[dmap(v2)] &= pm[dmap(v1)];	/* and			*/
	break;
case 14: pm[dmap(v2)] |= pm[dmap(v1)];	/* or			*/
	break;
case 16: pc = v1;			/* go to		*/
	break;
case 17: if (pm[dmap(v1)] != pm[dmap(v2)]) pc++;  /* if =	*/
	break;
case 18:  if (pm[dmap(v1)] == pm[dmap(v2)]) pc++; /* if !=	*/
	break;
case 19:  if (pm[dmap(v1)] >= pm[dmap(v2)]) pc++; /* if <	*/
	break;
case 20: if (pm[dmap(v1)] < pm[dmap(v2)]) pc++;	  /* if >=	*/
	break;
case 21: xr++;				/*  loop		*/
	 if (xr < pm[dmap(v1)]) pc = v2;
	break;
case 22: sr = pc;
	 pc = v1;			/* call			*/
	 break;
case 23:  pc = sr + pm[dmap(v1)];	/* return		*/
	 break;
case 26: xr = v1;			/* xr set		*/
	 break;
case 27: pm[dmap(v2)] = v1;		/* vm set		*/
	 break;
case 28: pm[dmap(v2)] = extract(pm[dmap(v1 + gr/4)],(gr%4)*8,8);	/* get byte	*/
	 break;
case 29:  setting =  extract(pm[dmap(v2)],0, 8); 	/* set byte */
	 setmask = setting << (gr%4)*8;			/* byte want to set in pos with 0's 
other */
 	 onemask = 0xFFFFFFFF - (0xFF <<  (gr%4) * 8);  /* mask with ones 'cept 0's in pos. */
	 oldmask = pm[dmap(v1+(gr/4))] & onemask;	/* old value of word with 0's in pos */
	 pm[dmap(v1+(gr/4))] = oldmask | setmask;	/* new word to write to memory */
	 break;


/*case 29: pm[dmap(v1 + gr)] = 0x00FFFFFF & pm[dmap(v1 + gr)] extract(pm[dmap(v2)],0,8);
*/
	/* put byte */
/*	 break; */


case 31: ;				/* noop			*/
	 break;
case 32: hlt = TRUE;			/* halt			*/
	 break;
default:  hlt = TRUE;				/* unused op	*/
	break;
	}
}
Ejemplo n.º 9
0
int main() {
  try {
    // Init Kinect
#ifdef VISP_HAVE_LIBFREENECT_OLD
    // This is the way to initialize Freenect with an old version of libfreenect packages under ubuntu lucid 10.04
    Freenect::Freenect<vpKinect> freenect;
    vpKinect & kinect = freenect.createDevice(0);
#else
    Freenect::Freenect freenect;
    vpKinect & kinect = freenect.createDevice<vpKinect>(0);
#endif

    // Set tilt angle in degrees
    if (0) {
      float angle = -3;
      kinect.setTiltDegrees(angle);
    }

    // Init display
#if 1
    kinect.start(vpKinect::DMAP_MEDIUM_RES); // Start acquisition thread with a depth map resolution of 480x640
    vpImage<unsigned char> Idmap(480,640);//for medium resolution
    vpImage<float> dmap(480,640);//for medium resolution
#else
    kinect.start(vpKinect::DMAP_LOW_RES); // Start acquisition thread with a depth map resolution of 240x320 (default resolution)
    vpImage<unsigned char> Idmap(240,320);//for low resolution
    vpImage<float> dmap(240,320);//for low resolution
#endif
    vpImage<vpRGBa> Irgb(480,640),Iwarped(480,640);

#if defined VISP_HAVE_X11
    vpDisplayX display, displayRgb, displayRgbWarped;
#elif defined VISP_HAVE_GTK
    vpDisplayGTK display;
    vpDisplayGTK displayRgb;
    vpDisplayGTK displayRgbWarped;
#elif defined VISP_HAVE_OPENCV
    vpDisplayOpenCV display;
    vpDisplayOpenCV displayRgb;
    vpDisplayOpenCV displayRgbWarped;
#elif defined VISP_HAVE_GDI
    vpDisplayGDI display;
    vpDisplayGDI displayRgb;
    vpDisplayGDI displayRgbWarped;
#endif

    display.init(Idmap, 100, 200,"Depth map");
    displayRgb.init(Irgb, 900, 200,"Color Image");
    displayRgbWarped.init(Iwarped,900,700,"Warped Color Image");

    // A click to stop acquisition
    std::cout << "Click in one image to stop acquisition" << std::endl;

    while(!vpDisplay::getClick(Idmap,false) && !vpDisplay::getClick(Irgb,false))
    {
      kinect.getDepthMap(dmap);
      kinect.getDepthMap(dmap, Idmap);
      kinect.getRGB(Irgb);

      vpDisplay::display(Idmap);
      vpDisplay::flush(Idmap);
      vpDisplay::display(Irgb);
      vpDisplay::flush(Irgb);

      //Warped RGB image:
      kinect.warpRGBFrame(Irgb,dmap, Iwarped);
      vpDisplay::display(Iwarped);
      vpDisplay::flush(Iwarped);
    }
    std::cout << "Stop acquisition" << std::endl;
    kinect.stop(); // Stop acquisition thread
    return 0;
  }
  catch(vpException &e) {
    std::cout << "Catch an exception: " << e << std::endl;
    return 1;
  }
  catch(...) {
    std::cout << "Catch an exception " << std::endl;
    return 1;
  }
}
Ejemplo n.º 10
0
void
FMultiGrid::init_mgt_solver (PArray<MultiFab>& phi)
{
    BL_ASSERT(  m_bc.initilized || m_bndry != 0);
    BL_ASSERT(!(m_bc.initilized && m_bndry != 0));
    BL_ASSERT(m_coeff.eq_type != invalid_eq);
    BL_ASSERT(m_mgt_solver == 0);

    int ncomp = phi[0].nComp();

    std::vector<DistributionMapping> dmap(m_nlevels);
    std::vector<BoxArray> ba(m_nlevels);

    for (int ilev = 0; ilev < m_nlevels; ++ilev) 
    {
	dmap[ilev] = phi[ilev].DistributionMap();
	ba  [ilev] = phi[ilev].boxArray();
    }

    bool nodal = false;
    int  nc = 0;
    Array<int> mg_bc;
    if (m_bc.initilized) 
    {
	mg_bc = m_bc.mg_bc;
    } 
    else 
    {
	mg_bc.resize(2*BL_SPACEDIM);
	
	for ( int i = 0; i < BL_SPACEDIM; ++i )
        { 
            if ( m_geom[0].isPeriodic(i) )
            {
                mg_bc[i*2 + 0] = 0;
                mg_bc[i*2 + 1] = 0;
            }
            else
            {
                mg_bc[i*2 + 0] = m_bndry->phys_bc_lo(i)==Outflow? MGT_BC_DIR : MGT_BC_NEU;
                mg_bc[i*2 + 1] = m_bndry->phys_bc_hi(i)==Outflow? MGT_BC_DIR : MGT_BC_NEU;
            }
        }
    }

    RAII_mgt_solver.resize(1, PArrayManage);
    RAII_mgt_solver.set(0, new MGT_Solver (m_geom, mg_bc.dataPtr() , ba, dmap, nodal,
					   m_stencil, nodal, nc, ncomp, m_verbose));
    m_mgt_solver = &(RAII_mgt_solver[0]);

    if (m_maxorder > 0) m_mgt_solver->set_maxorder(m_maxorder);

    if (m_bndry == 0) {
	RAII_bndry.resize(1, PArrayManage);
	RAII_bndry.set(0, new MacBndry (ba[0], ncomp, m_geom[0]));
	m_bndry = &(RAII_bndry[0]);

	m_bc.set_bndry_values(*m_bndry, m_crse_ratio);
    }

    m_coeff.set_coeffs(*m_mgt_solver, *this);
}
Ejemplo n.º 11
0
/*!
 * This function applies the Jones matrices after each integration run.
 * In addition, exatra integration is performed between each set of matrices to simulate the
 * waveplates being a physical distance apart
 */
void jones_optical::post_ifft_operations(){
    //apply the jones matrices, and integration between them

    if(!jones_matrices.empty()){
        Eigen::Map<Eigen::Matrix<comp, 2, Eigen::Dynamic, Eigen::RowMajor>, Eigen::Aligned> dmap(ucur, 2, nts);
        //this is a more complicated structure but will save an fft/ifft combination
        dmap = jones_matrices[0]->mvals*dmap;
        for(size_t i = 1; i < jones_matrices.size(); i++){
            for(size_t j = 0; j < num_pulses; j++){
                fft(ucur+j*nts, ucur+j*nts, nts);
            }
            inter->integrate(ucur, tcur, tcur+jones_int_dist);
            for(size_t j = 0; j < num_pulses; j++){
                ifft(ucur+j*nts, ucur+j*nts, nts);
            }
            tcur+=jones_int_dist;
            dmap = jones_matrices[i]->mvals*dmap;
        }
    }
}