Exemple #1
0
int main () {

  struct KD_FUNC_PREFIX_kdtree *kd = KD_FUNC_PREFIX_kd_create(3, 3, 0.5);

  double pos[3] = {0.0, 0.0, 0.0};

  double t_start = ts_now();
  for(double x=0.0; x < 10; x += 0.5) {
    for(double y=0.0; y < 10; y += 0.5) {
      for(double z=0.0; z < 10; z += 0.5) {
	pos[0] = x;
	pos[1] = y;
	pos[2] = z;
	KD_FUNC_PREFIX_kd_insert(kd, pos, NULL);
      }
    }
  }
  double t_end = ts_now();

  printf("Inserted %d nodes in %f seconds (%f seconds/node)\n",
	 20*20*20, (t_end-t_start)/1000000.0, ((t_end-t_start)/1000000.0)/(20*20*20));

  pos[0] = 12.1;
  pos[1] = 12.1;
  pos[2] = 12.1;

  struct KD_FUNC_PREFIX_kdres *ret = KD_FUNC_PREFIX_kd_nearest(kd, pos);

  if(ret) {
    printf("%2.2f %2.2f %2.2f\n",
	   ret->rlist->next->item->points[0],
	   ret->rlist->next->item->points[1],
	   ret->rlist->next->item->points[2]);
  }

  double total_x = 0;
  double total_y = 0;
  double total_z = 0;

  for(int i=0; i < 10000; ++i) {
    KD_FUNC_PREFIX_kd_sample_pos(kd, pos);
    total_x += pos[0];
    total_y += pos[1];
    total_z += pos[2];
  }

  printf("Average sample: %2.2f, %2.2f, %2.2f\n",
	 total_x/10000.0,
	 total_y/10000.0,
	 total_z/10000.0);

  KD_FUNC_PREFIX_kd_free(kd);
  return 1;
}
void *thread_2(void *ptr) {
    
//     const struct aiScene* ai_scene2 = aiImportFile("../../unitTesting/cube.3ds",aiProcessPreset_TargetRealtime_Quality);
    const struct aiScene* ai_scene2 = aiImportFile(OBJECT_TO_DISPLAY,aiProcessPreset_TargetRealtime_Quality);
    
    if (global_pointer) {
// 	global_pointer->addObject(ai_scene2, "cube2");
    }
    
    int64_t time_start = ts_now();
    
    while(1) {
	aiVector3D vshift( 10.0* sin( ((double) (ts_now() - time_start)) / 1000000.0 ), 0.0, 0.0 );
	aiMatrix4x4 matr;
	aiMatrix4x4::Translation(vshift, matr);     
	ai_scene2->mRootNode->mTransformation = matr;
    }
    
    return NULL;
}
Exemple #3
0
std::ostream& Debug::printTraceOut(
	const char _t,
	unsigned _module,
	const char *_file,
	const char *_fnc,
	int _line
){
	d.m.lock();
	if(d.respinsz && d.respinsz <= d.sz){
		d.doRespin();
	}
	char		buf[128];
	TimeSpec	ts_now(TimeSpec::createRealTime());
	time_t		t_now = ts_now.seconds();
	tm			*ploctm;
#ifdef ON_WINDOWS
	ploctm = localtime(&t_now);
#else
	tm			loctm;
	ploctm = localtime_r(&t_now, &loctm);
#endif
	sprintf(
		buf,
		"%c[%04u-%02u-%02u %02u:%02u:%02u.%03u]",
		_t,
		ploctm->tm_year + 1900,
		ploctm->tm_mon + 1, 
		ploctm->tm_mday,
		ploctm->tm_hour,
		ploctm->tm_min,
		ploctm->tm_sec,
		(uint)ts_now.nanoSeconds()/1000000//,
		//d.nv[_module],
		//Thread::currentId()
	);
	(*d.pos)<<buf;
	--d.trace_debth;
	d.pos->write(tabs, d.trace_debth);
#ifdef ON_WINDOWS
	(*d.pos)<<'['<<d.modvec[_module].name<<']'<<'['<<src_file_name(_file)<<':'<<_line<<"]["<<Thread::currentId()<<']'<<' '<<'}'<<_fnc<<'(';
#else
	(*d.pos)<<'['<<d.modvec[_module].name<<']'<<'['<<src_file_name(_file)<<':'<<_line<<"][0x"<<std::hex<<Thread::currentId()<<std::dec<<']'<<' '<<'}'<<_fnc<<'(';
#endif
	return (*d.pos);
}