<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>VTK: dox/Filtering/vtkAMRBox.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <h1>dox/Filtering/vtkAMRBox.h</h1><a href="a02191.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: Visualization Toolkit</span> <a name="l00004"></a>00004 <span class="comment"> Module: $RCSfile: vtkAMRBox.h,v $</span> <a name="l00005"></a>00005 <span class="comment"></span> <a name="l00006"></a>00006 <span class="comment"> Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen</span> <a name="l00007"></a>00007 <span class="comment"> All rights reserved.</span> <a name="l00008"></a>00008 <span class="comment"> See Copyright.txt or http://www.kitware.com/Copyright.htm for details.</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment"> This software is distributed WITHOUT ANY WARRANTY; without even</span> <a name="l00011"></a>00011 <span class="comment"> the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR</span> <a name="l00012"></a>00012 <span class="comment"> PURPOSE. See the above copyright notice for more information.</span> <a name="l00013"></a>00013 <span class="comment"></span> <a name="l00014"></a>00014 <span class="comment">=========================================================================*/</span> <a name="l00035"></a>00035 <span class="preprocessor">#ifndef __vtkAMRBox_h</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define __vtkAMRBox_h</span> <a name="l00037"></a>00037 <span class="preprocessor"></span> <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="a02079.html">vtkObject.h</a>"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="a02149.html">vtkType.h</a>"</span><span class="comment">//For utility functions.</span> <a name="l00040"></a>00040 <span class="preprocessor">#include <vtkstd/vector></span><span class="comment">//For utility functions.</span> <a name="l00041"></a>00041 <a name="l00042"></a><a class="code" href="a00104.html">00042</a> <span class="keyword">class </span><a class="code" href="a02170.html#95ced7977a6b6b1bf9f38bf04e3835b6">VTK_FILTERING_EXPORT</a> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> <a name="l00043"></a>00043 { <a name="l00044"></a>00044 <span class="keyword">public</span>: <a name="l00046"></a>00046 <a name="l00047"></a>00047 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keywordtype">int</span> dim=3); <a name="l00048"></a>00048 <span class="comment">// Description:</span> <a name="l00049"></a>00049 <span class="comment">// Construct a specific 3D box.</span> <a name="l00050"></a>00050 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>( <a name="l00051"></a>00051 <span class="keywordtype">int</span> ilo,<span class="keywordtype">int</span> jlo,<span class="keywordtype">int</span> klo, <a name="l00052"></a>00052 <span class="keywordtype">int</span> ihi,<span class="keywordtype">int</span> jhi,<span class="keywordtype">int</span> khi); <a name="l00053"></a>00053 <span class="comment">// Description:</span> <a name="l00054"></a>00054 <span class="comment">// Construct a specific 2D box.</span> <a name="l00055"></a>00055 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>( <a name="l00056"></a>00056 <span class="keywordtype">int</span> ilo,<span class="keywordtype">int</span> jlo, <a name="l00057"></a>00057 <span class="keywordtype">int</span> ihi,<span class="keywordtype">int</span> jhi); <a name="l00058"></a>00058 <span class="comment">// Description:</span> <a name="l00059"></a>00059 <span class="comment">// Construct a specific box. (ilo,jlo,klo,)(ihi,jhi,khi)</span> <a name="l00060"></a>00060 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keywordtype">int</span> dim, <span class="keyword">const</span> <span class="keywordtype">int</span> lo[3], <span class="keyword">const</span> <span class="keywordtype">int</span> hi[3]); <a name="l00061"></a>00061 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> lo[3], <span class="keyword">const</span> <span class="keywordtype">int</span> hi[3]); <a name="l00062"></a>00062 <span class="comment">// Description:</span> <a name="l00063"></a>00063 <span class="comment">// Construct a specific box. (ilo,ihi, jlo,jhi, klo,khi)</span> <a name="l00064"></a>00064 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keywordtype">int</span> dim, <span class="keyword">const</span> <span class="keywordtype">int</span> dims[6]); <a name="l00065"></a>00065 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> dims[6]); <a name="l00066"></a>00066 <span class="comment">// Description:</span> <a name="l00067"></a>00067 <span class="comment">// Copy construct this box from another.</span> <a name="l00068"></a>00068 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a>(<span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &other); <a name="l00069"></a>00069 <span class="comment">// Description:</span> <a name="l00070"></a>00070 <span class="comment">// Copy the other box to this box.</span> <a name="l00071"></a>00071 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &operator=(<span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &other); <a name="l00072"></a>00072 <span class="comment">// Description:</span> <a name="l00073"></a>00073 <span class="comment">// Set the box to null;</span> <a name="l00074"></a>00074 <span class="keywordtype">void</span> Invalidate(); <a name="l00075"></a>00075 <span class="comment">// Description:</span> <a name="l00076"></a>00076 <span class="comment">// Get/Set the spatial dimension of the box. Only 2 and 3 </span> <a name="l00077"></a>00077 <span class="comment">// are valid.</span> <a name="l00078"></a><a class="code" href="a00104.html#6b5c42f9da69b8c1268224475816f53c">00078</a> <span class="keywordtype">int</span> GetDimensionality()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this->Dimension; } <a name="l00079"></a>00079 <span class="keywordtype">void</span> SetDimensionality(<span class="keywordtype">int</span> dim); <a name="l00080"></a>00080 <span class="comment">// Description:</span> <a name="l00081"></a>00081 <span class="comment">// Set the dimensions of the box. ilo,jlo,klo,ihi,jhi,khi</span> <a name="l00082"></a>00082 <span class="keywordtype">void</span> SetDimensions( <a name="l00083"></a>00083 <span class="keywordtype">int</span> ilo, <span class="keywordtype">int</span> jlo, <span class="keywordtype">int</span> klo, <a name="l00084"></a>00084 <span class="keywordtype">int</span> ihi, <span class="keywordtype">int</span> jhi, <span class="keywordtype">int</span> khi); <a name="l00085"></a>00085 <span class="comment">// Description:</span> <a name="l00086"></a>00086 <span class="comment">// Set the dimensions of the box. (ilo,jlo,klo),(ihi,jhi,khi)</span> <a name="l00087"></a>00087 <span class="keywordtype">void</span> SetDimensions(<span class="keyword">const</span> <span class="keywordtype">int</span> lo[3], <span class="keyword">const</span> <span class="keywordtype">int</span> hi[3]); <a name="l00088"></a>00088 <span class="comment">// Description:</span> <a name="l00089"></a>00089 <span class="comment">// Set the dimensions of the box. (ilo,ihi,jlo,jhi,klo,khi)</span> <a name="l00090"></a>00090 <span class="keywordtype">void</span> SetDimensions(<span class="keyword">const</span> <span class="keywordtype">int</span> dims[6]); <a name="l00091"></a>00091 <span class="comment">// Description:</span> <a name="l00092"></a>00092 <span class="comment">// Get the dimensions of this box. (ilo,jlo,jhi),(ihi,jhi,khi)</span> <a name="l00093"></a>00093 <span class="keywordtype">void</span> GetDimensions(<span class="keywordtype">int</span> lo[3], <span class="keywordtype">int</span> hi[3]) <span class="keyword">const</span>; <a name="l00094"></a>00094 <span class="comment">// Description:</span> <a name="l00095"></a>00095 <span class="comment">// Get the dimensions of this box. (ilo,ihi, jlo,jhi, klo,khi)</span> <a name="l00096"></a>00096 <span class="keywordtype">void</span> GetDimensions(<span class="keywordtype">int</span> dims[6]) <span class="keyword">const</span>; <a name="l00097"></a>00097 <span class="comment">// Description:</span> <a name="l00098"></a>00098 <span class="comment">// Get the low corner index.</span> <a name="l00099"></a>00099 <span class="keywordtype">void</span> GetLoCorner(<span class="keywordtype">int</span> lo[3]) <span class="keyword">const</span>; <a name="l00100"></a><a class="code" href="a00104.html#b86e47c6001725ab83f8b68fd07e80e3">00100</a> <span class="keyword">const</span> <span class="keywordtype">int</span> *GetLoCorner()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this->LoCorner; } <a name="l00101"></a>00101 <span class="comment">// Description:</span> <a name="l00102"></a>00102 <span class="comment">// Copy the high corner index.</span> <a name="l00103"></a>00103 <span class="keywordtype">void</span> GetHiCorner(<span class="keywordtype">int</span> hi[3]) <span class="keyword">const</span>; <a name="l00104"></a><a class="code" href="a00104.html#a2dfcafb6ed448d9c9902391c19e4a73">00104</a> <span class="keyword">const</span> <span class="keywordtype">int</span> *GetHiCorner()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this->HiCorner; } <a name="l00105"></a>00105 <span class="comment">// Description:</span> <a name="l00106"></a>00106 <span class="comment">// Gets the number of cells enclosed by the box.</span> <a name="l00107"></a>00107 <span class="keywordtype">void</span> GetNumberOfCells(<span class="keywordtype">int</span> ext[3]) <span class="keyword">const</span>; <a name="l00108"></a>00108 <a class="code" href="a02149.html#20bd6b6dedfe1bbb096c50354d52cc7e">vtkIdType</a> GetNumberOfCells() <span class="keyword">const</span>; <a name="l00109"></a>00109 <span class="comment">// Description:</span> <a name="l00110"></a>00110 <span class="comment">// Gets the number of nodes required to construct</span> <a name="l00111"></a>00111 <span class="comment">// a physical representation of the box.</span> <a name="l00112"></a>00112 <span class="keywordtype">void</span> GetNumberOfNodes(<span class="keywordtype">int</span> ext[3]) <span class="keyword">const</span>; <a name="l00113"></a>00113 <a class="code" href="a02149.html#20bd6b6dedfe1bbb096c50354d52cc7e">vtkIdType</a> GetNumberOfNodes() <span class="keyword">const</span>; <a name="l00114"></a>00114 <span class="comment">// Description:</span> <a name="l00115"></a>00115 <span class="comment">// Set/Get grid spacing. Refine/coarsen operations update</span> <a name="l00116"></a>00116 <span class="comment">// the grid spacing.</span> <a name="l00117"></a><a class="code" href="a00104.html#773ba63d3a5bc6ce03b146188721c53c">00117</a> <span class="keyword">const</span> <span class="keywordtype">double</span> *GetGridSpacing()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this->DX; } <a name="l00118"></a>00118 <span class="keywordtype">void</span> GetGridSpacing(<span class="keywordtype">double</span> dX[3]) <span class="keyword">const</span>; <a name="l00119"></a>00119 <span class="keywordtype">void</span> SetGridSpacing(<span class="keywordtype">double</span> dx); <a name="l00120"></a>00120 <span class="keywordtype">void</span> SetGridSpacing(<span class="keyword">const</span> <span class="keywordtype">double</span> dX[3]); <a name="l00121"></a>00121 <span class="keywordtype">void</span> SetGridSpacing(<span class="keywordtype">double</span> dx, <span class="keywordtype">double</span> dy, <span class="keywordtype">double</span> dz); <a name="l00122"></a>00122 <span class="comment">// Description:</span> <a name="l00123"></a>00123 <span class="comment">// Set/Get world space origin of the data set, The origin</span> <a name="l00124"></a>00124 <span class="comment">// is the location of the low corner cell's low corner node</span> <a name="l00125"></a>00125 <span class="comment">// of the data set. Which is not necessarilly the origin of</span> <a name="l00126"></a>00126 <span class="comment">// this box! For that use GetBoxOrigin().</span> <a name="l00127"></a><a class="code" href="a00104.html#20b3664f8007d3d488b02a510180b4af">00127</a> <span class="keyword">const</span> <span class="keywordtype">double</span> *GetDataSetOrigin()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this->X0; } <a name="l00128"></a>00128 <span class="keywordtype">void</span> GetDataSetOrigin(<span class="keywordtype">double</span> X0[3]) <span class="keyword">const</span>; <a name="l00129"></a>00129 <span class="keywordtype">void</span> SetDataSetOrigin(<span class="keyword">const</span> <span class="keywordtype">double</span> X0[3]); <a name="l00130"></a>00130 <span class="keywordtype">void</span> SetDataSetOrigin(<span class="keywordtype">double</span> x0, <span class="keywordtype">double</span> y0, <span class="keywordtype">double</span> z0); <a name="l00131"></a>00131 <span class="comment">// Description:</span> <a name="l00132"></a>00132 <span class="comment">// Get the world space origin of this box. The origin is the</span> <a name="l00133"></a>00133 <span class="comment">// location of the lower corner cell's lower corner node,</span> <a name="l00134"></a>00134 <span class="comment">// which is not necessarilly the orgin of the data set! For</span> <a name="l00135"></a>00135 <span class="comment">// that use GetDataSetOrigin(). The value is computed each time,</span> <a name="l00136"></a>00136 <span class="comment">// so that operations on the box are are appropriately reflected.</span> <a name="l00137"></a>00137 <span class="keywordtype">void</span> GetBoxOrigin(<span class="keywordtype">double</span> x0[3]) <span class="keyword">const</span>; <a name="l00138"></a>00138 <span class="comment">// Description:</span> <a name="l00139"></a>00139 <span class="comment">// Grows the box in all directions.</span> <a name="l00140"></a>00140 <span class="keywordtype">void</span> Grow(<span class="keywordtype">int</span> byN); <a name="l00141"></a>00141 <span class="comment">// Description:</span> <a name="l00142"></a>00142 <span class="comment">// Shrinks the box in all directions.</span> <a name="l00143"></a>00143 <span class="keywordtype">void</span> Shrink(<span class="keywordtype">int</span> byN); <a name="l00144"></a>00144 <span class="comment">// Description:</span> <a name="l00145"></a>00145 <span class="comment">// Shifts the box in index space.</span> <a name="l00146"></a>00146 <span class="keywordtype">void</span> Shift(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j); <a name="l00147"></a>00147 <span class="keywordtype">void</span> Shift(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j, <span class="keywordtype">int</span> k); <a name="l00148"></a>00148 <span class="keywordtype">void</span> Shift(<span class="keyword">const</span> <span class="keywordtype">int</span> I[3]); <a name="l00149"></a>00149 <span class="comment">// Description:</span> <a name="l00150"></a>00150 <span class="comment">// Test if this box is empty/valid.</span> <a name="l00151"></a>00151 <span class="keywordtype">bool</span> Empty() <span class="keyword">const</span>; <a name="l00152"></a>00152 <span class="comment">// Description:</span> <a name="l00153"></a>00153 <span class="comment">// Test if this box has the same dimensions as another.</span> <a name="l00154"></a>00154 <span class="keywordtype">bool</span> <a class="code" href="a02263.html#544428171128ab0363576bae16711623">operator==</a>(<span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &other); <a name="l00155"></a>00155 <span class="comment">// Description:</span> <a name="l00156"></a>00156 <span class="comment">// Intersect this box with another box in place.</span> <a name="l00157"></a>00157 <span class="keywordtype">void</span> operator&=(<span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &rhs); <a name="l00158"></a>00158 <span class="comment">// Description:</span> <a name="l00159"></a>00159 <span class="comment">// Test to see if a given cell index is inside this box.</span> <a name="l00160"></a>00160 <span class="keywordtype">bool</span> Contains(<span class="keywordtype">int</span> i,<span class="keywordtype">int</span> j,<span class="keywordtype">int</span> k) <span class="keyword">const</span>; <a name="l00161"></a>00161 <span class="keywordtype">bool</span> Contains(<span class="keyword">const</span> <span class="keywordtype">int</span> I[3]) <span class="keyword">const</span>; <a name="l00162"></a>00162 <span class="comment">// Description:</span> <a name="l00163"></a>00163 <span class="comment">// Test to see if a given box is inside this box.</span> <a name="l00164"></a>00164 <span class="keywordtype">bool</span> Contains(<span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &other) <span class="keyword">const</span>; <a name="l00165"></a>00165 <span class="comment">// Description:</span> <a name="l00166"></a>00166 <span class="comment">// Refine the box.</span> <a name="l00167"></a>00167 <span class="keywordtype">void</span> Refine(<span class="keywordtype">int</span> r); <a name="l00168"></a>00168 <span class="comment">// Description:</span> <a name="l00169"></a>00169 <span class="comment">// Coarsen the box.</span> <a name="l00170"></a>00170 <span class="keywordtype">void</span> Coarsen(<span class="keywordtype">int</span> r); <a name="l00171"></a>00171 <span class="comment">// Description:</span> <a name="l00172"></a>00172 <span class="comment">// Send the box to a stream. "(ilo,jlo,jhi),(ihi,jhi,khi)"</span> <a name="l00173"></a>00173 ostream &Print(ostream &os) <span class="keyword">const</span>; <a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="comment">//BTX</span> <a name="l00177"></a>00177 <span class="comment">// @deprecated Replaced by Contains() as of VTK 5.4.</span> <a name="l00178"></a>00178 <span class="comment">// Do not use! See Contains().</span> <a name="l00179"></a>00179 VTK_LEGACY(<span class="keywordtype">int</span> DoesContainCell(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j, <span class="keywordtype">int</span> k)); <a name="l00180"></a>00180 <span class="comment">// @deprecated Replaced by Contains() as of VTK 5.4.</span> <a name="l00181"></a>00181 <span class="comment">// Do not use! See Contains().</span> <a name="l00182"></a>00182 VTK_LEGACY(<span class="keywordtype">int</span> DoesContainBox(<a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> <span class="keyword">const</span> & box) <span class="keyword">const</span>); <a name="l00183"></a>00183 <span class="comment">//ETX</span> <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keyword">public</span>: <a name="l00187"></a>00187 <a name="l00191"></a><a class="code" href="a00104.html#ad5b802303e10f625fe018b18a769c8d">00191</a> <span class="keywordtype">int</span> LoCorner[3]; <span class="comment">// lo corner cell id.</span> <a name="l00192"></a><a class="code" href="a00104.html#27ef6e917fdaefcdad0f5c4f526aa64b">00192</a> <span class="keywordtype">int</span> HiCorner[3]; <span class="comment">// hi corner cell id.</span> <a name="l00194"></a>00194 <span class="comment"></span><span class="keyword">private</span>: <a name="l00195"></a>00195 <span class="keywordtype">int</span> Dimension; <span class="comment">// 2 or 3.</span> <a name="l00196"></a>00196 <span class="keywordtype">double</span> X0[3]; <span class="comment">// Dataset origin (not box origin). low corner cell's, low corner node.</span> <a name="l00197"></a>00197 <span class="keywordtype">double</span> DX[3]; <span class="comment">// grid spacing.</span> <a name="l00198"></a>00198 }; <a name="l00199"></a>00199 <a name="l00200"></a>00200 <span class="comment">// NOTE 2008-11-10</span> <a name="l00201"></a>00201 <span class="comment">// Favor the set'ers above to this helper, where ever possible.</span> <a name="l00202"></a>00202 <span class="comment">// Helper to unroll the loop</span> <a name="l00203"></a>00203 <span class="keyword">template</span><<span class="keywordtype">int</span> dimension> <a name="l00204"></a>00204 <span class="keyword">struct </span>vtkAMRBoxInitializeHelp; <a name="l00205"></a>00205 <span class="keyword">template</span><<span class="keywordtype">int</span> dimension> <a name="l00206"></a><a class="code" href="a02191.html#b3a8a031139ffb0b499d2850eaa276c4">00206</a> <span class="keywordtype">void</span> <a class="code" href="a02191.html#b3a8a031139ffb0b499d2850eaa276c4">vtkAMRBoxInitialize</a>( <a name="l00207"></a>00207 <span class="keywordtype">int</span> *LoCorner, <a name="l00208"></a>00208 <span class="keywordtype">int</span> *HiCorner, <span class="comment">// member</span> <a name="l00209"></a>00209 <span class="keyword">const</span> <span class="keywordtype">int</span> *loCorner, <a name="l00210"></a>00210 <span class="keyword">const</span> <span class="keywordtype">int</span> *hiCorner, <span class="comment">// local</span> <a name="l00211"></a>00211 vtkAMRBoxInitializeHelp<dimension>* = 0) <span class="comment">// dummy parameter for vs6</span> <a name="l00212"></a>00212 { <a name="l00213"></a>00213 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<dimension; ++i) <a name="l00214"></a>00214 { <a name="l00215"></a>00215 LoCorner[i] = loCorner[i]; <a name="l00216"></a>00216 HiCorner[i] = hiCorner[i]; <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=dimension; i<(3-dimension); ++i) <a name="l00219"></a>00219 { <a name="l00220"></a>00220 LoCorner[i] = 0; <a name="l00221"></a>00221 HiCorner[i] = 0; <a name="l00222"></a>00222 } <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="comment">//*****************************************************************************</span> <a name="l00227"></a>00227 <span class="comment"></span> <a name="l00229"></a>00229 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00230"></a><a class="code" href="a02191.html#fa2f5b7d34fa1b4ecc7ae44483601be5">00230</a> <span class="keywordtype">void</span> <a class="code" href="a02191.html#fa2f5b7d34fa1b4ecc7ae44483601be5">FillRegion</a>( <a name="l00231"></a>00231 T *pArray, <a name="l00232"></a>00232 <span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &arrayRegion, <a name="l00233"></a>00233 <span class="keyword">const</span> <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> &destRegion, <a name="l00234"></a>00234 T fillValue) <a name="l00236"></a>00236 { <a name="l00237"></a>00237 <span class="comment">// Convert regions to array index space. VTK arrays</span> <a name="l00238"></a>00238 <span class="comment">// always start with 0,0,0.</span> <a name="l00239"></a>00239 <span class="keywordtype">int</span> ofs[3]; <a name="l00240"></a>00240 arrayRegion.<a class="code" href="a00104.html#6517e6c2c6df6d00f0325af1f2b90c90">GetLoCorner</a>(ofs); <a name="l00241"></a>00241 ofs[0]=-ofs[0]; <a name="l00242"></a>00242 ofs[1]=-ofs[1]; <a name="l00243"></a>00243 ofs[2]=-ofs[2]; <a name="l00244"></a>00244 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> arrayDims(arrayRegion); <a name="l00245"></a>00245 arrayDims.<a class="code" href="a00104.html#d98fc938c411be7d3e358eb77bdeb495">Shift</a>(ofs); <a name="l00246"></a>00246 <a class="code" href="a00104.html" title="Encloses a rectangular region of voxel like cells.">vtkAMRBox</a> destDims(destRegion); <a name="l00247"></a>00247 destDims.<a class="code" href="a00104.html#d98fc938c411be7d3e358eb77bdeb495">Shift</a>(ofs); <a name="l00248"></a>00248 <span class="comment">// Quick sanity check.</span> <a name="l00249"></a>00249 <span class="keywordflow">if</span> (!arrayRegion.<a class="code" href="a00104.html#e83e0d78b4cd7e0b6e5ca14533d4fc94">Contains</a>(destRegion)) <a name="l00250"></a>00250 { <a name="l00251"></a>00251 vtkGenericWarningMacro( <a name="l00252"></a>00252 << <span class="stringliteral">"ERROR: Array must enclose the destination region. "</span> <a name="l00253"></a>00253 << <span class="stringliteral">"Aborting the fill."</span>); <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <span class="comment">// Get the bounds of the indices we fill.</span> <a name="l00256"></a>00256 <span class="keywordtype">int</span> destLo[3]; <a name="l00257"></a>00257 destDims.<a class="code" href="a00104.html#6517e6c2c6df6d00f0325af1f2b90c90">GetLoCorner</a>(destLo); <a name="l00258"></a>00258 <span class="keywordtype">int</span> destHi[3]; <a name="l00259"></a>00259 destDims.<a class="code" href="a00104.html#0c37b29420b783dd6ab61c0c089ca866">GetHiCorner</a>(destHi); <a name="l00260"></a>00260 <span class="comment">// Get the array dimensions.</span> <a name="l00261"></a>00261 <span class="keywordtype">int</span> arrayHi[3]; <a name="l00262"></a>00262 arrayDims.<a class="code" href="a00104.html#4989c4015517644f9de5e2ed5e946bc9">GetNumberOfCells</a>(arrayHi); <a name="l00263"></a>00263 <span class="comment">// Fill.</span> <a name="l00264"></a>00264 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k=destLo[2]; k<=destHi[2]; ++k) <a name="l00265"></a>00265 { <a name="l00266"></a>00266 <a class="code" href="a02149.html#20bd6b6dedfe1bbb096c50354d52cc7e">vtkIdType</a> kOfs=k*arrayHi[0]*arrayHi[1]; <a name="l00267"></a>00267 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=destLo[1]; j<=destHi[1]; ++j) <a name="l00268"></a>00268 { <a name="l00269"></a>00269 <a class="code" href="a02149.html#20bd6b6dedfe1bbb096c50354d52cc7e">vtkIdType</a> idx=kOfs+j*arrayHi[0]+destLo[0]; <a name="l00270"></a>00270 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=destLo[0]; i<=destHi[0]; ++i) <a name="l00271"></a>00271 { <a name="l00272"></a>00272 pArray[idx]=fillValue; <a name="l00273"></a>00273 ++idx; <a name="l00274"></a>00274 } <a name="l00275"></a>00275 } <a name="l00276"></a>00276 } <a name="l00277"></a>00277 } <a name="l00278"></a>00278 <a name="l00282"></a>00282 <span class="keywordtype">void</span> <a class="code" href="a02191.html#fdafee8973deea2f195544e74846d461">Split</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> N[3], <span class="keyword">const</span> <span class="keywordtype">int</span> minSide[3], vtkstd::vector<vtkAMRBox> &decomp); <a name="l00283"></a>00283 <a name="l00287"></a>00287 <span class="keywordtype">void</span> <a class="code" href="a02191.html#fdafee8973deea2f195544e74846d461">Split</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> minSide[3], vtkstd::vector<vtkAMRBox> &decomp); <a name="l00288"></a>00288 <a name="l00289"></a>00289 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Wed Jun 3 18:35:14 2009 for VTK by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> </body> </html>