Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/10/2011, 15:04
jrj2011
 
Fecha de Ingreso: octubre-2011
Mensajes: 2
Antigüedad: 12 años, 7 meses
Puntos: 0
Leer archivo binario

Hola a todos,

Necesitaría leer un archivo binario, generado con c++ pero no tengo conocimientos de dicho lenguaje , ya que programo en VB. El programador que genera el fichero binario lo hace con la siguiente rutina:

long CurePlan::Sencillo(AnsiString DestinationFile)
{
unsigned long implantCount;

struct implant {
double x, y, z;
double tilt, nothing, turn;
} implantStored;

Space.SetStentReferenceFrame(implants, (HeadFlags & efMandibula) != 0);

chmod(DestinationFile.c_str(), S_IREAD|S_IWRITE) ;
int fd = open(DestinationFile.c_str(), O_WRONLY|O_CREAT|O_TRUNC|O_BINARY);

implantCount = implants->Count;
write(fd, &implantCount, sizeof(implantCount));

for (int i = 0 ; i < implants->Count ; i++) {
Implant *imp = implants->Item(i);

// No need to correct for the lengt of implant + abutment,
// because the implant position is the top
AFMTvector<> position = imp->PositionF;
AFMTvector<> direction = imp->DirectionF;

// X and Y coordinates are swapped in robot mind
if (Space.Flags & efMaxilla) {
implantStored.x = position.y;
implantStored.y = position.x;
implantStored.z = position.z;
} else {
implantStored.x = position.y;
implantStored.y = position.x;
implantStored.z = - position.z;
}

implantStored.tilt = imp->TiltF;
if ((implantStored.turn = imp->TurnF + 180.0) >= 360.0) implantStored.turn -= 360.0;
implantStored.nothing = 0.0;

write(fd, &implantStored, sizeof(struct implant));
}

close(fd);
chmod(DestinationFile.c_str(), S_IREAD|S_IWRITE);

return ResetError() ;
}

... Los datos que contiene necesito pasarlos a ASCII... si alguien puede ayudarme, se lo agradecería

Un cordial saludo,

Jaime Rodríguez