本文整理汇总了C++中BalanceFactor::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ BalanceFactor::isEmpty方法的具体用法?C++ BalanceFactor::isEmpty怎么用?C++ BalanceFactor::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BalanceFactor
的用法示例。
在下文中一共展示了BalanceFactor::isEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: advanceTrial
/**
* @brief advanceTrial
* @param response
*/
void advanceTrial(int response)
{
responseFile <<
parameters.find("SubjectName") << "\t" <<
trialNumber << "\t" <<
focalDistance << "\t" <<
response << "\t" <<
trialTimer.getElapsedTimeInMilliSec() << "\t" <<
trial.getCurrent().at("ZWidth") << "\t" <<
trial.getCurrent().at("Slant") << "\t" <<
trial.getCurrent().at("Tilt") << "\t" <<
trial.getCurrent().at("StimulusAnchored") << " " << endl;
if ( trial.isEmpty() )
{
exit(0);
}
trial.next();
updateStimulus();
beepOk();
trialMode=BLACK_MODE;
trialNumber++;
trialTimer.start();
frame=0.0;
}
示例2: advanceTrial
void advanceTrial()
{
double timeElapsed = timer.getElapsedTimeInMilliSec();
responseFile.precision(3);
responseFile <<
parameters.find("SubjectName") << "\t" <<
//interoculardistance << "\t" <<
trialNumber << "\t" <<
stimPosn << "\t" <<
"-420" << "\t" <<//trial.getCurrent()["AbsDepth"] <<"\t" <<
"50" << "\t" <<//trial.getCurrent()["ObjHeight"] <<"\t" <<
timer.getElapsedTimeInMilliSec() << "\t" <<
//trial.getCurrent()["HapticFB"] << "\t" <<
//randCond << "\t" <<
//randIncrement << "\t" <<
stimCond << "\t" <<
pulsingColors << "\t" <<
endl;
trialFile.close();
trialNumber++;
if( !trial.isEmpty() )
{
trial.next();
initTrial();
}
else
{
exit(0);
}
}
示例3: advanceTrial
/**
* @brief advanceTrial: This function to the next trial
*/
void advanceTrial()
{
fingersTimer.start(); // Here we change trial mode
if (trialMode == HANDONSTARTMODE )
{
// Wait to show the stimulus that the fingers points are projected in the screen
trialMode = STIMULUSMODE;
}
else // trialMode == STIMULUSMODE
{
trialMode = HANDONSTARTMODE;
paintGL();
beepTrial();
double oldDistance = factors.getCurrent().at("Distances");
// Reinsert the trial if too much occluded frames
double maxInvisibleFramesPercent = util::str2num<double>(parameters.find("MaxPercentOccludedFrames"))/100.0;
if ( (invisibleIndexFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent ) ||
(invisibleThumbFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent )||
(invisibleWristFrames / ((double)drawingTrialFrame) > maxInvisibleFramesPercent ) )
{
map<string,double> currentFactorsList = factors.getCurrent();
beepBad();
cerr << "Reinserted current trial (InvIndex,InvThumb,drawingTrialFrame,totTrialFrame)" << invisibleIndexFrames << " " << invisibleThumbFrames << " " << drawingTrialFrame << " " << trialFrame << endl;
factors.reinsert(currentFactorsList);
}
if (factors.isEmpty())
{
beepLong();
beepLong();
beepLong();
plato_stop();
exit(0);
}
invisibleIndexFrames = invisibleThumbFrames = invisibleWristFrames = trialFrame = drawingTrialFrame = 0;
totalTrialNumber++;
factors.next();
if (oldDistance == factors.getCurrent().at("Distances"))
{
Timer sleepTimer; sleepTimer.sleep(1000);
}
double marker5z = markers.at(5).p.z();
generateSphereStimulus( factors.getCurrent().at("StimulusRadius") );
initProjectionScreen(factors.getCurrent().at("Distances"));
moveStimulusObject(visualStimCenter,3500);
}
}
示例4: mouseFunc
void mouseFunc(int button, int state, int _x , int _y)
{
if ( trialMode == PROBEMODE )
{
glutWarpPointer(SCREEN_WIDTH/2,SCREEN_HEIGHT/2);
if ( button == GLUT_LEFT_BUTTON && (state==GLUT_DOWN) )
mouseButton=1;
if ( button == GLUT_RIGHT_BUTTON && (state==GLUT_DOWN) )
mouseButton=-1;
if( (button== GLUT_LEFT_BUTTON || button==GLUT_RIGHT_BUTTON) && (state==GLUT_UP) && (mouseButton!=0) )
{
double responseTime=responseTimer.getElapsedTimeInMilliSec();
double clickDelay=100; //milliseconds before the click is valid
if ( responseTime > clickDelay )
{
timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in
if ( trial.isEmpty() )
{
responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl;
cleanup();
exit(0);
}
else
{
responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl;
factors = trial.getNext();
trialNumber++;
}
advanceTrial();
redDotsPlane.setDimensions(50,50,0.1);
redDotsPlane.setSlantTilt(factors["Slant"], factors["Tilt"] );
redDotsPlane.compute();
stimDrawer.initList(&redDotsPlane);
mouseButton=0;
}
}
}
glutPostRedisplay();
}
示例5: handleKeypress
// Funzione di callback per gestire pressioni dei tasti
void handleKeypress(unsigned char key, int x, int y)
{ switch (key)
{ //Quit program
case 'x':
// Facendo cosi si cancella lo stimolo durante il movimento (SINCRONO) del monitor.
// Si imposta il isStimulusDrawn a FALSE e si riaggiorna la schermata con una drawGLScene()
// infine si muove il monitor, la chiamata blocca il programma per x secondi, si
// simula lo spostamento dello schermo di proiezione ed infine si reimposta isStimulusDrawn a TRUE
// cosi' la prossima chiamata di drawStimulus() lo disegna correttamente a schermo. Provare per credere...
//factors = trial.getNext();
trial.next();
isStimulusDrawn=false;
drawGLScene();
initProjectionScreen(trial.getCurrent()["AbsDepth"]);
isStimulusDrawn=true;
break;
case 'i':
visibleInfo=!visibleInfo;
break;
case 'm':
interoculardistance += 0.5;
break;
case 'n':
interoculardistance -= 0.5;
break;
case '+':
{
// Il trucco per avanzare alla modalita' trial successiva: incrementi di uno e poi tieni il resto della
// divisione per due, in questo caso ad esempio sara' sempre:
// 0,1,0,1,0,1
// se metti il resto della divisione per 3 invece la variabile trialMode sar'
// 0,1,2,0,1,2
// ogni ciclo della variabile trialMode normalmente e' un trial (1)
// puoi anche definire una funzione void advanceTrial() che si occupa di andare al trial successivo,
// deve contenere una chiamata alla BalanceFactor::getNext() cosi' passi alla nuova lista di fattori
// Ad esempio
trialMode++;
trialMode=trialMode%3;
}
break;
case 't':
{
if (trial.isEmpty())
exit(0);
trial.next();
break;
}
case 'Q':
case 'q':
case 27: //corrisponde al tasto ESC
{
// Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi
// spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini)
cleanup();
exit(0);
}
break;
case ' ':
{
// Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0)
if ( headCalibrationDone==0 && allVisiblePatch )
{
headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance );
headCalibrationDone=1;
beepOk(0);
break;
}
// Second calibration, you must look a fixed fixation point
if ( headCalibrationDone==1 && allVisiblePatch )
{
headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance );
headCalibrationDone=2;
break;
}
}
break;
// Enter key: press to make the final calibration
case 13:
{
if ( headCalibrationDone == 2 && allVisiblePatch )
{
headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1].p, markers[2].p,markers[3].p,interoculardistance );
headCalibrationDone=3;
visibleInfo=false;
}
}
break;
case '5':
{
if(dz/2>10)
zedge -= .25;
else
zedge = zedge;
}
break;
case '8':
{
zedge += .25;
//.........这里部分代码省略.........
示例6: main
int main(void)
{ randomizeSeed();
/*
BalanceFactor<int> balance;
map<string,int> factors;
balance.init(1,true);
vector<int> f;
for (int i=0; i<10; i++)
f.push_back(i);
balance.addFactor( "Slant", f );
while ( !balance.isEmpty() )
{
factors = balance.getNext();
cout << factors["Slant"] << endl;
}
balance.init(1,true);
cerr << "==========" << endl;
f.clear();
for (int i=0; i<10; i++)
f.push_back(i);
balance.addFactor( "Slant", f );
while ( !balance.isEmpty() )
{
factors = balance.getNext();
cout << factors["Slant"] << endl;
}
*/
/*
balance.addFactor( "Tilt", vlist_of<int>(90) );
balance.addFactor( "Anchored", vlist_of<int>(0)(1)(2)(3));
//balance.print();
while ( !balance.isEmpty() )
{
map<string, int> tmp2 = balance.getNext() ;
for ( map<string, int>::iterator iter = tmp2.begin(); iter!=tmp2.end(); ++iter)
cout << iter->first << " " << iter->second << " ";
cout << endl;
}
cerr << isnan(1.0/0.0) << " " << isinf(1.0/0.0) << endl;
return 0;
*/
map<string,int> factors;
ifstream paramFile;
paramFile.open("prova.exp");
ParametersLoader params;
params.loadParameterFile(paramFile);
BalanceFactor<int> bfact;
bfact.init(params);
while (!bfact.isEmpty())
{ factors = bfact.getNext();
cout << factors["StimSpeed"] << endl;
}
//bfact.print();
bfact.init(params);
while (!bfact.isEmpty())
{ factors = bfact.getNext();
cout << factors["StimSpeed"] << endl;
}
/*
BalanceFactor<int> balance;
balance.init(params);
balance.print();
while ( !balance.isEmpty() )
{
map<string,int> vals = balance.getNext();
for ( map<string,int>::iterator iter = vals.begin(); iter!=vals.end(); ++iter )
{
cout << iter->first << " " << iter->second << endl;
}
cout << endl << endl;
}
*/
return 0;
}
示例7: advanceTrial
void advanceTrial()
{
// Determine if previous trial was a good trial
double percentOccludedFrames = numLostFrames/TGA_frame;
bool notEnoughFrames = percentOccludedFrames > 0.10 ;
int overwrite = 0;
// If any of these things are true when advanceTrial is called, reinsert!
if (training || !reachedObject || notEnoughFrames ) {
beepOk(3); // 1000hz, 50ms
if (training)
cout << "Training Mode!" << endl;
if (!reachedObject)
cout << "I don't think you reached the object..." << endl;
if (notEnoughFrames)
cout << "Be visible!" << endl;
if (!controlCondition) {
map<std::string,double> currentFactorsList = trial.getCurrent();
trial.reinsert(currentFactorsList);
}
overwrite = 1;
}
// Write previous trial to response file
if (!overwrite && !controlCondition)
{
responseFile.precision(3);
responseFile <<
parameters.find("SubjectName") << "\t" <<
trialNumber << "\t" <<
TGA_time << "\t" <<
trial.getCurrent()["ObjPosn"] << "\t" <<
sm_lg << "\t" <<
con_inc << "\t" <<
endl;
} else if (!overwrite && controlCondition) {
controlResponseFile.precision(3);
controlResponseFile <<
parameters.find("SubjectName") << "\t" <<
controlTrial << "\t" <<
TGA_time << "\t" <<
currentObj << "\t" <<
sm_lg << "\t" <<
con_inc << "\t" <<
endl;
}
// Close previous trial file
trialFile.close();
// If we're done with control block
if (controlCondition && controlTrial==16) {
if (!overwrite) { // and not overwriting, change over
plato_stop();
exit(0);
//controlCondition=false;
//endControl=true;
}
else // if we ARE overwriting, initTrial again until we get it
initTrial();
}
// If we're still in the control block
if (controlCondition && controlTrial<16 ){
if (!overwrite) //and not overwriting
controlTrial++; //increment
initTrial(); //initTrial will handle a repeat or the next trial
}
// If we're in the main block
if( !trial.isEmpty() && !controlCondition)
{
if (!endControl) { // If it's NOT the v. first main block trial
if (!overwrite) // and we're not overwriting due to a bad trial
trialNumber++; // increment
factors = trial.getNext(); // get the next trial and initialize it!
initTrial();
} else { // It IS the v. first main block trial (endControl)
endControl=false; // turn this switch off so we know next time around that it's trial 1
initTrial(); // initTrial WITHOUT getNext because we already gotNext at the end of calibration
}
}
// Finally, if we're out of trials, finish the experiment.
else if (trial.isEmpty() && !controlCondition)
{
controlCondition=true;
initTrial();
}
}
示例8: initTrial
// INITTRIAL TO CHECK (MOSTLY FOR FINGERS-RELATED EVENTS)
void initTrial()
{
// if the current is not an empty trial...
if(!trial.isEmpty())
{
if(condition == 0)
beepOk(0);
if(condition == 1)
endTrial = false;
// these variables are reset
showStimuli = false;
h_stimulus = 1;
fingersOccluded = 0;
framesOccluded=0;
frameN = 0;
// random seed
//srand(rand() % 100);
// pick 0 or 1 at random and assign it to first_interval
first_interval = rand() % 2;
// pick the complementary (0 or 1) and assign it to second_interval
second_interval = 1 - first_interval;
#ifdef SIMULATION
//srand(5);
testJND = str2num<double>(parameters.find("JND"));
double JND = mathcommon::gaussRand(0,testJND);
// set the parameters to build the stimulus:
// HEIGHT
//--- standard
stimulus_height[0] = 55.0;
//--- comparison
stimulus_height[1] = trial.getCurrent()["ConstantStimuli"] + JND;
// EGOCENTRIC DISTANCE
absDepth = trial.getCurrent()["AbsDepth"];
#else
// set the parameters to build the stimulus:
// HEIGHT
//--- standard
stimulus_height[0] = 55.0;
//--- comparison
stimulus_height[1] = trial.getCurrent()["ConstantStimuli"];
// EGOCENTRIC DISTANCE
absDepth = trial.getCurrent()["AbsDepth"];
#endif
// build the stimuli
buildStandard(stimulus_noise, absDepth);
buildComparison(stimulus_height[1], stimulus_noise, absDepth);
#ifndef SIMULATION
// roll on
drawGLScene();
initProjectionScreen(absDepth);
if(condition == 1)
{
// generate random speed between 3500 and 5000
randSpeed = rand() % 1501 + 3500;
// move bottom surface up to topY - stimulus_height[first_interval]
Vector3d moveHeight(0.0,whereTop.y()-stimulus_height[first_interval],absDepth);
moveObjectAbsolute(moveHeight, whereBottom, randSpeed);
beepOk(0);
}
if(condition == 0)
{
// show the stimuli
showStimuli = true;
}
timer.start();
#else
advanceTrial();
#endif
} else
{
if(condition == 1)
responseFile.close();
summaryFile.close();
cleanup();
exit(0);
}
}