Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
agg::vertex_block_storage< T, BlockShift, BlockPool > Class Template Reference

#include <src/agg/agg_path_storage.h>

Public Types

enum  block_scale_e { block_shift = BlockShift , block_size = 1 << block_shift , block_mask = block_size - 1 , block_pool = BlockPool }
 
typedef T value_type
 
typedef vertex_block_storage< T, BlockShift, BlockPool > self_type
 

Public Member Functions

 ~vertex_block_storage ()
 
 vertex_block_storage ()
 
 vertex_block_storage (const self_type &v)
 
const self_typeoperator= (const self_type &ps)
 
void remove_all ()
 
void free_all ()
 
void add_vertex (double x, double y, unsigned cmd)
 
void modify_vertex (unsigned idx, double x, double y)
 
void modify_vertex (unsigned idx, double x, double y, unsigned cmd)
 
void modify_command (unsigned idx, unsigned cmd)
 
void swap_vertices (unsigned v1, unsigned v2)
 
unsigned last_command () const
 
unsigned last_vertex (double *x, double *y) const
 
unsigned prev_vertex (double *x, double *y) const
 
double last_x () const
 
double last_y () const
 
unsigned total_vertices () const
 
unsigned vertex (unsigned idx, double *x, double *y) const
 
unsigned command (unsigned idx) const
 

Private Member Functions

void allocate_block (unsigned nb)
 
int8ustorage_ptrs (T **xy_ptr)
 

Private Attributes

unsigned m_total_vertices
 
unsigned m_total_blocks
 
unsigned m_max_blocks
 
T ** m_coord_blocks
 
int8u ** m_cmd_blocks
 

Detailed Description

template<class T, unsigned BlockShift = 8, unsigned BlockPool = 256>
class agg::vertex_block_storage< T, BlockShift, BlockPool >

Member Typedef Documentation

◆ self_type

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
typedef vertex_block_storage<T, BlockShift, BlockPool> agg::vertex_block_storage< T, BlockShift, BlockPool >::self_type

◆ value_type

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
typedef T agg::vertex_block_storage< T, BlockShift, BlockPool >::value_type

Member Enumeration Documentation

◆ block_scale_e

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
enum agg::vertex_block_storage::block_scale_e
Enumerator
block_shift 
block_size 
block_mask 
block_pool 
36 {
37 block_shift = BlockShift,
40 block_pool = BlockPool
41 };
@ block_pool
Definition agg_path_storage.h:40
@ block_size
Definition agg_path_storage.h:38
@ block_mask
Definition agg_path_storage.h:39
@ block_shift
Definition agg_path_storage.h:37

Constructor & Destructor Documentation

◆ ~vertex_block_storage()

template<class T , unsigned S, unsigned P>
agg::vertex_block_storage< T, S, P >::~vertex_block_storage
111 {
112 free_all();
113 }
void free_all()
Definition agg_path_storage.h:86

◆ vertex_block_storage() [1/2]

template<class T , unsigned S, unsigned P>
agg::vertex_block_storage< T, S, P >::vertex_block_storage
117 :
120 m_max_blocks(0),
122 m_cmd_blocks(0)
123 {
124 }
unsigned m_total_blocks
Definition agg_path_storage.h:77
T ** m_coord_blocks
Definition agg_path_storage.h:79
unsigned m_total_vertices
Definition agg_path_storage.h:76
unsigned m_max_blocks
Definition agg_path_storage.h:78
int8u ** m_cmd_blocks
Definition agg_path_storage.h:80

◆ vertex_block_storage() [2/2]

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
agg::vertex_block_storage< T, BlockShift, BlockPool >::vertex_block_storage ( const self_type v)

Member Function Documentation

◆ add_vertex()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::add_vertex ( double  x,
double  y,
unsigned  cmd 
)
inline
165 {
166 T* coord_ptr = 0;
167 *storage_ptrs(&coord_ptr) = (int8u)cmd;
168 coord_ptr[0] = T(x);
169 coord_ptr[1] = T(y);
171 }
int8u * storage_ptrs(T **xy_ptr)
Definition agg_path_storage.h:337
AGG_INT8U int8u
Definition agg_basics.h:120
struct command cmd[]
Definition term.c:94

References cmd.

