IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

[Qt > C#] Pourquoi le fichier généré n'est pas reconnu ? ?


Sujet :

C#

  1. #1
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut [Qt > C#] Pourquoi le fichier généré n'est pas reconnu ? ?
    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

  2. #2
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut
    je deteste les fichier binaire
    mais pour votre informations je viens de trouver le probleme

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public void WriteTrainingImageToSgems(string OutFile,IDiscreteProperty
     TrainingImage)
            {
     
                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.
                uint magic_number = 0xB211175D;
                bw.Write(Convert.ToUInt32(magic_number));
    alors le truc en rouge au lieu de le trouver comme cela dans mon fichier, je trouve l'inverse

    5D 17 11 B2 ,
    merci ultraedit

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [WordPress]Mon fichier archive.php n'est pas reconnu ?
    Par dbzes59113 dans le forum WordPress
    Réponses: 0
    Dernier message: 17/01/2010, 16h00
  2. Pourquoi getToolkit() n'est pas reconnu
    Par L4BiN dans le forum AWT/Swing
    Réponses: 6
    Dernier message: 26/11/2009, 18h08
  3. [Utilisation] Comment marquer un fichier comme commité alors qu'il ne l'est pas
    Par Invité dans le forum Subversion
    Réponses: 3
    Dernier message: 09/01/2009, 12h01
  4. Réponses: 3
    Dernier message: 16/05/2006, 16h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo