forked from robertstarr/ulp_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brd_to_dsn.ulp
2646 lines (2350 loc) · 57.7 KB
/
brd_to_dsn.ulp
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//=====================================
//
// Converter of CadSoft-Eagle board designs to the Specctra DSN-Textformat.
//
// Created by ConnectEDA extended and modified by Thomas Kaeubler and Alfons Wirtz.
//
// Many thanks to ConnectEDA for allowing us to use their pcb_to_dsn ulp-file.
//
//
// Last change February 22th 2006
//
//=====================================
int preprotect = 0;
int string_quote = 1;
real polyline_endpoint_tolerance = 0.001; // The tolerance for regarding 2 line endpoints as equal.
real outline_endpoint_tolerance = 2.0; // The tolerance for regarding 2 line endpoints of the outline as equal.
enum {false,true};
int Units;
string layer_name[];
string TopLayer, BotLayer;
real default_wire_width, default_via_size, default_drill_size, default_clearance, rv_pad_inner, min_via_inner, min_pad_inner, max_pad_inner;
real clearance_wire_pad, clearance_wire_smd, clearance_wire_via, clearance_pad_pad, clearance_pad_via;
real clearance_via_via, clearance_smd_pad, clearance_smd_via, clearance_smd_smd;
void write_Db2Unit(int Length)
//----------------------------
{
real Value;
switch (Units)
{
case GRID_UNIT_MM :
Value = u2mm(Length);
break;
case GRID_UNIT_MIL :
Value = u2mil(Length);
break;
case GRID_UNIT_INCH :
Value = u2inch(Length);
break;
case GRID_UNIT_MIC :
Value = u2mic(Length);
break;
}
string String;
sprintf(String,"%f",Value);
printf(String);
}
void write_Int(int Val)
//---------------------
{
string String;
sprintf(String,"%d",Val);
printf(String);
}
void write_Real(real Val)
//-----------------------
{
string String;
sprintf(String,"%f",Val);
printf(String);
}
void write_qStr(string String)
//----------------------------
{
if (string_quote)
printf("\"");
printf(String);
if (string_quote)
printf("\"");
}
void write_Str(string String)
//---------------------------
{
printf(String);
}
real Db2Unit(int Length)
//---------------------
{
real Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = u2mm(Length);
break;
case GRID_UNIT_MIL :
Value = u2mil(Length);
break;
case GRID_UNIT_INCH :
Value = u2inch(Length);
break;
case GRID_UNIT_MIC :
Value = u2mic(Length);
break;
}
return Value;
}
real mm2u(real val)
//-----------------
{
real Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = val;
break;
case GRID_UNIT_MIL :
Value = val*39.3700787402;
break;
case GRID_UNIT_INCH :
Value = val*0.0393700787402;
break;
case GRID_UNIT_MIC :
Value = val*0.001;
break;
}
return Value;
}
real mil2u(real val)
//-----------------
{
real Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = val*0.0254;
break;
case GRID_UNIT_MIL :
Value = val;
break;
case GRID_UNIT_INCH :
Value = val*0.001;
break;
case GRID_UNIT_MIC :
Value = val*0.0000254;
break;
}
return Value;
}
real inch2u(real val)
//-----------------
{
real Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = val*25.4;
break;
case GRID_UNIT_MIL :
Value = val*1000;
break;
case GRID_UNIT_INCH :
Value = val;
break;
case GRID_UNIT_MIC :
Value = val*0.0254;
break;
}
return Value;
}
real mic2u(real val)
//-----------------
{
real Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = val*0.001;
break;
case GRID_UNIT_MIL :
Value = val*0.0393700787402;
break;
case GRID_UNIT_INCH :
Value = val*0.0000393700787402;
break;
case GRID_UNIT_MIC :
Value = val;
break;
}
return Value;
}
int u2int_u(real val)
//-----------------
{
int Value = 0;
switch (Units)
{
case GRID_UNIT_MM :
Value = val*10000;
break;
case GRID_UNIT_MIL :
Value = val*254;
break;
case GRID_UNIT_INCH :
Value = val*254000;
break;
case GRID_UNIT_MIC :
Value = val;
break;
}
return Value;
}
real Unit2Value(real val, string s)
//---------------------
{
real Value = 0;
if( s=="m" )
{
Value = mm2u(val);
}
else
if( s=="l" )
{
Value = mil2u(val);
}
else
if( s=="h" )
{
Value = inch2u(val);
}
else
if( s=="c" )
{
Value = mic2u(val);
}
else
{
Value = val;
}
return Value;
}
//=================================================================
int NumberPadTypes = 0;
numeric string PadTypeName[];
string ViaTypeName[];
int PadTypeshape[];
int PadTypeDrill[];
int PadTypeX[];
int PadTypeY[];
int PadTypeE[];
int PadTypeAngle[];
int PadTypeLayer[];
int PadShapeRectangle=99;
//Erweiterung---------------------------------------
int ViaTypeStart[];
int ViaTypeEnd[];
//--------------------------------------------------
int ViaType = 0;
string layer_setup; // = "(1*16)";
int Layer_No[];
int Layer_count=0;
string LayerSetup[];
int LayerSetup_rk[];
int LayerSetup_ek[];
int NumberLayer=0;
int ViaBracketLevel[];
int ViaBracketPos[];
int ViaTypeDrill[];
int rgw;
int read_layer_setup(UL_BOARD B)
//----------------------------
{
int i;
int n = strlen(layer_setup);
int ek=0;
int rk=0;
int no=0;
int count=0;
for (i=0; i<n; i++)
{
string tmp_s = strsub(layer_setup, i, 1);
if (tmp_s == "[")
{
ek++;
LayerSetup_ek[count]=ek;
}
if (tmp_s == "(")
{
rk++;
LayerSetup_rk[count]=rk;
}
if (tmp_s == "]")
{
LayerSetup_ek[count]=ek;
ek--;
}
if (tmp_s == ")")
{
LayerSetup_rk[count]=rk;
rk--;
}
if (tmp_s=="0"||tmp_s=="1"||tmp_s=="2"||tmp_s=="3"||tmp_s=="4"||tmp_s=="5"||
tmp_s=="6"||tmp_s=="7"||tmp_s=="8"||tmp_s=="9")
{
if(no==1)
{
tmp_s = strsub(layer_setup, i-1, 2);
count--;
}
no=1;
}
else
{
no=0;
}
LayerSetup[count]=tmp_s;
count++;
}
return count;
}
string NewPadTypeName(int ShapeType)
//----------------------------------
{
string Name;
int i=0;
int Highest=-1;
if (ShapeType == PAD_SHAPE_SQUARE)
{
Name = "Square";
}
else
if (ShapeType == PAD_SHAPE_ROUND)
{
Name = "Round";
}
else
if (ShapeType == PAD_SHAPE_OCTAGON)
{
Name = "Octagon";
}
else
if (ShapeType == PadShapeRectangle)
{
Name = "Rectangle";
}
else
if (ShapeType == PAD_SHAPE_LONG)
{
Name = "Oblong";
}
/* else
if (ShapeType == PAD_SHAPE_OFFSET)
{
Name = "Offset";
}
*/
for (i = 0; i < NumberPadTypes; i++)
{
if (PadTypeshape[i] == ShapeType)
{
Highest = i;
}
}
int Index = 1;
if (Highest >= 0)
{
string IndexString = strsub(PadTypeName[Highest], strlen(Name));
Index = strtol(IndexString) + 1;
}
sprintf(Name, "%s%d", Name, Index);
return(Name);
}
int write_ViaType(UL_BOARD B, int n)
//----------------------------
{
int i=0;
//----Blinde Via from Top
for (i=0; i<n; i++)
{
if (LayerSetup[i] == "[" && LayerSetup[i+1]!="[" && LayerSetup[i+1]!="(")
{
if (LayerSetup[i+2]==":")
{
ViaTypeEnd[ViaType++]=strtol(LayerSetup[i+1]);
for (int j=i+1; j<n; j++)
{
if (
LayerSetup[j]==":"
&&
(strtol(LayerSetup[j+1])>0 && strtol(LayerSetup[j+1])<17)
&&
(LayerSetup[j+2]=="+" || LayerSetup[j+2]=="*")
)
{
ViaTypeStart[ViaType-1]=strtol(LayerSetup[j+1]);
break;
}
if (
LayerSetup[j]==":"
&&
( LayerSetup[j+1]=="[" || LayerSetup[j+1]=="(" )
&&
(strtol(LayerSetup[j+2])>0 && strtol(LayerSetup[j+2])<17)
&&
(LayerSetup[j+3]=="+" || LayerSetup[j+3]=="*")
)
{
ViaTypeStart[ViaType-1]=strtol(LayerSetup[j+2]);
break;
}
}
}
}
}
//----Blinde Via from Bottom
for (i=n; i>0; i--)
{
if (LayerSetup[i] == "]" && LayerSetup[i-1]!="]" && LayerSetup[i-1]!=")")
{
if (LayerSetup[i-2]==":")
{
ViaTypeStart[ViaType++]=strtol(LayerSetup[i-1]);
for (int j=i-1; j>=0; j--)
{
if (
LayerSetup[j]==":"
&&
(strtol(LayerSetup[j-1])>0 && strtol(LayerSetup[j-1])<17)
&&
(LayerSetup[j-2]=="+" || LayerSetup[j-2]=="*")
)
{
ViaTypeEnd[ViaType-1]=strtol(LayerSetup[j-1]);
break;
}
if (
LayerSetup[j]==":"
&&
( LayerSetup[j-1]=="]" || LayerSetup[j-1]==")" )
&&
(strtol(LayerSetup[j-2])>0 && strtol(LayerSetup[j-2])<17)
&&
(LayerSetup[j-3]=="+" || LayerSetup[j-3]=="*")
)
{
ViaTypeEnd[ViaType-1]=strtol(LayerSetup[j-2]);
break;
}
}
}
}
}
//----Buried Via from Top
int BracketStart[];
int BracketEnd[];
// Offene Klammern zu denen noch keine passende geschlossene Klammer gefunden wurde.
// Temporärer Array, der nur während der Berechnung benötigt wird.
int unhandeled_open_brackets [];
int unhandeled_open_bracket_count = 0;
// Arrays der gefundenen Positionen der zueinander passenen offenen und geschlossenen Klammern.
int bracket_count;
int open_brackets[];
int closed_brackets[];
// Berechnet Paare von offenen und geschlossenen Klammern und speichert das Ergebnis in
// den Arrays open_brackets und closed_brackets
// Schleife über den ganzen String
for (i=0; i<n ; i++)
{
// gehe bis zur nächsten geschlossenen Klammer und paare sie mit der letzen
// offenen Klammer im Array unhandeled_open_brackets.
if(LayerSetup[i]=="(")
{
unhandeled_open_brackets[unhandeled_open_bracket_count] = i;
++unhandeled_open_bracket_count;
}
else if(LayerSetup[i]==")")
{
// Geschlossene Klammer gefunden.
closed_brackets[bracket_count] = i;
if (unhandeled_open_bracket_count <= 0)
{
// Fehler, der geschlossenen Klammer geht keine offene Klammer vorous
}
// Die passende offenne Klammer ist die letzte im Array unhandeled_open_brackets
// Füge sie zum Array open_brackets hinzu und entferne sie aus dem Array unhandeled_open_brackets
--unhandeled_open_bracket_count;
open_brackets[bracket_count] = unhandeled_open_brackets [unhandeled_open_bracket_count];
++bracket_count;
}
}
if (unhandeled_open_bracket_count != 0)
{
// Fehler, Anzahl der offenen und geschlossenen Klammern ist nicht gleich
}
for( i=0; i<bracket_count; i++)
{
int j;
for( j=open_brackets[i]; j<=closed_brackets[i]; j++)
{
if( LayerSetup[j]=="(" && (strtol(LayerSetup[j+1])>0 && strtol(LayerSetup[j+1])<17))
{
ViaTypeStart[ViaType]=strtol(LayerSetup[j+1]);
break;
}
}
for(j=closed_brackets[i]; j>=open_brackets[i]; j--)
{
if( LayerSetup[j]==")" && (strtol(LayerSetup[j-1])>0 && strtol(LayerSetup[j-1])<17))
{
ViaTypeEnd[ViaType++]=strtol(LayerSetup[j-1]);
break;
}
}
}
NumberPadTypes = ViaType;
for (i=0; i<ViaType; i++)
{
PadTypeshape[i]=1;
PadTypeX[i] = u2int_u(default_via_size);
PadTypeDrill[i] = u2int_u(default_drill_size);
PadTypeY[i] = 0;
PadTypeE[i] = 0;
PadTypeAngle[i] = 0;
PadTypeLayer[i] = 0;
sprintf(PadTypeName[i], "%s%d$%f", "Round", i+1, Db2Unit(PadTypeDrill[i]));
ViaTypeName[i] = PadTypeName[i];
}
return n;
}
int find_layer(UL_BOARD B,int n)
//----------------------------
{
string tmp;
for (int i=0; i<n; i++)
{
int Found=-1;
if(strtol(LayerSetup[i])>0 && strtol(LayerSetup[i])<17)
{
for (int j=0; (j<Layer_count); j++)
{
if (Layer_No[j]==strtol(LayerSetup[i]))
{
Found=j;
break;
}
}
if(Found==-1)
{
Layer_No[Layer_count++]=strtol(LayerSetup[i]);
}
}
}
sort( Layer_count, Layer_No);
for (int j=0; (j<Layer_count); j++)
{
sprintf(tmp, "%d", Layer_No[j]);
}
return Layer_count;
}
void PTHPadType(UL_PAD Pad)
//-------------------------
{
int i=0;
int Found=-1;
for (i=0; (i<NumberPadTypes) && (Found==-1); i++)
{
if (PadTypeshape[i] == Pad.shape[LAYER_TOP] &&
PadTypeX[i] == Pad.diameter[LAYER_TOP] &&
PadTypeE[i] == Pad.elongation &&
PadTypeAngle[i] == Pad.angle &&
PadTypeDrill[i] == Pad.drill &&
PadTypeY[i] == 0 &&
PadTypeLayer[i] == 0)
{
Found = i;
}
}
if (Found==-1)
{
PadTypeName[NumberPadTypes] = NewPadTypeName(Pad.shape[LAYER_TOP]);
PadTypeshape[NumberPadTypes] = Pad.shape[LAYER_TOP];
PadTypeX[NumberPadTypes] = Pad.diameter[LAYER_TOP];
PadTypeE[NumberPadTypes] = Pad.elongation;
PadTypeAngle[NumberPadTypes] = Pad.angle;
PadTypeDrill[NumberPadTypes] = Pad.drill;
PadTypeY[NumberPadTypes] = 0;
PadTypeLayer[NumberPadTypes] = 0;
NumberPadTypes++;
}
}
void SMDPadType(UL_SMD Pad)
//-------------------------
{
int i=0;
int Found=-1;
int ShapeType = PadShapeRectangle;
// Fehlerhaft bei rechteckigen SMD-Pads mit Roundness 100 20050620 thk
if (Pad.roundness == 100)
ShapeType = PAD_SHAPE_ROUND;
for (i=0; (i<NumberPadTypes) && (Found==-1); i++)
{
if (PadTypeshape[i] == ShapeType &&
PadTypeX[i] == Pad.dx &&
PadTypeY[i] == Pad.dy &&
PadTypeAngle[i] == Pad.angle &&
PadTypeLayer[i] == Pad.layer)
{
Found = i;
}
}
if (Found == -1)
{
PadTypeName[NumberPadTypes] = NewPadTypeName(ShapeType);
PadTypeshape[NumberPadTypes] = ShapeType;
PadTypeX[NumberPadTypes] = Pad.dx;
PadTypeY[NumberPadTypes] = Pad.dy;
PadTypeE[NumberPadTypes] = 0;
PadTypeAngle[NumberPadTypes] = Pad.angle;
PadTypeDrill[NumberPadTypes] = 0;
PadTypeLayer[NumberPadTypes] = Pad.layer;
NumberPadTypes++;
}
}
void ViaPadType(UL_VIA Via)
//-------------------------
{
int i=0;
int Found=-1;
for (i=0; (i<NumberPadTypes) && (Found==-1); i++)
{
if (PadTypeshape[i] == Via.shape[LAYER_TOP] &&
PadTypeX[i] == Via.diameter[LAYER_TOP] &&
PadTypeDrill[i] == Via.drill &&
//Erweiterung---------------------------------------
ViaTypeStart[i] == Via.start &&
ViaTypeEnd[i] == Via.end &&
//--------------------------------------------------
PadTypeY[i] == 0 &&
PadTypeLayer[i] == 0)
{
Found = i;
}
}
if (Found==-1)
{
//Erweiterung---------------------------------------
ViaTypeStart[NumberPadTypes] = Via.start;
ViaTypeEnd[NumberPadTypes] = Via.end;
//--------------------------------------------------
PadTypeshape[NumberPadTypes] = Via.shape[LAYER_TOP];
PadTypeX[NumberPadTypes] = Via.diameter[LAYER_TOP];
PadTypeDrill[NumberPadTypes] = Via.drill;
PadTypeY[NumberPadTypes] = 0;
PadTypeE[NumberPadTypes] = 0;
PadTypeAngle[NumberPadTypes] = 0;
PadTypeLayer[NumberPadTypes] = 0;
sprintf(PadTypeName[NumberPadTypes], "%s$%f", NewPadTypeName(Via.shape[LAYER_VIAS]), Db2Unit(PadTypeDrill[NumberPadTypes]));
ViaTypeName[ViaType] = PadTypeName[NumberPadTypes];
ViaType++;
NumberPadTypes++;
}
}
string FindPadType(int ShapeType, int XSize, int YSize, int drill, int Layer, int Elongation, int Angle)
//------------------------------------------------------------------------------------------------------
{
int i=0;
int Found=-1;
for (i=0; (i<NumberPadTypes) && (Found==-1); i++)
{
if (PadTypeshape[i] == ShapeType &&
PadTypeX[i] == XSize &&
PadTypeY[i] == YSize &&
PadTypeAngle[i] == Angle &&
PadTypeDrill[i] == drill &&
PadTypeE[i] == Elongation &&
PadTypeLayer[i] == Layer)
{
Found = i;
}
}
return(PadTypeName[Found]);
}
string FindViaType(int ShapeType, int XSize, int YSize, int drill, int Layer, int Elongation, int Angle, int start, int end)
//--------------------------------------------------------------------------------------------------------------------------
{
int i=0;
int Found=-1;
for (i=0; (i<NumberPadTypes) && (Found==-1); i++)
{
if (PadTypeshape[i] == ShapeType &&
ViaTypeStart[i] == start &&
ViaTypeEnd[i] == end &&
PadTypeX[i] == XSize &&
PadTypeY[i] == YSize &&
PadTypeAngle[i] == Angle &&
PadTypeDrill[i] == drill &&
PadTypeE[i] == Elongation &&
PadTypeLayer[i] == Layer)
{
Found = i;
}
}
return(PadTypeName[Found]);
}
void FPPadTypes(UL_PACKAGE FP)
//----------------------------
{
FP.contacts(C)
{
if (C.pad)
{
PTHPadType(C.pad);
}
if (C.smd)
{
SMDPadType(C.smd);
}
}
}
string LayerFromId_old(int Id)
//------------------------
{
string LayerName;
if ((Id < 1) || (Id > 16))
return "signal";
board(Board)
{
Board.layers(Layer)
{
if (Layer.number == Id)
{
LayerName = Layer.name;
return LayerName;
}
}
}
return "signal";
}
string LayerFromId(int Id)
//------------------------
{
string LayerName;
if ((Id < 1) || (Id > 16))
return "signal";
for (int i = 0; i < rgw; i++)
{
if (Layer_No[i] == Id)
{
sprintf(LayerName,"%d#%s", Layer_No[i], LayerFromId_old(Layer_No[i]));
if(string_quote)
sprintf(LayerName,"%c%s%c",'"', LayerName, '"');
return LayerName;
}
}
return "signal";
}
void write_Octagon(int o, int i, real a, real b)
//------------------
{
printf("\n (shape ");
printf("(polygon ");
printf(LayerFromId(o));
printf(" 0 ");
printf("%f %f ", a, b );// 1
printf("%f %f ", b, a );// 2
printf("%f %f ", -b, a );// 3
printf("%f %f ", -a, b );// 4
printf("%f %f ", -a, -b );// 5
printf("%f %f ", -b, -a );// 6
printf("%f %f ", b, -a );// 7
printf("%f %f ", a, -b );// 8
printf("))");
}
void Padstacks()
//--------------
{
int i, j, l;
real Side, a, b;
string tmp;
printf(" (padstack ");
sprintf(tmp, "ViaDefault$%f", default_drill_size);
write_qStr(tmp); printf("\n");
printf(" (shape (circle signal %f", default_via_size);
printf(" 0 0))\n");
printf(" )\n");
for (i=0; i<NumberPadTypes; i++)
{
l=0;
printf(" (padstack ");
write_qStr(PadTypeName[i]); printf(" ");// "\n"
if (PadTypeshape[i]==PAD_SHAPE_ROUND)
{
if (PadTypeLayer[i]==0)
{
for( j=0; j <rgw; j++)
{
if(ViaTypeStart[i] <= Layer_No[j])
{
if(Layer_No[j] > ViaTypeEnd[i])
{
if(l==0)
{
printf("\n (shape ");
printf("(circle ");
printf(LayerFromId(ViaTypeStart[i]));
printf(" ");
write_Db2Unit(PadTypeX[i]);
printf(" 0 0))");
}
break;
}
else
{
l=1;
printf("\n (shape ");
printf("(circle ");
printf(LayerFromId(Layer_No[j]));
printf(" ");
write_Db2Unit(PadTypeX[i]);
printf(" 0 0))");
}
}
}
}
else
{
printf(" (shape ");
printf("(circle ");
printf(LayerFromId(PadTypeLayer[i]));
printf(" ");
write_Db2Unit(PadTypeX[i]);
printf(" 0 0))");
}
}
else
if (PadTypeshape[i]==PAD_SHAPE_OCTAGON)
{
a=Db2Unit(PadTypeX[i])/2;
b=(Db2Unit(PadTypeX[i])/2)*0.4142135;
if (PadTypeLayer[i]==0)
{
for( j=0; j <rgw; j++)
{
if(ViaTypeStart[i] <= Layer_No[j])
{
if(Layer_No[j] > ViaTypeEnd[i])
{
if(l==0)
{
if(Layer_No[j]==Layer_No[0])
write_Octagon(Layer_No[j], i, a, b);
if((j > 0) && (j < rgw-1))
{
printf("\n (shape ");
printf("(circle ");
printf(LayerFromId(Layer_No[j]));
printf(" ");
if(Db2Unit(PadTypeDrill[i])+(min_pad_inner*2) >= Db2Unit(PadTypeDrill[i])*(1+rv_pad_inner*2))
{
printf("%f",Db2Unit(PadTypeDrill[i])+(min_pad_inner*2));
}
else if(Db2Unit(PadTypeDrill[i])*(1+rv_pad_inner*2) <= Db2Unit(PadTypeDrill[i])+(max_pad_inner*2))
{
printf("%f",Db2Unit(PadTypeDrill[i])*(1+rv_pad_inner*2));
}
else
{
printf("%f",Db2Unit(PadTypeDrill[i])+(max_pad_inner*2));
}
printf(" 0 0))");
}
if(Layer_No[j]==Layer_No[rgw-1])
write_Octagon(Layer_No[j], i, a, b);
}
// break;
}
else
{
l=1;
if(Layer_No[j]==Layer_No[0])