Quote Originally Posted by rakeshthp View Post
Actually, there are two types of polyline. One is with points and another is without points (as shown in the attached image). So in case of polyline with points, There are three objects, one is polyline, second is node and third is vertex. So a special polyline is combination of Nodes, vertices and polyline. Am I right?
I'm not sure what you are trying to say exactly. Do you want to distinguish a polyline that displays its points from one that doesn't? Or are there other differences between the two types? Or are you just saying you want to model a polyline as a collection of points and lines?

In any case, the fact that your polyline can be represented (and drawn) as a set of points and lines does not imply that you should use the composite pattern. You could derive a class PolyLine (or PolyLineWithPoints) from a CompositeShape, but you probably wouldn't gain much from doing so, instead of just storing a bunch of points (in order) in a PolyLine object.

If you want to achieve good performance, then you should be reluctant to use runtime polymorphism in elements of your code that will occur inside performance-critical loops. An approach using parallel homogeneous arrays of each type of shape or using a variant type (see e.g. boost::variant) is likely to give better results in terms of performance.