<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Crystal Space 1.2.1: csgeom/subrec.h Source File (Crystal Space 1.2.1 Public API Reference)</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="head"> <tr height="59"> <td class="head" width="202" valign="bottom" style="padding-left:0;"><a href="http://www.crystalspace3d.org/"><img src="csblur.png" width="236" height="59" alt="CrystalSpace" border="0"></a></td> <td class="head"><h2>Public API Reference</h2></td> </tr> <tr height="11"> <td colspan="2" class="headshadow" valign="top" style="padding-left:0;"><img src="csblurb.png" width="236" height="11" alt="" border="0"></td> </tr> </table> <div class="content"> <!-- Generated by Doxygen 1.5.3 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</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> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul> </div> <h1>csgeom/subrec.h</h1><a href="subrec_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"> Copyright (C) 2001-2005 by Jorrit Tyberghein</span> <a name="l00003"></a>00003 <span class="comment"> 2003-2005 by Frank Richter</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00006"></a>00006 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00007"></a>00007 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00008"></a>00008 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment"></span> <a name="l00010"></a>00010 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00011"></a>00011 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00012"></a>00012 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00013"></a>00013 <span class="comment"> Library General Public License for more details.</span> <a name="l00014"></a>00014 <span class="comment"></span> <a name="l00015"></a>00015 <span class="comment"> You should have received a copy of the GNU Library General Public</span> <a name="l00016"></a>00016 <span class="comment"> License along with this library; if not, write to the Free</span> <a name="l00017"></a>00017 <span class="comment"> Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00018"></a>00018 <span class="comment">*/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef __CS_SUBREC_H__</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define __CS_SUBREC_H__</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00030"></a>00030 <span class="preprocessor">#include "csextern.h"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="csrect_8h.html" title="Rectangle class.">csgeom/csrect.h</a>"</span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="csutil_2array_8h.html" title="Generic Array Template.">csutil/array.h</a>"</span> <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="blockallocator_8h.html" title="Generic Memory Block Allocator.">csutil/blockallocator.h</a>"</span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="keyword">namespace </span>CS <a name="l00038"></a>00038 { <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="keyword">class </span>SubRectanglesCompact; <a name="l00041"></a>00041 <a name="l00048"></a><a class="code" href="classCS_1_1SubRectangles.html">00048</a> <span class="keyword">class </span>CS_CRYSTALSPACE_EXPORT <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a> : <span class="keyword">public</span> CS::Memory::CustomAllocated <a name="l00049"></a>00049 { <a name="l00050"></a>00050 <span class="keyword">public</span>: <a name="l00054"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html">00054</a> <span class="keyword">class </span><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a> <a name="l00055"></a>00055 { <a name="l00056"></a>00056 <span class="keyword">private</span>: <a name="l00057"></a>00057 <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> rect; <a name="l00058"></a>00058 <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> allocedRect; <a name="l00059"></a>00059 <span class="keyword">protected</span>: <a name="l00060"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#37c6f813e8d4c992be9a002a13bb409d">00060</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a>; <a name="l00061"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#770e8d2f724fd191eadf14ad4971b366">00061</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCS_1_1SubRectanglesCompact.html" title="A variation of SubRectangles that tries to place rectangles in a rectangular fashion...">SubRectanglesCompact</a>; <a name="l00062"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#9691acdff806dd62e00473b09024301c">00062</a> <span class="keyword">typedef</span> <a class="code" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">csBlockAllocator<SubRect></a> <a class="code" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">SubRectAlloc</a>; <a name="l00063"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#1b54d9b106fee3eabc93ee4e60ea981f">00063</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">csBlockAllocator</a><<a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>>; <span class="comment">// SubRectAlloc</span> <a name="l00064"></a>00064 <a name="l00065"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86">00065</a> <span class="keyword">enum</span> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86">SplitType</a> <a name="l00066"></a>00066 { <a name="l00067"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f869ae831cbf61f8f389781fcbaa3207198">00067</a> SPLIT_UNSPLIT, <a name="l00068"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86ae8489befe61863eedc700ea934986ed">00068</a> SPLIT_H, <a name="l00069"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86b48691f2c11f8596e0e686569af5a3c2">00069</a> SPLIT_V <a name="l00070"></a>00070 }; <a name="l00071"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a5">00071</a> <span class="keyword">enum</span> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a5">AllocPos</a> <a name="l00072"></a>00072 { <a name="l00073"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a5694189fe142794a93483a716bd2cf084">00073</a> ALLOC_INVALID = -1, <a name="l00074"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a502ff26a4219ce0ad245cee935ff563e6">00074</a> ALLOC_RIGHT, <a name="l00075"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a5036060a33e6877837ac3d325861b9745">00075</a> ALLOC_BELOW, <a name="l00076"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a546f70afdd44b54b55de1bba95a0aa13b">00076</a> ALLOC_NEW <a name="l00077"></a>00077 }; <a name="l00078"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html">00078</a> <span class="keyword">struct </span><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html">AllocInfo</a> <a name="l00079"></a>00079 { <a name="l00080"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html#9a16d5ac94d7ab5dfc527e1782f3ff46">00080</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* node; <a name="l00081"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html#3ade502f241a4ff5c48bafa8c5fd8e5c">00081</a> <span class="keywordtype">int</span> d; <a name="l00082"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html#8de8f878ef785c7d800c9d73d3ea6252">00082</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#61180f4644eba16f99c4558e798077a5">AllocPos</a> allocPos; <a name="l00083"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html#2b34e48e7536168d0712fd2592de2d9f">00083</a> <span class="keywordtype">bool</span> res; <a name="l00084"></a>00084 <a name="l00085"></a><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html#2fe38facdbce1eeda22da6ea2f8a36ea">00085</a> <a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html">AllocInfo</a>() : node(0), d(0x7fffffff), allocPos(ALLOC_INVALID), <a name="l00086"></a>00086 res(false) {}; <a name="l00087"></a>00087 }; <a name="l00088"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#c9968daa18f50edaffba29d10f3eee70">00088</a> <span class="keyword">friend</span> <span class="keyword">struct </span><a class="code" href="structCS_1_1SubRectangles_1_1SubRect_1_1AllocInfo.html">AllocInfo</a>; <span class="comment">// Give MSVC6 access to ALLOC_INVALID.</span> <a name="l00089"></a>00089 <a name="l00090"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#0d5c427d478c0009a0517d6f8b0052b5">00090</a> <span class="keywordtype">int</span> splitPos; <a name="l00091"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#24bc3f2e74a848465982bf976404cd8f">00091</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86">SplitType</a> splitType; <a name="l00092"></a>00092 <a name="l00093"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#2ad3257a175e909bc33789afc612b114">00093</a> <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a>* superrect; <a name="l00094"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#df949e95a8557ae01a8a0697563bf6c2">00094</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* parent; <a name="l00095"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#d87e3cb7a7fa0efee13d870fb78b4af2">00095</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* children[2]; <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a> (); <a name="l00098"></a>00098 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>& operator= (<span class="keyword">const</span> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>& other); <a name="l00099"></a>00099 <a name="l00101"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#0e17dbb19a393ef2486666b33072db8e">00101</a> <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& GetRect()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rect; } <a name="l00103"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#9718ffbae84e77e84ffcc9dec176c1f3">00103</a> <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& GetAllocedRect()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> allocedRect; } <a name="l00105"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#b2284e7d29de4bf65bf8b734ad7ba82d">00105</a> <span class="keywordtype">void</span> MakeEmpty () <a name="l00106"></a>00106 { allocedRect.Set (0, 0, -1, -1); } <a name="l00108"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#be47208a3b0a2d52c2242bd502c905a9">00108</a> <span class="keywordtype">bool</span> IsEmpty ()<span class="keyword"> const</span> <a name="l00109"></a>00109 <span class="keyword"> </span>{ <span class="keywordflow">return</span> (allocedRect.xmax < 0) || (allocedRect.ymax < 0); } <a name="l00110"></a>00110 <a name="l00112"></a>00112 <span class="keywordtype">void</span> TestAlloc (<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, AllocInfo& ai); <a name="l00114"></a>00114 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* Alloc (<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <span class="keyword">const</span> AllocInfo& ai, <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& r); <a name="l00116"></a>00116 <span class="keywordtype">void</span> Reclaim (); <a name="l00117"></a><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#6655894a935092f184d31fd4ae75b545">00117</a> <span class="keywordtype">bool</span> IsReclaimed()<span class="keyword"> const</span> <a name="l00118"></a>00118 <span class="keyword"> </span>{ <span class="keywordflow">return</span> IsEmpty() && (splitType == SPLIT_UNSPLIT); } <a name="l00120"></a>00120 <span class="keywordtype">void</span> TestCollapse (); <a name="l00121"></a>00121 <a name="l00124"></a>00124 <span class="keywordtype">void</span> DecideBestSplit (<span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& rect, <span class="keywordtype">int</span> splitX, <span class="keywordtype">int</span> splitY, <a name="l00125"></a>00125 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#a09484eef8cad8fc9da506ff32c49f86">SubRect::SplitType</a>& splitType); <a name="l00126"></a>00126 }; <a name="l00127"></a><a class="code" href="classCS_1_1SubRectangles.html#6cea3452ad7652661e084b42e1b98099">00127</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>; <span class="comment">// Give MSVC6 access to enclosing protected scope.</span> <a name="l00128"></a>00128 <span class="keyword">protected</span>: <a name="l00130"></a><a class="code" href="classCS_1_1SubRectangles.html#035b3f2df91bb39a03bb4c5c386c1141">00130</a> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> region; <a name="l00132"></a><a class="code" href="classCS_1_1SubRectangles.html#c5b6e4402e032ceaef77972330398a4c">00132</a> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* root; <a name="l00133"></a>00133 <a name="l00134"></a><a class="code" href="classCS_1_1SubRectangles.html#f95603b00df37194183c44023e07d4c9">00134</a> <a class="code" href="classcsBlockAllocator.html" title="This class implements a memory allocator which can efficiently allocate objects that...">SubRect::SubRectAlloc</a> alloc; <a name="l00135"></a><a class="code" href="classCS_1_1SubRectangles.html#205b0278b4caae3b2f599820cae7cb25">00135</a> <span class="keyword">inline</span> <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* AllocSubrect () <a name="l00136"></a>00136 { <a name="l00137"></a>00137 <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* sr = alloc.Alloc(); <a name="l00138"></a>00138 sr-><a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html#2ad3257a175e909bc33789afc612b114">superrect</a> = <span class="keyword">this</span>; <a name="l00139"></a>00139 <span class="keywordflow">return</span> sr; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <span class="keywordtype">void</span> FreeSubrect (SubRect* sr); <a name="l00142"></a>00142 <a name="l00144"></a><a class="code" href="classCS_1_1SubRectangles.html#825119f59433a2cccff92746341cc3ca">00144</a> <a class="code" href="classcsArray.html" title="A templated array class.">csArray<SubRect*></a> leaves; <a name="l00145"></a>00145 <span class="keyword">static</span> <span class="keywordtype">int</span> SubRectCompare (<a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* <span class="keyword">const</span>& sr1, <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* <span class="keyword">const</span>& sr2); <a name="l00146"></a><a class="code" href="classCS_1_1SubRectangles.html#504d1849f2f1f429d6dc97309b3d6360">00146</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> AddLeaf (<a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* sr) <a name="l00147"></a>00147 { <a name="l00148"></a>00148 leaves.InsertSorted (sr, SubRectCompare); <a name="l00149"></a>00149 } <a name="l00150"></a><a class="code" href="classCS_1_1SubRectangles.html#f51b27aa86a17311bc704aca37e58a44">00150</a> <span class="keywordtype">void</span> RemoveLeaf (<a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">SubRect</a>* sr) <a name="l00151"></a>00151 { <a name="l00152"></a>00152 <span class="keywordtype">size_t</span> index = leaves.FindSortedKey ( <a name="l00153"></a>00153 <a class="code" href="classcsArrayCmp.html" title="A functor template which encapsulates a key and a comparison function for use with...">csArrayCmp<SubRect*, SubRect*></a> (sr, SubRectCompare)); <a name="l00154"></a>00154 leaves.DeleteIndex (index); <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00158"></a>00158 <span class="keywordtype">void</span> Split (SubRect* subRect, SubRect::SplitType split, <span class="keywordtype">int</span> splitPos); <a name="l00159"></a>00159 <a name="l00160"></a>00160 <span class="keywordtype">void</span> Grow (SubRect* sr, <span class="keywordtype">int</span> ow, <span class="keywordtype">int</span> oh, <span class="keywordtype">int</span> nw, <span class="keywordtype">int</span> nh, <a name="l00161"></a>00161 <span class="keywordtype">int</span> touch); <a name="l00162"></a>00162 <span class="keywordtype">bool</span> Shrink (SubRect* sr, <span class="keywordtype">int</span> ow, <span class="keywordtype">int</span> oh, <span class="keywordtype">int</span> nw, <span class="keywordtype">int</span> nh); <a name="l00163"></a>00163 <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> GetMinimumRectangle (SubRect* sr) <span class="keyword">const</span>; <a name="l00164"></a>00164 <span class="keywordtype">void</span> DupeWithOffset (<span class="keyword">const</span> SubRect* from, SubRect* to, <a name="l00165"></a>00165 <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <a class="code" href="classcsHash.html" title="A generic hash table class, which grows dynamically and whose buckets are unsorted...">csHash</a><SubRect*, <a class="code" href="classcsConstPtrKey.html" title="A helper template to use const pointers as keys for hashes.">csConstPtrKey<SubRect></a> >* map, <a name="l00166"></a>00166 <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& outerAllocated, <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& outerRect); <a name="l00167"></a>00167 <span class="keyword">public</span>: <a name="l00169"></a>00169 <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a> (<span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& region); <a name="l00170"></a>00170 <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a> (<span class="keyword">const</span> <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a>& other); <a name="l00171"></a>00171 <a name="l00173"></a>00173 <span class="keyword">virtual</span> ~<a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a> (); <a name="l00174"></a>00174 <a name="l00176"></a><a class="code" href="classCS_1_1SubRectangles.html#4faf1847af63c9be313102e34cd8808f">00176</a> <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& GetRectangle ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> region; } <a name="l00177"></a>00177 <a name="l00181"></a>00181 <span class="keyword">virtual</span> <span class="keywordtype">void</span> Clear (); <a name="l00182"></a>00182 <a name="l00186"></a>00186 <span class="keyword">virtual</span> SubRect* Alloc (<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& rect); <a name="l00187"></a>00187 <a name="l00192"></a>00192 <span class="keywordtype">void</span> Reclaim (SubRect* subrect); <a name="l00193"></a>00193 <a name="l00198"></a>00198 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> Grow (<span class="keywordtype">int</span> newWidth, <span class="keywordtype">int</span> newHeight); <a name="l00199"></a>00199 <a name="l00207"></a>00207 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> Shrink (<span class="keywordtype">int</span> newWidth, <span class="keywordtype">int</span> newHeight); <a name="l00208"></a>00208 <a name="l00212"></a><a class="code" href="classCS_1_1SubRectangles.html#517a487260861c6bb79084e0bc2913e1">00212</a> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> GetMinimumRectangle ()<span class="keyword"> const</span> <a name="l00213"></a>00213 <span class="keyword"> </span>{ <span class="keywordflow">return</span> GetMinimumRectangle (root); } <a name="l00214"></a>00214 <a name="l00219"></a>00219 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> PlaceInto (<span class="keyword">const</span> <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a>* rectangles, <a name="l00220"></a>00220 SubRect* subRect, <a name="l00221"></a>00221 <a class="code" href="classcsHash.html" title="A generic hash table class, which grows dynamically and whose buckets are unsorted...">csHash</a><SubRect*, <a class="code" href="classcsConstPtrKey.html" title="A helper template to use const pointers as keys for hashes.">csConstPtrKey<SubRect></a> >* newRectangles = 0); <a name="l00222"></a>00222 <a name="l00228"></a>00228 <span class="keywordtype">void</span> Dump (<a class="code" href="structiObjectRegistry.html" title="This interface serves as a registry of other objects.">iObjectRegistry</a>* object_reg, <span class="keyword">const</span> <span class="keywordtype">char</span>* tag = 0); <a name="l00229"></a>00229 <a name="l00235"></a>00235 <span class="keywordtype">void</span> Dump (<span class="keyword">const</span> <span class="keywordtype">char</span>* tag = 0); <a name="l00236"></a>00236 }; <a name="l00237"></a>00237 <a name="l00251"></a><a class="code" href="classCS_1_1SubRectanglesCompact.html">00251</a> <span class="keyword">class </span>CS_CRYSTALSPACE_EXPORT <a class="code" href="classCS_1_1SubRectanglesCompact.html" title="A variation of SubRectangles that tries to place rectangles in a rectangular fashion...">SubRectanglesCompact</a> : <span class="keyword">public</span> <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">SubRectangles</a> <a name="l00252"></a>00252 { <a name="l00253"></a>00253 <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a> maxArea; <a name="l00254"></a>00254 <span class="keywordtype">bool</span> growPO2; <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="keyword">inline</span> <span class="keywordtype">int</span> NewSize (<span class="keywordtype">int</span> amount, <span class="keywordtype">int</span> inc) <a name="l00257"></a>00257 { <span class="keywordflow">return</span> growPO2 ? <a class="code" href="group__util.html#ge54904d35bd5deee0f65e854cb14a205" title="Finds the smallest number that is a power of two and is larger or equal to n.">csFindNearestPowerOf2</a> (amount + inc) : amount + inc; } <a name="l00258"></a>00258 <span class="keyword">public</span>: <a name="l00259"></a>00259 <a class="code" href="classCS_1_1SubRectanglesCompact.html" title="A variation of SubRectangles that tries to place rectangles in a rectangular fashion...">SubRectanglesCompact</a> (<span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& maxArea); <a name="l00260"></a>00260 <a class="code" href="classCS_1_1SubRectanglesCompact.html" title="A variation of SubRectangles that tries to place rectangles in a rectangular fashion...">SubRectanglesCompact</a> (<span class="keyword">const</span> <a class="code" href="classCS_1_1SubRectanglesCompact.html" title="A variation of SubRectangles that tries to place rectangles in a rectangular fashion...">SubRectanglesCompact</a>& other); <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="keywordtype">void</span> Clear (); <a name="l00263"></a>00263 SubRect* Alloc (<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& rect); <a name="l00264"></a>00264 <a name="l00266"></a><a class="code" href="classCS_1_1SubRectanglesCompact.html#6936a1c9cd3660dd8fa5a9b3494a3ee2">00266</a> <span class="keyword">const</span> <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& GetMaximumRectangle ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> maxArea; } <a name="l00267"></a>00267 <a name="l00273"></a><a class="code" href="classCS_1_1SubRectanglesCompact.html#1c53fb61150b6d589ffe28ae1de8d6b1">00273</a> <span class="keywordtype">void</span> SetGrowPO2 (<span class="keywordtype">bool</span> growPO2) { this->growPO2 = growPO2; } <a name="l00275"></a><a class="code" href="classCS_1_1SubRectanglesCompact.html#d6b57d94d693b855fd8fcf1eba0a5908">00275</a> <span class="keywordtype">bool</span> GetGrowPO2 ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> growPO2; } <a name="l00276"></a>00276 <a name="l00278"></a><a class="code" href="classCS_1_1SubRectanglesCompact.html#cd7ea6cd7e679f56751a07054d2954fd">00278</a> SubRect* AllocNoGrow (<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h, <a class="code" href="classcsRect.html" title="Rectangle class: simple class for manipulating 2D rectangles.">csRect</a>& rect) <a name="l00279"></a>00279 { <a name="l00280"></a>00280 <span class="keywordflow">return</span> <a class="code" href="classCS_1_1SubRectangles.html#81482d1c1f66941113cdfad4543470fb" title="Allocate a new rectangle.">SubRectangles::Alloc</a> (w, h, rect); <a name="l00281"></a>00281 } <a name="l00282"></a>00282 }; <a name="l00283"></a>00283 <a name="l00284"></a>00284 } <span class="comment">// namespace CS</span> <a name="l00285"></a>00285 <a name="l00286"></a>00286 <span class="keyword">typedef</span> <a class="code" href="cssysdef_8h.html#91e256b131a2cf6b4b9db8830a0c88f4" title="A variant of CS_DEPRECATED_TYPE that also emits the message msg on compilers that...">CS_DEPRECATED_TYPE_MSG</a>(<span class="stringliteral">"csSubRectangles renamed to CS::SubRectangles"</span>) <a name="l00287"></a><a class="code" href="group__geom__utils.html#g6113008bbb5ba16336524ebe861b7a9a">00287</a> CS::SubRectangles <a class="code" href="classCS_1_1SubRectangles.html" title="A class managing allocations of sub-rectangles.">csSubRectangles</a>; <a name="l00288"></a>00288 typedef <a class="code" href="cssysdef_8h.html#91e256b131a2cf6b4b9db8830a0c88f4" title="A variant of CS_DEPRECATED_TYPE that also emits the message msg on compilers that...">CS_DEPRECATED_TYPE_MSG</a>("<a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">csSubRect</a> renamed to CS::SubRectangles::SubRect") <a name="l00289"></a><a class="code" href="group__geom__utils.html#gab103d6e426c03627a369775f8c06f2d">00289</a> CS::SubRectangles::SubRect <a class="code" href="classCS_1_1SubRectangles_1_1SubRect.html" title="Sub-rectangle.">csSubRect</a>; <a name="l00290"></a>00290 <a name="l00293"></a>00293 <span class="preprocessor">#endif // __CS_SUBREC_H__</span> <a name="l00294"></a>00294 <span class="preprocessor"></span> </pre></div><hr size="1"><address><small>Generated for Crystal Space 1.2.1 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.5.3 </small></address> </div></body> </html>