home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / printing / ghostscrip / source / _gs / h / gzpath < prev    next >
Encoding:
Text File  |  1991-10-27  |  3.6 KB  |  103 lines

  1. /* Copyright (C) 1989, 1990 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gzpath.h */
  21. /* Private representation of paths for GhostScript library */
  22. /* Requires gxfixed.h */
  23. #include "gxpath.h"
  24.  
  25. /* Definition of a path segment: a segment start, a line, */
  26. /* or a Bezier curve. */
  27. typedef enum {
  28.     s_start,
  29.     s_line,
  30.     s_line_close,
  31.     s_curve
  32. } segment_type;
  33. #define segment_type_sizes\
  34.   sizeof(subpath), sizeof(line_segment), sizeof(line_close_segment),\
  35.   sizeof(curve_segment)
  36. #define segment_common\
  37.     struct segment_s *prev;\
  38.     struct segment_s *next;\
  39.     segment_type type;\
  40.     gs_fixed_point pt;        /* initial point for starts, */\
  41.                     /* final point for others */
  42. /* A generic segment */
  43. typedef struct segment_s {
  44.     segment_common
  45. } segment;
  46. /* A start segment.  This serves as the head of a subpath. */
  47. typedef struct {
  48.     segment_common
  49.     segment *last;            /* last segment of subpath, */
  50.                     /* points back to here if empty */
  51.     int line_count;            /* # of lines */
  52.     int curve_count;        /* # of curves */
  53.     char closed;            /* true if subpath is closed */
  54. } subpath;
  55. /* Line segments have no special data. */
  56. typedef struct {
  57.     segment_common
  58. } line_segment;
  59. /* Line_close segments are for the lines appended by closepath. */
  60. /* They point back to the subpath being closed. */
  61. typedef struct {
  62.     segment_common
  63.     subpath *sub;
  64. } line_close_segment;
  65. /* Curve segments store the control points, not the coefficients. */
  66. /* We may want to change this someday. */
  67. typedef struct {
  68.     segment_common
  69.     gs_fixed_point p1, p2;
  70. } curve_segment;
  71.  
  72. /* A path is stored as a linked list of segments, */
  73. /* but each path occupies a single contiguous block of memory. */
  74. struct gx_path_s {
  75.     gs_memory_procs memory_procs;
  76.     gs_fixed_rect bbox;        /* bounding box (in device space) */
  77.     segment *box_last;        /* box incorporates segments */
  78.                     /* up to & including this one */
  79.     gs_fixed_rect cbox;        /* an inner clipping rectangle */
  80.                     /* for a quick check */
  81.     subpath *first_subpath;
  82.     subpath *current_subpath;
  83.     int subpath_count;
  84.     int segment_count;
  85.     int curve_count;
  86.     gs_fixed_point position;    /* current position */
  87.     char position_valid;
  88.     char subpath_open;
  89.     char shares_segments;        /* if true, this path shares its */
  90.                     /* segment storage with the one in */
  91.                     /* the previous saved graphics state */
  92. };
  93.  
  94. /* Macros equivalent to a few heavily used procedures. */
  95. /* Be aware that these macros may evaluate arguments more than once. */
  96. #define gx_path_current_point_inline(ppath,ppt)\
  97.  ( !ppath->position_valid ? gs_note_error(gs_error_nocurrentpoint) :\
  98.    ((ppt)->x = ppath->position.x, (ppt)->y = ppath->position.y, 0) )
  99. #define gx_path_add_relative_point_inline(ppath,dx,dy)\
  100.  ( !ppath->position_valid ? gs_note_error(gs_error_nocurrentpoint) :\
  101.    (ppath->position.x += dx, ppath->position.y += dy,\
  102.     ppath->subpath_open = 0) )
  103.