Ejemplo n.º 1
0
void
process_args(long argc, char **argv, hydroparam_t * H)
{
    long n = 1;
    char donnees[512];
    default_values(H);
    while (n < argc) {
        if (strcmp(argv[n], "--help") == 0) {
            usage();
            n++;
            continue;
        }
        if (strcmp(argv[n], "-v") == 0) {
            n++;
            H->prt++;
            continue;
        }
        if (strcmp(argv[n], "-i") == 0) {
            n++;
            strncpy(donnees, argv[n], 512);
            donnees[511] = 0;   // security
            n++;
            continue;
        }
        fprintf(stderr, "Clef %s inconnue\n", argv[n]);
        n++;
    }
    if (donnees != NULL) {
        process_input(donnees, H);
    } else {
        fprintf(stderr, "Option -i donnees manquantes\n");
        exit(1);
    }
}
void opengl_texture_state::Delete(GLuint tex_id)
{
	if (tex_id == 0) {
		Int3();
		return;
	}

	GLuint atu_save = active_texture_unit;

	for (unsigned int i = 0; i < num_texture_units; i++) {
		if (units[i].texture_id == tex_id) {
			SetActiveUnit(i);

			glBindTexture(units[i].texture_target, 0);
			units[i].texture_id = 0;

			default_values(i, units[i].texture_target);

			if (i == atu_save) {
				atu_save = 0;
			}
		}
	}

	SetActiveUnit(atu_save);
}
Ejemplo n.º 3
0
void opengl_texture_state::init(GLuint n_units)
{
	Assert( n_units > 0 );
	units = (opengl_texture_unit*) vm_malloc(n_units * sizeof(opengl_texture_unit));
	num_texture_units = n_units;

	for (unsigned int unit = 0; unit < num_texture_units; unit++) {
		units[unit].active = GL_FALSE;
		units[unit].enabled = GL_FALSE;
		units[unit].used = GL_FALSE;

		default_values(unit);

		glActiveTexture(GL_TEXTURE0 + unit);
		if (unit < (GLuint)GL_supported_texture_units) {
			glDisable(GL_TEXTURE_GEN_S);
			glDisable(GL_TEXTURE_GEN_T);
			glDisable(GL_TEXTURE_GEN_R);
			glDisable(GL_TEXTURE_GEN_Q);
		}

		units[unit].texgen_S = GL_FALSE;
		units[unit].texgen_T = GL_FALSE;
		units[unit].texgen_R = GL_FALSE;
		units[unit].texgen_Q = GL_FALSE;

		if (unit < (GLuint)GL_supported_texture_units) {
			glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
			glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
			glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
			glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
		}

		units[unit].texgen_mode_S = GL_EYE_LINEAR;
		units[unit].texgen_mode_T = GL_EYE_LINEAR;
		units[unit].texgen_mode_R = GL_EYE_LINEAR;
		units[unit].texgen_mode_Q = GL_EYE_LINEAR;

		if (unit < (GLuint)GL_supported_texture_units) {
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
			glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
			glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
		}

		units[unit].env_mode = GL_MODULATE;
		units[unit].env_combine_rgb = GL_MODULATE;
		units[unit].env_combine_alpha = GL_MODULATE;

		if (unit < (GLuint)GL_supported_texture_units) {
			glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
			glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1.0f);
		}

		units[unit].rgb_scale = 1.0f;
		units[unit].alpha_scale = 1.0f;
	}

	DisableAll();
}
void opengl_texture_state::SetTarget(GLenum tex_target)
{
	if (units[active_texture_unit].texture_target != tex_target) {

		if (units[active_texture_unit].texture_id) {
			glBindTexture(units[active_texture_unit].texture_target, 0);
			units[active_texture_unit].texture_id = 0;
		}

		// reset modes, since those were only valid for the previous texture target
		default_values(active_texture_unit, tex_target);
		units[active_texture_unit].texture_target = tex_target;
	}
}
void opengl_texture_state::init(GLuint n_units)
{
	Assert( n_units > 0 );
	units = (opengl_texture_unit*) vm_malloc(n_units * sizeof(opengl_texture_unit));
	num_texture_units = n_units;

	for (unsigned int unit = 0; unit < num_texture_units; unit++) {
		units[unit].enabled = GL_FALSE;

		default_values(unit);

		glActiveTexture(GL_TEXTURE0 + unit);
	}

	SetActiveUnit();
}
Ejemplo n.º 6
0
/*
 * load and parse an IPsec configuration file
 */
