Generated on Tue Oct 22 2013 00:49:02 for Gecode by doxygen 1.8.4
visualnode.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2006
8  *
9  * Last modified:
10  * $Date: 2013-05-06 09:02:17 +0200 (Mon, 06 May 2013) $ by $Author: tack $
11  * $Revision: 13613 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode { namespace Gist {
39 
41  Extent::Extent(void) : l(-1), r(-1) {}
42 
44  Extent::Extent(int l0, int r0) : l(l0), r(r0) {}
45 
46  inline
47  Extent::Extent(int width) {
48  int halfWidth = width / 2;
49  l = 0 - halfWidth;
50  r = 0 + halfWidth;
51  }
52 
53  inline void
54  Extent::extend(int deltaL, int deltaR) {
55  l += deltaL; r += deltaR;
56  }
57 
58  inline void
59  Extent::move(int delta) {
60  l += delta; r += delta;
61  }
62 
63  forceinline int
64  Shape::depth(void) const { return _depth; }
65 
66  forceinline void
68  assert(d <= _depth);
69  _depth = d;
70  }
71 
72  forceinline const Extent&
73  Shape::operator [](int i) const {
74  assert(i < _depth);
75  return shape[i];
76  }
77 
80  assert(i < _depth);
81  return shape[i];
82  }
83 
84  inline Shape*
86  assert(d >= 1);
87  Shape* ret;
88  ret =
89  static_cast<Shape*>(heap.ralloc(sizeof(Shape)+(d-1)*sizeof(Extent)));
90  ret->_depth = d;
91  return ret;
92  }
93 
94  forceinline void
96  if (shape != hidden && shape != leaf)
97  heap.rfree(shape);
98  }
99 
100  forceinline bool
102  if (d > depth())
103  return false;
104  extent = Extent(0,0);
105  for (int i=0; i <= d; i++) {
106  Extent currentExtent = (*this)[i];
107  extent.l += currentExtent.l;
108  extent.r += currentExtent.r;
109  }
110  return true;
111  }
112 
113  forceinline void
115  int lastLeft = 0;
116  int lastRight = 0;
117  bb.left = 0;
118  bb.right = 0;
119  for (int i=0; i<depth(); i++) {
120  lastLeft = lastLeft + (*this)[i].l;
121  lastRight = lastRight + (*this)[i].r;
122  bb.left = std::min(bb.left,lastLeft);
123  bb.right = std::max(bb.right,lastRight);
124  }
125  }
126 
127  forceinline const BoundingBox&
128  Shape::getBoundingBox(void) const {
129  return bb;
130  }
131 
132  forceinline bool
134  return getFlag(HIDDEN);
135  }
136 
137  forceinline void
139  setFlag(HIDDEN, h);
140  }
141 
142  forceinline void
144  if (getStatus() == BRANCH && h)
145  setStatus(STOP);
146  else if (getStatus() == STOP && !h)
147  setStatus(UNSTOP);
148  }
149 
150  forceinline int
151  VisualNode::getOffset(void) { return offset; }
152 
153  forceinline void
155 
156  forceinline bool
158  return getFlag(DIRTY);
159  }
160 
161  forceinline void
163  setFlag(DIRTY, d);
164  }
165 
166  forceinline bool
168  return getFlag(CHILDRENLAYOUTDONE);
169  }
170 
171  forceinline void
174  }
175 
176  forceinline bool
178  return getFlag(MARKED);
179  }
180 
181  forceinline void
183  setFlag(MARKED, m);
184  }
185 
186  forceinline bool
188  return getFlag(BOOKMARKED);
189  }
190 
191  forceinline void
193  setFlag(BOOKMARKED, m);
194  }
195 
196  forceinline bool
198  return getFlag(ONPATH);
199  }
200 
201  forceinline void
203  setFlag(ONPATH, b);
204  }
205 
208  return isHidden() ? Shape::hidden : shape;
209  }
210 
213 
214 }}
215 
216 // STATISTICS: gist-any