Commit 4ce4631d authored by raburton's avatar raburton

set eol-style and mime-type properties for new polygon related files

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