dienbaquan2nd
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!
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!
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.