added: libraries and infos relatives to polygons (usefull for zone redesign)
This commit is contained in:
parent
611c220891
commit
dab0fd9edb
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,133 @@
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Project: Generic Polygon Clipper
|
||||||
|
|
||||||
|
A new algorithm for calculating the difference, intersection,
|
||||||
|
exclusive-or or union of arbitrary polygon sets.
|
||||||
|
|
||||||
|
File: gpc.h
|
||||||
|
Author: Alan Murta (email: gpc@cs.man.ac.uk)
|
||||||
|
Version: 2.32
|
||||||
|
Date: 17th December 2004
|
||||||
|
|
||||||
|
Copyright: (C) Advanced Interfaces Group,
|
||||||
|
University of Manchester.
|
||||||
|
|
||||||
|
This software is free for non-commercial use. It may be copied,
|
||||||
|
modified, and redistributed provided that this copyright notice
|
||||||
|
is preserved on all copies. The intellectual property rights of
|
||||||
|
the algorithms used reside with the University of Manchester
|
||||||
|
Advanced Interfaces Group.
|
||||||
|
|
||||||
|
You may not use this software, in whole or in part, in support
|
||||||
|
of any commercial product without the express consent of the
|
||||||
|
author.
|
||||||
|
|
||||||
|
There is no warranty or other guarantee of fitness of this
|
||||||
|
software for any purpose. It is provided solely "as is".
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gpc_h
|
||||||
|
#define __gpc_h
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Constants
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Increase GPC_EPSILON to encourage merging of near coincident edges */
|
||||||
|
|
||||||
|
#define GPC_EPSILON (DBL_EPSILON)
|
||||||
|
|
||||||
|
#define GPC_VERSION "2.32"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Public Data Types
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum /* Set operation type */
|
||||||
|
{
|
||||||
|
GPC_DIFF, /* Difference */
|
||||||
|
GPC_INT, /* Intersection */
|
||||||
|
GPC_XOR, /* Exclusive or */
|
||||||
|
GPC_UNION /* Union */
|
||||||
|
} gpc_op;
|
||||||
|
|
||||||
|
typedef struct /* Polygon vertex structure */
|
||||||
|
{
|
||||||
|
double x; /* Vertex x component */
|
||||||
|
double y; /* vertex y component */
|
||||||
|
} gpc_vertex;
|
||||||
|
|
||||||
|
typedef struct /* Vertex list structure */
|
||||||
|
{
|
||||||
|
int num_vertices; /* Number of vertices in list */
|
||||||
|
gpc_vertex *vertex; /* Vertex array pointer */
|
||||||
|
} gpc_vertex_list;
|
||||||
|
|
||||||
|
typedef struct /* Polygon set structure */
|
||||||
|
{
|
||||||
|
int num_contours; /* Number of contours in polygon */
|
||||||
|
int *hole; /* Hole / external contour flags */
|
||||||
|
gpc_vertex_list *contour; /* Contour array pointer */
|
||||||
|
} gpc_polygon;
|
||||||
|
|
||||||
|
typedef struct /* Tristrip set structure */
|
||||||
|
{
|
||||||
|
int num_strips; /* Number of tristrips */
|
||||||
|
gpc_vertex_list *strip; /* Tristrip array pointer */
|
||||||
|
} gpc_tristrip;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
Public Function Prototypes
|
||||||
|
===========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
void gpc_read_polygon (FILE *infile_ptr,
|
||||||
|
int read_hole_flags,
|
||||||
|
gpc_polygon *polygon);
|
||||||
|
|
||||||
|
void gpc_write_polygon (FILE *outfile_ptr,
|
||||||
|
int write_hole_flags,
|
||||||
|
gpc_polygon *polygon);
|
||||||
|
|
||||||
|
void gpc_add_contour (gpc_polygon *polygon,
|
||||||
|
gpc_vertex_list *contour,
|
||||||
|
int hole);
|
||||||
|
|
||||||
|
void gpc_polygon_clip (gpc_op set_operation,
|
||||||
|
gpc_polygon *subject_polygon,
|
||||||
|
gpc_polygon *clip_polygon,
|
||||||
|
gpc_polygon *result_polygon);
|
||||||
|
|
||||||
|
void gpc_tristrip_clip (gpc_op set_operation,
|
||||||
|
gpc_polygon *subject_polygon,
|
||||||
|
gpc_polygon *clip_polygon,
|
||||||
|
gpc_tristrip *result_tristrip);
|
||||||
|
|
||||||
|
void gpc_polygon_to_tristrip (gpc_polygon *polygon,
|
||||||
|
gpc_tristrip *tristrip);
|
||||||
|
|
||||||
|
void gpc_free_polygon (gpc_polygon *polygon);
|
||||||
|
|
||||||
|
void gpc_free_tristrip (gpc_tristrip *tristrip);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
===========================================================================
|
||||||
|
End of file: gpc.h
|
||||||
|
===========================================================================
|
||||||
|
*/
|
Binary file not shown.
|
@ -0,0 +1,123 @@
|
||||||
|
|
||||||
|
Generic Polygon Clipper (gpc) Revision History
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
|
||||||
|
v2.32 17th Dec 2004
|
||||||
|
---------------------
|
||||||
|
Fixed occasional memory leak occurring when processing some
|
||||||
|
degenerate polygon arrangements.
|
||||||
|
Added explicit type casting to memory allocator in support of
|
||||||
|
increased code portability.
|
||||||
|
|
||||||
|
v2.31 4th Jun 1999
|
||||||
|
---------------------
|
||||||
|
Separated edge merging measure based on a user-defined GPC_EPSILON
|
||||||
|
value from general numeric equality testing and ordering, which now
|
||||||
|
uses direct arithmetic comparison rather an EPSILON based proximity
|
||||||
|
test.
|
||||||
|
Fixed problem with numerical equality test during construction of
|
||||||
|
local minima and scanbeam tables, leading to occasional crash.
|
||||||
|
Fixed hole array memory leak in gpc_add_contour.
|
||||||
|
Fixed uninitialised hole field bug in gpc_polygon_clip result.
|
||||||
|
|
||||||
|
v2.30 11th Apr 1999
|
||||||
|
---------------------
|
||||||
|
Major re-write.
|
||||||
|
Minor API change: additional 'hole' array field added to gpc_polygon
|
||||||
|
datatype to indicate which constituent contours are internal holes,
|
||||||
|
and which form external boundaries.
|
||||||
|
Minor API change: additional 'hole' argument to gpc_add_contour
|
||||||
|
to indicate whether the new contour is a hole or external contour.
|
||||||
|
Minor API change: additional parameter to gpc_read_polygon and
|
||||||
|
gpc_write_polygon to indicate whether or not to read or write
|
||||||
|
contour hole flags.
|
||||||
|
Fixed NULL pointer bug in add/merge left/right operations.
|
||||||
|
Fixed numerical problem in intersection table generation.
|
||||||
|
Fixed zero byte malloc problem.
|
||||||
|
Fixed problem producing occasional 2 vertex contours.
|
||||||
|
Added bounding box test optimisations.
|
||||||
|
Simplified edge bundle creation, detection of scanbeam internal
|
||||||
|
edge intersections and tristrip scanbeam boundary code.
|
||||||
|
Renamed 'class' variable to be C++ friendly.
|
||||||
|
|
||||||
|
v2.22 17th Oct 1998
|
||||||
|
---------------------
|
||||||
|
Re-implemented edge interpolation and intersection calculations
|
||||||
|
to improve numerical robustness.
|
||||||
|
Simplified setting of GPC_EPSILON.
|
||||||
|
|
||||||
|
v2.21 19th Aug 1998
|
||||||
|
---------------------
|
||||||
|
Fixed problem causing occasional incorrect output when processing
|
||||||
|
self-intersecting polygons (bow-ties etc).
|
||||||
|
Removed bug which may lead to non-generation of uppermost triangle
|
||||||
|
in tristrip output.
|
||||||
|
|
||||||
|
v2.20 26th May 1998
|
||||||
|
---------------------
|
||||||
|
Major re-write.
|
||||||
|
Added exclusive-or polygon set operation.
|
||||||
|
Replaced table-based processing of edge intersections with
|
||||||
|
rule-based system.
|
||||||
|
Replaced two-pass approach to scanbeam interior processing with
|
||||||
|
single pass method.
|
||||||
|
|
||||||
|
v2.10a 14th May 1998
|
||||||
|
---------------------
|
||||||
|
Minor bug-fixes to counter some v2.10 reliability problems.
|
||||||
|
|
||||||
|
v2.10 11th May 1998
|
||||||
|
---------------------
|
||||||
|
Major re-write.
|
||||||
|
Incorporated edge bundle processing of AET to overcome coincident
|
||||||
|
edge problems present in previous releases.
|
||||||
|
Replaced Vatti's method for processing scanbeam interior regions
|
||||||
|
with an adapted version of the scanbeam boundary processing
|
||||||
|
algorithm.
|
||||||
|
|
||||||
|
v2.02 16th Apr 1998 (unreleased)
|
||||||
|
----------------------------------
|
||||||
|
Fixed internal minimum vertex duplication in gpc_polygon_clip
|
||||||
|
result.
|
||||||
|
Improved line intersection code discourage superfluous
|
||||||
|
intersections near line ends.
|
||||||
|
Removed limited precision number formatting in gpc_write_polygon.
|
||||||
|
Modification to allow subject or clip polygon to be reused as the
|
||||||
|
result in gpc_polygon_clip without memory leakage.
|
||||||
|
|
||||||
|
v2.01 23rd Feb 1998
|
||||||
|
---------------------
|
||||||
|
Removed bug causing duplicated vertices in output polygon.
|
||||||
|
Fixed scanbeam table index overrun problem.
|
||||||
|
|
||||||
|
v2.00 25th Nov 1997
|
||||||
|
---------------------
|
||||||
|
Major re-write.
|
||||||
|
Replaced temporary horizontal edge work-around (using tilting)
|
||||||
|
with true horizontal edge handling.
|
||||||
|
Trapezoidal output replaced by tristrips.
|
||||||
|
gpc_op constants now feature a `GPC_' prefix.
|
||||||
|
Data structures now passed by reference to gpc functions.
|
||||||
|
Replaced AET search by proxy addressing in polygon table.
|
||||||
|
Eliminated most (all?) coincident vertex / edge crashes.
|
||||||
|
|
||||||
|
v1.02 18th Oct 1997 (unreleased)
|
||||||
|
----------------------------------
|
||||||
|
Significantly reduced number of mallocs in build_lmt.
|
||||||
|
Scanbeam table now built using heapsort rather than insertion
|
||||||
|
sort.
|
||||||
|
|
||||||
|
v1.01 12th Oct 1997
|
||||||
|
---------------------
|
||||||
|
Fixed memory leak during output polygon build in
|
||||||
|
gpc_clip_polygon.
|
||||||
|
Removed superfluous logfile debug code.
|
||||||
|
Commented out malloc counts.
|
||||||
|
Added missing horizontal edge tilt-correction code in
|
||||||
|
gpc_clip_polygon.
|
||||||
|
|
||||||
|
v1.00 8th Oct 1997
|
||||||
|
--------------------
|
||||||
|
First release.
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**********************/
|
||||||
|
/* Some usual defines */
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
#ifndef DEFS_MACROS_H
|
||||||
|
#define DEFS_MACROS_H
|
||||||
|
|
||||||
|
#ifndef BOOL
|
||||||
|
#define BOOL bool
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE false
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE true
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef abs
|
||||||
|
#define abs(x) (((x) >=0) ? (x) : (-(x)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TRACE printf
|
||||||
|
|
||||||
|
#define ASSERT(x) // todo : change to DEBUG, under wxWidgets
|
||||||
|
|
||||||
|
#endif // ifndef DEFS_MACROS_H
|
|
@ -0,0 +1,17 @@
|
||||||
|
links to software relative to polygons (clipping and and other operations)
|
||||||
|
|
||||||
|
used in freePCB (Written by Alan Wright)
|
||||||
|
gpc (here: GenericPolygonClipperLibrary.cpp)
|
||||||
|
http://www.cs.man.ac.uk/~toby/alan/software/gpc.html
|
||||||
|
|
||||||
|
polygon.php (ported in "C++" by Alan Wright)
|
||||||
|
the c++ corresponding file is php_polygon.cpp
|
||||||
|
http://www.phpclasses.org/browse/file/10683.html
|
||||||
|
|
||||||
|
used in gpcb:
|
||||||
|
polygon1.c:
|
||||||
|
http://www.koders.com/c/
|
||||||
|
and for this file:
|
||||||
|
http://www.koders.com/c/fidE26CF2236C2DF7E435D597390A05B982EDFB4C38.aspx
|
||||||
|
|
||||||
|
gpcb uses a modified file (integer coordinates)
|
|
@ -0,0 +1,18 @@
|
||||||
|
WXDIR = $(WXWIN)
|
||||||
|
|
||||||
|
TARGET = lib_polygon.a
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
include ../libs.win
|
||||||
|
|
||||||
|
include makefile.include
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS) ../libs.win makefile.include
|
||||||
|
ar ruv $@ $(OBJECTS)
|
||||||
|
ranlib $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.bak
|
||||||
|
rm -f *.o
|
||||||
|
rm -f $(TARGET)
|
|
@ -0,0 +1,37 @@
|
||||||
|
## Makefile for common.a
|
||||||
|
CC = gcc
|
||||||
|
|
||||||
|
|
||||||
|
include ../libs.linux
|
||||||
|
|
||||||
|
# Compiler flags.
|
||||||
|
CPPFLAGS += -I./ -I../include
|
||||||
|
|
||||||
|
EDACPPFLAGS = $(CPPFLAGS)
|
||||||
|
|
||||||
|
TARGET = lib_polygon.a
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
deps:
|
||||||
|
$(CXX) $(CPPFLAGS) -E -MMD -MG *.cpp >/dev/null
|
||||||
|
|
||||||
|
include makefile.include
|
||||||
|
-include *.d
|
||||||
|
|
||||||
|
CPPFLAGS += $(EXTRACPPFLAGS) -fno-strict-aliasing
|
||||||
|
EDACPPFLAGS = $(CPPFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS) makefile.gtk makefile.include
|
||||||
|
rm -f $@
|
||||||
|
ar -rv $@ $(OBJECTS)
|
||||||
|
ranlib $@
|
||||||
|
|
||||||
|
install:$(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *~ core *.bak *.obj *.d
|
||||||
|
rm -f $(TARGET)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
EXTRACPPFLAGS += -I$(SYSINCLUDE) -I./ -Ibitmaps -I../include
|
||||||
|
|
||||||
|
COMMON =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OBJECTS= \
|
||||||
|
GenericPolygonClipperLibrary.o \
|
||||||
|
php_polygon.o\
|
||||||
|
php_polygon_vertex.o
|
||||||
|
|
||||||
|
GenericPolygonClipperLibrary.o: GenericPolygonClipperLibrary.cpp GenericPolygonClipperLibrary.h
|
||||||
|
|
||||||
|
php_polygon.o: php_polygon.cpp php_polygon.h php_polygon_vertex.h defs-macros.h
|
||||||
|
|
||||||
|
#polygon1.o: polygon1.cpp polyarea.h vectmatr.h
|
|
@ -0,0 +1,26 @@
|
||||||
|
## Makefile for common.a
|
||||||
|
|
||||||
|
include ../libs.macosx
|
||||||
|
|
||||||
|
TARGET = lib_polygon.a
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
|
||||||
|
deps:
|
||||||
|
$(CXX) $(CPPFLAGS) -E -MMD -MG *.cpp >/dev/null
|
||||||
|
|
||||||
|
include makefile.include
|
||||||
|
-include *.d
|
||||||
|
|
||||||
|
CPPFLAGS += $(EXTRACPPFLAGS)
|
||||||
|
EDACPPFLAGS = $(CPPFLAGS)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS) makefile.macosx makefile.include
|
||||||
|
rm -f $@
|
||||||
|
ar -rv $@ $(OBJECTS)
|
||||||
|
ranlib $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o; rm -f *~
|
||||||
|
rm -f $(TARGET)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,61 @@
|
||||||
|
// file php_polygon.h
|
||||||
|
// See comments in php_polygon.cpp
|
||||||
|
|
||||||
|
#ifndef PHP_POLYGON_H
|
||||||
|
#define PHP_POLYGON_H
|
||||||
|
|
||||||
|
class vertex;
|
||||||
|
class segment;
|
||||||
|
|
||||||
|
#define infinity 100000000 // for places that are far far away
|
||||||
|
#define PI 3.14159265359
|
||||||
|
|
||||||
|
enum{ A_OR_B, A_AND_B, A_MINUS_B, B_MINUS_A };
|
||||||
|
|
||||||
|
class polygon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
** This class manages a doubly linked list of vertex objects that represents
|
||||||
|
** a polygon. The class consists of basic methods to manage the list
|
||||||
|
** and methods to implement boolean operations between polygon objects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
vertex * m_first; // Reference to first vertex in the linked list
|
||||||
|
int m_cnt; // Tracks number of vertices in the polygon
|
||||||
|
|
||||||
|
polygon( vertex * first = NULL );
|
||||||
|
~polygon();
|
||||||
|
vertex * getFirst();
|
||||||
|
polygon * NextPoly();
|
||||||
|
|
||||||
|
void add( vertex * nv );
|
||||||
|
void addv( double x, double y,
|
||||||
|
double xc=0, double yc=0, int d=0);
|
||||||
|
vertex * del( vertex * v );
|
||||||
|
void res();
|
||||||
|
polygon * copy_poly();
|
||||||
|
void insertSort( vertex * nv, vertex * s, vertex * e );
|
||||||
|
vertex * nxt( vertex * v );
|
||||||
|
BOOL unckd_remain();
|
||||||
|
vertex * first_unckd_intersect();
|
||||||
|
double dist( double x1, double y1, double x2, double y2 );
|
||||||
|
double angle( double xc, double yc, double x1, double y1 );
|
||||||
|
double aAlpha( double x1, double y1, double x2, double y2,
|
||||||
|
double xc, double yc, double xi, double yi, double d );
|
||||||
|
void perturb( vertex * p1, vertex * p2, vertex * q1, vertex * q2,
|
||||||
|
double aP, double aQ );
|
||||||
|
BOOL ints( vertex * p1, vertex * p2, vertex * q1, vertex * q2,
|
||||||
|
int * n, double ix[], double iy[], double alphaP[], double alphaQ[] );
|
||||||
|
BOOL isInside ( vertex * v );
|
||||||
|
polygon * boolean( polygon * polyB, int oper );
|
||||||
|
#if 0
|
||||||
|
function isPolyInside (p);
|
||||||
|
function move (dx, dy);
|
||||||
|
function rotate (xr, yr, a);
|
||||||
|
function &bRect ();
|
||||||
|
#endif
|
||||||
|
}; //end of class polygon
|
||||||
|
|
||||||
|
|
||||||
|
#endif // ifndef PHP_POLYGON_H
|
|
@ -0,0 +1,144 @@
|
||||||
|
// file php_polygon_vertex.cpp
|
||||||
|
// This is a port of a php class written by Brenor Brophy (see below)
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
** File: vertex.php
|
||||||
|
** Description: PHP class for a polygon vertex. Used as the base object to
|
||||||
|
** build a class of polygons.
|
||||||
|
** Version: 1.1
|
||||||
|
** Author: Brenor Brophy
|
||||||
|
** Email: brenor at sbcglobal dot net
|
||||||
|
** Homepage: www.brenorbrophy.com
|
||||||
|
**------------------------------------------------------------------------------
|
||||||
|
** COPYRIGHT (c) 2005 BRENOR BROPHY
|
||||||
|
**
|
||||||
|
** The source code included in this package is free software; you can
|
||||||
|
** redistribute it and/or modify it under the terms of the GNU General Public
|
||||||
|
** License as published by the Free Software Foundation. This license can be
|
||||||
|
** read at:
|
||||||
|
**
|
||||||
|
** http://www.opensource.org/licenses/gpl-license.php
|
||||||
|
**
|
||||||
|
** This program 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 General Public License for more details.
|
||||||
|
**------------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
** Based on the paper "Efficient Clipping of Arbitary Polygons" by Gunther
|
||||||
|
** Greiner (greiner at informatik dot uni-erlangen dot de) and Kai Hormann
|
||||||
|
** (hormann at informatik dot tu-clausthal dot de), ACM Transactions on Graphics
|
||||||
|
** 1998;17(2):71-83.
|
||||||
|
**
|
||||||
|
** Available at: www.in.tu-clausthal.de/~hormann/papers/clipping.pdf
|
||||||
|
**
|
||||||
|
** Another useful site describing the algorithm and with some example
|
||||||
|
** C code by Ionel Daniel Stroe is at:
|
||||||
|
**
|
||||||
|
** http://davis.wpi.edu/~matt/courses/clipping/
|
||||||
|
**
|
||||||
|
** The algorithm is extended by Brenor Brophy to allow polygons with
|
||||||
|
** arcs between vertices.
|
||||||
|
**
|
||||||
|
** Rev History
|
||||||
|
** -----------------------------------------------------------------------------
|
||||||
|
** 1.0 08/25/2005 Initial Release
|
||||||
|
** 1.1 09/04/2005 Added software license language to header comments
|
||||||
|
*/
|
||||||
|
//#include "stdafx.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "php_polygon_vertex.h"
|
||||||
|
|
||||||
|
segment::segment(double xc, double yc, int d )
|
||||||
|
{
|
||||||
|
m_xc = xc;
|
||||||
|
m_yc = yc;
|
||||||
|
m_d = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex::vertex( double x, double y,
|
||||||
|
double xc, double yc, double d,
|
||||||
|
vertex * nextV, vertex * prevV,
|
||||||
|
polygon * nextPoly,
|
||||||
|
BOOL intersect,
|
||||||
|
vertex * neighbor,
|
||||||
|
double alpha,
|
||||||
|
BOOL entry,
|
||||||
|
BOOL checked )
|
||||||
|
{
|
||||||
|
m_x = x;
|
||||||
|
m_y = y;
|
||||||
|
m_nextV = nextV;
|
||||||
|
m_prevV = prevV;
|
||||||
|
m_nextPoly = nextPoly;
|
||||||
|
m_intersect = intersect;
|
||||||
|
m_neighbor = neighbor;
|
||||||
|
m_alpha = alpha;
|
||||||
|
m_entry = entry;
|
||||||
|
m_checked = checked;
|
||||||
|
m_id = 0;
|
||||||
|
m_nSeg = new segment( xc, yc, d );
|
||||||
|
m_pSeg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex::~vertex()
|
||||||
|
{
|
||||||
|
if( m_nSeg )
|
||||||
|
delete m_nSeg;
|
||||||
|
}
|
||||||
|
|
||||||
|
double vertex::Xc ( BOOL g )
|
||||||
|
{
|
||||||
|
if ( isIntersect() )
|
||||||
|
{
|
||||||
|
if ( m_neighbor->isEntry() )
|
||||||
|
return m_neighbor->m_nSeg->Xc();
|
||||||
|
else
|
||||||
|
return m_neighbor->m_pSeg->Xc();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (g)
|
||||||
|
return m_nSeg->Xc();
|
||||||
|
else
|
||||||
|
return m_pSeg->Xc();
|
||||||
|
}
|
||||||
|
|
||||||
|
double vertex::Yc ( BOOL g )
|
||||||
|
{
|
||||||
|
if ( isIntersect() )
|
||||||
|
{
|
||||||
|
if ( m_neighbor->isEntry() )
|
||||||
|
return m_neighbor->m_nSeg->Yc();
|
||||||
|
else
|
||||||
|
return m_neighbor->m_pSeg->Yc();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (g)
|
||||||
|
return m_nSeg->Yc();
|
||||||
|
else
|
||||||
|
return m_pSeg->Yc();
|
||||||
|
}
|
||||||
|
|
||||||
|
double vertex::d ( BOOL g )
|
||||||
|
{
|
||||||
|
if ( isIntersect() )
|
||||||
|
{
|
||||||
|
if ( m_neighbor->isEntry() )
|
||||||
|
return m_neighbor->m_nSeg->d();
|
||||||
|
else
|
||||||
|
return (-1*m_neighbor->m_pSeg->d());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (g)
|
||||||
|
return m_nSeg->d();
|
||||||
|
else
|
||||||
|
return (-1*m_pSeg->d());
|
||||||
|
}
|
||||||
|
|
||||||
|
void vertex::setChecked( BOOL check )
|
||||||
|
{
|
||||||
|
m_checked = check;
|
||||||
|
if( m_neighbor )
|
||||||
|
if( !m_neighbor->isChecked() )
|
||||||
|
m_neighbor->setChecked();
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
// file php_polygon_vertex.h
|
||||||
|
// See comments in file php_polygon_vertex.cpp
|
||||||
|
|
||||||
|
#ifndef PHP_POLYGON_VERTEX_H
|
||||||
|
#define PHP_POLYGON_VERTEX_H
|
||||||
|
|
||||||
|
#include "defs-macros.h"
|
||||||
|
|
||||||
|
class vertex;
|
||||||
|
class polygon;
|
||||||
|
|
||||||
|
class segment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
segment(double xc=0.0, double yc=0.0, int d=0 );
|
||||||
|
double Xc(){ return m_xc; };
|
||||||
|
double Yc(){ return m_yc; };
|
||||||
|
int d(){ return m_d; };
|
||||||
|
void setXc( double xc ){ m_xc = xc; };
|
||||||
|
void setYc( double yc ){ m_yc = yc; };
|
||||||
|
|
||||||
|
double m_xc, m_yc; // center of arc
|
||||||
|
int m_d; // direction (-1=CW, 0=LINE, 1=CCW)
|
||||||
|
};
|
||||||
|
|
||||||
|
class vertex
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
vertex( double x, double y,
|
||||||
|
double xc=0.0, double yc=0.0, double d=0.0,
|
||||||
|
vertex * nextV=NULL, vertex * prevV=NULL,
|
||||||
|
polygon * nextPoly=NULL,
|
||||||
|
BOOL intersect=FALSE,
|
||||||
|
vertex * neighbor=NULL,
|
||||||
|
double alpha=0.0,
|
||||||
|
BOOL entry=TRUE,
|
||||||
|
BOOL checked=FALSE );
|
||||||
|
~vertex();
|
||||||
|
int id() { return m_id; };
|
||||||
|
double X() { return m_x; };
|
||||||
|
void setX( double x ) { m_x = x; };
|
||||||
|
double Y() { return m_y; };
|
||||||
|
void setY( double y ) { m_y = y; };
|
||||||
|
double Xc ( BOOL g = TRUE );
|
||||||
|
double Yc ( BOOL g = TRUE );
|
||||||
|
double d ( BOOL g = TRUE );
|
||||||
|
void setXc ( double xc ) { m_nSeg->setXc(xc); };
|
||||||
|
void setYc ( double yc ) { m_nSeg->setYc(yc); };
|
||||||
|
void setNext ( vertex* nextV ){ m_nextV = nextV; };
|
||||||
|
vertex * Next (){ return m_nextV; };
|
||||||
|
void setPrev ( vertex *prevV ){ m_prevV = prevV; };
|
||||||
|
vertex * Prev (){ return m_prevV; };
|
||||||
|
void setNseg ( segment * nSeg ){ m_nSeg = nSeg; };
|
||||||
|
segment * Nseg (){ return m_nSeg; };
|
||||||
|
void setPseg ( segment * pSeg ){ m_pSeg = pSeg; };
|
||||||
|
segment * Pseg (){ return m_pSeg; };
|
||||||
|
void setNextPoly ( polygon * nextPoly ){ m_nextPoly = nextPoly; };
|
||||||
|
polygon * NextPoly (){ return m_nextPoly; };
|
||||||
|
void setNeighbor ( vertex * neighbor ){ m_neighbor = neighbor; };
|
||||||
|
vertex * Neighbor (){ return m_neighbor; };
|
||||||
|
double Alpha (){ return m_alpha; };
|
||||||
|
BOOL isIntersect (){ return m_intersect; };
|
||||||
|
void setChecked( BOOL check = TRUE);
|
||||||
|
BOOL isChecked () { return m_checked; };
|
||||||
|
void setEntry ( BOOL entry = TRUE){ m_entry = entry; }
|
||||||
|
BOOL isEntry (){ return m_entry; };
|
||||||
|
|
||||||
|
double m_x, m_y; // coords
|
||||||
|
vertex * m_nextV; // links to next and prev vertices
|
||||||
|
vertex * m_prevV; // links to next and prev vertices
|
||||||
|
segment * m_nSeg, * m_pSeg; // links to next and prev segments
|
||||||
|
polygon * m_nextPoly;
|
||||||
|
BOOL m_intersect;
|
||||||
|
vertex * m_neighbor;
|
||||||
|
double m_alpha;
|
||||||
|
BOOL m_entry;
|
||||||
|
BOOL m_checked;
|
||||||
|
int m_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ifndef PHP_POLYGON_VERTEX_H
|
Binary file not shown.
Loading…
Reference in New Issue