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
|
// nclip: a polygon clip library
// Copyright (C) 1993 University of Twente
// 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.
#include <cstring>
#include <iostream>
#include "poly.h"
#include "poly_io.h"
#include "nclip.h"
using namespace ::std;
void
clear(PolyPList &l)
{
PolyPListIter i(l);
while(i())
delete i.val();
}
int
main(int, char *[])
{
Poly *a = read_poly(cin), *b = read_poly(cin);
PolyPList a_min_b, b_min_a, a_and_b;
// printf("Area a %g b %g\n", a->area(), b->area());
clip_poly( *a, *b, a_min_b, b_min_a, a_and_b );
cout << "a_min_b:\n" << a_min_b;
cout << "b_min_a:\n" << b_min_a;
cout << "a_and_b:\n" << a_and_b;
delete a;
delete b;
clear(a_min_b);
clear(b_min_a);
clear(a_and_b);
return 0;
}
|