comparison nonfree/gpc/gpc_tristrip.cc @ 0:6b33357c7561 octave-forge

Initial revision
author pkienzle
date Wed, 10 Oct 2001 19:54:49 +0000
parents
children eceaddf7df9c
comparison
equal deleted inserted replaced
-1:000000000000 0:6b33357c7561
1 /*
2
3 Copyright (C) 2001 Rafael Laboissiere
4
5 This file is part of octave-gpc.
6
7 octave-gpc is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 octave-gpc is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with octave-gpc; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 */
22
23 #include "octave-gpc.h"
24
25 // This are the user functions for reading (writing) polygons from (to)
26 // files.
27 DEFUN_DLD (gpc_tristrip, args, ,
28 " SYNOPSIS:\n"
29 " tristrip = gpc_tristrip (polygon)\n"
30 "\n"
31 " DESCRIPTION:\n"
32 " Obtain a TRISTRIP representation of POLYGON, a gpc_polygon object.\n"
33 " Tristrips are suitable for fill plottings and are coped with by\n"
34 " gpc_plot.\n"
35 "\n"
36 " SEE ALSO:\n"
37 " The General Polygon Clipper Library documentation.\n"
38 " gpc_create, gpc_clip, gpc_get, gpc_read, gpc_write, \n"
39 " gpc_is_polygon, gpc_plot.\n" )
40 {
41 octave_value retval;
42
43 // Sanity check of the arguments
44 int nargin = args.length ();
45
46 if ( nargin != 1 )
47 print_usage ("gpc_tristrip");
48 else
49 {
50 if ( args(0).type_id () != octave_gpc_polygon::static_type_id () )
51 {
52 error ("gpc_tristrip: argument must be of type gpc_polygon");
53 return retval;
54 }
55 else
56 {
57 gpc_tristrip t;
58 gpc_polygon p;
59
60 gpc_polygon_to_tristrip (get_gpc_pt (args (0)), &t);
61
62 p.contour = t.strip;
63 int n = (p.num_contours = t.num_strips);
64 p.hole = new int [n];
65 for (int i = 0; i < n; i++)
66 p.hole[i] = 0;
67
68 Octave_map m;
69 gpc_to_map (&p, &m);
70 retval = octave_value (new octave_gpc_polygon (m));
71
72 gpc_free_tristrip (&t);
73 delete [] p.hole;
74 }
75 }
76
77 return retval;
78 }
79
80 /*
81 ;;; Local Variables: ***
82 ;;; mode: C++ ***
83 ;;; End: ***
84 */