1
0
Fork 0

Renamed main.cxx to testclipper.cxx

Converted clipper routines to a class FGClipper.
This commit is contained in:
curt 1999-03-13 23:51:32 +00:00
parent cac521c151
commit 58242933eb
4 changed files with 53 additions and 22 deletions

View file

@ -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 \

View file

@ -25,25 +25,26 @@
#include "clipper.hxx"
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
#include <Misc/fgstream.hxx>
#include <Polygon/names.hxx>
#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.
//

View file

@ -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:
// Do actually clipping work
bool fgClipperMaster(const point2d& min, const point2d& max);
// Constructor
FGClipper( void );
// 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.
//

View file

@ -23,11 +23,11 @@
#include "clipper.hxx"
#include <Debug/logstream.hxx>
#include <Bucket/newbucket.hxx>
#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.
//