Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Problema con vectores dinámicos (https://www.clubdelphi.com/foros/showthread.php?t=14631)

aluduena 27-09-2004 03:05:12

Problema con vectores dinámicos
 
Hola que tal?.. tengo un problema al crear vectores dinámicos, los utilizo para almacenar reales, los vectores funcionan bien hasta cierto momento, desde ahi no puedo crear mas vectores y me salta un 'access violation' si trato de crear uno. Me imagino que debe ser por falta de memoria, no se si delphi le adjudica memoria a las aplicaciones y quizas no me esté dando.
Saludos
Ariel

Codigo:

function concatenarVectores(vec1,vec2:TVecReal): TVecReal;
var
vecFinal: TVecReal;
i,j,tope1,tope2: integer;
begin
SetLength(vecFinal,Length(vec1)+Length(vec2)-1);
tope1 := Length(vec1)-1;
tope2 := Length(vecFinal)-1;
for i:=0 to tope1-1 do
vecFinal[i]:=vec1[i];
for j:=tope1 to tope2 do
vecFinal[j]:=vec2[j-tope1];
result := vecFinal;
end;

procedure TTriangulo.pintarTriangulo;
var
za,zb,zc,xa,xb,xc,xd,ha,hb,hc,XIni,XFin,HIni,HFin,HScan,ZIni,ZFin,ZScan: TVecReal;
r,y,x,yNum,xInic,xFina:integer;
vec: TVecPoint;
h:byte;
xInicial,xFinal,hInicial,hFinal,zInicial,zFinal: real;
begin
vec := ordenar(self.vertice1,self.vertice2,self.vertice3);
xa := interpolar(vec[0].y,vec[2].y,vec[0].x,vec[2].x);
ha := interpolar(vec[0].y,vec[2].y,vec[0].h,vec[2].h);
za := interpolar(vec[0].y,vec[2].y,vec[0].z,vec[2].z);
xb := interpolar(vec[0].y,vec[1].y,vec[0].x,vec[1].x);
hb := interpolar(vec[0].y,vec[1].y,vec[0].h,vec[1].h);
zb := interpolar(vec[0].y,vec[1].y,vec[0].z,vec[1].z);
xc := interpolar(vec[1].y,vec[2].y,vec[1].x,vec[2].x);
hc := interpolar(vec[1].y,vec[2].y,vec[1].h,vec[2].h);
zc := interpolar(vec[1].y,vec[2].y,vec[1].z,vec[2].z);
XIni := xa;
XFin := concatenarVectores(xb,xc);
HIni := ha;
HFin := concatenarVectores(hb,hc);
ZIni := za;
ZFin := concatenarVectores(zb,zc);

......
El problema me lo da cuando concateno los vectores, me da un access violation cuando creo el vector dinámico en el procedimiento 1.

Salú

defcon1_es 27-09-2004 10:31:12

Hola,
ayudaría que pusieras algo de código...
¿Cómo creas los vectores?,
¿cuántos vectores puedes llegar a tener?,
¿el equipo es Windows 98/NT/2000/XP?

Salu2

Julià T. 27-09-2004 23:09:19

creo que el error está al copiar el array
Código:

for i:=0 to high(vecfinal) do
  result[i] := vecFinal[i];



La franja horaria es GMT +2. Ahora son las 11:06:20.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi