more updates
[synfig.git] / synfig-core / trunk / src / synfig / curveset.h
1 /* === S I N F G =========================================================== */
2 /*!     \file curveset.h
3 **      \brief Curve Set Header
4 **
5 **      $Id: curveset.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === S T A R T =========================================================== */
23
24 #ifndef __SINFG_CURVESET_H
25 #define __SINFG_CURVESET_H
26
27 /* === H E A D E R S ======================================================= */
28 #include "blinepoint.h"
29 #include <vector>
30
31 /* === M A C R O S ========================================================= */
32
33 /* === T Y P E D E F S ===================================================== */
34
35 /* === C L A S S E S & S T R U C T S ======================================= */
36 namespace sinfg
37 {
38
39 class BLinePoint;
40         
41 struct CurvePoint
42 {
43         Point   p;
44         Point   l,r;
45         
46         CurvePoint () {}
47         CurvePoint(const Point &pin, const Vector &left, const Vector &right);
48         
49         CurvePoint(const BLinePoint &bpoint);
50 };
51         
52 class CurveSet 
53 {
54         bool            invert; //winding order...
55         
56         void CleanUp(int curve = 0);
57 public:
58         
59         typedef std::vector<CurvePoint> region;
60         typedef std::vector<region>             set_type;
61         
62         set_type        set; //specifies a region object (assumes looping)
63
64         void SetClamp(int &i, int &si);
65
66         //actual stuff
67         CurveSet()
68         {
69         }
70         
71         //anything supporting iterator type operations
72         template < typename Iterator >
73         CurveSet(Iterator begin, Iterator end, bool invert = false)
74         {
75                 set.push_back(std::vector<CurvePoint>(begin,end));
76                 CleanUp(invert);
77         }
78         
79         CurveSet operator &(const CurveSet &rhs) const; //intersect
80         CurveSet operator |(const CurveSet &rhs) const; //union
81         CurveSet operator -(const CurveSet &rhs) const; //subtract
82         
83         
84         //Point containment
85         int intersect(const Point &p) const;
86 };
87
88 }
89 /* === E N D =============================================================== */
90
91 #endif