1 /*****************************************************************************
5 ** Purpose: Classes for CT scanner
6 ** Programmer: Kevin Rosenberg
9 ** This is part of the CTSim program
10 ** Copyright (c) 1983-2001 Kevin Rosenberg
12 ** $Id: scanner.cpp,v 1.43 2003/04/01 19:49:41 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 ******************************************************************************/
31 const int Scanner::GEOMETRY_INVALID = -1;
32 const int Scanner::GEOMETRY_PARALLEL = 0;
33 const int Scanner::GEOMETRY_EQUIANGULAR = 1;
34 const int Scanner::GEOMETRY_EQUILINEAR = 2;
35 const int Scanner::GEOMETRY_LINOGRAM = 3;
37 const char* Scanner::s_aszGeometryName[] =
45 const char* Scanner::s_aszGeometryTitle[] =
53 const int Scanner::s_iGeometryCount = sizeof(s_aszGeometryName) / sizeof(const char*);
57 // DetectorArray Construct a DetectorArray
59 DetectorArray::DetectorArray (const int nDet)
62 m_detValues = new DetectorValue [m_nDet];
67 // ~DetectorArray Free memory allocated to a detector array
69 DetectorArray::~DetectorArray (void)
71 delete [] m_detValues;
77 * Scanner::Scanner Construct a user specified detector structure
80 * Scanner (phm, nDet, nView, nSample)
81 * Phantom& phm PHANTOM that we are making detector for
82 * int geomety Geometry of detector
83 * int nDet Number of detector along detector array
84 * int nView Number of rotated views
85 * int nSample Number of rays per detector
88 Scanner::Scanner (const Phantom& phm, const char* const geometryName,
89 int nDet, int nView, int offsetView,
90 int nSample, const double rot_anglen,
91 const double dFocalLengthRatio,
92 const double dCenterDetectorRatio,
93 const double dViewRatio, const double dScanRatio)
96 m_idGeometry = convertGeometryNameToID (geometryName);
97 if (m_idGeometry == GEOMETRY_INVALID) {
99 m_failMessage = "Invalid geometry name ";
100 m_failMessage += geometryName;
104 if (nView < 1 || nDet < 1) {
106 m_failMessage = "nView & nDet must be greater than 0";
114 m_iOffsetView = offsetView;
116 m_dFocalLengthRatio = dFocalLengthRatio;
117 m_dCenterDetectorRatio = dCenterDetectorRatio;
118 m_dViewRatio = dViewRatio;
119 m_dScanRatio = dScanRatio;
121 m_dViewDiameter = phm.getDiameterBoundaryCircle() * m_dViewRatio;
122 m_dFocalLength = (m_dViewDiameter / 2) * m_dFocalLengthRatio;
123 m_dCenterDetectorLength = (m_dViewDiameter / 2) * m_dCenterDetectorRatio;
124 m_dSourceDetectorLength = m_dFocalLength + m_dCenterDetectorLength;
125 m_dScanDiameter = m_dViewDiameter * m_dScanRatio;
127 m_dXCenter = phm.xmin() + (phm.xmax() - phm.xmin()) / 2;
128 m_dYCenter = phm.ymin() + (phm.ymax() - phm.ymin()) / 2;
129 m_rotLen = rot_anglen;
130 m_rotInc = m_rotLen / m_nView;
131 if (m_idGeometry == GEOMETRY_PARALLEL) {
133 m_detLen = m_dScanDiameter;
134 m_detStart = -m_detLen / 2;
135 m_detInc = m_detLen / m_nDet;
136 double dDetectorArrayEndOffset = 0;
137 // For even number of detectors, make detInc slightly larger so that center lies
138 // at nDet/2. Also, extend detector array by one detInc so that all of the phantom is scanned
139 if (isEven (m_nDet)) { // Adjust for Even number of detectors
140 m_detInc = m_detLen / (m_nDet - 1); // center detector = (nDet/2)
141 dDetectorArrayEndOffset = m_detInc;
144 double dHalfDetLen = m_detLen / 2;
145 m_initPos.xs1 = m_dXCenter - dHalfDetLen;
146 m_initPos.ys1 = m_dYCenter + m_dFocalLength;
147 m_initPos.xs2 = m_dXCenter + dHalfDetLen + dDetectorArrayEndOffset;
148 m_initPos.ys2 = m_dYCenter + m_dFocalLength;
149 m_initPos.xd1 = m_dXCenter - dHalfDetLen;
150 m_initPos.yd1 = m_dYCenter - m_dCenterDetectorLength;
151 m_initPos.xd2 = m_dXCenter + dHalfDetLen + dDetectorArrayEndOffset;
152 m_initPos.yd2 = m_dYCenter - m_dCenterDetectorLength;
153 m_initPos.angle = m_iOffsetView * m_rotInc;
154 m_detLen += dDetectorArrayEndOffset;
155 } else if (m_idGeometry == GEOMETRY_EQUILINEAR) {
156 if (m_dScanDiameter / 2 >= m_dFocalLength) {
158 m_failMessage = "Invalid geometry: Focal length must be larger than scan length";
162 const double dAngle = asin ((m_dScanDiameter / 2) / m_dFocalLength);
163 const double dHalfDetLen = m_dSourceDetectorLength * tan (dAngle);
165 m_detLen = dHalfDetLen * 2;
166 m_detStart = -dHalfDetLen;
167 m_detInc = m_detLen / m_nDet;
168 double dDetectorArrayEndOffset = 0;
169 if (isEven (m_nDet)) { // Adjust for Even number of detectors
170 m_detInc = m_detLen / (m_nDet - 1); // center detector = (nDet/2)
171 dDetectorArrayEndOffset = m_detInc;
172 m_detLen += dDetectorArrayEndOffset;
175 m_dFanBeamAngle = dAngle * 2;
176 m_initPos.xs1 = m_dXCenter;
177 m_initPos.ys1 = m_dYCenter + m_dFocalLength;
178 m_initPos.xs2 = m_dXCenter;
179 m_initPos.ys2 = m_dYCenter + m_dFocalLength;
180 m_initPos.xd1 = m_dXCenter - dHalfDetLen;
181 m_initPos.yd1 = m_dYCenter - m_dCenterDetectorLength;
182 m_initPos.xd2 = m_dXCenter + dHalfDetLen + dDetectorArrayEndOffset;
183 m_initPos.yd2 = m_dYCenter - m_dCenterDetectorLength;
184 m_initPos.angle = m_iOffsetView * m_rotInc;
185 } else if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
186 if (m_dScanDiameter / 2 > m_dFocalLength) {
188 m_failMessage = "Invalid geometry: Focal length must be larger than scan length";
191 const double dAngle = asin ((m_dScanDiameter / 2) / m_dFocalLength);
193 m_detLen = 2 * dAngle;
194 m_detStart = -dAngle;
195 m_detInc = m_detLen / m_nDet;
196 double dDetectorArrayEndOffset = 0;
197 if (isEven (m_nDet)) { // Adjust for Even number of detectors
198 m_detInc = m_detLen / (m_nDet - 1); // center detector = (nDet/2)
199 dDetectorArrayEndOffset = m_detInc;
201 // adjust for center-detector length
202 double dA1 = acos ((m_dScanDiameter / 2) / m_dCenterDetectorLength);
203 double dAngularScale = 2 * (HALFPI + dAngle - dA1) / m_detLen;
205 m_dAngularDetLen = dAngularScale * (m_detLen + dDetectorArrayEndOffset);
206 m_dAngularDetIncrement = dAngularScale * m_detInc;
207 m_initPos.dAngularDet = -m_dAngularDetLen / 2;
209 m_dFanBeamAngle = dAngle * 2;
210 m_initPos.angle = m_iOffsetView * m_rotInc;
211 m_initPos.xs1 = m_dXCenter;
212 m_initPos.ys1 = m_dYCenter + m_dFocalLength;;
213 m_initPos.xs2 = m_dXCenter;
214 m_initPos.ys2 = m_dYCenter + m_dFocalLength;
215 m_detLen += dDetectorArrayEndOffset;
218 // Calculate incrementatal rotation matrix
220 xlat_mtx2 (m_rotmtxIncrement, -m_dXCenter, -m_dYCenter);
221 rot_mtx2 (temp, m_rotInc);
222 mult_mtx2 (m_rotmtxIncrement, temp, m_rotmtxIncrement);
223 xlat_mtx2 (temp, m_dXCenter, m_dYCenter);
224 mult_mtx2 (m_rotmtxIncrement, temp, m_rotmtxIncrement);
228 Scanner::~Scanner (void)
234 Scanner::convertGeometryIDToName (const int geomID)
236 const char *name = "";
238 if (geomID >= 0 && geomID < s_iGeometryCount)
239 return (s_aszGeometryName[geomID]);
245 Scanner::convertGeometryIDToTitle (const int geomID)
247 const char *title = "";
249 if (geomID >= 0 && geomID < s_iGeometryCount)
250 return (s_aszGeometryName[geomID]);
256 Scanner::convertGeometryNameToID (const char* const geomName)
258 int id = GEOMETRY_INVALID;
260 for (int i = 0; i < s_iGeometryCount; i++)
261 if (strcasecmp (geomName, s_aszGeometryName[i]) == 0) {
271 * collectProjections Calculate projections for a Phantom
274 * collectProjections (proj, phm, start_view, nView, bStoreViewPos, trace)
275 * Projectrions& proj Projection storage
276 * Phantom& phm Phantom for which we collect projections
277 * bool bStoreViewPos TRUE then storage proj at normal view position
278 * int trace Trace level
283 Scanner::collectProjections (Projections& proj, const Phantom& phm, const int trace, SGP* pSGP)
285 collectProjections (proj, phm, m_startView, proj.nView(), m_iOffsetView, true, trace, pSGP);
289 Scanner::collectProjections (Projections& proj, const Phantom& phm, const int iStartView,
290 const int iNumViews, const int iOffsetView, bool bStoreAtViewPosition,
291 const int trace, SGP* pSGP)
293 int iStorageOffset = (bStoreAtViewPosition ? iStartView : 0);
294 collectProjections (proj, phm, iStartView, iNumViews, iOffsetView, iStorageOffset, trace, pSGP);
298 Scanner::collectProjections (Projections& proj, const Phantom& phm, const int iStartView,
299 const int iNumViews, const int iOffsetView, int iStorageOffset,
300 const int trace, SGP* pSGP)
303 double start_angle = (iStartView + iOffsetView) * proj.rotInc();
305 // Calculate initial rotation matrix
306 GRFMTX_2D rotmtx_initial, temp;
307 xlat_mtx2 (rotmtx_initial, -m_dXCenter, -m_dYCenter);
308 rot_mtx2 (temp, start_angle);
309 mult_mtx2 (rotmtx_initial, temp, rotmtx_initial);
310 xlat_mtx2 (temp, m_dXCenter, m_dYCenter);
311 mult_mtx2 (rotmtx_initial, temp, rotmtx_initial);
313 double xd1=0, yd1=0, xd2=0, yd2=0;
314 if (m_idGeometry != GEOMETRY_EQUIANGULAR) {
319 xform_mtx2 (rotmtx_initial, xd1, yd1); // rotate detector endpoints
320 xform_mtx2 (rotmtx_initial, xd2, yd2); // to initial view_angle
323 double xs1 = m_initPos.xs1;
324 double ys1 = m_initPos.ys1;
325 double xs2 = m_initPos.xs2;
326 double ys2 = m_initPos.ys2;
327 xform_mtx2 (rotmtx_initial, xs1, ys1); // rotate source endpoints to
328 xform_mtx2 (rotmtx_initial, xs2, ys2); // initial view angle
332 for (iView = 0, viewAngle = start_angle; iView < iNumViews; iView++, viewAngle += proj.rotInc()) {
333 int iStoragePosition = iView + iStorageOffset;
335 DetectorArray& detArray = proj.getDetectorArray( iStoragePosition );
338 if (pSGP && m_trace >= Trace::TRACE_PHANTOM) {
340 double dWindowSize = dmax (m_detLen, m_dSourceDetectorLength) * 2;
341 double dHalfWindowSize = dWindowSize / 2;
342 m_dXMinWin = m_dXCenter - dHalfWindowSize;
343 m_dXMaxWin = m_dXCenter + dHalfWindowSize;
344 m_dYMinWin = m_dYCenter - dHalfWindowSize;
345 m_dYMaxWin = m_dYCenter + dHalfWindowSize;
347 m_pSGP->setWindow (m_dXMinWin, m_dYMinWin, m_dXMaxWin, m_dYMaxWin);
348 m_pSGP->setRasterOp (RO_COPY);
350 m_pSGP->setColor (C_RED);
351 m_pSGP->moveAbs (0., 0.);
352 m_pSGP->drawCircle (m_dViewDiameter / 2);
354 m_pSGP->moveAbs (0., 0.);
355 m_pSGP->setColor (C_GREEN);
356 m_pSGP->drawCircle (m_dFocalLength);
357 m_pSGP->setColor (C_BLUE);
359 m_pSGP->setTextPointSize (9);
361 m_pSGP->setTextPointSize (14);
364 m_dTextHeight = m_pSGP->getCharHeight ();
366 traceShowParam ("Phantom:", "%s", PROJECTION_TRACE_ROW_PHANT_ID, C_BLACK, phm.name().c_str());
367 traceShowParam ("Geometry:", "%s", PROJECTION_TRACE_ROW_GEOMETRY, C_BLUE, convertGeometryIDToName(m_idGeometry));
368 traceShowParam ("Focal Length Ratio:", "%.2f", PROJECTION_TRACE_ROW_FOCAL_LENGTH, C_BLUE, m_dFocalLengthRatio);
369 // traceShowParam ("Field Of View Ratio:", "%.2f", PROJECTION_TRACE_ROW_FIELD_OF_VIEW, C_BLUE, m_dFieldOfViewRatio);
370 traceShowParam ("Num Detectors:", "%d", PROJECTION_TRACE_ROW_NDET, C_BLUE, proj.nDet());
371 traceShowParam ("Num Views:", "%d", PROJECTION_TRACE_ROW_NVIEW, C_BLUE, proj.nView());
372 traceShowParam ("Samples / Ray:", "%d", PROJECTION_TRACE_ROW_SAMPLES, C_BLUE, m_nSample);
374 m_pSGP->setMarker (SGP::MARKER_BDIAMOND);
379 if (m_pSGP && m_trace >= Trace::TRACE_PHANTOM) {
380 m_pSGP->setColor (C_BLACK);
381 m_pSGP->setPenWidth (2);
382 if (m_idGeometry == GEOMETRY_PARALLEL) {
383 m_pSGP->moveAbs (xs1, ys1);
384 m_pSGP->lineAbs (xs2, ys2);
385 m_pSGP->moveAbs (xd1, yd1);
386 m_pSGP->lineAbs (xd2, yd2);
387 } else if (m_idGeometry == GEOMETRY_EQUILINEAR) {
388 m_pSGP->setPenWidth (4);
389 m_pSGP->moveAbs (xs1, ys1);
390 m_pSGP->lineAbs (xs2, ys2);
391 m_pSGP->setPenWidth (2);
392 m_pSGP->moveAbs (xd1, yd1);
393 m_pSGP->lineAbs (xd2, yd2);
394 } else if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
395 m_pSGP->setPenWidth (4);
396 m_pSGP->moveAbs (xs1, ys1);
397 m_pSGP->lineAbs (xs2, ys2);
398 m_pSGP->setPenWidth (2);
399 m_pSGP->moveAbs (0., 0.);
400 m_pSGP->drawArc (m_dCenterDetectorLength, viewAngle + 3 * HALFPI - (m_dAngularDetLen/2), viewAngle + 3 * HALFPI + (m_dAngularDetLen/2));
402 m_pSGP->setPenWidth (1);
404 if (m_trace > Trace::TRACE_CONSOLE)
405 traceShowParam ("Current View:", "%d (%.0f%%)", PROJECTION_TRACE_ROW_CURR_VIEW, C_RED, iView + iStartView, (iView + iStartView) / static_cast<double>(m_nView) * 100.);
407 if (m_trace == Trace::TRACE_CONSOLE)
408 std::cout << "Current View: " << iView+iStartView << std::endl;
410 projectSingleView (phm, detArray, xd1, yd1, xd2, yd2, xs1, ys1, xs2, ys2, viewAngle + 3 * HALFPI);
411 detArray.setViewAngle (viewAngle);
414 if (m_pSGP && m_trace >= Trace::TRACE_PHANTOM) {
415 // rs_plot (detArray, xd1, yd1, dXCenter, dYCenter, theta);
418 xform_mtx2 (m_rotmtxIncrement, xs1, ys1);
419 xform_mtx2 (m_rotmtxIncrement, xs2, ys2);
420 if (m_idGeometry != GEOMETRY_EQUIANGULAR) {
421 xform_mtx2 (m_rotmtxIncrement, xd1, yd1); // rotate detector endpoints
422 xform_mtx2 (m_rotmtxIncrement, xd2, yd2);
424 } /* for each iView */
429 * rayview Calculate raysums for a view at any angle
432 * rayview (phm, detArray, xd1, nSample, yd1, xd2, yd2, xs1, ys1, xs2, ys2)
433 * Phantom& phm Phantom to scan
434 * DETARRAY *detArray Storage of values for detector array
435 * Scanner& det Scanner parameters
436 * double xd1, yd1, xd2, yd2 Beginning & ending detector positions
437 * double xs1, ys1, xs2, ys2 Beginning & ending source positions
440 * For each detector, have there are a variable number of rays traced.
441 * The source of each ray is the center of the source x-ray cell. The
442 * detector positions are equally spaced within the cell
444 * The increments between rays are calculated so that the cells start
445 * at the beginning of a detector cell and they end on the endpoint
446 * of the cell. Thus, the last cell starts at (xd2-ddx),(yd2-ddy).
447 * The exception to this is if there is only one ray per detector.
448 * In that case, the detector position is the center of the detector cell.
452 Scanner::projectSingleView (const Phantom& phm, DetectorArray& detArray, const double xd1, const double yd1, const double xd2, const double yd2, const double xs1, const double ys1, const double xs2, const double ys2, const double dDetAngle)
455 double sdx = (xs2 - xs1) / detArray.nDet(); // change in coords
456 double sdy = (ys2 - ys1) / detArray.nDet(); // between source
457 double xs_maj = xs1 + (sdx / 2); // put ray source in center of cell
458 double ys_maj = ys1 + (sdy / 2);
460 double ddx=0, ddy=0, ddx2=0, ddy2=0, ddx2_ofs=0, ddy2_ofs=0, xd_maj=0, yd_maj=0;
461 double dAngleInc=0, dAngleSampleInc=0, dAngleSampleOffset=0, dAngleMajor=0;
462 if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
463 dAngleInc = m_dAngularDetIncrement;
464 dAngleSampleInc = dAngleInc / m_nSample;
465 dAngleSampleOffset = dAngleSampleInc / 2;
466 dAngleMajor = dDetAngle - (m_dAngularDetLen/2) + dAngleSampleOffset;
468 ddx = (xd2 - xd1) / detArray.nDet(); // change in coords
469 ddy = (yd2 - yd1) / detArray.nDet(); // between detectors
470 ddx2 = ddx / m_nSample; // Incr. between rays with detector cell
471 ddy2 = ddy / m_nSample; // Doesn't include detector endpoints
472 ddx2_ofs = ddx2 / 2; // offset of 1st ray from start of detector cell
475 xd_maj = xd1 + ddx2_ofs; // Incr. between detector cells
476 yd_maj = yd1 + ddy2_ofs;
479 DetectorValue* detval = detArray.detValues();
481 if (phm.getComposition() == P_UNIT_PULSE) { // put unit pulse in center of view
482 for (int d = 0; d < detArray.nDet(); d++)
484 detval[ detArray.nDet() / 2 ] = 1;
486 for (int d = 0; d < detArray.nDet(); d++) {
489 double xd=0, yd=0, dAngle=0;
490 if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
491 dAngle = dAngleMajor;
497 for (unsigned int i = 0; i < m_nSample; i++) {
498 if (m_idGeometry == GEOMETRY_EQUIANGULAR) {
499 xd = m_dCenterDetectorLength * cos (dAngle);
500 yd = m_dCenterDetectorLength * sin (dAngle);
504 if (m_pSGP && m_trace >= Trace::TRACE_PROJECTIONS) {
505 m_pSGP->setColor (C_YELLOW);
506 m_pSGP->setRasterOp (RO_AND);
507 m_pSGP->moveAbs (xs, ys);
508 m_pSGP->lineAbs (xd, yd);
512 sum += projectSingleLine (phm, xd, yd, xs, ys);
515 // if (m_trace >= Trace::TRACE_CLIPPING) {
516 // traceShowParam ("Attenuation:", "%s", PROJECTION_TRACE_ROW_ATTEN, C_LTMAGENTA, " ");
517 // traceShowParam ("Attenuation:", "%.3f", PROJECTION_TRACE_ROW_ATTEN, C_LTMAGENTA, sum);
520 if (m_idGeometry == GEOMETRY_EQUIANGULAR)
521 dAngle += dAngleSampleInc;
526 } // for each sample in detector
528 detval[d] = sum / m_nSample;
531 if (m_idGeometry == GEOMETRY_EQUIANGULAR)
532 dAngleMajor += dAngleInc;
537 } /* for each detector */
538 } /* if not unit pulse */
543 Scanner::traceShowParam (const char *szLabel, const char *fmt, int row, int color, ...)
546 va_start(arg, color);
548 traceShowParamRasterOp (RO_COPY, szLabel, fmt, row, color, arg);
550 traceShowParamRasterOp (0, szLabel, fmt, row, color, arg);
556 Scanner::traceShowParamXOR (const char *szLabel, const char *fmt, int row, int color, ...)
559 va_start(arg, color);
561 traceShowParamRasterOp (RO_XOR, szLabel, fmt, row, color, arg);
563 traceShowParamRasterOp (0, szLabel, fmt, row, color, arg);
569 Scanner::traceShowParamRasterOp (int iRasterOp, const char *szLabel, const char *fmt, int row, int color, va_list args)
573 vsnprintf (szValue, sizeof(szValue), fmt, args);
577 m_pSGP->setRasterOp (iRasterOp);
578 m_pSGP->setTextColor (color, -1);
579 double dValueOffset = (m_dXMaxWin - m_dXMinWin) / 4;
581 double dYPos = m_dYMaxWin - (row * m_dTextHeight);
582 double dXPos = m_dXMinWin;
583 m_pSGP->moveAbs (dXPos, dYPos);
584 m_pSGP->drawText (szLabel);
585 m_pSGP->moveAbs (dXPos + dValueOffset, dYPos);
586 m_pSGP->drawText (szValue);
589 double dYPos = m_dYMaxWin - (row * m_dTextHeight);
590 double dXPos = m_dXMinWin + (m_dXMaxWin - m_dXMinWin) * 0.5;
591 m_pSGP->moveAbs (dXPos, dYPos);
592 m_pSGP->drawText (szLabel);
593 m_pSGP->moveAbs (dXPos + dValueOffset, dYPos);
594 m_pSGP->drawText (szValue);
599 cio_put_str (szLabel);
600 cio_put_str (szValue);
608 * projectSingleLine INTERNAL: Calculates raysum along a line for a Phantom
611 * rsum = phm_ray_attenuation (phm, x1, y1, x2, y2)
612 * double rsum Ray sum of Phantom along given line
613 * Phantom& phm; Phantom from which to calculate raysum
614 * double *x1, *y1, *x2, y2 Endpoints of ray path (in Phantom coords)
618 Scanner::projectSingleLine (const Phantom& phm, const double x1, const double y1, const double x2, const double y2)
620 // check ray against each pelem in Phantom
622 for (PElemConstIterator i = phm.listPElem().begin(); i != phm.listPElem().end(); i++)
623 rsum += projectLineAgainstPElem (**i, x1, y1, x2, y2);
630 * pelem_ray_attenuation Calculate raysum of an pelem along one line
633 * rsum = pelem_ray_attenuation (pelem, x1, y1, x2, y2)
634 * double rsum Computed raysum
635 * PhantomElement& pelem Pelem to scan
636 * double x1, y1, x2, y2 Endpoints of raysum line
640 Scanner::projectLineAgainstPElem (const PhantomElement& pelem, double x1, double y1, double x2, double y2)
642 if (! pelem.clipLineWorldCoords (x1, y1, x2, y2)) {
643 if (m_trace == Trace::TRACE_CLIPPING)
644 cio_tone (1000., 0.05);
649 if (m_pSGP && m_trace == Trace::TRACE_CLIPPING) {
650 m_pSGP->setRasterOp (RO_XOR);
651 m_pSGP->moveAbs (x1, y1);
652 m_pSGP->lineAbs (x2, y2);
653 cio_tone (8000., 0.05);
654 m_pSGP->moveAbs (x1, y1);
655 m_pSGP->lineAbs (x2, y2);
656 m_pSGP->setRasterOp (RO_SET);
660 double len = lineLength (x1, y1, x2, y2);
661 return (len * pelem.atten());