本文整理汇总了C++中model::init方法的典型用法代码示例。如果您正苦于以下问题:C++ model::init方法的具体用法?C++ model::init怎么用?C++ model::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void simulationGrid::init(){
int i,tmpAgents;
/* Initialize random number generator's seed to the current time */
srand(time(NULL));
/* Initialize Simulation Grid */
valid(1);
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w(), 0, h(), -100, 100);
glMatrixMode (GL_MODELVIEW);
glColor4d(0.2,0,1,0.2);
if(!resized)
{
/* Initial Parameters */
gui_linear_lattice_dimension = LINEAR_LATTICE_DIMENSION_INIT;
gui_delta = DELTA_INIT;
gui_pos_traits = POS_TRAITS_INIT;
simSpeed = SIM_SPEED_INIT;
}
if(resized)
{
if(latticeOn)
{
tmpAgents = gui_linear_lattice_dimension*gui_linear_lattice_dimension;
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta,1, w(), h());
}
else if(kleinbergOn)
{
tmpAgents = gui_linear_lattice_dimension*gui_linear_lattice_dimension;
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta,0, w(), h());
}
else
{
tmpAgents = gui_linear_lattice_dimension*gui_linear_lattice_dimension;
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta,-1, w(), h());
}
resized = false;
}
else if(initModel && latticeOn)
{
m.init(LINEAR_LATTICE_DIMENSION_INIT, AGENTS, NFEATURES, POS_TRAITS_INIT, OUTDEGREE, DELTA_INIT,1, w(), h());
initModel=false;
restart = false;
}
else if(initModel && kleinbergOn)
{
m.init(LINEAR_LATTICE_DIMENSION_INIT, AGENTS, NFEATURES, POS_TRAITS_INIT, OUTDEGREE, DELTA_INIT,0, w(), h());
initModel=false;
restart = false;
}
else if(initModel && randomOn)
{
printf("Arrivo qua Init modello \n");
m.init(LINEAR_LATTICE_DIMENSION_INIT, AGENTS, NFEATURES, POS_TRAITS_INIT, OUTDEGREE, DELTA_INIT,-1, w(), h());
initModel=false;
restart = false;
}
else
{
restart = true;
}
}
示例2: draw
void simulationGrid::draw() {
int i, j, k, tmpAgents;
/* Graphic Reinitialization */
if (!valid())
{
init();
resized = true;
}
/* If Restart Button is pressed */
if(restartB)
{
tmpAgents = gui_linear_lattice_dimension*gui_linear_lattice_dimension;
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta, m.maxSide, w(), h());
restartB = false;
simStepLabel->value(0);
restart = false;
restartS = true;
}
/* Catch parameters from gui and reinit if needed */
else if((m.delta != gui_delta) || (m.pos_traits != gui_pos_traits ) || (m.linear_lattice_dimension != gui_linear_lattice_dimension) || restart)
{
tmpAgents = gui_linear_lattice_dimension*gui_linear_lattice_dimension;
if(latticeOn)
{
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta, 1,w(), h());
restartS = true;
}
else if(kleinbergOn)
{
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta, 0, w(), h());
restartS = true;
}
else
{
m.init(gui_linear_lattice_dimension, tmpAgents, NFEATURES, gui_pos_traits, OUTDEGREE, gui_delta, -1, w(), h());
restartS = true;
}
restart = false;
}
/* Clear display */
glClear(GL_COLOR_BUFFER_BIT);
if(linkVisualization)
{
for (i=0;i<m.agents;i++)
{
link(i);
}
}
/* Draws all Agents */
for(i=0; i<m.agents;i++)
{
drawAgents(i,MIN(w(),h()));
}
/* Simulation Step */
m.step();
/* Compute Regions */
computeRegions();
g1->redraw();
g2->redraw();
g3->redraw();
}