X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fphantom.cpp;h=f02877775729f2f1a4781e78eec84ad2d9f1ef56;hp=540adf8022ce91b82141ffafc755f9cbb737075c;hb=54275dac65e81ac6558d8f5f7ff39f2f8a53a818;hpb=564da05751f196760e1d2f9a4f49161e27cedd54 diff --git a/libctsim/phantom.cpp b/libctsim/phantom.cpp index 540adf8..f028777 100644 --- a/libctsim/phantom.cpp +++ b/libctsim/phantom.cpp @@ -507,6 +507,33 @@ 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]; + for (int iy = 0; iy < ny; iy++) { + double y = ymin + iy * yinc; + double dAtten = 0; + for (int kx = 0; kx < nsample; kx++) { + double xi = x + kxofs + kxinc * kx; + for (int ky = 0; ky < nsample; ky++) { + double yi = y + kyofs + ky * 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; @@ -526,12 +553,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];