/usr/include/clippoly/poly.h is in libclippoly-dev 0.11-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | // nclip: a polygon clip library
// Copyright (C) 1993 Klamer Schutte
// klamer@mi.el.utwente.nl
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef POLY_H
#define POLY_H
// Revision 1.7 2005/03/12 16:32:36 klamer
// Changes to keep Visual C++ (vc98) silent while compiling.
//
// Revision 1.6 2005/02/28 21:12:05 klamer
// Made changes such that gcc 3.4.2 compiles silent with -ansi -pedantic -Wall.
//
// Revision 1.5 2005/02/28 17:21:12 klamer
// Changed to have g++ 3.2.3 run silently using g++ -ansi -pedantic -Wall -Wno-unused -Wno-reorder.
// Change use of (libg++) String to ANSI C++ string.
//
// Revision 1.2 1994/01/04 12:55:37 klamer
// Changed PolyNode constructors.
// Added Poly::revert() member.
//
// Revision 1.1 1993/10/27 14:43:52 klamer
// Initial revision
//
// Revision 1.2 1992/12/07 13:32:35 klamer
// Deleted comments from Poly::Poly(const Point &) in-class defined
// constructor.
//
// Revision 1.1 1992/12/07 10:46:35 klamer
// Initial revision
//
#ifdef __GNUG__
#pragma interface
#endif
#include <iostream>
#ifndef PRIMITIVES_H
#include <primitives.h>
#endif
#ifndef SET_H
#include <set.h>
#endif
#ifndef POSADDER_H
#include <posadder.h>
#endif
int intersect_right( const Edge &edge, const Point &point );
enum EdgeState { Unknown, None, Shared, Inside };
// enum LogicStates;
class Vec;
class Poly;
class PolyNode
{
friend class Poly;
friend class PolyIter;
friend class ConstPolyIter;
friend std::ostream &operator<<(std::ostream &, const PolyNode &);
public:
PolyNode *link()
{ return _link; }
const PolyNode *link() const
{ return _link; }
const Point &point() const
{ return p; }
EdgeState edgestate() const
{ return _edgestate; }
const PolyNode &prevnode() const;
// { return *_parent_poly->prevnode(this); }
const PolyNode &nextnode() const;
// { return *_parent_poly->nextnode(this); }
private:
PolyNode( const PolyNode © ); // Don't use
PolyNode( const PolyNode ©, const Poly *parent );
PolyNode( const Point &point, const Poly *parent, PolyNode *tail = 0)
: p( point ), next( tail ), prev(0), _link( 0 ),
_parent_poly( parent ), _edgestate( ::Unknown )
{ }
PolyNode( const Point &point, const Poly *parent, EdgeState es )
: p( point ), next( 0 ), prev(0), _link( 0 ),
_parent_poly( parent ), _edgestate( es )
{ }
~PolyNode();
void operator=( PolyNode node ); // Don't use it!
Point p;
PolyNode *next, *prev;
PolyNode *_link;
const Poly *_parent_poly;
const Poly *parent_poly() const;
EdgeState _edgestate;
};
class DirPolyIter;
class NodePEdge
{
const PolyNode *n1, *n2;
friend class Set<NodePEdge>;
friend class RSet<NodePEdge>;
NodePEdge()
{ }
public:
NodePEdge( const PolyNode *n_1, const PolyNode *n_2 )
: n1( n_1 ), n2( n_2 )
{ }
NodePEdge( const DirPolyIter &dpi );
int operator==( const NodePEdge &cmp ) const
{ return (n1 == cmp.n1) && (n2 == cmp.n2); }
};
typedef Set<const PolyNode *> PolyNodePList;
typedef SetIter<const PolyNode *> PolyNodePListIter;
typedef RSet<NodePEdge> NodePEdgeList;
typedef RSetIter<NodePEdge> NodePEdgeListIter;
enum Orientation { ClockWise, CounterClockWise };
class Poly
{
private:
friend class PolyIter;
friend class DirPolyIter;
PolyNode *list, *prev;
Poly &operator=( const Poly © ); // Don't use it!
public:
Poly( const Poly © )
: prev( 0 )
{ list = new PolyNode( *copy.list, this ); }
// Poly( const PolyNode *copy, const Poly *parent )
// : list( new PolyNode( copy, parent ) ), prev(0)
// { }
Poly( const Point &p, const Poly *parent, EdgeState es )
: list( new PolyNode( p, parent, es ) ), prev(0)
{ }
Poly( const Point &p )
// : list( new PolyNode( &PolyNode(p), 0 ) ), prev(0)
: prev(0)
{ list = new PolyNode( p, this ); }
~Poly()
{ delete list; }
void add( const Point &p, const Poly *parent, EdgeState es );
void add( const Point &p )
{ add( p, 0, ::Unknown ); } // 0 or this ???
int has_point( const Point &point ) const; // point inside *this?
const PolyNode *nextnode( const PolyNode *node ) const;
Orientation orientation() const;
double area() const;
void revert();
void make_prev() const;
const PolyNode *prevnode( const PolyNode *node ) const;
const Point &firstpoint() const
{ return list->point(); }
const PolyNode *firstnode() const
{ return list; }
double xmin() const;
double xmax() const;
double ymin() const;
double ymax() const;
int intersect_table( int hor, Vec &it, double h );
};
inline const PolyNode &
PolyNode::prevnode() const
{
return *_parent_poly->prevnode(this);
}
inline const PolyNode &
PolyNode::nextnode() const
{
return *_parent_poly->nextnode(this);
}
typedef Set<Poly *> PolyPList;
typedef SetIter<Poly *> PolyPListIter;
class PolyIter
{
Poly &poly;
PolyNode *cur, *app_next;
PolyNode *AppNext()
{ return (app_next != 0) ? app_next : poly.list; }
const PolyNode *AppNext() const
{ return (app_next != 0) ? app_next : poly.list; }
PolyNode *next(PolyNode *node)
{ return (node->next != 0) ? node->next : poly.list; }
PolyNode *add( const Point &point, int &new_point );
PolyNode *add( const Point &point )
{ int dummy; return add(point, dummy); }
public:
PolyIter( Poly &poly );
void reset()
{ app_next = poly.list; }
int operator() ();
PolyNode *node()
{ return cur; }
const PolyNode *node() const
{ return cur; }
const PolyNode *nextnode() const
{ return AppNext(); }
const PolyNode *prevnode() const
{ return poly.prevnode(node()); }
Edge edge() const
{ return Edge( cur->p, AppNext()->p ); }
static int add_point( PolyIter &a, PolyIter &b, const Point &p );
void set_shared()
{ cur->_edgestate = ::Shared; }
void set_inside()
{ cur->_edgestate = ::Inside; }
void set_none()
{ cur->_edgestate = ::None; }
};
enum IterDirection { FORWARD, BACKWARD, NONE };
class DirPolyIter
{
const Poly &_poly, &_linkpoly;
const IterDirection _dir;
const PolyNode *_node;
IterDirection dir() const
{ return _dir; }
const Poly &linkpoly() const
{ return _linkpoly; }
const PolyNode *prevnode() const;
public:
DirPolyIter( const Poly &poly, const PolyNode *node,
const Poly &link, IterDirection dir );
// Continue on link
DirPolyIter( const DirPolyIter &dpi, IterDirection dir );
void next()
{ _node = nextnode(); }
const PolyNode *node() const
{ return _node; }
const PolyNode *nextnode() const;
const PolyNode *link() const
{ return node()->link(); }
const Point &point() const
{ return node()->point(); }
const Point &nextpoint() const
{ return nextnode()->point(); }
const Point &linknextpoint() const
{ return linkpoly().nextnode(link())->point(); }
const Point &linkprevpoint() const
{ return linkpoly().prevnode(link())->point(); }
const Poly &poly() const
{ return _poly; }
EdgeState edgestate() const;
};
class ConstPolyIter
{
PolyIter polyiter;
const PolyNode *prevnode() const
{ return polyiter.prevnode(); }
const PolyNode *nextnode() const
{ return polyiter.nextnode(); }
public:
ConstPolyIter( const Poly &poly );
int operator() ()
{ return polyiter(); }
const PolyNode *node() const
{ return polyiter.node(); }
LogicStates parent(const Poly &poly);
const Point &point() const
{ return node()->point(); }
const Point &prevpoint() const
{ return prevnode()->point(); }
const Point &nextpoint() const
{ return nextnode()->point(); }
Edge edge() const
{ return polyiter.edge(); }
};
#endif /* POLY_H */
|