-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibstla_io.f90
2396 lines (2037 loc) · 57.5 KB
/
libstla_io.f90
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
MODULE stla_io
implicit none
CONTAINS
subroutine ch_cap ( c )
!*****************************************************************************80
!
!! CH_CAP capitalizes a single character.
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 19 July 1998
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input/output, character C, the character to capitalize.
!
implicit none
character c
integer ( kind = 4 ) itemp
itemp = ichar ( c )
if ( 97 <= itemp .and. itemp <= 122 ) then
c = char ( itemp - 32 )
end if
return
end subroutine ch_cap
function ch_eqi( c1, c2 )
!*****************************************************************************80
!
!! CH_EQI is a case insensitive comparison of two characters for equality.
!
! Example:
!
! CH_EQI ( 'A', 'a' ) is TRUE.
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 28 July 2000
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, character C1, C2, the characters to compare.
!
! Output, logical CH_EQI, the result of the comparison.
!
implicit none
character c1
character c1_cap
character c2
character c2_cap
logical ch_eqi
c1_cap = c1
c2_cap = c2
call ch_cap ( c1_cap )
call ch_cap ( c2_cap )
if ( c1_cap == c2_cap ) then
ch_eqi = .true.
else
ch_eqi = .false.
end if
return
end function ch_eqi
subroutine ch_to_digit ( c, digit )
!*****************************************************************************80
!
!! CH_TO_DIGIT returns the integer value of a base 10 digit.
!
! Example:
!
! C DIGIT
! --- -----
! '0' 0
! '1' 1
! ... ...
! '9' 9
! ' ' 0
! 'X' -1
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 04 August 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, character C, the decimal digit, '0' through '9' or blank
! are legal.
!
! Output, integer ( kind = 4 ) DIGIT, the corresponding integer value.
! If C was 'illegal', then DIGIT is -1.
!
implicit none
character c
integer ( kind = 4 ) digit
if ( lle ( '0', c ) .and. lle ( c, '9' ) ) then
digit = ichar ( c ) - 48
else if ( c == ' ' ) then
digit = 0
else
digit = -1
end if
return
end subroutine ch_to_digit
subroutine get_unit ( iunit )
!*****************************************************************************80
!
!! GET_UNIT returns a free FORTRAN unit number.
!
! Discussion:
!
! A "free" FORTRAN unit number is an integer between 1 and 99 which
! is not currently associated with an I/O device. A free FORTRAN unit
! number is needed in order to open a file with the OPEN command.
!
! If IUNIT = 0, then no free FORTRAN unit could be found, although
! all 99 units were checked (except for units 5, 6 and 9, which
! are commonly reserved for console I/O).
!
! Otherwise, IUNIT is an integer between 1 and 99, representing a
! free FORTRAN unit. Note that GET_UNIT assumes that units 5 and 6
! are special, and will never return those values.
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 18 September 2005
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Output, integer ( kind = 4 ) IUNIT, the free unit number.
!
implicit none
integer ( kind = 4 ) i
integer ( kind = 4 ) ios
integer ( kind = 4 ) iunit
logical lopen
iunit = 0
do i = 1, 99
if ( i /= 5 .and. i /= 6 .and. i /= 9 ) then
inquire ( unit = i, opened = lopen, iostat = ios )
if ( ios == 0 ) then
if ( .not. lopen ) then
iunit = i
return
end if
end if
end if
end do
return
end subroutine get_unit
subroutine r8vec_cross_3d ( v1, v2, v3 )
!*****************************************************************************80
!
!! R8VEC_CROSS_3D computes the cross product of two vectors in 3D.
!
! Discussion:
!
! The cross product in 3D can be regarded as the determinant of the
! symbolic matrix:
!
! | i j k |
! det | x1 y1 z1 |
! | x2 y2 z2 |
!
! = ( y1 * z2 - z1 * y2 ) * i
! + ( z1 * x2 - x1 * z2 ) * j
! + ( x1 * y2 - y1 * x2 ) * k
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 07 August 2005
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, real ( kind = 8 ) V1(3), V2(3), the two vectors.
!
! Output, real ( kind = 8 ) V3(3), the cross product vector.
!
implicit none
integer ( kind = 4 ), parameter :: dim_num = 3
real ( kind = 8 ) v1(dim_num)
real ( kind = 8 ) v2(dim_num)
real ( kind = 8 ) v3(dim_num)
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
end subroutine r8vec_cross_3d
subroutine s_cat ( s1, s2, s3 )
!*****************************************************************************80
!
!! S_CAT concatenates two strings to make a third string.
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 18 September 2000
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, character ( len = * ) S1, the "prefix" string.
!
! Input, character ( len = * ) S2, the "postfix" string.
!
! Output, character ( len = * ) S3, the string made by
! concatenating S1 and S2, ignoring any trailing blanks.
!
implicit none
character ( len = * ) s1
character ( len = * ) s2
character ( len = * ) s3
if ( s1 == ' ' .and. s2 == ' ' ) then
s3 = ' '
else if ( s1 == ' ' ) then
s3 = s2
else if ( s2 == ' ' ) then
s3 = s1
else
s3 = trim ( s1 ) // trim ( s2 )
end if
return
end subroutine s_cat
function s_eqi( s1, s2 )
!*****************************************************************************80
!
!! S_EQI is a case insensitive comparison of two strings for equality.
!
! Example:
!
! S_EQI ( 'Anjana', 'ANJANA' ) is TRUE.
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 14 April 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, character ( len = * ) S1, S2, the strings to compare.
!
! Output, logical S_EQI, the result of the comparison.
!
implicit none
character c1
character c2
integer ( kind = 4 ) i
integer ( kind = 4 ) len1
integer ( kind = 4 ) len2
integer ( kind = 4 ) lenc
character ( len = * ) s1
character ( len = * ) s2
logical s_eqi
len1 = len ( s1 )
len2 = len ( s2 )
lenc = min ( len1, len2 )
s_eqi = .false.
do i = 1, lenc
c1 = s1(i:i)
c2 = s2(i:i)
call ch_cap ( c1 )
call ch_cap ( c2 )
if ( c1 /= c2 ) then
return
end if
end do
do i = lenc + 1, len1
if ( s1(i:i) /= ' ' ) then
return
end if
end do
do i = lenc + 1, len2
if ( s2(i:i) /= ' ' ) then
return
end if
end do
s_eqi = .true.
return
end function s_eqi
subroutine s_to_r8 ( s, dval, ierror, length )
!*****************************************************************************80
!
!! S_TO_R8 reads an R8 from a string.
!
! Discussion:
!
! The routine will read as many characters as possible until it reaches
! the end of the string, or encounters a character which cannot be
! part of the number.
!
! Legal input is:
!
! 1 blanks,
! 2 '+' or '-' sign,
! 2.5 blanks
! 3 integer part,
! 4 decimal point,
! 5 fraction part,
! 6 'E' or 'e' or 'D' or 'd', exponent marker,
! 7 exponent sign,
! 8 exponent integer part,
! 9 exponent decimal point,
! 10 exponent fraction part,
! 11 blanks,
! 12 final comma or semicolon,
!
! with most quantities optional.
!
! Example:
!
! S DVAL
!
! '1' 1.0
! ' 1 ' 1.0
! '1A' 1.0
! '12,34,56' 12.0
! ' 34 7' 34.0
! '-1E2ABCD' -100.0
! '-1X2ABCD' -1.0
! ' 2E-1' 0.2
! '23.45' 23.45
! '-4.2E+2' -420.0
! '17d2' 1700.0
! '-14e-2' -0.14
! 'e2' 100.0
! '-12.73e-9.23' -12.73 * 10.0**(-9.23)
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 07 September 2004
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, character ( len = * ) S, the string containing the
! data to be read. Reading will begin at position 1 and
! terminate at the end of the string, or when no more
! characters can be read to form a legal real. Blanks,
! commas, or other nonnumeric data will, in particular,
! cause the conversion to halt.
!
! Output, real ( kind = 8 ) DVAL, the value read from the string.
!
! Output, integer ( kind = 4 ) IERROR, error flag.
! 0, no errors occurred.
! 1, 2, 6 or 7, the input number was garbled. The
! value of IERROR is the last type of input successfully
! read. For instance, 1 means initial blanks, 2 means
! a plus or minus sign, and so on.
!
! Output, integer ( kind = 4 ) LENGTH, the number of characters read
! to form the number, including any terminating
! characters such as a trailing comma or blanks.
!
implicit none
character c
real ( kind = 8 ) dval
integer ( kind = 4 ) ierror
integer ( kind = 4 ) ihave
integer ( kind = 4 ) isgn
integer ( kind = 4 ) iterm
integer ( kind = 4 ) jbot
integer ( kind = 4 ) jsgn
integer ( kind = 4 ) jtop
integer ( kind = 4 ) length
integer ( kind = 4 ) nchar
integer ( kind = 4 ) ndig
real ( kind = 8 ) rbot
real ( kind = 8 ) rexp
real ( kind = 8 ) rtop
character ( len = * ) s
nchar = len_trim ( s )
ierror = 0
dval = 0.0D+00
length = -1
isgn = 1
rtop = 0
rbot = 1
jsgn = 1
jtop = 0
jbot = 1
ihave = 1
iterm = 0
do
length = length + 1
if ( nchar < length+1 ) then
exit
end if
c = s(length+1:length+1)
!
! Blank character.
!
if ( c == ' ' ) then
if ( ihave == 2 ) then
else if ( ihave == 6 .or. ihave == 7 ) then
iterm = 1
else if ( 1 < ihave ) then
ihave = 11
end if
!
! Comma.
!
else if ( c == ',' .or. c == ';' ) then
if ( ihave /= 1 ) then
iterm = 1
ihave = 12
length = length + 1
end if
!
! Minus sign.
!
else if ( c == '-' ) then
if ( ihave == 1 ) then
ihave = 2
isgn = -1
else if ( ihave == 6 ) then
ihave = 7
jsgn = -1
else
iterm = 1
end if
!
! Plus sign.
!
else if ( c == '+' ) then
if ( ihave == 1 ) then
ihave = 2
else if ( ihave == 6 ) then
ihave = 7
else
iterm = 1
end if
!
! Decimal point.
!
else if ( c == '.' ) then
if ( ihave < 4 ) then
ihave = 4
else if ( 6 <= ihave .and. ihave <= 8 ) then
ihave = 9
else
iterm = 1
end if
!
! Scientific notation exponent marker.
!
else if ( ch_eqi ( c, 'E' ) .or. ch_eqi ( c, 'D' ) ) then
if ( ihave < 6 ) then
ihave = 6
else
iterm = 1
end if
!
! Digit.
!
else if ( ihave < 11 .and. lle ( '0', c ) .and. lle ( c, '9' ) ) then
if ( ihave <= 2 ) then
ihave = 3
else if ( ihave == 4 ) then
ihave = 5
else if ( ihave == 6 .or. ihave == 7 ) then
ihave = 8
else if ( ihave == 9 ) then
ihave = 10
end if
call ch_to_digit ( c, ndig )
if ( ihave == 3 ) then
rtop = 10.0D+00 * rtop + real ( ndig, kind = 8 )
else if ( ihave == 5 ) then
rtop = 10.0D+00 * rtop + real ( ndig, kind = 8 )
rbot = 10.0D+00 * rbot
else if ( ihave == 8 ) then
jtop = 10 * jtop + ndig
else if ( ihave == 10 ) then
jtop = 10 * jtop + ndig
jbot = 10 * jbot
end if
!
! Anything else is regarded as a terminator.
!
else
iterm = 1
end if
!
! If we haven't seen a terminator, and we haven't examined the
! entire string, go get the next character.
!
if ( iterm == 1 ) then
exit
end if
end do
!
! If we haven't seen a terminator, and we have examined the
! entire string, then we're done, and LENGTH is equal to NCHAR.
!
if ( iterm /= 1 .and. length+1 == nchar ) then
length = nchar
end if
!
! Number seems to have terminated. Have we got a legal number?
! Not if we terminated in states 1, 2, 6 or 7!
!
if ( ihave == 1 .or. ihave == 2 .or. ihave == 6 .or. ihave == 7 ) then
ierror = ihave
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'S_TO_R8 - Serious error!'
write ( *, '(a)' ) ' Illegal or nonnumeric input:'
write ( *, '(a)' ) ' ' // trim ( s )
return
end if
!
! Number seems OK. Form it.
!
if ( jtop == 0 ) then
rexp = 1.0D+00
else
if ( jbot == 1 ) then
rexp = 10.0D+00 ** ( jsgn * jtop )
else
rexp = 10.0D+00 ** ( real ( jsgn * jtop, kind = 8 ) &
/ real ( jbot, kind = 8 ) )
end if
end if
dval = real ( isgn, kind = 8 ) * rexp * rtop / rbot
return
end subroutine s_to_r8
function stla_check ( input_file_name )
!*****************************************************************************80
!
!! STLA_CHECK checks an ASCII StereoLithography file.
!
! Example:
!
! solid MYSOLID
! facet normal 0.4 0.4 0.2
! outerloop
! vertex 1.0 2.1 3.2
! vertex 2.1 3.7 4.5
! vertex 3.1 4.5 6.7
! end loop
! end facet
! ...
! facet normal 0.2 0.2 0.4
! outerloop
! vertex 2.0 2.3 3.4
! vertex 3.1 3.2 6.5
! vertex 4.1 5.5 9.0
! end loop
! end facet
! end solid MYSOLID
!
! Licensing:
!
! This code is distributed under the MIT license.
!
! Modified:
!
! 18 September 2005
!
! Author:
!
! John Burkardt
!
! Reference:
!
! 3D Systems, Inc,
! Stereolithography Interface Specification,
! October 1989.
!
! Parameters:
!
! Input, character ( len = * ) INPUT_FILE_NAME, the name of the input file.
!
! Output, logical STLA_CHECK, is TRUE if the file is legal.
!
implicit none
logical done
real ( kind = 8 ) dval
integer ( kind = 4 ) i
integer ( kind = 4 ) ierror
character ( len = * ) input_file_name
integer ( kind = 4 ) ios
integer ( kind = 4 ) iunit
integer ( kind = 4 ) lchar
integer ( kind = 4 ) state
logical stla_check
character ( len = 255 ) text
integer ( kind = 4 ) text_num
integer ( kind = 4 ) vertex
character ( len = 255 ) word1
character ( len = 255 ) word2
state = 0
text_num = 0
!
! Open the file.
!
call get_unit ( iunit )
open ( unit = iunit, file = input_file_name, status = 'old', iostat = ios )
if ( ios /= 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a)' ) ' Could not open the file "' &
// trim ( input_file_name ) // '".'
stla_check = .false.
return
end if
!
! Read the next line of text.
!
do
read ( iunit, '(a)', iostat = ios ) text
if ( ios /= 0 ) then
if ( state /= 0 .and. state /= 1 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' End-of-file, but model not finished.'
stla_check = .false.
return
end if
exit
end if
text_num = text_num + 1
done = .true.
!
! Read the first word in the line.
!
call word_next_read ( text, word1, done )
if ( done ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' No information on line.'
stla_check = .false.
return
end if
!
! "Doctor" the text, changing a beginning occurrence of:
!
! END FACET to ENDFACET
! END LOOP to ENDLOOP
! END SOLID to ENDSOLID
! FACET NORMAL to FACETNORMAL
! OUTER LOOP to OUTERLOOP
!
if ( s_eqi ( word1, 'END' ) ) then
call word_next_read ( text, word2, done )
if ( .not. s_eqi ( word2, 'FACET' ) .and. &
.not. s_eqi ( word2, 'LOOP' ) .and. &
.not. s_eqi ( word2, 'SOLID' ) ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' The tag END was followed by an illegal '
write ( *, '(a)' ) ' word: "' // trim ( word2 ) // '", when expecting'
write ( *, '(a)' ) ' "FACET", "LOOP", or "SOLID".'
stla_check = .false.
return
end if
call s_cat ( word1, word2, word1 )
else if ( s_eqi ( word1, 'FACET' ) ) then
call word_next_read ( text, word2, done )
if ( .not. s_eqi ( word2, 'NORMAL' ) ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' The tag FACET was followed by an illegal '
write ( *, '(a)' ) ' word: "' // trim ( word2 ) // '", when expecting'
write ( *, '(a)' ) ' "NORMAL".'
stla_check = .false.
return
end if
call s_cat ( word1, word2, word1 )
else if ( s_eqi ( word1, 'OUTER' ) ) then
call word_next_read ( text, word2, done )
if ( .not. s_eqi ( word2, 'LOOP' ) ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' The tag OUTER was followed by an illegal '
write ( *, '(a)' ) ' word: "' // trim ( word2 ) // '", when expecting'
write ( *, '(a)' ) ' "LOOP".'
stla_check = .false.
return
end if
call s_cat ( word1, word2, word1 )
end if
!
! This first word tells us what to do.
!
! SOLID - begin a new solid.
! Valid in state 0, moves to state 1.
! ENDSOLID - end current solid.
! Valid in state 1, moves to state 0.
!
! FACETNORMAL - begin a new facet.
! Valid in state 0 or 1, moves to state 2.
! ENDFACET - end current facet.
! Valid in state 2, moves to state 1.
!
! OUTERLOOP - begin a list of vertices.
! Valid in state 2, moves to state 3.
! ENDLOOP - end vertex list.
! Valid in state 3, moves to state 2.
!
! VERTEX - give coordinates of next vertex.
! Valid in state 3 if current vertex count is 0, 1 or 2.
!
! End of file -
! Valid in state 0 or 1.
!
if ( s_eqi ( word1, 'SOLID' ) ) then
if ( state /= 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' A new SOLID statement was encountered, but we'
write ( *, '(a)' ) ' have not finished processing the current solid.'
stla_check = .false.
return
end if
state = 1
else if ( s_eqi ( word1, 'ENDSOLID' ) ) then
if ( state /= 1 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' An END SOLID statement was encountered, but'
write ( *, '(a)' ) ' either we have not begun a solid at all, or we'
write ( *, '(a)' ) ' are not at an appropriate point to finish the'
write ( *, '(a)' ) ' current solid.'
stla_check = .false.
return
end if
state = 0
else if ( s_eqi ( word1, 'FACETNORMAL' ) ) then
if ( state /= 0 .and. state /= 1 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' Model not in right state for FACET.'
stla_check = .false.
return
end if
state = 2
do i = 1, 3
call word_next_read ( text, word2, done )
if ( done ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' End of information while reading a component'
write ( *, '(a)' ) ' of the normal vector.'
stla_check = .false.
return
end if
call s_to_r8 ( word2, dval, ierror, lchar )
if ( ierror /= 0 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) &
' Error while reading a component of the normal vector.'
stla_check = .false.
return
end if
end do
else if ( s_eqi ( word1, 'ENDFACET' ) ) then
if ( state /= 2 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' Model not in right state for ENDFACET.'
stla_check = .false.
return
end if
state = 1
else if ( s_eqi ( word1, 'OUTERLOOP' ) ) then
if ( state /= 2 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' Model not in right state for OUTERLOOP.'
stla_check = .false.
return
end if
state = 3
vertex = 0
else if ( s_eqi ( word1, 'ENDLOOP' ) ) then
if ( state /= 3 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' Model not in right state for ENDLOOP.'
stla_check = .false.
return
end if
state = 2
else if ( s_eqi ( word1, 'VERTEX' ) ) then
if ( state /= 3 ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'
write ( *, '(a,i8)' ) ' File line number = ', text_num
write ( *, '(a)' ) ' Model not in right state for VERTEX.'
stla_check = .false.
return
end if
if ( 3 <= vertex ) then
write ( *, '(a)' ) ' '
write ( *, '(a)' ) 'STLA_CHECK - Fatal error!'