00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2011 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib may link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Harry Storbacka 00027 ** Magnus Norddahl 00028 ** Kenneth Gangstoe 00029 */ 00030 00033 00034 #pragma once 00035 00036 #include "../api_display.h" 00037 #include <vector> 00038 #include "outline_circle.h" 00039 00040 class CL_Contour_Impl 00041 { 00042 public: 00043 CL_Contour_Impl() : is_inside_contour(false) {}; 00044 00045 std::vector<CL_Pointf> points; 00046 00047 bool is_inside_contour; 00048 00049 std::vector<CL_OutlineCircle> sub_circles; 00050 }; 00051 00056 class CL_Contour 00057 { 00060 public: 00062 CL_Contour() : impl(new CL_Contour_Impl()) {}; 00063 ~CL_Contour() {}; 00064 00068 public: 00069 // Points forming the countour. 00070 std::vector<CL_Pointf> &get_points() { return impl->points; } 00071 const std::vector<CL_Pointf> &get_points() const { return impl->points; } 00072 00073 // boolean specifying if this contour is inside-out (the inside of a hollow polygon) 00074 // if that is the case, then the collision-test will skip the inside_contour-test (because you can 00075 // be inside this one, without causing a collision) 00076 bool is_inside_contour() const { return impl->is_inside_contour; } 00077 00081 void set_inside_contour(bool is_inside) { impl->is_inside_contour = is_inside; } 00082 00083 // Circles encapsulating a part of the outline. 00084 // If two circles arent intersecting, none of the lines inside them 00085 // collide either. 00086 std::vector<CL_OutlineCircle> &get_sub_circles() { return impl->sub_circles; } 00087 const std::vector<CL_OutlineCircle> &get_sub_circles() const { return impl->sub_circles; } 00089 00092 public: 00094 bool operator==(const CL_Contour &other) const { return impl==other.impl; } 00095 00097 bool operator!=(const CL_Contour &other) const { return impl!=other.impl; } 00098 00100 bool operator<(const CL_Contour &other) const { return impl < other.impl; } 00101 00103 CL_Contour clone() 00104 { 00105 CL_Contour copy; 00106 copy.impl->points = impl->points; 00107 copy.impl->is_inside_contour = impl->is_inside_contour; 00108 copy.impl->sub_circles = impl->sub_circles; 00109 return copy; 00110 } 00111 00113 00116 private: 00117 CL_SharedPtr<CL_Contour_Impl> impl; 00119 }; 00120