Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
agg::rasterizer_sl_clip< Conv > Class Template Reference

#include <src/agg/agg_rasterizer_sl_clip.h>

+ Collaboration diagram for agg::rasterizer_sl_clip< Conv >:

Public Types

typedef Conv conv_type
 
typedef Conv::coord_type coord_type
 
typedef rect_base< coord_typerect_type
 

Public Member Functions

 rasterizer_sl_clip ()
 
void reset_clipping ()
 
void clip_box (coord_type x1, coord_type y1, coord_type x2, coord_type y2)
 
void move_to (coord_type x1, coord_type y1)
 
template<class Rasterizer >
void line_to (Rasterizer &ras, coord_type x2, coord_type y2)
 

Private Member Functions

template<class Rasterizer >
AGG_INLINE void line_clip_y (Rasterizer &ras, coord_type x1, coord_type y1, coord_type x2, coord_type y2, unsigned f1, unsigned f2) const
 

Private Attributes

rect_type m_clip_box
 
coord_type m_x1
 
coord_type m_y1
 
unsigned m_f1
 
bool m_clipping
 

Detailed Description

template<class Conv>
class agg::rasterizer_sl_clip< Conv >

Member Typedef Documentation

◆ conv_type

template<class Conv >
typedef Conv agg::rasterizer_sl_clip< Conv >::conv_type

◆ coord_type

template<class Conv >
typedef Conv::coord_type agg::rasterizer_sl_clip< Conv >::coord_type

◆ rect_type

template<class Conv >
typedef rect_base<coord_type> agg::rasterizer_sl_clip< Conv >::rect_type

Constructor & Destructor Documentation

◆ rasterizer_sl_clip()

template<class Conv >
agg::rasterizer_sl_clip< Conv >::rasterizer_sl_clip ( )
inline
114 :
115 m_clip_box(0,0,0,0),
116 m_x1(0),
117 m_y1(0),
118 m_f1(0),
119 m_clipping(false)
120 {}
coord_type m_x1
Definition agg_rasterizer_sl_clip.h:301
bool m_clipping
Definition agg_rasterizer_sl_clip.h:304
coord_type m_y1
Definition agg_rasterizer_sl_clip.h:302
unsigned m_f1
Definition agg_rasterizer_sl_clip.h:303
rect_type m_clip_box
Definition agg_rasterizer_sl_clip.h:300

Member Function Documentation

◆ clip_box()

template<class Conv >
void agg::rasterizer_sl_clip< Conv >::clip_box ( coord_type  x1,
coord_type  y1,
coord_type  x2,
coord_type  y2 
)
inline
130 {
131 m_clip_box = rect_type(x1, y1, x2, y2);
133 m_clipping = true;
134 }
rect_base< coord_type > rect_type
Definition agg_rasterizer_sl_clip.h:111
const self_type & normalize()
Definition agg_basics.h:298

References agg::rasterizer_sl_clip< Conv >::m_clip_box, agg::rasterizer_sl_clip< Conv >::m_clipping, and agg::rect_base< T >::normalize().

+ Here is the call graph for this function:

◆ line_clip_y()

template<class Conv >
template<class Rasterizer >
AGG_INLINE void agg::rasterizer_sl_clip< Conv >::line_clip_y ( Rasterizer &  ras,
coord_type  x1,
coord_type  y1,
coord_type  x2,
coord_type  y2,
unsigned  f1,
unsigned  f2 
) const
inlineprivate
151 {
152 f1 &= 10;
153 f2 &= 10;
154 if((f1 | f2) == 0)
155 {
156 // Fully visible
157 ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2));
158 }
159 else
160 {
161 if(f1 == f2)
162 {
163 // Invisible by Y
164 return;
165 }
166
167 coord_type tx1 = x1;
168 coord_type ty1 = y1;
169 coord_type tx2 = x2;
170 coord_type ty2 = y2;
171
172 if(f1 & 8) // y1 < clip.y1
173 {
174 tx1 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1);
175 ty1 = m_clip_box.y1;
176 }
177
178 if(f1 & 2) // y1 > clip.y2
179 {
180 tx1 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1);
181 ty1 = m_clip_box.y2;
182 }
183
184 if(f2 & 8) // y2 < clip.y1
185 {
186 tx2 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1);
187 ty2 = m_clip_box.y1;
188 }
189
190 if(f2 & 2) // y2 > clip.y2
191 {
192 tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1);
193 ty2 = m_clip_box.y2;
194 }
195 ras.line(Conv::xi(tx1), Conv::yi(ty1),
196 Conv::xi(tx2), Conv::yi(ty2));
197 }
198 }
Conv::coord_type coord_type
Definition agg_rasterizer_sl_clip.h:110
T y1
Definition agg_basics.h:287
T y2
Definition agg_basics.h:287

References agg::rasterizer_sl_clip< Conv >::m_clip_box, agg::rect_base< T >::y1, and agg::rect_base< T >::y2.

Referenced by agg::rasterizer_sl_clip< Conv >::line_to().

+ Here is the caller graph for this function:

◆ line_to()

