X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fphantom.cpp;h=bf1165499445375848e475861060d00a8762c443;hp=f9bb1dbf38db3f4172c658ac99c99809f5bfddb7;hb=b6b7a4c68b20d0f86c8fb1095a166d4b93c3feba;hpb=88fd1492afba7c103e2bedbaac0d69fb9bf3cf66 diff --git a/libctsim/phantom.cpp b/libctsim/phantom.cpp index f9bb1db..bf11654 100644 --- a/libctsim/phantom.cpp +++ b/libctsim/phantom.cpp @@ -7,9 +7,7 @@ ** Date Started: Aug 1984 ** ** This is part of the CTSim program -** Copyright (c) 1983-2001 Kevin Rosenberg -** -** $Id$ +** Copyright (c) 1983-2009 Kevin Rosenberg ** ** 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 @@ -117,13 +115,13 @@ Phantom::convertNameToPhantomID (const char* const phmName) { int id = PHM_INVALID; - for (int i = 0; i < s_iPhantomCount; i++) + for (int i = 0; i < s_iPhantomCount; i++) { if (strcasecmp (phmName, s_aszPhantomName[i]) == 0) { id = i; break; } - - return (id); + } + return (id); } @@ -509,6 +507,34 @@ Phantom::convertToImagefile (ImageFile& im, const int iTotalRasterCols, const do *vCol++ = 0; } +#if HAVE_OPENMP + double x_start = xmin + (colStart * xinc); + for (PElemConstIterator pelem = m_listPElem.begin(); pelem != m_listPElem.end(); pelem++) { + const PhantomElement& rPElem = **pelem; + #pragma omp parallel for + for (int ix = 0; ix < colCount; ix++) { + double x = x_start + ix * xinc; + int iColStore = ix + iStorageOffset; + ImageFileColumn vCol = v[iColStore]; + + double y = ymin; + for (int iy = 0; iy < ny; iy++, y += yinc) { + double dAtten = 0; + double xi = x + kxofs; + for (int kx = 0; kx < nsample; kx++, xi += kxinc) { + double yi = y + kyofs; + for (int ky = 0; ky < nsample; ky++, yi += kyinc) { + if (rPElem.isPointInside (xi, yi, PHM_COORD)) + dAtten += rPElem.atten(); + } // ky + } // kx + *vCol++ += dAtten; + } /* iy */ + } /* ix */ + } /* pelem */ + +#else + double x_start = xmin + (colStart * xinc); for (PElemConstIterator pelem = m_listPElem.begin(); pelem != m_listPElem.end(); pelem++) { const PhantomElement& rPElem = **pelem; @@ -528,12 +554,13 @@ Phantom::convertToImagefile (ImageFile& im, const int iTotalRasterCols, const do } /* for iy */ } /* for ix */ } /* for pelem */ - +#endif if (nsample > 1) { double factor = 1.0 / static_cast(nsample * nsample); - - +#if HAVE_OPENMP + #pragma omp parallel for +#endif for (int ix = 0; ix < colCount; ix++) { int iColStore = ix + iStorageOffset; ImageFileColumn vCol = v[iColStore];