|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78710 - in trunk: boost/polygon boost/polygon/detail libs/polygon/doc libs/polygon/example libs/polygon/test tools/build/v2
From: sydorchuk.andriy_at_[hidden]
Date: 2012-05-28 06:23:44
Author: asydorchuk
Date: 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
New Revision: 78710
URL: http://svn.boost.org/trac/boost/changeset/78710
Log:
Polygon: removed data member from Voronoi primitives; added color member instead; removed size template parameter from the extended_int class methods.
Text files modified:
trunk/boost/polygon/detail/voronoi_ctypes.hpp | 111 +++++++++++++++++----------------------
trunk/boost/polygon/detail/voronoi_structures.hpp | 2
trunk/boost/polygon/voronoi_builder.hpp | 2
trunk/boost/polygon/voronoi_diagram.hpp | 77 ++++++++++++---------------
trunk/libs/polygon/doc/voronoi_basic_tutorial.htm | 76 ++++++++++----------------
trunk/libs/polygon/doc/voronoi_diagram.htm | 87 +++++++++++++++---------------
trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp | 4
trunk/libs/polygon/example/voronoi_basic_tutorial.cpp | 22 +++----
trunk/libs/polygon/example/voronoi_visualizer.cpp | 10 ++-
trunk/libs/polygon/test/voronoi_ctypes_test.cpp | 5 -
trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp | 10 +-
trunk/tools/build/v2/user-config.jam | 2
12 files changed, 182 insertions(+), 226 deletions(-)
Modified: trunk/boost/polygon/detail/voronoi_ctypes.hpp
==============================================================================
--- trunk/boost/polygon/detail/voronoi_ctypes.hpp (original)
+++ trunk/boost/polygon/detail/voronoi_ctypes.hpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -221,7 +221,7 @@
// Very efficient stack allocated big integer class.
// Supports next set of arithmetic operations: +, -, *.
-template<size_t N>
+template<std::size_t N>
class extended_int {
public:
static const uint64 kUInt64LowMask;
@@ -264,9 +264,7 @@
this->count_ = -this->count_;
}
- template <size_t M>
- extended_int(const extended_int<M>& that) {
- if (that.size() > N) return;
+ extended_int(const extended_int& that) {
this->count_ = that.count();
std::memcpy(this->chunks_, that.chunks(), that.size() * sizeof(uint32));
}
@@ -300,11 +298,9 @@
return *this;
}
- template <size_t M>
- extended_int& operator=(const extended_int<M>& that) {
- size_t mx = (std::max)(N, that.size());
+ extended_int& operator=(const extended_int& that) {
this->count_ = that.count();
- std::memcpy(this->chunks_, that.chunks(), mx * sizeof(uint32));
+ std::memcpy(this->chunks_, that.chunks(), that.size() * sizeof(uint32));
return *this;
}
@@ -320,26 +316,23 @@
return this->count_ == 0;
}
- template <size_t M>
- bool operator==(const extended_int<M>& that) const {
+ bool operator==(const extended_int& that) const {
if (this->count_ != that.count())
return false;
- for (size_t i = 0; i < this->size(); ++i)
+ for (std::size_t i = 0; i < this->size(); ++i)
if (this->chunks_[i] != that.chunks()[i])
return false;
return true;
}
- template <size_t M>
- bool operator!=(const extended_int<M>& that) const {
+ bool operator!=(const extended_int& that) const {
return !(*this == that);
}
- template <size_t M>
- bool operator<(const extended_int<M>& that) const {
+ bool operator<(const extended_int& that) const {
if (this->count_ != that.count())
return this->count_ < that.count();
- size_t i = this->size();
+ std::size_t i = this->size();
if (!i)
return false;
do {
@@ -350,18 +343,15 @@
return false;
}
- template <size_t M>
- bool operator>(const extended_int<M>& that) const {
+ bool operator>(const extended_int& that) const {
return that < *this;
}
- template <size_t M>
- bool operator<=(const extended_int<M>& that) const {
+ bool operator<=(const extended_int& that) const {
return !(that < *this);
}
- template <size_t M>
- bool operator>=(const extended_int<M>& that) const {
+ bool operator>=(const extended_int& that) const {
return !(*this < that);
}
@@ -375,15 +365,13 @@
this->count_ = -this->count_;
}
- template <size_t M>
- extended_int<(N>M?N:M)> operator+(const extended_int<M>& that) const {
- extended_int<(N>M?N:M)> ret_val;
+ extended_int operator+(const extended_int& that) const {
+ extended_int ret_val;
ret_val.add(*this, that);
return ret_val;
}
- template <size_t N1, size_t N2>
- void add(const extended_int<N1>& e1, const extended_int<N2>& e2) {
+ void add(const extended_int& e1, const extended_int& e2) {
if (!e1.count()) {
*this = e2;
return;
@@ -401,15 +389,13 @@
this->count_ = -this->count_;
}
- template <size_t M>
- extended_int<(N>M?N:M)> operator-(const extended_int<M>& that) const {
- extended_int<(N>M?N:M)> ret_val;
+ extended_int operator-(const extended_int& that) const {
+ extended_int ret_val;
ret_val.dif(*this, that);
return ret_val;
}
- template <size_t N1, size_t N2>
- void dif(const extended_int<N1>& e1, const extended_int<N2> &e2) {
+ void dif(const extended_int& e1, const extended_int& e2) {
if (!e1.count()) {
*this = e2;
this->count_ = -this->count_;
@@ -428,25 +414,23 @@
this->count_ = -this->count_;
}
- extended_int<N> operator*(int32 that) const {
- extended_int<N> temp(that);
+ extended_int operator*(int32 that) const {
+ extended_int temp(that);
return (*this) * temp;
}
- extended_int<N> operator*(int64 that) const {
- extended_int<N> temp(that);
+ extended_int operator*(int64 that) const {
+ extended_int temp(that);
return (*this) * temp;
}
- template <size_t M>
- extended_int<(N>M?N:M)> operator*(const extended_int<M>& that) const {
- extended_int<(N>M?N:M)> ret_val;
+ extended_int operator*(const extended_int& that) const {
+ extended_int ret_val;
ret_val.mul(*this, that);
return ret_val;
}
- template <size_t N1, size_t N2>
- void mul(const extended_int<N1>& e1, const extended_int<N2>& e2) {
+ void mul(const extended_int& e1, const extended_int& e2) {
if (!e1.count() || !e2.count()) {
this->count_ = 0;
return;
@@ -464,13 +448,13 @@
return count_;
}
- size_t size() const {
+ std::size_t size() const {
return (std::abs)(count_);
}
std::pair<fpt64, int> p() const {
std::pair<fpt64, int> ret_val(0, 0);
- size_t sz = this->size();
+ std::size_t sz = this->size();
if (!sz) {
return ret_val;
} else {
@@ -481,7 +465,7 @@
static_cast<fpt64>(0x100000000LL) +
static_cast<fpt64>(this->chunks_[0]);
} else {
- for (size_t i = 1; i <= 3; ++i) {
+ for (std::size_t i = 1; i <= 3; ++i) {
ret_val.first *= static_cast<fpt64>(0x100000000LL);
ret_val.first += static_cast<fpt64>(this->chunks_[sz - i]);
}
@@ -499,19 +483,20 @@
}
private:
- void add(const uint32* c1, size_t sz1, const uint32* c2, size_t sz2) {
+ void add(const uint32* c1, std::size_t sz1,
+ const uint32* c2, std::size_t sz2) {
if (sz1 < sz2) {
add(c2, sz2, c1, sz1);
return;
}
this->count_ = sz1;
uint64 temp = 0;
- for (size_t i = 0; i < sz2; ++i) {
+ for (std::size_t i = 0; i < sz2; ++i) {
temp += static_cast<uint64>(c1[i]) + static_cast<uint64>(c2[i]);
this->chunks_[i] = static_cast<uint32>(temp & kUInt64LowMask);
temp >>= 32;
}
- for (size_t i = sz2; i < sz1; ++i) {
+ for (std::size_t i = sz2; i < sz1; ++i) {
temp += static_cast<uint64>(c1[i]);
this->chunks_[i] = static_cast<uint32>(temp & kUInt64LowMask);
temp >>= 32;
@@ -522,8 +507,9 @@
}
}
- void dif(const uint32* c1, size_t sz1,
- const uint32* c2, size_t sz2, bool rec = false) {
+ void dif(const uint32* c1, std::size_t sz1,
+ const uint32* c2, std::size_t sz2,
+ bool rec = false) {
if (sz1 < sz2) {
dif(c2, sz2, c1, sz1, true);
this->count_ = -this->count_;
@@ -549,11 +535,11 @@
}
this->count_ = sz1-1;
bool flag = false;
- for (size_t i = 0; i < sz2; ++i) {
+ for (std::size_t i = 0; i < sz2; ++i) {
this->chunks_[i] = c1[i] - c2[i] - (flag?1:0);
flag = (c1[i] < c2[i]) || ((c1[i] == c2[i]) && flag);
}
- for (size_t i = sz2; i < sz1; ++i) {
+ for (std::size_t i = sz2; i < sz1; ++i) {
this->chunks_[i] = c1[i] - (flag?1:0);
flag = !c1[i] && flag;
}
@@ -561,16 +547,17 @@
++this->count_;
}
- void mul(const uint32* c1, size_t sz1, const uint32* c2, size_t sz2) {
+ void mul(const uint32* c1, std::size_t sz1,
+ const uint32* c2, std::size_t sz2) {
uint64 cur = 0, nxt, tmp;
this->count_ = static_cast<int32>((std::min)(N, sz1 + sz2 - 1));
- for (size_t shift = 0; shift < static_cast<size_t>(this->count_);
+ for (std::size_t shift = 0; shift < static_cast<std::size_t>(this->count_);
++shift) {
nxt = 0;
- for (size_t first = 0; first <= shift; ++first) {
+ for (std::size_t first = 0; first <= shift; ++first) {
if (first >= sz1)
break;
- size_t second = shift - first;
+ std::size_t second = shift - first;
if (second >= sz2)
continue;
tmp = static_cast<uint64>(c1[first]) * static_cast<uint64>(c2[second]);
@@ -590,22 +577,22 @@
int32 count_;
};
-template <size_t N>
+template <std::size_t N>
const uint64 extended_int<N>::kUInt64LowMask = 0x00000000ffffffffULL;
-template <size_t N>
+template <std::size_t N>
const uint64 extended_int<N>::kUInt64HighMask = 0xffffffff00000000ULL;
-template <size_t N>
+template <std::size_t N>
bool is_pos(const extended_int<N>& that) {
return that.count() > 0;
}
-template <size_t N>
+template <std::size_t N>
bool is_neg(const extended_int<N>& that) {
return that.count() < 0;
}
-template <size_t N>
+template <std::size_t N>
bool is_zero(const extended_int<N>& that) {
return !that.count();
}
@@ -616,7 +603,7 @@
return static_cast<fpt64>(that);
}
- template <size_t N>
+ template <std::size_t N>
fpt64 operator()(const extended_int<N>& that) const {
return that.d();
}
@@ -627,7 +614,7 @@
};
struct type_converter_efpt {
- template <size_t N>
+ template <std::size_t N>
extended_exponent_fpt<fpt64> operator()(const extended_int<N>& that) const {
std::pair<fpt64, int> p = that.p();
return extended_exponent_fpt<fpt64>(p.first, p.second);
Modified: trunk/boost/polygon/detail/voronoi_structures.hpp
==============================================================================
--- trunk/boost/polygon/detail/voronoi_structures.hpp (original)
+++ trunk/boost/polygon/detail/voronoi_structures.hpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -185,7 +185,7 @@
return *this;
}
- size_t index() const {
+ std::size_t index() const {
return site_index_ >> 2;
}
Modified: trunk/boost/polygon/voronoi_builder.hpp
==============================================================================
--- trunk/boost/polygon/voronoi_builder.hpp (original)
+++ trunk/boost/polygon/voronoi_builder.hpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -161,7 +161,7 @@
site_events_.begin(), site_events_.end()), site_events_.end());
// Index sites.
- for (size_t cur = 0; cur < site_events_.size(); ++cur)
+ for (std::size_t cur = 0; cur < site_events_.size(); ++cur)
site_events_[cur].index(cur);
// Init site iterator.
Modified: trunk/boost/polygon/voronoi_diagram.hpp
==============================================================================
--- trunk/boost/polygon/voronoi_diagram.hpp (original)
+++ trunk/boost/polygon/voronoi_diagram.hpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -24,30 +24,31 @@
// Represents Voronoi cell.
// Data members:
-// 1) pointer to the incident edge;
-// 2) site inside cell;
-// 3) data associated with a cell.
+// 1) pointer to the incident edge
+// 2) site inside cell
+// 3) mutable color member
// Cell may contain point or segment site inside.
template <typename T>
class voronoi_cell {
public:
typedef T coordinate_type;
typedef detail::point_2d<coordinate_type> point_type;
+ typedef std::size_t color_type;
typedef voronoi_edge<coordinate_type> voronoi_edge_type;
voronoi_cell(const point_type &p1, voronoi_edge_type *edge) :
point0_(p1),
point1_(p1),
- incident_edge_(edge),
- data_(NULL) {}
+ color_(0),
+ incident_edge_(edge) {}
voronoi_cell(const point_type &p1,
const point_type &p2,
voronoi_edge_type *edge) :
point0_(p1),
point1_(p2),
- incident_edge_(edge),
- data_(NULL) {}
+ color_(0),
+ incident_edge_(edge) {}
// Returns true if the cell contains point site, false else.
bool contains_point() const { return point0_ == point1_; }
@@ -66,71 +67,64 @@
// the second endpoint of the segment site else.
const point_type &point1() const { return point1_; }
+ color_type color() const { return color_; }
+ void color(const color_type& color) const { color_ = color; }
+
voronoi_edge_type *incident_edge() { return incident_edge_; }
const voronoi_edge_type *incident_edge() const { return incident_edge_; }
void incident_edge(voronoi_edge_type *e) { incident_edge_ = e; }
-#ifndef NO_VORONOI_CELL_DATA
- void *data() const { return data_; }
- void data(void *d) const { data_ = d; }
-#endif
-
private:
point_type point0_;
point_type point1_;
+ mutable color_type color_;
voronoi_edge_type *incident_edge_;
-#ifndef NO_VORONOI_CELL_DATA
- mutable void *data_;
-#endif
};
// Represents Voronoi vertex.
// Data members:
-// 1) vertex point itself;
-// 2) pointer to the incident edge;
-// 3) data associated with vertex.
+// 1) vertex point itself
+// 2) pointer to the incident edge
+// 3) mutable color member
template <typename T>
class voronoi_vertex {
public:
typedef T coordinate_type;
typedef detail::point_2d<T> point_type;
+ typedef std::size_t color_type;
typedef voronoi_edge<coordinate_type> voronoi_edge_type;
voronoi_vertex(const point_type &vertex, voronoi_edge_type *edge) :
vertex_(vertex),
- incident_edge_(edge),
- data_(NULL) {}
+ color_(0),
+ incident_edge_(edge) {}
const point_type &vertex() const { return vertex_; }
bool is_degenerate() const { return incident_edge_ == NULL; }
+ color_type color() const { return color_; }
+ void color(const color_type& color) const { color_ = color; }
+
voronoi_edge_type *incident_edge() { return incident_edge_; }
const voronoi_edge_type *incident_edge() const { return incident_edge_; }
void incident_edge(voronoi_edge_type *e) { incident_edge_ = e; }
-#ifndef NO_VORONOI_VERTEX_DATA
- void *data() const { return data_; }
- void data(void *d) const { data_ = d; }
-#endif
-
private:
point_type vertex_;
+ mutable color_type color_;
voronoi_edge_type *incident_edge_;
-#ifndef NO_VORONOI_VERTEX_DATA
- mutable void *data_;
-#endif
};
// Half-edge data structure. Represents Voronoi edge.
// Data members:
-// 1) pointer to the corresponding cell;
+// 1) pointer to the corresponding cell
// 2) pointer to the vertex that is the starting
-// point of the half-edge;
-// 3) pointer to the twin edge;
-// 4) pointer to the CCW next edge;
-// 5) pointer to the CCW prev edge;
-// 6) pointer to data associated with edge.
+// point of the half-edge
+// 3) pointer to the twin edge
+// 4) pointer to the CCW next edge
+// 5) pointer to the CCW prev edge
+// 6) mutable color member
template <typename T>
class voronoi_edge {
public:
@@ -138,6 +132,7 @@
typedef voronoi_cell<coordinate_type> voronoi_cell_type;
typedef voronoi_vertex<coordinate_type> voronoi_vertex_type;
typedef voronoi_edge<coordinate_type> voronoi_edge_type;
+ typedef std::size_t color_type;
voronoi_edge() :
cell_(NULL),
@@ -145,7 +140,7 @@
twin_(NULL),
next_(NULL),
prev_(NULL),
- data_(NULL) {}
+ color_(0) {}
voronoi_cell_type *cell() { return cell_; }
const voronoi_cell_type *cell() const { return cell_; }
@@ -171,11 +166,6 @@
const voronoi_edge_type *prev() const { return prev_; }
void prev(voronoi_edge_type *e) { prev_ = e; }
-#ifndef NO_VORONOI_EDGE_DATA
- void *data() const { return data_; }
- void data(void *d) const { data_ = d; }
-#endif
-
// Returns a pointer to the rotation next edge
// over the starting point of the half-edge.
voronoi_edge_type *rot_next() {
@@ -230,15 +220,16 @@
return true;
}
+ color_type color() const { return color_; }
+ void color(const color_type& color) const { color_ = color; }
+
private:
voronoi_cell_type *cell_;
voronoi_vertex_type *vertex_;
voronoi_edge_type *twin_;
voronoi_edge_type *next_;
voronoi_edge_type *prev_;
-#ifndef NO_VORONOI_EDGE_DATA
- mutable void *data_;
-#endif
+ mutable color_type color_;
};
template <typename T>
Modified: trunk/libs/polygon/doc/voronoi_basic_tutorial.htm
==============================================================================
--- trunk/libs/polygon/doc/voronoi_basic_tutorial.htm (original)
+++ trunk/libs/polygon/doc/voronoi_basic_tutorial.htm 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -8,6 +8,7 @@
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>Voronoi Basic Tutorial</title><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>
<h1>Voronoi Basic Tutorial<br>
@@ -213,37 +214,22 @@
We will consider the first example and will associate the total number
of incident edges with each cell.<br>
-Note: Each Voronoi primitive contains mutable pointer to the void* type,
-that allows to associate any type of data with it.<br>
-
-<br>
+Note: Each Voronoi primitive contains mutable color member,
+that allows to use it for the graph algorithms or associate user data via array indices.<br>
-<span style="font-family: Courier New,Courier,monospace;">std::vector<int>
-counts;</span><br>
+<br style="font-family: Courier New,Courier,monospace;">
-<span style="font-family: Courier New,Courier,monospace;">// This is
-required as reallocation of underlying vector will invalidate all the
-pointers.<br>
-counts.reserve(vd.num_cells());<br>
-for (voronoi_diagram<double>::const_cell_iterator it =
-vd.cells().begin();<br>
- it != vd.cells().end(); ++it) {<br>
- const voronoi_diagram<double>::cell_type &cell = *it;<br>
- const voronoi_diagram<double>::edge_type *edge =
-cell.incident_edge();<br>
- int count = 0;<br>
- do {<br>
- ++count;<br>
- edge = edge->next();<br>
- } while (edge != cell.incident_edge());<br>
- counts.push_back(count);<br>
- cell.data(&counts.back());<br>
-}</span><span style="font-family: Courier New,Courier,monospace;"><br>
-</span><br>
-
-Note: In the example above we could not use count variable
-without the vector, because the pointer to it will become invalid as soon as
-we leave the scope of the enclosing for-loop.<br>
+<span style="font-family: Courier New,Courier,monospace;">for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin();</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> it != vd.cells().end(); ++it) {</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> const voronoi_diagram<double>::cell_type &cell = *it;</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> const voronoi_diagram<double>::edge_type *edge = cell.incident_edge();</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> std::size_t count = 0;</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> do {</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> ++count;</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> edge = edge->next();</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> } while (edge != cell.incident_edge());</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;"> cell.color(count);</span><br style="font-family: Courier New,Courier,monospace;">
+<span style="font-family: Courier New,Courier,monospace;">}</span><br>
<h2>Rendering Voronoi Diagram</h2>
@@ -291,31 +277,26 @@
<br>
-<span style="font-family: Courier New,Courier,monospace;">void
-render_diagram(const voronoi_diagram<double> &vd,<br>
+<span style="font-family: Courier New,Courier,monospace;">void render_diagram(const voronoi_diagram<double> &vd,<br>
const voronoi_utils<double>::brect_type &bbox) {<br>
- int visited = 1;<br>
- for (voronoi_diagram<double>::const_edge_iterator it =
-vd.edges().begin();<br>
+ const std::size_t VISITED = 1;<br>
+ for (voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin();<br>
it != vd.edges().end(); ++it) {<br>
- // We use data pointer to mark visited edges.<br>
- it->data(&visited);<br>
+ // We use color to mark visited edges.<br>
+ it->color(VISITED);<br>
// Don't render the same edge twice.<br>
- if (it->twin()->data()) continue;<br>
+ if (it->twin()->color()) continue;<br>
voronoi_utils<double>::point_set_type polyline;<br>
if (it->is_linear())<br>
- voronoi_utils<double>::clip(*it,
-bbox, polyline);<br>
+ voronoi_utils<double>::clip(*it, bbox, polyline);<br>
else<br>
// Parabolic edges are always finite.<br>
-
-voronoi_utils<double>::discretize(*it, 1E-1, polyline);<br>
- // Note: discretized edge segments may also lie
-outside of the bbox.<br>
- for (int i = 1; i < polyline.size(); ++i)<br>
- draw_segment(polyline[i-1].x(),
-polyline[i-1].y(),<br>
+ voronoi_utils<double>::discretize(*it, 1E-1, polyline);<br>
+ // Note: discretized edges may also lie outside of the bbox.<br>
+ // So user might do additional clipping before rendering each such edge. <br>
+ for (std::size_t i = 1; i < polyline.size(); ++i)<br>
+ draw_segment(polyline[i-1].x(), polyline[i-1].y(),<br>
polyline[i].x(), polyline[i].y());<br>
}<br>
@@ -357,4 +338,5 @@
</tbody>
</table>
-</body></html>
+
+</body></html>
\ No newline at end of file
Modified: trunk/libs/polygon/doc/voronoi_diagram.htm
==============================================================================
--- trunk/libs/polygon/doc/voronoi_diagram.htm (original)
+++ trunk/libs/polygon/doc/voronoi_diagram.htm 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -6,6 +6,8 @@
+
+
<meta http-equiv="Content-Language" content="en-us">
@@ -23,7 +25,7 @@
<tbody>
<tr>
- <td style="background-color: rgb(238, 238, 238);" valign="top" nowrap="1">
+ <td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top">
<div style="padding: 5px;" align="center"> <img src="images/boost.png" border="0" height="86" width="277"><a title="www.boost.org home page" tabindex="2" style="border: medium none ;" href="http://www.boost.org/"> </a></div>
<div style="margin: 5px;">
<h3 class="navbar">Contents</h3>
@@ -473,20 +475,18 @@
</td>
</tr>
<tr>
- <td style="font-family: Courier New,Courier,monospace;">void
-*data() const<br>
+ <td style="font-family: Courier New,Courier,monospace;">size_t color() const<br>
</td>
- <td>Returns the pointer to the
-data associated with the edge.<br>
+ <td>Returns the color value.<br>
</td>
</tr>
<tr>
<td style="font-family: Courier New,Courier,monospace;">void
-data(void *d) const<br>
+data(size_t color) const<br>
</td>
- <td>Sets the data pointer of
+ <td>Sets the color of
the edge.<br>
-This allows the user to associate any data type with the edge.<br>
+Allows to execut graph algorithms and associate data.<br>
</td>
</tr>
<tr>
@@ -560,11 +560,7 @@
<span style="font-family: Courier New,Courier,monospace;"><br>
</span>All
the above methods have O(1) complexity. The size of
-the Voronoi edge structure is equal to: 6 * sizeof(void *). It is
-possible to disable the data member of the Voronoi edge data structure
-during the compile time using the following directive:<br>
- <br>
- <span style="font-family: Courier New,Courier,monospace;">#define NO_VORONOI_EDGE_DATA</span><br>
+the Voronoi edge structure is equal to: 5 * sizeof(void *) + sizeof(size_t).<span style="font-family: Courier New,Courier,monospace;"></span><br>
<h2>Member Types</h2>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
@@ -592,7 +588,13 @@
</td>
<td>Voronoi edge type.<br>
</td>
+ </tr><tr>
+ <td style="vertical-align: top;">color_type<br>
+ </td>
+ <td style="vertical-align: top;">Color type.<br>
+ </td>
</tr>
+
</tbody>
</table>
<h1>Voronoi Cell</h1>
@@ -682,19 +684,18 @@
</td>
</tr>
<tr>
- <td style="font-family: Courier New,Courier,monospace;">void
-*data() const<br>
+ <td style="font-family: Courier New,Courier,monospace;">size_t color() const<br>
</td>
- <td>Returns the pointer to the
-data associated with the cell.</td>
+ <td>Returns the color associated with the cell.</td>
</tr>
<tr>
- <td style="font-family: Courier New,Courier,monospace;">void
-data(void *d) const<br>
+ <td style="font-family: Courier New,Courier,monospace;">void color(size_t color) const<br>
</td>
- <td>Sets the data pointer of
+ <td>Sets the color of
the cell.<br>
-This allows the user to associate any data type with the cell.</td>
+
+Allows to execut graph algorithms and associate data.<br>
+</td>
</tr>
<tr>
<td style="font-family: Courier New,Courier,monospace;">bool
@@ -719,13 +720,7 @@
</table>
<span style="font-family: Courier New,Courier,monospace;"><br>
</span>All the above methods have O(1) complexity. The size of
-the Voronoi cell structure is equal to: 2 * sizeof(void *) + 4 *
-sizeof(coordinate_type). It is possible to disable the data member of the Voronoi cell data
-structure during the compile time using the following directive:<br>
-
- <br>
-
- <span style="font-family: Courier New,Courier,monospace;">#define NO_VORONOI_CELL_DATA</span>
+the Voronoi cell structure is equal to: sizeof(void *) + sizeof(size_t) + 4 * sizeof(coordinate_type).<span style="font-family: Courier New,Courier,monospace;"></span>
<h2>Member Types</h2>
@@ -744,6 +739,12 @@
</td>
</tr>
<tr>
+ <td style="vertical-align: top;">color_type<br>
+ </td>
+ <td style="vertical-align: top;">Color type.<br>
+ </td>
+ </tr>
+<tr>
<td>voronoi_edge_type<br>
</td>
<td>Voronoi edge type.<br>
@@ -827,31 +828,23 @@
</td>
</tr>
<tr>
- <td style="font-family: Courier New,Courier,monospace;">void
-*data() const<br>
+ <td style="font-family: Courier New,Courier,monospace;">size_t color() const<br>
</td>
- <td>Returns the pointer to the
-data associated with the vertex.</td>
+ <td>Returns the color associated with the vertex.</td>
</tr>
<tr>
- <td style="font-family: Courier New,Courier,monospace;">void
-data(void *d) const<br>
+ <td style="font-family: Courier New,Courier,monospace;">void color(size_t color) const<br>
</td>
- <td>Sets the data pointer of
+ <td>Sets the color of
the cell.<br>
-This allows the user to associate any data type with the vertex.</td>
+Allows to execut graph algorithms and associate data.</td>
</tr>
</tbody>
</table>
<span style="font-family: Courier New,Courier,monospace;"><br>
</span>All the above methods have O(1) complexity. The size of
-the Voronoi vertex structure is equal to: 2 * sizeof(void *) + 2 *
-sizeof(coordinate_type). It is possible to disable the data member of the Voronoi vertex data
-structure during the compile time using the following directive:<br>
-
- <br>
-
- <span style="font-family: Courier New,Courier,monospace;">#define NO_VORONOI_VERTEX_DATA</span>
+the Voronoi vertex structure is equal to: sizeof(void *) + sizeof(size_t) + 2 *
+sizeof(coordinate_type).<span style="font-family: Courier New,Courier,monospace;"></span>
<h2>Member Types</h2>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
<tbody>
@@ -868,6 +861,12 @@
</td>
</tr>
<tr>
+ <td style="vertical-align: top;">color_type<br>
+ </td>
+ <td style="vertical-align: top;">Color type.<br>
+ </td>
+ </tr>
+<tr>
<td>voronoi_edge_type<br>
</td>
<td>Voronoi edge type.<br>
@@ -963,7 +962,7 @@
</td>
</tr>
<tr>
- <td style="background-color: rgb(238, 238, 238);" valign="top" nowrap="1"> </td>
+ <td style="background-color: rgb(238, 238, 238);" nowrap="1" valign="top"> </td>
<td style="padding-left: 10px; padding-right: 10px; padding-bottom: 10px;" valign="top" width="100%">
<table class="docinfo" id="table2" frame="void" rules="none">
<colgroup> <col class="docinfo-name"><col class="docinfo-content"> </colgroup> <tbody valign="top">
Modified: trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp (original)
+++ trunk/libs/polygon/example/voronoi_advanced_tutorial.cpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -68,10 +68,10 @@
return static_cast<fpt80>(that);
}
- template <size_t N>
+ template <std::size_t N>
fpt80 operator()(const typename detail::extended_int<N> &that) const {
fpt80 result = 0.0;
- for (size_t i = 1; i <= (std::min)((size_t)3, that.size()); ++i) {
+ for (std::size_t i = 1; i <= (std::min)((std::size_t)3, that.size()); ++i) {
if (i != 1)
result *= static_cast<fpt80>(0x100000000ULL);
result += that.chunks()[that.size() - i];
Modified: trunk/libs/polygon/example/voronoi_basic_tutorial.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_basic_tutorial.cpp (original)
+++ trunk/libs/polygon/example/voronoi_basic_tutorial.cpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -112,13 +112,13 @@
void render_diagram(const voronoi_diagram<double> &vd,
const voronoi_utils<double>::brect_type &bbox) {
- int visited = 1;
+ const std::size_t VISITED = 1;
for (voronoi_diagram<double>::const_edge_iterator it = vd.edges().begin();
it != vd.edges().end(); ++it) {
- // We use data pointer to mark visited edges.
- it->data(&visited);
+ // We use color to mark visited edges.
+ it->color(VISITED);
// Don't render the same edge twice.
- if (it->twin()->data()) continue;
+ if (it->twin()->color()) continue;
voronoi_utils<double>::point_set_type polyline;
if (it->is_linear())
voronoi_utils<double>::clip(*it, bbox, polyline);
@@ -127,7 +127,7 @@
voronoi_utils<double>::discretize(*it, 1E-1, polyline);
// Note: discretized edges may also lie outside of the bbox.
// So user might do additional clipping before rendering each such edge.
- for (size_t i = 1; i < polyline.size(); ++i)
+ for (std::size_t i = 1; i < polyline.size(); ++i)
draw_segment(polyline[i-1].x(), polyline[i-1].y(),
polyline[i].x(), polyline[i].y());
}
@@ -155,29 +155,25 @@
printf("\n");
}
- // Associating User Data with Voronoi Primitives.
- std::vector<int> counts;
+ // Using color member of the Voronoi primitives..
{
- // This is required as reallocation of underlying vector will invalidate all the pointers.
- counts.reserve(vd.num_cells());
for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin();
it != vd.cells().end(); ++it) {
const voronoi_diagram<double>::cell_type &cell = *it;
const voronoi_diagram<double>::edge_type *edge = cell.incident_edge();
- int count = 0;
+ std::size_t count = 0;
do {
++count;
edge = edge->next();
} while (edge != cell.incident_edge());
- counts.push_back(count);
- cell.data(&counts.back());
+ cell.color(count);
}
// Count the average number of edges.
double total = 0;
for (voronoi_diagram<double>::const_cell_iterator it = vd.cells().begin();
it != vd.cells().end(); ++it) {
- total += *static_cast<int*>(it->data());
+ total += it->color();
}
total /= vd.cells().size();
printf("The average number of edges per Voronoi cell is equal to: %3.1f\n", total);
Modified: trunk/libs/polygon/example/voronoi_visualizer.cpp
==============================================================================
--- trunk/libs/polygon/example/voronoi_visualizer.cpp (original)
+++ trunk/libs/polygon/example/voronoi_visualizer.cpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -151,7 +151,7 @@
if (primary_edges_only_ && !it->is_primary()) {
continue;
}
- if (internal_edges_only_ && it->data()) {
+ if (internal_edges_only_ && it->color()) {
continue;
}
std::vector<point_type> vec;
@@ -191,11 +191,13 @@
typedef VD::const_vertex_iterator const_vertex_iterator;
typedef VD::const_edge_iterator const_edge_iterator;
+ static const std::size_t VISITED = 1;
+
void remove_exterior(const VD::edge_type* edge) {
- if (edge->data())
+ if (edge->color())
return;
- edge->data(&edge);
- edge->twin()->data(&edge);
+ edge->color(VISITED);
+ edge->twin()->color(VISITED);
const voronoi_diagram<double>::vertex_type* v = edge->vertex1();
if (v == NULL || !edge->is_primary())
return;
Modified: trunk/libs/polygon/test/voronoi_ctypes_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_ctypes_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_ctypes_test.cpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -284,12 +284,11 @@
BOOST_AUTO_TEST_CASE(extened_int_test11) {
typedef extended_int<1> eint32;
typedef extended_int<64> eint2048;
- eint32 two(2), one(1);
- eint2048 value(1);
+ eint2048 two(2), value(1);
for (int i = 0; i < 1024; ++i)
value = value * two;
BOOST_CHECK_EQUAL(value.count(), 33);
- for (size_t i = 1; i < value.size(); ++i)
+ for (std::size_t i = 1; i < value.size(); ++i)
BOOST_CHECK_EQUAL(value.chunks()[i-1], 0U);
BOOST_CHECK_EQUAL(value.chunks()[32], 1U);
}
Modified: trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp
==============================================================================
--- trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp (original)
+++ trunk/libs/polygon/test/voronoi_robust_fpt_test.cpp 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -282,7 +282,7 @@
int32 A[4] = {1000, 3000, -2000, -500};
int32 B[4] = {400, 100, 900, 1600};
eint512 AA[4], BB[4];
- for (size_t i = 0; i < 4; ++i) {
+ for (std::size_t i = 0; i < 4; ++i) {
AA[i] = A[i];
BB[i] = B[i];
}
@@ -292,20 +292,20 @@
template <typename _int, typename _fpt>
class sqrt_expr_tester {
public:
- static const size_t MX_SQRTS = 4;
+ static const std::size_t MX_SQRTS = 4;
bool run() {
static boost::mt19937 gen(static_cast<uint32>(time(NULL)));
bool ret_val = true;
- for (size_t i = 0; i < MX_SQRTS; ++i) {
+ for (std::size_t i = 0; i < MX_SQRTS; ++i) {
a[i] = gen() & 1048575;
int64 temp = gen() & 1048575;
b[i] = temp * temp;
}
uint32 mask = (1 << MX_SQRTS);
- for (size_t i = 0; i < mask; i++) {
+ for (std::size_t i = 0; i < mask; i++) {
fpt64 expected_val = 0.0;
- for (size_t j = 0; j < MX_SQRTS; j++) {
+ for (std::size_t j = 0; j < MX_SQRTS; j++) {
if (i & (1 << j)) {
A[j] = a[j];
B[j] = b[j];
Modified: trunk/tools/build/v2/user-config.jam
==============================================================================
--- trunk/tools/build/v2/user-config.jam (original)
+++ trunk/tools/build/v2/user-config.jam 2012-05-28 06:23:43 EDT (Mon, 28 May 2012)
@@ -79,7 +79,7 @@
# -----------------
# Configure assuming QTDIR gives the installation prefix.
-# using qt ;
+using qt : /Users/asydorchuk/Downloads/Qt ;
# Configure with an explicit installation prefix.
# using qt : /usr/opt/qt ;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk