rsspice 0.1.0

Pure Rust port of the SPICE Toolkit for space geometry
Documentation
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
//! #  DLA Required Reading
//!
//!  Last revised on 2017 APR 03 by N. J. Bachman.
//!
//!  
//!
//!
//!  
//! ##  Abstract
//!
//!  The "Doubly Linked Array" (DLA) SPICE file format enables data in a
//!    DAS file to be treated as a doubly linked list of virtual arrays, where
//!    each virtual array may contain integer, double precision, and character
//!    components.
//!
//!  
//!
//!
//!  
//! ##  Intended audience
//!
//!  This document is intended primarily for SPICE users who wish to gain a
//!    detailed understanding of the DLA format, particularly users who wish to
//!    create DSK files and sophisticated SPICE users who wish to create their
//!    own DLA-based file formats.
//!
//!  It may also be of interest to SPICE users who wish to access the
//!    segment-oriented routines of the DSK subsystem; however, such users may
//!    find adequate guidance in the code examples provided in API
//!    documentation of those DSK routines and of the DLA routines referenced
//!    by DSK documentation.
//!
//!  Users of DSK files can find documentation of the DSK interface routines
//!    in the DSK Required Reading file, [dsk.req](crate::required_reading::dsk).
//!
//!  
//!
//!
//!  
//! ##  Related Documents
//!
//!  The following documents pertinent to DLA usage are included in the SPICE
//!    Toolkit:
//!
//!  
//!
//! * DAS Required Reading
//!
//!  * DSK Required Reading
//!
//!  * Convert User's Guide
//!
//!  * COMMNT User's Guide
//!
//!     
//! ##  Introduction
//!
//!  The SPICE Doubly Linked Array (DLA) subsystem consists of a Fortran 77
//!    direct access file format and a set of subroutines that make it
//!    convenient to create, read, annotate, and transport files having this
//!    format. The same DLA file format is used by all language versions of
//!    SPICE.
//!
//!  The DLA file format is an instance of the DAS architecture. DLA files
//!    enable user application software to view the data in a DAS file as a
//!    doubly linked list of virtual arrays, usually called "segments," where
//!    each segment may contain character, double precision, and integer
//!    components.
//!
//!  DLA segments provide a mechanism for grouping related data. For example,
//!    in the SPICE DSK format, which is a specialization of the DLA format,
//!    data are grouped into segments; each DSK segment is a DLA segment as
//!    well. DSK segments contain data representing shapes of extended objects.
//!    Such representations may use both integer and double precision data. For
//!    example, in DSK data type 2, segments contain double precision numbers
//!    that represent the vertex coordinates of triangular plates, and integers
//!    that indicate which vertices belong to each plate.
//!
//!  DLA files may be thought of as a functional generalization of DAF files:
//!    DAF arrays contain only double precision data; DLA segments contain data
//!    of multiple types. However, there are some differences that prevent
//!    either format from being a special case of the other:
//!
//!  
//!
//! * DLA is based on the DAS low-level architecture
//!
//!  * DAS access methods differ from DAF methods
//!
//!  * DLA descriptors contain only segment location and size information; DAF
//! descriptors contain both location information and information describing
//! segment contents.
//!
//!  Applications can locate DLA segments by means of forward or backward
//!    linear searches. DLA routines are provided to start a forward or
//!    backward search, and to find the next or previous segment relative to a
//!    given segment.
//!
//!  In the SPICE Toolkit, functionality that makes use of DLA segments' data
//!    is provided by higher-level code, as is the case for the DSK subsystem.
//!
//!  
//!
//!
//!  
//! #  DLA Files
//!
//!  This chapter discusses details of the DLA file format.
//!
//!  
//!
//!
//!  
//! ##  DLA File Structure
//!
//!  DLA files are a special case of DAS files; they inherit all of the
//!    characteristics of DAS files. DAS files, once they have been written,
//!    are normally "segregated," meaning that the character, double
//!    precision, and integer records of a DAS file form three contiguous
//!    components of the respective data types. See the DAS Required Reading,
//!    [das.req](crate::required_reading::das), for details.
//!
//!  The underlying DAS architecture, in its segregated form, is:
//!
//!  
//!
//! ```text
//!         File component          Record count
//!         ==============          ============
//!  
//!    +------------------------+
//!    |      file record       |   ( 1 )
//!    +------------------------+
//!    |    reserved records    |   ( variable )
//!    +------------------------+
//!    |    comment records     |
//!    |                        |   ( variable )
//!    |                        |
//!    +------------------------+
//!    | first data directory   |   ( 1 )
//!    +------------------------+
//!    | character data records |
//!    |                        |   ( variable )
//!    |                        |
//!    +------------------------+
//!    |   d.p. data records    |
//!    |                        |   ( variable )
//!    |                        |
//!    +------------------------+
//!    |  integer data records  |
//!    |                        |   ( variable )
//!    |                        |
//!    +------------------------+
//! ```
//!
//!  The DLA format presents a higher-level view of the DAS architecture. For
//!    most purposes, DLA files can be thought of as having the following
//!    logical components:
//!
//!  
//!
//! ```text
//!    +----------------------------+
//!    |       file record          |
//!    +----------------------------+
//!    |       comment area         |
//!    |                            |
//!    |                            |
//!    +----------------------------+
//!    | DLA format version         |
//!    +----------------------------+
//!    | DLA forward and backward   |
//!    | pointers                   |
//!    +----------------------------+
//!    | DLA descriptors            |
//!    +----------------------------+
//!    | first virtual DLA segment  |
//!    +----------------------------+
//!    | second virtual DLA segment |
//!    |                            |
//!    |                            |
//!    +----------------------------+
//!               ...
//!    +----------------------------+
//!    | last virtual DLA segment   |
//!    |                            |
//!    +----------------------------+
//! ```
//!
//!  The diagram above does not show the physical order of the segments,
//!    since segment data are distributed across the character, double
//!    precision, and integer records of the file, and since DLA descriptors
//!    are interleaved with DLA segments' integer components.
//!
//!  Details of these components are discussed below.
//!
//!  
//!
//!
//!  
//! ###  The DLA File Record
//!
//!  In a DLA file, the file record conforms to the DAS file record format.
//!    See the DAS Required Reading, [das.req](crate::required_reading::das), for a complete description of
//!    this format. Within the file record, the ID word has the format
//!
//!  
//!
//! ```text
//!    DAS/xxxx
//! ```
//!
//!  where the pattern
//!
//!  
//!
//! ```text
//!    xxxx
//! ```
//!
//!  represents up to four printing characters identifying the file type. For
//!    example, in DSK files, the ID word is
//!
//!  
//!
//! ```text
//!    DAS/DSK
//! ```
//!
//!  In general the portion of the ID word indicating file type need not
//!    indicate explicitly that the file is a DLA file. That fact can be
//!    derived from the file type string if the type is known to the SPICE
//!    system.
//!
//!  
//!
//!
//!  
//! ###  DLA Comment Area
//!
//!  All properties of the DLA comment area are inherited from the DAS
//!    architecture. DAS routines are used to access the comment area
//!    programmatically. The SPICE COMMNT utility can access the DLA comment
//!    area interactively.
//!
//!  
//!
//!
//!  
//! ###  DLA Format Version
//!
//!  The first member of a DLA file's integer address space is a parameter
//!    indicating the format version of the file. The primary purpose of this
//!    parameter is to indicate that the file is a DLA file. If the format is
//!    updated, this version will allow SPICE software to identify the version
//!    and access the file appropriately.
//!
//!  SPICE identifies DLA files using a combination of three attributes:
//!
//!  
//!
//! *  1. The file architecture, which must be DAS
//!
//!  *  2. The file type, which must be recognized as one derived from the DLA format,
//! for example DSK
//!
//!  *  3. The DLA format version
//!
//!     
//! ###  DLA Forward and Backward Pointers
//!
//!  The segments of a DLA file are organized as a doubly linked list. The
//!    DLA file contains pointers to data structures called "segment
//!    descriptors," which are associated with segments, at the head and tail
//!    of the list. These pointers are used to initiate forward and backward
//!    searches.
//!
//!  
//!
//!
//!  
//! ###  DLA Segment Descriptors
//!
//!  A DLA "segment descriptor," or simply "descriptor," is a small array
//!    of integers that indicate the sizes and addresses of the components of a
//!    corresponding DLA segment. A DLA descriptor also contains integers that
//!    act as forward and backward pointers to other DLA descriptors in the DLA
//!    file's doubly linked segment list.
//!
//!  DLA descriptors are also data structures used as input and output
//!    arguments of DLA routines. They are also used extensively as arguments
//!    to DSK routines; the DSK subsystem is currently the only other SPICE
//!    subsystem where they're used. In the Fortran, IDL, and MATLAB SPICE
//!    Toolkits, DLA descriptors are implemented as arrays. In the CSPICE
//!    Toolkit, DLA descriptors are implemented by the structure SpiceDLADescr.
//!
//!  The DLA segment descriptor members are:
//!
//!  
//!
//! ```text
//!    +---------------+
//!    | BACKWARD PTR  | Linked list backward pointer
//!    +---------------+
//!    | FORWARD PTR   | Linked list forward pointer
//!    +---------------+
//!    | BASE INT ADDR | Base DAS integer address
//!    +---------------+
//!    | INT COMP SIZE | Size of integer segment component
//!    +---------------+
//!    | BASE DP ADDR  | Base DAS d.p. address
//!    +---------------+
//!    | DP COMP SIZE  | Size of d.p. segment component
//!    +---------------+
//!    | BASE CHR ADDR | Base DAS character address
//!    +---------------+
//!    | CHR COMP SIZE | Size of character segment component
//!    +---------------+
//!  
//! ```
//!
//!  The "base address" of a segment component of a given data type is the
//!    address, in the DAS address space of that type, preceding the first
//!    element of that component. All DAS addresses are 1-based.
//!
//!  The general form of the doubly linked list layout in DAS integer address
//!    space is:
//!
//!  
//!
//! ```text
//!  
//!                  +------------------------------+
//!                  |  Pointer to first descriptor | ----+
//!                  +------------------------------+     |
//!    +-------------|  Pointer to last descriptor  |     |
//!    |             +------------------------------+     |
//!    |                                                  |
//!    |             +------------------------------+     |
//!    |  NULL <---- |  Backward pointer            | <---+ First node
//!    |       +---> |                              |
//!    |       |     +------------------------------+
//!    |       |     |  Forward pointer             | ----+
//!    |       |     +------------------------------+     |
//!    |       |     |  Rest of DLA Descriptor 1    |     |
//!    |       |     +------------------------------+     |
//!    |       |     |  Segment 1 integer component |     |
//!    |       |     +------------------------------+     |
//!    |       +---- |  Backward pointer            | <---+ Second node
//!    |       +---> |                              |
//!    |       |     +------------------------------+
//!    |       |     |  Forward pointer             | ----+
//!    |       |     +------------------------------+     |
//!    |       |     |  Rest of DLA Descriptor 2    |     |
//!    |       |     +------------------------------+     |
//!    |       |     |  Segment 2 integer component |     |
//!    |       |     +------------------------------+     |
//!    |  pointer from third node                     <---+ Third node
//!    |                            .
//!    |                            .
//!    |                            .
//!    |  pointer to node N-1                  pointer from node N-1
//!    |       |                                          |
//!    |       |     +------------------------------+     |
//!    +--->   +---- |  Backward pointer            | <---+ Final (Nth) node
//!                  +------------------------------+
//!                  |  Forward pointer             | ----> NULL
//!                  +------------------------------+
//!                  |  Rest of DLA Descriptor N    |
//!                  +------------------------------+
//!                  |  Segment N integer component |
//!                  +------------------------------+
//!  
//! ```
//!
//!  While this diagram shows the presence of multiple segments, a DLA file
//!    need not contain more than one segment. It is valid, but usually not
//!    useful, for a DLA file to have no segments.
//!
//!  
//!
//!
//!  
//! ##  DLA Segment Layout
//!
//!  The data populating a DLA file are stored in the file's segments.
//!
//!  The segments of a DLA file consist of components in the respective DAS
//!    character, double precision, and integer address spaces. The components
//!    occupy contiguous address ranges in the respective address spaces.
//!
//!  The general form of the DLA segment layout is:
//!
//!  
//!
//! ```text
//!  
//!    Character space   Double precision space   Integer space
//!  
//!    +-------------+   +--------------------+
//!    |Segment 1    |   |Segment 1           |  +------------+
//!    |character    |   |double precision    |  |Segment 1   |
//!    |component    |   |component           |  |integer     |
//!    +-------------+   |                    |  |component   |
//!    |Segment 2    |   |                    |  |            |
//!    |character    |   +--------------------+  |            |
//!    |component    |   |Segment 2           |  +------------+
//!    |             |   |double precision    |
//!    +-------------+   |component           |  +------------+
//!                      +--------------------+  |Segment 2   |
//!                                              |integer     |
//!                                              |component   |
//!                                              +------------+
//!         ...                   ...                 ...
//!  
//! ```
//!
//!  In the diagram above, the first integer segment component is displaced
//!    downward slightly to indicate that the first component starts at an
//!    integer address greater than 1: that component is preceded by other
//!    information. DLA descriptors lie between consecutively numbered integer
//!    components, so those components are not contiguous.
//!
//!  Any of the segment components may be empty, but the DAS integer address
//!    space is never empty.
//!
//!  In a segregated DLA file, all segment components of a given type are
//!    stored sequentially in the DAS address space of that type.
//!
//!  
//!
//!
//!  
//! #  DLA Routines
//!
//!  Access to DLA files is provided by DLA routines and routines of the
//!    SPICE DAS subsystem.
//!
//!  In all languages supported by SPICE, the DLA subsystem provides routines
//!    for traversing DLA segment lists. Although the term is somewhat
//!    inaccurate, this is usually referred to as "searching" the lists.
//!
//!  Routines of the DAS subsystem enable applications to open a DLA file for
//!    read access, close a DLA file, and extract comments from a DLA file's
//!    comment area.
//!
//!  In the Fortran and C SPICE Toolkits, DAS routines can open an existing
//!    DLA file for write access and delete or write to a DLA file's comment
//!    area.
//!
//!  In the Fortran SPICE Toolkit, DLA routines are provided to open a new
//!    DLA file and to start and finish new DLA segments. DAS routines are
//!    provided to write data to DLA segments, read data from DLA segments, and
//!    update data in existing DLA segments.
//!
//!  
//!
//!
//!  
//! ###  Summary of DLA Mnemonics
//!
//!  All of the subroutines in the DLA family have names beginning with the
//!    letters "DLA," followed by a two- or three-character mnemonic. For
//!    example, the routine that starts a forward search through the segment
//!    descriptor list in a DLA file is named [DLABFS](crate::raw::dlabfs), pronounced "DLA-B-F-S."
//!    The following is a complete list of DLA mnemonics and translations, in
//!    alphabetical order.
//!
//!  
//!
//! ```text
//!    BBS  Begin backward search
//!    BFS  Begin forward search
//!    BNS  Begin new segment
//!    ENS  End new segment
//!    FNS  Find next segment
//!    FPS  Find previous segment
//!    OPN  Open new DLA file
//!    SSG  Test for same segment
//! ```
//!
//!     
//! ###  Summary of DAS Mnemonics
//!
//!  The DAS routines whose mnemonics are listed below serve as part of the
//!    DLA system's interface.
//!
//!  
//!
//! ```text
//!    AC   Add comments from buffer to file
//!    ADC  Add character data to file
//!    ADD  Add double precision data to file
//!    ADI  Add integer data to file
//!    CLS  Close file
//!    DC   Delete comments from file
//!    EC   Extract comments from file
//!    OPR  Open file for read access
//!    OPW  Open file for write access
//!    RDC  Read character data from file
//!    RDD  Read double precision data from file
//!    RDI  Read integer data from file
//!    UDC  Update character data in file
//!    UDD  Update double precision data in file
//!    UDI  Update integer data in file
//! ```
//!
//!     
//! ###  Summary of Calling Sequences
//!
//!  Calling sequences of the DLA family of routines are given below.
//!    Routines are grouped according to function.
//!
//!  The following routines are intended for use by both SPICELIB users'
//!    application programs and by SPICELIB routines.
//!
//!  Opening and closing files:
//!
//!  
//!
//! ```text
//!    DASCLS ( HANDLE )
//!    DASOPR ( FNAME, HANDLE )
//!    DLAOPN ( FNAME, FTYPE, IFNAME, NRESV, HANDLE )
//!    DASOPW ( FNAME, HANDLE )
//! ```
//!
//!  Beginning and ending new segments:
//!
//!  
//!
//! ```text
//!    DLABNS ( HANDLE )
//!    DLAENS ( HANDLE )
//! ```
//!
//!  Adding data to files:
//!
//!  
//!
//! ```text
//!    DASADC ( HANDLE, N, BPOS, EPOS, DATA )
//!    DASADD ( HANDLE, N,             DATA )
//!    DASADI ( HANDLE, N,             DATA )
//! ```
//!
//!  Updating data in files:
//!
//!  
//!
//! ```text
//!    DASUDC ( HANDLE, FIRST, LAST, BPOS, EPOS, DATA )
//!    DASUDD ( HANDLE, FIRST, LAST,             DATA )
//!    DASUDI ( HANDLE, FIRST, LAST,             DATA )
//! ```
//!
//!  Reading data from files:
//!
//!  
//!
//! ```text
//!    DASRDC ( HANDLE, FIRST, LAST, BPOS, EPOS, DATA )
//!    DASRDD ( HANDLE, FIRST, LAST,             DATA )
//!    DASRDI ( HANDLE, FIRST, LAST,             DATA )
//! ```
//!
//!  Searching for segments:
//!
//!  
//!
//! ```text
//!    DLABBS ( HANDLE, DESCR, FOUND )
//!    DLAFNS ( HANDLE, DESCR, NXTDSC, FOUND )
//!    DLAFPS ( HANDLE, DESCR, PRVDSC, FOUND )
//!    DLABFS ( HANDLE, DESCR, FOUND )
//! ```
//!
//!  Accessing the comment area:
//!
//!  
//!
//! ```text
//!    DASAC ( HANDLE, N, BUFFER )
//!    DASDC ( HANDLE )
//!    DASEC ( HANDLE, BUFSIZ, N, BUFFER, DONE )
//! ```
//!
//!  Comparing DLA segment descriptors
//!
//!  
//!
//! ```text
//!    DLASSG
//! ```
//!
//!     
//! #  Appendix A: Revision History
//!
//!  
//!
//!
//!  
//! ###  2017 APR 03 by N. J. Bachman
//!
//!  Initial release.
//!
//!  
//!
//!
//!