From 55426f4170ed9dc777c3cec3741e4a59e6eebd38 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 6 Dec 2000 15:17:51 +0000 Subject: [PATCH] r248: msvc changes --- include/array2dfile.h | 4 ++-- include/ct.h | 20 +++++++++++++------- include/ctsupport.h | 10 +++++----- include/ezplot.h | 4 ++-- include/sgp.h | 6 +++--- libctgraphics/ezset.cpp | 6 +++--- libctsim/array2dfile.cpp | 16 +++++++++------- libctsim/backprojectors.cpp | 8 +++++--- libctsupport/clip.cpp | 10 +++++----- 9 files changed, 47 insertions(+), 37 deletions(-) diff --git a/include/array2dfile.h b/include/array2dfile.h index 9af82a7..512772d 100644 --- a/include/array2dfile.h +++ b/include/array2dfile.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: array2dfile.h,v 1.8 2000/12/04 04:15:48 kevin Exp $ +** $Id: array2dfile.h,v 1.9 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -33,7 +33,7 @@ #endif #include -#include +#include #include #include #include diff --git a/include/ct.h b/include/ct.h index 0928b91..84e139f 100644 --- a/include/ct.h +++ b/include/ct.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ct.h,v 1.41 2000/12/04 05:36:57 kevin Exp $ +** $Id: ct.h,v 1.42 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -29,12 +29,13 @@ #define CT_H #ifdef MSVC - extern "C" {int strcasecmp(const char*, const char*);} + // extern "C" {int strcasecmp(const char*, const char*);} typedef long off_t; - #define HAVE_STRING_H 1 - #include - #define strcasecmp stricmp - #define strncasecmp strnicmp + #define HAVE_STRING_H 1 + #include + #define strdup _strdup + #define strcasecmp _stricmp + #define strncasecmp _strnicmp #endif #ifdef HAVE_CONFIG_H @@ -52,8 +53,13 @@ #include #include using namespace std; - + +#if defined(MSVC) || HAVE_SSTREAM #include +#else +#include +#endif + #include #include #include diff --git a/include/ctsupport.h b/include/ctsupport.h index 60a6c2c..ac3ffe0 100644 --- a/include/ctsupport.h +++ b/include/ctsupport.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ctsupport.h,v 1.8 2000/12/06 01:46:43 kevin Exp $ +** $Id: ctsupport.h,v 1.9 2000/12/06 15:17:51 kevin Exp $ ** ** ** This program is free software; you can redistribute it and/or modify @@ -252,10 +252,10 @@ inline void minmax_array (const T* array, const int n, T& min, T& max) // clip.cpp bool clip_rect (double& x1, double& y1, double& x2, double& y2, const double rect[4]); -int clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, const double v); -int clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, const double v); -int clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2); -int clip_triangle (double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis); +bool clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, const double v); +bool clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, const double v); +bool clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2); +bool clip_triangle (double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis); // xform.cpp diff --git a/include/ezplot.h b/include/ezplot.h index 11f95ba..c15428b 100644 --- a/include/ezplot.h +++ b/include/ezplot.h @@ -7,7 +7,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: ezplot.h,v 1.16 2000/12/06 01:46:43 kevin Exp $ +** $Id: ezplot.h,v 1.17 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -208,7 +208,7 @@ class EZPlot { void clearCurves (); bool ezcmd (char *comm); - int do_cmd(int lx); + bool do_cmd(int lx); void bad_option(char *opt); void initPlotSettings(); diff --git a/include/sgp.h b/include/sgp.h index f30f582..174d83b 100644 --- a/include/sgp.h +++ b/include/sgp.h @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: sgp.h,v 1.20 2000/12/06 01:46:43 kevin Exp $ +** $Id: sgp.h,v 1.21 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -86,10 +86,10 @@ public: { return m_sWindowTitle; } bool isWX () const - { return (m_idDriver & SGPDRIVER_WXWINDOWS); } + { return (m_idDriver & SGPDRIVER_WXWINDOWS ? true : false); } bool isG2 () const - { return (m_idDriver & SGPDRIVER_G2); } + { return (m_idDriver & SGPDRIVER_G2 ? true : false); } int idG2 () const { return m_idG2; } diff --git a/libctgraphics/ezset.cpp b/libctgraphics/ezset.cpp index e4f6abf..4e68671 100644 --- a/libctgraphics/ezset.cpp +++ b/libctgraphics/ezset.cpp @@ -6,7 +6,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** - ** $Id: ezset.cpp,v 1.8 2000/12/06 01:46:43 kevin Exp $ + ** $Id: ezset.cpp,v 1.9 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -74,7 +74,7 @@ EZPlot::ezcmd (char *comm) } -int +bool EZPlot::do_cmd (int lx) { char str [1024]; @@ -368,7 +368,7 @@ EZPlot::do_cmd (int lx) } pol_reader (); - return (TRUE); + return (true); } diff --git a/libctsim/array2dfile.cpp b/libctsim/array2dfile.cpp index b16c7d3..e35a149 100644 --- a/libctsim/array2dfile.cpp +++ b/libctsim/array2dfile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: array2dfile.cpp,v 1.15 2000/12/06 01:46:43 kevin Exp $ +** $Id: array2dfile.cpp,v 1.16 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -26,9 +26,10 @@ ******************************************************************************/ #include "array2dfile.h" -#include -#include - +#include +#ifdef MSVC +typedef long off_t; +#endif using namespace std; @@ -108,9 +109,10 @@ Array2dFileLabel::getDateTime (int& year, int& month, int& day, int& hour, int& const string& Array2dFileLabel::getDateString (void) const { - ostringstream oss; - oss << static_cast(m_month + 1) <<"/"<< static_cast(m_day) <<"/"<< static_cast(m_year + 1900) << " " << static_cast(m_hour) <<":"<< static_cast(m_minute) <<":"<< static_cast(m_second); - m_strDate = oss.str(); + char szDate [128]; + snprintf (szDate, sizeof(szDate), "%2d/%02d/%4d %02d:%02d:%02d", + m_month + 1, m_day, m_year + 1900, m_hour, m_minute, m_second); + m_strDate = szDate; return m_strDate; } diff --git a/libctsim/backprojectors.cpp b/libctsim/backprojectors.cpp index ecdc3fd..0d3cd80 100644 --- a/libctsim/backprojectors.cpp +++ b/libctsim/backprojectors.cpp @@ -8,7 +8,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: backprojectors.cpp,v 1.17 2000/12/06 01:46:43 kevin Exp $ +** $Id: backprojectors.cpp,v 1.18 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -299,7 +299,8 @@ void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, doubl } void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, double L, int iDetPos) -{ +{ +#if 1 ostringstream os; os << "ix=" << ix << ", iy=" << iy << ", theta=" << theta << ", L=" << L << ", detinc=" << detInc << "\n"; os << "ndet=" << nDet << ", detInc=" << detInc << ", iDetCenter=" << iDetCenter << "\n"; @@ -307,7 +308,8 @@ void Backproject::errorIndexOutsideDetector (int ix, int iy, double theta, doubl os << "yMin=" << yMin << ", yMax=" << yMax << ", yInc=" << yInc << "\n"; os << "iDetPos index outside bounds: " << iDetPos << " [backprojector]";; - sys_error (ERR_WARNING, os.str().c_str()); + sys_error (ERR_WARNING, os.str().c_str()); +#endif } diff --git a/libctsupport/clip.cpp b/libctsupport/clip.cpp index 2123c29..3ff8b08 100644 --- a/libctsupport/clip.cpp +++ b/libctsupport/clip.cpp @@ -14,7 +14,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: clip.cpp,v 1.5 2000/12/06 01:46:43 kevin Exp $ +** $Id: clip.cpp,v 1.6 2000/12/06 15:17:51 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -42,7 +42,7 @@ * double u,v Dimensions of segment */ -int +bool clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, const double v) { double xc1 = x1 * u; @@ -88,7 +88,7 @@ clip_segment (double& x1, double& y1, double& x2, double& y2, const double u, co * double u,v Size of sector */ -int +bool clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, const double v) { double xc1 = x1 * u; @@ -124,7 +124,7 @@ clip_sector (double& x1, double& y1, double& x2, double& y2, const double u, con * double t1,t2 Starting & stopping angles of clipping */ -int +bool clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, const double cy, const double radius, double t1, double t2) { double xc1 = x1; @@ -241,7 +241,7 @@ clip_circle (double& x1, double& y1, double& x2, double& y2, const double cx, co static int tcode (const double x, const double y, const double m, const double b, const int clip_xaxis); -int +bool clip_triangle (double& x1, double& y1, double& x2, double& y2, const double u, const double v, const int clip_xaxis) { double m = v / u; // slope of triangle lines -- 2.34.1