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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
|
This document is the reference manual for the harness Draw, Draw is a
command interpreter based on TCL and a graphical system used to test
and demonstrate CAS.CADE modeling libraries. In this document are
described the basics of the TCL command language and Draw extensions,
the commands to do geometry and the commands to do topology.
*Overview
Draw is a test and development harness for CAS.CADE. It is intended to
provide a flexible and easy-to-use means of testing and demonstrating
the CAS.CADE modeling libraries.
Draw can be used interactively to create, display and modify objects
such as curves, surfaces and topological shapes.
Scripts can be written to customize Draw and perform tests. New types
of objects and new commands can be added using the C++ programing
language.
Draw is basically made up of
- a command interpreter based on the TCL command language
- a 3d graphic viewer based on the X system
- a basic set of commands covering scripts, variables and graphics
- a set of geometric commands, allowing to create and modify curves
and surfaces and to use CAS.CADE geometry algorithms. This set of
commands is optional
- a set of topological commands to create and modify BRep shapes and
to use the CAS.CADE topology algorithms
As a rule there is an "official" set of commands for each delivery
unit in the modeling libraries : GEOMETRY, TOPOLOGY, ADVALGOS,
GRAPHIC, PRESENTATION
**Contents of the documentation
This documentation describes
- the command language
- the basic set of commands
- the graphical commands
- the geometry set of commands
- the topology set of commands
This document does not describe the other sets of commands and does
not explain how to extend Draw using C++.
This document is mainly a reference manual, it contains descriptions
of commands, all descriptions have the same format which is above
illustrated with the exit command.
*** exit
.Synopsis
exit
.Purpose
Terminates the Draw, TCL session. If the commands are read from a file
using the source command this will terminante reading from the file.
.Example
# this is a very short example
exit
.See also
source
.Index
exit command
**Getting started
We will now try a simple example. The first thing to do is to setup a
Draw executable, check if the DRAW and TCL ULs are visible in your
workbench with the wok command "ulinuse". If DRAW does not appear you
should check with your workshop manager to install DRAW and TCL.
We will now suppose that you have a DRAW version, at least DRAW-7 (use
"ulinuse -v" to check so). You must now find an executable. Let us
try TGEOMETRY. Just type TGEOMETRY, if you do not get a prompt
"Draw[1]> " you must create an executable by linking the program from
the source example TestDraw.cxx which can be found in the src
directory of the UL.
Draw displays prompt and waits for commands, here is a sample session
:
.Example
# create Two views 2d and axonometric
Draw[1]> av2d
# create a 2d circle
Draw[2]> circle c 0 0 1 0 5
Draw[3]> 2dfit
# trim the circle and dump it
Draw[4]> trim c c 0 pi/2
Draw[5]> dump c
0*********** Dump of c *************
Trimmed curve
Parameters : 0 1.5707963267949
Basis curve :
Circle
Center :0, 0
XAxis :1, 0
YAxis :-0, 1
Radius :5
# make a 3d circle from it, and turn it into a bspline
Draw[6]> to3d c c
Draw[7]> fit
Draw[8]> convert c c
Draw[9]> dump c
0*********** Dump of c *************
BSplineCurve rational
Degree 2, 3 Poles, 2 Knots
Poles :
1 : 5, 0, 0 1
2 : 5, 5, 0 0.707106781186548
3 : 3.06161699786838e-16, 5, 0 1
Knots :
1 : 0 3
2 : 1.5707963267949 3
.Example
# make a surface of revolution from the spline
Draw[10]> fit
Draw[11]> help rev
reverse : reverse name ...
revsurf : revsurf name curvename x y z dx dy dz
# here you must click on the curve with the mouse
Draw[12]> revsurf s . 5 5 0 -1 1 0
Pick an object
Draw[13]> fit
# rotate the view
Draw[14]> u
Draw[15]> erase c
c
# make a bspline surface and intersect with a plane
Draw[20]> convert s s
Draw[21]> fit
Draw[22]> plane p 5 5 5 1 1 1 1 0 0
Draw[23]> intersect c p s
# pick on one of the intersection curves
# you may get c_2 onstead of c_1
Draw[24]> whatis .
Pick an object
c_1 is a a 3d curve
Draw[25]> clear
Draw[27]> rename c_1 c
Draw[28]> fit
# save the curve, use any directory where you can write
Draw[29]> datadir $env(WBCONTAINER)/data/default
/adv_20/BAG/data/default
Draw[30]> save c curveinter
c
Draw[31]> exit
.Text
In this example some geometrical operations have been performed,
objects have been displayed and wrote to files.
*The command language
The command language used in Draw is the TCL command language. It is
highly recommended, if you want to use Draw extensively, to read some
TCL documentation like "TCL and the TK Toolkit" by John K. Ousterhout
(Addison-Wesley).
The following section is a short outline of the TCL language and its
extensions incorporated in Draw. The following topics will be covered.
- syntax of the TCL language
- accessing variables in TCL and Draw
- control structures
- procedures
** Syntax of TCL
.Index
TCL
script
command
word
substitution
quoting
.Text
TCL is an interpreted command language, it is not a structured
language like C, Pascal, LISP or Basic, it is rather a line oriented
language like a shell (csh for example). However you will find that
TCL is easier to use than shell because control structures and
procedure are easier to define. TCL is also faster than shell because
it does not fork a process for each command.
The basic program for TCL is a script. A script consists of one or
more commands. Commands are separated by newlines or semicolons.
.Example
set a 24
set b 15
set a 25; set b 15
.Text
Each command consists of one or more words, the first word is the name
of a command and additional words are arguments for that command.
Words are separated by spaces or tabs. In the preceding example each
command has three words. There may be any number of words in a command
and each word is a string of arbitrary length.
The evaluation of a command by TCL follows two steps. In the first
step the command is parsed and broken into words and some
substitutions are performed. In the second step the command procedure
corresponding to the first word is called with the other words as
arguments. In the first step there is only string manipulation,
meaning is given to the words only in the second step by the command
procedure.
The following substitutions are performed by TCL
- Variable substitution is triggered by the $ character (as with csh),
the content of the variable is substituted, {} may be used as in csh
to enclose the name of the variable.
.Example
# set a variable value
set file documentation
# a simple substitution, set psfile to documentation.ps
set psfile $file.ps
# another substitution, set pfile to documentationPS
set pfile ${file}PS
# a last one,
# delete files NEWdocumentation and OLDdocumentation
foreach prefix {NEW OLD} {rm $prefix$file}
.Text
- Command substitution is triggered by the [] characters. The brackets
must enclose a valid script, this scrit is evaluated and the result is
substituted. This is similar to the `command` construction in csh.
.Example
set degree 30
set pi 3.14159265
# expr is a command evaluating a numeric expression
set radian [expr $pi*$degree/180]
.Index
expr command
.Text
- Backslash substitution is triggered by the backslash character. It
is used to insert special characters like : $,[,]. A backslash
terminated line is continued on the following line.
TCL uses two forms of quoting to prevent substitution and word
breaking.
- Double quote quoting enables to define a string with space and tabs
as a single word, substitutions are still performed inside the "".
.Example
# set msg to "the price is 12.00$"
set price "\$ 12.00"
set msg "the price is $price"
.Text
- Braces quoting prevent all the substitutions. Braces are also
nested. The main use of braces is to defer evaluation when defining
procedures and control structures. Braces are useful to present nicely
TCL scripts on multiple lines.
.Example
set x 0
# this will loop for ever
# because while argument is "0 < 3"
while "$x < 3" {set x [expr $x+1]}
# this will terminate as expected because
# while argument is {$x < 3}
while {$x < 3} {set x [expr $x+1]}
# this can be written also
while {$x < 3} {
set x [expr $x+1]
}
# the following cannot be written
# because while requires two arguments
while {$x < 3}
{
set x [expr $x+1]
}
.Text
Comments start with a # character as the first non blank character in
a command. If you want to comment at the end of the line you must
precede the comment by semi-colon to end the preceding command.
.Example
# This is a comment
set a 1 # this is not a comment
set b 1; # this is a comment
.Text
Last but not least thing to know about parsing in TCL is that the
number of words is never changed by substitution. For example the
result of a substitution is always a single word. This is different
than csh but it is very convenient as the behavior of the parser is
more predictable. Sometimes it may be necessary to enforce a second
round of evaluation to reparse, the eval command is useful to that
purpose. This command concatenates all its arguments and evaluates
this script.
.Example
# I want to delete two files
set files "foo bar"
# this will fail because rm will receive only one argument
# and complain that "foo bar" does not exists
exec rm $files
# a second evaluation will do it
eval exec rm $files
.Index
eval command
exec command
** Accessing variables in TCL and Draw
TCL variables have only string values. Note that even numeric values
are stored as string literals and computations with the expr command
start by parsing the strings. This approach is not sufficient for Draw
where variables with other kinds of values are necessary, such as
curves, surfaces or topological shapes.
Fortunately TCL provides a mechanism to link user data to variables,
this mechanism is used with Draw. Draw variables are TCL variables
with associated data. The string value of a Draw variable is
meaningless, it is usually set to the name of the variable itself, so
preceding a Draw variable with a $ do not change the result of a
command. The content of a Draw variable is accessed with appropriate
commands. There are many kinds of Draw variables, and new ones may be
added with C++. We will describe later geometric and topological
variables, for the moment we will only describe the numeric variables.
Draw numeric variables can be used within an expression whereever a
Draw comand requires a numeric value. The expr command is useless in
this case. Those variables are not stored as strings but as floating
point values.
.Example
# dset is used for numeric variables
# pi is a predefined Draw variable
dset angle pi/3 radius 10
point p radius*cos(angle) radius*sin(angle) 0
.Text
At the beginning the difference between TCL and Draw variables may be
confusing but you will be quickly used to it. My advice is to use TCL
variable only for strings and to use Draw for numerics as you can
avoid the expr command. Usually for geometry and topology you will
only need numbers no strings.
.Index
numeric variables
Draw variables
pi
*** set, unset
.Synopsis
set varname [value]
unset varname [varname varname ...]
.Purpose
Use the set command to assign a string value to a variable. If the
variable does not exist it is created.
Without the value argument the command returns the content of the
variable.
Use the unset command to destroy the variables. This is is also used
to destroy Draw variables.
.Example
set a "Hello world"
set b "Goodbye"
set a
==> "Hello world"
unset a b
set a
==> Error message....
.Warning
The set command can set only one variable, unlike the dset command.
.See also
dset, dval
.Index
set command
unset command
*** dset, dval
.Synopsis
dset varname expression [varname expression ...]
dval expression
.Purpose
Use the dset command to assign values to Draw numeric variables. The
expression may be any numeric expression including Draw numeric
variables, as any Draw command expecting a numeric expression there is
no need for $ or expr. The dset command can assign many variables, if
there is an odd number of argument the last variable will be assigned
a value of 0. If the variable does not exist it will be created.
Use dval to evaluate an expression containing Draw numeric variables
and return the result as a string, including a single variable. This
not useful for Draw commands as they usually interpret expression, but
this is useful for TCL basic commands expecting strings.
.Example
# z is set to 0
dset x 10 y 15 z
# no $ required for Draw commands
point p x y z
# puts prints a string
puts "x = [dval x], cos(x/pi) = [dval cos(x/pi)]"
.Warning
In TCL parentheses are not considered as special characters, so do not
forget to quote an expression if it contains spaces to avoid parsing
different words.
(a + b) is parsed as three words, "(a + b)" or (a+b) are correct.
.See also
set, unset
.Index
dset command
dval command
** lists
TCL uses lists a lot, a list is only a string containing elements
separated by spaces or tabs. If the string contains braces the braced
part count for one element, this allows to put lists in lists.
.Example
# a list of 3 strings
"a b c"
# a list of two strings the first is a list of 2
"{a b} c"
.Text
Many TCL commands return lists and the foreach command is an useful
way to loop on list elements.
** Control Structures
TCL allows repetition of an execution using control structures. The
control structures are implemented with commands and their syntax is
very similar to their C counterpart (if, while, switch,..). There are
two main differences with C. Do not use parentheses to enclose
conditions but braces, do not start the script on the next line or
your command will not have enough argument.
*** if
.Synopsis
if condition script [elseif script .... else script]
.Purpose
If evaluate the condition and evaluate the script if the condition is
true, and so on.
.Example
# note the position of the braces
# even if you find it ugly, you must do it this way
if {$x > 0} {
puts "positive"
} elseif {$x == 0} {
puts "null"
} else {
puts "negative"
}
.Index
if command
*** while, for, foreach
.Synopsis
while condition script
for init condition reinit script
foreach varname list script
.Purpose
The three loop structures are similar to their C or csh equivalent. It
is important to use braces to delay evaluation. foreach will assign
the elements of the list to the variable before evaluating the script.
.Example
# while example
dset x 1.1
while {[dval x] < 100} {
circle c 0 0 x
dset x x*x
}
# for example
# incr var d, incremente une variable de d (defaut 1)
for {set i 0} {$i < 10} {incr i} {
dset angle $i*pi/10
point p$i cos(angle0 sin(angle) 0
}
# foreach example
foreach object {crapo tomson lucas} {display $object}
.Index
while command
for command
foreach command
incr command
.See also
break, continue
*** break, continue
.Synopsis
break
continue
.Purpose
Within loops the, break and continue commands have the same effect
than in C. break interrupts the innermost loop and continue steps to
the next iteration.
.Example
# search the index for which t$i has value "secret"
for {set i 1} {$i <= 100} {incr i} {
if {[set t$i] == "secret"} break;
}
.Warning
.See also
.Index
break command
continue command
** Procedures
TCL can be extended by defining procedures using the proc command. The
proc commandsetup a context of local variables, binds arguments and
executes a TCL script.
The only confusing point in procedures is that variables are strictly
local, and as they are implicitly created when used it may be
difficult to detect the errors.
There are two means to access a variable outside the scope of the
current procedure. The global command may be used to declare a global
variable (a variable outside all procedures), the upvar command can be
used to access a variable in the scope of the caller. In TCL arguments
are always string values, the only way to pass Draw variables is to
pass by reference, i.e. passing the name of the variable and using
the upvar command as in the following examples.
TCL is not a strongly typed language, it is thus very difficult to
detect programming errors and debugging can be tedious, TCL procedures
are not designed for large scale software development but for testing
and simple command or interactive writing.
*** proc
.Synopsis
proc arglist script
.Purpose
Use the proc command to define a procedure, arglist is the list of
arguments, it must be an empty list if there are no arguments. An
argument may have a default value, it is then a list of the form
{argument value}. The script is the body of the procedure.
The return command is used to give a return value to the procedure.
.Example
# simple procedure
proc hello {} {
puts "hello world"
}
# procedure with arguments and default values
proc distance {x1 y1 {x2 0} {y2 0}} {
set d [expr (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)]
return [expr sqrt(d)]
}
# we could not resist the classical one
proc fact n {
if {$n == 0} {return 1} else {
return [expr n*[fact [expr n -1]]]
}
}
.Warning
.See also
global, upvar
.Index
proc command
procedure
*** global, upvar
.Synopsis
global varname [varname ...]
upvar varname localname [varname localname ...]
.Purpose
Use the global command to access top level variables. Unlike in C
global variables are not visible in procedures.
Use the upvar command to give a local name to a variable in the caller
scope, this is when an argument is the name of a variable instead of a
value, this is call by reference and it is the only way to use Draw
variables as arguments.
Note in the following examples that the $ is always necessary to
access the arguments.
.Example
# convert degree to radian
# pi is a global variable
proc deg2rad (degree} {
global pi
return [dval pi*$degree/180.]
}
# create line with a point and an angle
proc linang {linename x y angle} {
upvar linename l
line l $x $y cos($angle) sin($angle)
}
.Warning
.See also
.Index
global command
upvar command
reference, call by
value, call by
*Basic commands
We will now describe all the commands defined in the basic Draw
package. Some of the commands are TCL commands, but most of them are
defined by Draw. Those commands are found in all Draw applications.
The commands are grouped in four sections
- general commandsused for Draw and TCL management
- variable commands used to manage Draw variables, storing, dumping ...
- graphic commands used to manage the graphic system : views ...
- variables display commands are used to manage the display of objects
**General commands
This section describes some useful commands, help to get information,
source to eval a script from a file, spy to capture the commands in a
file, cpulimit limit the process cpu time, wait to waste some time,
chrono to time commands.
***help
.Synopsis
help [command [helpstring group]]
.Purpose
Provides help or modifies the help information.
help, without arguments list all groups and the commands in each
group.
help command, provides information on a command or a set of commands,
command may be a shell-like regular expression. * is automatically
added at the end so that all completing commands match.
help command helpstring group, defines helpstring to be the help for
command, put the command in the group. The group defaults to "User
commands".
.Example
# Gives help on all command starting with a
help a
# defines help for the help command
help {help [command [helpstring group = "Use commands"]]} "DRAW Basic Commands"
.Index
help command
***source
.Synopsis
source file
.Purpose
Reads and evaluates commands from a file.
The exit command will terminate the file.
.See also
exit
.Index
source command
*** spy
.Synopsis
spy [file]
.Purpose
Save interactive commands in the file. If there is already spying the
current file is closed. spy without argument closes the current file
and stops spying.
If a command returns an error it is saved with a comment mark.
The file created by spy can be played with the source command.
.Example
# from now all commands will be saved in the file "session"
spy session
# the file "session" is closed and commands are not saved
spy
.See also
source
.Index
spy command
spying session
*** cpulimit
.Synopsis
cpulimit [nbseconds]
.Purpose
The process will be interrupted after nbseconds of cpu, this is useful
during tests to avoid infinite loops. cpulimit without arguments
removes all existing limits.
.Example
#limit cpu to one hour
cpulimit 3600
.Index
cpulimit command
*** wait
.Synopsis
wait [nbseconds]
.Purpose
Interrupt execution for nbseconds, the default value is ten (10)
seconds. This is usefull in a demo to give people time to admire a
nice picture.
.Example
# You have ten seconds ...
wait
.Index
wait command
*** chrono
.Synopsis
chrono [ name start/stop/reset/show]
.Purpose
The chrono command has two usages, without arguments it toggles the
timing of commands. When chronometers are activated each command will
be timed, i.e. the cpu and user time of the command will be printed.
With arguments the chrono command is used to manage chronometers, a
chronometer is a special kind of Draw variable used to measure
time. The following action can be performed on a chronometer.
- start : to run the chronometer.
- stop : to stop the chronometer.
- reset : to reset the chronometer to 0.
- show : to display the current time.
Chronometers are useful to print partial times as in the following
example, the timing of the command foreach will only give you the time
for all the process.
.Example
# use of a chronometer
chrono swatch
foreach face {f1 f2 f3 f4 f5} {
chrono swatch reset
processface $face
chrono swatch stop
puts "$face is processed"
chrono swatch show
}
.Index
chrono command
** Variables management commands
We describe now commands used to manage Draw variables. isdraw test if
a variable is a draw variable, directory list draw variables, whatis
gives the type of a variable, dump prints the content of a variable,
rename and copy change the content of variables, datadir, save and
restore are used to put the contents of variables in files.
*** isdraw, directory
.Synopsis
isdraw varname
directory [pattern]
.Purpose
Use isdraw to test if a variable is a draw variable, isdraw will
return 1 if there is a Draw value attached to the variable.
Use directory to return a list of all Draw global variables matching a
pattern, like the shell ls command.
.Example
set a 1
isdraw a
===> 0
dset a 1
isdraw a
===> 1
circle c 0 0 1 0 5
isdraw c
===> 1
# to destroy all Draw objects with name containing curve
foreach var [directory *curve*] {unset $var}
.See also
whatis
.Index
isdraw command
directory command
*** whatis, dump
.Synopsis
whatis varname [varname ...]
dump varname [varname ...]
.Purpose
Use whatis to get a short information about a Draw variable, the
result depends on the type of the object. Usually it is the name of
the type.
Use dump to get a long information about a Draw variable, the result
depends on the type of the object. Usually it is a full dump (may be
rather long for geometry or topology).
.Example
dset x 3
whatis x
==> x is a numeric
dump x
==> *********** Dump of x *************
==> 3
.Warning
The behavior of whatis on other variables (not Draw) is not excellent.
.Index
whatis command
dump command
*** rename, copy
.Synopsis
rename varname tovarname [varname tovarname ...]
copy varname tovarname [varname tovarname ...]
.Purpose
Use rename to change the name of a Draw variable, the original
variable does not exist any more, note that the content is not
modified, only the name is changed.
Use copy to make a new variable with a copy of the content of an
existing variable. The exact behavior of copy is type dependent, in
some cases the content may still be shared (see the topological
variables for example).
.Example
circle c1 0 0 1 0 5
rename c1 c2
# curves are copied, c2 will not be modified
copy c2 c3
2dtranslate c3 10 0
.Index
rename command
copy command
*** datadir, save, restore
.Synopsis
datadir [data-path]
save name [filename]
restore filename [name]
.Purpose
Use save and restore to transfert the content of Draw variables to
files, the files are located in the data directory.
Use save to write a file in the data directory with the content of a
variable, by default the name of the file is the name of the variable,
to give a different name use a second argument.
Use restore to read the content of a file in the data directory in a
local variable, by default the name of the variable if the name of the
file, to give a different name use a second argument.
The exact content of the file is type dependent, they are usually
ASCII files, so they are architecture independnts.
.Example
# note how TCL access shell environment variables
# using $env()
datadir $env(WBCONTAINER)/data/default
datadir
==> /adv_20/BAG/data/default
box b 10 20 30
save b theBox
# when TCL does not find a command it tries a shell command
ls [datadir]
==> theBox
restore theBox
datadir ./bugs
datadir
==> /adv_20/BAG/data/bugs
# now the box is saved in both the default and data directories
save theBox
.Index
datadir command
save command
restore command
environment variables
**Graphic Commands
Graphic commands are used to manage the Draw graphic system. Draw
provides a 2d and a 3d viewer with up to 30 views, views are numbered
and the index of the view is visible in the title of the
window. Objects are displayed in all 2d views or in all 3d views
depending on their type but never on both.
The view and delete commands are the basic view management commands,
but useful procedures for screen layout are defined, axo, left, top.
Commands are provided to modify the view parameters, fit, zoom, pu,
pd, pl, pr to pan, u,d,l,r to rotate. fu, fd to change the focal.
The view parameters commands process all views or only one view, in
this case the index of the view must be given as the first argument. A
command control 3d views or 2d views, the 2d views version of the
command starts with 2d, for example zoom and 2dzoom.
Colors are numbered from 1 to 15, the aspect can be changed with the
color command.
To put some text on the screen use the dtext command.
Postscript drawings can be made with the hardcopy command and xwd
files with the xwd command.
To use the mouse you can use the pick and the wclick commands.
*** view, delete
.Synopsis
view index type [X Y W H]
delete [index]
.Purpose
view is the basic view creation command. It creates a new view with
the given index, if a view already exits with this index it is
destroyed. The view is created with default parameters and X Y W H are
the position and dimensions on the window on the screen, they are X
window system coordinates in pixel, 0,0 being the upper left corner of
the screen. Default values are 0, 0, 500, 500 which is not very
convenient.
Usually it is far simpler to use the procedures as axo, top, left to
create views.
delete destroy a view, if no index is given all views are destroyed.
The type is a four letter upper case code among the followings
- AXON : Axonometric view
- PERS : Perspective view
- +X+Y : View on the two axes (i.e. a top view), other codes are
-X+Y +Y-Z etc...
- -2D- : 2d view
The index, the type, the current zoom are displayed in the window
title.
.Example
# this is the content of the mu4 procedure
proc mu4 {} {
delete
view 1 +X+Z 320 20 400 400
view 2 +X+Y 320 450 400 400
view 3 +Y+Z 728 20 400 400
view 4 AXON 728 450 400 400
}
.See also
axo, pers, top, bottom, left, right, front, back, mu4
v2d, av2d, smallview
.Index
view command
delete command
window
*** axo, pers, top, ...
.Synopsis
axo
pers
...
smallview type
.Purpose
All these commands are procedures used to define standard screen
layout, they delete all existing views and create some views. The
layout usually abides by the european convention, i.e. the top view is
under the front view.
- axo : One big axonometric view
- pers : One big perspective view
- top, bottom, left, right, front, back : One big axis view
- mu4 : Four views layout with front, left, top and axo
- v2d : One big 2d view
- av2d : Two views, one 2d and one axo
The smallview command creates a view at the right bottom of the screen
with the given type. See the view command for the type list.
.Example
# just try them !!
# here we give the body of smallview
proc smallview {{v AXON}} {
delete
view 1 $v 728 450 400 400
}
.See also
view, delete
.Index
axo command
pers command
top command
top command
bottom command
left command
right command
front command
back command
mu4 command
v2d command
av2d command
smallview command
screen layout
layout of views
*** mu, md, 2dmu, 2dmd, zoom, 2dzoom, wzoom
.Synopsis
mu [index]
2dmu [index]
zoom [index] value
wzoom
.Purpose
Use mu (magnify up) to increase the zoom in a view or in all views by
a factor of 10%. md (magnify down) decrease the zoom by the inverse
factor. 2dmu and 2dmd do the same on one or all 2d views.
Use zoom or 2dzoom to set the zoom factor to a given value. The
current zoom is always displayed in the window title.
Use wzoom (window zoom) to select with the mouse the area you want to
zoom in a view. You will be prompted for two graphic selections in the
same view and the rectangle you defined will be set to the whole
window of the view.
.Example
# set a zoom of 2.5 on all 2d views
zoom 2.5
# magnify on
mu 1
.See also
fit, 2dfit
.Index
mu command
md command
2dmu command
2dmd command
zoom command
2dzoom command
wzoom command
*** pu, pd, pl, pr, 2dpu, 2dpd, 2dpl, 2dpr
.Synopsis
pu [index]
pd [index]
.Purpose
Use the pu, .. commands to pan the view, pu and pd pan vertically up
and down, pl and pr pan horizontally left and right. The views are
panned by a quantity of 40 pixels.
.Example
# pan up the first view
pu 1
.See also
fit, 2dfit
.Index
pu command
pd command
pl command
pr command
2dpu command
2dpd command
2dpl command
2dpr command
*** fit, 2dfit
.Synopsis
fit [index]
2dfit [index]
.Purpose
Use the fit command to compute automatically a best zoom and panning on
the content of the view. The content of the view will be centered and
fit the whole window.
When fitting all views a unique zoom is computed for all the views, so
each view is not best fitted but all views are on the same scale. To
compute a best fit on all views fit them one by one.
.Example
# fit only view 1
fit 1
# fit all 2d views
2dfit
.Warning
.See also
zoom, mu, pu
.Index
fit command
2dfit command
*** u, d, l, r
.Synopsis
u [index]
d [index]
l [index]
r [index]
.Purpose
Rotate the view in the up, down, left or right direction by five
degrees. This is only for axonometric and perspective views.
.Example
# rotate the view up
u
.Index
u command
d command
l command
r command
*** focal, fu, fd
.Synopsis
focal [index] value
fu [index]
fd [index]
.Purpose
Use the focal method to change the focal distance for perspective
views. The focal is the distance form the eye to the view point. A low
focal increases the perspective effect, a high focal looks like an
axonometric. The default value is 500.
Use fu and fd to increase or decrease the focal value by 10%. fd makes
the eye closer to the object.
.Example
# create a perspective and look closer
pers
repeat 10 fd
.Warning
A negative or null focal is not a bright idea !!
.See also
pers
.Index
focal command
fu command
fd command
*** color
.Synopsis
color index name
.Purpose
Set the color to a value, index is the index of the color between 0
and 15, name is a X window color name. The list can be found in the
file rgb.txt in the X library directory.
The default value are
0 White
, 1 Red
, 2 Green
, 3 Blue
, 4 Cyan
, 5 Gold
, 6 Magenta
, 7 Marron
, 8 Orange
, 9 Pink
, 10 Salmon
, 11 Violet
, 12 Yellow
, 13 Khaki
, 14 Coral
.Example
# change the hue of the blue
color 3 "navy blue"
.Warning
The color change will be visible on the next redraw of the views, for
example after fit or mu.
.Index
color command
*** dtext
.Synopsis
dtext [x y [z]] string
.Purpose
Display a string in all 3d or 2d views. If no coordinates are given a
graphic selection is required. If two coordinates are given the text
is created in 2d views at this position, with 3 coordinates the text
is created in 3d views. The coordinates are real space coordinates.
.Example
# mark the origins
dtext 0 0 "This is the 2d origin"
dtext 0 0 0 "This is the 3d origin"
# write on the views
dtext "You just clicked here"
.Index
dtext command
text display
*** hardcopy, hcolor, xwd
.Synopsis
hardcopy [index]
hcolor index width gray
xwd [index] filename
.Purpose
The hardcopy command creates a postcript file named post.ps in the
current directory. This file contains the postscript description of
the view index, or of all the views.
The hcolor command lets you change the aspect of lines in the
postscript file, it allows to specify a width and a gray level for one
of the 16 colors. width is measured in points, the default value is 1,
gray is a grey level from 0 = black to 1 = white, the default value is
0. All colors are bound to the default values at the beginning.
The xwd command creates an X window xwd file from a view, by default
index is 1. To visualize an xwd file you can use the unix command
xwud.
.Example
# all blue lines (color 3)
# will be half-width and grey
hcolor 3 0.5
# make a postscript file and print it
hardcopy
lpr post.ps
# make an xwd file and display it
xwd theview
xwud -in theview
.Warning
There are bugs when using hardcopy without index with more than one
view.
You need a postscript printer or your harcopy will not look great.
.See also
color
.Index
hardcopy command
hcolor command
xwd command
postscript
dump of image
xwud
*** wclick, pick
.Synopsis
wclick
pick index X Y Z b [nowait]
.Purpose
Use the wclick command to wait until a mouse button is clicked, the
message "just click" is displayed. This is useful to let people
admire a drawing until they are fed up with it.
Use the pick command to get a graphical input, the arguments must be
names for variables where the results are stored.
- index : will be the index of the view where the input was made
- X,Y,Z : Are 3d coordinates in real world
- b : b is the mouse button 1,2 or 3
When there is an extra argument its value is not used and the command
do not wait for a button click, the value of b may then be 0 if there
was no click. This option is useful for tracking the pointer.
Note that the results are stored in Draw numeric variables.
.Example
# make a circle at mouse location
pick index x y z b
circle c x y z 0 0 1 1 0 0 0 30
# make a dynamic circle at mouse location
# stop when a button is clicked
# (see the repaint command)
dset b 0
while {[dval b] == 0} {
pick index x y z b nowait
circle c x y z 0 0 1 1 0 0 0 30
repaint
}
.See also
repaint
.Index
wclick command
pick command
** Variables display commands
Many Draw objects can be displayed, for example curves, surfaces,
shapes. Draw provides commands to manage the display of the objects.
display, donly are used to display objects, erase, clear, 2dclear to
erase them. The autodisplay command is used to control if variables
are displayed as soon as created.
The variable name "." (dot) has a special status within Draw, any draw
command expecting a Draw object as argument can be passed a dot. The
meaning of the dot is the following.
If the dot is an input argument a graphical selection will be made,
instead of getting the object from a variable. Draw will ask you to
select an object on a view.
If the dot is an output argument, an unnamed object will be created,
of course this will make sense only for graphical objects, if you
create an unnamed number you will not be able to access it. This
feature is useful when you want to create objects for display only.
If you do not see what you expected while executing loops or sourcing
files you may want to consider the repaint and dflush commands.
.Example
# use dot to dump an object on the screen
dump .
# display points on a curve c
# with dot no variables are created
for {set i 0} {$i <= 10} {incr i} {
cvalue c $i/10 x y z
point . x y z
}
# point p x y z
# would have displayed only one point
# because the precedent content of a variable is erased
# point p$i x y z
# is an other solution, creating variables
# p0, p1, p2, ....
# give a name to a graphic object
rename . x
.Index
dot argument
selection, graphical
unnamed objects
*** autodisplay
.Synopsis
autodisplay [0/1]
.Purpose
By default Draw displays automatically any graphical object as soon as
it is created. This behavior known as autodisplay can be removed with
this command. Without arguments, autodisplay toggles the autodisplay
mode, the command always returns the current mode.
When autodisplay is off, using the dot return argument is ineffective.
.Example
# c is dislayed
circle c 0 0 1 0 5
# toggle the mode
autodisplay
==> 0
circle c 0 0 1 0 5
# c is erased, but not displayed
display c
.Warning
.See also
display
.Index
autodisplay command
*** display, donly
.Synopsis
display varname [varname ...]
donly varname [varname ...]
.Purpose
Use display to make objects visible. Use donly to make objects visible
and erase all other objects, it stands for "display only".
As you may have guessed "display ." is quite useless, "donly ." is
very useful to extract one object from a messy screen.
.Example
# to see everybody
foreach var [directory] {display $var}
# to select two objects and erase the others
donly . .
.See also
erase
.Index
display command
donly command
*** erase, clear, 2dclear
.Synopsis
erase [varname varname ...]
clear
2dclear
.Purpose
Use erase to erase objects from all the views, erase without arguments
erase everything in 3d and 2d. To erase unnamed objects use "erase .".
Use clear to erase only 3d objects and 2dclear for 2d objects, erase
without arguments is the same thing as "clear; 2dclear".
.Example
# erase all guys with name starting by c_
foreach var [directory c_*] {erase $var}
# clear 2d views
2d clear
.See also
display
.Index
erase command
clear command
2dclear command
*** repaint, dflush
.Synopsis
repaint
dflush
.Purpose
The repaint command enforces pending repaint of the views. The dflush
command flushes the graphic buffers. These commands are useful within
loops or in scripts.
A new object is immediatly displayed, but when an object is modified
or erased the whole view must be repainted. To avoid doing it too many
times, Draw only sets a flag and delays the repaint to the end of the
command when the new prompt is issued. Within a script you may want to
display immediatly the result of a modification, the repaint command
will repaint the views if the flag is raised and clear the flag.
Graphical operations are buffered by Draw (and also by the X system),
usually the buffer is flushed at the end of a command and before
graphical selection. If you want to flush the buffer within a script
use the dflush command.
.Example
# See the example with the pick command
.See also
pick
.Index
repaint command
dflush command
*Geometry commands
Draw provides a set of commands to test geometry libraries. Geometry
libraries are provided with the GEOMETRY UL. These commands are found
in the TGEOMETRY executable, or in any Draw executable as long as it
includes the GeometryTest commands.
The geometry with Draw includes new types of variables
- The 2d and 3d point will be referred to as Draw points.
- The 2d curve, it is exactly the same as the Geom2d_Curve class. Will
be referred to as Draw 2d curve.
- The 3d curve and the surface, they are exactly the Geom_Curve and
Geom_Surface classes. Will be referred to as Draw curve and Draw
surface.
Please refer to the Geom and Geom2d packages to learn more about
CAS.CADE geometry.
Draw geometric variables never share their data, the copy command will
always make a complete copy of the content of the variable.
The following sections cover the topics
- crves creation, the different types of curves and how to create
them.
- surfaces creation, the different types of surfaces and how to create
them.
- curves and surfaces modification, commands to modify the definition
of curves and surfaces, a majority is for bezier and bspline.
- geometric transformations, i.e. translation, rotation, mirror, ...
- analysis of curves and surfaces, commands to compute points,
derivatives, curvatures.
- intersections of surfaces and curves.
- approximations of set of points to create curves and surfaces.
- construction of 2d circles and lines by constraints like tangency.
- the last section describes commands which control the display of
curves and surfaces.
When possible the commands are general, i.e. they process 2d curves 3d
curves and surfaces, for example the circle command may create a 2d or
a 3d circle depending on the number of arguments and the translate
command will process points, curves or surfaces depending on the type
of the argument. So when you do not find a command in a section you
may look in another section, for example the trim command is described
in the surface section but it can be used with curves.
**Creation of curves
To create points use the point command, to create curves use the
command corresponding to the type. The types of curves are :
- Analytical curves : line, circle, ellipse, parabola, hyperbola.
- Polar curves : beziercurve, bsplinecurve, bspline, bspline2d
- Trimmed curves and Offset curves made from other curves with the
trim and offset command. Note that the trim and offset command are
described in the surface section, as they work on curves or surfaces.
- Bspline curves (NURBS) can be created from other curves using the
convert command (see the surface creation).
- Curves can be created from surface isoparametric lines with the uiso
and viso commands.
- 3d curves can be created from 2d curves and the contrary using the
to3d and to2d commands. The project command more generally computes
the 2d curve on a surface.
Curves are displayed with an arrow to indicate the last parameter.
*** point
.Synopsis
point name x y [z]
.Purpose
Use the point command to create a 2d or 3d point, depending on the
number of arguments.
.Example
# 2d point
point p1 1 2
# 3d point
point p2 10 20 -5
.Index
point command
*** line
.Synopsis
line name x y [z] dx dy [dz]
.Purpose
Use the line command to create a 3d or 2d line. x y z are the
coordinates of the origin of the line, dx, dy, dz is the direction
vector. Of course the dimension must be consistent, either line l x y
dx dy in 2d or line l x y z dx dy dz in 3d.
A line is parametrised by the length starting form the origin along
the direction vector, the direction vector will be normalised, it must
not be null. The lines are infinite, but not the drawing.
.Example
# a 2d line at 45 degrees of the X axis
line l2d 0 0 1 1
# a 3d line trough the point 10 0 0 parallel to Z
line l 10 0 0 0 0 1
.See also
.Index
line command
*** circle
.Synopsis
circle name x y [z [dx dy dz]] [ux uy [uz]] radius
.Purpose
Use this command to create a 2d or a 3d circle, in 2d x,y are the
coordinates of the center and ux, uy is the vector in the direction of
the origin of the parameters, by default this direction is (1,0) the X
axis. Use another vector to change the origin of parameters.
In 3d x,y,z are the coordinates of the center, dx,dy,dz is the normal
vector defining the plane through the center where the circle is, this
vector is normalised and must not be null, by default this vector is
(0,0,1) i.e. the Z axis. ux,uy,uz is the direction of the origin, if
it is not given a default direction will be computed, this vector must
not be null or parallel to dx,dy,dz.
The circle is parametrised by the angle in [0,2*pi] starting from the
origin. Note that the specification of origin direction and plane is
the same for all analytical curves and surfaces.
.Example
# A 2d circle of radius 5 centered at 10,-2
circle c1 10 -2 5
# an other 2d circle with a user defined origin
# the point of parameter 0 on this circle will be
# 1+sqrt(2),1+sqrt(2)
circle c2 1 1 1 1 2
# a 3d circle, center 10 20 -5, axis Z, radius 17
circle c3 10 20 -5 17
# same 3d circle with axis Y
circle c4 10 20 -5 0 1 0 17
# full 3d circle, axis X, origin on Z
circle c5 10 20 -5 1 0 0 0 0 1 17
.Index
circle command
*** ellipse
.Synopsis
ellipse name x y [z [dx dy dz]] [ux uy [uz]] firstradius secondradius
.Purpose
Create a 2d or 3d ellipse, the first arguments are the same as for the
circle to define the center and the system of axis. The ellipse will
have firstradius on its X axis and secondradius on its Y axis. The
ellipse is parametrised by [0,2*pi] starting from the X axis going to
the Y axis. Note that this is not an angle, the local parametrisation
of the ellipse is (firstradius * cos(t), secondradius * sin(t))
.Example
# default 2d ellipse
ellipse e1 10 5 20 10
# 2d ellipse at angle 60 degree
ellipse e2 0 0 1 2 30 5
# 3d ellipse, in the XY plane
ellipse e3 0 0 0 25 5
# 3d ellipse in the X,Z plane with axis 1, 0 ,1
ellipse e4 0 0 0 0 1 0 1 0 1 25 5
.See also
circle
.Index
ellipse command
*** hyperbola
.Synopsis
hyperbola name x y [z [dx dy dz]] [ux uy [uz]] firstradius secondradius
.Purpose
Create a 2d or 3d ellipse, the first arguments are the same as for the
circle to define the center and the system of axis. The hyperbola will
have firstradius on its X axis and secondradius on its Y axis. This
values are not real radius but the coefficients of the parametric
equation, where the parameters run for -infinite to +infinite
(firstradius * ch(t), secondradius * sh(t)). Note that the hyperbola
has only one branch, the one in the X direction.
.Example
# default 2d hyperbola, with asymptotes 1,1 -1,1
hyperbola h1 0 0 30 30
# 2d hyperbola at angle 60 degree
hyperbola h2 0 0 1 2 20 20
# 3d hyperbola, in the XY plane
hyperbola h3 0 0 0 50 50
.Warning
.See also
circle
.Index
hyperbola command
*** parabola
.Synopsis
parabola name x y [z [dx dy dz]] [ux uy [uz]] focal
.Purpose
Create a 2d or 3d parabola in the axis-system defined by the first
arguments (see the circle command), the origin is the apex of the
parabola and focal is the coefficient in the parametric equation : (
x= t*t / 4*focal, y = t).
.Example
# 2d parabola
parabola p1 0 0 50
# 2d parabola with convexity +Y
parabola p2 0 0 0 1 50
# 3d parabola in the Y-Z plane, convexity +Z
parabola p3 0 0 0 1 0 0 0 0 1 50
.Warning
.See also
circle
.Index
parabola command
*** beziercurve, 2dbeziercurve
.Synopsis
beziercurve name nbpoles x1 y1 z1 [w1] x2 y2 z2 [w2] ....
2dbeziercurve name nbpoles x1 y1 z1 [w1] x2 y2 z2 [w2] ....
.Purpose
Use the beziercurve command to create a 3d curve, give the number of
poles then the coordinates of the poles, the degree will be
nbpoles-1. You can give weights with the poles to create a rational
curve, you must give weights for all poles or for none.
Use 2dbeziercurve to create a 2d curve with the same conditions as
above.
.Example
# a rational 2d bezier curve (arc of circle)
2dbeziercurve ci 3 0 0 1 10 0 sqrt(2.)/2. 10 10 1
# a 3d bezier curve, not rational
beziercurve cc 4 0 0 0 10 0 0 10 0 10 10 10 10
.Index
beziercurve command
2dbeziercurve command
*** bsplinecurve, 2dbsplinecurve, pbsplinecurve, 2dpbsplinecurve
.Synopsis
bsplinecurve name degree nbknots k1 m1 ... x1 y1 z1 w1 ...
2dbsplinecurve name degree nbknots k1 m1 ... x1 y1 w1 ...
pbsplinecurve name degree nbknots k1 m1 ... x1 y1 z1 w1 ...
2dpbsplinecurve name degree nbknots k1 m1 ... x1 y1 w1 ...
.Purpose
Use the bsplinecurve commands to create 3d or 2d NURBS curves, the
pbsplinecurve and 2dpbsplinecurve commands create periodic
curves. Degree is the degree for the curves, nbknots the number of
knots, then you must give the knots with their multiplicities, the
knots must be non decreasing, if succcessive knots are equal the
multiplicities will be added, multiplicities must be lower or equal to
the degree, on non periodic curves the first and last multiplicities
can be equal to degree+1, this is even recommended if you like the
curve to go from the first pole to the last pole. On a periodic curve
the first and last multiplicity must be equal.
The poles must be given with their weights, use weights of 1 for a non
rational curve, the number of poles must be
For a non periodic curve, Sum of multiplicities - degree + 1
For a periodic curve, Sum of multiplicities - last multiplicity
.Example
# a 2d periodic circle (parameter from 0 to 2*pi !!)
dset h sqrt(3)/2
2dpbsplinecurve c 2 \
4 0 2 pi/1.5 2 pi/0.75 2 2*pi 2 \
0 -h/3 1 \
0.5 -h/3 0.5 \
0.25 h/6 1 \
0 2*h/3 0.5 \
-0.25 h/6 1 \
-0.5 -h/3 0.5 \
0 -h/3 1
.Warning
.See also
.Index
bsplinecurve command
2dbsplinecurve command
pbsplinecurve command
2dpbsplinecurve command
periodic bsplines
*** bspline, bspline2d
.Synopsis
bspline name <digitizes ...> <mouse bouton 2>
bspline2d name <digitizes ...> <mouse bouton 2>
.Purpose
Use the bspline commands to create 3d or 2d NURBS curves by
digitizing on the screen. The mouse bouton 2 ends the digitizing
scheme and constructs a degree 3 curve that is scaled so that it fits
in box of length 1. The graphic screen is updated when the mouse
button 2 is pressed.
.Example
#
# a random bspline curve
#
bspline mycurve
.Warning
.See also
.Index
bsplinecurve command
2dbsplinecurve command
pbsplinecurve command
2dpbsplinecurve command
periodic bsplines
*** uiso, viso
.Synopsis
uiso name surface u
viso name surface u
.Purpose
Use these commands to create a U or V isoparametric curve from a surface.
.Example
# create a cylinder and extract to iso curves
# see the cylinder command
cylinder c 10
uiso c1 c pi/6
viso c2 c 5
.Warning
It is not possible to extract isoparametric curves on offset surfaces.
.See also
.Index
uiso command
viso command
isoparametric curves
*** to2d, to3d
.Synopsis
to3d name curve2d [plane]
to2d name curve3d [plane]
.Purpose
to3d and to2d commands are used to create a 3d curve from a 2d curve
and a 2d curve from a 3d curve. The transformation uses a planar
surface to define the XY plane in 3d, by default this plane is the
default OXY plane. to3d always gives a correct result, but to2d may
surprise you as it is not a projection. It is always correct if the
curve is planar and parallel to the plane of projection, the points
defining the curve are projected onto the plane but a circle will
remain a circle for example, it will not be changed to an ellipse.
.Example
# the following commands
circle c 0 0 5
plane p -2 1 0 1 2 3
to3d c c p
# will create the same circle as
circle c -2 1 0 1 2 3 5
.Warning
.See also
project
.Index
to2d command
to3d command
*** project
.Synopsis
project name curve3d surface
.Purpose
Computes the 2d curve in the parametric space of the surface
correponding to the 3d curve. This can be used only on analytical
surface and for curves lying on the surface.
.Example
# intersect a cylinder and a plane
# and project the resulting ellipse on the cylinder
# this will create a 2d sinusoid-like bspline
cylinder c 5
plane p 0 0 0 0 1 1
intersect i c p
project i2d i c
.Warning
.See also
.Index
project command
**Creation of surfaces
To create surfaces use also the type, types of surfaces are
- Analytical surface : plane, cylinder, cone, sphere, torus.
- Polar surfaces : beziersurf, bsplinesurf
- Trimmed and Offset surface, using the commands trim, trimu, trimv,
offset.
- Surface of Revolution and Extrusion, created from curves with the
revsurf and extsurf commands.
- NURBS surface can be constructed from other surfaces using the
convert command.
Surfaces are displayed with isoparametric lines, a small parametric
line is displayed at 1/10 of U with a length 1/10 of V to show the
parametrisation.
*** plane
.Synopsis
plane name [x y z [dx dy dz [ux uy uz]]]
.Purpose
Uses this command to create an infinite plane, a plane is the same
thing as a 3d coordinate system, x,y,z is the origin, dx, dy, dz is
the Z direction and ux, uy, uz is the X direction. The plane is
perpendicular to Z and X is the U parameter. dx,dy,dz and ux,uy,uz
must not be null and not colinear. ux,uy,uz will be modified to be
orthogonal to dx,dy,dz. There are default values for the coordinate
system, if no arguments are given the default is the global system
(0,0,0), (0,0,1), (1,0,0), if only the origin is given the axis are
the default ones (0,0,1), (1,0,0), if the origin and the Z axis are
given the X axis is generated perpendicular to the Z axis. Note that
this definition will be used for all analytical surfaces.
.Example
# a plane through the point 10,0,0 perpendicular to X
# with U direction on Y
plane p1 10 0 0 1 0 0 0 1 0
# an horixontal plane with origin 10, -20, -5
plane p2 10 -20 -5
.Index
plane command
coordinate system
*** cylinder
.Synopsis
cylinder name [x y z [dx dy dz [ux uy uz]]] radius
.Purpose
A cylinder is defined by a coordinate system, just like a plane, and a
radius. The cylinder is an infinite cylinder with the Z axis as axis,
the U parameter is the angle starting from X going to the Y
direction. The V coordinate is the length along the Z axis starting
from the origin.
.Example
# a cylinder on the default Z axis, radius 10
cylinder c1 10
# a cylinder, also with Z axis but with origin 5, 10, -3
cylinder c2 5 10 -3 10
# a cylinder through the origin
# with longitude pi/3 and latitude pi/4 (euler angles)
dset lo pi/3. la pi/4.
cylinder c3 0 0 0 cos(la)*cos(lo) cos(la)*sin(lo) sin(la) 10
.See also
plane
.Index
cylinder command
longitude and latitude
euler angles
*** cone
.Synopsis
cone name [x y z [dx dy dz [ux uy uz]]] semi-angle radius
.Purpose
Creates a cone in the coordinate system, the radius is the radius of
the section of the cone in the XY plane, the semi-angle is the angle
in degree of the cone with the axis, it should be between -90 and 90,
both and 0 excluded. The vertex is on the Z axis in the negative
direction at a distance radius/tan(semi-angle) from the origin. If the
radius is 0 the vertex is the origin.
To parametrise the cone, U is the angle starting from 0, in the Y
direction, V is the length along the the side starting from the
origin, in the local system V = Z / cos(semi-angle).
The definition of the cone may seem redundant but it is very useful to
disconnect the origin of the V parameter and the apex, mainly for very
small angle when the cone is like a cylinder, the useful part of the
surface may be very far from the apex and would require very large
parameter values.
.Example
# a cone a 45 degree at the origin on Z
cone c1 45 0
# a cone on axis Z with radius r1 at z1 and r2 at z2
cone c2 0 0 z1 180.*atan2(r2-r1,z2-z1)/pi r1
.Warning
The angle is in degree.
.See also
plane
.Index
cone command
*** sphere
.Synopsis
sphere name [x y z [dx dy dz [ux uy uz]]] radius
.Purpose
Creates a sphere in a local coordinate system defined like for the
lane command. The sphere is centered at the origin with the given
radius. To parametrise the sphere, U is the angle from X to Y, U is
between o and 2*pi, V is the angle in the half-circle at angle U in
the plane containing the Z axis, V is between -pi/2 and pi/2. The
poles are the points Z = +/- radius, their parameters are U,+/-pi/2
for any U in 0,2*pi.
.Example
# a sphere at the origin
sphere s1 10
# a sphere at 10 10 10, with poles on the axis 1,1,1
sphere s2 10 10 10 1 1 1 10
.Warning
.See also
plane
.Index
sphere command
*** torus
.Synopsis
torus name [x y z [dx dy dz [ux uy uz]]] major minor
.Purpose
Creates a torus in the local coordinate system with the given major
and minor radius, Z is the axis for the major radius. The major radius
can be lower than the minor one.
To parametrize a torus, U is the angle from X to Y, V is the angle in
the plane at angle U from the XY plane to Z. U and V are in 0,2*pi.
.Example
# a torus at the origin
torus t1 20 5
# a torus in another system
torus t2 10 5 -2 2 1 0 20 5
.See also
plane
.Index
torus command
*** beziersurf
.Synopsis
beziersurf name nbupoles nbvolpes x y z [w] ....
.Purpose
Use this command to create a bezier surface, rational or not. You must
first give the numbers of poles in the U and V directions, degrees
will be nbupoles-1 and nbvpoles-1. Then give the nbupoles*nbvpoles
poles, starting with U. i.e. P(1,1) P(2,1) ,... P(nbupoles,1) P(1,2)
,... P(nbupoles,nbvpoles). You can omit weights, but if you give one
weight you must give them all.
.Example
# a non-rational degree 2,3 surface
beziersurf s 3 4 \
0 0 0 10 0 5 20 0 0 \
0 10 2 10 10 3 20 10 2 \
0 20 10 10 20 20 20 20 10 \
0 30 0 10 30 0 20 30 0
.See also
beziercurve
.Index
beziersurf command
*** bsplinesurf, upbsplinesurf, vpbsplinesurf, uvpbsplinesurf
.Synopsis
bsplinesurf name udegree nbuknots uknot umult ... nbvknot vknot vmult ... x y z w ...
upbsplinesurf ...
vpbsplinesurf ...
uvpbsplinesurf ...
.Purpose
Use the bsplinesurf command to create NURBS surfaces, the
upbsplinesurf command to create a NURBS surface periodic in U,
vpbsplinesurf periodic in V, and uvpbsplinesurf periodic in UV.
The description is similar to the bsplinecurve command, first you give
the degree in U and the knots in U with their multiplicities, then the
same in V. The poles follow, the number of poles is the product of the
number in U and the number in V, see bsplinecurve to compute the
number of poles, the poles are first given in U as in the beziersurf
command. Note that you must give the weights, use 1 for rational
surface.
.Example
# create a bspline surface of degree 1 2
# with two knots in U and three in V
bsplinesurf s \
1 2 0 2 1 2 \
2 3 0 3 1 1 2 3 \
0 0 0 1 10 0 5 1 \
0 10 2 1 10 10 3 1 \
0 20 10 1 10 20 20 1 \
0 30 0 1 10 30 0 1
.Warning
The weights are mandatory.
.See also
bsplinecurve
beziersurf
convert
.Index
bsplinesurf command
upbsplinesurf command
vpbsplinesurf command
uvpbsplinesurf command
periodic bsplines
*** trim, trimu, trimv
.Synopsis
trim newname name [u1 u2 [v1 v2]]
trimu newname name [u1 u2]
trimv newname name [v1 v2]
.Purpose
The trim commands are used to create trimmed curves or trimmed
surfaces. Note that trimmed curves and surfaces are classes of the
Geom packages. The trim command creates a new trimmed curve from a
curve, or a new trimmed surface in u and v from a surface. trimu
creates a u trimmed surface, and trimv a vtrimmed surface. If no
parameters are given, the command recreates the basis curve and
surface if the argument is trimmed. The curves can be either 2d or 3d
curves. If the trimming parameters are decreasing, direction is
reversed if the curve or surface is not periodic.
Note that a trimmed curve or surface contains a copy of the basis
geometry, so modifying it will not modify the trimmed geometry. Note
also that trimmig a trimmed geometry will not create multiple levels
of trimming, the basic geometry will be used.
.Example
# create a 3d circle
circle c 0 0 0 10
# trim it, use the same variable, the original is destroyed
trim c c 0 pi/2
# original can be recovered !
trim orc c
# trim again
trim c c pi/4 pi/2
# original is not the trimmed curve but the basis
trim orc c
# as the circle is periodic the two following commands are identical
trim cc c pi/2 0
trim cc c pi/2 2*pi
# trim an infinite cylinder
cylinder cy 10
trimv cy cy 0 50
.Warning
.See also
reverse
.Index
trim command
trimu command
trimv command
*** offset
.Synopsis
offset newname name distance [dx dy dz]
.Purpose
Use the offset command to create offset curve or surface from a basis
curve or surface at a given distance, offset curves and surfaces are
classes from the Geom package. The curve can be a 2d or a 3d curve,
for a 3d curve you must give also a vector dx,dy,dz to compute the
offsets, usually for a planar curve this vector is the normal to the
plane containing the curve.
The offset curve or surface copies the basis geometry which can be
modified later.
.Example
# graphical demonstration that the outline of a torus
# is the offset of an ellipse
# Please do this in a top view
smallview +X+Y
dset angle pi/6
torus t 0 0 0 0 cos(angle) sin(angle) 50 20
fit
ellipse e 0 0 0 50 50*sin(angle)
# note that the distance can be negative
offset l1 e 20 0 0 1
offset l2 e -20 0 0 1
# Admire...
.Index
offset command
*** revsurf
.Synopsis
revsurf newname curvename x y z dx dy dz
.Purpose
This command creates a surface of revolution from a 3d curve, this is
the class SurfaceOfRevolution from Geom, x,y,z and dx,dy,dz defines
the axis of revolution. To parametrize a surface of revolution U, is
the angle around the axis, starting from the curve, V is the parameter
of the curve.
.Example
# another way to make a torus like surface
circle c 50 0 0 20
revsurf s c 0 0 0 0 1 0
.Warning
.See also
.Index
revsurf command
*** extsurf
.Synopsis
extsurf newname curvename dx dy dz
.Purpose
Use the extsurf command to create a surface of linear extrusion from a
3d curve. dx,dy,dz is the direction of extrusion. To parametrize a
surface of extrusion, U is the parameter on the curve, V is the length
along the direction of extrusion.
.Example
# an elliptic cylinder
ellipse e 0 0 0 10 5
extsurf s e 0 0 1
# to make it finite
trimv s s 0 10
.Index
extsurf command
*** convert
.Synopsis
convert newname name
.Purpose
The convert command creates a NURBS 2d curve, 3d curve or surface from
any 2d curve, curve, and surface. essentially conics curves and
quadric surfaces are turned to NURBS, it does not process offsets.
.Example
# turn a 2d arc of circle into a 2d nurbs
circle c 0 0 5
trim c c 0 pi/3
convert c c
# an easy way to make a planar bspline surface
plane p
trim p p -1 1 -1 1
convert p p
.Warning
Offset curves and surfaces are not processed.
.See also
bsplinecurve, bsplinesurf
.Index
convert command
**Modifications of Curves and surfaces
Draw provides commands to modify curves and surfaces, some of them are
general, others are restricted to bezier or bsplines.
General modification are
- Reversing the parametrisation : reverse, ureverse, vreverse.
Modifications for bezier and bspline are
- Exchanging U and V on a surface : exchuv
- segmentation, segment, segsur
- Increasing the degree, incdeg, incudeg, incvdeg
- moving poles, cmovep, movep, movecolp, moverowp
- moving a point on a curve or a surface, cmovepoint, movepoint
Modifications for bezier are
- adding and removing poles, insertpole, rempole, remcolpole, remrowpole
Modifications for bspline are
- inserting and removing knots, insertknot, remknot, insertuknot,
remuknot, insetvknot, remvknot
- modifying periodic curves and surfaces, setperiodic, setnotperiodic,
setorigin, setuperiodic, setunotperiodic, setuorigin, setvperiodic,
setvnotperiodic, setvorigin
*** reverse, ureverse, vreverse
.Synopsis
reverse curvename
ureverse surfacename
vreverse surfacename
.Purpose
Use the reverse command to reverse the parametrisation of a 3d or 2d
curve, use ureverse or vreverse to reverse the U or V parameter of a
surface. Note that the new parameters of the curve may change
according to the type of curve. For example they will change sign on a
line or stay 0,1 on a bezier.
Reversing a parameter on an analytical surface may create an indirect
coordinate system, i.e. for example Z is not the cross product of X
and Y, because reversing a parameter will reverse only one axis.
.Example
# reverse a trimmed 2d circle
circle c 0 0 5
trim c c pi/4 pi/2
reverse c
# dumping c will show that it is now trimmed between
# 3*pi/2 and 7*pi/4 i.e. 2*pi-pi/2 and 2*pi-pi/4
.Warning
The geometry has been modified, if you want to keep the curve or the
surface you must copy it before.
.See also
.Index
reverse command
ureverse command
vreverse command
*** exchuv
.Synopsis
exchuv surfacename
.Purpose
For a bezier or bspline surface this command exchange the U and V parameters.
.Example
# exchanging u and v on a spline (made from a cylinder)
# this is impossible on the cylinder
cylinder c 5
trimv c c 0 10
convert c c
exchuv c
.Index
exchuv command
*** segment, segsur
.Synopsis
segment curve ufirst ulast
segsur surface ufirst ulast vfirst vlast
.Purpose
Use the segment and segsur commands to segment respectively a bezier
or bspline curve and surface. This command modifies the curve to
restrict it between the new parameters. This command must not be
confused with the trim command which creates a new geometry.
.Example
# segment a bezier curve in half
beziercurve c 3 0 0 0 10 0 0 10 10 0
segment c 0.5 1
.Warning
.See also
.Index
segment command
segsur command
*** incdeg, incudeg, incvdeg
.Synopsis
incdeg curvename newdegree
incudeg surfacename newdegree
incvdeg surfacename newdegree
.Purpose
Use the incdeg command to increase the degree of a 2d or 3d bezier or
bspline curve to a new value higher than the current one. Use incudeg
and incvdeg to increase the degree in U or V of a surface.
.Example
# make a planar bspline and increase the degree to 2 3
plane p
trim p p -1 1 -1 1
convert p p
incudeg p 2
incvdeg p 3
.Warning
The geometry is modified.
.See also
.Index
incdeg command
incudeg command
incvdeg command
*** cmovep, movep, movecolp, moverowp
.Synopsis
cmovep curve index dx dy [dz]
movep surface uindex vindex dx dy dz
movecolp uindex dx dy dz
moverowp vindex dx dy dz
.Purpose
Use the move methods to translate poles of a bezier or a bspline curve
or surface. cmovep and movep translate the pole with the given index.
movecolp and moverowp translate a whole column or row of poles.
.Example
# start with a plane
# turn to bspline, raise degree and raise poles
plane p
trim p p -10 10 -10 10
convert p p
incud p 2
incvd p 2
movecolp p 2 0 0 5
moverowp p 2 0 0 5
movep p 2 2 0 0 5
.Warning
.See also
.Index
cmovep command
movep command
movecolp command
moverowp command
*** cmovepoint, movepoint
.Synopsis
cmovepoint curve u dx dy [dz]
movepoint surface u v dx dy dz
.Purpose
Use the cmovepoint command to modify a curve so the point of parameter
u have a new position translated by dx,dy,dz (no dz in 2d).
Use the movepoint command to modify a surface so the point of
parameters u,v have a new position translated by dx,dy,dz.
.Example
# Create a spline curve and move 100 times a point
bsplinecurve bscurv \
3 2 -1.0 4 1.0 4 0 0 0 1 1 0 0 1 2 0 0 1 3 0 0 1
incdeg bscurv 10
translate bscurv 0 -4 0
set i 1
repeat 100 {cmovepoint bscurv 0.3 0. 0.05 0.0e0 ; incr i 1; repaint}
dump bscurv
set i 1
repeat 100 {cmovepoint bscurv 0.3 0. -0.05 0.0e0 ; incr i 1;repaint}
.Warning
The geometry is modfied. Do not confuse with cmovep and movep which
modifies a pole and not a point.
.See also
cmovep, movep
.Index
cmovepoint command
movepoint command
*** insertpole, rempole, remcolpole, remrowpole
.Synopsis
insertpole curvename index x y [z] [w]
rempole curvename index
remcolpole surfacename index
remrowpole surfacename index
.Purpose
Use the insertpole command to insert a new pole on a 2d or 3d bezier
curve, you can add a weight for the pole, the default value for the
weight is 1. The pole is added at the position after the index, use an
index 0 to insert before the first pole.
Use the rempole command to remove a pole from a 2d or 3d bezier curve,
you must leave at least two poles in the curves.
Use the remcolpole and remrowpole commands to remove a column or a row
of poles from a bezier surface. A column is in the V direction and a
row in the U direction, the resulting degree must be at least 1, i.e
there are two rows and two columns.
.Example
# start with a segment, insert a pole at end
# then remove the central pole
beziercurve c 2 0 0 0 10 0 0
insertpole c 2 10 10 0
rempole c 2
.Index
insertpole command
rempole command
remcolpole command
remrowpole command
pole insertion and removal
*** insertknot, insertuknot, insertvknot
.Synopsis
insertknot curvename knot [mult]
insertuknot surfacename knot [mult]
insertvknot surfacename knot [mult]
.Purpose
Insert knots in the knot sequence of a bspline curve or surface, use
insertknot for a curve, you must give a knot value and a target
multiplicity, the default multiplicity is 1. If there is already a
knot with the given value its multiplicity will be raised if it is
lower than the target multiplicity. Use insertuknot and insertvknot to
insert knots in a surface.
.Example
# create a cylindrical surface and insert a knot
cylinder c 10
trim c c 0 pi/2 0 10
convert c c
insertuknot c pi/4 1
.Index
insertknot command
insertuknot command
insertvknot command
knot insertion
*** remknot, remulnot, remvknot
.Synopsis
remknot index [mult] [tol]
remuknot index [mult] [tol]
remvknot index [mult] [tol]
.Purpose
To remove a knot from the knot sequence of a curve or a surface use
the remknot commands, give the index of the knot and the target
multiplicity, default is 0 to remove the knot, if the target
multiplicity is not 0, the multiplicity of the knot will be
lowered. You can give a tolerance value to control the process as the
curve may be modified, if the tolerance is low the removal will be
done only if the curve is not modified. By default the removal is
always done.
.Example
# bspline circle, remove a knot
circle c 0 0 5
convert c c
incd c 5
remknot c 2
.Warning
The curve or the surface may be modified.
.See also
.Index
remknot command
remulnot command
remvknot command
knot removal
*** setperiodic, setnotperiodic, setuperiodic, setunotperiodic, setvperiodic, setvnotperiodic
.Synopsis
setperiodic curve
setnotperiodic curve
setuperiodic surface
setunotperiodic surface
setvperiodic surface
setvnotperiodic surface
.Purpose
setperiodic turns a bspline curve in a periodic bspline curve, the
knot vector is the same and excess poles are truncated, the curve may
be modified if it was not closed. setnotperiodic removes the
periodicity of a periodic curve, poles are duplicated. Note that knots
are added at the begining and the end of the knot vector and the
multiplicity are knot set to degree+1 at the start and the end.
.Example
# a circle deperiodicised
circle c 0 0 5
convert c c
setnotperiodic c
.Index
setperiodic command
setnotperiodic command
setuperiodic command
setunotperiodic command
setvperiodic command
setvnotperiodic command
*** setorigin, setuorigin, setvorigin
.Synopsis
setorigin curvename index
setuorigin surfacename index
setuorigin surfacename index
.Purpose
Use these commands to change the origin of the parameters on periodic
curves or surfaces, the new origin must be an existing knot. To set an
origin outside a knot you must first insert a knot with the insertknot
command.
.Example
# a torus with new U and V origins
torus t 20 5
convert t t
setuorigin t 2
setvorigin t 2
.See also
insertknot
.Index
setorigin command
setuorigin command
setvorigin command
**Transformations
Draw provides commands to apply linear transformations to geometric
objects, they include translation, rotation, mirror and scale.
*** translate, 2dtranslate
.Synopsis
translate name [name ...] dx dy dz
2dtranslate name [name ...] dx dy
.Purpose
To translate 3d points, curves and surfaces use the translate
commands, giving a vector dx,dy,dz. You can translate more than one
object with the same command.
For 2d points or curves use the 2dtranslate command.
.Example
# 3d translation
point p 10 20 30
circle c 10 20 30 5
torus t 10 20 30 5 2
translate p c t 0 0 15
.Warning
Objects are modified.
.See also
.Index
translate command
2dtranslate command
*** rotate, 2drotate
.Synopsis
rotate name [name ...] x y z dx dy dz angle
2drotate name [name ...] x y angle
.Purpose
To rotate a 3d point, curve or surface use the rotate command. You
must give an axis of rotation with a point x,y,z, a vector dx,dy,dz
and an angle in degree.
For a 2d rotation you must only give the center and the angle. In 3d
or 2d the angle can be negative.
.Example
# make an helix of circles
circle c0 10 0 0 3
for {set i 1} {$i <= 10} {incr i} {
copy c[expr $i-1] c$i
translate c$i 0 0 3
rotate c$i 0 0 0 0 0 1 36
}
.Index
rotate command
2drotate command
*** pmirror, lmirror, smirror, 2dpmirror, 2dlmirror
.Synopsis
pmirror name [name ...] x y z
lmirror name [name ...] x y z dx dy dz
smirror name [name ...] x y z dx dy dz
2dpmirror name [name ...] x y
2dlmirror name [name ...] x y dx dy
.Purpose
The mirrors command make a mirror transformation of a 3d or 2d
geometry. pmirror is the point mirror, or central symetry, lmirror is
the line mirror or axial symetry, smirror is the surface mirror or
planar symetry, the plane of symetry is perpendicular to dx,dy,dz.
In 2d we have only 2dpmirror, the point symetry, and 2dlmirror the
axis symetry.
.Example
# build 3 images of a torus
torus t 10 10 10 1 2 3 5 1
copy t t1
pmirror t1 0 0 0
copy t t2
lmirror t2 0 0 0 1 0 0
copy t t3
smirror t3 0 0 0 1 0 0
.Warning
.See also
.Index
pmirror command
lmirror command
smirror command
2dpmirror command
2dlmirror command
*** pscale, 2dpscale
.Synopsis
pscale name [name ...] x y z s
2dpscale name [name ...] x y s
.Purpose
Use the pscale and 2dpscale commands to transform an object with a
point scaling (central homotetic). You must give the center and the
scaling factor. Using a scaling factor of -1 is similar to pmirror.
.Example
# double the size of a sphere
sphere s 0 0 0 10
pscale s 0 0 0 2
.Warning
.See also
.Index
pscale command
2dpscale command
**Analysis of curves and surfaces
Draw provides methods to compute information about curves and
surfaces.
- Use coord to find the coordinates of a point.
- Use cvalue and 2dcvalue to compute points and derivatives on
curves.
- Use svalue to compute points and derivatives on a surface.
- Use localprop and minmaxcurandif to compute the curvature on a
curve.
- Use parameters to compute U,V values for a point on a surface.
- Use proj and 2dproj to project a point on a curve or a surface.
- Use surface_radius to compute the curvalture on a surface.
*** coord
.Synopsis
coord point x y [z]
.Purpose
The coord command will store in the variable x, y and z the
coordinates of the point.
.Example
# translate a point
point p 10 5 5
translate p 5 0 0
coord p x y z
# x value is 15
.See also
point
.Index
coord command
*** cvalue, 2dcvalue
.Synopsis
cvalue curve u [x y z [d1x d1y d1z [d2x d2y d2z]]] [P]
2dcvalue curve u [x y [d1x d1y [d2x d2y]]] [P]
.Purpose
Depending on the number of arguments this command computes on a curve
at a given parameter : the coordinates in x,y,z, the first derivative
in d1x,d1y,d1z, the second derivative in d2x,d2y,d2z and set in P the
point of coordinates x,y,z.
.Example
# on a bezier curve at parameter 0
# the point is the first pole
# the derivative is the vector first to second pole
# multiplied by the degree
# the second derivative is the difference
# first to second pole, second to third pole
# multiplied by degree * degree-1
2dbeziercurve c 4 0 0 1 1 2 1 3 0
2dcvalue c 0 x y d1x d1y d2x d2y P
# values of x y d1x d1y d2x d2y
# are 0 0 3 3 0 -6
# and displays the point P(0,0,3)
.Warning
.See also
.Index
cvalue command
2dcvalue command
value on curves
derivative on curves
*** svalue
.Synopsis
svalue surface u v [x y z [dux duy duz dvx dvy dvz [d2ux d2uy
d2uz d2vx d2vy d2vz d2uvx d2uvy d2uvz]]] [P]
.Purpose
Use the svalue command to compute point and derivatives on a surface
at a pair of parameter values, the result depends on the number of
arguments. You can compute up to order two of derivation and display
the resulting point.
.Example
# display points on a sphere
sphere s 10
for {dset t 0} {[dval t] <= 1} {dset t t+0.01} {
svalue s t*2*pi t*pi-pi/2 x y z
point . x y z
}
# can also be written
sphere s 10
for {dset t 0} {[dval t] <= 1} {dset t t+0.01} {
svalue s t*2*pi t*pi-pi/2 .
}
.Warning
.See also
.Index
svalue command
*** localprop, minmaxcurandif
.Synopsis
localprop curve u
minmaxcurandif curve
.Purpose
The localprop command computes on a curve the curvature and display
the osculationg circle. The minmaxcurandif command computes and print
the parameters where the curvature is minimum or maximum on a curve.
.Example
# show curvature at the center of a bezier curve
beziercurve c 3 0 0 0 10 2 0 20 0 0
localprop c 0.5
.See also
surface_radius
.Index
localprop command
minmaxcurandif command
radius of curvature
curvature
*** parameters
.Synopsis
parameters surface x y z u v
.Purpose
The parameters command returns in variables u and v the parameters on
the surface of the 3d point x,y,z. This command can be used only on
analytical surfaces, plane, cylinder, cone, sphere, torus.
.Example
# Compute parameters on a plane
plane p 0 0 10 1 1 0
parameters p 5 5 5 u v
# the values of u and v are 0 5
.Warning
.See also
.Index
parameters command
*** proj, 2dproj
.Synopsis
proj name x y z
2dproj name xy
.Purpose
Use proj to project a point on a curve or a surface and 2dproj for a
2d curve, the command will compute and display all points at an
extreme distance. The lines joining the point to the projections are
created with names such as ext_1, ext_2, ...
.Example
# project point on a torus
torus t 20 5
proj t 30 10 7
.Warning
.See also
.Index
proj command
2dproj command
*** surface_radius
.Synopsis
surface_radius surface u v [c1 c2]
.Purpose
Use the surface radius command to compute the main curvatures of a
surface at parameters u,v. If there are extra arguments the curvatures
are stored in variables c1 and c2.
.Example
# computes curvatures of a cylinder
cylinder c 5
surface_radius c pi 3 c1 c2
.Warning
The radii are displayed and the curvatures are returned, the radius is
the inverse of the curvature.
.See also
.Index
surface_radius command
curvature of surfaces
**Intersections
To compute intersections of surfaces, use the intersect command; to
compute intersections of 2d curves, use the 2dintersect command.
*** intersect
.Synopsis
intersect name surface1 surface2 [tolerance]
.Purpose
Use the intersect command to intersect two surfaces, if there is one
intersection curve it will be named "name", if there are more than one
they will be named "name_1", "name_2", ... The precision of the result
is the given tolerance, this is important when a spline is fitted to
the result curve. The default tolerance is 1e-7.
.Example
# create an ellipse
cone c 45 0
plane p 0 0 40 0 1 5
intersect e c p
.Warning
.See also
.Index
intersect command
*** 2dintersect
.Synopsis
2dintersect curve1 curve2
.Purpose
Display the intersection points between two 2d curves.
.Example
# intersect two 2d ellipses
ellipse e1 0 0 5 2
ellipse e2 0 0 0 1 5 2
2dintersect e1 e2
.Warning
.See also
.Index
2dintersect command
**Approximations
Draw provides commandd to create curves and surfaces by
approximations. 2dapprox to fit a curve through 2d points. appro to
fit a curve through 3d points. surfapp and grilapp to fit a surface
through 3d points. 2dinterpolate can be used to interpolate a curve.
*** appro, 2dapprox, 2dinterpolate
.Synopsis
appro name nbpoints [curve]
2dapprox name name nbpoints [curve / x1 y1 x2 y2 ...]
2dinterpolate name name nbpoints [curve / x1 y1 x2 y2 ...]
.Purpose
Fit a curve through a set of points, first give the number of points,
then there are three ways to give the points. Without arguments
interactivly click the points, with a curve argument computes the
points on the curve, else give a list of points.
.Example
# pick ten points and they will be fit
2dapprox c 10
.Warning
.See also
.Index
appro command
2dapprox command
approximation
*** surfapp, grilapp
.Synopsis
surfapp name nbupoints nbvpoints x y z ....
grilapp name nbupoints nbvpoints xo dx yo dy z11 z12 ...
.Purpose
Use surfapp to fit a surface through an array of points
nbupoints*nbvpoints. grilapp do the same but the x,y coordinates of
the points are on a grid starting at x0,y0 with steps dx,dy.
.See also
.Index
surfapp command
grilapp command
**Constraints
The command cirtang is used to construct 2d circles tangent to curves
and lintan to construct 2d lines tangent to curves.
*** cirtang
.Synopsis
cirtang name c1 c2 c3
.Purpose
The cirtang command will build all circles satsifying the three
constraints c1,c2,c3. The constraints are either, a curve then the
circle must be tangent to that curve, a point then the circle must
pass through that point, a radius for the circle. Only one constraint
can be a radius. The solutions will be stored in variables called
name_1, name_2, ...
.Example
# a point, a line and a radius. 2 solutions
point p 0 0
line l 10 0 -1 1
cirtan c p l 4
.Warning
.See also
.Index
cirtang command
tangent circle
*** lintan
.Synopsis
lintan name curve curve [angle]
.Purpose
The lintan command will build all 2d lines tangent to two curves. If a
third angle argument is given the second curve must be a line and
lintan will build all lines tangent to the first curve making the
given angle with the line. The angle is defined in degree. The
solutions are named name_1, name_2, ...
.Example
# lines tangent to 2 circles, 4 solutions
circle c1 -10 0 10
circle c2 10 0 5
lintan l c1 c2
.Warning
.See also
.Index
lintan command
tangent line
**Display
Draw provides commands to control the display of geometric
objects. Some display parameters are used for all objects, some are
valid only for surfaces, some are valid only for bezier and bspline,
and some only for bspline.
On curve and surfaces you can control the display mode (how points are
computed) with the dmode command. And the parameters for the mode
with the defle command and the discr command to control the deflection
and the discretisation.
On surfaces you can control the number of isoparametric curves
displayed on the surface with the nbiso command.
On bezier and bspline curve and surface you can toggle the display of
the control points with the clpoles and shpoles commands.
On bspline curves and surfaces you can toggle the display of the knots
with the shknots clknots commands.
.Index
display of curves and surfaces
*** dmod, discr, defle
.Synopsis
dmode name [name ...] u/d
discr name [name ...] nbintervals
defle name [name ...] deflection
.Purpose
You can choose the display mode for a curve or a surface with the
dmode command. The display mode defines how the points are computed to
create the polygon to display the curve or the surface.
In "u" mode, known as uniform deflection, the points are computed to
keep the polygon at a distance lower than the deflection from the
geometry. The deflection is set with the defle command. This mode is
more computer intensive.
In "d" mode, known as discretisation, a fixed number of points is
computed, this number is set with the discr command. This is the
default mode. On a bspline the fixed number of points is computed for
each span of the curve. (A span is the interval between two knots).
If the curves are not smooth you can either increase the
discretisation or lower the deflection, depending on the mode in
use. This will increase the number of points.
.Example
# increment the number of points on a big circle
circle c 0 0 50 50
discr 100
# change the mode
dmode c u
.Warning
.See also
.Index
dmod command
discr command
defle command
*** nbiso
.Synopsis
nbiso surface [surface ...] nbuiso nbviso
.Purpose
Use the nbiso command to change the number of isoparametric curves
displayed on a surface in the U and V directions. Note that on a
bspline surface by default isoparametrics are displayed at knots
values, using nbiso will remove this feature.
.Example
# display 35 meridians and 15 parallels on a sphere
sphere s 20
nbiso s 35 15
.Warning
.See also
.Index
nbiso command
*** clpoles, shpoles
.Synopsis
clpoles name
shpoles name
.Purpose
On bezier and bspline curves and surfaces the control polygon is
displayed by default, you can suppress it with the clpoles command and
restore it with the shpoles command.
.Example
# create a bezier curve and erase the poles
beziercurve c 3 0 0 0 10 0 0 10 10 0
clpoles c
.Warning
.See also
.Index
clpoles command
shpoles command
poles display
*** clknots, shknots
.Synopsis
clknots name
shknots name
.Purpose
By default on a bspline curve and surface knots are displayed with a
marker at the points with a parametric value equal to the knots. You
can remove them with the clknots commands and restore them with the
shknots command.
.Example
# hide the knots on a circle converted to spline
circle c 0 0 5
convert c c
clknots c
.Warning
.See also
.Index
clknots command
shknots command
knots display
*Topology commands
Draw provides a set of commands to test topology libraries. Topology
libraries are provided with the TOPOLOGY UL. Those commnads are found
in the TTOPOLOGY executable or in any executable including the
BRepTest commands.
The topology adds a new type of variable in Draw, the shape variable,
shape is a topological object, it can be a Vertex, an Edge, a Wire, a
Face, a Shell, a Solid, a CompSolid or a Compound, you are invited to
refer to the topology documentation for more information.
Shapes are usually shared, i.e. the Draw copy command will create a
new shape sharing its representation with the original, but two shapes
sharing their topology can be moved independently (see the section
about transformations for more details).
The following sections cover the topics
- Basic shape commands, to handle the structure of shapes and control
the display.
- Curves and surfaces topology, methods to make topology from
geometry, or vice versa.
- The profile method to make planar profiles.
- Primitive construction commands. Box, cylinder, ...
- Sweeping of shapes.
- Transformations of shapes. Translation, copy, ....
- Topological operations, also known as booleans.
- Local operations. Features, holes.
- Drafting and blending.
- Analysis of shapes. Length, area, volume....
**Basic topology
The basic set of commands allows simple operations on shapes, or
stepwise constructions of objects which may be far from simple. They
are useful for analysis of shapes structure.
- Shapes are displayed with isoparametric curves on the faces, this is
controlled with the isos command. The number of points used to display
the shapes curves can be modified with the discretisation command.
- To modify topological attributes such as the orientation use
orientation, complement and invert.
- To analyse the structure of a shape, use explode, exwire and
nbshapes.
- To create shapes by stepwise construction, use emptycopy, add,
compound.
*** isos, discretisation
.Synopsis
isos [name ...] nbisos
discretisation nbpoints
.Purpose
Shapes are displayed by a set of curves, the edges and isoparametric
curves on the faces. There is color coding for the edges, a red edge
is an isolated edge (belongs to no faces), a green edge is a free
boundary edge (belongs to one face), a yellow edge is a shared edge
(at least two faces).
You can change the number of isoparametric curves on shapes using the
isos commands. Nnote that the same number is used for the U and V
directions, if you give no shape arguments the value you give will be
the new default value (originally 2), if you give no arguments at all
the command prints the current default value.
You can change the default number of points used to display the curves
with the discretisation command. The original value is 30.
.Example
# Display only the edges (the wireframe)
isos 0
.Warning
Do not get confused with the geometric commands nbisos and discr which
control the display of geometry.
.See also
.Index
isos command
discretisation command
display of shapes
free boundary
*** orientation, complement, invert
.Synopsis
orientation name [name ...] F/R/E/I
complement name [name ...]
invert name
.Purpose
These commands are used to change the orientation of shapes.
The orientation command sets one of the four values, FORWARD, REVERSED,
INTERNAL, EXTERNAL
The complement command changes the current orientation to its
complement, FORWARD <-> REVERSED, INTERNAL <-> EXTERNAL.
The invert command creates a new shape which is a copy of the original
with all subshapes orientation reversed. It is useful for example to
reverse the normals of a solid.
.Example
# invert normals of a box
box b 10 20 30
normals b 5
invert b
normals b 5
.Index
orientation command
complement command
invert command
*** explode, exwire, nbshapes
.Synopsis
explode name [C/So/Sh/F/W/E/V]
exwire name
nbshapes name
.Purpose
The explode command is very useful to extract subshapes from a shape,
the subshapes will be named name_1, name_2, ... Note that they are not
copied but shared with the original. Without other arguments than the
shape explode will extract the first sublevel of shapes, the shells of
a solid, the edges of a wire for example. With an argument explode
will extract all subshapes of the given type, C for compounds, So for
solids, Sh for shells, F for faces, W for wires, E for edges, V for
vertices.
The exwire command is a special case of explode for wires which
extract the edges in an ordered way if possible. i/e/ each edge is
connected to the following one by a vertex.
The nbshapes command counts the number of shapes of each type in a
shape.
.Example
# on a box
box b 10 20 30
# whatis returns the type and various information
whatis b
=> b is a shape SOLID FORWARD Free Modified
# make one shell
explode b
whatis b_1
=> b_1 is a shape SHELL REVERSED Modified Orientable Closed
# extract the edges b_1, ... , b_12
explode b e
==> b_12
# count subshapes
nbshapes b
==>
Number of shapes in b
VERTEX : 8
EDGE : 12
WIRE : 6
FACE : 6
SHELL : 1
SOLID : 1
COMPSOLID : 0
COMPOUND : 0
SHAPE : 34
.Warning
.See also
.Index
explode command
exwire command
nbshapes command
exploring a shape
wire exploration
*** emptycopy, add, compound
.Synopsis
emptycopy [newname] name
add name toname
compound [name ...] compoundname
.Purpose
The emptycopy command creates a new shape from an existing one without
subshapes, only the geometry, if there is one, is used. The new shape
is stored with the same name if the newname argument is not
given. This command is useful to modify a frozen shape, a frozen shape
is a shape used by an other shape, it cannot be modifed, so it must be
emptycopied and its subshape may be reinserted with the add command.
The add command insert a reference to a shape in an other one, the
shapes must be compatible (you cannot insert a face into an edge) and
the modified shape must not be frozen. (However, using emptycopy and
add requires caution).
The compound command is very safe, it creates a compound from shapes,
if no shapes are given the compound is empty.
.Example
# a compound with three boxes
box b1 0 0 0 1 1 1
box b2 3 0 0 1 1 1
box b3 6 0 0 1 1 1
compound b1 b2 b3 c
.Warning
.See also
.Index
emptycopy command
add command
compound command
**Curve and surfaces topology
This group of commands is used to create topology from shapes and to
extract shapes geometry. Note that these commands are low-level, to
create faces or wires the profile command described in the next
section is usually more appropriate.
- To create vertices use the vertex command.
- To create edges use the edge, mkedge commands.
- To create wires use the wire, polyline, polyvertex commands.
- To create faces use the mkplane, mkface commands.
- To extract the geometry from edges or faces use the mkcurve and
mkface commands.
- To extract the 2d curves for edges on faces use the pcurve command.
*** vertex
.Synopsis
vertex name [x y z / p edge]
.Purpose
Creates a vertex at a 3d location, the location is a x,y,z point or
the point at parameter p on an edge.
.Example
vertex v1 10 20 30
.Warning
.See also
.Index
vertex command
*** edge, mkedge
.Synopsis
edge name vertex1 vertex2
mkedge edge curve [surface] [pfirst plast] [vfirst [pfirst] vlast [plast]]
.Purpose
The edge command creates a straight line edge between two vertices. Of
course they must not be at the same location.
The mkedge command allows the creation of edges from curves, it is a
quite complete command corresponding to the BRepAPI_MakeEdge class. It
can create an edge from a curve, two parameters can be given for the
vertices (the default are the first and last parameters of the curve),
vertices can also be given with their parameters, this option allows
to inhibate the creation of new vertices, if the parameters of the
vertices are not given they are computed by projection on the
curve. Instead of a 3d curve a 2d curve and a surface can be given.
.Example
# straight line edge
vertex v1 10 0 0
vertex v2 10 10 0
edge e1 v1 v2
# make a circular edge
circle c 0 0 0 5
mkedge e2 c 0 pi/2
# the same result may be achieved with a trimmed curve
# trimmed curves are recognised removed my mkedge
trim c c 0 pi/2
mkedge e2 c
.Warning
.See also
.Index
edge command
mkedge command
curve to edge
edge from curve
*** wire, polyline, polyvertex
.Synopsis
wire name name1 [name2 ...]
polyline name x1 y1 z1 x2 y2 z2 ...
polyvertex name v1 v2 ...
.Purpose
The wire command creates a wire from edges or wires, the order of the
elements must ensure that the wire is connected. The vertices
locations are compared to detect connection, if the vertices are
differents new edges are created to ensure topological connectivity,
so the original edge may be copied in the wire.
The polyline command creates a polygonal wire from points coordinates,
to make a closed wire you should repeat the first point at the end.
The polyvertex command creates a polygonal wire from vertices.
.Example
# create two polygonal wires
# and glue them
polyline w1 0 0 0 10 0 0 10 10 0
polyline w2 10 10 0 0 10 0 0 0 0
wire w w1 w2
.Warning
.See also
.Index
wire command
polyline command
polyvertex command
*** mkplane, mkface
.Synopsis
mkplane name wire
mkface mkface name surface [ufirst ulast vfirst vlast]
.Purpose
Use the mkplane command to make a face from a planar wire, the plane
surface will be constructed with an orientation to keep the face
inside the wire.
Use the mkface command to make a face from a surface, parameter values
can be given to trim a rectangular area, the default are the bounds of
the surface.
.Example
# make a polygonal face
polyline f 0 0 0 20 0 0 20 10 0 10 10 0 10 20 0 0 20 0 0 0 0
mkplane f f
# make a cylindrical face
cylinder g 10
trim g g -pi/3 pi/2 0 15
mkface g g
.Warning
.See also
.Index
mkplane command
mkface command
surface to face
face from surface
*** mkcurve, mkface
.Synopsis
mkcurve name edge
mksurface name face
.Purpose
Use the mkcurve command to create a 3d curve from an edge, the curve
will be trimmed to the edge boundaries, this is not possible if the
edge has no 3d curve.
Use the mksurface command to make a surface from a face, the surface
is not trimmed.
.Example
# make a line
vertex v1 0 0 0
vertex v2 10 0 0
edge e v1 v2
mkcurve l e
.Warning
.See also
.Index
mkcurve command
mkface command
edge to curve
curve from edge
*** pcurve
.Synopsis
pcurve [name edge] face
.Purpose
The pcurve command extracts the 2d curve of an edge on a face. If the
only argument is a face the command extracts all the curves and color
them according to their orientation. This is very useful to check if
the edges in a face are correctly oriented, i.e. they turn
counterclockwise.
.Example
# view the pcurves of a face
plane p
trim p p -1 1 -1 1
mkface p p
av2d; # a 2d view
pcurve p
2dfit
.Warning
If you do not see anything, may you forgot to create a 2d view or to
fit it woth the 2dfit command.
.See also
.Index
pcurve command
** Making profiles
The profile command is a powerfull tool to create planar faces or
wires made of straight lines an circles which are current in
mechanical applications.
*** profile
.Synopsis
profile name [instruction parameters instruction parameters ....]
.Purpose
The profile command creates a planar profile from a list of
instructions. The profile is created in 2d on a plane starting from
point 0,0 and direction X (1,0), some instructions creates a segment
of line or an arc of circle moving the point and setting a new
direction to the tangent of the profile. Other instructions modify the
current direction, the plane or terminate the profile.
Instructions are one or two upper or lowercase letter, followed by a
fixed number of arguments. The angles are given in degree.
- O X Y Z, Set the origin of the plane (default value is 0 0 0)
- P DX DY DZ UX UY UZ, Set the normal and X direction of the plane,
(default value is 0 0 1 1 0 0, an X Y plane)
- X DX, Move the point along X axis.
- Y DY, Move the point along Y axis.
- L DL, Move the point along the current direction by length DL.
- XX X, Set point X coordinate (absolute value).
- YY Y, Set point Y coordinate (absolute value).
- T DX DY, Translate the point.
- TT X Y, Set the point (absolute coordinates).
- R Angle, Rotate the direction (clockwise).
- RR Angle, Set the direction (absolute angle from X axis).
- D DX DY, Set the direction (DX DY will be normalized).
The instructions starting with I will intersect the line defined by the
point and the direction with a curve and move to this new point.
- IX X, Intersect with a vertical (absolute X value).
- IY Y, Intersect with an horizontal (absolute X value).
- C Radius Angle, Make an arc of circle tangent to the current direction.
By default the profile is closed and a face is created, to create a
closed or open wire the following instructions may be used. The
profile will be terminated.
- W, Make a closed wire.
- WW, Make an open wire.
.Example
# Make a square with two fillets on the top
# and a half-circle on the bottom
profile f x 5 r -90 c 5 180 x 5 y 8 c 2 90 xx 2 c 2 90
.Warning
.See also
.Index
profile command
face creation
**Primitives
Primitive commands allow the creation of simple shapes.
- box and wedge commands.
- pcylinder, pcone, psphere, ptorus commands.
*** box, wedge
.Synopsis
box name [x y z] dx dy dz
wedge name dx dy dz ltx / xmin zmin xmax xmax
.Purpose
Use the box command to create a box parallel to the axes with
dx,dy,dz dimensions. x,y,z is the corner of the box, by default it
is the origin.
Use the wedge command to create a wedge, a wedge has six faces, one
face in the OXZ plane has dimensions dx,dz the other face is in the
plane y = dy. It has dimensions ltx,dz or it is bounded by
xmin,zmin,xmax,zmax. The other faces are defined between those faces.
The face in the y=yd plane may be degenerated into a line if ltx = 0
or a point if xmin = xmax and ymin = ymax, in this case there are 5
faces. To position the wedge use the ttranslate and trotate commands.
.Example
# a box at the origin
box b1 10 20 30
# an other box
box b2 30 30 40 10 20 30
# a wedge
wedge w1 10 20 30 5
# a wedge with a sharp edge (5 faces)
wedge w2 10 20 30 0
# a pyramid
wedge w3 20 20 20 10 10 10 10
.Warning
.See also
.Index
box command
wedge command
*** pcylinder, pcone, psphere, ptorus
.Synopsis
pcylinder name [plane] radius height [angle]
pcone name [plane] radius1 radius2 height [angle]
pcone name [plane] radius1 radius2 height [angle]
psphere name [plane] radius1 [angle1 angle2] [angle]
psphere name [plane] radius1 radius2 [angle1 angle2] [angle]
.Purpose
All these commands create solids in the default coordinate system,
using the Z axis as the axis of revolution and the X axis as origin of
angles. To use another system you can translate and rotate the
resulting solid or use a plane as the first argument to specify a
coordinate system. Note that this is quite different because the
translation and rotation only change the coordinate system of the
object. All primitives have an optional last argument which is an
angle in degree around the Z axis, starting from the X axis. The
default is 360.
The pcylinder command creates a cylindrical block around with given
radius and height.
The pcone command creates a truncated cone of given height with radius
radius1 in the plane z = 0 and radius2 in the plane z = heigth. The
radii must not be negative but one of them can be null.
The psphere command creates a solid sphere centered at the origin, if
two angles angle1 and angle2 are given the solid will be limited by
two planes at latitude angle1 and angle2 in degree. The angles must be
increasing and in the range -90,90.
The ptorus command creates a solid torus centered at the origin around
the z axis with given radii, if two increasing angles in degree in the
range 0 360 are given the solid will be bounded by two planar surfaces
at these positions on the circle.
.Example
# make a can
pcylinder cy 5 10
# a quarter of trucated cone
pcone co 15 10 10 90
# three-quarters of sphere
psphere sp 10 270
# half torus
ptorus to 20 5 0 90
.Warning
.See also
.Index
pcylinder command
pcone command
psphere command
ptorus command
cone solid
cylinder solid
sphere solid
torus solid
**Sweeping
Sweepinf creates shapes by sweeping a shape along a path.
- prism sweeps along a direction.
- revol sweeps around an axis.
- pipe sweeps along a wire.
*** prism
.Synopsis
prism name shape dx dy dz ["Copy | Inf | SemiInf]
.Purpose
The prism command creates a new shape by sweeping a shape along a
direction. Any shape can be swept, a vertex gives an edge, en edge
gives a face, a face gives a solid...
The sweeping is done along the vector dx dy dz. The original shape
will be shared in the result unless "Copy" is specified. If Inf is
specified the prism is infinite in both directions, if SemiInf is
specified the prism is infinite in the dx,dy,dz direction, then the
length of the vector has no meaning.
.Example
# sweep a planar face to make a solid
polyline f 0 0 0 10 0 0 10 5 0 5 5 0 5 15 0 0 15 0 0 0 0
mkplane f f
prism p f 0 0 10
.Warning
.See also
.Index
prism command
sweeping
*** revol
.Synopsis
revol name shape x y z dx dy dz angle [Copy]
.Purpose
The revol command creates a new shape by sweeping a shape around the
axis x,y,z dx,dy,dz by an angle in degree. As with the prism command
the shape can be of any type and is not shared if Copy is specified.
.Example
# shell by wire rotation
polyline w 0 0 0 10 0 0 10 5 0 5 5 0 5 15 0 0 15 0
revol s w 20 0 0 0 1 0 90
.Warning
.See also
.Index
revol command
*** pipe
.Synopsis
pipe name wire shape
.Purpose
The pipe command creates a shape by sweeping a shape known as the
profile along a wire known as the spine.
.Example
# sweep a circle along a bezier curve to make a solid pipe
beziercurve spine 4 0 0 0 10 0 0 10 10 0 20 10 0
mkedge spine spine
wire spine spine
circle profile 0 0 0 1 0 0 2
mkedge profile profile
wire profile profile
mkplane profile profile
pipe p spine profile
.Warning
.See also
.Index
pipe command
**Topology transformation
Transformations are application of matrices, when the transformation
is non deforming, like translation or rotation, the object is not
copied, we use the topology local coordinate system feature. The copy
can be enforced with the tcopy command.
- tcopy makes a copy of the structure of a shape.
- ttranslate, trotate, tmove, reset moves a shape.
- tmirror, tscale always modify the shape.
*** tcopy
.Synopsis
tcopy name toname [name toname ...]
.Purpose
Copy the structure of a shape in a new shape, including the geometry.
.Example
# create an edge from a curve and copy it
beziercurve c 3 0 0 0 10 0 0 20 10 0
mkedge e1 c
ttranslate e1 0 5 0
tcopy e1 e2
ttranslate e2 0 5 0
# now modify the curve, only e1 will be modified
cmovep c 2 0 0 20
.Warning
.See also
.Index
tcopy command
copying shapes
*** tmove, treset
.Synopsis
tmove name [name ...] shape
reset name [name ...]
.Purpose
The tmove and reset command are used to modify the location, or local
coordinate system of a shape, tmove applies to some shapes the
location of a given shape. reset removes the location of a shape,
restoring it in its original coordinate system.
.Example
# create two boxes
box b1 10 10 10
box b2 20 0 0 10 10 10
# translate the first box
ttranslate b1 0 10 0
# and apply the same location to b2
tmove b2 b1
# return to original positions
reset b1 b2
.Warning
.See also
.Index
tmove command
treset command
location
*** ttranslate, trotate
.Synopsis
ttranslate [name ...] dx dy dz
trotate [name ...] x y z dx dy dz angle
.Purpose
Use the ttranslate command to translate a set of shapes by a given
vector, and the trotate command to rotate them by a given angle in
degree around an axis. Both commands only modify the location of the
shape. When transforming multiple shapes the same location is used for
all the shapes, when a command is used for each shape, even if the
translation or the rotation are the same, a new location is created.
Locations are very economic in the data structure because multiple
occurrences of an object share the topological description.
.Example
# make rotated copy of a sphere and cylinders
pcylinder c1 30 5
copy c1 c2
ttranslate c2 0 0 20
psphere s 3
ttranslate s 25 0 12.5
for {set i 0} {$i < 360} {incr i 20} {
copy s s$i
trotate s$i 0 0 0 0 0 1 $i
}
.Warning
.See also
.Index
ttranslate command
trotate command
translating shapes
rotating shapes
*** tmirror, tscale
.Synopsis
tmirror name x y z dx dy dz
tscale name x y z scale
.Purpose
The tmirror command makes a mirror copy of a shape about a plane x,y,z
dx,dy,dz, the tscale command applies a central homothety to the shape.
.Example
# mirror a portion of cylinder about the YZ plane
pcylinder c1 10 10 270
copy c1 c2
tmirror c2 15 0 0 1 0 0
# and scale it
tscale c1 0 0 0 0.5
.Warning
.See also
.Index
tmirror command
tscale command
mirroring shapes
scaling shapes
**Topological operations
Topological operations includes the boolean operations, they are using
intersections.
- fuse, cut, common are the boolean operations.
- section, psection computes sections.
*** fuse, cut, common
.Synopsis
fuse name shape1 shape2
cut name shape1 shape2
common name shape1 shape2
.Purpose
Creation of a new shape by a boolean operation between two shapes,
fuse is the union, cut substract the second to the first, common is
the intersection.
.Example
# the four boolean operations between a box and a cylinder
box b 0 -10 5 20 20 10
pcylinder c 5 20
fuse s1 b c
ttranslate s1 40 0 0
cut s2 b c
ttranslate s2 -40 0 0
cut s3 c b
ttranslate s3 0 40 0
common s4 b c
ttranslate s4 0 -40 0
.Warning
.See also
.Index
fuse command
cut command
common command
boolean operations
*** section, psection
.Synopsis
section name shape1 shape2
psection name shape plane
.Purpose
The section command creates a compound with the intersection edges
created from the faces of two shapes, this is the section line. The
psection command do the same between a shape and a plane. This is the
planar section.
.Example
# section line between a cylinder and a box
pcylinder c 10 20
box b 0 0 5 15 15 15
trotate b 0 0 0 1 1 1 20
section s b c
# planar section of a cone
pcone c 10 30 30
plane p 0 0 15 1 1 2
psection s c p
.Warning
.See also
.Index
section command
psection command
planar section
**Local operations
Local operations are boolean operations restricted to some faces of a
solid.
- localope is the general local operation command, to perform local
boolean operations.
- hole, firsthole, holend, blindhole are various commands to create
cylindrical holes.
*** localope
.Synopsis
localope name shape tool F/C face [face ...]
.Purpose
Use the localope command to perform a local operation on a shape with
a tool. The operation is a fusion or a cut (use 'F' or 'C'). The
operation will be restricted to the designates faces. The tool is
intersected only with the given faces and other faces necessary to
close the intersection curves.
This operation is the basis for features implementation.
.Example
# make a box and fuse a cylinder on one side
box b 10 10 10
pcylinder c 1 20
ttranslate c 5 5 -5
# click on the top or bottom face and observe the result...
localope a b c F .
.Warning
.See also
.Index
localope command
features
*** hole, firsthole, holend, blindhole, holecontrol
.Synopsis
hole name shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius [Pfrom Pto]
firsthole name shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius
holend name shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius
blindhole name shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius Length
holecontrol [0/1]
.Purpose
Use the hole commands to make a cylindrical hole in a solid, in any
case you must give an axis and a radius with Or.X Or.Y Or.Z Dir.X
Dir.Y Dir.Z Radius.
- hole will make a hole through the whole solid or between parameters
Pfrom and Pto on the axis.
- firsthole will make only the first possible hole along the positive
side of the axis.
- holend will make all possible holes along the positive side of the
axis.
- blindhole will make a blind hole of depth Length starting from the
origin of the axis on the positive side.
The holecontrol command is used to set or display the control
mode. When the value is 1 a check of validity is performed after all
the hole commands.
.Example
# make a hole through a cylinder
pcylinder c 5 10
firsthole r c 0 -10 5 0 1 0 1
.Warning
If the axis does not intersect the solid nothing is done, this is not
the same as a full boolean operation.
.See also
.Index
hole command
firsthole command
holend command
blindhole command
holecontrol command
**Drafting and blending
Drafting is the creation of a new shape by tilting faces with an
angle, blending is the creation of a new shapes by rounding of edges.
- Use the depouille command for drafting.
- Use the blend command for simple blending.
- Use the chfi2d command for blending or chamfering planar faces.
- Use fubl for a fusion + blending operation.
- Use buildevol, mkevol, updatevol to make varying radius blending.
*** depouille
.Synopsis
depouille name shape dirx diry dirz face angle x y x dx dy dz [face angle...]
.Purpose
Use this command to create a new shape by drafting faces of a shape,
you must give the shape to be drafted and the drafting direction
(think of it as an unmolding direction), then faces with angles and
axis of rotation. The faces must be faces of the shape, you can use
the dot syntax to pick the faces.
.Example
# draft a face of a box
box b 10 10 10
explode b f
depouille a b 0 0 1 b_2 10 0 10 0 1 0 5
.Warning
.See also
.Index
depouille command
*** blend
.Synopsis
blend name shape radius edge [radius edge ...]
.Purpose
The blend command creates a new shape by rounding edges of a shape,
you must give the shape and pairs radius, edge. The edge must be in
the shape, you may use the dot syntax. Not that the blend is expanded
to other edges when the faces are tangent. Blends are also called
fillets.
.Example
# blend a box, click on an edge
box b 20 20 20
blend b b 2 .
.Warning
.See also
.Index
blend command
fillets
*** chfi2d
.Synopsis
chfi2d result face [edge1 edge2 (F radius/CDD d1 d2/CDA d ang) ....]
.Purpose
Creates a new face name result from an existing face adding fillets
and chamfers. The face must be planar, if it is a wire a planar face
can be made with the mkplane command. Multiples fillets and chamfers
can be built.
edge1 edge2 F radius, builds a fillet of the given radius on the
vertex connecting the two edges.
edge1 edge2 CDD d1 d2, builds a chamfer on the vertex connecting the
two edges with distance d1 on edge1 and d2 on edge2.
edge1 edge2 CDA d ang, builds a chamfer on the vertex connecting the
two edges at distance d on edge1 making an angle ang (degree) with
edge1.
.Example
# Make a fillet and the two kinds of vertices
# with graphical selection of the edges
polyline f 0 0 0 20 0 0 20 10 0 10 10 0 10 30 0 0 30 0 0 0 0
mkplane f f
chfi2d f f . . F 3 . . CDD 1 2 . . CDA 1.5 60
.Warning
.See also
mkplane
.Index
chfi2d command
rounding
fillet 2d
chamfer 2d
*** fubl
.Synopsis
fubl name shape1 shape2 radius
.Purpose
Make a fusion boolean operation between two shapes then blend the
intersection edges with the radius.
.Example
# fuse-blend two boxes
box b1 20 20 5
copy b1 b2
ttranslate b2 -10 10 3
fubl a b1 b2 1
.Warning
.See also
fuse
blend
.Index
fubl command
*** mkevol, updatevol, buildevol
.Synopsis
mkevol name shape
updatevol edge u1 radius1 [u2 radius2 ...]
buildevol
.Purpose
These three commands work together to blend shapes with evolving
radius. First you give the shape and the name of the result with the
mkevol command. Then you describe edges to be blended with the
updatevol command., for each edge you give a set of pairs : parameter
radius, the parameters will be scaled along the edge and the radius
function interpolated for the whole edge. At last the buildevol
command computes the result.
.Example
# makes an evolved radius on a box
box b 10 10 10
mkevol b b
# click an edge
updatevol . 0 1 1 3 2 2
buildevol
.Warning
.See also
.Index
buildevol command
mkevol command
updatevol command
**Topology analysis
Analysis of shapes includes the commands to compute length, area
volumes and inertia properties.
- Use lprops, sprops, vprops to compute properties.
- Use bounding to display the bounding box of a shape.
*** lprops, sprops, vprops
.Synopsis
lprops shape
sprops shape
vprops shape
.Purpose
lprops computes massic properties of all edges in the shape with a
linear density of 1, sprops of all faces with a surfacic density of 1
and vprops of all solids with a density of 1.
The three commands print the mass, which is either the length, the
area or the volume, the coordinates of the center of gravity, the
matrix of inertia and the moments. The center and the main axis of
inertia are displayed.
.Example
# volume of a cylinder
pcylinder c 10 20
vprops c
==> results
Mass : 6283.18529981086
Center of gravity :
X = 4.1004749224903e-06
Y = -2.03392858349861e-16
Z = 9.9999999941362
Matrix of Inertia :
366519.141445068 5.71451850691484e-12 0.257640437382627
5.71451850691484e-12 366519.141444962 2.26823064169991e-10
0.257640437382627 2.26823064169991e-10 314159.265358863
Moments :
IX = 366519.141446336
IY = 366519.141444962
IZ = 314159.265357595
.Warning
.See also
.Index
lprops command
sprops command
vprops command
length
area
volume
inertia
*** bounding
.Synopsis
bounding shape
.Purpose
Display the bounding box of a shape and returns the string "xmin ymin
zmin xmax ymax zmax"
.Example
# bounding box of a torus
ptorus t 20 5
bounding t
==>
-25.000000100000001 -25.000000100000001 -5.0000001000000003
25.000000100000001 25.000000100000001 5.0000001000000003
.Warning
.See also
.Index
bounding command
box, bounding
|