1 /*****************************************************************************
5 ** Purpose: Header file for Phantom objects
6 ** Programmer: Kevin Rosenberg
7 ** Date Started: July 1, 1984
9 ** This is part of the CTSim program
10 ** Copyright (C) 1983-2000 Kevin Rosenberg
12 ** $Id: phantom.h,v 1.1 2000/06/19 18:45:36 kevin Exp $
14 ** This program is free software; you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License (version 2) as
16 ** published by the Free Software Foundation.
18 ** This program is distributed in the hope that it will be useful,
19 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ** GNU General Public License for more details.
23 ** You should have received a copy of the GNU General Public License
24 ** along with this program; if not, write to the Free Software
25 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ******************************************************************************/
43 /* Codes for Coordinate Types */
44 /* Defines coords for isPointInside() */
47 PELEM_COORD, /* Normalized PElem Coordinates */
48 PHM_COORD /* World phantom Coordinates */
55 PhantomElement (const char* const type, const double cx, const double cy, const double u, const double v, const double rot, const double atten);
57 ~PhantomElement (void);
59 bool isPointInside (double x, double y, const CoordType coord_type);
61 bool clipLineNormalizedCoords (double& x1, double& y1, double& x2, double& y2) const;
63 bool clipLineWorldCoords (double& x1, double& y1, double& x2, double& y2) const;
65 const int nOutlinePoints(void) const {return m_nPoints;}
66 double* rectLimits(void) {return m_rectLimits;}
67 double* xOutline() {return m_xOutline;}
68 double* yOutline() {return m_yOutline;}
69 const double atten(void) const {return m_atten;}
70 const double diameter(void) const {return m_diameter;}
71 const double xmin(void) const {return m_xmin;}
72 const double xmax(void) const {return m_xmax;}
73 const double ymin(void) const {return m_ymin;}
74 const double ymax(void) const {return m_ymax;}
75 const double rot(void) const {return m_rot;}
76 const double cx(void) const {return m_cx;}
77 const double cy(void) const {return m_cy;}
78 const double u(void) const {return m_u;}
79 const double v(void) const {return m_v;}
82 PhmElemType m_type; // pelem type (box, ellipse, etc)
83 double m_atten; // X-ray attenuation coefficient
84 double m_cx, m_cy; // center of pelem
85 double m_u, m_v; // size of pelem
86 double m_rot; // pelem rotation angle (in radians)
87 double *m_x, *m_y; // ptr to array of points in obj world coord
88 int m_nPoints; // number of points in outline arrays
89 double m_xmin, m_xmax, m_ymin, m_ymax; // pelem limits
91 GRFMTX_2D m_xformPhmToObj; // map from phantom to normalized pelem coords
92 GRFMTX_2D m_xformObjToPhm; // map from normalized pelem coords to phantom coords
95 double m_rectLimits[4];
97 static const int POINTS_PER_CIRCLE = 360;
99 void makeTransformMatrices (void);
101 void makeVectorOutline (void);
103 void calcArcPoints (double x[], double y[], const int pts, const double xcent, const double ycent, const double r, const double start, const double stop);
105 void calcEllipsePoints (double x[], double y[], const int pts, const double u, const double v);
107 int numCirclePoints (double theta) const;
113 P_PELEMS, // Phantom made of PElems
114 P_UNIT_PULSE, // Special phantom, not made of pelems
115 P_FILTER // defined only by this type
116 } PhantomComposition;
126 void setComposition (PhantomComposition composition)
127 { m_composition = composition; }
129 const PhantomComposition getComposition (void) const
130 { return m_composition; }
132 void create (const int phmid);
134 bool createFromFile (const char* const fname);
136 void addPElem (const PhantomElement& pelem);
138 void addPElem (const char* const composition, const double cx, const double cy, const double u, const double v, const double rot, const double atten);
140 void print (void) const;
143 void show (void) const;
144 void draw (void) const;
147 void std_herman (void);
149 void std_rowland (void);
151 void std_rowland_bordered (void);
153 const double maxAxisLength (void) const {return (((m_xmax - m_xmin) > (m_ymax - m_ymin)) ? (m_xmax - m_xmin) : (m_ymax - m_ymin));}
155 const double diameter(void) const {return m_diameter;}
156 const double xmin(void) const {return m_xmin;}
157 const double xmax(void) const {return m_xmax;}
158 const double ymin(void) const {return m_ymin;}
159 const double ymax(void) const {return m_ymax;}
160 slist<PhantomElement*>& listPElem(void) {return m_listPElem;}
161 const slist<PhantomElement*>& listPElem(void) const {return m_listPElem;}
162 const int nPElem(void) const {return m_nPElem;}
165 PhantomComposition m_composition;
166 int m_nPElem; // number of pelems in phantom
167 double m_xmin, m_xmax, m_ymin, m_ymax; // extent of pelems in pelem coordinates
168 double m_diameter; // diameter of object
169 mutable slist<PhantomElement*> m_listPElem; // pelem lists
173 typedef slist<PhantomElement*>::iterator PElemIterator;
174 typedef slist<PhantomElement*>::const_iterator PElemConstIterator;