summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runpath.cc
blob: 87b10b02d8a1eec5adac941801fc12a5707b8e6f (plain)
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
/***** Autogenerated from runpath.in; changes will be overwritten *****/

#line 1 "runtimebase.in"
/*****
 * runtimebase.in
 * Andy Hammerlindl  2009/07/28
 *
 * Common declarations needed for all code-generating .in files.
 *
 *****/


#line 1 "runpath.in"
/*****
 * runpicture.in
 *
 * Runtime functions for picture operations.
 *
 *****/

#line 1 "runtimebase.in"
#include "stack.h"
#include "types.h"
#include "builtin.h"
#include "entry.h"
#include "errormsg.h"
#include "array.h"
#include "triple.h"
#include "callable.h"
#include "opsymbols.h"

using vm::stack;
using vm::error;
using vm::array;
using vm::read;
using vm::callable;
using types::formal;
using types::function;
using camp::triple;

#define PRIMITIVE(name,Name,asyName) using types::prim##Name;
#include <primitives.h>
#undef PRIMITIVE

typedef double real;

void unused(void *);

namespace run {
array *copyArray(array *a);
array *copyArray2(array *a);
array *copyArray3(array *a);

double *copyTripleArray2Components(array *a, bool square=true, size_t dim2=0,
                                   GCPlacement placement=NoGC);
}

function *realRealFunction();

#define CURRENTPEN processData().currentpen

#line 17 "runpath.in"
#include "path.h"
#include "arrayop.h"
#include "predicates.h"

using namespace camp;
using namespace vm;

typedef array realarray;
typedef array realarray2;
typedef array patharray;

using types::realArray;
using types::realArray2;
using types::pathArray;

Int windingnumber(array *p, camp::pair z)
{
  size_t size=checkArray(p);
  Int count=0;
  for(size_t i=0; i < size; i++) 
    count += read<path *>(p,i)->windingnumber(z);
  return count;
}

// Autogenerated routines:



#ifndef NOSYM
#include "runpath.symbols.h"

