Macros | Functions
vgl_clip.hxx File Reference
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <limits>
#include <cmath>
#include "vgl_clip.h"

Go to the source code of this file.

Macros

#define VGL_CLIP_INSTANTIATE(T)
 

Functions

template<class T >
bool vgl_clip_lineseg_to_line (T &x1, T &y1, T &x2, T &y2, T a, T b, T c)
 clips away the portion where ax+by+c<0. return false if nothing left. More...
 
template<class T >
bool vgl_clip_line_to_box (T a, T b, T c, T x1, T y1, T x2, T y2, T &bx, T &by, T &ex, T &ey)
 clip line ax+by+c=0 to given box. return false if no intersection. More...
 
template<class T >
vgl_polygon< T > vgl_clip (vgl_polygon< T > const &poly1, vgl_polygon< T > const &poly2, vgl_clip_type op, int *p_retval)
 Clip a polygon against another polygon. More...
 
template<class T >
vgl_polygon< T > vgl_clip (vgl_polygon< T > const &poly1, vgl_polygon< T > const &poly2, vgl_clip_type op)
 Clip a polygon against another polygon. More...
 

Detailed Description

Author
fsm

Definition in file vgl_clip.hxx.

Macro Definition Documentation

◆ VGL_CLIP_INSTANTIATE

#define VGL_CLIP_INSTANTIATE (   T)
Value:
template bool vgl_clip_lineseg_to_line(T&,T&,T&,T&,T,T,T); \
template bool vgl_clip_line_to_box(T,T,T,T,T,T,T,T&,T&,T&,T&); \
bool vgl_clip_lineseg_to_line(T &x1, T &y1, T &x2, T &y2, T a, T b, T c)
clips away the portion where ax+by+c<0. return false if nothing left.
Definition: vgl_clip.hxx:19
vgl_polygon< T > vgl_clip(const vgl_polygon< T > &poly1, const vgl_polygon< T > &poly2, vgl_clip_type op=vgl_clip_type_intersect)
Clip a polygon against another polygon.
vgl_clip_type
Type of polygon "clip" operations.
Definition: vgl_clip.h:23
vgl_line_segment_2d< T > vgl_clip_line_to_box(vgl_line_2d< T > const &l, vgl_box_2d< T > const &b)
clip given line to given box, and return resulting line segment.
Definition: vgl_clip.h:55
Store a polygon.
Definition: vgl_area.h:6

Definition at line 340 of file vgl_clip.hxx.

Function Documentation

◆ vgl_clip() [1/2]

template<class T >
vgl_polygon<T> vgl_clip ( vgl_polygon< T > const &  poly1,
vgl_polygon< T > const &  poly2,
vgl_clip_type  op,
int *  p_retval 
)

Clip a polygon against another polygon.

Same as vgl_clip( const vgl_polygon<T>& poly1, const vgl_polygon<T>& poly2, vgl_clip_type op = vgl_clip_type_intersect ); but where the fourth parameter is a return flag which is 1 if success, or 0 if the operation faced a geometric degeneracy which could not be handled. In this case, it might be necessary to perturb the input with a tiny amount of random noise and try again.

Definition at line 207 of file vgl_clip.hxx.

◆ vgl_clip() [2/2]

template<class T >
vgl_polygon<T> vgl_clip ( const vgl_polygon< T > &  poly1,
const vgl_polygon< T > &  poly2,
vgl_clip_type  op = vgl_clip_type_intersect 
)

Clip a polygon against another polygon.

The two polygons poly1 and poly2 are combined with each other. The operation (intersection, union, etc) is given by parameter op.

Note
The implementation of this code is based on Alan Murta's GPC library (http://www.cs.man.ac.uk/aig/staff/alan/software/gpc.html) which is free for non-commercial use.

In order to be able to use it, make sure to satisfy the copyright notice, then activate the "BUILD_NONCOMMERCIAL" compiler option.

Definition at line 333 of file vgl_clip.hxx.

◆ vgl_clip_line_to_box()

template<class T >
bool vgl_clip_line_to_box ( a,
b,
c,
x1,
y1,
x2,
y2,
T &  bx,
T &  by,
T &  ex,
T &  ey 
)

clip line ax+by+c=0 to given box. return false if no intersection.

Definition at line 45 of file vgl_clip.hxx.

◆ vgl_clip_lineseg_to_line()

template<class T >
bool vgl_clip_lineseg_to_line ( T &  x1,
T &  y1,
T &  x2,
T &  y2,
a,
b,
c 
)

clips away the portion where ax+by+c<0. return false if nothing left.

Definition at line 19 of file vgl_clip.hxx.