upgrade clipper to 5.1.5 - refs #1749
This commit is contained in:
parent
1b95518ce1
commit
8af516a904
3 changed files with 657 additions and 599 deletions
621
deps/agg/include/agg_conv_clipper.h
vendored
621
deps/agg/include/agg_conv_clipper.h
vendored
|
@ -1,326 +1,295 @@
|
|||
/*******************************************************************************
|
||||
* *
|
||||
* Author : Angus Johnson *
|
||||
* Version : 1.1 *
|
||||
* Date : 4 April 2011 *
|
||||
* Website : http://www.angusj.com *
|
||||
* Copyright : Angus Johnson 2010-2011 *
|
||||
* *
|
||||
* License: *
|
||||
* Use, modification & distribution is subject to Boost Software License Ver 1. *
|
||||
* http://www.boost.org/LICENSE_1_0.txt *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef AGG_CONV_CLIPPER_INCLUDED
|
||||
#define AGG_CONV_CLIPPER_INCLUDED
|
||||
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_array.h"
|
||||
#include "clipper.hpp"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
enum clipper_op_e { clipper_or,
|
||||
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
|
||||
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
|
||||
|
||||
template<class VSA, class VSB> class conv_clipper
|
||||
{
|
||||
enum status { status_move_to, status_line_to, status_stop };
|
||||
typedef VSA source_a_type;
|
||||
typedef VSB source_b_type;
|
||||
typedef conv_clipper<source_a_type, source_b_type> self_type;
|
||||
|
||||
private:
|
||||
source_a_type* m_src_a;
|
||||
source_b_type* m_src_b;
|
||||
status m_status;
|
||||
int m_vertex;
|
||||
int m_contour;
|
||||
int m_scaling_factor;
|
||||
clipper_op_e m_operation;
|
||||
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
|
||||
ClipperLib::Polygons m_poly_a;
|
||||
ClipperLib::Polygons m_poly_b;
|
||||
ClipperLib::Polygons m_result;
|
||||
ClipperLib::Clipper m_clipper;
|
||||
clipper_PolyFillType m_subjFillType;
|
||||
clipper_PolyFillType m_clipFillType;
|
||||
double start_x_;
|
||||
double start_y_;
|
||||
|
||||
int Round(double val)
|
||||
{
|
||||
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
|
||||
}
|
||||
|
||||
public:
|
||||
conv_clipper(source_a_type &a, source_b_type &b,
|
||||
clipper_op_e op = clipper_or,
|
||||
clipper_PolyFillType subjFillType = clipper_even_odd,
|
||||
clipper_PolyFillType clipFillType = clipper_even_odd,
|
||||
int scaling_factor = 2) :
|
||||
m_src_a(&a),
|
||||
m_src_b(&b),
|
||||
m_status(status_move_to),
|
||||
m_vertex(-1),
|
||||
m_contour(-1),
|
||||
m_operation(op),
|
||||
m_subjFillType(subjFillType),
|
||||
m_clipFillType(clipFillType),
|
||||
start_x_(0),
|
||||
start_y_(0)
|
||||
{
|
||||
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
|
||||
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
|
||||
}
|
||||
|
||||
conv_clipper(source_a_type &a,
|
||||
clipper_op_e op = clipper_and,
|
||||
clipper_PolyFillType subjFillType = clipper_non_zero,
|
||||
clipper_PolyFillType clipFillType = clipper_non_zero,
|
||||
int scaling_factor = 6) :
|
||||
m_src_a(&a),
|
||||
m_status(status_move_to),
|
||||
m_vertex(-1),
|
||||
m_contour(-1),
|
||||
m_operation(op),
|
||||
m_subjFillType(subjFillType),
|
||||
m_clipFillType(clipFillType),
|
||||
start_x_(0),
|
||||
start_y_(0)
|
||||
{
|
||||
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
|
||||
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
|
||||
}
|
||||
|
||||
~conv_clipper()
|
||||
{
|
||||
}
|
||||
unsigned type() const { return m_src_a->type(); }
|
||||
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
|
||||
{ m_src_a = &source; m_subjFillType = subjFillType; }
|
||||
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
|
||||
{ m_src_b = &source; m_clipFillType = clipFillType; }
|
||||
|
||||
void operation(clipper_op_e v) { m_operation = v; }
|
||||
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
bool next_contour();
|
||||
bool next_vertex(double* x, double* y);
|
||||
void start_extracting();
|
||||
void add_vertex_(double &x, double &y);
|
||||
void end_contour(ClipperLib::Polygons &p);
|
||||
|
||||
template<class VS> void add(VS &src, ClipperLib::Polygons &p){
|
||||
unsigned cmd;
|
||||
double x; double y; double start_x; double start_y;
|
||||
bool starting_first_line;
|
||||
|
||||
start_x = 0.0;
|
||||
start_y = 0.0;
|
||||
starting_first_line = true;
|
||||
p.resize(0);
|
||||
|
||||
cmd = src->vertex( &x , &y );
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
if(!starting_first_line ) end_contour(p);
|
||||
start_x = x;
|
||||
start_y = y;
|
||||
}
|
||||
add_vertex_( x, y );
|
||||
starting_first_line = false;
|
||||
}
|
||||
else if(is_end_poly(cmd))
|
||||
{
|
||||
if(!starting_first_line && is_closed(cmd))
|
||||
add_vertex_( start_x, start_y );
|
||||
}
|
||||
cmd = src->vertex( &x, &y );
|
||||
}
|
||||
end_contour(p);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::start_extracting()
|
||||
{
|
||||
m_status = status_move_to;
|
||||
m_contour = -1;
|
||||
m_vertex = -1;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
|
||||
{
|
||||
m_src_a->rewind( path_id );
|
||||
m_src_b->rewind( path_id );
|
||||
|
||||
add( m_src_a , m_poly_a );
|
||||
add( m_src_b , m_poly_b );
|
||||
m_result.resize(0);
|
||||
|
||||
ClipperLib::PolyFillType pftSubj, pftClip;
|
||||
switch (m_subjFillType)
|
||||
{
|
||||
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
|
||||
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
|
||||
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
|
||||
default: pftSubj = ClipperLib::pftNegative;
|
||||
}
|
||||
switch (m_clipFillType)
|
||||
{
|
||||
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
|
||||
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
|
||||
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
|
||||
default: pftClip = ClipperLib::pftNegative;
|
||||
}
|
||||
|
||||
m_clipper.Clear();
|
||||
switch( m_operation ) {
|
||||
case clipper_or:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
|
||||
break;
|
||||
}
|
||||
case clipper_and:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_xor:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_a_minus_b:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_b_minus_a:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
}
|
||||
start_extracting();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Polygons &p)
|
||||
{
|
||||
unsigned i, len;
|
||||
|
||||
if( m_vertex_accumulator.size() < 3 ) return;
|
||||
len = p.size();
|
||||
p.resize(len+1);
|
||||
p[len].resize(m_vertex_accumulator.size());
|
||||
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
|
||||
p[len][i] = m_vertex_accumulator[i];
|
||||
m_vertex_accumulator.remove_all();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
|
||||
{
|
||||
ClipperLib::IntPoint v;
|
||||
|
||||
v.X = Round(x * m_scaling_factor);
|
||||
v.Y = Round(y * m_scaling_factor);
|
||||
m_vertex_accumulator.add( v );
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
bool conv_clipper<VSA, VSB>::next_contour()
|
||||
{
|
||||
m_contour++;
|
||||
if(m_contour >= (int)m_result.size()) return false;
|
||||
m_vertex =-1;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
|
||||
{
|
||||
m_vertex++;
|
||||
if(m_vertex >= (int)m_result[m_contour].size()) return false;
|
||||
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
|
||||
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
|
||||
{
|
||||
if( m_status == status_move_to )
|
||||
{
|
||||
if( next_contour() )
|
||||
{
|
||||
if( next_vertex( x, y ) )
|
||||
{
|
||||
m_status =status_line_to;
|
||||
start_x_ = *x;
|
||||
start_y_ = *y;
|
||||
return path_cmd_move_to;
|
||||
}
|
||||
else
|
||||
{
|
||||
*x = start_x_;
|
||||
*y = start_y_;
|
||||
m_status = status_stop;
|
||||
return path_cmd_end_poly | path_flags_close;
|
||||
}
|
||||
}
|
||||
else
|
||||
return path_cmd_stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( next_vertex( x, y ) )
|
||||
{
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_status = status_move_to;
|
||||
*x = start_x_;
|
||||
*y = start_y_;
|
||||
return path_cmd_end_poly | path_flags_close;
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} //namespace agg
|
||||
#endif //AGG_CONV_CLIPPER_INCLUDED
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Author : Angus Johnson *
|
||||
* Version : 1.1 *
|
||||
* Date : 4 April 2011 *
|
||||
* Website : http://www.angusj.com *
|
||||
* Copyright : Angus Johnson 2010-2011 *
|
||||
* *
|
||||
* License: *
|
||||
* Use, modification & distribution is subject to Boost Software License Ver 1. *
|
||||
* http://www.boost.org/LICENSE_1_0.txt *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef AGG_CONV_CLIPPER_INCLUDED
|
||||
#define AGG_CONV_CLIPPER_INCLUDED
|
||||
|
||||
#include <cmath>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_array.h"
|
||||
#include "clipper.hpp"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
enum clipper_op_e { clipper_or,
|
||||
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
|
||||
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
|
||||
|
||||
template<class VSA, class VSB> class conv_clipper
|
||||
{
|
||||
enum status { status_move_to, status_line_to, status_stop };
|
||||
typedef VSA source_a_type;
|
||||
typedef VSB source_b_type;
|
||||
typedef conv_clipper<source_a_type, source_b_type> self_type;
|
||||
|
||||
private:
|
||||
source_a_type* m_src_a;
|
||||
source_b_type* m_src_b;
|
||||
status m_status;
|
||||
int m_vertex;
|
||||
int m_contour;
|
||||
int m_scaling_factor;
|
||||
clipper_op_e m_operation;
|
||||
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
|
||||
ClipperLib::Polygons m_poly_a;
|
||||
ClipperLib::Polygons m_poly_b;
|
||||
ClipperLib::Polygons m_result;
|
||||
ClipperLib::Clipper m_clipper;
|
||||
clipper_PolyFillType m_subjFillType;
|
||||
clipper_PolyFillType m_clipFillType;
|
||||
|
||||
int Round(double val)
|
||||
{
|
||||
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
|
||||
}
|
||||
|
||||
public:
|
||||
conv_clipper(source_a_type &a, source_b_type &b,
|
||||
clipper_op_e op = clipper_or,
|
||||
clipper_PolyFillType subjFillType = clipper_even_odd,
|
||||
clipper_PolyFillType clipFillType = clipper_even_odd,
|
||||
int scaling_factor = 2) :
|
||||
m_src_a(&a),
|
||||
m_src_b(&b),
|
||||
m_status(status_move_to),
|
||||
m_vertex(-1),
|
||||
m_contour(-1),
|
||||
m_operation(op),
|
||||
m_subjFillType(subjFillType),
|
||||
m_clipFillType(clipFillType)
|
||||
{
|
||||
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
|
||||
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
|
||||
}
|
||||
|
||||
~conv_clipper()
|
||||
{
|
||||
}
|
||||
|
||||
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
|
||||
{ m_src_a = &source; m_subjFillType = subjFillType; }
|
||||
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
|
||||
{ m_src_b = &source; m_clipFillType = clipFillType; }
|
||||
|
||||
void operation(clipper_op_e v) { m_operation = v; }
|
||||
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
|
||||
bool next_contour();
|
||||
bool next_vertex(double* x, double* y);
|
||||
void start_extracting();
|
||||
void add_vertex_(double &x, double &y);
|
||||
void end_contour(ClipperLib::Polygons &p);
|
||||
|
||||
template<class VS> void add(VS &src, ClipperLib::Polygons &p){
|
||||
unsigned cmd;
|
||||
double x; double y; double start_x; double start_y;
|
||||
bool starting_first_line;
|
||||
|
||||
start_x = 0.0;
|
||||
start_y = 0.0;
|
||||
starting_first_line = true;
|
||||
p.resize(0);
|
||||
|
||||
cmd = src->vertex( &x , &y );
|
||||
while(!is_stop(cmd))
|
||||
{
|
||||
if(is_vertex(cmd))
|
||||
{
|
||||
if(is_move_to(cmd))
|
||||
{
|
||||
if(!starting_first_line ) end_contour(p);
|
||||
start_x = x;
|
||||
start_y = y;
|
||||
}
|
||||
add_vertex_( x, y );
|
||||
starting_first_line = false;
|
||||
}
|
||||
else if(is_end_poly(cmd))
|
||||
{
|
||||
if(!starting_first_line && is_closed(cmd))
|
||||
add_vertex_( start_x, start_y );
|
||||
}
|
||||
cmd = src->vertex( &x, &y );
|
||||
}
|
||||
end_contour(p);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::start_extracting()
|
||||
{
|
||||
m_status = status_move_to;
|
||||
m_contour = -1;
|
||||
m_vertex = -1;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
|
||||
{
|
||||
m_src_a->rewind( path_id );
|
||||
m_src_b->rewind( path_id );
|
||||
|
||||
add( m_src_a , m_poly_a );
|
||||
add( m_src_b , m_poly_b );
|
||||
m_result.resize(0);
|
||||
|
||||
ClipperLib::PolyFillType pftSubj, pftClip;
|
||||
switch (m_subjFillType)
|
||||
{
|
||||
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
|
||||
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
|
||||
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
|
||||
default: pftSubj = ClipperLib::pftNegative;
|
||||
}
|
||||
switch (m_clipFillType)
|
||||
{
|
||||
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
|
||||
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
|
||||
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
|
||||
default: pftClip = ClipperLib::pftNegative;
|
||||
}
|
||||
|
||||
m_clipper.Clear();
|
||||
switch( m_operation ) {
|
||||
case clipper_or:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
|
||||
break;
|
||||
}
|
||||
case clipper_and:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_xor:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_a_minus_b:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
case clipper_b_minus_a:
|
||||
{
|
||||
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptSubject );
|
||||
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptClip );
|
||||
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
|
||||
break;
|
||||
}
|
||||
}
|
||||
start_extracting();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Polygons &p)
|
||||
{
|
||||
unsigned i, len;
|
||||
|
||||
if( m_vertex_accumulator.size() < 3 ) return;
|
||||
len = p.size();
|
||||
p.resize(len+1);
|
||||
p[len].resize(m_vertex_accumulator.size());
|
||||
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
|
||||
p[len][i] = m_vertex_accumulator[i];
|
||||
m_vertex_accumulator.remove_all();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
|
||||
{
|
||||
ClipperLib::IntPoint v;
|
||||
|
||||
v.X = Round(x * m_scaling_factor);
|
||||
v.Y = Round(y * m_scaling_factor);
|
||||
m_vertex_accumulator.add( v );
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
bool conv_clipper<VSA, VSB>::next_contour()
|
||||
{
|
||||
m_contour++;
|
||||
if(m_contour >= (int)m_result.size()) return false;
|
||||
m_vertex =-1;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
|
||||
{
|
||||
m_vertex++;
|
||||
if(m_vertex >= (int)m_result[m_contour].size()) return false;
|
||||
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
|
||||
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class VSA, class VSB>
|
||||
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
|
||||
{
|
||||
if( m_status == status_move_to )
|
||||
{
|
||||
if( next_contour() )
|
||||
{
|
||||
if( next_vertex( x, y ) )
|
||||
{
|
||||
m_status =status_line_to;
|
||||
return path_cmd_move_to;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_status = status_stop;
|
||||
return path_cmd_end_poly | path_flags_close;
|
||||
}
|
||||
}
|
||||
else
|
||||
return path_cmd_stop;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( next_vertex( x, y ) )
|
||||
{
|
||||
return path_cmd_line_to;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_status = status_move_to;
|
||||
return path_cmd_end_poly | path_flags_close;
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} //namespace agg
|
||||
#endif //AGG_CONV_CLIPPER_INCLUDED
|
||||
|
|
25
deps/clipper/include/clipper.hpp
vendored
Normal file → Executable file
25
deps/clipper/include/clipper.hpp
vendored
Normal file → Executable file
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************
|
||||
* *
|
||||
* Author : Angus Johnson *
|
||||
* Version : 5.1.3 *
|
||||
* Date : 27 February 2013 *
|
||||
* Version : 5.1.5 *
|
||||
* Date : 4 May 2013 *
|
||||
* Website : http://www.angusj.com *
|
||||
* Copyright : Angus Johnson 2010-2013 *
|
||||
* *
|
||||
|
@ -34,6 +34,8 @@
|
|||
#ifndef clipper_hpp
|
||||
#define clipper_hpp
|
||||
|
||||
#include <mapnik/config.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
@ -134,7 +136,6 @@ struct TEdge {
|
|||
double dx;
|
||||
long64 deltaX;
|
||||
long64 deltaY;
|
||||
long64 tmpX;
|
||||
PolyType polyType;
|
||||
EdgeSide side;
|
||||
int windDelta; //1 or -1 depending on winding direction
|
||||
|
@ -211,7 +212,7 @@ typedef std::vector < HorzJoinRec* > HorzJoinList;
|
|||
//ClipperBase is the ancestor to the Clipper class. It should not be
|
||||
//instantiated directly. This class simply abstracts the conversion of sets of
|
||||
//polygon coordinates into edge objects that are stored in a LocalMinima list.
|
||||
class ClipperBase
|
||||
class MAPNIK_DECL ClipperBase
|
||||
{
|
||||
public:
|
||||
ClipperBase();
|
||||
|
@ -232,7 +233,7 @@ protected:
|
|||
EdgeList m_edges;
|
||||
};
|
||||
|
||||
class Clipper : public virtual ClipperBase
|
||||
class MAPNIK_DECL Clipper : public virtual ClipperBase
|
||||
{
|
||||
public:
|
||||
Clipper();
|
||||
|
@ -248,6 +249,8 @@ public:
|
|||
void Clear();
|
||||
bool ReverseSolution() {return m_ReverseOutput;};
|
||||
void ReverseSolution(bool value) {m_ReverseOutput = value;};
|
||||
bool ForceSimple() {return m_ForceSimple;};
|
||||
void ForceSimple(bool value) {m_ForceSimple = value;};
|
||||
protected:
|
||||
void Reset();
|
||||
virtual bool ExecuteInternal();
|
||||
|
@ -265,6 +268,7 @@ private:
|
|||
PolyFillType m_SubjFillType;
|
||||
bool m_ReverseOutput;
|
||||
bool m_UsingPolyTree;
|
||||
bool m_ForceSimple;
|
||||
void DisposeScanbeamList();
|
||||
void SetWindingCount(TEdge& edge);
|
||||
bool IsEvenOddFillType(const TEdge& edge) const;
|
||||
|
@ -287,10 +291,8 @@ private:
|
|||
void ProcessHorizontal(TEdge *horzEdge);
|
||||
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
|
||||
OutRec* GetOutRec(int idx);
|
||||
void AppendPolygon(TEdge *e1, TEdge *e2);
|
||||
void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
|
||||
void IntersectEdges(TEdge *e1, TEdge *e2,
|
||||
const IntPoint &pt, const IntersectProtects protects);
|
||||
OutRec* CreateOutRec();
|
||||
|
@ -304,12 +306,12 @@ private:
|
|||
void ProcessEdgesAtTopOfScanbeam(const long64 topY);
|
||||
void BuildResult(Polygons& polys);
|
||||
void BuildResult2(PolyTree& polytree);
|
||||
void SetHoleState(TEdge *e, OutRec *OutRec);
|
||||
void SetHoleState(TEdge *e, OutRec *outrec);
|
||||
void DisposeIntersectNodes();
|
||||
bool FixupIntersectionOrder();
|
||||
void FixupOutPolygon(OutRec &outRec);
|
||||
void FixupOutPolygon(OutRec &outrec);
|
||||
bool IsHole(TEdge *e);
|
||||
void FixHoleLinkage(OutRec &outRec);
|
||||
void FixHoleLinkage(OutRec &outrec);
|
||||
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
|
||||
void ClearJoins();
|
||||
void AddHorzJoin(TEdge *e, int idx);
|
||||
|
@ -317,6 +319,7 @@ private:
|
|||
bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2);
|
||||
void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx);
|
||||
void JoinCommonEdges();
|
||||
void DoSimplePolygons();
|
||||
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
|
||||
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
|
||||
};
|
||||
|
|
610
deps/clipper/src/clipper.cpp
vendored
Normal file → Executable file
610
deps/clipper/src/clipper.cpp
vendored
Normal file → Executable file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue