From: Kevin M. Rosenberg Date: Tue, 27 Feb 2001 10:58:34 +0000 (+0000) Subject: r590: no message X-Git-Tag: debian-4.5.3-3~427 X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=commitdiff_plain;h=a4b718a2681d65cb56e62400cec28bc09f9509e1 r590: no message --- diff --git a/ChangeLog b/ChangeLog index e4044e8..295c3c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ * ctsim: Added background and SMP processing for reconstructions. * ctsim: Added background and SMP processing for scanning. + + * ctsim: Added background and SMP processing for rasterization. * ctsim: Added "Verbose Logging", "Startup Tips", and "Background processes" options to Preferences dialog. diff --git a/doc/ctsim-algorithms.tex b/doc/ctsim-algorithms.tex index 31346ae..504aba1 100644 --- a/doc/ctsim-algorithms.tex +++ b/doc/ctsim-algorithms.tex @@ -4,6 +4,82 @@ \ctsim\ uses a number of interesting algorithms. This appendix details some of the techniques that \ctsim\ uses. + +\section{Phantom Processing}\label{phantomprocessing} +\textbf{Key Concepts}\\ +\hspace*{1cm}\texttt{Geometric transformations}\\ +\hspace*{1cm}\texttt{Matrix algebra}\\ + +Phantom objects are processed in two different ways: rasterization +and projections. \ctsim\ uses optimized techniques to perform +those procedures. + +The primary tool used to optimize these processes is +\emph{Geometric transformations}. For every primitive +\helpref{phantom element}{phantomelements}, a standardized +configuration is defined. This standard configuration is used to +speed the process of collecting projections. + +In general, to transform an object into the standard +configuration, the following sequence of transformations occur. +When this sequence is performed, the coordinates are termed the +\emph{normalized phantom element} coordinates. + +\begin{itemize} +\item Scaling by the inverse of its size, that is usually +scaling by \texttt{(1/dx,1/dy)}. +\item Translating the object to the origin, that is usually translation by +\texttt{(-cx,-cy)}. +\item Rotating the object by \texttt{-r}. +\end{itemize} + +These steps can by combined into a single matrix multiplication +which involves only 4 multiplications and 6 additions to transform +both \texttt{x} and \texttt{y} coordinates. This matrix is +precalculated and stored when the phantom is created. Similarly, +the inverse of the matrix is precalculated and store to perform +the inverse of this transformation. + +As an example of this technique, consider the problem of finding +the length of an arbitrary line that may intersect an arbitary +ellipse. Define the endpoints of the line by \texttt{(x1,y1)} and +\texttt{(x2,y2)}. + +\begin{enumerate} +\item First, transform the coordinates into the normalized +phantom element coordinates. At this point, the ellipse will have +been transformed into a unit circle centered at \texttt{(0,0)}. +\item Translate the +coordinates by \texttt{(-x1,-y2)}. The line now has the endpoint +centered at the origin. The ellipse will now have its center at +\texttt{(-x1,-y1)}. +\item Rotate the coordinates by the negative of angle of the line +with respect to the x-axis. +\end{enumerate} + +At this point the line will now lie along the positive x-axis with +one end at \texttt{(0,0)}. The circle will be rotated around the +origin as well. At this point, it is fairly trivial to calculate +the length of the intersection of the line with the unit circle. +For example, if the \texttt{y} coordinate for the center of the +circle is greater than \texttt{1} or less than \texttt{-1}, then +we know that the unit circle doesn't intersect the line at all and +stop further processing. Otherwise, the endpoints of the +intersection of the line with the unit circle is a simple +calculation. + +Those new, intersected endpoints are then inverse transformed by +reverse of the above transformation sequence. After the inverse +translation, the transformed endpoints will be the endpoints of +the line that intersect the actual ellipse prior to any +transformations. + +Though this sequence of events is somewhat complex, it is quite +fast since the multiple transformations can be combined into a +single matrix multiplication. Further, this technique is amendable +to rapidly calculating the intersection of a line with any of the +phantom elements that \ctsim\ supports. + \section{Background Processing}\label{backgroundprocessing}\index{Background processing} \textbf{Key Concepts}\\ \hspace*{1cm}\texttt{Multithreading}\\ @@ -25,20 +101,26 @@ symmetric multiprocessing (SMP) computer. When background processing option is turned on or when \ctsim\ is running on a SMP computer, and \ctsim\ is directed to perform -reconstructions or projections, \ctsim\ will spawn a -\emph{Background Supervisor} thread. This supervisor thread then -creates a \emph{Supervisor Event Handler} (supervisor). The -supervisor thread then waits for the supervisor to finish. The +reconstruction, rasterization, or projections, \ctsim\ will spawn +a \emph{Background Supervisor} thread. This supervisor thread then +creates a \emph{Supervisor Event Handler} (supervisor). The supervisor communicates with the rest of \ctsim\ by using message passing to avoid issues with re-entrant code. -The supervisor registers itself, as always via message passing, -with the \emph{Background Manager} which will display the -execution progress in a pop-up window. The supervisor also -registers itself with the document being processed. This is done -so that if the document is closed, the document can send a message -to the supervisor directing the supervisor to cancel the -calculation. +Though the various threads do not directly call each other, it is +prudent to lock the class data structures with \emph{Critical +Sections}. Critical sections lock areas of code and prevent more +than one thread to access a section of code at a time. This is +used when maintaining the tables of worker threads in the +supervisor and also when maintaining the tables of supervisors in +the background manager. + +The supervisor registers itself via message passing with the +\emph{Background Manager} which will display the execution +progress in a pop-up window. The supervisor also registers itself +with the document being processed. This is done so that if the +document is closed, the document can send a message to the +supervisor directing the supervisor to cancel the calculation. After registering with \ctsim\ components, the supervisor creates \emph{Worker Threads}. These worker threads are the processes that @@ -58,11 +140,19 @@ window to display the finished work. The supervisor then deregisters itself via messages with the background manager and the document. The background manager removes the progress gauge from its display and resizes its -window. +window. Finally, the background supervisor exits and background +supervisor thread terminates. -Finally, the background supervisor exits and background supervisor -thread terminates. This structure may seem more complex than is -necessary, but it has several advantages: +This functionality has been compartmentalized into inheritable C++ +classes \texttt{BackgroundSupervisor}, +\texttt{BackgroundWorkerThread}, and +\texttt{BackgroundProcessingDocument}. These classes serve as base +classes for the reconstruction, rasterization, and projection +multithreading classes. + +\subsection{Advantages} +This structure may seem more complex than is necessary, but it has +several advantages: \begin{itemize} \item Since the various threads do not call objects in other threads, problems @@ -70,19 +160,29 @@ with re-entrant code are eliminated. \item A supervisor can parallel process with any number of worker threads to take advantage of potentially large numbers of CPU's in SMP computers. +\item Allows for continued user-interaction with \ctsim\ while lengthy calculations +are performed in the background. \end{itemize} -Though the various threads do not directly call each other, it is -prudent to lock the class data structures with \emph{Critical -Sections}. Critical sections lock areas of code and prevent more -than one thread to access a section of code at a time. This is -used when maintaining the tables of worker threads in the -supervisor and also when maintaining the tables of supervisors in -the background manager. +\subsection{Disadvantages} -This functionality has been compartmentalized in the inheritable -C++ classes \texttt{BackgroundSupervisor}, -\texttt{BackgroundWorkerThread}, and -\texttt{BackgroundProcessingDocument}. These classes serve as base -classes for the reconstruction and projection multithreading -classes. +The above advantages are not free of cost. The disadvantages +include: + +\begin{itemize} +\item Increased memory usage.\\ + The workers threads allocate memory to store their intermediate +results. When the worker threads finish, the supervisor allocates +memory for the final result and collates the results for the +workers. This collation results in a doubling of the memory +requirements. Of course, after collation the supervisor +deallocates the memory used by the workers. +\item Slower execution on single CPU systems. \\ +The message passing between threads and collation +of results for worker threads adds overhead compared to simply +calculating the result directly in the foreground. On single CPU +systems this results in slower processing compared to foreground +processing. On dual-CPU and greater SMP systems, though, the +advantage of using multiple CPU's in parallel exceeds the overhead +of background processing. +\end{itemize} diff --git a/doc/ctsim-gui.tex b/doc/ctsim-gui.tex index 923554a..6637303 100644 --- a/doc/ctsim-gui.tex +++ b/doc/ctsim-gui.tex @@ -142,6 +142,7 @@ At a setting of \texttt{0.54}, the Hamming filter is the same as the Hanning window.} \twocolitem{\textbf{Bandwidth}}{Sets the bandwidth of the filter.} \end{twocollist} + \begin{twocollist} \twocolitem{\textbf{Axis (input) Scale}}{Sets the scale for the filter input. By default, the input to the filter is the distance in pixels from the center of the image. By changing this value, one can set a scale the input to the filter. diff --git a/doc/ctsim.prj b/doc/ctsim.prj index 98e8805..de489c8 100644 --- a/doc/ctsim.prj +++ b/doc/ctsim.prj @@ -5,34 +5,34 @@ 1 ctsim.tex 21 -6 -1 +3 +0 -ctsim-gui.tex +ctsim-algorithms.tex TeX -12282 0 602 60 26 76 176 176 1253 763 +268439547 0 65 52 0 43 44 44 960 631 +ctsim-concepts.tex +TeX +12282 0 31 22 44 30 110 110 1187 697 ctsim.tex TeX -402665466 0 125 1 13 26 22 22 1099 609 +134230010 2 50 12 50 22 22 22 1099 609 +ctsim-gui.tex +TeX +268447738 0 145 21 144 1 176 176 1253 763 ctsim-install.tex TeX -12282 1 0 1 4 1 110 110 1187 697 +268447738 1 0 1 4 1 110 110 1187 697 psbox.tex TeX -4090 0 0 1 0 1 88 88 1004 675 -ctsim-algorithms.tex -TeX -4091 0 68 22 79 25 44 44 960 631 +268439546 0 0 1 0 1 88 88 1004 675 ctsim-sgp.tex TeX -4090 0 1 1 0 1 44 44 960 631 +268439546 0 1 1 0 1 44 44 960 631 ctsim-appendix.tex TeX 268447738 0 0 1 0 2 44 44 1121 631 -ctsim-concepts.tex -TeX -12282 0 334 29 307 1 110 110 1187 697 ctsim-textui.tex TeX 12282 0 38 45 38 46 198 198 1275 785 diff --git a/doc/ctsim.tex b/doc/ctsim.tex index c6cfc80..08dd8bf 100644 --- a/doc/ctsim.tex +++ b/doc/ctsim.tex @@ -1,4 +1,4 @@ -\documentclass[letterpaper,11pt]{report}% +\documentclass[letterpaper,11pt]{report} \usepackage{graphicx} \usepackage{texhelp} \usepackage{fancyhea} @@ -41,12 +41,12 @@ \author{Kevin M. Rosenberg, M.D.}% \makeindex% -\begin{document} \textheight=9in -\textwidth=6.5in +\textwidth=6.0in \evensidemargin=0in \oddsidemargin=0in +\begin{document} \maketitle \pagestyle{fancyplain} \pagenumbering{roman} diff --git a/msvc/ctsim/ctsim.dsp b/msvc/ctsim/ctsim.dsp index f59a03b..7cbc9e3 100644 --- a/msvc/ctsim/ctsim.dsp +++ b/msvc/ctsim/ctsim.dsp @@ -144,6 +144,10 @@ SOURCE=..\..\src\threadproj.cpp # End Source File # Begin Source File +SOURCE=..\..\src\threadraster.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\threadrecon.cpp # End Source File # Begin Source File @@ -205,6 +209,10 @@ SOURCE=..\..\src\threadproj.h # End Source File # Begin Source File +SOURCE=..\..\src\threadraster.h +# End Source File +# Begin Source File + SOURCE=..\..\src\threadrecon.h # End Source File # Begin Source File diff --git a/msvc/ctsim/ctsim.plg b/msvc/ctsim/ctsim.plg index 4a13f39..2da97a3 100644 --- a/msvc/ctsim/ctsim.plg +++ b/msvc/ctsim/ctsim.plg @@ -3,16 +3,112 @@
 

