1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#include "stdafx.h"
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <fstream>
#include "math.h"
using namespace std;
void VC3( vector< double > & coord )
{
string line;
ifstream myfile ("test3.txt");
if (myfile.is_open())
{
coord.reserve(1200);
while ( getline (myfile,line))
{
stringstream ss(line);
double nombre1;
double nombre2;
double nombre3;
char sep;
while(ss >> nombre1 >> sep >> nombre2 >> sep >> nombre3)
{
coord.push_back(nombre3);
}
}
myfile.close();
}
else cout << "Unable to open file";
}
void Color( vector< int > &lightcolor )
{
vector< double > heightmap;
VC3( heightmap ); //fonction qui remplit le vector heightmap
int s=1156;
int size=34;
lightcolor.resize(s);
int X=0;
int Y=0;
int index;
int index2;
int a = Y * size + X;
while (1)
{
while(1)
{
index = Y * size + X;
index2 = Y * size + X;
vector<int>::iterator it = lightcolor.begin()+index;
vector<double>::iterator it2 = heightmap.begin()+ index2;
*it=*it2;
X++;
if(X >= size) break;
}
X=0;
Y++;
if(Y >= size) break;
}
}
int main ()
{
vector< double > heightmap;
VC3( heightmap );
vector< int > IntersectMap;
Color( IntersectMap );
int s =1156;
for (int i = 0 ; i <s ; i++)
{
cout << IntersectMap[i]<< endl;
}
cout << heightmap.size() << endl;
return 0;
} |
Partager