From 4114001db83630028afd31d215df560f8d682b22 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 6 Dec 2000 01:55:08 +0000 Subject: [PATCH] r247: *** empty log message *** --- libctgraphics/ctm.cpp | 230 ------------------------------------------ libctsim/dialogs.cpp | 222 ---------------------------------------- 2 files changed, 452 deletions(-) delete mode 100644 libctgraphics/ctm.cpp delete mode 100644 libctsim/dialogs.cpp diff --git a/libctgraphics/ctm.cpp b/libctgraphics/ctm.cpp deleted file mode 100644 index ec61c29..0000000 --- a/libctgraphics/ctm.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: ctm.cpp,v 1.2 2000/06/19 19:04:05 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 -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ - -/*----------------------------------------------------------------------------- - * FILE IDENTIFICATION - * - * Name: ctm.c - * Function: Current Transform Matrix routine for graphic library - * Programmer: Kevin Rosenberg - * Date Started: 1-22-85 - * - * FUNCTION SUMMARY - * ctm_xlat_pre_2 () - * ctm_xlat_post_2 () - * ctm_scale_pre_2 () - * ctm_scale_post_2 () - * ctm_rotate_pre_2 () - * ctm_rotate_post_2 () - * - * NOTES - * The indices on the 2d matrix are opposite of the cartesian order used - * in the sdf_2d files. Here, the 1st index is the row & and 2nd is the - * column - *---------------------------------------------------------------------------*/ - -#include "ctsupport.h" -#include -#include "sgp.h" - - -/*---------------------------------------------------------------------------*/ -/* Geometric Operations */ -/*---------------------------------------------------------------------------*/ - -void -ctm_xlat_pre_2 (double x, double y) -{ - GRFMTX_2D m; - - xlat_gmtx_2 (m, x, y); - ctm_pre_mult_2 (m); -} - - -void -ctm_xlat_post_2 (double x, double y) -{ - GRFMTX_2D m; - - xlat_gmtx_2 (m, x, y); - ctm_post_mult_2 (m); -} - - -void -ctm_scale_pre_2 (double sx, double sy) -{ - GRFMTX_2D m; - - scale_gmtx_2 (m, sx, sy); - ctm_pre_mult_2 (m); -} - - -void -ctm_scale_post_2 (double sx, double sy) -{ - GRFMTX_2D m; - - scale_gmtx_2 (m, sx, sy); - ctm_post_mult_2 (m); -} - - -void -ctm_rotate_pre_2 (double theta) -{ - GRFMTX_2D m; - - rotate_gmtx_2 (m, theta); - ctm_pre_mult_2 (m); -} - - -void -ctm_rotate_post_2 (double theta) -{ - GRFMTX_2D m; - - rotate_gmtx_2 (m, theta); - ctm_post_mult_2 (m); -} - - -void -ctm_shear_pre_2 (double shrx, double shry) -{ - GRFMTX_2D m; - - shear_gmtx_2 (m, shrx, shry); - ctm_pre_mult_2 (m); -} - - -void -ctm_shear_post_2 (double shrx, double shry) -{ - GRFMTX_2D m; - - shear_gmtx_2 (m, shrx, shry); - ctm_post_mult_2 (m); -} - -/*---------------------------------------------------------------------------*/ -/* Low-Level Internal Functions */ -/*---------------------------------------------------------------------------*/ - - -void -xlat_gmtx_2 (GRFMTX_2D m, double x, double y) -{ - ident_gmtx_2 (m); - m[2][0] = x; - m[2][1] = y; -} - - -void -scale_gmtx_2 (GRFMTX_2D m, double sx, double sy) -{ - ident_gmtx_2 (m); - m[0][0] = sx; - m[1][1] = sy; -} - - -void -shear_gmtx_2 (GRFMTX_2D m, double shrx, double shry) -{ - ident_gmtx_2 (m); - m[1][0] = shrx; - m[0][1] = shry; -} - -void -rotate_gmtx_2 (GRFMTX_2D m, double theta) -{ - double s, c; - - s = sin (theta); - c = cos (theta); - - ident_gmtx_2 (m); - - m[0][0] = c; m[0][1] = s; - m[1][0] = -s; m[1][1] = c; -} - - -void -ident_gmtx_2 (GRFMTX_2D m) -{ - m[0][0] = 1.; m[0][1] = 0.; m[0][2] = 0.; - m[1][0] = 0.; m[1][1] = 1.; m[1][2] = 0.; - m[2][0] = 0.; m[2][1] = 0.; m[2][2] = 1.; -} - - -void -mult_gmtx_2 (GRFMTX_2D a, GRFMTX_2D b, GRFMTX_2D c) -{ - int row, col, calc; - - for (row = 0; row < 3; row++) - for (col = 0; col < 3; col++) { - c[row][col] = 0.; - for (calc = 0; calc < 3; calc++) - c[row][col] += a[row][calc] * b[calc][col]; - } -} - -void -invert_gmtx_2 (GRFMTX_2D a, GRFMTX_2D b) -{ - double determ; - - determ = determ_gmtx_2 (a); - if (fabs(determ) < 1E-6) - sys_error (ERR_WARNING, "Determinant = %lg [invert_gmtx_2]", determ); - - b[0][0] = (a[1][1] * a[2][2] - a[2][1] * a[1][2]) / determ; - b[1][0] = -(a[1][0] * a[2][2] - a[2][0] * a[1][2]) / determ; - b[2][0] = (a[1][0] * a[2][1] - a[2][0] * a[1][1]) / determ; - - b[0][1] = -(a[0][1] * a[2][2] - a[2][1] * a[0][2]) / determ; - b[1][1] = (a[0][0] * a[2][2] - a[2][0] * a[0][2]) / determ; - b[2][1] = -(a[0][0] * a[2][1] - a[2][0] * a[0][1]) / determ; - - b[0][2] = (a[0][1] * a[1][2] - a[1][1] * a[0][2]) / determ; - b[1][2] = -(a[0][0] * a[1][2] - a[1][0] * a[0][2]) / determ; - b[2][2] = (a[0][0] * a[1][1] - a[1][0] * a[0][1]) / determ; -} - - -double -determ_gmtx_2 (GRFMTX_2D a) -{ - return - (a[0][0] * a[1][1] * a[2][2] - a[0][0] * a[2][1] * a[1][2] - - a[0][1] * a[1][0] * a[2][2] + a[0][1] * a[2][0] * a[1][2] + - a[0][2] * a[1][0] * a[2][1] - a[0][2] * a[2][0] * a[1][1]); -} - diff --git a/libctsim/dialogs.cpp b/libctsim/dialogs.cpp deleted file mode 100644 index e73f6e1..0000000 --- a/libctsim/dialogs.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/***************************************************************************** -** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg -** -** $Id: dialogs.cpp,v 1.2 2000/06/22 10:42:39 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 -** published by the Free Software Foundation. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -******************************************************************************/ - -#include "ct.h" - -/************************************************************************* - * FUNCTION DECLARATIONS - ************************************************************************/ - -// dialogs.cpp -bool phm_add_pelem_kb (Phantom& phm); -const Phantom& phm_select (Phantom& phm); -int interpolation_select (void); -int filter_select (double *filter_param); - - -/* NAME - * phm_add_pelem_kb Let user specify pelem, and add it to the pic - * - * SYNOPSIS - * phm_add_pelem_kb (phm) - * Phantom& pic PHANTOM that we are to add pelem to - * - * RETURNS - * true if user added an pelem to PHANTOM - * false if user decided not to add an pelem to the PHANTOM - */ - -bool -phm_add_pelem_kb (Phantom& phm) -{ - int retval = false; - - do { - int pelemtype; - - crt_clrline (1); - crt_clrline (2); - crt_set_cpos (1, 2); - crt_put_str ("1 = Rectangle, 2 = Triangle, 3 = Ellipse, 4 = Sector, 5 = Segment"); - crt_set_cpos (1, 1); - crt_put_str ("Enter pelem type (1-5, 0 = no pelem) -- "); - scanf ("%d", &pelemtype); - crt_clrline (1); - crt_clrline (2); - - if (pelemtype < 1) { - retval = false; - } else { - double cx, cy, u, v, rot, dens; - - retval = true; - crt_set_cpos (1, 1); - crt_put_str ("Enter pelem specs (cx, cy, u, v, rot, density) -- "); - scanf ("%lf %lf %lf %lf %lf %lf %*c", &cx, &cy, &u, &v, &rot, &dens); - crt_clrline (1); - phm.addPelem (phm, pelemtype, cx, cy, u, v, rot, dens); - } - } while (retval == true); - - return (true); -} - -const Phantom& phm_select (Phantom& phm) -{ - string fname; - int phmnum; - - printf ("Which phantom do you want to compile into pixels:\n"); - printf (" 1 - Herman head phantom\n"); - printf (" 2 - Rowland head phantom\n"); - printf (" 3 - \n"); - printf (" 4 - Rowland head phantom (Bordered)\n"); - printf (" 6 - A Filter\n"); - printf (" 7 - Unit pulse\n"); - printf (" 8 - Enter PHANTOM from file\n"); - printf (" 9 - Enter PHANTOM from keyboard\n"); - printf ("Enter the number corresponding to your choice: "); - scanf ("%d%*c", &phmnum); - - switch (phmnum) { - case 1: - phm.std_herman (); - break; - case 2: - phm.std_rowland (); - break; - case 4: - phm.std_rowland_bordered (); - break; - case 6: - phm.setComposition (P_FILTER); - break; - case 7: - phm.setComposition (P_UNIT_PULSE); - phm.addPelem (1, 0., 0., 100., 100., 0., 0.); /* outline */ - phm.addPelem (3, 0., 0., 1., 1., 0., 1.); /* pulse */ - break; - case 8: - printf ("Enter name of file: "); - scanf ("%s %*c", fname); - phm.setComposition (P_PELEMS); - if (phm.createFromFile (fname) == false) - cerr << "File " << fname << " doesn't contain valid Phantom declaration" << endl; - break; - case 9: - crt_clrscrn (); - phm_add_pelem_kb (phm); - crt_clrscrn (); - break; - default: - sys_error (ERR_FATAL, "Illegal Phantom number %d\n", phmnum); - break; - } - - return (phm); -} - -/* NAME - * interpolation_select Let user select an interpolation method - * - * SYNOPSIS - * interpolation_type = interpolation_select() - * int interpolation_type Method of interpolation to use - */ - -int interpolation_select (void) -{ - bool got_it = false; - - do { - int interp_type; - - printf ("What interpolation method do you want to use:\n"); - printf (" %2d - Nearest neighbor\n", I_NEAREST); - printf (" %2d - Linear\n", I_LINEAR); - printf (" %2d - B-Spline\n", I_BSPLINE); - printf ("Enter number corresponding to desired method: "); - scanf ("%d", &interp_type); - printf ("\n"); - - if (interp_name_of (interp_type) == NULL) { - cout << endl; - cio_beep (); - } else - got_it = true; - - } while (! got_it); - - return (interp_type); -} - - -/* NAME - * filter_select Let user select a filter - * - * SYNOPSIS - * filter_type = filt_select (filt_param) - * int filt_type Type of filter to use - * double *filt_param Returns parameter to filter - * Currently, only used with Hamming filters - */ - -int -filter_select (double *filt_param) -{ - bool got_it = false; - - do { - int filt_type; - - printf ("Which filter would you like to use:\n"); - printf (" %2d - Bandlimiting\n", FILTER_BANDLIMIT); - printf (" %2d - Sinc\n", FILTER_SINC); - printf (" %2d - Hamming\n", FILTER_G_HAMMING); - printf (" %2d - Cosine\n", FILTER_COSINE); - printf (" %2d - Triangle\n", FILTER_TRIANGLE); - printf (" %2d - Abs * Bandlimit\n", FILTER_ABS_BANDLIMIT); - printf (" %2d - Abs * Sinc\n", FILTER_ABS_SINC); - printf (" %2d - Abs * Hamming \n", FILTER_ABS_G_HAMMING); - printf (" %2d - Abs * Cosine\n", FILTER_ABS_COSINE); - printf (" %2d - Shepp-Logan\n", FILTER_SHEPP); - printf ("Enter number corresponding to desired filter: "); - scanf ("%d", &filt_type); - - if (filter_name_of (filt_type) == NULL) { - printf ("\n"); - cio_beep (); - } else - got_it = true; - - } while (! got_it); - - if (filt_type == FILTER_G_HAMMING || filt_type == FILTER_ABS_G_HAMMING) { - cout << "Enter alpha (0-1): " << flush; - cin >> *filt_param; - } else - *filt_param = 0.0; - - return (filt_type); -} - - - - -- 2.34.1