#include <stdlib.h> /* for random(), srandom() */
#include <time.h> /* for time() to seed srandom() */
-#include <Debug/fg_debug.h>
+/* #include <Debug/fg_debug.h> */
#include "fg_random.h"
/* Seed the random number generater with time() so we don't see the
* same sequence every time */
void fg_srandom(void) {
- fgPrintf( FG_MATH, FG_INFO, "Seeding random number generater\n");
+ /* fgPrintf( FG_MATH, FG_INFO, "Seeding random number generater\n"); */
#ifdef HAVE_RAND
srand(time(NULL));
/* $Log$
-/* Revision 1.8 1998/04/25 22:06:23 curt
-/* Edited cvs log messages in source files ... bad bad bad!
+/* Revision 1.9 1998/11/06 21:17:26 curt
+/* Converted to new logstream debugging facility. This allows release
+/* builds with no messages at all (and no performance impact) by using
+/* the -DFG_NDEBUG flag.
/*
+ * Revision 1.8 1998/04/25 22:06:23 curt
+ * Edited cvs log messages in source files ... bad bad bad!
+ *
* Revision 1.7 1998/04/24 00:43:13 curt
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
*
// (Log is kept at end of this file)
-#include <string.h>
+#include <string>
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
#include <Include/fg_zlib.h>
+#include <Misc/fgstream.hxx>
#include "interpolater.hxx"
// Constructor -- loads the interpolation table from the specified
// file
-fgINTERPTABLE::fgINTERPTABLE( char *file ) {
- char fgfile[256], line[256];
- fgFile fd;
-
- fgPrintf( FG_MATH, FG_INFO, "Initializing Interpolator for %s\n", file);
-
- // First try "file.gz"
- strcpy(fgfile, file);
- strcat(fgfile, ".gz");
- if ( (fd = fgopen(fgfile, "rb")) == NULL ) {
- // Next try "path"
- if ( (fd = fgopen(file, "rb")) == NULL ) {
- fgPrintf(FG_MATH, FG_EXIT, "Cannot open file: %s\n", file);
- }
+fgINTERPTABLE::fgINTERPTABLE( const string& file ) {
+ string fgfile, line;
+
+ FG_LOG( FG_MATH, FG_INFO, "Initializing Interpolator for " << file );
+
+ fg_gzifstream in( file );
+ if ( !in ) {
+ FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
+ exit(-1);
}
size = 0;
- while ( fggets(fd, line, 250) != NULL ) {
+ in >> skipcomment;
+ while ( ! in.eof() ){
if ( size < MAX_TABLE_SIZE ) {
- sscanf(line, "%lf %lf\n", &(table[size][0]), &(table[size][1]));
+ in >> table[size][0] >> table[size][1];
size++;
} else {
- fgPrintf( FG_MATH, FG_EXIT,
- "fgInterpolateInit(): Exceed max table size = %d\n",
- MAX_TABLE_SIZE );
+ FG_LOG( FG_MATH, FG_ALERT,
+ "fgInterpolateInit(): Exceed max table size = "
+ << MAX_TABLE_SIZE );
+ exit(-1);
}
}
-
- fgclose(fd);
}
// printf ("i = %d ", i);
if ( (i == 0) && (x < table[0][0]) ) {
- fgPrintf( FG_MATH, FG_ALERT,
- "fgInterpolateInit(): lookup error, x to small = %.2f\n", x);
+ FG_LOG( FG_MATH, FG_ALERT,
+ "fgInterpolateInit(): lookup error, x to small = " << x );
return(0.0);
}
if ( x > table[i][0] ) {
- fgPrintf( FG_MATH, FG_ALERT,
- "fgInterpolateInit(): lookup error, x to big = %.2f\n", x);
+ FG_LOG( FG_MATH, FG_ALERT,
+ "fgInterpolateInit(): lookup error, x to big = " << x );
return(0.0);
}
// $Log$
+// Revision 1.5 1998/11/06 21:17:27 curt
+// Converted to new logstream debugging facility. This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
// Revision 1.4 1998/05/13 18:24:25 curt
// Wrapped zlib calls so zlib can be optionally disabled.
//
#endif
+#include <string>
+
+
#define MAX_TABLE_SIZE 32
// Constructor -- loads the interpolation table from the specified
// file
- fgINTERPTABLE( char *file );
+ fgINTERPTABLE( const string& file );
// Given an x value, linearly interpolate the y value from the table
double interpolate(double x);
// $Log$
+// Revision 1.3 1998/11/06 21:17:28 curt
+// Converted to new logstream debugging facility. This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
// Revision 1.2 1998/04/22 13:18:10 curt
// C++ - ified comments. Make file open errors fatal.
//
# define ios_badbit ios::badbit
# define ios_failbit ios::failbit
-// Dummy up some char traits for now.
-template<class charT> struct char_traits{};
-
-FG_TEMPLATE_NULL
-struct char_traits<char>
-{
- typedef char char_type;
- typedef int int_type;
- typedef streampos pos_type;
- typedef streamoff off_type;
-
- static int_type eof() { return EOF; }
-};
+# include "Include/fg_traits.hxx"
#endif // FG_HAVE_STD_INCLUDES
#endif // _zfstream_hxx
// $Log$
+// Revision 1.5 1998/11/06 21:17:29 curt
+// Converted to new logstream debugging facility. This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
// Revision 1.4 1998/11/06 14:05:16 curt
// More portability improvements by Bernie Bright.
//