#endif
namespace run {
#line 44 "runpath.in"
void nullPath(stack *Stack)
{
#line 45 "runpath.in"
  {Stack->push<path>(nullpath); return;}
}

#line 49 "runpath.in"
// bool ==(path a, path b);
void gen_runpath1(stack *Stack)
{
  path b=vm::pop<path>(Stack);
  path a=vm::pop<path>(Stack);
#line 50 "runpath.in"
  {Stack->push<bool>(a == b); return;}
}

#line 54 "runpath.in"
// bool !=(path a, path b);
void gen_runpath2(stack *Stack)
{
  path b=vm::pop<path>(Stack);
  path a=vm::pop<path>(Stack);
#line 55 "runpath.in"
  {Stack->push<bool>(!(a == b)); return;}
}

#line 59 "runpath.in"
// pair point(path p, Int t);
void gen_runpath3(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 60 "runpath.in"
  {Stack->push<pair>(p.point((Int) t)); return;}
}

#line 64 "runpath.in"
// pair point(path p, real t);
void gen_runpath4(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 65 "runpath.in"
  {Stack->push<pair>(p.point(t)); return;}
}

#line 69 "runpath.in"
// pair precontrol(path p, Int t);
void gen_runpath5(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 70 "runpath.in"
  {Stack->push<pair>(p.precontrol((Int) t)); return;}
}

#line 74 "runpath.in"
// pair precontrol(path p, real t);
void gen_runpath6(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 75 "runpath.in"
  {Stack->push<pair>(p.precontrol(t)); return;}
}

#line 79 "runpath.in"
// pair postcontrol(path p, Int t);
void gen_runpath7(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 80 "runpath.in"
  {Stack->push<pair>(p.postcontrol((Int) t)); return;}
}

#line 84 "runpath.in"
// pair postcontrol(path p, real t);
void gen_runpath8(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 85 "runpath.in"
  {Stack->push<pair>(p.postcontrol(t)); return;}
}

#line 89 "runpath.in"
// pair dir(path p, Int t, Int sign=0, bool normalize=true);
void gen_runpath9(stack *Stack)
{
  bool normalize=vm::pop<bool>(Stack,true);
  Int sign=vm::pop<Int>(Stack,0);
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 90 "runpath.in"
  {Stack->push<pair>(p.dir(t,sign,normalize)); return;}
}

#line 94 "runpath.in"
// pair dir(path p, real t, bool normalize=true);
void gen_runpath10(stack *Stack)
{
  bool normalize=vm::pop<bool>(Stack,true);
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 95 "runpath.in"
  {Stack->push<pair>(p.dir(t,normalize)); return;}
}

#line 99 "runpath.in"
// pair accel(path p, Int t, Int sign=0);
void gen_runpath11(stack *Stack)
{
  Int sign=vm::pop<Int>(Stack,0);
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 100 "runpath.in"
  {Stack->push<pair>(p.accel(t,sign)); return;}
}

#line 104 "runpath.in"
// pair accel(path p, real t);
void gen_runpath12(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 105 "runpath.in"
  {Stack->push<pair>(p.accel(t)); return;}
}

#line 109 "runpath.in"
// real radius(path p, real t);
void gen_runpath13(stack *Stack)
{
  real t=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 110 "runpath.in"
  pair v=p.dir(t,false);
  pair a=p.accel(t);
  real d=dot(a,v);
  real v2=v.abs2();
  real a2=a.abs2();
  real denom=v2*a2-d*d;
  real r=v2*sqrt(v2);
  {Stack->push<real>(denom > 0 ? r/sqrt(denom) : 0.0); return;}
}

#line 121 "runpath.in"
// path reverse(path p);
void gen_runpath14(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 122 "runpath.in"
  {Stack->push<path>(p.reverse()); return;}
}

#line 126 "runpath.in"
// path subpath(path p, Int a, Int b);
void gen_runpath15(stack *Stack)
{
  Int b=vm::pop<Int>(Stack);
  Int a=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 127 "runpath.in"
  {Stack->push<path>(p.subpath((Int) a, (Int) b)); return;}
}

#line 131 "runpath.in"
// path subpath(path p, real a, real b);
void gen_runpath16(stack *Stack)
{
  real b=vm::pop<real>(Stack);
  real a=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 132 "runpath.in"
  {Stack->push<path>(p.subpath(a,b)); return;}
}

#line 136 "runpath.in"
// path nurb(pair z0, pair z1, pair z2, pair z3,          real w0, real w1, real w2, real w3, Int m);
void gen_runpath17(stack *Stack)
{
  Int m=vm::pop<Int>(Stack);
  real w3=vm::pop<real>(Stack);
  real w2=vm::pop<real>(Stack);
  real w1=vm::pop<real>(Stack);
  real w0=vm::pop<real>(Stack);
  pair z3=vm::pop<pair>(Stack);
  pair z2=vm::pop<pair>(Stack);
  pair z1=vm::pop<pair>(Stack);
  pair z0=vm::pop<pair>(Stack);
#line 138 "runpath.in"
  {Stack->push<path>(nurb(z0,z1,z2,z3,w0,w1,w2,w3,m)); return;}
}

#line 142 "runpath.in"
// Int length(path p);
void gen_runpath18(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 143 "runpath.in"
  {Stack->push<Int>(p.length()); return;}
}

#line 147 "runpath.in"
// bool cyclic(path p);
void gen_runpath19(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 148 "runpath.in"
  {Stack->push<bool>(p.cyclic()); return;}
}

#line 152 "runpath.in"
// bool straight(path p, Int t);
void gen_runpath20(stack *Stack)
{
  Int t=vm::pop<Int>(Stack);
  path p=vm::pop<path>(Stack);
#line 153 "runpath.in"
  {Stack->push<bool>(p.straight(t)); return;}
}

#line 157 "runpath.in"
// path unstraighten(path p);
void gen_runpath21(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 158 "runpath.in"
  {Stack->push<path>(p.unstraighten()); return;}
}

#line 162 "runpath.in"
// bool piecewisestraight(path p);
void gen_runpath22(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 163 "runpath.in"
  {Stack->push<bool>(p.piecewisestraight()); return;}
}

#line 167 "runpath.in"
// real arclength(path p);
void gen_runpath23(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 168 "runpath.in"
  {Stack->push<real>(p.arclength()); return;}
}

#line 172 "runpath.in"
// real arctime(path p, real dval);
void gen_runpath24(stack *Stack)
{
  real dval=vm::pop<real>(Stack);
  path p=vm::pop<path>(Stack);
#line 173 "runpath.in"
  {Stack->push<real>(p.arctime(dval)); return;}
}

#line 177 "runpath.in"
// real dirtime(path p, pair z);
void gen_runpath25(stack *Stack)
{
  pair z=vm::pop<pair>(Stack);
  path p=vm::pop<path>(Stack);
#line 178 "runpath.in"
  {Stack->push<real>(p.directiontime(z)); return;}
}

#line 182 "runpath.in"
// realarray* intersect(path p, path q, real fuzz=-1);
void gen_runpath26(stack *Stack)
{
  real fuzz=vm::pop<real>(Stack,-1);
  path q=vm::pop<path>(Stack);
  path p=vm::pop<path>(Stack);
#line 183 "runpath.in"
  bool exact=fuzz <= 0.0;
  if(fuzz < 0)
    fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
                       ::max(length(q.max()),length(q.min())));
  std::vector<real> S,T;
  real s,t;
  if(intersections(s,t,S,T,p,q,fuzz,true,exact)) {
    array *V=new array(2);
    (*V)[0]=s;
    (*V)[1]=t;
    {Stack->push<realarray*>(V); return;}
  }
  {Stack->push<realarray*>(new array(0)); return;}
}