starter_config_t* confread_load(const char *file)
{
	starter_config_t *cfg = NULL;
	config_parsed_t  *cfgp;
	section_list_t   *sconn, *sca;
	starter_conn_t   *conn;
	starter_ca_t     *ca;

	u_int total_err;
	u_int visit	= 0;

	/* load IPSec configuration file  */
	cfgp = parser_load_conf(file);
	if (!cfgp)
	{
		return NULL;
	}
	cfg = malloc_thing(starter_config_t);

	/* set default values */
	default_values(cfg);

	/* load config setup section */
	load_setup(cfg, cfgp);

	/* in the first round parse also statements */
	cfg->parse_also = TRUE;

	/* find %default ca section */
	for (sca = cfgp->ca_first; sca; sca = sca->next)
	{
		if (streq(sca->name, "%default"))
		{
			DBG2(DBG_APP, "Loading ca %%default");
			load_ca(&cfg->ca_default, sca->kw, cfg);
		}
	}

	/* parameters defined in ca %default sections can be overloads */
	cfg->ca_default.seen = SEEN_NONE;

	/* load other ca sections */
	for (sca = cfgp->ca_first; sca; sca = sca->next)
	{
		u_int previous_err;

		/* skip %default ca section */
		if (streq(sca->name, "%default"))
			continue;

		DBG2(DBG_APP, "Loading ca '%s'", sca->name);
		ca = malloc_thing(starter_ca_t);

		ca_default(sca->name, ca, &cfg->ca_default);
		ca->kw =  sca->kw;
		ca->next = NULL;

		previous_err = cfg->err;
		load_ca(ca, ca->kw, cfg);
		if (cfg->err > previous_err)
		{
			/* errors occurred - free the ca */
			confread_free_ca(ca);
			cfg->non_fatal_err += cfg->err - previous_err;
			cfg->err = previous_err;
		}
		else
		{
			/* success - insert the ca into the chained list */
			if (cfg->ca_last)
				cfg->ca_last->next = ca;
			cfg->ca_last = ca;
			if (!cfg->ca_first)
				cfg->ca_first = ca;
		}
	}

	for (ca = cfg->ca_first; ca; ca = ca->next)
	{
		also_t *also = ca->also;

		while (also != NULL)
		{
			kw_list_t *kw = find_also_ca(also->name, cfg->ca_first, cfg);

			load_ca(ca, kw, cfg);
			also = also->next;
		}

		if (ca->startup != STARTUP_NO)
			ca->state = STATE_TO_ADD;
	}

	/* find %default conn sections */
	for (sconn = cfgp->conn_first; sconn; sconn = sconn->next)
	{
		if (streq(sconn->name, "%default"))
		{
			DBG2(DBG_APP, "Loading conn %%default");
			load_conn(&cfg->conn_default, sconn->kw, cfg);
		}
	}

	/* parameters defined in conn %default sections can be overloaded */
	cfg->conn_default.seen       = SEEN_NONE;
	cfg->conn_default.right.seen = SEEN_NONE;
	cfg->conn_default.left.seen  = SEEN_NONE;

	/* load other conn sections */
	for (sconn = cfgp->conn_first; sconn; sconn = sconn->next)
	{
		u_int previous_err;

		/* skip %default conn section */
		if (streq(sconn->name, "%default"))
			continue;

		DBG2(DBG_APP, "Loading conn '%s'", sconn->name);
		conn = malloc_thing(starter_conn_t);

		conn_default(sconn->name, conn, &cfg->conn_default);
		conn->kw =  sconn->kw;
		conn->next = NULL;

		previous_err = cfg->err;
		load_conn(conn, conn->kw, cfg);
		if (cfg->err > previous_err)
		{
			/* error occurred - free the conn */
			confread_free_conn(conn);
			cfg->non_fatal_err += cfg->err - previous_err;
			cfg->err = previous_err;
		}
		else
		{
			/* success - insert the conn into the chained list */
			if (cfg->conn_last)
				cfg->conn_last->next = conn;
			cfg->conn_last = conn;
			if (!cfg->conn_first)
				cfg->conn_first = conn;
		}
	}

	/* in the second round do not parse also statements */
	cfg->parse_also = FALSE;

	for (ca = cfg->ca_first; ca; ca = ca->next)
	{
		ca->visit = ++visit;
		load_also_cas(ca, ca->also, cfg);

		if (ca->startup != STARTUP_NO)
			ca->state = STATE_TO_ADD;
	}

	for (conn = cfg->conn_first; conn; conn = conn->next)
	{
		conn->visit = ++visit;
		load_also_conns(conn, conn->also, cfg);

		if (conn->startup != STARTUP_NO)
			conn->state = STATE_TO_ADD;
	}

	parser_free_conf(cfgp);

	total_err = cfg->err + cfg->non_fatal_err;
	if (total_err > 0)
	{
		DBG1(DBG_APP, "### %d parsing error%s (%d fatal) ###",
			 total_err, (total_err > 1)?"s":"", cfg->err);
	}

	return cfg;
}
Ejemplo n.º 7
0
void
process_args (int argc, char **argv, hydroparam_t * H)
{
  int n = 1;
  char donnees[512];

  default_values (H);

  MPI_Comm_size (MPI_COMM_WORLD, &H->nproc);
  MPI_Comm_rank (MPI_COMM_WORLD, &H->mype);
  while (n < argc)
    {
      if (strcmp (argv[n], "--help") == 0)
	{
	  usage ();
	  n++;
	  continue;
	}
      if (strcmp (argv[n], "-v") == 0)
	{
	  n++;
	  H->prt++;
	  continue;
	}
      if (strcmp (argv[n], "-i") == 0)
	{
	  n++;
	  strncpy (donnees, argv[n], 512);
	  donnees[511] = 0;	// security
	  n++;
	  continue;
	}
      fprintf (stderr, "Clef %s inconnue\n", argv[n]);
      n++;
    }
  if (donnees != NULL)
    {
      process_input (donnees, H);
    }
  else
    {
      fprintf (stderr, "Option -f donnees manquantes\n");
      exit (1);
    }

  H->globnx = H->nx;
  H->globny = H->ny;
  H->box[XMIN_BOX] = 0;
  H->box[XMAX_BOX] = H->nx;
  H->box[YMIN_BOX] = 0;
  H->box[YMAX_BOX] = H->ny;

  if (H->nproc > 1)
    {
      // MPI_Barrier(MPI_COMM_WORLD);
      // first pass : determin our actual sub problem size
      CalcSubSurface (0, H->globnx, 0, H->globny, 0, H->nproc - 1, 0, H->box,
		      H->mype, 0);
      // second pass : determin our neighbours
      CalcSubSurface (0, H->globnx, 0, H->globny, 0, H->nproc - 1, 0, H->box,
		      H->mype, 1);

      H->nx = H->box[XMAX_BOX] - H->box[XMIN_BOX];
      H->ny = H->box[YMAX_BOX] - H->box[YMIN_BOX];
      printf
	("[%4d/%4d] x=%4d X=%4d y=%4d Y=%4d / u=%4d d=%4d l=%4d r=%4d \n",
	 H->mype, H->nproc, H->box[XMIN_BOX], H->box[XMAX_BOX],
	 H->box[YMIN_BOX], H->box[YMAX_BOX], H->box[UP_BOX], H->box[DOWN_BOX],
	 H->box[LEFT_BOX], H->box[RIGHT_BOX]);
      // adapt the boundary conditions 
      if (H->box[LEFT_BOX] != -1)
	{
	  H->boundary_left = 0;
	}
      if (H->box[RIGHT_BOX] != -1)
	{
	  H->boundary_right = 0;
	}
      if (H->box[DOWN_BOX] != -1)
	{
	  H->boundary_down = 0;
	}
      if (H->box[UP_BOX] != -1)
	{
	  H->boundary_up = 0;
	}
    }
}
Ejemplo n.º 8
0
void
process_args(int argc, char **argv, hydroparam_t * H) {
  int n = 1;
  char donnees[512];

  default_values(H);

#ifdef MPI
  MPI_Comm_size(MPI_COMM_WORLD, &H->nproc);
  MPI_Comm_rank(MPI_COMM_WORLD, &H->mype);
#else
  H->nproc = 1;
  H->mype = 0;
#endif
  while (n < argc) {
    if (strcmp(argv[n], "--help") == 0) {
      usage();
      n++;
      continue;
    }
    if (strcmp(argv[n], "-v") == 0) {
      n++;
      H->prt++;
      continue;
    }
    if (strcmp(argv[n], "-i") == 0) {
      n++;
      strncpy(donnees, argv[n], 512);
      donnees[511] = 0;         // security
      n++;
      continue;
    }
    fprintf(stderr, "Key %s is unkown\n", argv[n]);
    n++;
  }
  if (donnees != NULL) {
    process_input(donnees, H);
  } else {
    fprintf(stderr, "Option -i is missing\n");
    exit(1);
  }

  H->globnx = H->nx;
  H->globny = H->ny;
  H->box[XMIN_BOX] = 0;
  H->box[XMAX_BOX] = H->nx;
  H->box[YMIN_BOX] = 0;
  H->box[YMAX_BOX] = H->ny;

#ifdef MPI
  if (H->nproc > 1) {
    MPI_Barrier(MPI_COMM_WORLD);
    // first pass : determin our actual sub problem size
    CalcSubSurface(0, H->globnx, 0, H->globny, 0, H->nproc - 1, 0, H->box, H->mype, 0);
    // second pass : determin our neighbours
    CalcSubSurface(0, H->globnx, 0, H->globny, 0, H->nproc - 1, 0, H->box, H->mype, 1);

    H->nx = H->box[XMAX_BOX] - H->box[XMIN_BOX];
    H->ny = H->box[YMAX_BOX] - H->box[YMIN_BOX];
    printf("[%4d/%4d] x=%4d X=%4d y=%4d Y=%4d / u=%4d d=%4d l=%4d r=%4d \n", H->mype, H->nproc, H->box[XMIN_BOX], H->box[XMAX_BOX], H->box[YMIN_BOX], H->box[YMAX_BOX], H->box[UP_BOX], H->box[DOWN_BOX], H->box[LEFT_BOX], H->box[RIGHT_BOX]);

    if (H->nx <= 0) {
      printf("Decomposition not suited for this geometry along X: increase nx or change number of procs\n");
    }

    if (H->ny <= 0) {
      printf("Decomposition not suited for this geometry along Y: increase ny or change number of procs\n");
    }

    if (H->nx == 0 || H->ny == 0) {
      MPI_Abort(MPI_COMM_WORLD, 123);
    }

    // adapt the boundary conditions 
    if (H->box[LEFT_BOX] != -1) {
      H->boundary_left = 0;
    }
    if (H->box[RIGHT_BOX] != -1) {
      H->boundary_right = 0;
    }
    if (H->box[DOWN_BOX] != -1) {
      H->boundary_down = 0;
    }
    if (H->box[UP_BOX] != -1) {
      H->boundary_up = 0;
    }
  }
  fflush(stdout);
#endif

  if (H->nxystep == -1) {
    // default = full slab
    H->nxystep = (H->nx < H->ny) ? H->nx: H->ny;
  } else {
    if (H->nxystep > H->nx) H->nxystep = H->nx;
    if (H->nxystep > H->ny) H->nxystep = H->ny;
  }

    H->nxystep = omp_get_max_threads();

  // small summary of the run conditions
  if (H->mype == 0) {
    printf("+-------------------+\n");
    printf("|GlobNx=%-7d     |\n", H->globnx);
    printf("|GlobNy=%-7d     |\n", H->globny);
    printf("|nx=%-7d         |\n", H->nx);
    printf("|ny=%-7d         |\n", H->ny);
    printf("|nxystep=%-7d    |\n", H->nxystep);
    printf("|tend=%-10.3f    |\n", H->tend);
    printf("|nstepmax=%-7d   |\n", H->nstepmax);
    printf("|noutput=%-7d    |\n", H->noutput);
    printf("|dtoutput=%-10.3f|\n", H->dtoutput);
    printf("+-------------------+\n");
  }
}
Ejemplo n.º 9
0
MainWindow::MainWindow() : QMainWindow(), Ui_MainWindow()
{
    // Initialize isMovingCircles, if we want to add a keyevent to
    // pause the moving circles we can call this, right now we make
    // sure that we only call it when we have circles inflated, but
    // it shouldn't matter, since the function only changes defined
    // points, so it should cause an issue if it's called even without
    // circles instantiated
    isMovingParticles = false;
    isMovingObstacles = false;
    isOpenFile = false;
    time_counter = 0.00;
    WIND_DIST_Y = 0.00;
    WIND_DIST_X = 0.00;
    OBSTACLE_RADIUS = .06;
    QString string_time = QString::number(time_counter,16);
    QString string_wind_x = QString::number(WIND_DIST_X);
    QString string_wind_y = QString::number(WIND_DIST_Y);
    QStringList list_wind_xy;
    list_wind_xy << string_wind_x << string_wind_y;
    QString string_wind_xy = list_wind_xy.join(",");

    exitAct = new QAction(tr("&Exit"), this);
    exitAct->setStatusTip(tr("exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(quit()));

    pauseAct = new QAction(tr("&Pause"), this);
    pauseAct->setStatusTip(tr("pause the simulation"));
    connect(pauseAct, SIGNAL(triggered()), this, SLOT(pause()));

    playAct = new QAction(tr("&Play"), this);
    playAct->setStatusTip(tr("continue the simulation"));
    connect(playAct, SIGNAL(triggered()), this, SLOT(play()));
     
    obstacleAct = new QAction(tr("&Oscillation"), this);
    obstacleAct->setStatusTip(tr("make the cilia oscillate"));
    connect(obstacleAct, SIGNAL(triggered()), this, SLOT(activate_obstacles()));

    coordAct = new QAction(tr("&Coordinates"), this);
    coordAct->setStatusTip(tr("print the coordinates data"));
    connect(coordAct, SIGNAL(triggered()), this, SLOT(coordinates()));
    
    radAct = new QAction(tr("&Radius"), this);
    radAct->setStatusTip(tr("print the radius data"));
    connect(radAct, SIGNAL(triggered()), this, SLOT(radius()));

    restartAct = new QAction(tr("&Restart"), this);
    restartAct->setStatusTip(tr("restart"));
    connect(restartAct, SIGNAL(triggered()), this, SLOT(restart()));

    defaultAct = new QAction(tr("&Default"), this);
    defaultAct->setStatusTip(tr("restart the simulation with default values"));
    connect(defaultAct, SIGNAL(triggered()), this, SLOT(default_values()));

    binAct = new QAction(tr("&Bins"), this);
    binAct->setStatusTip(tr("set the number of bins for histogram"));
    connect(binAct, SIGNAL(triggered()), this, SLOT(bin_count_window()));

    timeAct = new QAction(tr("&Time Elapsed:"), this);
    binAct->setStatusTip(tr("displaying the total time elapsed in milliseconds"));

    WindAct = new QAction(tr("&Wind:"), this);
    WindAct->setStatusTip(tr("Use the controls to increase or decrease wind"));

    upWindAct = new QAction(tr("&Up"), this);
    upWindAct->setStatusTip(tr("increase wind upwards"));
    connect(upWindAct, SIGNAL(triggered()), this, SLOT(upWind()));
    downWindAct = new QAction(tr("&Down"), this);
    downWindAct->setStatusTip(tr("increase wind downwards"));
    connect(downWindAct, SIGNAL(triggered()), this, SLOT(downWind()));
    leftWindAct = new QAction(tr("&Left"), this);
    leftWindAct->setStatusTip(tr("increase wind towards the left"));
    connect(leftWindAct, SIGNAL(triggered()), this, SLOT(leftWind()));
    rightWindAct = new QAction(tr("&Right"), this);
    rightWindAct->setStatusTip(tr("increase wind towards the right"));
    connect(rightWindAct, SIGNAL(triggered()), this, SLOT(rightWind()));
     
    OrAct = new QAction(tr("&Obstacle Size"), this);
    OrAct->setStatusTip(tr("set the Obstacle Size (radius)"));
    connect(OrAct, SIGNAL(triggered()), this, SLOT(setObstacleRadius_window()));

    //endtime = new QTimeEdit();
    timetime = new QPlainTextEdit(string_time);
    timetime->setReadOnly(true);
    timetime->setMaximumHeight(25);
    timetime->setMaximumWidth(80);
    
    windwind = new QPlainTextEdit(string_wind_xy);
    windwind->setReadOnly(true);
    windwind->setMaximumHeight(25);
    windwind->setMaximumWidth(100);


    fileToolBar = addToolBar(tr("Tools"));
    fileToolBar->addAction(exitAct);
    fileToolBar->addAction(pauseAct);
    fileToolBar->addAction(playAct);
    fileToolBar->addAction(timeAct);
    fileToolBar->addWidget(timetime);
    fileToolBar->addAction(restartAct);
    fileToolBar->addAction(defaultAct);
    fileToolBar->addAction(binAct);
    fileToolBar->addAction(coordAct);
    fileToolBar->addAction(radAct);


    currentTool = addToolBar(tr("controls"));
    currentTool->addAction(obstacleAct);
    currentTool->addAction(WindAct);
    currentTool->addWidget(windwind);
    currentTool->addAction(upWindAct);
    currentTool->addAction(downWindAct);
    currentTool->addAction(leftWindAct);
    currentTool->addAction(rightWindAct);
    currentTool->addAction(OrAct);
    

    fileToolBar->setAllowedAreas(Qt::BottomToolBarArea);
    addToolBar(Qt::BottomToolBarArea, fileToolBar);

    // Start the timer with interval TIMER_INTERVAL, which is defined in
    // randomWalk.h. This calls timer_update() ever TIMER_INTERVAL ms
    QTimer *timer = new QTimer(this);
    QString it;

    //establish connections
    connect(timer, SIGNAL(timeout()), this, SLOT(timer_update()));

    timer->start(TIMER_INTERVAL);

    setupUi(this);

}