<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ITK: itkSimpleFilterWatcher.h Source File</title> <link href="DoxygenStyle.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 --> <center> <a href="index.html" class="qindex">Main Page</a> <a href="modules.html" class="qindex">Groups</a> <a href="namespaces.html" class="qindex">Namespace List</a> <a href="hierarchy.html" class="qindex">Class Hierarchy</a> <a href="classes.html" class="qindex">Alphabetical List</a> <a href="annotated.html" class="qindex">Compound List</a> <a href="files.html" class="qindex">File List</a> <a href="namespacemembers.html" class="qindex">Namespace Members</a> <a href="functions.html" class="qindex">Compound Members</a> <a href="globals.html" class="qindex">File Members</a> <a href="pages.html" class="qindex">Concepts</a></center> <!-- Generated by Doxygen 1.5.9 --> <div class="navpath"><a class="el" href="dir_02e23d841c198393a6e961e9a0678fff.html">Code</a> » <a class="el" href="dir_ea7fc529ede9a38b0438cf13831ae873.html">Common</a> </div> <div class="contents"> <h1>itkSimpleFilterWatcher.h</h1><a href="itkSimpleFilterWatcher_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*=========================================================================</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> Program: Insight Segmentation & Registration Toolkit</span> <a name="l00004"></a>00004 <span class="comment"> Module: $RCSfile: itkSimpleFilterWatcher.h,v $</span> <a name="l00005"></a>00005 <span class="comment"> Language: C++</span> <a name="l00006"></a>00006 <span class="comment"> Date: $Date: 2006-11-07 11:56:40 $</span> <a name="l00007"></a>00007 <span class="comment"> Version: $Revision: 1.9 $</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> Copyright (c) Insight Software Consortium. All rights reserved.</span> <a name="l00010"></a>00010 <span class="comment"> See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This software is distributed WITHOUT ANY WARRANTY; without even </span> <a name="l00013"></a>00013 <span class="comment"> the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span> <a name="l00014"></a>00014 <span class="comment"> PURPOSE. See the above copyright notices for more information.</span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment">=========================================================================*/</span> <a name="l00017"></a>00017 <span class="preprocessor">#ifndef __itkSimpleFilterWatcher_h</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define __itkSimpleFilterWatcher_h</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="itkCommand_8h.html">itkCommand.h</a>"</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="itkProcessObject_8h.html">itkProcessObject.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="itkTimeProbe_8h.html">itkTimeProbe.h</a>"</span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="keyword">namespace </span>itk <a name="l00026"></a>00026 { <a name="l00027"></a>00027 <a name="l00063"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html">00063</a> <span class="keyword">class </span><a class="code" href="itkWin32Header_8h.html#faefe352c9fb4179f5a770afc70ea90f">ITKCommon_EXPORT</a> <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a> <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <span class="keyword">public</span>: <a name="l00068"></a>00068 <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>(<a class="code" href="classitk_1_1ProcessObject.html" title="ProcessObject is the base class for all process objects (source, filters, mappers)...">itk::ProcessObject</a>* o, <span class="keyword">const</span> <span class="keywordtype">char</span> *comment=<span class="stringliteral">""</span>); <a name="l00069"></a>00069 <a name="l00071"></a>00071 <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>(<span class="keyword">const</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>& ); <a name="l00072"></a>00072 <a name="l00075"></a>00075 <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>(); <a name="l00076"></a>00076 <a name="l00078"></a>00078 <span class="keywordtype">void</span> operator=(<span class="keyword">const</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>& ); <a name="l00079"></a>00079 <a name="l00081"></a>00081 <span class="keyword">virtual</span> ~<a class="code" href="classitk_1_1SimpleFilterWatcher.html" title="Simple mechanism for monitoring the pipeline events of a filter and reporting these...">SimpleFilterWatcher</a>(); <a name="l00082"></a>00082 <a name="l00085"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#b78be8a3376f8ea884c093fec2902f3f">00085</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="namespaceHardConnectedComponentImageFilter.html#1e7887715ed528b24824746b7f5d5e58">GetNameOfClass</a> () <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="keywordflow">return</span> (m_Process.GetPointer() ? m_Process->GetNameOfClass() : <span class="stringliteral">"None"</span>); <a name="l00088"></a>00088 } <a name="l00089"></a>00089 <a name="l00092"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#358969e7bd7f4f101fda031f6a8875eb">00092</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#358969e7bd7f4f101fda031f6a8875eb">QuietOn</a>() {m_Quiet = <span class="keyword">true</span>;}; <a name="l00093"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#f2993a5f70782efd5564cf4be3da666b">00093</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#f2993a5f70782efd5564cf4be3da666b">QuietOff</a>() {m_Quiet = <span class="keyword">false</span>;}; <a name="l00095"></a>00095 <a name="l00099"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#2e36ffaf6e518875c83317a580d89557">00099</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#2e36ffaf6e518875c83317a580d89557">TestAbortOn</a>() {m_TestAbort = <span class="keyword">true</span>;}; <a name="l00100"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#771409594c749dc53a82f2ba1ab31508">00100</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#771409594c749dc53a82f2ba1ab31508">TestAbortOff</a>() {m_TestAbort = <span class="keyword">false</span>;}; <a name="l00102"></a>00102 <a name="l00106"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#ab0f1fff8a7ee5d723b7e66279a8a2db">00106</a> <a class="code" href="classitk_1_1ProcessObject.html" title="ProcessObject is the base class for all process objects (source, filters, mappers)...">ProcessObject</a> *<a class="code" href="classitk_1_1SimpleFilterWatcher.html#ab0f1fff8a7ee5d723b7e66279a8a2db">GetProcess</a> () {<span class="keywordflow">return</span> m_Process.GetPointer();}; <a name="l00107"></a>00107 <a name="l00109"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#7c20a3985bd569887a8d6885cd3796ec">00109</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#7c20a3985bd569887a8d6885cd3796ec">SetSteps</a>(<span class="keywordtype">int</span> val) {m_Steps=val;}; <a name="l00110"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#1bb2a354d707efcf163f7129a43618b7">00110</a> <span class="keywordtype">int</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#1bb2a354d707efcf163f7129a43618b7">GetSteps</a>() {<span class="keywordflow">return</span> m_Steps;}; <a name="l00112"></a>00112 <a name="l00114"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#25edd5b01475ad92004ba4898d65db2f">00114</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#25edd5b01475ad92004ba4898d65db2f">SetIterations</a>(<span class="keywordtype">int</span> val) {m_Iterations=val;}; <a name="l00115"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#412275589296412d9e8b68cbaa0b39e3">00115</a> <span class="keywordtype">int</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#412275589296412d9e8b68cbaa0b39e3">GetIterations</a>() {<span class="keywordflow">return</span> m_Iterations;}; <a name="l00117"></a>00117 <a name="l00120"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#beb0cf301bf7bcd2b221b855f61a201e">00120</a> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#beb0cf301bf7bcd2b221b855f61a201e">SetQuiet</a>(<span class="keywordtype">bool</span> val) {m_Quiet=val;}; <a name="l00121"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#7a9919754b5c4c5bcdfc0854bab8da7b">00121</a> <span class="keywordtype">bool</span> <a class="code" href="classitk_1_1SimpleFilterWatcher.html#7a9919754b5c4c5bcdfc0854bab8da7b">GetQuiet</a>() {<span class="keywordflow">return</span> m_Quiet;}; <a name="l00123"></a>00123 <a name="l00125"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#caf3e67f83702f367c37b46e6377ca2b">00125</a> std::string <a class="code" href="classitk_1_1SimpleFilterWatcher.html#caf3e67f83702f367c37b46e6377ca2b">GetComment</a>() {<span class="keywordflow">return</span> m_Comment;}; <a name="l00126"></a>00126 <a name="l00128"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#42338a6d97f3f436a506157671d2a1ee">00128</a> <a class="code" href="classitk_1_1TimeProbe.html" title="Class for computing the time passed between two points in the code.">TimeProbe</a> &<a class="code" href="classitk_1_1SimpleFilterWatcher.html#42338a6d97f3f436a506157671d2a1ee">GetTimeProbe</a>() {<span class="keywordflow">return</span> m_TimeProbe;} <a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="keyword">protected</span>: <a name="l00131"></a>00131 <a name="l00133"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#7a09c53c58550eb0b926bb08679fb43c">00133</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> ShowProgress() <a name="l00134"></a>00134 { <a name="l00135"></a>00135 <span class="keywordflow">if</span> (m_Process) <a name="l00136"></a>00136 { <a name="l00137"></a>00137 m_Steps++; <a name="l00138"></a>00138 <span class="keywordflow">if</span> (!m_Quiet) <a name="l00139"></a>00139 { <a name="l00140"></a>00140 std::cout << <span class="stringliteral">" | "</span> << m_Process->GetProgress() << std::flush; <a name="l00141"></a>00141 <span class="keywordflow">if</span> ((m_Steps % 10) == 0) <a name="l00142"></a>00142 { <a name="l00143"></a>00143 std::cout << std::endl; <a name="l00144"></a>00144 } <a name="l00145"></a>00145 } <a name="l00146"></a>00146 <span class="keywordflow">if</span> (m_TestAbort) <a name="l00147"></a>00147 { <a name="l00148"></a>00148 <span class="keywordflow">if</span> (m_Process->GetProgress() > .03) <a name="l00149"></a>00149 { <a name="l00150"></a>00150 m_Process->AbortGenerateDataOn(); <a name="l00151"></a>00151 } <a name="l00152"></a>00152 } <a name="l00153"></a>00153 } <a name="l00154"></a>00154 } <a name="l00156"></a>00156 <a name="l00158"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#c519077b687378bd4fad95ad9c50121e">00158</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> ShowAbort() <a name="l00159"></a>00159 { <a name="l00160"></a>00160 std::cout << std::endl << <span class="stringliteral">"-------Aborted"</span> << std::endl << std::flush; <a name="l00161"></a>00161 } <a name="l00162"></a>00162 <a name="l00164"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#f3248b3bb4c16b5398f52171fa993d9b">00164</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> ShowIteration() <a name="l00165"></a>00165 { <a name="l00166"></a>00166 std::cout << <span class="stringliteral">" # "</span> << std::flush; <a name="l00167"></a>00167 m_Iterations++; <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00171"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#112dcbbbdb04522aac5ac07b07ad4ba7">00171</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> StartFilter() <a name="l00172"></a>00172 { <a name="l00173"></a>00173 m_Steps = 0; <a name="l00174"></a>00174 m_Iterations = 0; <a name="l00175"></a>00175 m_TimeProbe.<a class="code" href="classitk_1_1ResourceProbe.html#c8d3b5d012b4a7a90dbaf0f87dc6a289">Start</a>(); <a name="l00176"></a>00176 std::cout << <span class="stringliteral">"-------- Start "</span> <a name="l00177"></a>00177 << (m_Process.GetPointer() ? m_Process->GetNameOfClass() : <span class="stringliteral">"None"</span>) <a name="l00178"></a>00178 << <span class="stringliteral">" \""</span> << m_Comment << <span class="stringliteral">"\" "</span>; <a name="l00179"></a>00179 <span class="keywordflow">if</span> (!m_Quiet) <a name="l00180"></a>00180 { <a name="l00181"></a>00181 <span class="keywordflow">if</span> (m_Process) <a name="l00182"></a>00182 { <a name="l00183"></a>00183 std::cout << m_Process; <a name="l00184"></a>00184 } <a name="l00185"></a>00185 <span class="keywordflow">else</span> <a name="l00186"></a>00186 { <a name="l00187"></a>00187 std::cout << <span class="stringliteral">"Null"</span>; <a name="l00188"></a>00188 } <a name="l00189"></a>00189 } <a name="l00190"></a>00190 std::cout << (m_Quiet ? <span class="stringliteral">"Progress Quiet "</span> : <span class="stringliteral">"Progress "</span>) <a name="l00191"></a>00191 << std::flush; <a name="l00192"></a>00192 } <a name="l00194"></a>00194 <a name="l00196"></a><a class="code" href="classitk_1_1SimpleFilterWatcher.html#e7ad6192a47ba10cfcc3f9d347670921">00196</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> EndFilter() <a name="l00197"></a>00197 { <a name="l00198"></a>00198 m_TimeProbe.Stop(); <a name="l00199"></a>00199 std::cout << std::endl << <span class="stringliteral">"Filter took "</span> <a name="l00200"></a>00200 << m_TimeProbe.GetMeanTime() <a name="l00201"></a>00201 << <span class="stringliteral">" seconds."</span>; <a name="l00202"></a>00202 std::cout << std::endl <a name="l00203"></a>00203 << <span class="stringliteral">"-------- End "</span> <a name="l00204"></a>00204 << (m_Process.GetPointer() ? m_Process->GetNameOfClass() : <span class="stringliteral">"None"</span>) <a name="l00205"></a>00205 << <span class="stringliteral">" \""</span> << m_Comment << <span class="stringliteral">"\" "</span> << std::endl; <a name="l00206"></a>00206 <span class="keywordflow">if</span> (!m_Quiet) <a name="l00207"></a>00207 { <a name="l00208"></a>00208 <span class="keywordflow">if</span> (m_Process) <a name="l00209"></a>00209 { <a name="l00210"></a>00210 std::cout << m_Process; <a name="l00211"></a>00211 } <a name="l00212"></a>00212 <span class="keywordflow">else</span> <a name="l00213"></a>00213 { <a name="l00214"></a>00214 std::cout << <span class="stringliteral">"None"</span>; <a name="l00215"></a>00215 } <a name="l00216"></a>00216 std::cout << std::flush; <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <span class="keywordflow">if</span> (m_Steps < 1) <a name="l00219"></a>00219 { <a name="l00220"></a>00220 <a class="code" href="itkMacro_8h.html#c51de1a715471e7fd0f2e481a70fa1f8">itkExceptionMacro</a> (<span class="stringliteral">"Filter does not have progress."</span>); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 } <a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="keyword">private</span>: <a name="l00226"></a>00226 <a class="code" href="classitk_1_1TimeProbe.html" title="Class for computing the time passed between two points in the code.">TimeProbe</a> m_TimeProbe; <a name="l00227"></a>00227 <span class="keywordtype">int</span> m_Steps; <a name="l00228"></a>00228 <span class="keywordtype">int</span> m_Iterations; <a name="l00229"></a>00229 <span class="keywordtype">bool</span> m_Quiet; <a name="l00230"></a>00230 <span class="keywordtype">bool</span> m_TestAbort; <a name="l00231"></a>00231 std::string m_Comment; <a name="l00232"></a>00232 <a class="code" href="classitk_1_1SmartPointer.html">itk::ProcessObject::Pointer</a> m_Process; <a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="keyword">typedef</span> <a class="code" href="classitk_1_1SimpleMemberCommand.html" title="Command subclass that calls a pointer to a member function.">SimpleMemberCommand<SimpleFilterWatcher></a> CommandType; <a name="l00235"></a>00235 <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">CommandType::Pointer</a> m_StartFilterCommand; <a name="l00236"></a>00236 <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">CommandType::Pointer</a> m_EndFilterCommand; <a name="l00237"></a>00237 <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">CommandType::Pointer</a> m_ProgressFilterCommand; <a name="l00238"></a>00238 <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">CommandType::Pointer</a> m_IterationFilterCommand; <a name="l00239"></a>00239 <a class="code" href="itkFEMMacro_8h.html#539cce1a3282ba59952dedcbf9cdb23f">CommandType::Pointer</a> m_AbortFilterCommand; <a name="l00240"></a>00240 <a name="l00241"></a>00241 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_StartTag; <a name="l00242"></a>00242 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_EndTag; <a name="l00243"></a>00243 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_ProgressTag; <a name="l00244"></a>00244 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_IterationTag; <a name="l00245"></a>00245 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_AbortTag; <a name="l00246"></a>00246 }; <a name="l00247"></a>00247 <a name="l00248"></a>00248 } <span class="comment">// end namespace itk</span> <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="preprocessor">#endif</span> <a name="l00251"></a>00251 <span class="preprocessor"></span> </pre></div></div> <hr><address><small> Generated at Fri May 8 00:14:05 2009 for ITK by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53> </a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2000</small></address> </body> </html>