]> git.mxchange.org Git - flightgear.git/blob - Clipper/clipper.hxx
Let's not pass copies of huge structures on the stack ... ye might see a
[flightgear.git] / Clipper / clipper.hxx
1 // clipper.hxx -- top level routines to take a series of arbitrary areas and
2 //                produce a tight fitting puzzle pieces that combine to make a
3 //                tile
4 //
5 // Written by Curtis Olson, started February 1999.
6 //
7 // Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
8 //
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 //
23 // $Id$
24 // (Log is kept at end of this file)
25  
26
27
28 #ifndef _CLIPPER_HXX
29 #define _CLIPPER_HXX
30
31
32 #ifndef __cplusplus                                                          
33 # error This library requires C++
34 #endif                                   
35
36
37 #include <Include/compiler.h>
38
39
40 // include Generic Polygon Clipping Library
41 //
42 //    http://www.cs.man.ac.uk/aig/staff/alan/software/
43 //
44 extern "C" {
45 #include <gpc.h>
46 }
47
48 #include STL_STRING
49 #include <vector>
50
51 FG_USING_STD(string);
52 FG_USING_STD(vector);
53
54
55 typedef vector < gpc_polygon * > gpcpoly_container;
56 typedef gpcpoly_container::iterator gpcpoly_iterator;
57 typedef gpcpoly_container::const_iterator const_gpcpoly_iterator;
58
59
60 #define FG_MAX_AREAS 20
61 #define EXTRA_SAFETY_CLIP
62 #define FG_MAX_VERTICES 100000
63
64
65 class point2d {
66 public:
67     double x, y;
68 };
69
70
71 class FGgpcPolyList {
72 public:
73     gpcpoly_container polys[FG_MAX_AREAS];
74     gpc_polygon safety_base;
75 };
76
77
78 class FGClipper {
79
80 private:
81
82     gpc_vertex_list v_list;
83     // static gpc_polygon poly;
84     FGgpcPolyList polys_in, polys_clipped;
85
86 public:
87
88     // Constructor
89     FGClipper( void );
90
91     // Destructor
92     ~FGClipper( void );
93
94     // Initialize Clipper (allocate and/or connect structures)
95     bool init();
96
97     // Load a polygon definition file
98     bool load_polys(const string& path);
99
100     // Do actually clipping work
101     bool clip_all(const point2d& min, const point2d& max);
102
103     // return output poly list
104     inline FGgpcPolyList get_polys_clipped() const { return polys_clipped; }
105 };
106
107
108 #endif // _CLIPPER_HXX
109
110
111 // $Log$
112 // Revision 1.4  1999/03/18 04:31:10  curt
113 // Let's not pass copies of huge structures on the stack ... ye might see a
114 // segfault ... :-)
115 //
116 // Revision 1.3  1999/03/17 23:48:59  curt
117 // minor renaming and a bit of rearranging.
118 //
119 // Revision 1.2  1999/03/13 23:51:34  curt
120 // Renamed main.cxx to testclipper.cxx
121 // Converted clipper routines to a class FGClipper.
122 //
123 // Revision 1.1  1999/03/01 15:39:39  curt
124 // Initial revision.
125 //