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
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const CTRSIZ: i32 = 2;
const MAXL: i32 = 36;
struct SaveVars {
SVCTR1: StackArray<i32, 2>,
SVINST: Vec<u8>,
SVINID: i32,
SVFND1: bool,
FIRST: bool,
}
impl SaveInit for SaveVars {
fn new() -> Self {
let mut SVCTR1 = StackArray::<i32, 2>::new(1..=CTRSIZ);
let mut SVINST = vec![b' '; MAXL as usize];
let mut SVINID: i32 = 0;
let mut SVFND1: bool = false;
let mut FIRST: bool = false;
FIRST = true;
Self {
SVCTR1,
SVINST,
SVINID,
SVFND1,
FIRST,
}
}
}
/// Get instrument FOV parameters, by instrument name
///
/// Return the field-of-view (FOV) parameters for a specified
/// instrument. The instrument is specified by name.
///
/// # Required Reading
///
/// * [NAIF_IDS](crate::required_reading::naif_ids)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// INST I Name of an instrument.
/// ROOM I Maximum number of vectors that can be returned.
/// SHAPE O Instrument FOV shape.
/// FRAME O Name of the frame in which FOV vectors are defined.
/// BSIGHT O Boresight vector.
/// N O Number of boundary vectors returned.
/// BOUNDS O FOV boundary vectors.
/// ```
///
/// # Detailed Input
///
/// ```text
/// INST is the name of an instrument, such as a
/// spacecraft-mounted framing camera, for which the field of
/// view parameters are to be retrieved from the kernel pool.
/// INST is case-insensitive, and leading and trailing blanks
/// in INST are not significant. Optionally, you may supply
/// the integer ID for the instrument as an integer string.
/// For example, both 'CASSINI_ISS_NAC' and '-82360' are
/// legitimate strings that indicate the CASSINI ISS NAC
/// camera is the instrument of interest.
///
/// ROOM is the maximum number of 3-dimensional vectors that can
/// be returned in BOUNDS.
/// ```
///
/// # Detailed Output
///
/// ```text
/// SHAPE is a character string that describes the "shape" of
/// the field of view. Possible values returned are:
///
/// 'POLYGON'
/// 'RECTANGLE'
/// 'CIRCLE'
/// 'ELLIPSE'
///
/// If the value of SHAPE is 'POLYGON' the field of view
/// of the instrument is a pyramidal polyhedron. The
/// vertex of the pyramid is at the instrument focal
/// point. The rays along the edges of the pyramid are
/// parallel to the vectors returned in BOUNDS.
///
/// If the value of SHAPE is 'RECTANGLE' the field of view
/// of the instrument is a rectangular pyramid. The vertex
/// of the pyramid is at the instrument focal point. The
/// rays along the edges of the pyramid are parallel to
/// the vectors returned in BOUNDS. Moreover, in this
/// case, the boresight points along the axis of symmetry
/// of the rectangular pyramid.
///
/// If the value of SHAPE is 'CIRCLE' the field of view of
/// the instrument is a circular cone centered on the
/// boresight vector. The vertex of the cone is at the
/// instrument focal point. A single vector will be
/// returned in BOUNDS. This vector will be parallel to a
/// ray that lies in the cone that makes up the boundary
/// of the field of view.
///
/// If the value of SHAPE is 'ELLIPSE' the field of view
/// of the instrument is an elliptical cone with the
/// boresight vector as the axis of the cone. In this
/// case two vectors are returned in BOUNDS. One of the
/// vectors returned in BOUNDS points to the end of the
/// semi-major axis of a perpendicular cross section of
/// the elliptic cone. The other vector points to the end
/// of the semi-minor axis of a perpendicular cross
/// section of the cone.
///
/// FRAME is the name of the reference frame in which the field
/// of view boundary vectors are defined.
///
/// BSIGHT is a vector representing the principal instrument view
/// direction that can be
///
/// - the central pixel view direction,
/// - the optical axis direction,
/// - the FOV geometric center view direction,
/// - an axis of the FOV frame,
///
/// or any other vector specified for this purpose
/// in the IK FOV definition. The length of BSIGHT
/// is not specified other than being non-zero.
///
/// N is the number of boundary vectors returned.
///
/// BOUNDS is an array of vectors that point to the "corners" of
/// the instrument field of view. (See the discussion
/// accompanying SHAPE for an expansion of the term
/// "corner of the field of view.") Note that the vectors
/// returned in BOUNDS are not necessarily unit vectors.
/// Their magnitudes will be as set in the IK (for
/// 'CORNERS'-style FOV specifications) or the same as the
/// magnitude of the boresight (for 'ANGLES'-style FOV
/// specifications.)
/// ```
///
/// # Parameters
///
/// ```text
/// MINCOS is the lower limit on the value of the cosine of the
/// cross or reference angles in the 'ANGLES' specification
/// cases. See the header of the routine GETFOV for its
/// current value.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If the name of the instrument cannot be translated to its
/// NAIF ID code, the error SPICE(IDCODENOTFOUND) is signaled.
///
/// 2) If the frame associated with the instrument can not be found,
/// an error is signaled by a routine in the call tree of this
/// routine.
///
/// 3) If the shape of the instrument field of view can not be found
/// in the kernel pool, an error is signaled by a routine in the
/// call tree of this routine.
///
/// 4) If the FOV_SHAPE specified by the instrument kernel is not
/// one of the four values: 'CIRCLE', 'POLYGON', 'ELLIPSE', or
/// 'RECTANGLE', an error is signaled by a routine in the call
/// tree of this routine. If the 'ANGLES' specification is used,
/// FOV_SHAPE must be one of the three values: 'CIRCLE',
/// 'ELLIPSE', or 'RECTANGLE'.
///
/// 5) If the direction of the boresight cannot be located in the
/// kernel pool, an error is signaled by a routine in the call
/// tree of this routine.
///
/// 6) If the number of components for the boresight vector in the
/// kernel pool is not 3, or they are not numeric, an error is
/// signaled by a routine in the call tree of this routine.
///
/// 7) If the boresight vector is the zero vector, an error is
/// signaled by a routine in the call tree of this routine.
///
/// 8) If the 'ANGLES' specification is not present in the kernel
/// pool and the boundary vectors for the edge of the field of
/// view cannot be found in the kernel pool, an error is signaled
/// by a routine in the call tree of this routine.
///
/// 9) If there is insufficient room (as specified by the argument
/// ROOM) to return all of the vectors associated with the
/// boundary of the field of view, an error is signaled by a
/// routine in the call tree of this routine.
///
/// 10) If the number of components of vectors making up the field of
/// view is not a multiple of 3, an error is signaled by a routine
/// in the call tree of this routine.
///
/// 11) If the number of components of vectors making up the field of
/// view is not compatible with the shape specified for the field
/// of view, an error is signaled by a routine in the call tree of
/// this routine.
///
/// 12) If the reference vector for the 'ANGLES' specification can not
/// be found in the kernel pool, an error is signaled by a routine
/// in the call tree of this routine.
///
/// 13) If the reference vector stored in the kernel pool to support
/// the 'ANGLES' specification contains an incorrect number of
/// components, contains 3 character components, or is parallel to
/// the boresight, an error is signaled by a routine in the call
/// tree of this routine.
///
/// 14) If the 'ANGLES' specification is present in the kernel pool
/// and the reference angle stored in the kernel pool to support
/// the 'ANGLES' specification is absent from the kernel pool, an
/// error is signaled by a routine in the call tree of this
/// routine.
///
/// 15) If the keyword that stores the angular units for the angles
/// used in the 'ANGLES' specification is absent from the kernel
/// pool, an error is signaled by a routine in the call tree of
/// this routine.
///
/// 16) If the value used for the units in the 'ANGLES' specification
/// is not one of the supported angular units of CONVRT, an error
/// is signaled by a routine in the call tree of this routine.
///
/// 17) If the keyword that stores the cross angle for the 'ANGLES'
/// specification is needed and is absent from the kernel pool, an
/// error is signaled by a routine in the call tree of this
/// routine.
///
/// 18) If the angles for the 'RECTANGLE'/'ANGLES' specification case
/// have cosines that are less than those stored in the parameter
/// MINCOS defined in the GETFOV routine, an error is signaled by
/// a routine in the call tree of this routine.
///
/// 19) If the class specification contains something other than
/// 'ANGLES' or 'CORNERS', an error is signaled by a routine in
/// the call tree of this routine.
///
/// 20) In the event that the CLASS_SPEC keyword is absent from the
/// kernel pool for the instrument whose FOV is sought, this
/// module assumes the 'CORNERS' specification is to be utilized.
/// ```
///
/// # Files
///
/// ```text
/// Appropriate SPICE kernels must be loaded by the calling program
/// before this routine is called.
///
/// This routine relies upon having successfully loaded an instrument
/// kernel (IK file) via the routine FURNSH prior to calling this
/// routine.
///
/// The name INST must be associated with an NAIF ID code, normally
/// through a frames kernel (FK file) or instrument kernel (IK file).
///
/// Kernel data are normally loaded via FURNSH once per program run,
/// NOT every time this routine is called.
/// ```
///
/// # Particulars
///
/// ```text
/// This routine provides a common interface for retrieving from the
/// kernel pool the geometric characteristics of an instrument field
/// of view for a wide variety of remote sensing instruments
/// across many different space missions.
///
/// This routine is identical in function to the routine GETFOV except
/// that it allows you to refer to an instrument by name (via a
/// character string) instead of by its NAIF instrument ID.
///
/// Given the NAIF instrument name, (and having "loaded" the
/// instrument field of view description and instrument name to NAIF
/// ID mapping) this routine returns the boresight of the instrument,
/// the "shape" of the field of view, a collection of vectors
/// that point along the edges of the field of view, and the
/// name of the reference frame in which these vectors are defined.
///
/// Currently this routine supports two classes of specifications
/// for FOV definitions: "corners" and "angles".
///
/// The "corners" specification requires that the following keywords
/// defining the shape, boresight, boundary vectors, and reference
/// frame of the FOV be provided in one of the text kernel files
/// (normally an IK file) loaded into the kernel pool (in the
/// keywords below <INSTID> is replaced with the instrument ID which
/// corresponds to the INST name passed into the module):
///
/// INS<INSTID>_FOV_CLASS_SPEC must be set to 'CORNERS' or
/// omitted to indicate the
/// "corners"-class
/// specification.
///
/// INS<INSTID>_FOV_SHAPE must be set to one of these
/// values:
///
/// 'CIRCLE'
/// 'ELLIPSE'
/// 'RECTANGLE'
/// 'POLYGON'
///
/// INS<INSTID>_FOV_FRAME must contain the name of
/// the frame in which the
/// boresight and boundary
/// corner vectors are defined.
///
/// INS<INSTID>_BORESIGHT must be set to a 3D vector
/// defining the boresight in
/// the FOV frame specified in
/// the FOV_FRAME keyword.
///
/// INS<INSTID>_FOV_BOUNDARY or
/// INS<INSTID>_FOV_BOUNDARY_CORNERS must be set to one (for
/// FOV_SHAPE = 'CIRCLE'), two
/// (for FOV_SHAPE =
/// 'ELLIPSE'), four (for
/// FOV_SHAPE = 'RECTANGLE'),
/// or three or more (for
/// 'POLYGON') 3D vectors
/// defining the corners of the
/// FOV in the FOV frame
/// specified in the FOV_FRAME
/// keyword. The vectors should
/// be listed in either
/// clockwise or
/// counterclockwise order.
/// This is required by some
/// SPICE routines that make
/// use of FOV specifications.
///
/// The "angles" specification requires the following keywords
/// defining the shape, boresight, reference vector, reference and
/// cross angular extents of the FOV be provided in one of the text
/// kernel files (normally an IK file) loaded into the kernel
/// pool (in the keywords below <INSTID> is replaced with the
/// instrument ID which corresponds to the INST name passed into the
/// module):
///
/// INS<INSTID>_FOV_CLASS_SPEC must be set to 'ANGLES' to
/// indicate the "angles"-class
/// specification.
///
/// INS<INSTID>_FOV_SHAPE must be set to one of these
/// values:
///
/// 'CIRCLE'
/// 'ELLIPSE'
/// 'RECTANGLE'
///
/// INS<INSTID>_FOV_FRAME must contain the name of
/// the frame in which the
/// boresight and the computed
/// boundary corner vectors are
/// defined.
///
/// INS<INSTID>_BORESIGHT must be set to a 3D vector
/// defining the boresight in
/// the FOV frame specified in
/// the FOV_FRAME keyword.
///
/// INS<INSTID>_FOV_REF_VECTOR must be set to a 3D vector
/// that together with the
/// boresight vector defines
/// the plane in which the
/// first angular extent of the
/// FOV specified in the
/// FOV_REF_ANGLE keyword is
/// measured.
///
/// INS<INSTID>_FOV_REF_ANGLE must be set to the angle
/// that is 1/2 of the total
/// FOV angular extent in the
/// plane defined by the
/// boresight and the vector
/// specified in the
/// FOV_REF_VECTOR keyword. The
/// the FOV angular half-extents
/// are measured from the
/// boresight vector.
///
/// INS<INSTID>_FOV_CROSS_ANGLE must be set to the angle
/// that is 1/2 of the total
/// FOV angular extent in the
/// plane containing the
/// boresight and perpendicular
/// to the plane defined by the
/// boresight and the vector
/// specified in the
/// FOV_REF_VECTOR keyword. The
/// the FOV angular half-extents
/// are measured from the
/// boresight vector. This
/// keyword is not required for
/// FOV_SHAPE = 'CIRCLE'.
///
/// INS<INSTID>_FOV_ANGLE_UNITS must specify units for the
/// angles given in the
/// FOV_REF_ANGLE and
/// FOV_CROSS_ANGLE keywords.
/// Any angular units
/// recognized by CONVRT are
/// acceptable.
///
/// The INS<INSTID>_FOV_REF_ANGLE and INS<INSTID>_FOV_CROSS_ANGLE
/// keywords can have any values for the 'CIRCLE' and 'ELLIPSE'
/// FOV shapes but must satisfy the condition COS( ANGLE ) > 0 for
/// the 'RECTANGLE' shape.
///
/// This routine is intended to be an intermediate level routine.
/// It is expected that users of this routine will be familiar
/// with the SPICE frames subsystem and will be comfortable writing
/// software to further manipulate the vectors retrieved by this
/// routine.
/// ```
///
/// # Examples
///
/// ```text
/// The numerical results shown for this example may differ across
/// platforms. The results depend on the SPICE kernels used as input,
/// the compiler and supporting libraries, and the machine specific
/// arithmetic implementation.
///
/// 1) Load an IK, fetch the parameters for each of the FOVs defined
/// within and print these parameters to the screen.
///
/// Use the kernel shown below, an IK defining four FOVs of
/// various shapes and sizes, to load the FOV definitions, and the
/// mapping between their NAMES and NAIF IDs.
///
///
/// KPL/IK
///
/// File name: getfvn_ex1.ti
///
/// The keywords below define a circular, 10-degree wide FOV
/// with the boresight along the +Z axis of the 'SC999_INST001'
/// frame for an instrument with ID -999001 using the
/// "angles"-class specification.
///
/// \begindata
/// INS-999001_FOV_CLASS_SPEC = 'ANGLES'
/// INS-999001_FOV_SHAPE = 'CIRCLE'
/// INS-999001_FOV_FRAME = 'SC999_INST001'
/// INS-999001_BORESIGHT = ( 0.0, 0.0, 1.0 )
/// INS-999001_FOV_REF_VECTOR = ( 1.0, 0.0, 0.0 )
/// INS-999001_FOV_REF_ANGLE = ( 5.0 )
/// INS-999001_FOV_ANGLE_UNITS = ( 'DEGREES' )
/// \begintext
///
/// The keywords below define an elliptical FOV with 2- and
/// 4-degree angular extents in the XZ and XY planes and the
/// boresight along the +X axis of the 'SC999_INST002' frame for
/// an instrument with ID -999002 using the "corners"-class
/// specification.
///
/// \begindata
/// INS-999002_FOV_SHAPE = 'ELLIPSE'
/// INS-999002_FOV_FRAME = 'SC999_INST002'
/// INS-999002_BORESIGHT = ( 1.0, 0.0, 0.0 )
/// INS-999002_FOV_BOUNDARY_CORNERS = (
/// 1.0, 0.0, 0.01745506,
/// 1.0, 0.03492077, 0.0 )
/// \begintext
///
/// The keywords below define a rectangular FOV with 1.2- and
/// 0.2-degree angular extents in the ZX and ZY planes and the
/// boresight along the +Z axis of the 'SC999_INST003' frame for
/// an instrument with ID -999003 using the "angles"-class
/// specification.
///
/// \begindata
/// INS-999003_FOV_CLASS_SPEC = 'ANGLES'
/// INS-999003_FOV_SHAPE = 'RECTANGLE'
/// INS-999003_FOV_FRAME = 'SC999_INST003'
/// INS-999003_BORESIGHT = ( 0.0, 0.0, 1.0 )
/// INS-999003_FOV_REF_VECTOR = ( 1.0, 0.0, 0.0 )
/// INS-999003_FOV_REF_ANGLE = ( 0.6 )
/// INS-999003_FOV_CROSS_ANGLE = ( 0.1 )
/// INS-999003_FOV_ANGLE_UNITS = ( 'DEGREES' )
/// \begintext
///
/// The keywords below define a triangular FOV with the
/// boresight along the +Y axis of the 'SC999_INST004' frame
/// for an instrument with ID -999004 using the "corners"-class
/// specification.
///
/// \begindata
/// INS-999004_FOV_SHAPE = 'POLYGON'
/// INS-999004_FOV_FRAME = 'SC999_INST004'
/// INS-999004_BORESIGHT = ( 0.0, 1.0, 0.0 )
/// INS-999004_FOV_BOUNDARY_CORNERS = ( 0.0, 0.8, 0.5,
/// 0.4, 0.8, -0.2,
/// -0.4, 0.8, -0.2 )
/// \begintext
///
/// The keywords below define the INSTRUMENT name to NAIF ID
/// mappings for this example. For convenience we will keep them
/// in the example's IK although they could be placed elsewhere
/// (normally on the mission's frames kernel)
///
/// \begindata
/// NAIF_BODY_NAME += ( 'SC999_INST001' )
/// NAIF_BODY_CODE += ( -999001 )
///
/// NAIF_BODY_NAME += ( 'SC999_INST002' )
/// NAIF_BODY_CODE += ( -999002 )
///
/// NAIF_BODY_NAME += ( 'SC999_INST003' )
/// NAIF_BODY_CODE += ( -999003 )
///
/// NAIF_BODY_NAME += ( 'SC999_INST004' )
/// NAIF_BODY_CODE += ( -999004 )
/// \begintext
///
/// End of IK
///
///
/// Example code begins here.
///
///
/// PROGRAM GETFVN_EX1
/// IMPLICIT NONE
///
/// C
/// C Local parameters
/// C
/// INTEGER MAXBND
/// PARAMETER ( MAXBND = 4 )
///
/// INTEGER NUMINS
/// PARAMETER ( NUMINS = 4 )
///
/// INTEGER WDSIZE
/// PARAMETER ( WDSIZE = 32 )
///
/// C
/// C Local variables
/// C
/// CHARACTER*(WDSIZE) INSTNM ( NUMINS )
/// CHARACTER*(WDSIZE) FRAME
/// CHARACTER*(WDSIZE) SHAPE
///
/// DOUBLE PRECISION BOUNDS ( 3, MAXBND )
/// DOUBLE PRECISION BSIGHT ( 3 )
///
/// INTEGER I
/// INTEGER J
/// INTEGER N
///
/// C
/// C Define the instrument IDs.
/// C
/// DATA INSTNM / 'SC999_INST001',
/// . 'SC999_INST002',
/// . 'SC999_INST003',
/// . 'SC999_INST004' /
///
/// C
/// C Load the IK file.
/// C
/// CALL FURNSH( 'getfvn_ex1.ti' )
///
/// C
/// C For each instrument ...
/// C
/// WRITE (*,'(A)') '--------------------------------------'
/// DO I = 1, NUMINS
///
/// C
/// C ... fetch FOV parameters and ...
/// C
/// CALL GETFVN ( INSTNM(I), MAXBND,
/// . SHAPE, FRAME, BSIGHT, N, BOUNDS )
///
/// C
/// C ... print them to the screen.
/// C
/// WRITE (*,'(2A)') 'Instrument NAME: ', INSTNM(I)
/// WRITE (*,'(2A)') ' FOV shape: ', SHAPE
/// WRITE (*,'(2A)') ' FOV frame: ', frame
/// WRITE (*,'(A,3F12.8)') 'FOV boresight: ', BSIGHT
///
/// WRITE (*,'(A)') ' FOV corners: '
/// DO J = 1, N
/// WRITE (*,'(A,3F12.8)') ' ',
/// . BOUNDS(1,J), BOUNDS(2,J), BOUNDS(3,J)
/// END DO
/// WRITE (*,'(A)')
/// . '--------------------------------------'
///
/// END DO
///
/// END
///
///
/// When this program was executed on a Mac/Intel/gfortran/64-bit
/// platform, the output was:
///
///
/// --------------------------------------
/// Instrument NAME: SC999_INST001
/// FOV shape: CIRCLE
/// FOV frame: SC999_INST001
/// FOV boresight: 0.00000000 0.00000000 1.00000000
/// FOV corners:
/// 0.08715574 0.00000000 0.99619470
/// --------------------------------------
/// Instrument NAME: SC999_INST002
/// FOV shape: ELLIPSE
/// FOV frame: SC999_INST002
/// FOV boresight: 1.00000000 0.00000000 0.00000000
/// FOV corners:
/// 1.00000000 0.00000000 0.01745506
/// 1.00000000 0.03492077 0.00000000
/// --------------------------------------
/// Instrument NAME: SC999_INST003
/// FOV shape: RECTANGLE
/// FOV frame: SC999_INST003
/// FOV boresight: 0.00000000 0.00000000 1.00000000
/// FOV corners:
/// 0.01047177 0.00174523 0.99994365
/// -0.01047177 0.00174523 0.99994365
/// -0.01047177 -0.00174523 0.99994365
/// 0.01047177 -0.00174523 0.99994365
/// --------------------------------------
/// Instrument NAME: SC999_INST004
/// FOV shape: POLYGON
/// FOV frame: SC999_INST004
/// FOV boresight: 0.00000000 1.00000000 0.00000000
/// FOV corners:
/// 0.00000000 0.80000000 0.50000000
/// 0.40000000 0.80000000 -0.20000000
/// -0.40000000 0.80000000 -0.20000000
/// --------------------------------------
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) This routine will not operate unless proper mapping between
/// the instrument name INST and a NAIF ID exists, an I-kernel for
/// that instrument ID has been loaded via a call to FURNSH prior
/// to calling this routine and this IK contains the specification
/// for the instrument field of view consistent with the
/// expectations of this routine.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// M. Liukis (JPL)
/// B.V. Semenov (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.0.0, 17-DEC-2021 (JDR) (BVS) (ML)
/// ```
pub fn getfvn(
ctx: &mut SpiceContext,
inst: &str,
room: i32,
shape: &mut str,
frame: &mut str,
bsight: &mut [f64; 3],
n: &mut i32,
bounds: &mut [[f64; 3]],
) -> crate::Result<()> {
GETFVN(
inst.as_bytes(),
room,
fstr::StrBytes::new(shape).as_mut(),
fstr::StrBytes::new(frame).as_mut(),
bsight,
n,
bounds.as_flattened_mut(),
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure GETFVN (Get instrument FOV parameters, by instrument name)
pub fn GETFVN(
INST: &[u8],
ROOM: i32,
SHAPE: &mut [u8],
FRAME: &mut [u8],
BSIGHT: &mut [f64],
N: &mut i32,
BOUNDS: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let save = ctx.get_vars::<SaveVars>();
let save = &mut *save.borrow_mut();
let mut BSIGHT = DummyArrayMut::new(BSIGHT, 1..=3);
let mut BOUNDS = DummyArrayMut2D::new(BOUNDS, 1..=3, 1..);
let mut INSTID: i32 = 0;
let mut FOUND: bool = false;
//
//
// SPICELIB functions
//
//
// Saved instrument name length.
//
//
// Local variables
//
//
// Saved name/ID item declarations.
//
//
// Saved name/ID items.
//
//
// Initial values.
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"GETFVN", ctx)?;
//
// Initialization.
//
if save.FIRST {
//
// Initialize counters.
//
ZZCTRUIN(save.SVCTR1.as_slice_mut(), ctx);
save.FIRST = false;
}
//
// Translate the instrument's name to its ID code
//
ZZBODS2C(
save.SVCTR1.as_slice_mut(),
&mut save.SVINST,
&mut save.SVINID,
&mut save.SVFND1,
INST,
&mut INSTID,
&mut FOUND,
ctx,
)?;
if !FOUND {
SETMSG(b"\'#\' is not a recognized name for an instrument. The cause of this problem may be that you have not loaded a required frame kernel or instrument kernel.", ctx);
ERRCH(b"#", INST, ctx);
SIGERR(b"SPICE(IDCODENOTFOUND)", ctx)?;
CHKOUT(b"GETFVN", ctx)?;
return Ok(());
}
GETFOV(
INSTID,
ROOM,
SHAPE,
FRAME,
BSIGHT.as_slice_mut(),
N,
BOUNDS.as_slice_mut(),
ctx,
)?;
CHKOUT(b"GETFVN", ctx)?;
Ok(())
}