◆ allocate_block()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::allocate_block ( unsigned  nb)
private
300 {
301 if(nb >= m_max_blocks)
302 {
303 T** new_coords =
305
306 unsigned char** new_cmds =
307 (unsigned char**)(new_coords + m_max_blocks + block_pool);
308
310 {
311 memcpy(new_coords,
313 m_max_blocks * sizeof(T*));
314
315 memcpy(new_cmds,
317 m_max_blocks * sizeof(unsigned char*));
318
320 }
321 m_coord_blocks = new_coords;
322 m_cmd_blocks = new_cmds;
324 }
325 m_coord_blocks[nb] =
327 block_size / (sizeof(T) / sizeof(unsigned char)));
328
329 m_cmd_blocks[nb] =
330 (unsigned char*)(m_coord_blocks[nb] + block_size * 2);
331
333 }
static T * allocate(unsigned num)
Definition agg_basics.h:38
static void deallocate(T *ptr, unsigned)
Definition agg_basics.h:39

References agg::pod_allocator< T >::allocate(), and agg::pod_allocator< T >::deallocate().

+ Here is the call graph for this function:

◆ command()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::command ( unsigned  idx) const
inline
293 {
294 return m_cmd_blocks[idx >> block_shift][idx & block_mask];
295 }

◆ free_all()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::free_all
87 {
89 {
90 T** coord_blk = m_coord_blocks + m_total_blocks - 1;
91 while(m_total_blocks--)
92 {
94 *coord_blk,
95 block_size * 2 +
96 block_size / (sizeof(T) / sizeof(unsigned char)));
97 --coord_blk;
98 }
100 m_total_blocks = 0;
101 m_max_blocks = 0;
102 m_coord_blocks = 0;
103 m_cmd_blocks = 0;
105 }
106 }

References agg::pod_allocator< T >::deallocate().

+ Here is the call graph for this function:

◆ last_command()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::last_command
inline
226 {
228 return path_cmd_stop;
229 }
@ path_cmd_stop
Definition agg_basics.h:370
Definition term.c:39

References agg::path_cmd_stop.

◆ last_vertex()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::last_vertex ( double *  x,
double *  y 
) const
inline
234 {
235 if(m_total_vertices) return vertex(m_total_vertices - 1, x, y);
236 return path_cmd_stop;
237 }
unsigned vertex(unsigned idx, double *x, double *y) const
Definition agg_path_storage.h:280

References agg::path_cmd_stop.

◆ last_x()

template<class T , unsigned S, unsigned P>
double agg::vertex_block_storage< T, S, P >::last_x
inline
250 {
252 {
253 unsigned idx = m_total_vertices - 1;
254 return m_coord_blocks[idx >> block_shift][(idx & block_mask) << 1];
255 }
256 return 0.0;
257 }

◆ last_y()

template<class T , unsigned S, unsigned P>
double agg::vertex_block_storage< T, S, P >::last_y
inline
262 {
264 {
265 unsigned idx = m_total_vertices - 1;
266 return m_coord_blocks[idx >> block_shift][((idx & block_mask) << 1) + 1];
267 }
268 return 0.0;
269 }

◆ modify_command()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::modify_command ( unsigned  idx,
unsigned  cmd 
)
inline
201 {
202 m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd;
203 }

References cmd.

◆ modify_vertex() [1/2]

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::modify_vertex ( unsigned  idx,
double  x,
double  y 
)
inline
177 {
178 T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1);
179 pv[0] = T(x);
180 pv[1] = T(y);
181 }

