Math-Clipper

 view release on metacpan or  search on metacpan

xsp/Clipper.xsp  view on Meta::CPAN

  Clipper();
  ~Clipper();

%{
ClipperLib::Polygons*
execute(THIS, clipType, subjFillType = pftEvenOdd, clipFillType = pftEvenOdd)
    Clipper* THIS
    ClipType clipType
    PolyFillType subjFillType
    PolyFillType clipFillType
  CODE:
    RETVAL = new ClipperLib::Polygons();
    THIS->Execute(clipType, *RETVAL, subjFillType, clipFillType);
  OUTPUT:
    RETVAL

ExPolygons*
ex_execute(THIS, clipType, subjFillType = pftEvenOdd, clipFillType = pftEvenOdd)
    Clipper* THIS
    ClipType clipType
    PolyFillType subjFillType
    PolyFillType clipFillType
  CODE:
    PolyTree* polytree = new ClipperLib::PolyTree();
    THIS->Execute(clipType, *polytree, subjFillType, clipFillType);
    RETVAL = new ExPolygons();
    PolyTreeToExPolygons(*polytree, *RETVAL);
    delete polytree;
  OUTPUT:
    RETVAL

ClipperLib::PolyTree*
pt_execute(THIS, clipType, subjFillType = pftEvenOdd, clipFillType = pftEvenOdd)
    Clipper* THIS
    ClipType clipType
    PolyFillType subjFillType
    PolyFillType clipFillType
  CODE:
    RETVAL = new ClipperLib::PolyTree();
    THIS->Execute(clipType, *RETVAL, subjFillType, clipFillType);
  OUTPUT:
    RETVAL
%}

// No longer in v4.X
//  %name{get_force_orientation}
//    bool ForceOrientation();
//  %name{set_force_orientation}
//    void ForceOrientation(bool value);

// We don't expose this since we save the PolyType stuff entirely that way!
//  %name{add_polygon}
//    void AddPolygon(const Polygon &pg, PolyType polyType);

%{

void
add_subject_polygon(self, poly)
    Clipper* self
    ClipperLib::Polygon* poly
  PPCODE:
    self->AddPolygon(*poly, ptSubject);
    delete poly;

void
add_clip_polygon(self, poly)
    Clipper* self
    ClipperLib::Polygon* poly
  PPCODE:
    self->AddPolygon(*poly, ptClip);
    delete poly;

void
add_subject_polygons(self, polys)
    Clipper* self
    ClipperLib::Polygons* polys
  PPCODE:
    self->AddPolygons(*polys, ptSubject);
    delete polys;

void
add_clip_polygons(self, polys)
    Clipper* self
    ClipperLib::Polygons* polys
  PPCODE:
    self->AddPolygons(*polys, ptClip);
    delete polys;

double
orientation(polygon)
    ClipperLib::Polygon* polygon
  CODE:
    RETVAL = ClipperLib::Orientation(*polygon);
    delete polygon;
  OUTPUT: RETVAL

double
area(polygon)
    ClipperLib::Polygon* polygon
  CODE:
    RETVAL = ClipperLib::Area(*polygon);
    delete polygon;
  OUTPUT: RETVAL

ClipperLib::Polygons*
_offset(polygons, delta, jointype, MiterLimit)
    ClipperLib::Polygons* polygons
    const float delta
    JoinType jointype
    const double MiterLimit
  CODE:
    RETVAL = new ClipperLib::Polygons();
    ClipperLib::OffsetPolygons(*polygons, *RETVAL, delta, jointype, MiterLimit);
    delete polygons;
  OUTPUT:
    RETVAL

ClipperLib::Polygons*
int_offset(polygons, delta, scale, jointype, MiterLimit)
    ClipperLib::Polygons* polygons
    const float delta
    const double scale
    JoinType jointype
    const double MiterLimit
  CODE:
    RETVAL = _int_offset(polygons, delta, scale, jointype, MiterLimit);
    delete polygons;
  OUTPUT:
    RETVAL

ClipperLib::Polygons*
int_offset2(polygons, delta1, delta2, scale, jointype, MiterLimit)
    ClipperLib::Polygons* polygons
    const float delta1
    const float delta2
    const double scale
    JoinType jointype
    const double MiterLimit
  CODE:
    // scale
    _scale_polygons(polygons, scale);
    
    // perform first offset
    ClipperLib::Polygons* offset1 = new ClipperLib::Polygons();
    ClipperLib::OffsetPolygons(*polygons, *offset1, (delta1*scale), jointype, MiterLimit);



( run in 0.474 second using v1.01-cache-2.11-cpan-5511b514fd6 )