#line 199 "runpath.in"
// realarray2* intersections(path p, path q, real fuzz=-1);
void gen_runpath27(stack *Stack)
{
  real fuzz=vm::pop<real>(Stack,-1);
  path q=vm::pop<path>(Stack);
  path p=vm::pop<path>(Stack);
#line 200 "runpath.in"
  bool exact=fuzz <= 0.0;
  if(fuzz < 0.0)
    fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
                       ::max(length(q.max()),length(q.min())));
  real s,t;
  std::vector<real> S,T;
  intersections(s,t,S,T,p,q,fuzz,false,true);
  size_t n=S.size();
  if(n == 0 && !exact) {
    if(intersections(s,t,S,T,p,q,fuzz,true,false)) {
      array *V=new array(1);
      array *Vi=new array(2);
      (*V)[0]=Vi;
      (*Vi)[0]=s;
      (*Vi)[1]=t;
      {Stack->push<realarray2*>(V); return;}
    }
  }
  array *V=new array(n);
  for(size_t i=0; i < n; ++i) {
    array *Vi=new array(2);
    (*V)[i]=Vi;
    (*Vi)[0]=S[i];
    (*Vi)[1]=T[i];
  }
  stable_sort(V->begin(),V->end(),run::compare2<real>());
  {Stack->push<realarray2*>(V); return;}
}

#line 230 "runpath.in"
// realarray* intersections(path p, explicit pair a, explicit pair b, real fuzz=-1);
void gen_runpath28(stack *Stack)
{
  real fuzz=vm::pop<real>(Stack,-1);
  pair b=vm::pop<pair>(Stack);
  pair a=vm::pop<pair>(Stack);
  path p=vm::pop<path>(Stack);
#line 231 "runpath.in"
  if(fuzz < 0)
    fuzz=BigFuzz*::max(::max(length(p.max()),length(p.min())),
                       ::max(length(a),length(b)));
  std::vector<real> S;
  intersections(S,p,a,b,fuzz);
  sort(S.begin(),S.end());
  size_t n=S.size();
  array *V=new array(n);
  for(size_t i=0; i < n; ++i)
    (*V)[i]=S[i];
  {Stack->push<realarray*>(V); return;}
}

// Return the intersection point of the extensions of the line segments 
// PQ and pq.
#line 247 "runpath.in"
// pair extension(pair P, pair Q, pair p, pair q);
void gen_runpath29(stack *Stack)
{
  pair q=vm::pop<pair>(Stack);
  pair p=vm::pop<pair>(Stack);
  pair Q=vm::pop<pair>(Stack);
  pair P=vm::pop<pair>(Stack);
#line 248 "runpath.in"
  pair ac=P-Q;
  pair bd=q-p;
  real det=ac.getx()*bd.gety()-ac.gety()*bd.getx();
  if(det == 0) {Stack->push<pair>(pair(infinity,infinity)); return;}
  {Stack->push<pair>(P+((p.getx()-P.getx())*bd.gety()-(p.gety()-P.gety())*bd.getx())*ac/det); return;}
}

#line 256 "runpath.in"
// Int size(path p);
void gen_runpath30(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 257 "runpath.in"
  {Stack->push<Int>(p.size()); return;}
}

#line 261 "runpath.in"
// path &(path p, path q);
void gen_runpath31(stack *Stack)
{
  path q=vm::pop<path>(Stack);
  path p=vm::pop<path>(Stack);
#line 262 "runpath.in"
  {Stack->push<path>(camp::concat(p,q)); return;}
}

#line 266 "runpath.in"
// pair min(path p);
void gen_runpath32(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 267 "runpath.in"
  {Stack->push<pair>(p.min()); return;}
}

#line 271 "runpath.in"
// pair max(path p);
void gen_runpath33(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 272 "runpath.in"
  {Stack->push<pair>(p.max()); return;}
}

#line 276 "runpath.in"
// pair min(patharray *a);
void gen_runpath34(stack *Stack)
{
  patharray * a=vm::pop<patharray *>(Stack);
#line 277 "runpath.in" 
  if (!a) {
    error("min called on null path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }
  if (a->empty()) {
    error("min called on empty path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }

  path *g = a->read<path *>(0);
  pair z = g->min();
  double minx = z.getx(), miny = z.gety();

  for (size_t i = 1; i < a->size(); ++i) {
    path *g = a->read<path *>(i);
    pair z = g->min();
    double x = z.getx(), y = z.gety();
    if (x < minx)
      minx = x;
    if (y < miny)
      miny = y;
  }

  {Stack->push<pair>(pair(minx, miny)); return;}
}

#line 304 "runpath.in"
// pair max(patharray *a);
void gen_runpath35(stack *Stack)
{
  patharray * a=vm::pop<patharray *>(Stack);
#line 305 "runpath.in" 
  if (!a) {
    error("max called on null path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }
  if (a->empty()) {
    error("max called on empty path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }

  path *g = a->read<path *>(0);
  pair z = g->max();
  double maxx = z.getx(), maxy = z.gety();

  for (size_t i = 1; i < a->size(); ++i) {
    path *g = a->read<path *>(i);
    pair z = g->max();
    double x = z.getx(), y = z.gety();
    if (x > maxx)
      maxx = x;
    if (y > maxy)
      maxy = y;
  }

  {Stack->push<pair>(pair(maxx, maxy)); return;}
}

#line 332 "runpath.in"
// pair minAfterTransform(transform t, patharray *a);
void gen_runpath36(stack *Stack)
{
  patharray * a=vm::pop<patharray *>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 333 "runpath.in" 
  if (!a) {
    error("minAfterTransform called on null path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }
  if (a->empty()) {
    error("minAfterTransform called on empty path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }

  path g = a->read<path *>(0)->transformed(t);
  pair z = g.min();
  double minx = z.getx(), miny = z.gety();

  for (size_t i = 1; i < a->size(); ++i) {
    path g = a->read<path *>(i)->transformed(t);
    pair z = g.min();
    double x = z.getx(), y = z.gety();
    if (x < minx)
      minx = x;
    if (y < miny)
      miny = y;
  }

  {Stack->push<pair>(pair(minx, miny)); return;}
}

#line 360 "runpath.in"
// pair maxAfterTransform(transform t, patharray *a);
void gen_runpath37(stack *Stack)
{
  patharray * a=vm::pop<patharray *>(Stack);
  transform t=vm::pop<transform>(Stack);
#line 361 "runpath.in" 
  if (!a) {
    error("maxAfterTransform called on null path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }
  if (a->empty()) {
    error("maxAfterTransform called on empty path array");
    {Stack->push<pair>(pair(0,0)); return;}
  }

  path g = a->read<path *>(0)->transformed(t);
  pair z = g.max();
  double maxx = z.getx(), maxy = z.gety();

  for (size_t i = 1; i < a->size(); ++i) {
    path g = a->read<path *>(i)->transformed(t);
    pair z = g.max();
    double x = z.getx(), y = z.gety();
    if (x > maxx)
      maxx = x;
    if (y > maxy)
      maxy = y;
  }

  {Stack->push<pair>(pair(maxx, maxy)); return;}
}

#line 388 "runpath.in"
// realarray* mintimes(path p);
void gen_runpath38(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 389 "runpath.in"
  array *V=new array(2);
  pair z=p.mintimes();
  (*V)[0]=z.getx();
  (*V)[1]=z.gety();
  {Stack->push<realarray*>(V); return;}
}

#line 397 "runpath.in"
// realarray* maxtimes(path p);
void gen_runpath39(stack *Stack)
{
  path p=vm::pop<path>(Stack);
#line 398 "runpath.in"
  array *V=new array(2);
  pair z=p.maxtimes();
  (*V)[0]=z.getx();
  (*V)[1]=z.gety();
  {Stack->push<realarray*>(V); return;}
}

#line 406 "runpath.in"
// real relativedistance(real theta, real phi, real t, bool atleast);
void gen_runpath40(stack *Stack)
{
  bool atleast=vm::pop<bool>(Stack);
  real t=vm::pop<real>(Stack);
  real phi=vm::pop<real>(Stack);
  real theta=vm::pop<real>(Stack);
#line 407 "runpath.in"
  {Stack->push<real>(camp::velocity(theta,phi,tension(t,atleast))); return;}
}

#line 411 "runpath.in"
// Int windingnumber(patharray *p, pair z);
void gen_runpath41(stack *Stack)
{
  pair z=vm::pop<pair>(Stack);
  patharray * p=vm::pop<patharray *>(Stack);
#line 412 "runpath.in"
  {Stack->push<Int>(windingnumber(p,z)); return;}
}

#line 416 "runpath.in"
// bool inside(explicit patharray *g, pair z, pen fillrule=CURRENTPEN);
void gen_runpath42(stack *Stack)
{
  pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
  pair z=vm::pop<pair>(Stack);
  patharray * g=vm::pop<patharray *>(Stack);
#line 417 "runpath.in"
  {Stack->push<bool>(fillrule.inside(windingnumber(g,z))); return;}
}

#line 421 "runpath.in"
// bool inside(path g, pair z, pen fillrule=CURRENTPEN);
void gen_runpath43(stack *Stack)
{
  pen fillrule=vm::pop<pen>(Stack,CURRENTPEN);
  pair z=vm::pop<pair>(Stack);
  path g=vm::pop<path>(Stack);
#line 422 "runpath.in"
  {Stack->push<bool>(fillrule.inside(g.windingnumber(z))); return;}
}

// Determine the side of a--b that c lies on
// (negative=left, zero=on line, positive=right).
#line 428 "runpath.in"
// real side(pair a, pair b, pair c);
void gen_runpath44(stack *Stack)
{
  pair c=vm::pop<pair>(Stack);
  pair b=vm::pop<pair>(Stack);
  pair a=vm::pop<pair>(Stack);
#line 429 "runpath.in"
  {Stack->push<real>(orient2d(a,b,c)); return;}
}

// Determine the side of the counterclockwise circle through a,b,c that d
// lies on (negative=inside, 0=on circle, positive=right). 
#line 435 "runpath.in"
// real incircle(pair a, pair b, pair c, pair d);
void gen_runpath45(stack *Stack)
{
  pair d=vm::pop<pair>(Stack);
  pair c=vm::pop<pair>(Stack);
  pair b=vm::pop<pair>(Stack);
  pair a=vm::pop<pair>(Stack);
#line 436 "runpath.in"
  {Stack->push<real>(incircle(a.getx(),a.gety(),b.getx(),b.gety(),c.getx(),c.gety(),
                  d.getx(),d.gety())); return;}
}

} // namespace run

namespace trans {

void gen_runpath_venv(venv &ve)
{
#line 44 "runpath.in"
  REGISTER_BLTIN(run::nullPath,"nullPath");
#line 49 "runpath.in"
  addFunc(ve, run::gen_runpath1, primBoolean(), SYM_EQ, formal(primPath(), SYM(a), false, false), formal(primPath(), SYM(b), false, false));
#line 54 "runpath.in"
  addFunc(ve, run::gen_runpath2, primBoolean(), SYM_NEQ, formal(primPath(), SYM(a), false, false), formal(primPath(), SYM(b), false, false));
#line 59 "runpath.in"
  addFunc(ve, run::gen_runpath3, primPair(), SYM(point), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false));
#line 64 "runpath.in"
  addFunc(ve, run::gen_runpath4, primPair(), SYM(point), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false));
#line 69 "runpath.in"
  addFunc(ve, run::gen_runpath5, primPair(), SYM(precontrol), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false));
#line 74 "runpath.in"
  addFunc(ve, run::gen_runpath6, primPair(), SYM(precontrol), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false));
#line 79 "runpath.in"
  addFunc(ve, run::gen_runpath7, primPair(), SYM(postcontrol), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false));
#line 84 "runpath.in"
  addFunc(ve, run::gen_runpath8, primPair(), SYM(postcontrol), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false));
#line 89 "runpath.in"
  addFunc(ve, run::gen_runpath9, primPair(), SYM(dir), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false), formal(primBoolean(), SYM(normalize), true, false));
#line 94 "runpath.in"
  addFunc(ve, run::gen_runpath10, primPair(), SYM(dir), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false), formal(primBoolean(), SYM(normalize), true, false));
#line 99 "runpath.in"
  addFunc(ve, run::gen_runpath11, primPair(), SYM(accel), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false), formal(primInt(), SYM(sign), true, false));
#line 104 "runpath.in"
  addFunc(ve, run::gen_runpath12, primPair(), SYM(accel), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false));
#line 109 "runpath.in"
  addFunc(ve, run::gen_runpath13, primReal(), SYM(radius), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(t), false, false));
#line 121 "runpath.in"
  addFunc(ve, run::gen_runpath14, primPath(), SYM(reverse), formal(primPath(), SYM(p), false, false));
#line 126 "runpath.in"
  addFunc(ve, run::gen_runpath15, primPath(), SYM(subpath), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(a), false, false), formal(primInt(), SYM(b), false, false));
#line 131 "runpath.in"
  addFunc(ve, run::gen_runpath16, primPath(), SYM(subpath), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(a), false, false), formal(primReal(), SYM(b), false, false));
#line 136 "runpath.in"
  addFunc(ve, run::gen_runpath17, primPath(), SYM(nurb), formal(primPair(), SYM(z0), false, false), formal(primPair(), SYM(z1), false, false), formal(primPair(), SYM(z2), false, false), formal(primPair(), SYM(z3), false, false), formal(primReal(), SYM(w0), false, false), formal(primReal(), SYM(w1), false, false), formal(primReal(), SYM(w2), false, false), formal(primReal(), SYM(w3), false, false), formal(primInt(), SYM(m), false, false));
#line 142 "runpath.in"
  addFunc(ve, run::gen_runpath18, primInt(), SYM(length), formal(primPath(), SYM(p), false, false));
#line 147 "runpath.in"
  addFunc(ve, run::gen_runpath19, primBoolean(), SYM(cyclic), formal(primPath(), SYM(p), false, false));
#line 152 "runpath.in"
  addFunc(ve, run::gen_runpath20, primBoolean(), SYM(straight), formal(primPath(), SYM(p), false, false), formal(primInt(), SYM(t), false, false));
#line 157 "runpath.in"
  addFunc(ve, run::gen_runpath21, primPath(), SYM(unstraighten), formal(primPath(), SYM(p), false, false));
#line 162 "runpath.in"
  addFunc(ve, run::gen_runpath22, primBoolean(), SYM(piecewisestraight), formal(primPath(), SYM(p), false, false));
#line 167 "runpath.in"
  addFunc(ve, run::gen_runpath23, primReal(), SYM(arclength), formal(primPath(), SYM(p), false, false));
#line 172 "runpath.in"
  addFunc(ve, run::gen_runpath24, primReal(), SYM(arctime), formal(primPath(), SYM(p), false, false), formal(primReal(), SYM(dval), false, false));
#line 177 "runpath.in"
  addFunc(ve, run::gen_runpath25, primReal(), SYM(dirtime), formal(primPath(), SYM(p), false, false), formal(primPair(), SYM(z), false, false));
#line 182 "runpath.in"
  addFunc(ve, run::gen_runpath26, realArray(), SYM(intersect), formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false));
#line 199 "runpath.in"
  addFunc(ve, run::gen_runpath27, realArray2(), SYM(intersections), formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false), formal(primReal(), SYM(fuzz), true, false));
