-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathivread_wr.f90
23252 lines (20345 loc) · 548 KB
/
ivread_wr.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
subroutine ivread_wr(filein_name,face_normal,face_area,face_num,cor3_num, &
cor3,face,order_max,face_order,face_material,material_num,vertex_range)
!
! ivread.f90 Wriedt 04 July 2000
!
!*******************************************************************************
!
!! IVREAD is the main program for converting a graphics file.
!
!
! Introduction:
!
! This program was written for the Studio for Creative Inquiry.
!
! This program was originally intended to read an Inventor 3D graphics
! file, and write a corresponding VLA graphics file.
!
! However, it can also try to read files of several different types,
! convert the data internally to line data, and write out files
! of various types.
!
! DXF and Inventor file formats are sophisticated and extensive.
! This program was only designed to work on a few simple cases, and
! may easily be confused by unexpected (though legal) data.
!
! A sketch of the file formats and data structures is included
! in most of the READ and WRITE routines.
!
! The sizes of COR3_MAX, FACE_MAX and LINE_MAX control how much
! information this program can handle.
!
! The "head.25.iv" file has 240146 faces and 119,736 points.
! The "fish.iv" file has about 76000 faces.
! The "brain.iv" file has between 40000 and 75000 faces.
!
! Development:
!
! 26 May 1999: Added LINE_PRUNE switch, which will try to cut down
! (by about half) the number of superfluous lines created when
! faces are turned into lines by FACE_TO_LINE for VLA_WRITE output.
!
! 22 May 1999: For VLA output files, the program now will automatically
! try to temporarily convert all face information to line information. No
! sophisticated attempt is made to delete superfluous lines (the
! way FACE_TO_EDGE tries.)
!
! The "<<" merge command:
!
! On 20 April 1999, the "<<" command was added, to allow data
! from two or more files to be merged. It works, on a simple example,
! for OBJ files. However, some tuning of OBJ_READ was necessary.
! Similar testing and tuning must be done to the other READ routines
! before they will work with this option.
! On 21 April 1999, the "<<" command worked on a simple example
! using two IV files as input. SMF_READ was also updated for the "<<"
! command, but not tested. ASE_READ, DXF_READ, HRC_READ,
! STLA_READ and VLA_READ may already be OK.
! On 22 April 1999, "<<" command works with ASE_READ, HRC_READ,
! SMF_READ and STLA_READ.
!
! The "MatrixTransform" field in IV_READ/IV_WRITE.
! I'm having problems because I am reading in an IV file that has
! a matrix transform that is not the identity. I just ignore it,
! and so my data is not rotated and scaled, when it should be.
! As a start toward addressing this issue, I have IV_WRITE
! writing out the current transform matrix. One problem with
! Inventor is that the transform matrix can be specified on
! every level, and the actual transform matrix that applies
! has to be deduced from where you are in the tree.
! Right now, all I've done is have IV_READ read the matrix,
! and IV_WRITE write it out. No concatenation is possible right now,
! but my kludgy code will at least apply ONE transformation matrix
! to the data, in IV_READ, anyway...
!
! Adding material/normal/texture binding stubs, because
! A) new SMF format allows it;
! B) Inventor uses it;
! C) SCI wants to do textures eventually.
!
! SMF_READ and SMF_WRITE can now read and write face and vertex colors
! of SMF2.0 files.
!
! Modified:
!
! 26 August 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Parameter, integer COR3_MAX, the maximum number of points.
!
! Parameter, integer EDGE_MAX, the maximum number of edges.
!
! Parameter, integer FACE_MAX, the maximum number of faces.
!
! Parameter, integer LINE_MAX, the maximum number of line definition items.
!
! Parameter, integer MATERIAL_MAX, the maximum number of materials.
!
! Parameter, integer ORDER_MAX, the maximum number of vertices per face.
!
! Parameter, integer TEXTURE_MAX, the maximum number of textures.
!
implicit none
integer, parameter :: cor3_max = 100000
integer, parameter :: edge_max = 100
integer, parameter :: face_max = 100000
integer, parameter :: line_max = 100000
integer, parameter :: material_max = 200
! yurkin - order_max is now an argument
integer order_max
integer, parameter :: texture_max = 10
!
real cor3(3,cor3_max)
integer cor3_material(cor3_max)
real cor3_normal(3,cor3_max)
integer cor3_num
real cor3_tex_uv(2,cor3_max)
logical debug
integer face(order_max,face_max)
real face_area(face_max)
integer face_material(face_max)
real face_normal(3,face_max)
integer face_order(face_max)
real face_tex_uv(2,face_max)
character ( len = 100 ) filein_name
character ( len = 100 ) fileout_name
!*thw 29.11.00!
integer ierror
integer line_dex(line_max)
integer line_material(line_max)
integer line_prune
character ( len = 100 ) material_name(material_max)
real material_rgba(4,material_max)
real normal_temp(3,order_max*face_max)
character ( len = 100 ) object_name
character ( len = 100 ) texture_name(texture_max)
real texture_temp(2,order_max*face_max)
real transform_matrix(4,4)
integer vertex_material(order_max,face_max)
real vertex_normal(3,order_max,face_max)
real vertex_tex_uv(2,order_max,face_max)
real vertex_range(6)
!*thw 29.11.00!
integer face_num
character ( len = 10 ) filein_type
integer material_num
!
! Initialize a few program variables.
!
debug = .false.
! filein_name = ' '
fileout_name = ' '
ierror = 0
line_prune = 1
!
call command_line ( cor3, cor3_material, cor3_normal, cor3_tex_uv, &
debug, face, face_area, face_material, face_normal, face_order, face_tex_uv, &
filein_name, ierror, line_dex, line_material, material_name, material_rgba, &
cor3_max, face_max, line_max, material_max, order_max, texture_max, &
normal_temp, object_name, texture_name, texture_temp, transform_matrix, &
vertex_material, vertex_normal, vertex_tex_uv, face_num, filein_type, &
cor3_num, material_num, vertex_range)
return
end
function angle_rad_3d ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )
!
!*******************************************************************************
!
!! ANGLE_RAD_3D returns the angle in radians between two vectors in 3D.
!
!
! Discussion:
!
! The routine always computes the SMALLER of the two angles between
! two vectors. Thus, if the vectors make an (exterior) angle of
! 1.5 radians, the (interior) angle of 0.5 radians will be reported.
!
! Formula:
!
! X dot Y = Norm(X) * Norm(Y) * Cos ( Angle(X,Y) )
!
! Modified:
!
! 19 April 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, real X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, are three points
! which define the vectors. The vectors are:
! ( X1-X2, Y1-Y2, Z1-Z2 ) and ( X3-X2, Y3-Y2, Z3-Z2 ).
!
! Output, real ANGLE_RAD_3D, the angle between the two vectors, in radians.
! This value will always be between 0 and PI. If either vector has
! zero length, then the angle is returned as zero.
!
implicit none
real angle_rad_3d
real dot
real dot0_3d
real enorm0_3d
real v1norm
real v2norm
real x1
real x2
real x3
real y1
real y2
real y3
real z1
real z2
real z3
!
dot = dot0_3d ( x2, y2, y2, x1, y1, z1, x3, y3, z3 )
v1norm = enorm0_3d ( x1, y1, z1, x2, y2, z2 )
v2norm = enorm0_3d ( x3, y3, z3, x2, y2, z2 )
if ( v1norm == 0.0 .or. v2norm == 0.0 ) then
angle_rad_3d = 0.0
else
angle_rad_3d = acos ( dot / ( v1norm * v2norm ) )
end if
return
end
subroutine ase_read ( cor3, cor3_material, face, face_material, face_normal, face_order, &
ierror, iunit, material_name, material_rgba, cor3_max, face_max, material_max, &
order_max, bad_num, cor3_num, face_num, material_num, text_num, vertex_material, &
vertex_normal )
!
!*******************************************************************************
!
!! ASE_READ reads graphics information from an ASE file.
!
!
! Problems:
!
! Processing of the MESH_FACELIST assumes faces are always triangles
! or quadrilaterals.
!
! Discussion:
!
! It is intended that the information read from the file can
! either start a whole new graphics object, or simply be added
! to a current graphics object via the '<<' command.
!
! This is controlled by whether the input values have been zeroed
! out or not. This routine simply tacks on the information it
! finds to the current graphics object.
!
! Modified:
!
! 02 June 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input/output, real COR3(3,COR3_MAX), the coordinates of points.
!
! Input/output, integer COR3_MATERIAL(COR3_MAX), the material index of each node.
!
! Input/output, integer FACE(ORDER_MAX,FACE_MAX), the nodes making faces.
!
! Input/output, integer FACE_MATERIAL(FACE_MAX), the material of each face.
!
! Input/output, real FACE_NORMAL(3,FACE_MAX), the normal vector at each face.
!
! Input/output, integer FACE_ORDER(FACE_MAX), the number of vertices per face.
!
! Output, integer IERROR, an error flag.
!
! Input, integer IUNIT, the FORTRAN unit from which data is read.
!
! Input/output, character ( len = 100 ) MATERIAL_NAME(MATERIAL_MAX), material names.
!
! Input, integer COR3_MAX, the maximum number of points.
!
! Input, integer FACE_MAX, the maximum number of faces.
!
! Input, integer MATERIAL_MAX, the maximum number of materials.
!
! Input, integer ORDER_MAX, the maximum number of vertices per face.
!
! Input/output, integer COR3_NUM, the number of points.
!
! Input/output, integer FACE_NUM, the number of faces.
!
! Input/output, integer MATERIAL_NUM, the number of materials.
!
! Output, real TRANSFORM_MATRIX(4,4), the transformation matrix.
!
! Input/output, integer VERTEX_MAT(ORDER_MAX,FACE_MAX), vertex materials.
!
! Input/output, real VERTEX_NORMAL(3,ORDER_MAX,FACE_MAX), normals at vertices.
!
implicit none
logical, parameter :: debug = .false.
integer, parameter :: level_max = 10
integer, parameter :: OFFSET = 1
!
integer cor3_max
integer face_max
integer material_max
integer order_max
!
integer bad_num
real bval
character ( len = 4 ) char4
real cor3(3,cor3_max)
integer cor3_material(cor3_max)
integer cor3_num
integer cor3_num_old
logical done
integer face(order_max,face_max)
integer face_material(face_max)
real face_normal(3,face_max)
integer face_num
integer face_num_old
integer face_order(face_max)
real gval
integer i
integer ierror
integer iface
integer imat
integer iunit
integer ivert
integer iword
integer lchar
integer level
character ( len = 256 ) level_name(0:level_max)
character ( len = 256 ) line
character ( len = 100 ) material_name(material_max)
integer material_num
integer mat_stored
real material_rgba(4,material_max)
integer nlbrack
integer node
integer nrbrack
real rgba(4)
real rval
logical s_eqi
real temp
integer text_num
real transform_matrix(4,4)
integer vertex_material(order_max,face_max)
real vertex_normal(3,order_max,face_max)
character ( len = 256 ) word
character ( len = 256 ) word1
character ( len = 256 ) wordm1
real x
real y
real z
!
ierror = 0
level = 0
level_name(0) = 'Top'
cor3_num_old = cor3_num
face_num_old = face_num
nlbrack = 0
nrbrack = 0
call tmat_init ( transform_matrix )
word = ' '
wordm1 = ' '
!
! Read a line of text from the file.
!
10 continue
read ( iunit, '(a)', end = 30 ) line
text_num = text_num + 1
!
! Replace any control characters (in particular, TAB's) by blanks.
!
call s_control_blank ( line )
done = .true.
iword = 0
!
! Read a word from the line.
!
20 continue
if ( word /= ' ' ) then
wordm1 = word
end if
call word_nexrd ( line, word, done )
!
! If no more words in this line, read a new line.
!
if ( done ) then
go to 10
end if
iword = iword + 1
if ( iword == 1 ) then
word1 = word
end if
!
! In cases where the word is a left bracket, record the level name,
! and for right brackets, do a parity check.
!
if ( word == '{' ) then
nlbrack = nlbrack + 1
level = nlbrack - nrbrack
if ( level < 0 ) then
write ( *, * ) 'Too many right brackets!'
level = 0
else if ( level > level_max ) then
write ( *, * ) 'Too many left brackets!'
level = level_max
end if
level_name(level) = wordm1
if ( debug ) then
do i = 0, level
write ( *, * ) i, trim ( level_name(i) )
end do
end if
else if ( word == '}' ) then
nrbrack = nrbrack + 1
if ( nlbrack < nrbrack ) then
write ( *, * ) ' '
write ( *, * ) 'ASE_READ - Fatal error!'
write ( *, * ) ' Extraneous right bracket on line ', text_num
write ( *, '(a)' ) trim ( line )
write ( *, * ) ' Currently processing field:'
write ( *, '(a)' ) trim ( level_name(level) )
ierror = 1
return
end if
end if
!
! *3DSMAX_ASCIIEXPORT 200
!
if ( word1 == '*3DSMAX_ASCIIEXPORT' ) then
go to 10
!
! *COMMENT
!
else if ( word1 == '*COMMENT' ) then
go to 10
!
! *GEOMOBJECT
!
else if ( level_name(level) == '*GEOMOBJECT' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*NODE_NAME' ) then
go to 10
else if ( word == '*NODE_TM' ) then
go to 20
else if ( word == '*MESH' ) then
go to 20
else if ( word == '*PROP_CASTSHADOW' ) then
go to 10
else if ( word == '*PROP_MOTIONBLUR' ) then
go to 10
else if ( word == '*PROP_RECVSHADOW' ) then
go to 10
else
go to 99
end if
!
! *MESH
!
else if ( level_name(level) == '*MESH' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*MESH_CFACELIST' ) then
go to 20
else if ( word == '*MESH_CVERTLIST' ) then
go to 20
else if ( word == '*MESH_FACE_LIST' ) then
go to 20
else if ( word == '*MESH_NORMALS' ) then
go to 20
else if ( word == '*MESH_NUMCVERTEX' ) then
go to 10
else if ( word == '*MESH_NUMCVFACES' ) then
go to 10
else if ( word == '*MESH_NUMFACES' ) then
go to 10
else if ( word == '*MESH_NUMTVERTEX' ) then
go to 10
else if ( word == '*MESH_NUMTVFACES' ) then
go to 10
else if ( word == '*MESH_NUMVERTEX' ) then
go to 10
else if ( word == '*MESH_TFACELIST' ) then
go to 20
else if ( word == '*MESH_TVERTLIST' ) then
go to 20
else if ( word == '*MESH_VERTEX_LIST' ) then
go to 20
else if ( word == '*TIMEVALUE' ) then
go to 10
else
bad_num = bad_num + 1
if ( bad_num < 10 ) then
write ( *, * ) 'Bad data while reading *MESH.'
write ( *, * ) trim ( line )
end if
go to 10
end if
!
! *MESH_CFACELIST
!
else if ( level_name(level) == '*MESH_CFACELIST' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*MESH_CFACE' ) then
go to 10
else
go to 99
end if
!
! *MESH_CVERTLIST
!
! Mesh vertex indices must be incremented by COR3_NUM_OLD before
! being stored in the internal array.
!
else if ( level_name(level) == '*MESH_CVERTLIST' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*MESH_VERTCOL' ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
i = i + cor3_num_old + OFFSET
call word_nexrd ( line, word, done )
call s_to_r ( word, rval, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, gval, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, bval, ierror, lchar )
rgba(1) = rval
rgba(2) = gval
rgba(3) = bval
rgba(4) = 1.0
mat_stored = min(material_num,material_max)
call rcol_find ( 4, mat_stored, material_rgba, rgba, imat )
if ( imat == 0 ) then
material_num = material_num + 1
if ( material_num <= material_max ) then
call i_to_s_zero ( material_num, char4 )
material_name(material_num) = 'Material_' // char4
material_rgba(1:4,material_num) = rgba(1:4)
imat = material_num
else
imat = 0
end if
end if
cor3_material(i) = imat
else
go to 99
end if
!
! *MESH_FACE_LIST
!
! WARNING:
! The following coding assumes that the faces are always triangles
! or quadrilaterals, but not higher order.
!
else if ( level_name(level) == '*MESH_FACE_LIST' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*MESH_FACE' ) then
face_num = face_num + 1
if ( face_num <= face_max ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
face_material(face_num) = material_num
face_order(face_num) = 0
call word_nexrd ( line, word, done )
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
face(1,face_num) = i + cor3_num_old + OFFSET
vertex_material(1,face_num) = material_num
face_order(face_num) = face_order(face_num) + 1
call word_nexrd ( line, word, done )
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
face(2,face_num) = i + cor3_num_old + OFFSET
vertex_material(2,face_num) = material_num
face_order(face_num) = face_order(face_num) + 1
call word_nexrd ( line, word, done )
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
face(3,face_num) = i + cor3_num_old + OFFSET
vertex_material(3,face_num) = material_num
face_order(face_num) = face_order(face_num) + 1
call word_nexrd ( line, word, done )
if ( s_eqi ( word, 'D:' ) ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
face(4,face_num) = i + cor3_num_old + OFFSET
vertex_material(4,face_num) = material_num
face_order(face_num) = face_order(face_num) + 1
end if
end if
go to 10
else
go to 99
end if
!
! *MESH_NORMALS
!
else if ( level_name(level) == '*MESH_NORMALS' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*MESH_FACENORMAL' ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, iface, ierror, lchar )
iface = iface + face_num_old + OFFSET
ivert = 0
call word_nexrd ( line, word, done )
call s_to_r ( word, x, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, y, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, z, ierror, lchar )
face_normal(1,iface) = x
face_normal(2,iface) = y
face_normal(3,iface) = z
go to 10
else if ( word == '*MESH_VERTEXNORMAL' ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, node, ierror, lchar )
ivert = ivert + 1
call word_nexrd ( line, word, done )
call s_to_r ( word, x, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, y, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, z, ierror, lchar )
vertex_normal(1,ivert,iface) = x
vertex_normal(2,ivert,iface) = y
vertex_normal(3,ivert,iface) = z
go to 10
else
go to 99
end if
!
! *MESH_TFACELIST
!
else if ( level_name(level) == '*MESH_TFACELIST' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word1 == '*MESH_TFACE' ) then
go to 10
else
go to 99
end if
!
! *MESH_TVERTLIST
!
else if ( level_name(level) == '*MESH_TVERTLIST' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word1 == '*MESH_TVERT' ) then
go to 10
else
go to 99
end if
!
! *MESH_VERTEX_LIST
!
else if ( level_name(level) == '*MESH_VERTEX_LIST' ) then
if ( word == '{' ) then
cor3_num_old = cor3_num
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word1 == '*MESH_VERTEX' ) then
call word_nexrd ( line, word, done )
call s_to_i ( word, i, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, x, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, y, ierror, lchar )
call word_nexrd ( line, word, done )
call s_to_r ( word, z, ierror, lchar )
i = i + cor3_num_old + OFFSET
cor3_num = max ( cor3_num, i )
if ( i <= cor3_max ) then
cor3(1,i) = transform_matrix(1,1) * x + transform_matrix(1,2) * y &
+ transform_matrix(3,1) * z + transform_matrix(4,1)
cor3(2,i) = transform_matrix(2,1) * x + transform_matrix(2,2) * y &
+ transform_matrix(2,3) * z + transform_matrix(2,4)
cor3(3,i) = transform_matrix(3,1) * x + transform_matrix(3,2) * y &
+ transform_matrix(3,3) * z + transform_matrix(3,4)
end if
go to 10
else
go to 99
end if
!
! *NODE_TM
!
! Each node should start out with a default transformation matrix.
!
else if ( level_name(level) == '*NODE_TM' ) then
if ( word == '{' ) then
call tmat_init ( transform_matrix )
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*INHERIT_POS' ) then
go to 10
else if ( word == '*INHERIT_ROT' ) then
go to 10
else if ( word == '*INHERIT_SCL' ) then
go to 10
else if ( word == '*NODE_NAME' ) then
go to 10
else if ( word == '*TM_POS' ) then
go to 10
else if ( word == '*TM_ROTANGLE' ) then
go to 10
else if ( word == '*TM_ROTAXIS' ) then
go to 10
else if ( word == '*TM_ROW0' ) then
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(1,1) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(2,1) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(3,1) = temp
go to 10
else if ( word == '*TM_ROW1' ) then
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(1,2) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(2,2) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(3,2) = temp
go to 10
else if ( word == '*TM_ROW2' ) then
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(1,3) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(2,3) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(3,3) = temp
go to 10
else if ( word == '*TM_ROW3' ) then
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(1,4) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(2,4) = temp
call word_nexrd ( line, word, done )
call s_to_r ( word, temp, ierror, lchar )
transform_matrix(3,4) = temp
go to 10
else if ( word == '*TM_SCALE' ) then
go to 10
else if ( word == '*TM_SCALEAXIS' ) then
go to 10
else if ( word == '*TM_SCALEAXISANG' ) then
go to 10
else
go to 99
end if
!
! *SCENE
!
else if ( level_name(level) == '*SCENE' ) then
if ( word == '{' ) then
go to 20
else if ( word == '}' ) then
level = nlbrack - nrbrack
else if ( word == '*SCENE_AMBIENT_STATIC' ) then
go to 10
else if ( word == '*SCENE_BACKGROUND_STATIC' ) then
go to 10
else if ( word == '*SCENE_FILENAME' ) then
go to 10
else if ( word == '*SCENE_FIRSTFRAME' ) then
go to 10
else if ( word == '*SCENE_FRAMESPEED' ) then
go to 10
else if ( word == '*SCENE_LASTFRAME' ) then
go to 10
else if ( word == '*SCENE_TICKSPERFRAME' ) then
go to 10
else
go to 99
end if
end if
go to 20
!
! Bad data
!
99 continue
bad_num = bad_num + 1
if ( bad_num <= 10 ) then
write ( *, * ) ' '
write ( *, * ) 'ASE_READ - Warning!'
write ( *, * ) ' Bad data on level ' // trim ( level_name(level) )
write ( *, '(a)' ) ' Bad word: ' // trim ( word )
write ( *, * ) ' Line number: ', text_num
write ( *, '(a)' ) trim ( line )
end if
go to 10
!
! End of information in file.
!
30 continue
return
end
subroutine ase_write ( cor3, face, face_normal, face_order, filein_name, &
fileout_name, iunit, cor3_max, face_max, order_max, cor3_num, face_num, &
vertex_normal )
!
!*******************************************************************************
!
!! ASE_WRITE writes graphics information to an ASE file.
!
!
! Modified:
!
! 22 April 1999
!
! Author:
!
! John Burkardt
!
! Parameters:
!
! Input, real COR3(3,COR3_MAX), the coordinates of points.
!
! Input, integer FACE(ORDER_MAX,FACE_MAX), the nodes making faces.
!
! Input, real FACE_NORMAL(3,FACE_MAX), the normal vector at each face.
!
! Input, integer FACE_ORDER(FACE_MAX), the number of vertices per face.
!
! Input, character ( len = 100 ) FILEIN_NAME, the name of the input file.
!
! Input, character ( len = 100 ) FILEOUT_NAME, the name of the output file.
!
! Input, integer IUNIT, the FORTRAN unit to which output is written.
!
! Input, integer COR3_MAX, the maximum number of points.
!
! Input, integer FACE_MAX, the maximum number of faces.
!
! Input, integer ORDER_MAX, the maximum number of vertices per face.
!
! Input, integer COR3_NUM, the number of points.
!
! Input, integer FACE_NUM, the number of faces.
!
! Input, real VERTEX_NORMAL(3,ORDER_MAX,FACE_MAX), normals at vertices.
!
implicit none
integer, parameter :: OFFSET = 1
!
integer cor3_max
integer face_max
integer order_max
!
character ( len = 10 ) chrtmp
real cor3(3,cor3_max)
integer cor3_num
integer face(order_max,face_max)
real face_normal(3,face_max)
integer face_num
integer face_order(face_max)
character ( len = 100 ) filein_name