Build Log

+--------------------Configuration: libctsim - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA3.tmp" with contents +[ +/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "..\..\..\wx2.2.5\src\png" /I "..\..\..\wx2.2.5\src\zlib" /I "..\..\INCLUDE" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\fftw" /I "..\..\..\fftw-2.1.3\rfftw" /I "..\..\..\wx2.2.5\include" /D "_DEBUG" /D "HAVE_WXWIN" /D "HAVE_STRING_H" /D "HAVE_GETOPT_H" /D "WIN32" /D "_MBCS" /D "_LIB" /D "MSVC" /D "HAVE_FFTW" /D "HAVE_PNG" /D "HAVE_SGP" /D "HAVE_WXWINDOWS" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /FR"Debug/" /Fp"Debug/libctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\libctsim\backprojectors.cpp" +"C:\ctsim\libctgraphics\dlgezplot.cpp" +"C:\ctsim\libctsim\filter.cpp" +"C:\ctsim\libctsim\fourier.cpp" +"C:\ctsim\libctsim\globalvars.cpp" +"C:\ctsim\libctsupport\hashtable.cpp" +"C:\ctsim\libctsim\imagefile.cpp" +"C:\ctsim\libctsim\phantom.cpp" +"C:\ctsim\libctsupport\plotfile.cpp" +"C:\ctsim\libctgraphics\pol.cpp" +"C:\ctsim\libctsim\procsignal.cpp" +"C:\ctsim\libctsim\projections.cpp" +"C:\ctsim\libctsim\reconstruct.cpp" +"C:\ctsim\libctsim\scanner.cpp" +"C:\ctsim\libctsupport\syserror.cpp" +"C:\ctsim\libctsim\trace.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA3.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA4.tmp" with contents +[ +/nologo /out:"Debug\libctsim.lib" +.\Debug\array2dfile.obj +.\Debug\backprojectors.obj +.\Debug\clip.obj +.\Debug\consoleio.obj +.\Debug\dlgezplot.obj +.\Debug\ezplot.obj +.\Debug\ezset.obj +.\Debug\ezsupport.obj +.\Debug\filter.obj +.\Debug\fnetorderstream.obj +.\Debug\fourier.obj +.\Debug\getopt.obj +.\Debug\getopt1.obj +.\Debug\globalvars.obj +.\Debug\hashtable.obj +.\Debug\imagefile.obj +.\Debug\interpolator.obj +.\Debug\mathfuncs.obj +.\Debug\phantom.obj +.\Debug\plotfile.obj +.\Debug\pol.obj +.\Debug\procsignal.obj +.\Debug\projections.obj +.\Debug\reconstruct.obj +.\Debug\scanner.obj +.\Debug\sgp.obj +.\Debug\strfuncs.obj +.\Debug\syserror.obj +.\Debug\trace.obj +.\Debug\transformmatrix.obj +.\Debug\xform.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA4.tmp" +

Output Window

+Compiling... +phantom.cpp +syserror.cpp +backprojectors.cpp +dlgezplot.cpp +filter.cpp +fourier.cpp +globalvars.cpp +hashtable.cpp +imagefile.cpp +plotfile.cpp +pol.cpp +procsignal.cpp +projections.cpp +reconstruct.cpp +scanner.cpp +trace.cpp +Creating library... +

--------------------Configuration: ctsim - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA0.tmp" with contents +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA5.tmp" with contents [ /nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\src\backgroundmgr.cpp" "C:\ctsim\src\backgroundsupr.cpp" +"C:\ctsim\src\graph3dview.cpp" +"C:\ctsim\src\threadproj.cpp" +"C:\ctsim\src\threadrecon.cpp" +"C:\ctsim\src\threadraster.cpp" ] -Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA0.tmp" -Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA1.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA5.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA6.tmp" with contents +[ +/nologo /G6 /MTd /W3 /Gm /Gi /GR /GX /Zi /Od /Gy /I "\wx2.2.5\include" /I "..\..\..\fftw-2.1.3\fftw" /I "\wx2.2.5\src\png" /I "\wx2.2.5\src\zlib" /I "..\..\include" /I "..\..\getopt" /I "..\..\..\fftw-2.1.3\rfftw" /D VERSION=\"3.0.0beta1\" /D "_DEBUG" /D "__WXMSW__" /D "HAVE_SGP" /D "HAVE_PNG" /D "HAVE_WXWINDOWS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HAVE_STRING_H" /D "HAVE_FFTW" /D "HAVE_RFFTW" /D "HAVE_GETOPT_H" /D "MSVC" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D CTSIMVERSION=\"3.0.4\" /D CTSIMVERSION=\"3.0.0alpha5\" /FR"Debug/" /Fp"Debug/ctsim.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"C:\ctsim\src\ctsim.cpp" +"C:\ctsim\src\dialogs.cpp" +"C:\ctsim\src\dlgprojections.cpp" +"C:\ctsim\src\dlgreconstruct.cpp" +"C:\ctsim\src\docs.cpp" +"C:\ctsim\src\views.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA6.tmp" +Creating temporary file "C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA7.tmp" with contents [ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\..\..\fftw-2.1.3\Win32\FFTW2st\Debug\FFTW2st.lib ..\..\..\fftw-2.1.3\Win32\RFFTW2st\Debug\RFFTW2st.lib wxd.lib xpmd.lib tiffd.lib zlibd.lib pngd.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib htmlhelp.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ctsim.pdb" /debug /machine:I386 /out:"Debug/ctsim.exe" /pdbtype:sept /libpath:"\wx2.2.5\lib" .\Debug\backgroundmgr.obj @@ -39,10 +135,22 @@ winmm.lib rpcrt4.lib ws2_32.lib ../libctsim/Debug/libctsim.lib libcmtd.lib ..\.. \wx2.2.5\lib\zlibd.lib \wx2.2.5\lib\tiffd.lib ] -Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA1.tmp" +Creating command line "link.exe @C:\DOCUME~1\kevin\LOCALS~1\Temp\RSPA7.tmp"

Output Window

Compiling... backgroundsupr.cpp +threadproj.cpp +threadrecon.cpp +threadraster.cpp +backgroundmgr.cpp +graph3dview.cpp +Compiling... +ctsim.cpp +dialogs.cpp +dlgprojections.cpp +dlgreconstruct.cpp +docs.cpp +views.cpp Linking...