◆ modify_vertex() [2/2]

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::modify_vertex ( unsigned  idx,
double  x,
double  y,
unsigned  cmd 
)
inline
188 {
189 unsigned block = idx >> block_shift;
190 unsigned offset = idx & block_mask;
191 T* pv = m_coord_blocks[block] + (offset << 1);
192 pv[0] = T(x);
193 pv[1] = T(y);
195 }
EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL EIGEN_DEVICE_FUNC BlockXpr block(Index startRow, Index startCol, Index blockRows, Index blockCols)
This is the const version of block(Index,Index,Index,Index). *‍/.
Definition BlockMethods.h:64
void offset(Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
Definition geometries.hpp:132

References block(), and cmd.

+ Here is the call graph for this function:

◆ operator=()

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
const vertex_block_storage< T, S, P > & agg::vertex_block_storage< T, S, P >::operator= ( const self_type ps)
142 {
143 remove_all();
144 unsigned i;
145 for(i = 0; i < v.total_vertices(); i++)
146 {
147 double x, y;
148 unsigned cmd = v.vertex(i, &x, &y);
149 add_vertex(x, y, cmd);
150 }
151 return *this;
152 }
void add_vertex(double x, double y, unsigned cmd)
Definition agg_path_storage.h:163
void remove_all()
Definition agg_path_storage.h:156
const Scalar & y
Definition MathFunctions.h:552
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

References cmd, agg::vertex_block_storage< T, BlockShift, BlockPool >::total_vertices(), and agg::vertex_block_storage< T, BlockShift, BlockPool >::vertex().

+ Here is the call graph for this function:

◆ prev_vertex()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::prev_vertex ( double *  x,
double *  y 
) const
inline
242 {
243 if(m_total_vertices > 1) return vertex(m_total_vertices - 2, x, y);
244 return path_cmd_stop;
245 }

References agg::path_cmd_stop.

◆ remove_all()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::remove_all
inline
157 {
159 }

◆ storage_ptrs()

template<class T , unsigned S, unsigned P>
int8u * agg::vertex_block_storage< T, S, P >::storage_ptrs ( T **  xy_ptr)
private
338 {
339 unsigned nb = m_total_vertices >> block_shift;
340 if(nb >= m_total_blocks)
341 {
342 allocate_block(nb);
343 }
344 *xy_ptr = m_coord_blocks[nb] + ((m_total_vertices & block_mask) << 1);
346 }
void allocate_block(unsigned nb)
Definition agg_path_storage.h:299

◆ swap_vertices()

template<class T , unsigned S, unsigned P>
void agg::vertex_block_storage< T, S, P >::swap_vertices ( unsigned  v1,
unsigned  v2 
)
inline
208 {
209 unsigned b1 = v1 >> block_shift;
210 unsigned b2 = v2 >> block_shift;
211 unsigned o1 = v1 & block_mask;
212 unsigned o2 = v2 & block_mask;
213 T* pv1 = m_coord_blocks[b1] + (o1 << 1);
214 T* pv2 = m_coord_blocks[b2] + (o2 << 1);
215 T val;
216 val = pv1[0]; pv1[0] = pv2[0]; pv2[0] = val;
217 val = pv1[1]; pv1[1] = pv2[1]; pv2[1] = val;
218 int8u cmd = m_cmd_blocks[b1][o1];
219 m_cmd_blocks[b1][o1] = m_cmd_blocks[b2][o2];
220 m_cmd_blocks[b2][o2] = cmd;
221 }

References cmd.

◆ total_vertices()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::total_vertices
inline
274 {
275 return m_total_vertices;
276 }

Referenced by agg::vertex_block_storage< T, BlockShift, BlockPool >::operator=().

+ Here is the caller graph for this function:

◆ vertex()

template<class T , unsigned S, unsigned P>
unsigned agg::vertex_block_storage< T, S, P >::vertex ( unsigned  idx,
double *  x,
double *  y 
) const
inline
282 {
283 unsigned nb = idx >> block_shift;
284 const T* pv = m_coord_blocks[nb] + ((idx & block_mask) << 1);
285 *x = pv[0];
286 *y = pv[1];
287 return m_cmd_blocks[nb][idx & block_mask];
288 }

Referenced by agg::vertex_block_storage< T, BlockShift, BlockPool >::operator=().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_cmd_blocks

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
int8u** agg::vertex_block_storage< T, BlockShift, BlockPool >::m_cmd_blocks
private

◆ m_coord_blocks

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
T** agg::vertex_block_storage< T, BlockShift, BlockPool >::m_coord_blocks
private

◆ m_max_blocks

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
unsigned agg::vertex_block_storage< T, BlockShift, BlockPool >::m_max_blocks
private

◆ m_total_blocks

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
unsigned agg::vertex_block_storage< T, BlockShift, BlockPool >::m_total_blocks
private

◆ m_total_vertices

template<class T , unsigned BlockShift = 8, unsigned BlockPool = 256>
unsigned agg::vertex_block_storage< T, BlockShift, BlockPool >::m_total_vertices
private

The documentation for this class was generated from the following file: