本文整理汇总了C++中std::deque::pop_front方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::pop_front方法的具体用法?C++ deque::pop_front怎么用?C++ deque::pop_front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::deque
的用法示例。
在下文中一共展示了deque::pop_front方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
void display()
{
glDrawPixels(windowWidth,windowHeight,GL_RGB,GL_FLOAT,image.data());
if(t<=1.0)
{
glBegin(GL_LINES);
for(unsigned int c = 0 ; c < vertices.size() ; ++c)
{
glVertex2fv(vertices[c].v1);
glVertex2fv(vertices[c].v1 + t*directions[c].v1);
glVertex2fv(vertices[c].v2);
glVertex2fv(vertices[c].v2 + t*directions[c].v2);
glVertex2fv(vertices[c].v3);
glVertex2fv(vertices[c].v3 + t*directions[c].v3);
} // end for
glEnd();
t += 0.030f;
}
else
{
t = 0.0;
glBegin(GL_TRIANGLES);
for(unsigned int c = 0 ; c < vertices.size() ; ++c)
{
glVertex2fv(vertices[c].v1);
glVertex2fv(vertices[c].v2);
glVertex2fv(vertices[c].v3);
} // end for
glEnd();
vertices.clear();
directions.clear();
// start new level
while(nCurrentLevel--) // foreach triangle in this level
{
// calculate center triangle's vertices
Triangle &t = triangles.front(); // does not remove the head element of the queue
Vector2D<float> c1 = (t.v1+t.v2)/2;
Vector2D<float> c2 = (t.v2+t.v3)/2;
Vector2D<float> c3 = (t.v3+t.v1)/2;
// register center triangle
vertices.push_back(Triangle(c1,c2,c3));
directions.push_back(Triangle(c2-c1,c3-c2,c1-c3));
// put smaller triangles in the queue
triangles.push_back(Triangle(t.v1,c1,c3));
triangles.push_back(Triangle(c1,t.v2,c2));
triangles.push_back(Triangle(c3,c2,t.v3));
// discard used triangle
triangles.pop_front();
nNextLevel += 3;
} // end while
nCurrentLevel = nNextLevel;
nNextLevel = 0;
++level;
glReadPixels(0,0,windowWidth,windowHeight,GL_RGB,GL_FLOAT,image.data());
if(level > levels)
glutDisplayFunc(simpleDisplay);
} // end else
glutSwapBuffers();
} // end function display
示例2: PriorityNoPre
void PriorityNoPre(){
out << alg.name << std::endl;
int timer = 0;
//who is ready at 0 seconds, add to priority
while(!master.empty()){
struct Qu t = master.front();
if(t.arrival_time == 0) priority.push_back(t);
else waiting.push(t);
master.pop();
}
while(completed.size() != alg.number_of_proc){
int flag_inner = 0;
//sort lowest cpu first
int min_cpu;
while(!priority.empty()){
flag_inner = 1;
if(priority.size() == 1){
ready.push(priority.front());
priority.pop_front();
}
else{
//if priority is bigger than 1, then need to sort
int s = priority.size();
struct Qu t[s];
int i = 0;
while(!priority.empty()){
t[i] = priority.front();
++i;
priority.pop_front();
}
//sort in array, then add back to prioroity
int j;
for(j=0; j<s; ++j){
int k;
for(k=1; k<s; ++k){
if(t[j].priority>t[k].priority && j<k){
struct Qu u = t[j];
t[j] = t[k];
t[k] = u;
} } }
for(j=0; j<s; ++j) ready.push(t[j]);
}
}
//now in ready, run all, set var, timer
while(!ready.empty()){
flag_inner = 1;
ready.front().time_start = timer;
out << timer << "\t" << ready.front().proc_num << std::endl;
while(ready.front().cpu_burst != 0){
--ready.front().cpu_burst;
++timer;
}
ready_to_completed(timer);
}
//increment timer
if(flag_inner == 1) flag_inner = 0;
else ++timer;
int i;
for(i=0; i<waiting.size(); ++i){
if(waiting.front().arrival_time <= timer){
priority.push_back(waiting.front());
waiting.pop();
--i;
} }
}
//calculate waiting time, sum of all starts
double total_w = 0;
while(!completed.empty()){
total_w += completed.front().time_start;
completed.pop();
}
total_w /= alg.number_of_proc;
out << std::setprecision(3) << "AVG Waiting Time: " << total_w << std::endl;
}
示例3: lookahead_pop
static wint_t lookahead_pop(void)
{
wint_t result = lookahead_list.front();
lookahead_list.pop_front();
return result;
}
示例4: main
//.........这里部分代码省略.........
std::cerr << "Hub exited..." << std::endl;
delete hub;
}));
}
if (!fromVistle) {
boost::mpi::broadcast(boost::mpi::communicator(), rank0, 0);
boost::mpi::broadcast(boost::mpi::communicator(), port, 0);
boost::mpi::broadcast(boost::mpi::communicator(), dataPort, 0);
args.push_back(rank0);
args.push_back(std::to_string(port));
args.push_back(std::to_string(dataPort));
}
#else
if (!fromVistle) {
std::cerr << "should be called from vistle, expecting 1st argument to be -from-vistle" << std::endl;
exit(1);
}
#endif
#ifdef COVER_ON_MAINTHREAD
#if defined(HAVE_QT) && defined(MODULE_THREAD)
if (!qApp) {
std::cerr << "early creation of QApplication object" << std::endl;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
if (xcb_connection_t *xconn = xcb_connect(nullptr, nullptr))
{
if (!xcb_connection_has_error(xconn)) {
std::cerr << "X11 connection!" << std::endl;
IceSetIOErrorHandler(&iceIOErrorHandler);
auto app = new QApplication(argc, argv);
}
xcb_disconnect(xconn);
}
#else
auto app = new QApplication(argc, argv);
#endif
if (qApp) {
qApp->setAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
QIcon icon(":/icons/vistle.png");
qApp->setWindowIcon(icon);
}
}
#endif
auto t = std::thread([args](){
#endif
try {
vistle::registerTypes();
std::vector<char *> argv;
for (auto &a: args) {
argv.push_back(const_cast<char *>(a.data()));
std::cerr << "arg: " << a << std::endl;
}
Vistle(argv.size(), argv.data()).run();
} catch(vistle::exception &e) {
std::cerr << "fatal exception: " << e.what() << std::endl << e.where() << std::endl;
exit(1);
} catch(std::exception &e) {
std::cerr << "fatal exception: " << e.what() << std::endl;
exit(1);
}
#ifdef COVER_ON_MAINTHREAD
std::unique_lock<std::mutex> lock(main_thread_mutex);
main_done = true;
main_thread_cv.notify_all();
});
for (;;) {
std::unique_lock<std::mutex> lock(main_thread_mutex);
main_thread_cv.wait(lock, []{ return main_done || !main_func.empty(); });
if (main_done) {
//main_thread_cv.notify_all();
break;
}
std::function<void()> f;
if (!main_func.empty()) {
std::cerr << "executing on main thread..." << std::endl;
f = main_func.front();
if (f)
f();
main_func.pop_front();
}
lock.unlock();
main_thread_cv.notify_all();
}
t.join();
#endif
MPI_Finalize();
return 0;
}
示例5: requeue
static void requeue(std::deque<int> &trg, std::deque<int> &src)
{
trg.push_back(src.front());
src.pop_front();
}
示例6: clean
void clean(int ts) {
int i = ts - 300;
while (m_cnter.size() && m_cnter.front() <= i) {
m_cnter.pop_front();
}
}
示例7: Update
void JoystickHistoryView::Update(const InputState &input_state) {
locations_.push_back(Location(curX_, curY_));
if ((int)locations_.size() > maxCount_) {
locations_.pop_front();
}
}
示例8: GenerateFaceIndicators
void GenerateFaceIndicators(const int &sampleIdx,
std::vector<double> &eyesHeightVec,
FaceFeature &faceFeatures,
std::deque<InfoPERCLOS> &PERCLOSDeque,
std::deque<InfoBLINK> &BLINKDeque,
const double &intervalTime)
{
double eyesHeight = 0, lastEyesHeight = faceFeatures.lastHeight;
double PERCLOS = 0, MICROSLEEP = 0, MICROSLEEPTime = faceFeatures.MICROSLEEPTime, BLINK = 0;
double eyesHeight_b = faceFeatures.Height_Baseline;
//Find the min size between two eyes.
if (!eyesHeightVec.empty()) {
sort(eyesHeightVec.begin(), eyesHeightVec.end(), SortBigger);
eyesHeight = eyesHeightVec.front();
if(eyesHeight > 2*eyesHeight_b )
eyesHeight = 2*eyesHeight_b;
}
else {
//Negative, if can NOT detect eyes correctly
eyesHeight = lastEyesHeight;
}
/*********************************************/
/* PERCLOS: Percentage of eye closure */
/*********************************************/
InfoPERCLOS perclosInfo;
perclosInfo.time = intervalTime;
if(!PERCLOSDeque.empty()){
/// Calculate the number of frames in fixed time
if (eyesHeight < faceFeatures.Height_Baseline * THRESHOLD_PERCLOS) {
perclosInfo.eyePERCLOS = 1; // eye closed
perclosInfo.timePERCLOS = PERCLOSDeque.back().timePERCLOS +intervalTime;
}
else {
perclosInfo.eyePERCLOS = 0;
perclosInfo.timePERCLOS = PERCLOSDeque.back().timePERCLOS;
}
perclosInfo.winTimePERCLOS = PERCLOSDeque.back().winTimePERCLOS + intervalTime;
//! Only focus on the fixed time interval.
while(perclosInfo.winTimePERCLOS > TIME_PERCLOS_WINDOW)
{
perclosInfo.winTimePERCLOS -= PERCLOSDeque.front().time;
if(PERCLOSDeque.front().eyePERCLOS == 1)
{
perclosInfo.timePERCLOS -= PERCLOSDeque.front().time;
}
PERCLOSDeque.pop_front();
}
//cout << "time PERCLOS: " << perclosInfo.timePERCLOS << endl;
}
else
{// The first frames without any PERCLOSInfo
if (eyesHeight < faceFeatures.Height_Baseline * THRESHOLD_PERCLOS) {
perclosInfo.eyePERCLOS = 1;
perclosInfo.timePERCLOS = intervalTime;
}
else {
perclosInfo.eyePERCLOS = 0;
perclosInfo.timePERCLOS = 0;
}
perclosInfo.winTimePERCLOS = intervalTime;
}
PERCLOSDeque.push_back(perclosInfo);
//! PERCLOS
if(perclosInfo.winTimePERCLOS < TIME_PERCLOS_WINDOW / 2)
PERCLOS = 0;//In first time interval too high value
else
PERCLOS = perclosInfo.timePERCLOS / perclosInfo.winTimePERCLOS;
/************************************************/
/* Statistics of Continuous Eye Closure */
/* MICROSLEEP: ND: 0~0.5 */
/* SD: 0.5~1 */
/* MD: 1~2 */
/* VD: 2~4 */
/* ED: 4~ */
/************************************************/
if (eyesHeight < faceFeatures.Height_Baseline * THRESHOLD_CLOSURE) {
MICROSLEEPTime += intervalTime;
}
else {
MICROSLEEPTime -= intervalTime;
MICROSLEEPTime = MICROSLEEPTime > 0 ? MICROSLEEPTime : 0;
}
//! When MICROSLEEPTime not equal to 0, Update the MICROSLEEP
if (MICROSLEEPTime < 0.5)
MICROSLEEP = 0.25 * MICROSLEEPTime; //Alert
else if (MICROSLEEPTime >= 0.5 && MICROSLEEPTime < 1)
MICROSLEEP = 0.5 * MICROSLEEPTime - 0.125; //Slightly Drowsy
else if (MICROSLEEPTime >= 1 && MICROSLEEPTime < 2)
MICROSLEEP = 0.25 * MICROSLEEPTime + 0.125; //Moderately Drowsy
else if(MICROSLEEPTime >= 2 && MICROSLEEPTime < 4)
MICROSLEEP = 0.125 * MICROSLEEPTime + 0.375; //Very Drowsy
else if(MICROSLEEPTime >= 4 && MICROSLEEPTime < 5)
//.........这里部分代码省略.........
示例9: init
bool init()
{
//Initialization flag
bool success = true;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 )
{
printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else
{
//Set texture filtering to linear
if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
{
printf( "Warning: Linear texture filtering not enabled!" );
}
//Create window
gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( gWindow == nullptr )
{
printf( "Window could not be created! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else
{
//Create renderer for window
gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED );
if( gRenderer == nullptr )
{
printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
success = false;
}
else
{
//Initialize renderer color
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
texture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, CHIP8_W,CHIP8_H);
if (!texture) {
printf("texture could not initialize!\n");
success = false;
} else {
//Initialize SDL_audio
SDL_AudioSpec spec;
spec.freq = 44100;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.samples = spec.freq / 20; // 0.05 seconds of latency
spec.callback = [] (void*, Uint8* stream, int len)
{
// Generate square wave
short* target = (short*)stream;
while(len > 0 && !AudioQueue.empty())
{
auto& data = AudioQueue.front();
for(; len && data.first; target += 2, len -= 4, --data.first)
target[0] = target[1] = data.second*300*((len&128)-64);
if(!data.first) AudioQueue.pop_front();
}
};
if(SDL_OpenAudio(&spec, &obtained) != 0 ) {
printf( "SDL_audio could not initialize! SDL_mixer Error: %s\n", SDL_GetError());
success = false;
}
SDL_PauseAudio(0);
}
}
}
}
return success;
}
示例10: simulate
void TransIcelandicExpress::simulate() {
sgVec3 fwd, right, up, frict, v;
sgVec3 playerForce;
float cf_accel = 1.0, // m/s^2
maxVel = 0.5, // m/2
cf_friction_land = 8.0,
cf_friction_ice = 5.0;
float pv,
ff; // friction fudge... more friction for slow objects
float timestep = 0.01f;
static float timeleft = 0.0f;
timeleft += deltaT;
sgSetVec3( up, 0.0, 1.0, 0.0 );
sgSetVec3( playerForce, 0.0, 0.0, 0.0 );
while (timeleft > timestep) {
sgCopyVec3( fwd, cameraPos );
sgNegateVec3( fwd );
fwd[1] = 0.0;
sgNormalizeVec3( fwd );
sgVectorProductVec3( right, fwd, up );
// todo: if on the ground
sgScaleVec3( fwd, cf_moveForward );
sgAddVec3( playerForce, fwd );
sgScaleVec3( right, cf_moveSideways );
sgAddVec3( playerForce, right );
sgScaleVec3( playerForce, cf_accel * timestep );
sgAddVec3( player->vel, playerForce );
pv = sgLengthVec3( player->vel ) ;
ff = (1.0 - ((pv / maxVel)* 0.8));
ff = ff*ff;
sgCopyVec3( frict, player->vel );
sgNegateVec3( frict );
sgScaleVec3( frict, ff * cf_friction_ice * timestep );
sgAddVec3( player->vel, frict );
dbgVel.push_back( pv );
if (dbgVel.size() > 100 ) {
dbgVel.pop_front();
}
if ( pv > maxVel ) {
//printf("maxvel!\n" );
sgNormalizeVec3( player->vel );
sgScaleVec3( player->vel, maxVel );
}
sgCopyVec3( v, player->vel );
sgScaleVec3( v, timestep );
sgAddVec3( player->pos, v );
// advance
timeleft -= timestep;
}
player->pos[1] = getHeight( player->pos );
}
示例11: PopFront
gfx::Polygon3D PopFront(std::deque<gfx::Polygon3D>& aPolygons)
{
gfx::Polygon3D polygon = std::move(aPolygons.front());
aPolygons.pop_front();
return polygon;
}
示例12: sio_read
int sio_read(std::string &result, int timeout, int pollfd) {
int once = 1;
GLOB_LOCK();
if (!postponed.empty()) {
result = postponed.front();
postponed.pop_front();
//printf("accepted: [%s] (%d)\n", result.c_str(), postponed.size());
GLOB_UNLOCK();
return result.length();
};
if (inside_read) {
GLOB_UNLOCK();
sio_write(SIO_ERROR, "recursive sio_read");
return -1;
};
int64 stoptime = time64() + timeout*1000;
while (once || (stoptime > time64())) {
once = 0;
int eol_pos = readbuf.find(eol_char);
if (eol_pos != std::string::npos) {
result = readbuf.substr(0, eol_pos);
readbuf = readbuf.substr(eol_pos+1);
if (sio_commdump & 2) {
printf("READ\t%s\n", result.c_str());
};
GLOB_UNLOCK();
int rv = _sio_handlemsg(result); // might call other functs
if (rv == 0) {
GLOB_LOCK();
continue;
};
if (rv < 0) return rv;
return result.length();
};
inside_read = 1;
GLOB_UNLOCK();
// wait for some more data...
fd_set fdr; struct timeval tv;
int delta = (int)( (stoptime - time64()) / 1000 );
if (delta < 0) delta = 0;
tv.tv_sec = delta/1000; tv.tv_usec = (delta%1000)*1000;
FD_ZERO(&fdr); FD_SET(ser_fd_read, &fdr);
if (pollfd!=-1) FD_SET(pollfd, &fdr);
int rv = select(max(ser_fd_read, pollfd)+1, &fdr, 0, 0, (timeout>=0)?&tv:0);
if ( (rv<0) && (errno != EINTR) ) {
inside_read = 0;
return -1; // error
};
if (pollfd != -1) if (FD_ISSET(pollfd, &fdr)) {
inside_read = 0;
return -3; // pollfd is select'ed
};
GLOB_LOCK();
inside_read = 0;
char bf[257];
rv = read(ser_fd_read, bf, sizeof(bf)-1);
if ( (rv<=0) && (errno!=EINTR) && (errno != EAGAIN)) {
GLOB_UNLOCK();
return -1; // error or timeout
};
if (rv<0) continue;
if (rv==0) {
GLOB_UNLOCK();
return -1; // EOF from server
};
bf[rv]=0;
//printf("\n\nREAD[[[%s]]]\n", bf);
readbuf = readbuf + bf;
};
GLOB_UNLOCK();
return 0; // timeout
};
示例13: build
void Regex::build(std::deque<Regex::Composition>& tokens) {
// Expands tokens until [min,max] = [0,1] or [1,1] or [0,inf] for all of them
std::deque<Composition> newList;
auto normalizeToken = [&](const Composition& token, bool push) {
Composition newToken;
newToken.pattern = token.pattern;
newToken.min = (token.min == 0) ? 0 : token.min - 1;
newToken.max = (token.max == -1) ? -1 : token.max - 1;
if (token.min == 0 && token.max == -1) {
newToken.ready = true;
}
newToken.nestingLevel = token.nestingLevel;
newToken.special = token.special;
if (push) {
newList.push_back(std::move(token));
}
tokens.pop_front();
tokens.push_front(std::move(newToken));
};
while (!tokens.empty()) {
Composition& token = tokens.front();
if ((token.min != 0 || token.max != 1)
&& (token.min != 1 || token.max != 1)
&& !token.ready) {
bool push = true;
if (token.pattern == PATTERN_CONTEXT_END) {
// The multiplier applies to the group
std::size_t currSize = newList.size();
std::size_t index = currSize - 1;
int level = 0;
for (auto& t : utils::make_reverse(newList)) {
if (t.pattern == PATTERN_CONTEXT_START && level == 0) {
break;
} else if (t.pattern == PATTERN_CONTEXT_START) {
level--;
} else if (t.pattern == PATTERN_CONTEXT_END) {
level++;
}
index--;
}
newList.push_back(token);
while (index < currSize) {
newList.push_back(newList[index]);
index++;
}
push = false;
}
normalizeToken(token, push);
} else {
newList.push_back(std::move(token));
tokens.pop_front();
}
}
tokens.swap(newList);
std::size_t i = 0;
std::size_t size = tokens.size();
// Links all closing brackets to its opening counterparts
std::unordered_map<std::size_t, std::size_t> bracketOpenings;
std::stack<std::size_t> bracketStack;
while (i < size) {
if (tokens[i].pattern == PATTERN_CONTEXT_START) {
bracketStack.push(i);
} else if (tokens[i].pattern == PATTERN_CONTEXT_END) {
assert(!bracketStack.empty());
bracketOpenings[i] = bracketStack.top();
bracketStack.pop();
}
i++;
}
assert(bracketStack.empty());
i = 0;
// Calculates all next references
while (i < size - 1) {
if (tokens[i].pattern == PATTERN_CONTEXT_START) {
// Context-starters point to the starting symbol of all branches
tokens[i].next.push_back(i + 1);
unsigned level = tokens[i].nestingLevel;
std::size_t j = i + 1;
while (tokens[j].nestingLevel >= level && j < size) {
if (tokens[j].nestingLevel == level && tokens[j].pattern == PATTERN_OR) {
tokens[i].next.push_back(j + 1);
}
j++;
}
} else if (tokens[i + 1].pattern != PATTERN_OR) {
// Simple symbols point to the next symbol
tokens[i].next = {i + 1};
} else {
// The | operator points to the next )
std::size_t j = i + 1;
int count = 0;
// Will always find a match since the last token is a )
while (count > 0 || tokens[j].pattern != PATTERN_CONTEXT_END) {
if (tokens[j].pattern == PATTERN_CONTEXT_START) {
count++;
} else if (tokens[j].pattern == PATTERN_CONTEXT_END) {
//.........这里部分代码省略.........
示例14: execute
void IrrealVM :: execute( uint64_t thread_id ){
//if( global_vm_queue.size() < 1 ){ return; }
pthread_mutex_lock( &global_vm_queue_lock );
if( global_vm_queue.size() < 1 ){
pthread_mutex_unlock( &global_vm_queue_lock );
return;
}
uint64_t ctx_id = global_vm_queue.front();
global_vm_queue.pop_front();
IrrealContext *ctx = global_contexts[ ctx_id ];
pthread_mutex_unlock( &global_vm_queue_lock );
test_for_error( ctx == NULL, "Invalid context!" );
ctx->lock_context();
global_running_threads_vm[ thread_id ] = ctx_id;
//printf( "Executing vm #%lu\n", ctx_id );
//_debug_running_threads();
IrrealStack *current, *code;
current = ctx->getCurrentStack();
code = ctx->getCodeStack();
test_for_error( current == NULL, "Invalid current stack!" );
test_for_error( code == NULL, "Invalid code stack!" );
uint8_t state = ctx->getState();
switch( state ){
case STATE_JOINING:
if( !current->isJoined() ){
pthread_mutex_lock( &global_vm_queue_lock );
global_vm_queue.push_back( ctx_id );
pthread_mutex_unlock( &global_vm_queue_lock );
ctx->mark();
ctx->unlock_context();
return;
}
break;
case STATE_SYNCING:
test_for_error( current->peek() == NULL, "Not enough values to perform 'sync'!" );
//printf( "syncing... ('%s')\n", current->peek()->getValue().c_str() );
if( current->peek()->getState() == STATE_NOT_YET ){
pthread_mutex_lock( &global_vm_queue_lock );
global_vm_queue.push_back( ctx_id );
pthread_mutex_unlock( &global_vm_queue_lock );
ctx->mark();
ctx->unlock_context();
return;
}
//printf( "Data synced, now continuing... \n" );
break;
}
std::string anon_name;
bool anon_state = false;
uint64_t begin_end_counter = 0;
bool done = false;
IrrealStack *anon_stack = NULL;
long int debug_value;
IrrealStack *debug_stack;
debug_value = ctx->getStack("PARAMS")->size();
debug_stack = ctx->getStack("PARAMS");
while( !done ){
ctx->mark();
//printf( "\n\n" );
IrrealValue *q = code->pop();
//printf( "current: " ); current->_debug_print();
//printf( "params: " ); ctx->getStack("PARAMS")->_debug_print();
//printf( "out: " ); ctx->getStack("OUT")->_debug_print();
if( q == NULL ){
//printf( "q == NULL\n" );
done = true;
if( ctx->getReturnValue() != NULL ){
//printf( "Returning value! ('%s')\n", ctx->getReturnValue()->getValue().c_str() );
ctx->getStack( ctx->getReturnValue()->getValue() )->merge( ctx->getStack( "OUT" ), false );
ctx->getReturnValue()->setType( TYPE_SYMBOL );
ctx->getReturnValue()->setState( STATE_OK );
//.........这里部分代码省略.........
示例15: processCloud
void processCloud(const sensor_msgs::PointCloud2 msg)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr curr_pc (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCLPointCloud2 cloud;
pcl::PointCloud<pcl::PointXYZ> pcl_pc;
std::vector<int> nan_indices;
pcl::PointCloud<pcl::PointXYZ>::Ptr prev_pc (new pcl::PointCloud<pcl::PointXYZ>);
//********* Retirive and process raw pointcloud************
pcl_conversions::toPCL(msg,cloud);
pcl::fromPCLPointCloud2(cloud,pcl_pc);
pcl::removeNaNFromPointCloud(pcl_pc,pcl_pc,nan_indices);
*curr_pc =pcl_pc;
//*********** Remove old data, update the data***************
cloud_seq_loaded.push_back(pcl_pc);
std::cout<<cloud_seq_loaded.size()<<std::endl;
if(cloud_seq_loaded.size()>2){
cloud_seq_loaded.pop_front();
}
if(cloud_seq_loaded.size()==1){
static_pc = pcl_pc;
}
//*********** Process currently observerd and buffered data*********
if(cloud_seq_loaded.size()==2){
*prev_pc =static_pc; //cloud_seq_loaded.front(); ss
//*************Create octree structure and search
pcl::octree::OctreePointCloudChangeDetector<pcl::PointXYZ> octree (0.5);
octree.setInputCloud(prev_pc);
octree.addPointsFromInputCloud();
octree.switchBuffers();
octree.setInputCloud(curr_pc);
octree.addPointsFromInputCloud();
std::vector<int> newPointIdxVector;
// Get vector of point indices from octree voxels which did not exist in previous buffer
octree.getPointIndicesFromNewVoxels (newPointIdxVector);
std::cout << "Output from getPointIndicesFromNewVoxels:" << std::endl;
pcl::PointCloud<pcl::PointXYZ>::Ptr dynamic_points (new pcl::PointCloud<pcl::PointXYZ>);
dynamic_points->header.frame_id = "some_tf_frame";
for (size_t i = 0; i < newPointIdxVector.size (); ++i){
pcl::PointXYZ point;
point.x = pcl_pc.points[newPointIdxVector[i]].x;
point.y = pcl_pc.points[newPointIdxVector[i]].y;
point.z = pcl_pc.points[newPointIdxVector[i]].z;
dynamic_points->push_back(point);
//std::cout << i << "# Index:" << newPointIdxVector[i]<< " Point:" << pcl_pc.points[newPointIdxVector[i]].x << " "<< pcl_pc.points[newPointIdxVector[i]].y << " "<< pcl_pc.points[newPointIdxVector[i]].z << std::endl;
}
std::cout<<newPointIdxVector.size ()<<std::endl;
//***************Filter point cloud to detect nearby changes only *****************
pcl::PassThrough<pcl::PointXYZ> pass;
pass.setInputCloud (dynamic_points);
pass.setFilterFieldName ("z");
pass.setFilterLimits (0.0, 3.0);
pass.filter (*dynamic_points);
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> dy_sor;
dy_sor.setInputCloud (dynamic_points);
dy_sor.setMeanK (50);
dy_sor.setStddevMulThresh (1.0);
dy_sor.filter (*dynamic_points);
//**********************Publish the data************************************
ros::NodeHandle k;
ros::Publisher pub = k.advertise<pcl::PointCloud<pcl::PointXYZ> >("dynamicPoints",2);
pub.publish(dynamic_points);
ros::Time time = ros::Time::now();
//Wait a duration of one second.
ros::Duration d = ros::Duration(1.5, 0);
d.sleep();
ros::spinOnce();
}
std::cout<<"finished"<<std::endl;
std::cout<<std::endl;
}