Polyline class in C++

Posted on 2009-05-23
Medium Priority
Last Modified: 2013-12-14
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!
Question by:dienbaquan2nd
  • 2

Expert Comment

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


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.

Author Comment

ID: 24461332
Thank maartennieber, however I just need the conceptual of the design but not to dig into library like cgal.
LVL 39

Expert Comment

ID: 24476091
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.


Accepted Solution

dienbaquan2nd earned 0 total points
ID: 24569746
I've solved it myself, thank you all!

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question