Develop and Download Open Source Software

Browse CVS Repository

Contents of /autocoast/src/lib/gpc.hpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Nov 25 10:06:31 2004 UTC (19 years, 4 months ago) by tmurakam
Branch: MAIN
CVS Tags: v0_3, v0_2, HEAD
Changes since 1.4: +2 -3 lines
File MIME type: text/x-c++hdr
misc fix

1 //
2 // AutoCoast: Automatic Coastline scenery generator for Flight Simulator
3 //
4 // Copyright (c) 2004, Takuya Murakami. All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // 2. Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
21 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 // GPC wrapper class
30
31 #ifndef _GPC_HPP
32 #define _GPC_HPP
33
34 #include <vector>
35 using namespace std;
36
37 #include "common.hpp"
38
39 extern "C" {
40 #include "gpc.h"
41 }
42
43 #include "bbox.hpp"
44
45 class GpcVertexList
46 {
47 protected:
48 gpc_vertex_list *vlist;
49 bool ownVlistMemory;
50
51 inline void check(void) {
52 ASSERT(vlist != NULL);
53 }
54 inline void checkn(int n) {
55 ASSERT(vlist != NULL);
56 ASSERT(0 <= n && n < vlist->num_vertices);
57 }
58
59 public:
60 GpcVertexList(void);
61 GpcVertexList(int n, gpc_vertex *vertex);
62 GpcVertexList(gpc_vertex_list *v);
63 ~GpcVertexList();
64
65 inline int numVertices(void) { check(); return vlist->num_vertices; }
66 inline gpc_vertex *vertex(int n) { checkn(n); return &vlist->vertex[n]; }
67 inline double vx(int n) { checkn(n); return vlist->vertex[n].x; }
68 inline double vy(int n) { checkn(n); return vlist->vertex[n].y; }
69
70 void modifyStartPointFromEdge(BoundingBox &bbox);
71 void invert(void);
72 bool isLeftHand(void);
73 void smoothing(void);
74 void crop(BoundingBox &bbox);
75
76 /* internal use... */
77 inline gpc_vertex_list *getvlist(void) { return vlist; }
78 };
79
80 class GpcPolygon
81 {
82 protected:
83 gpc_polygon polygon;
84 vector<GpcVertexList*> contour;
85
86 public:
87 GpcPolygon();
88 ~GpcPolygon();
89 void clear(void);
90
91 void LoadFromFile(const char *fname);
92 void SaveToFile(const char *fname);
93 void AddVertexList(GpcVertexList *list, bool rebuild=true);
94 void BuildVertexListFromGpcPolygon(void);
95 GpcPolygon *Clipping(BoundingBox &bbox);
96
97 bool isEmpty(void);
98 bool isFull(BoundingBox &bbox);
99
100 inline int numVList(void) { return contour.size(); }
101 inline GpcVertexList *getVList(int n) { return contour.at(n); }
102
103 void Smoothing(void);
104 void Crop(BoundingBox &bbox);
105
106 void printStat(void);
107
108 /* internal use... */
109 inline gpc_polygon *getpolygon(void) { return &polygon; }
110 };
111
112 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26