From 58242933eb92eca020221556f884f075f5e96551 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 13 Mar 1999 23:51:32 +0000 Subject: [PATCH] Renamed main.cxx to testclipper.cxx Converted clipper routines to a class FGClipper. --- Clipper/Makefile.am | 2 +- Clipper/clipper.cxx | 25 ++++++++++++-------- Clipper/clipper.hxx | 33 ++++++++++++++++++++++----- Clipper/{main.cxx => testclipper.cxx} | 15 ++++++++---- 4 files changed, 53 insertions(+), 22 deletions(-) rename Clipper/{main.cxx => testclipper.cxx} (91%) diff --git a/Clipper/Makefile.am b/Clipper/Makefile.am index 07ddbce96..87a59e28b 100644 --- a/Clipper/Makefile.am +++ b/Clipper/Makefile.am @@ -4,7 +4,7 @@ libClipper_a_SOURCES = clipper.cxx clipper.hxx bin_PROGRAMS = testclipper -testclipper_SOURCES = main.cxx +testclipper_SOURCES = testclipper.cxx testclipper_LDADD = $(top_builddir)/Tools/Construct/Clipper/libClipper.a \ $(top_builddir)/Tools/Lib/Polygon/libPolygon.a \ diff --git a/Clipper/clipper.cxx b/Clipper/clipper.cxx index e4aaa76f0..3ea78c200 100644 --- a/Clipper/clipper.cxx +++ b/Clipper/clipper.cxx @@ -25,25 +25,26 @@ -#include "clipper.hxx" - #include #include #include #include +#include "clipper.hxx" -#define EXTRA_SAFETY_CLIP -#define FG_MAX_VERTICES 100000 +// Constructor +FGClipper::FGClipper( void ) { +} -static gpc_vertex_list v_list; -// static gpc_polygon poly; -static FGPolyList polys_in, polys_out; + +// Destructor +FGClipper::~FGClipper( void ) { +} // Initialize Clipper (allocate and/or connect structures) -bool fgClipperInit() { +bool FGClipper::init() { v_list.num_vertices = 0; v_list.vertex = new gpc_vertex[FG_MAX_VERTICES];; @@ -52,7 +53,7 @@ bool fgClipperInit() { // Load a polygon definition file -bool fgClipperLoadPolygons(const string& path) { +bool FGClipper::load_polys(const string& path) { string poly_name; AreaType poly_type; int contours, count, i, j; @@ -141,7 +142,7 @@ bool fgClipperLoadPolygons(const string& path) { // Do actually clipping work -bool fgClipperMaster(const point2d& min, const point2d& max) { +bool FGClipper::clip_all(const point2d& min, const point2d& max) { gpc_polygon accum, result_diff, result_union, tmp; polylist_iterator current, last; @@ -221,6 +222,10 @@ bool fgClipperMaster(const point2d& min, const point2d& max) { // $Log$ +// Revision 1.2 1999/03/13 23:51:33 curt +// Renamed main.cxx to testclipper.cxx +// Converted clipper routines to a class FGClipper. +// // Revision 1.1 1999/03/01 15:39:39 curt // Initial revision. // diff --git a/Clipper/clipper.hxx b/Clipper/clipper.hxx index 79b7e16da..b9f0d1bed 100644 --- a/Clipper/clipper.hxx +++ b/Clipper/clipper.hxx @@ -52,6 +52,8 @@ typedef vector < gpc_polygon * > polylist; typedef polylist::iterator polylist_iterator; #define FG_MAX_AREAS 20 +#define EXTRA_SAFETY_CLIP +#define FG_MAX_VERTICES 100000 class point2d { public: @@ -66,22 +68,41 @@ public: }; -// Initialize Clipper (allocate and/or connect structures) -bool fgClipperInit(); +class FGClipper { +private: -// Load a polygon definition file -bool fgClipperLoadPolygons(const string& path); + gpc_vertex_list v_list; + // static gpc_polygon poly; + FGPolyList polys_in, polys_out; +public: + + // Constructor + FGClipper( void ); -// Do actually clipping work -bool fgClipperMaster(const point2d& min, const point2d& max); + // Destructor + ~FGClipper( void ); + + // Initialize Clipper (allocate and/or connect structures) + bool init(); + + // Load a polygon definition file + bool load_polys(const string& path); + + // Do actually clipping work + bool clip_all(const point2d& min, const point2d& max); +}; #endif // _CLIPPER_HXX // $Log$ +// Revision 1.2 1999/03/13 23:51:34 curt +// Renamed main.cxx to testclipper.cxx +// Converted clipper routines to a class FGClipper. +// // Revision 1.1 1999/03/01 15:39:39 curt // Initial revision. // diff --git a/Clipper/main.cxx b/Clipper/testclipper.cxx similarity index 91% rename from Clipper/main.cxx rename to Clipper/testclipper.cxx index 4aa613a4e..2a0477b48 100644 --- a/Clipper/main.cxx +++ b/Clipper/testclipper.cxx @@ -23,11 +23,11 @@ -#include "clipper.hxx" - #include #include +#include "clipper.hxx" + int main( int argc, char **argv ) { point2d global_min, global_max; @@ -37,7 +37,8 @@ int main( int argc, char **argv ) { global_min.x = global_min.y = 200; global_max.y = global_max.x = -200; - fgClipperInit(); + FGClipper clipper; + clipper.init(); if ( argc < 2 ) { FG_LOG( FG_CLIPPER, FG_ALERT, "Usage: " << argv[0] @@ -97,11 +98,11 @@ int main( int argc, char **argv ) { if ( max.y > global_max.y ) global_max.y = max.y; // finally, load the polygon(s) from this file - fgClipperLoadPolygons( full_path ); + clipper.load_polys( full_path ); } // do the clipping - fgClipperMaster(global_min, global_max); + clipper.clip_all(global_min, global_max); FG_LOG( FG_CLIPPER, FG_INFO, "finished main" ); @@ -109,6 +110,10 @@ int main( int argc, char **argv ) { } // $Log$ +// Revision 1.1 1999/03/13 23:51:36 curt +// Renamed main.cxx to testclipper.cxx +// Converted clipper routines to a class FGClipper. +// // Revision 1.1 1999/03/01 15:39:39 curt // Initial revision. // -- 2.39.2