Link to home
Start Free TrialLog in
Avatar of dienbaquan2nd
dienbaquan2ndFlag for United States of America

asked on

Polyline class in C++

In my problem, a polyline is defined to contain straight lines, arcs (elliptical), bezier curves and other polylines.
Please give me a suggestion to represent polyline with C++, so that I can isolate its components, rotate and duplicate a polyline?

I use Visual C++ 6.0. Thank you!
Avatar of maartennieber
maartennieber

The CGAL library can be used to handle different kinds of curves (check if it covers your needs)

http://www.cgal.org/

It requires buying a license for commercial applications, but not for open source.

I think CGAL does not handle polycurves (polylines of curves that may not be straight lines).
I don't know of a library that does handle this case. You may have to program your own class that holds a collection of curves (taken from CGAL for example) and ensures that the end-points of adjacent curves overlap.
Avatar of dienbaquan2nd

ASKER

Thank maartennieber, however I just need the conceptual of the design but not to dig into library like cgal.
You can do

class Segment
{
     Point p1;
     Point p2;
};

class Line : public Segment
{
};

class Arc : public Segment
{
     Point m;
};

class Bezier  : public Segment
{
    // some Bezier parameters
};

class PolyLine : public Segment
{
    std::vector<Segment*>  polyline;
};


Add some virtual functions to copy, rotate, or isolate segments of a polyline.

ASKER CERTIFIED SOLUTION
Avatar of dienbaquan2nd
dienbaquan2nd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial