Moyennage besoin d'aide

cedm237 Messages postés 5 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 12 février 2010 - 6 févr. 2010 à 16:53
cedm237 Messages postés 5 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 12 février 2010 - 10 févr. 2010 à 20:21
Bonjour, je connais pas grand chose en C, mais j'ai besoin d'un petit code, qui me fasse ceci:
-j'ai un fichier contenant 1millions de ligne de coordonnée X Y Z et une valeur et je souhaite pondéré la valeur en mm^2.

une ligne se présente comme ceci(XYZvaleur):
-4.774505615 0.553915918 -6.218049526 0.000627153/size

voir fichier liée es.txt
es.txt

je voudrais prendre la première ligne de es.txt, définir une cible 3D (X1-0.5<Xi<X1+0.5 et Y1-0.5<Xi<Y1+0.5 et Z1-0.5<Zi<Z1+0.5), et définir parmi les lignes suivantes (de es.txt)celle rentrant dans la cible, avec ces différentes lignes trouvées, donner le barycentre X1+..Xn/n Y1+..+Yn/n Z1+..Zn/n et valeur1+...valeurn

éliminer la ligne 1 et les lignes qui ont répondu ok au critère cible, et faire pareil avec les lignes restantes, et finalement à la fin obtenir un fichier avec les barycentres et leur valeur.

4 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
6 févr. 2010 à 17:51
C'est toi qui produit ce es.txt ???

Si OUI:
Ne pas faire de la transformation ASCII <=> BIN et vice versa, tout binaire d'un bout à l'autre sera 1000 faois plus rapide, il n'y aura meme plus notion de lignes.

typedef struct _COORD {
double X;
double Y;
double Z;
double v;
} COORD, *PCOORD;

1 millions de COORD se lisent et s'écrivent aisément et ultra rapidement.

ciao...
BruNews, MVP VC++
0
cedm237 Messages postés 5 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 12 février 2010
6 févr. 2010 à 22:42
j'ai la description du fichier binaires, si c'est plus simple.
structure du binaire

tu vois y a plein de truc dans ce binaires, moi les seuls truc qui m'intéresse, c'est XYZ et F
et j'essaie d'avoir une grille restructurée par mm^3...
0
cedm237 Messages postés 5 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 12 février 2010
7 févr. 2010 à 23:20
personne pour m'aider à extraire XYZF de mon binaire et barycentrer XYZF par mm^2
0
cedm237 Messages postés 5 Date d'inscription vendredi 12 février 2010 Statut Membre Dernière intervention 12 février 2010
10 févr. 2010 à 20:21
voici mon code, il génère des erreurs, j'essaie d'extraire les data du binaire binaireet de les mettre en tableau

// VC5.cpp : Defines the entry point for the console application.
//

/clr
#include "stdafx.h"
#include <fstream>
#include 
#include 
#include <cstring>
#include "stdio.h"
#include "stdlib.h"
#include <vcclr.h>
#include <vector>

using namespace std;
using namespace System;



FILE *fp1;


//Variable
char * prt_info;
long recl,lenr,numf,numx,numy;
float xmin,xmax,ymin,ymax;


//Struct
struct Arr
{
float *X;
float *Y;
float *Z;
float *A;
float *B;
float *C;
float *F;
long numofRec;
};

int main()
{
System::String^ str;
//Number of records
int num_rec = 0;
int i=0;
//Declare struct
Arr info[1];

      pin_ptr<const wchar_t> wch = PtrToStringChars(str);

      // Convert to a char*
      size_t origsize = wcslen(wch) + 1;
      const size_t newsize = 1000;
      size_t convertedChars = 0;
      char nstring[newsize];
      wcstombs_s(&convertedChars, nstring, origsize, wch, _TRUNCATE);
      //strcat_s(nstring, " (char *)");

errno_t err;
//Read from data file


if((err=fopen_s(&fp1,"C:\Sample\raysdetector.dis","rb"))!=0)
fread(&recl,sizeof(recl),1,fp1);
lenr=recl/256/4;
fseek(fp1,28+24,0);
fread(&numf,sizeof(numf),1,fp1);
fseek(fp1,3*28+16,0);
fread(&ymin,4,1,fp1);
fread(&ymax,4,1,fp1);
fread(&numy,4,1,fp1);
fseek(fp1,4*28+16,0);
fread(&xmin,4,1,fp1);
fread(&xmax,4,1,fp1);
fread(&numx,4,1,fp1);

for (long i=1;i<numy;i++)
{
fread(info[i].X,4,1,fp1);
fread(info[i].Y,4,1,fp1);
fread(info[i].Z,4,1,fp1);
fread(info[i].A,4,1,fp1);
fread(info[i].B,4,1,fp1);
fread(info[i].C,4,1,fp1);
fread(info[i].F,4,1,fp1);
info[i].numofRec=i;
printf("info[i].numofRec");
}

fclose(fp1);
}



'VC5.exe': Loaded 'E:\VC5\VC5\Debug\VC5.exe', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'VC5.exe': Unloaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\mscoree.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\advapi32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\rpcrt4.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\secur32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcm90d.dll', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\ole32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcrt.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\user32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\CLKERN.DLL', Binary was not built with debug information.
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\shlwapi.dll'
'VC5.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll'
'VC5.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.1433_x-ww_5cf844d2\msvcr80.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\shell32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\WinSxS\wow64_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_5FA17F4E\comctl32.dll'
'VC5.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Culture.dll'
'VC5.exe': Unloaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Culture.dll'
'VC5.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\32e6f703c114f3a971cbe706586e3655\mscorlib.ni.dll'
'VC5.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'VC5.exe' (Managed): Loaded 'e:\VC5\VC5\Debug\VC5.exe', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll'
'VC5.exe': Loaded 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\rsaenh.dll'
'VC5.exe': Loaded 'C:\WINDOWS\SysWOW64\psapi.dll'
'VC5.exe' (Managed): Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597C3456\msvcm90d.dll', Symbols loaded.
'VC5.exe': Loaded 'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\System\ba0e3a22211ba7343e0116b051f2965a\System.ni.dll'
'VC5.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
First-chance exception at 0x102670ef (msvcr90d.dll) in VC5.exe: 0xC0000005: Access violation reading location 0x00000000.
A first chance exception of type 'System.AccessViolationException' occurred in VC5.exe
An unhandled exception of type 'System.AccessViolationException' occurred in VC5.exe

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The thread 'Win32 Thread' (0x11a4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe04) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1204) has exited with code 0 (0x0).
The program '[4436] VC5.exe: Managed' has exited with code 0 (0x0).
The program '[4436] VC5.exe: Native' has exited with code 0 (0x0).
0
Rejoignez-nous