visualnode.hpp
Go to the documentation of this file.00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Guido Tack <tack@gecode.org> 00005 * 00006 * Copyright: 00007 * Guido Tack, 2006 00008 * 00009 * Last modified: 00010 * $Date: 2009-05-13 00:53:54 +0200 (Wed, 13 May 2009) $ by $Author: tack $ 00011 * $Revision: 9076 $ 00012 * 00013 * This file is part of Gecode, the generic constraint 00014 * development environment: 00015 * http://www.gecode.org 00016 * 00017 * Permission is hereby granted, free of charge, to any person obtaining 00018 * a copy of this software and associated documentation files (the 00019 * "Software"), to deal in the Software without restriction, including 00020 * without limitation the rights to use, copy, modify, merge, publish, 00021 * distribute, sublicense, and/or sell copies of the Software, and to 00022 * permit persons to whom the Software is furnished to do so, subject to 00023 * the following conditions: 00024 * 00025 * The above copyright notice and this permission notice shall be 00026 * included in all copies or substantial portions of the Software. 00027 * 00028 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00029 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00030 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00031 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00032 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00033 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00034 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00035 * 00036 */ 00037 00038 namespace Gecode { namespace Gist { 00039 00040 forceinline 00041 Extent::Extent(void) : l(-1), r(-1) {} 00042 00043 forceinline 00044 Extent::Extent(int l0, int r0) : l(l0), r(r0) {} 00045 00046 inline 00047 Extent::Extent(int width) { 00048 int halfWidth = width / 2; 00049 l = 0 - halfWidth; 00050 r = 0 + halfWidth; 00051 } 00052 00053 inline void 00054 Extent::extend(int deltaL, int deltaR) { 00055 l += deltaL; r += deltaR; 00056 } 00057 00058 inline void 00059 Extent::move(int delta) { 00060 l += delta; r += delta; 00061 } 00062 00063 forceinline const Extent& 00064 Shape::operator [](int i) const { 00065 assert(i < _depth); 00066 return shape[i]; 00067 } 00068 00069 forceinline Extent& 00070 Shape::operator [](int i) { 00071 assert(i < _depth); 00072 return shape[i]; 00073 } 00074 00075 inline Shape* 00076 Shape::allocate(int d) { 00077 Shape* ret = 00078 static_cast<Shape*>(heap.ralloc(sizeof(Shape) + 00079 (d-1)*sizeof(Extent))); 00080 ret->_depth = d; 00081 return ret; 00082 } 00083 00084 inline Shape* 00085 Shape::allocate(Extent e) { 00086 Shape* ret = Shape::allocate(1); 00087 (*ret)[0] = e; 00088 return ret; 00089 } 00090 00091 forceinline void 00092 Shape::deallocate(Shape* shape) { 00093 if (shape != hidden && shape != leaf) 00094 heap.rfree(shape); 00095 } 00096 00097 forceinline int 00098 Shape::depth(void) const { return _depth; } 00099 00100 forceinline 00101 BoundingBox::BoundingBox(int l, int r) 00102 : left(l), right(r) {} 00103 00104 forceinline bool 00105 VisualNode::isHidden(void) { 00106 return nstatus & (1<<(HIDDEN-1)); 00107 } 00108 00109 forceinline void 00110 VisualNode::setHidden(bool h) { 00111 if (h) 00112 nstatus |= 1<<(HIDDEN-1); 00113 else 00114 nstatus &= ~(1<<(HIDDEN-1)); 00115 } 00116 00117 forceinline int 00118 VisualNode::getOffset(void) { return offset; } 00119 00120 forceinline void 00121 VisualNode::setOffset(int n) { offset = n; } 00122 00123 forceinline bool 00124 VisualNode::isDirty(void) { 00125 return nstatus & (1<<(DIRTY-1)); 00126 } 00127 00128 forceinline void 00129 VisualNode::setDirty(bool d) { 00130 if (d) 00131 nstatus |= 1<<(DIRTY-1); 00132 else 00133 nstatus &= ~(1<<(DIRTY-1)); 00134 } 00135 00136 forceinline bool 00137 VisualNode::childrenLayoutIsDone(void) { 00138 return nstatus & (1<<(CHILDRENLAYOUTDONE-1)); 00139 } 00140 00141 forceinline void 00142 VisualNode::setChildrenLayoutDone(bool d) { 00143 if (d) 00144 nstatus |= 1<<(CHILDRENLAYOUTDONE-1); 00145 else 00146 nstatus &= ~(1<<(CHILDRENLAYOUTDONE-1)); 00147 } 00148 00149 forceinline bool 00150 VisualNode::isMarked(void) { 00151 return nstatus & (1<<(MARKED-1)); 00152 } 00153 00154 forceinline void 00155 VisualNode::setMarked(bool m) { 00156 if (m) 00157 nstatus |= 1<<(MARKED-1); 00158 else 00159 nstatus &= ~(1<<(MARKED-1)); 00160 } 00161 00162 forceinline bool 00163 VisualNode::isOnPath(void) { 00164 return nstatus & (1<<(ONPATH-1)); 00165 } 00166 00167 forceinline void 00168 VisualNode::setOnPath(bool b) { 00169 if (b) 00170 nstatus |= 1<<(ONPATH-1); 00171 else 00172 nstatus &= ~(1<<(ONPATH-1)); 00173 } 00174 00175 forceinline Shape* 00176 VisualNode::getShape(void) { return shape; } 00177 00178 forceinline void 00179 VisualNode::setBoundingBox(BoundingBox b) { box = b; } 00180 00181 forceinline BoundingBox 00182 VisualNode::getBoundingBox(void) { return box; } 00183 00184 forceinline VisualNode* 00185 VisualNode::getParent() { 00186 return static_cast<VisualNode*>(SpaceNode::getParent()); 00187 } 00188 00189 forceinline VisualNode* 00190 VisualNode::getChild(int i) { 00191 return static_cast<VisualNode*>(SpaceNode::getChild(i)); 00192 } 00193 00194 }} 00195 00196 // STATISTICS: gist-any