#line 230 "runpath.in"
  addFunc(ve, run::gen_runpath28, realArray(), SYM(intersections), formal(primPath(), SYM(p), false, false), formal(primPair(), SYM(a), false, true), formal(primPair(), SYM(b), false, true), formal(primReal(), SYM(fuzz), true, false));
#line 245 "runpath.in"
  addFunc(ve, run::gen_runpath29, primPair(), SYM(extension), formal(primPair(), SYM(p), false, false), formal(primPair(), SYM(q), false, false), formal(primPair(), SYM(p), false, false), formal(primPair(), SYM(q), false, false));
#line 256 "runpath.in"
  addFunc(ve, run::gen_runpath30, primInt(), SYM(size), formal(primPath(), SYM(p), false, false));
#line 261 "runpath.in"
  addFunc(ve, run::gen_runpath31, primPath(), SYM_AMPERSAND, formal(primPath(), SYM(p), false, false), formal(primPath(), SYM(q), false, false));
#line 266 "runpath.in"
  addFunc(ve, run::gen_runpath32, primPair(), SYM(min), formal(primPath(), SYM(p), false, false));
#line 271 "runpath.in"
  addFunc(ve, run::gen_runpath33, primPair(), SYM(max), formal(primPath(), SYM(p), false, false));
#line 276 "runpath.in"
  addFunc(ve, run::gen_runpath34, primPair(), SYM(min), formal(pathArray()  , SYM(a), false, false));
