From 63ddd1048df804cc73f21c1cdaf70f32324d0197 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 19 Jun 2000 18:45:36 +0000 Subject: [PATCH] r107: initial cvs import --- include/phantom.h | 176 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 include/phantom.h diff --git a/include/phantom.h b/include/phantom.h new file mode 100644 index 0000000..21b08c4 --- /dev/null +++ b/include/phantom.h @@ -0,0 +1,176 @@ +/***************************************************************************** +** FILE IDENTIFICATION +** +** Name: phantom.h +** Purpose: Header file for Phantom objects +** Programmer: Kevin Rosenberg +** Date Started: July 1, 1984 +** +** This is part of the CTSim program +** Copyright (C) 1983-2000 Kevin Rosenberg +** +** $Id: phantom.h,v 1.1 2000/06/19 18:45:36 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 +******************************************************************************/ + +#ifndef PHANTOM_H +#define PHANTOM_H + +#include +using namespace std; + +typedef enum { + PELEM_INVALID, + PELEM_RECTANGLE, + PELEM_TRIANGLE, + PELEM_ELLIPSE, + PELEM_SECTOR, + PELEM_SEGMENT +} PhmElemType; + +/* Codes for Coordinate Types */ +/* Defines coords for isPointInside() */ + +typedef enum { + PELEM_COORD, /* Normalized PElem Coordinates */ + PHM_COORD /* World phantom Coordinates */ +} CoordType; + + +class PhantomElement +{ + public: + PhantomElement (const char* const type, const double cx, const double cy, const double u, const double v, const double rot, const double atten); + + ~PhantomElement (void); + + bool isPointInside (double x, double y, const CoordType coord_type); + + bool clipLineNormalizedCoords (double& x1, double& y1, double& x2, double& y2) const; + + bool clipLineWorldCoords (double& x1, double& y1, double& x2, double& y2) const; + + const int nOutlinePoints(void) const {return m_nPoints;} + double* rectLimits(void) {return m_rectLimits;} + double* xOutline() {return m_xOutline;} + double* yOutline() {return m_yOutline;} + const double atten(void) const {return m_atten;} + const double diameter(void) const {return m_diameter;} + const double xmin(void) const {return m_xmin;} + const double xmax(void) const {return m_xmax;} + const double ymin(void) const {return m_ymin;} + const double ymax(void) const {return m_ymax;} + const double rot(void) const {return m_rot;} + const double cx(void) const {return m_cx;} + const double cy(void) const {return m_cy;} + const double u(void) const {return m_u;} + const double v(void) const {return m_v;} + + private: + PhmElemType m_type; // pelem type (box, ellipse, etc) + double m_atten; // X-ray attenuation coefficient + double m_cx, m_cy; // center of pelem + double m_u, m_v; // size of pelem + double m_rot; // pelem rotation angle (in radians) + double *m_x, *m_y; // ptr to array of points in obj world coord + int m_nPoints; // number of points in outline arrays + double m_xmin, m_xmax, m_ymin, m_ymax; // pelem limits + double m_diameter; + GRFMTX_2D m_xformPhmToObj; // map from phantom to normalized pelem coords + GRFMTX_2D m_xformObjToPhm; // map from normalized pelem coords to phantom coords + double* m_xOutline; + double* m_yOutline; + double m_rectLimits[4]; + + static const int POINTS_PER_CIRCLE = 360; + + void makeTransformMatrices (void); + + void makeVectorOutline (void); + + void calcArcPoints (double x[], double y[], const int pts, const double xcent, const double ycent, const double r, const double start, const double stop); + + void calcEllipsePoints (double x[], double y[], const int pts, const double u, const double v); + + int numCirclePoints (double theta) const; + +}; + + +typedef enum { + P_PELEMS, // Phantom made of PElems + P_UNIT_PULSE, // Special phantom, not made of pelems + P_FILTER // defined only by this type +} PhantomComposition; + +// Phantom class + +class Phantom +{ + public: + Phantom (void); + ~Phantom (void); + + void setComposition (PhantomComposition composition) + { m_composition = composition; } + + const PhantomComposition getComposition (void) const + { return m_composition; } + + void create (const int phmid); + + bool createFromFile (const char* const fname); + + void addPElem (const PhantomElement& pelem); + + void addPElem (const char* const composition, const double cx, const double cy, const double u, const double v, const double rot, const double atten); + + void print (void) const; + +#if HAVE_SGP + void show (void) const; + void draw (void) const; +#endif + + void std_herman (void); + + void std_rowland (void); + + void std_rowland_bordered (void); + + const double maxAxisLength (void) const {return (((m_xmax - m_xmin) > (m_ymax - m_ymin)) ? (m_xmax - m_xmin) : (m_ymax - m_ymin));} + + const double diameter(void) const {return m_diameter;} + const double xmin(void) const {return m_xmin;} + const double xmax(void) const {return m_xmax;} + const double ymin(void) const {return m_ymin;} + const double ymax(void) const {return m_ymax;} + slist& listPElem(void) {return m_listPElem;} + const slist& listPElem(void) const {return m_listPElem;} + const int nPElem(void) const {return m_nPElem;} + + private: + PhantomComposition m_composition; + int m_nPElem; // number of pelems in phantom + double m_xmin, m_xmax, m_ymin, m_ymax; // extent of pelems in pelem coordinates + double m_diameter; // diameter of object + mutable slist m_listPElem; // pelem lists + string m_name; +}; + +typedef slist::iterator PElemIterator; +typedef slist::const_iterator PElemConstIterator; + +#endif -- 2.34.1