template<class Conv >
template<class Rasterizer >
void agg::rasterizer_sl_clip< Conv >::line_to ( Rasterizer &  ras,
coord_type  x2,
coord_type  y2 
)
inline
205 {
206 if(m_clipping)
207 {
208 unsigned f2 = clipping_flags(x2, y2, m_clip_box);
209
210 if((m_f1 & 10) == (f2 & 10) && (m_f1 & 10) != 0)
211 {
212 // Invisible by Y
213 m_x1 = x2;
214 m_y1 = y2;
215 m_f1 = f2;
216 return;
217 }
218
219 coord_type x1 = m_x1;
220 coord_type y1 = m_y1;
221 unsigned f1 = m_f1;
222 coord_type y3, y4;
223 unsigned f3, f4;
224
225 switch(((f1 & 5) << 1) | (f2 & 5))
226 {
227 case 0: // Visible by X
228 line_clip_y(ras, x1, y1, x2, y2, f1, f2);
229 break;
230
231 case 1: // x2 > clip.x2
232 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1);
234 line_clip_y(ras, x1, y1, m_clip_box.x2, y3, f1, f3);
235 line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x2, y2, f3, f2);
236 break;
237
238 case 2: // x1 > clip.x2
239 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1);
241 line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3);
242 line_clip_y(ras, m_clip_box.x2, y3, x2, y2, f3, f2);
243 break;
244
245 case 3: // x1 > clip.x2 && x2 > clip.x2
246 line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y2, f1, f2);
247 break;
248
249 case 4: // x2 < clip.x1
250 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1);
252 line_clip_y(ras, x1, y1, m_clip_box.x1, y3, f1, f3);
253 line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x1, y2, f3, f2);
254 break;
255
256 case 6: // x1 > clip.x2 && x2 < clip.x1
257 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1);
258 y4 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1);
261 line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3);
262 line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x1, y4, f3, f4);
263 line_clip_y(ras, m_clip_box.x1, y4, m_clip_box.x1, y2, f4, f2);
264 break;
265
266 case 8: // x1 < clip.x1
267 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1);
269 line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3);
270 line_clip_y(ras, m_clip_box.x1, y3, x2, y2, f3, f2);
271 break;
272
273 case 9: // x1 < clip.x1 && x2 > clip.x2
274 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1);
275 y4 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1);
278 line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3);
279 line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x2, y4, f3, f4);
280 line_clip_y(ras, m_clip_box.x2, y4, m_clip_box.x2, y2, f4, f2);
281 break;
282
283 case 12: // x1 < clip.x1 && x2 < clip.x1
284 line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y2, f1, f2);
285 break;
286 }
287 m_f1 = f2;
288 }
289 else
290 {
291 ras.line(Conv::xi(m_x1), Conv::yi(m_y1),
292 Conv::xi(x2), Conv::yi(y2));
293 }
294 m_x1 = x2;
295 m_y1 = y2;
296 }
AGG_INLINE void line_clip_y(Rasterizer &ras, coord_type x1, coord_type y1, coord_type x2, coord_type y2, unsigned f1, unsigned f2) const
Definition agg_rasterizer_sl_clip.h:147
unsigned clipping_flags_y(T y, const rect_base< T > &clip_box)
Definition agg_clip_liang_barsky.h:75
unsigned clipping_flags(T x, T y, const rect_base< T > &clip_box)
Definition agg_clip_liang_barsky.h:57
T x2
Definition agg_basics.h:287
T x1
Definition agg_basics.h:287

References agg::clipping_flags(), agg::clipping_flags_y(), agg::rasterizer_sl_clip< Conv >::line_clip_y(), agg::rasterizer_sl_clip< Conv >::m_clip_box, agg::rasterizer_sl_clip< Conv >::m_clipping, agg::rasterizer_sl_clip< Conv >::m_f1, agg::rasterizer_sl_clip< Conv >::m_x1, agg::rasterizer_sl_clip< Conv >::m_y1, agg::rect_base< T >::x1, and agg::rect_base< T >::x2.

+ Here is the call graph for this function:

◆ move_to()

template<class Conv >
void agg::rasterizer_sl_clip< Conv >::move_to ( coord_type  x1,
coord_type  y1 
)
inline
138 {
139 m_x1 = x1;
140 m_y1 = y1;
142 }

References agg::clipping_flags(), agg::rasterizer_sl_clip< Conv >::m_clip_box, agg::rasterizer_sl_clip< Conv >::m_clipping, agg::rasterizer_sl_clip< Conv >::m_f1, agg::rasterizer_sl_clip< Conv >::m_x1, and agg::rasterizer_sl_clip< Conv >::m_y1.

+ Here is the call graph for this function:

◆ reset_clipping()

template<class Conv >
void agg::rasterizer_sl_clip< Conv >::reset_clipping ( )
inline
124 {
125 m_clipping = false;
126 }

References agg::rasterizer_sl_clip< Conv >::m_clipping.

Member Data Documentation

◆ m_clip_box

◆ m_clipping

◆ m_f1

template<class Conv >
unsigned agg::rasterizer_sl_clip< Conv >::m_f1
private

◆ m_x1

◆ m_y1


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