1

I'm trying to use Clipper library to expand the obstacle images in my obstacle avoidance robot control assignment. But now, I'm even stuck with the example code of the library:

(http://www.angusj.com/delphi/clipper.php#code)

include "clipper.hpp"

//from clipper.hpp ...
//typedef signed long long long64;
//struct IntPoint {long64 X; long64 Y;};
//typedef std::vector<IntPoint> Polygon;
//typedef std::vector<Polygon> Polygons;
...
using namespace ClipperLib;

Polygons subj(2), clip(1), solution;

subj[0].push_back(IntPoint(180,200));
subj[0].push_back(IntPoint(260,200));
subj[0].push_back(IntPoint(260,150));
subj[0].push_back(IntPoint(180,150));

subj[1].push_back(IntPoint(215,160));
subj[1].push_back(IntPoint(230,190));
subj[1].push_back(IntPoint(200,190));

clip[0].push_back(IntPoint(190,210));
clip[0].push_back(IntPoint(240,210));
clip[0].push_back(IntPoint(240,130));
clip[0].push_back(IntPoint(190,130));

DrawPolygons(subj, 0x160000FF, 0x600000FF);  // <- identifier not found
DrawPolygons(clip, 0x20FFFF00, 0x30FF0000);  // <- identifier not found

Clipper c;
c.AddPolygons(subject, ptSubject);
c.AddPolygons(clip, ptClip);
if (c.Execute(ctIntersection, solution)
  DrawPolygons(solution, 0x3000FF00, 0xFF006600);

I'm wondering if I'm lack of any library installation? I know this is a small question and I'm a bit of a novic but any help can ease a lot of my work. Thank you!

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
TSL_
  • 2,049
  • 3
  • 34
  • 55

1 Answers1

5

I'm wondering if I'm lack of any library installation?

No, you're not lacking any library. The 'DrawPolygons' function is simply a placeholder for your own code. How you implement the drawing of polygons will depend on the graphics library you intend to use, if any (eg GDI+, OpenGL, Cairo, AGG etc).

(The Clipper package comes with numerous compiled examples that demonstrate how to use Clipper with each of the graphics rendering libraries mentioned above.)

Angus Johnson
  • 4,565
  • 2
  • 26
  • 28
  • 2
    Just a quick note to Angus - great library! – Adi May 23 '13 at 20:47
  • Thanks Adi. It's been fun and a real challenge creating it. – Angus Johnson May 24 '13 at 20:27
  • @AngusJohnson From your post regarding Cairo - https://groups.google.com/g/delphionrails/c/8H3GKwnUG4Q - is there a way to use clipper from within Cairo ? So, I have 2 Cairo paths p1 and p2 - how can I use clipper to intersect p1 and p2 ? – moi Jan 07 '22 at 08:32