-
Notifications
You must be signed in to change notification settings - Fork 30
/
trte.c
11310 lines (9972 loc) · 382 KB
/
trte.c
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
/* trte.f -- translated by f2c (version 20100827).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
/*
Since Mefisto is using very little real fortran API calls only the definition
portion of the f2c header is used and the fortran write() calls are commented out:
//io___187.ciunit = unites_2.imprim;
//s_wsle(&io___187);
//do_lio(&c__9, &c__1, "pas de triangle d'abscisse minimale", (ftnlen)
// 35);
//e_wsle();
This calls print out error information and are not needed in FreeCAD....
JR 2014
*/
// start F2c.h content
typedef long int integer;
typedef unsigned long int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
typedef long int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
#ifdef INTEGER_STAR_8 /* Adjust for integer*8. */
typedef long long longint; /* system-dependent */
typedef unsigned long long ulongint; /* system-dependent */
#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
#define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
#endif
#define TRUE_ (1)
#define FALSE_ (0)
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
/* I/O stuff */
#ifdef f2c_i2
/* for -i2 */
typedef short flag;
typedef short ftnlen;
typedef short ftnint;
#else
typedef long int flag;
typedef long int ftnlen;
typedef long int ftnint;
#endif
/*external read, write*/
typedef struct
{ flag cierr;
ftnint ciunit;
flag ciend;
char *cifmt;
ftnint cirec;
} cilist;
/*internal read, write*/
typedef struct
{ flag icierr;
char *iciunit;
flag iciend;
char *icifmt;
ftnint icirlen;
ftnint icirnum;
} icilist;
/*open*/
typedef struct
{ flag oerr;
ftnint ounit;
char *ofnm;
ftnlen ofnmlen;
char *osta;
char *oacc;
char *ofm;
ftnint orl;
char *oblnk;
} olist;
/*close*/
typedef struct
{ flag cerr;
ftnint cunit;
char *csta;
} cllist;
/*rewind, backspace, endfile*/
typedef struct
{ flag aerr;
ftnint aunit;
} alist;
/* inquire */
typedef struct
{ flag inerr;
ftnint inunit;
char *infile;
ftnlen infilen;
ftnint *inex; /*parameters in standard's order*/
ftnint *inopen;
ftnint *innum;
ftnint *innamed;
char *inname;
ftnlen innamlen;
char *inacc;
ftnlen inacclen;
char *inseq;
ftnlen inseqlen;
char *indir;
ftnlen indirlen;
char *infmt;
ftnlen infmtlen;
char *inform;
ftnint informlen;
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
ftnint *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
#define VOID void
union Multitype { /* for multiple entry points */
integer1 g;
shortint h;
integer i;
/* longint j; */
real r;
doublereal d;
complex c;
doublecomplex z;
};
typedef union Multitype Multitype;
/*typedef long int Long;*/ /* No longer used; formerly in Namelist */
struct Vardesc { /* for Namelist */
char *name;
char *addr;
ftnlen *dims;
int type;
};
typedef struct Vardesc Vardesc;
struct Namelist {
char *name;
Vardesc **vars;
int nvars;
};
typedef struct Namelist Namelist;
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (doublereal)abs(x)
#define min(a,b) ((a) <= (b) ? (a) : (b))
#define max(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (doublereal)min(a,b)
#define dmax(a,b) (doublereal)max(a,b)
#define bit_test(a,b) ((a) >> (b) & 1)
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
/* procedure parameter types for -A and -C++ */
#define F2C_proc_par_types 1
#ifdef NIX
typedef int /* Unknown procedure type */ (*U_fp)(...);
typedef shortint (*J_fp)(...);
typedef integer (*I_fp)(...);
typedef real (*R_fp)(...);
typedef doublereal (*D_fp)(...), (*E_fp)(...);
typedef /* Complex */ VOID (*C_fp)(...);
typedef /* Double Complex */ VOID (*Z_fp)(...);
typedef logical (*L_fp)(...);
typedef shortlogical (*K_fp)(...);
typedef /* Character */ VOID (*H_fp)(...);
typedef /* Subroutine */ int (*S_fp)(...);
#else
typedef int /* Unknown procedure type */ (*U_fp)();
typedef shortint (*J_fp)();
typedef integer (*I_fp)();
typedef real (*R_fp)();
typedef doublereal (*D_fp)(), (*E_fp)();
typedef /* Complex */ VOID (*C_fp)();
typedef /* Double Complex */ VOID (*Z_fp)();
typedef logical (*L_fp)();
typedef shortlogical (*K_fp)();
typedef /* Character */ VOID (*H_fp)();
typedef /* Subroutine */ int (*S_fp)();
#endif
/* E_fp is for real functions when -R is not specified */
typedef VOID C_f; /* complex function */
typedef VOID H_f; /* character function */
typedef VOID Z_f; /* double complex function */
typedef doublereal E_f; /* real function with -R not specified */
/* undef any lower-case symbols that your C compiler predefines, e.g.: */
#ifndef Skip_f2c_Undefs
#undef cray
#undef gcos
#undef mc68010
#undef mc68020
#undef mips
#undef pdp11
#undef sgi
#undef sparc
#undef sun
#undef sun2
#undef sun3
#undef sun4
#undef u370
#undef u3b
#undef u3b2
#undef u3b5
#undef unix
#undef vax
#endif
// stop F2c.h content
union {
struct {
integer lecteu, imprim, nunite[30];
} _1;
struct {
integer lecteu, imprim, intera, nunite[29];
} _2;
} unites_;
#define unites_1 (unites_._1)
#define unites_2 (unites_._2)
/* Table of constant values */
static integer c__9 = 9;
static integer c__1 = 1;
static integer c__3 = 3;
static integer c__2 = 2;
static integer c__5 = 5;
static doublereal c_b357 = .1;
static integer c_n1 = -1;
static integer c__0 = 0;
static integer c__512 = 512;
static integer c__32 = 32;
/* MEFISTO2: a library to compute 2D triangulation from segmented boundaries */
/* Copyright (C) 2006 Laboratoire J.-L. Lions UPMC Paris */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation; either */
/* version 2.1 of the License. */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Lesser General Public License for more details. */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* See http://www.ann.jussieu.fr/~perronnet or email perronnet@ann.jussieu.fr */
/* File : trte.f le Fortran du trianguleur plan */
/* Module : SMESH */
/* Author : Alain PERRONNET */
/* Date : 13 novembre 2006 */
doublereal diptdr_(doublereal *pt, doublereal *p1dr, doublereal *p2dr)
{
/* System generated locals */
doublereal ret_val, d__1;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static doublereal a, b, c__;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++012 */
/* but : calculer la distance entre un point et une droite */
/* ----- definie par 2 points p1dr et p2dr */
/* entrees : */
/* --------- */
/* pt : le point de R ** 2 */
/* p1dr p2dr : les 2 points de R ** 2 de la droite */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++012 */
/* programmeur : alain perronnet analyse numrique paris janvier 1986 */
/* ....................................................................012 */
/* les coefficients de la droite a x + by + c =0 */
/* Parameter adjustments */
--p2dr;
--p1dr;
--pt;
/* Function Body */
a = p2dr[2] - p1dr[2];
b = p1dr[1] - p2dr[1];
c__ = -a * p1dr[1] - b * p1dr[2];
/* la distance = | a * x + b * y + c | / sqrt( a*a + b*b ) */
ret_val = (d__1 = a * pt[1] + b * pt[2] + c__, abs(d__1)) / sqrt(a * a +
b * b);
return ret_val;
} /* diptdr_ */
/* Subroutine */ int qutr2d_(doublereal *p1, doublereal *p2, doublereal *p3,
doublereal *qualite)
{
/* System generated locals */
doublereal d__1, d__2;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static doublereal a, b, c__, p;
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : calculer la qualite d'un triangle de r**2 */
/* ----- 2 coordonnees des 3 sommets en double precision */
/* entrees : */
/* --------- */
/* p1,p2,p3 : les 3 coordonnees des 3 sommets du triangle */
/* sens direct pour une surface et qualite >0 */
/* sorties : */
/* --------- */
/* qualite: valeur de la qualite du triangle entre 0 et 1 (equilateral) */
/* 1 etant la qualite optimale */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique upmc paris janvier 1995 */
/* 2345x7..............................................................012 */
/* d2uxr3 = 2 * sqrt(3) */
/* la longueur des 3 cotes */
/* Parameter adjustments */
--p3;
--p2;
--p1;
/* Function Body */
/* Computing 2nd power */
d__1 = p2[1] - p1[1];
/* Computing 2nd power */
d__2 = p2[2] - p1[2];
a = sqrt(d__1 * d__1 + d__2 * d__2);
/* Computing 2nd power */
d__1 = p3[1] - p2[1];
/* Computing 2nd power */
d__2 = p3[2] - p2[2];
b = sqrt(d__1 * d__1 + d__2 * d__2);
/* Computing 2nd power */
d__1 = p1[1] - p3[1];
/* Computing 2nd power */
d__2 = p1[2] - p3[2];
c__ = sqrt(d__1 * d__1 + d__2 * d__2);
/* demi perimetre */
p = (a + b + c__) * .5;
if (a * b * c__ != 0.) {
/* critere : 2 racine(3) * rayon_inscrit / plus longue arete */
/* Computing MAX */
d__2 = max(a,b);
*qualite = sqrt((d__1 = (p - a) / p * (p - b) * (p - c__), abs(d__1)))
* 3.4641016151377544f / max(d__2,c__);
} else {
*qualite = 0.;
}
/* autres criteres possibles: */
/* critere : 2 * rayon_inscrit / rayon_circonscrit */
/* qualite = 8d0 * (p-a) * (p-b) * (p-c) / (a * b * c) */
/* critere : 3*sqrt(3.) * ray_inscrit / demi perimetre */
/* qualite = 3*sqrt(3.) * sqrt ((p-a)*(p-b)*(p-c) / p**3) */
/* critere : 2*sqrt(3.) * ray_inscrit / max( des aretes ) */
/* qualite = 2*sqrt(3.) * sqrt( (p-a)*(p-b)*(p-c) / p ) / max(a,b,c) */
return 0;
} /* qutr2d_ */
doublereal surtd2_(doublereal *p1, doublereal *p2, doublereal *p3)
{
/* System generated locals */
doublereal ret_val;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : calcul de la surface d'un triangle defini par 3 points de R**2 */
/* ----- */
/* parametres d entree : */
/* --------------------- */
/* p1 p2 p3 : les 3 fois 2 coordonnees des sommets du triangle */
/* parametre resultat : */
/* -------------------- */
/* surtd2 : surface du triangle */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique upmc paris fevrier 1992 */
/* 2345x7..............................................................012 */
/* la surface du triangle */
/* Parameter adjustments */
--p3;
--p2;
--p1;
/* Function Body */
ret_val = ((p2[1] - p1[1]) * (p3[2] - p1[2]) - (p2[2] - p1[2]) * (p3[1] -
p1[1])) * .5;
return ret_val;
} /* surtd2_ */
integer nopre3_(integer *i__)
{
/* System generated locals */
integer ret_val;
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : numero precedent i dans le sens circulaire 1 2 3 1 ... */
/* ----- */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique paris upmc fevrier 1992 */
/* 2345x7..............................................................012 */
if (*i__ == 1) {
ret_val = 3;
} else {
ret_val = *i__ - 1;
}
return ret_val;
} /* nopre3_ */
integer nosui3_(integer *i__)
{
/* System generated locals */
integer ret_val;
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : numero suivant i dans le sens circulaire 1 2 3 1 ... */
/* ----- */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique paris upmc fevrier 1992 */
/* 2345x7..............................................................012 */
if (*i__ == 3) {
ret_val = 1;
} else {
ret_val = *i__ + 1;
}
return ret_val;
} /* nosui3_ */
/* Subroutine */ int provec_(doublereal *v1, doublereal *v2, doublereal *v3)
{
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : v3 vecteur = produit vectoriel de 2 vecteurs de r ** 3 */
/* ----- */
/* entrees: */
/* -------- */
/* v1, v2 : les 2 vecteurs de 3 composantes */
/* sortie : */
/* -------- */
/* v3 : vecteur = v1 produit vectoriel v2 */
/* c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : perronnet alain upmc analyse numerique paris mars 1987 */
/* 2345x7..............................................................012 */
/* Parameter adjustments */
--v3;
--v2;
--v1;
/* Function Body */
v3[1] = v1[2] * v2[3] - v1[3] * v2[2];
v3[2] = v1[3] * v2[1] - v1[1] * v2[3];
v3[3] = v1[1] * v2[2] - v1[2] * v2[1];
return 0;
} /* provec_ */
/* Subroutine */ int norme1_(integer *n, doublereal *v, integer *ierr)
{
/* System generated locals */
integer i__1;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static integer i__;
static doublereal s;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : normalisation euclidienne a 1 d un vecteur v de n composantes */
/* ----- */
/* entrees : */
/* --------- */
/* n : nombre de composantes du vecteur */
/* modifie : */
/* --------- */
/* v : le vecteur a normaliser a 1 */
/* sortie : */
/* --------- */
/* ierr : 1 si la norme de v est egale a 0 */
/* 0 si pas d'erreur */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique paris mars 1987 */
/* ...................................................................... */
/* Parameter adjustments */
--v;
/* Function Body */
s = 0.;
i__1 = *n;
for (i__ = 1; i__ <= i__1; ++i__) {
s += v[i__] * v[i__];
/* L10: */
}
/* test de nullite de la norme du vecteur */
/* -------------------------------------- */
if (s <= 0.) {
/* norme nulle du vecteur non normalisable a 1 */
*ierr = 1;
return 0;
}
s = 1. / sqrt(s);
i__1 = *n;
for (i__ = 1; i__ <= i__1; ++i__) {
v[i__] *= s;
/* L20: */
}
*ierr = 0;
return 0;
} /* norme1_ */
/* Subroutine */ int insoar_(integer *mxsomm, integer *mosoar, integer *
mxsoar, integer *n1soar, integer *nosoar)
{
/* System generated locals */
integer nosoar_dim1, nosoar_offset, i__1;
/* Local variables */
static integer i__;
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : initialiser le tableau nosoar pour le hachage des aretes */
/* ----- */
/* entrees: */
/* -------- */
/* mxsomm : plus grand numero de sommet d'une arete au cours du calcul */
/* mosoar : nombre maximal d'entiers par arete du tableau nosoar */
/* mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar */
/* avec mxsoar>=3*mxsomm */
/* sorties: */
/* -------- */
/* n1soar : numero de la premiere arete vide dans le tableau nosoar */
/* une arete i de nosoar est vide <=> nosoar(1,i)=0 */
/* chainage des aretes vides amont et aval */
/* l'arete vide qui precede=nosoar(4,i) */
/* l'arete vide qui suit =nosoar(5,i) */
/* nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, */
/* chainage momentan'e d'aretes, chainage du hachage des aretes */
/* hachage des aretes = min( nosoar(1), nosoar(2) ) */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique paris upmc mars 1997 */
/* 2345x7..............................................................012 */
/* initialisation des aretes 1 a mxsomm */
/* Parameter adjustments */
nosoar_dim1 = *mosoar;
nosoar_offset = 1 + nosoar_dim1;
nosoar -= nosoar_offset;
/* Function Body */
i__1 = *mxsomm;
for (i__ = 1; i__ <= i__1; ++i__) {
/* sommet 1 = 0 <=> temoin d'arete vide pour le hachage */
nosoar[i__ * nosoar_dim1 + 1] = 0;
/* arete sur aucune ligne */
nosoar[i__ * nosoar_dim1 + 3] = 0;
/* la position de l'arete interne ou frontaliere est inconnue */
nosoar[i__ * nosoar_dim1 + 6] = -2;
/* fin de chainage du hachage pas d'arete suivante */
nosoar[*mosoar + i__ * nosoar_dim1] = 0;
/* L10: */
}
/* la premiere arete vide chainee est la mxsomm+1 du tableau */
/* car ces aretes ne sont pas atteignables par le hachage direct */
*n1soar = *mxsomm + 1;
/* initialisation des aretes vides et des chainages */
i__1 = *mxsoar;
for (i__ = *n1soar; i__ <= i__1; ++i__) {
/* sommet 1 = 0 <=> temoin d'arete vide pour le hachage */
nosoar[i__ * nosoar_dim1 + 1] = 0;
/* arete sur aucune ligne */
nosoar[i__ * nosoar_dim1 + 3] = 0;
/* chainage sur l'arete vide qui precede */
/* (si arete occupee cela deviendra le no du triangle 1 de l'arete) */
nosoar[i__ * nosoar_dim1 + 4] = i__ - 1;
/* chainage sur l'arete vide qui suit */
/* (si arete occupee cela deviendra le no du triangle 2 de l'arete) */
nosoar[i__ * nosoar_dim1 + 5] = i__ + 1;
/* chainages des aretes frontalieres ou internes ou ... */
nosoar[i__ * nosoar_dim1 + 6] = -2;
/* fin de chainage du hachage */
nosoar[*mosoar + i__ * nosoar_dim1] = 0;
/* L20: */
}
/* la premiere arete vide n'a pas de precedent */
nosoar[*n1soar * nosoar_dim1 + 4] = 0;
/* la derniere arete vide est mxsoar sans arete vide suivante */
nosoar[*mxsoar * nosoar_dim1 + 5] = 0;
return 0;
} /* insoar_ */
/* Subroutine */ int azeroi_(integer *l, integer *ntab)
{
/* System generated locals */
integer i__1;
/* Local variables */
static integer i__;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : initialisation a zero d un tableau ntab de l variables entieres */
/* ----- */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique upmc paris septembre 1988 */
/* 23456---------------------------------------------------------------012 */
/* Parameter adjustments */
--ntab;
/* Function Body */
i__1 = *l;
for (i__ = 1; i__ <= i__1; ++i__) {
ntab[i__] = 0;
/* L1: */
}
return 0;
} /* azeroi_ */
/* Subroutine */ int fasoar_(integer *ns1, integer *ns2, integer *nt1,
integer *nt2, integer *nolign, integer *mosoar, integer *mxsoar,
integer *n1soar, integer *nosoar, integer *noarst, integer *noar,
integer *ierr)
{
/* System generated locals */
integer nosoar_dim1, nosoar_offset;
/* Builtin functions */
//integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
// e_wsle(void);
/* Local variables */
static integer i__, n, nu2sar[2];
extern /* Subroutine */ int hasoar_(integer *, integer *, integer *,
integer *, integer *, integer *);
/* Fortran I/O blocks */
static cilist io___13 = { 0, 0, 0, 0, 0 };
static cilist io___14 = { 0, 0, 0, 0, 0 };
static cilist io___15 = { 0, 0, 0, 0, 0 };
static cilist io___18 = { 0, 0, 0, 0, 0 };
static cilist io___19 = { 0, 0, 0, 0, 0 };
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : former l'arete de sommet ns1-ns2 dans le hachage du tableau */
/* ----- nosoar des aretes de la triangulation */
/* entrees: */
/* -------- */
/* ns1 ns2: numero pxyd des 2 sommets de l'arete */
/* nt1 : numero du triangle auquel appartient l'arete */
/* nt1=-1 si numero inconnu */
/* nt2 : numero de l'eventuel second triangle de l'arete si connu */
/* nt2=-1 si numero inconnu */
/* nolign : numero de la ligne de l'arete dans ladefi(wulftr-1+nolign) */
/* =0 si l'arete n'est une arete de ligne */
/* ce numero est ajoute seulement si l'arete est creee */
/* mosoar : nombre maximal d'entiers par arete du tableau nosoar */
/* mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar */
/* modifies: */
/* --------- */
/* n1soar : numero de la premiere arete vide dans le tableau nosoar */
/* une arete i de nosoar est vide <=> nosoar(1,i)=0 */
/* chainage des aretes vides amont et aval */
/* l'arete vide qui precede=nosoar(4,i) */
/* l'arete vide qui suit =nosoar(5,i) */
/* nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, */
/* chainage momentan'e d'aretes, chainage du hachage des aretes */
/* hachage des aretes = min( nosoar(1), nosoar(2) ) */
/* noarst : noarst(np) numero d'une arete du sommet np */
/* ierr : si < 0 en entree pas d'affichage en cas d'erreur du type */
/* "arete appartenant a plus de 2 triangles et a creer!" */
/* si >=0 en entree affichage de ce type d'erreur */
/* sorties: */
/* -------- */
/* noar : >0 numero de l'arete retrouvee ou ajoutee */
/* ierr : =0 si pas d'erreur */
/* =1 si le tableau nosoar est sature */
/* =2 si arete a creer et appartenant a 2 triangles distincts */
/* des triangles nt1 et nt2 */
/* =3 si arete appartenant a 2 triangles distincts */
/* differents des triangles nt1 et nt2 */
/* =4 si arete appartenant a 2 triangles distincts */
/* dont le second n'est pas le triangle nt2 */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteur : alain perronnet analyse numerique paris upmc mars 1997 */
/* 2345x7..............................................................012 */
/* Parameter adjustments */
nosoar_dim1 = *mosoar;
nosoar_offset = 1 + nosoar_dim1;
nosoar -= nosoar_offset;
--noarst;
/* Function Body */
*ierr = 0;
/* ajout eventuel de l'arete s1 s2 dans nosoar */
nu2sar[0] = *ns1;
nu2sar[1] = *ns2;
/* hachage de l'arete de sommets nu2sar */
hasoar_(mosoar, mxsoar, n1soar, &nosoar[nosoar_offset], nu2sar, noar);
/* en sortie: noar>0 => no arete retrouvee */
/* <0 => no arete ajoutee */
/* =0 => saturation du tableau nosoar */
if (*noar == 0) {
/* saturation du tableau nosoar */
//io___13.ciunit = unites_1.imprim;
//s_wsle(&io___13);
//do_lio(&c__9, &c__1, "fasoar: tableau nosoar sature", (ftnlen)29);
//e_wsle();
*ierr = 1;
return 0;
} else if (*noar < 0) {
/* l'arete a ete ajoutee. initialisation des autres informations */
*noar = -(*noar);
/* le numero de la ligne de l'arete */
nosoar[*noar * nosoar_dim1 + 3] = *nolign;
/* le triangle 1 de l'arete => le triangle nt1 */
nosoar[*noar * nosoar_dim1 + 4] = *nt1;
/* le triangle 2 de l'arete => le triangle nt2 */
nosoar[*noar * nosoar_dim1 + 5] = *nt2;
/* le chainage est mis a -1 */
nosoar[*noar * nosoar_dim1 + 6] = -1;
/* le sommet appartient a l'arete noar */
noarst[nu2sar[0]] = *noar;
noarst[nu2sar[1]] = *noar;
} else {
/* l'arete a ete retrouvee. */
/* si elle appartient a 2 triangles differents de nt1 et nt2 */
/* alors il y a une erreur */
if (nosoar[*noar * nosoar_dim1 + 4] > 0 && nosoar[*noar * nosoar_dim1
+ 5] > 0) {
if ((nosoar[*noar * nosoar_dim1 + 4] != *nt1 && nosoar[*noar *
nosoar_dim1 + 4] != *nt2) || (nosoar[*noar * nosoar_dim1 +
5] != *nt1 && nosoar[*noar * nosoar_dim1 + 5] != *nt2)) {
/* arete appartenant a plus de 2 triangles => erreur */
if (*ierr >= 0) {
// io___14.ciunit = unites_1.imprim;
// s_wsle(&io___14);
// do_lio(&c__9, &c__1, "erreur fasoar: arete ", (ftnlen)21);
// do_lio(&c__3, &c__1, (char *)&(*noar), (ftnlen)sizeof(
// integer));
// do_lio(&c__9, &c__1, " dans 2 triangles", (ftnlen)17);
// do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1
// + 4], (ftnlen)sizeof(integer));
// do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1
// + 5], (ftnlen)sizeof(integer));
// do_lio(&c__9, &c__1, " et ajouter", (ftnlen)11);
// do_lio(&c__3, &c__1, (char *)&(*nt1), (ftnlen)sizeof(
// integer));
// do_lio(&c__3, &c__1, (char *)&(*nt2), (ftnlen)sizeof(
// integer));
// e_wsle();
// io___15.ciunit = unites_1.imprim;
// s_wsle(&io___15);
// do_lio(&c__9, &c__1, "arete", (ftnlen)5);
// do_lio(&c__3, &c__1, (char *)&(*noar), (ftnlen)sizeof(
// integer));
// i__1 = *mosoar;
// for (i__ = 1; i__ <= i__1; ++i__) {
//do_lio(&c__3, &c__1, (char *)&nosoar[i__ + *noar *
// nosoar_dim1], (ftnlen)sizeof(integer));
// }
// e_wsle();
}
/* ERREUR. CORRECTION POUR VOIR ... */
nosoar[*noar * nosoar_dim1 + 4] = *nt1;
nosoar[*noar * nosoar_dim1 + 5] = *nt2;
/* cc ierr = 2 */
/* cc return */
}
}
/* mise a jour du numero des triangles de l'arete noar */
/* le triangle 2 de l'arete => le triangle nt1 */
if (nosoar[*noar * nosoar_dim1 + 4] <= 0) {
/* pas de triangle connu pour cette arete */
n = 4;
} else {
/* deja un triangle connu. ce nouveau est le second */
if (nosoar[*noar * nosoar_dim1 + 5] > 0 && *nt1 > 0 && nosoar[*
noar * nosoar_dim1 + 5] != *nt1) {
/* arete appartenant a plus de 2 triangles => erreur */
//io___18.ciunit = unites_1.imprim;
//s_wsle(&io___18);
//do_lio(&c__9, &c__1, "erreur fasoar: arete ", (ftnlen)21);
//do_lio(&c__3, &c__1, (char *)&(*noar), (ftnlen)sizeof(integer)
// );
//do_lio(&c__9, &c__1, " dans triangles", (ftnlen)15);
//do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1 + 4],
// (ftnlen)sizeof(integer));
//do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1 + 5],
// (ftnlen)sizeof(integer));
//do_lio(&c__9, &c__1, " et ajouter triangle", (ftnlen)20);
//do_lio(&c__3, &c__1, (char *)&(*nt1), (ftnlen)sizeof(integer))
// ;
//e_wsle();
*ierr = 3;
return 0;
}
n = 5;
}
nosoar[n + *noar * nosoar_dim1] = *nt1;
/* cas de l'arete frontaliere retrouvee comme diagonale d'un quadrangle */
if (*nt2 > 0) {
/* l'arete appartient a 2 triangles */
if (nosoar[*noar * nosoar_dim1 + 5] > 0 && nosoar[*noar *
nosoar_dim1 + 5] != *nt2) {
/* arete appartenant a plus de 2 triangles => erreur */
//io___19.ciunit = unites_1.imprim;
//s_wsle(&io___19);
//do_lio(&c__9, &c__1, "erreur fasoar: arete ", (ftnlen)21);
//do_lio(&c__3, &c__1, (char *)&(*noar), (ftnlen)sizeof(integer)
// );
//do_lio(&c__9, &c__1, " de st", (ftnlen)6);
//do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1 + 1],
// (ftnlen)sizeof(integer));
//do_lio(&c__9, &c__1, "-", (ftnlen)1);
//do_lio(&c__3, &c__1, (char *)&nosoar[*noar * nosoar_dim1 + 2],
// (ftnlen)sizeof(integer));
//do_lio(&c__9, &c__1, " dans plus de 2 triangles", (ftnlen)25);
//e_wsle();
*ierr = 4;
return 0;
}
nosoar[*noar * nosoar_dim1 + 5] = *nt2;
}
}
/* pas d'erreur */
*ierr = 0;
return 0;
} /* fasoar_ */
/* Subroutine */ int fq1inv_(real *x, real *y, real *s, real *xc, real *yc,
integer *ierr)
{
/* System generated locals */
real r__1, r__2;
/* Builtin functions */
double sqrt(doublereal);
/* Local variables */
static doublereal a, b, c__, d__;
static integer i__;
static doublereal t[2], u, v, w, x0, y0, beta;
static real dist[2];
static doublereal gamma, alpha, delta;
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* but : calcul des 2 coordonnees (xc,yc) dans le carre (0,1) */
/* ----- image par f:carre unite-->quadrangle appartenant a q1**2 */
/* par une resolution directe due a Nicolas Thenault */
/* entrees: */
/* -------- */
/* x,y : coordonnees du point image dans le quadrangle de sommets s */
/* s : les 2 coordonnees des 4 sommets du quadrangle */
/* sorties: */
/* -------- */
/* xc,yc : coordonnees dans le carre dont l'image par f vaut (x,y) */
/* ierr : 0 si calcul sans erreur, 1 si quadrangle degenere */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* auteurs: thenault tulenew analyse numerique paris janvier 1998 */
/* modifs : perronnet alain analyse numerique paris janvier 1998 */
/* 234567..............................................................012 */
/* Parameter adjustments */
s -= 3;
/* Function Body */
a = s[3];
b = s[5] - s[3];
c__ = s[9] - s[3];
d__ = s[3] - s[5] + s[7] - s[9];
alpha = s[4];
beta = s[6] - s[4];
gamma = s[10] - s[4];
delta = s[4] - s[6] + s[8] - s[10];
u = beta * c__ - b * gamma;
if (u == 0.) {
/* quadrangle degenere */
*ierr = 1;
return 0;
}
v = delta * c__ - d__ * gamma;
w = b * delta - beta * d__;
x0 = c__ * (*y - alpha) - gamma * (*x - a);
y0 = b * (*y - alpha) - beta * (*x - a);
a = v * w;
b = u * u - w * x0 - v * y0;
c__ = x0 * y0;
if (a != 0.) {
delta = sqrt(b * b - a * 4 * c__);
if (b >= 0.f) {
t[1] = -b - delta;
} else {
t[1] = -b + delta;
}
/* la racine de plus grande valeur absolue */