#line 304 "runpath.in"
  addFunc(ve, run::gen_runpath35, primPair(), SYM(max), formal(pathArray()  , SYM(a), false, false));
#line 332 "runpath.in"
  addFunc(ve, run::gen_runpath36, primPair(), SYM(minAfterTransform), formal(primTransform(), SYM(t), false, false), formal(pathArray()  , SYM(a), false, false));
#line 360 "runpath.in"
  addFunc(ve, run::gen_runpath37, primPair(), SYM(maxAfterTransform), formal(primTransform(), SYM(t), false, false), formal(pathArray()  , SYM(a), false, false));
#line 388 "runpath.in"
  addFunc(ve, run::gen_runpath38, realArray(), SYM(mintimes), formal(primPath(), SYM(p), false, false));
#line 397 "runpath.in"
  addFunc(ve, run::gen_runpath39, realArray(), SYM(maxtimes), formal(primPath(), SYM(p), false, false));
#line 406 "runpath.in"
  addFunc(ve, run::gen_runpath40, primReal(), SYM(relativedistance), formal(primReal(), SYM(theta), false, false), formal(primReal(), SYM(phi), false, false), formal(primReal(), SYM(t), false, false), formal(primBoolean(), SYM(atleast), false, false));
#line 411 "runpath.in"
  addFunc(ve, run::gen_runpath41, primInt(), SYM(windingnumber), formal(pathArray()  , SYM(p), false, false), formal(primPair(), SYM(z), false, false));
#line 416 "runpath.in"
  addFunc(ve, run::gen_runpath42, primBoolean(), SYM(inside), formal(pathArray()  , SYM(g), false, true), formal(primPair(), SYM(z), false, false), formal(primPen(), SYM(fillrule), true, false));
#line 421 "runpath.in"
  addFunc(ve, run::gen_runpath43, primBoolean(), SYM(inside), formal(primPath(), SYM(g), false, false), formal(primPair(), SYM(z), false, false), formal(primPen(), SYM(fillrule), true, false));
#line 426 "runpath.in"
  addFunc(ve, run::gen_runpath44, primReal(), SYM(side), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false));
#line 433 "runpath.in"
  addFunc(ve, run::gen_runpath45, primReal(), SYM(incircle), formal(primPair(), SYM(a), false, false), formal(primPair(), SYM(b), false, false), formal(primPair(), SYM(c), false, false), formal(primPair(), SYM(d), false, false));
}

} // namespace trans