Statistiques
| Révision :

root / bin / load_initial_state.cpp @ 1

Historique | Voir | Annoter | Télécharger (940 octet)

1
#include "load_initial_state.h"
2
#include <fstream>
3
#include <iostream>
4
#include <limits>
5

    
6
/* this function loads the initial state in a .txt file */
7

    
8
using namespace std;
9

    
10
void load_initial_state(const char* file_name, int cell_number, int vertices_number, float *vertices, int *vertices_number_in_each_cell, int *cells_vertices){
11

    
12
std::ifstream file(file_name,ios::in);
13
float d; int i,j;
14

    
15
file.ignore(numeric_limits<streamsize>::max(),'[');
16
file.ignore(1,EOF);
17

    
18
for (i=0;i<2*vertices_number;i++){
19
file >> d;
20
file.ignore(1,EOF);
21
vertices[i]=d;}
22

    
23
file.ignore(numeric_limits<streamsize>::max(),'[');
24
file.ignore(1,EOF);
25

    
26
for (i=0;i<cell_number+1;i++){
27
file >> j;
28
file.ignore(1,EOF);
29
vertices_number_in_each_cell[i]=j;}
30

    
31
file.ignore(numeric_limits<streamsize>::max(),'[');
32
file.ignore(1,EOF);
33

    
34
for (i=0;i<vertices_number_in_each_cell[cell_number];i++){
35
file >> j;
36
cells_vertices[i]=j;
37
file.ignore(1,EOF);}
38

    
39
file.close();
40
}