ClanLib  2.3.7
contour.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 ** Magnus Norddahl
28 ** Kenneth Gangstoe
29 */
30 
33 
34 #pragma once
35 
36 #include "../api_display.h"
37 #include <vector>
38 #include "outline_circle.h"
39 
41 {
42 public:
44 
45  std::vector<CL_Pointf> points;
46 
48 
49  std::vector<CL_OutlineCircle> sub_circles;
50 };
51 
57 {
60 public:
62  CL_Contour() : impl(new CL_Contour_Impl()) {};
64 
68 public:
69  // Points forming the countour.
70  std::vector<CL_Pointf> &get_points() { return impl->points; }
71  const std::vector<CL_Pointf> &get_points() const { return impl->points; }
72 
73  // boolean specifying if this contour is inside-out (the inside of a hollow polygon)
74  // if that is the case, then the collision-test will skip the inside_contour-test (because you can
75  // be inside this one, without causing a collision)
76  bool is_inside_contour() const { return impl->is_inside_contour; }
77 
81  void set_inside_contour(bool is_inside) { impl->is_inside_contour = is_inside; }
82 
83  // Circles encapsulating a part of the outline.
84  // If two circles arent intersecting, none of the lines inside them
85  // collide either.
86  std::vector<CL_OutlineCircle> &get_sub_circles() { return impl->sub_circles; }
87  const std::vector<CL_OutlineCircle> &get_sub_circles() const { return impl->sub_circles; }
89 
92 public:
94  bool operator==(const CL_Contour &other) const { return impl==other.impl; }
95 
97  bool operator!=(const CL_Contour &other) const { return impl!=other.impl; }
98 
100  bool operator<(const CL_Contour &other) const { return impl < other.impl; }
101 
104  {
105  CL_Contour copy;
106  copy.impl->points = impl->points;
107  copy.impl->is_inside_contour = impl->is_inside_contour;
108  copy.impl->sub_circles = impl->sub_circles;
109  return copy;
110  }
111 
113 
116 private:
117  CL_SharedPtr<CL_Contour_Impl> impl;
119 };
120