From 55ae073ba291978687e82d909cd02e9a3d886491 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 23 Jan 2006 10:25:38 +0000 Subject: [PATCH] added alternative vertex storage impl --- include/geometry.hpp | 5 ++- include/vertex_vector.hpp | 67 +++++++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/include/geometry.hpp b/include/geometry.hpp index fdaea9d96..fbb8f430c 100644 --- a/include/geometry.hpp +++ b/include/geometry.hpp @@ -57,7 +57,6 @@ namespace mapnik virtual int type() const=0; virtual bool hit_test(value_type x,value_type y) const=0; virtual void move_to(value_type x,value_type y)=0; - virtual void line_to(value_type x,value_type y)=0; virtual void transform(const mapnik::CoordTransform& t)=0; virtual unsigned num_points() const = 0; @@ -244,8 +243,8 @@ namespace mapnik }; typedef point point_impl; - typedef line_string line_string_impl; - typedef polygon polygon_impl; + typedef line_string line_string_impl; + typedef polygon polygon_impl; typedef geometry geometry_type; typedef boost::shared_ptr geometry_ptr; diff --git a/include/vertex_vector.hpp b/include/vertex_vector.hpp index a1f8b5ffd..6944d8458 100644 --- a/include/vertex_vector.hpp +++ b/include/vertex_vector.hpp @@ -30,10 +30,14 @@ #include "vertex.hpp" #include "ctrans.hpp" +#include +#include +#include + namespace mapnik { template - class vertex_vector + class vertex_vector : private boost::noncopyable { typedef typename T::type value_type; typedef vertex vertex_type; @@ -101,27 +105,7 @@ namespace mapnik *y = (*vertex); return commands_[block] [pos & block_mask]; } - unsigned get_at(unsigned pos,value_type& x,value_type& y) const - { - if (pos >= pos_) return SEG_END; - unsigned block = pos >> block_shift; - const value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1); - x = (*vertex++); - y = (*vertex); - return commands_[block] [pos & block_mask]; - } - - unsigned get_at(unsigned pos,vertex_type& v) const - { - if (pos >= pos_) return SEG_END; - unsigned block = pos >> block_shift; - const value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1); - unsigned char* cmd= commands_[block] + (pos_ & block_mask); - v.x=(*vertex++); - v.y=(*vertex); - return commands_[block] [pos & block_mask]; - } - + void transform_at(unsigned pos,const CoordTransform& t) { if (pos >= pos_) return; @@ -133,8 +117,6 @@ namespace mapnik } private: - vertex_vector(const vertex_vector&); - vertex_vector& operator=(const vertex_vector&); void allocate_block(unsigned block) { if (block >= max_blocks_) @@ -156,6 +138,43 @@ namespace mapnik ++num_blocks_; } }; + + template + struct vertex_vector2 : boost::noncopyable + { + typedef typename T::type value_type; + typedef boost::tuple coord; + vertex_vector2() {} + + unsigned size() const + { + return cont_.size(); + } + + void push_back (value_type x,value_type y,unsigned command) + { + cont_.push_back(coord(x,y,command)); + } + unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const + { + if (pos >= cont_.size()) return SEG_END; + coord const& c = cont_[pos]; + *x = boost::get<0>(c); + *y = boost::get<1>(c); + return boost::get<2>(c); + } + + void transform_at(unsigned pos,const CoordTransform& t) + { + if (pos >= cont_.size()) return; + coord & c = cont_[pos]; + t.forward_x(&boost::get<0>(c)); + t.forward_y(&boost::get<1>(c)); + } + + private: + std::vector cont_; + }; } #endif //VERTEX_VECTOR_HPP