Bonjour,
j'ai une fonction ecrite en C++ utilisant la librairie QT, et je voulais la porter vers C# mais j'ai un petit probleme, le l'application qui devrait ouvrir ce fichier n'arrive pas a le reconnaitre ( le fichier que j'ai genere avec C#)

voici la fonction QT
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
bool Simulacre_output_filter::write( std::string outfile, const Geostat_grid*
 grid,std::string* errors ) 
{
	QFile file( outfile.c_str() );
	if( !file.open( IO_WriteOnly ) ) {
		if( errors ) 
			errors->append( "can't write to file: " + outfile );
		return false;
	}

	QDataStream stream( &file );

	// Write a header with a "magic number" and the grid type
	stream << (Q_UINT32)0xB211175D;
	stream <<"Cgrid".c_str();

	
	stream << "TrainingImage".c_str();

	stream << (Q_INT32)100;

	// write the grid dimensions
	stream << (Q_UINT32) grid->nx() 
		<< (Q_UINT32) grid->ny()
		<< (Q_UINT32) grid->nz(); 

	// write the cell dimensions
	GsTLCoordVector cell_dims = grid->cell_dimensions();
	stream << (float) cell_dims[0]
	<< (float) cell_dims[1]
	<< (float) cell_dims[2];

	// write the grid origin
	GsTLPoint origin = grid->origin();
	stream << (float) origin[0] 
	<< (float) origin[1]
	<< (float) origin[2];


	// Write the number of properties and the property names
	std::list<std::string> prop_list = grid->property_list();
	stream << (Q_UINT32) prop_list.size();

	std::list<std::string>::iterator it = prop_list.begin();
	for( ; it != prop_list.end(); ++it ) {
		stream << it->c_str() ;
	}

	// write the property values, one property at a time
	it = prop_list.begin();
	for( ; it != prop_list.end(); ++it ) {
		const GsTLGridProperty* prop = grid->property( *it );
		appli_assert( prop );
		for( unsigned int i = 0; i < prop->size(); i++ ) { 
			if( prop->is_informed( i ) )
				stream << (float) prop->get_value( i );
			else
				stream << (float)
 GsTLGridProperty::no_data_value;
		}
	}

	return true;

	
}
et voici ma fonction C#

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
FileStream fs = new FileStream(OutFile, FileMode.Create);
// Create the writer for data.
BinaryWriter bw = new BinaryWriter
(fs,System.Text.Encoding.BigEndianUnicode);
// Write data to Test.data.
 
 
bw.Write(Convert.ToUInt32(0xB211175D));
bw.Write("Cgrid"); // will deal only with cartesian grid
bw.Write("TrainingImage");// the name of our object
bw.Write(Convert.ToInt32(100)); // version number
// write the grid size
Index3 index = TrainingImage.NumCellsIJK;
bw.Write(Convert.ToUInt32(index.I));
bw.Write(Convert.ToUInt32(index.J));
bw.Write(Convert.ToUInt32(index.K));
 
// write the cell size, always equal to one in our purpose
 
bw.Write((float)1);
bw.Write((float)1);
bw.Write((float)1);
 
// suppose that the grid origine is 0,0,0
 
bw.Write((float)0);
bw.Write((float)0);
bw.Write((float)0);
 
// the property number equal to one !!!
 
bw.Write(Convert.ToUInt32(1));
// property name
bw.Write("TrainingImage unit1 Scale");
//bw.Write("IIndex unit1 Scale");
//bw.Write("JIndex unit1 Scale");
//bw.Write("KIndex unit1 Scale");
for(int	k=0; k<index.K; k++)
{
  for(int	j=0; j<index.J; j++)
  {
    for(int	i=0; i<index.I; i++)
    {
      bw.Write((float)TrainingImage[i,j,k]);
    }
  }
}
bw.Close();
fs.Close();
est-ce que vous auriez une idee d'ou vient le probleme