void wnvald_c ( SpiceInt size,
SpiceInt n,
SpiceCell * window )
Form a valid double precision window from the contents
of a window array.
WINDOWS
WINDOWS
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
size I Size of window.
n I Original number of endpoints.
window I,O Input, output window.
size is the size of the window to be validated. This
is the maximum number of endpoints that the cell
used to implement the window is capable of holding
at any one time.
n is the original number of endpoints in the input
cell.
window on input, is a (possibly uninitialized) cell array
containing n endpoints of (possibly unordered
and non-disjoint) intervals.
window must be declared as a double precision SpiceCell.
window on output, is a window containing the union of the
intervals in the input cell.
None.
1) If the input window does not have double precision type,
the error SPICE(TYPEMISMATCH) is signaled.
2) If the number of endpoints n is odd, the error
SPICE(UNMATCHENDPTS) is signaled.
3) If the number of end points of the window exceeds its size, the
error SPICE(WINDOWTOOSMALL) is signaled.
4) If any left endpoint is greater than the corresponding right endpoint,
the error SPICE(BADENDPOINTS) is signaled.
None.
This routine takes as input a cell array containing pairs of
endpoints and validates it to form a window.
On input, window is a cell of size size containing n endpoints.
During validation, the intervals are ordered, and overlapping
intervals are merged. On output, the cardinality of window is
the number of endpoints remaining, and window is ready for use with
any of the window routines.
Because validation is done in place, there is no chance of
overflow.
The following small program
#include <stdio.h>
#include <string.h>
#include "SpiceUsr.h"
int main()
{
#define WINSIZ 20
SPICEDOUBLE_CELL ( window, WINSIZ );
SpiceDouble winData [WINSIZ] =
{
0.0, 0.0,
10.0, 12.0,
2.0, 7.0,
13.0, 15.0,
1.0, 5.0,
23.0, 29.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0
};
SpiceInt i;
memmove ( (SpiceDouble *)(window.data),
winData,
WINSIZ * sizeof(SpiceDouble) );
wnvald_c ( 20, 16, &window );
printf ( "Current intervals: %d\n", (int)card_c(&window)/2 );
printf ( "Maximum intervals: %d\n", (int)size_c(&window)/2 );
printf ( "\nIntervals\n\n" );
for ( i = 0; i < card_c(&window); i+=2 )
{
printf ( "%10.6f %10.6f\n",
SPICE_CELL_ELEM_D (&window, i ),
SPICE_CELL_ELEM_D (&window, i+1) );
}
return ( 0 );
}
produces the following output (possibly with different formatting).
Current intervals: 5
Maximum intervals: 10
Intervals
0.000000 0.000000
1.000000 7.000000
10.000000 12.000000
13.000000 15.000000
23.000000 29.000000
None.
None.
N.J. Bachman (JPL)
H.A. Neilan (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.0.3, 12-JUL-2016 (EDW)
Edit to example program to use "%d" with explicit casts
to int for printing SpiceInts with printf.
-CSPICE Version 1.0.2, 18-DEC-2008 (EDW)
Corrected a typo in the version ID of the 08-OCT-2004
Version entry. 1.0.0 changed to 1.0.1.
-CSPICE Version 1.0.1, 08-OCT-2004 (NJB)
Corrected typo in code example; also added "return"
statement to code example.
-CSPICE Version 1.0.0, 29-JUL-2002 (NJB) (HAN) (WLT) (IMU)
validate a d.p. window
Link to routine wnvald_c source file wnvald_c.c
|