-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcambia.h
146 lines (115 loc) · 3.29 KB
/
cambia.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*Función que cambia lee las coordenadas de los módulos del primer bloque*/
//Referencias y coordenadas: ref posx posy angle en listaref[i][j]
void cambiaposxposy(int huellastotales,char referencia[LONG],char lineat[LONG],char listaref[huellastotales][COL][LONG])
{
int i,j;
for (i=0; i<huellastotales; i++)
{
if (!strcmp(referencia,listaref[i][0]))
{
strcpy(lineat," (fp_text reference ");
strcat(lineat,listaref[i][0]);
strcat(lineat," (at ");
strcat(lineat,listaref[i][1]);
strcat(lineat," ");
strcat(lineat,listaref[i][2]);
if (strcmp(listaref[i][3],"0.0"))
{
strcat(lineat," ");
strcat(lineat,listaref[i][3]);
}
strcat(lineat,") (layer F.SilkS)\n");
}
}
} /*cambiacoordenadas() */
/*Función que cambia las coordenadas del módulo por las nuevas que queremos poner*/
//Referencias y coordenadas: ref posx posy angle en posiciones[i][j]
void cambiacoordenadas(int numhuellas,char referencia[LONG],char lineat[LONG],char posiciones[numhuellas][COL][LONG])
{
int i,j;
for (i=0; i<numhuellas; i++)
{
if (!strcmp(referencia,posiciones[i][0]))
{
strcpy(lineat," (at ");
strcat(lineat,posiciones[i][1]);
strcat(lineat," ");
strcat(lineat,posiciones[i][2]);
if (strcmp(posiciones[i][3],"0.0"))
{
strcat(lineat," ");
strcat(lineat,posiciones[i][3]);
}
strcat(lineat,")\n");
}
}
} /*cambiacoordenadas() */
/*Elimina la extensión del nombre de archivo*/
void quitaextension(char entrada[MAXCHAR], char salida[MAXCHAR])
{
int i=0, j=0;
char ch;
while((ch=entrada[i++])!='.')
{
salida[j++]=ch;
salida[j]='\0';
}
}
/*Elimina la extensión del nombre de archivo*/
void extraenombre(char entrada[MAXCHAR], char salida[MAXCHAR])
{
int i=0, j=0;
char ch;
while((ch=entrada[i++])!='-')
{
salida[j++]=ch;
salida[j]='\0';
}
}
renombrafichero(char entrada[MAXCHAR],char salida[MAXCHAR])
{
char nuevo[MAXCHAR];
char viejo[MAXCHAR];
strcpy(nuevo,entrada);
strcpy(viejo,entrada);
strcat(viejo,"Old");
if (rename(entrada,viejo)==0)
printf("\nEl fichero de entrada ha sido renombrado como %s\n",viejo);
else
printf("\nEl fichero de entrada %s no se ha podido renombrar\n",entrada);
if (rename(salida,nuevo)==0)
printf("\nEl fichero de salida ha sido renombrado como %s\n",nuevo);
else
printf("\nEl fichero de salida %s no se ha podido renombrar\n",salida);
}
/*ordena cada bloque de coordenadas gemelas (D1,D2,D4,D5,D3) según su número de bloque
* que está en la línea AR path */
void ordenargemdown(char path[LONG][200][200],int i, int limitecol)
{
int j=0;
char temp[LONG];
int tope, busca;
for (tope=0 ; tope < limitecol ; tope++)
for (busca= tope+1 ; busca < limitecol ; busca++)
if (strcmp(path[i][tope],path[i][busca])>0)
{
strcpy(temp,path[i][tope]);
strcpy(path[i][tope],path[i][busca]);
strcpy(path[i][busca],temp);
}
}
/*Lo mismo que ordenagem pero en sentido inverso */
void ordenargemup(char path[LONG][200][200],int i, int limitecol)
{
int j=0;
char temp[LONG];
int tope, busca;
for (tope=0 ; tope < limitecol ; tope++)
for (busca= tope+1 ; busca < limitecol ; busca++)
if (strcmp(path[i][tope],path[i][busca])<0)
{
strcpy(temp,path[i][tope]);
strcpy(path[i][tope],path[i][busca]);
strcpy(path[i][busca],temp);
}
}