This is RegionConverter.h in view mode; [Download] [Up]
/***********************************************************************\
region converter for Convert PICT which converts graphics from PICT to eps formats.
Copyright (C) 1993 David John Burrowes
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author, David John Burrowes, can be reached at:
davidjohn@kira.net.netcom.com
David John Burrowes
1926 Ivy #10
San Mateo, CA 94403-1367
\***********************************************************************/
#import "ResultObject.h"
#import "common.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions: region types:
// Description:
// The following data types are used by the region converter when converting
// a Mac region into a set of coordinates for a PS description of the same.
// NOTE:
// Please read RegionConverter.rtf, since that describes much more about how
// this object behaves!
// Bugs:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// A structure for describing an integral coordinate
//
typedef struct
{
Integer x;
Integer y;
}
Coordinate;
//
// This is used to represent a segment where both coordinates reside on one y coordinate.
// Thus, one only needs to store the x values. Note: left is always <= right
//
typedef struct
{
Integer left;
Integer right;
}
Segment, * SegmentAddr;
#define NullSegment ((SegmentAddr) NULL)
//
// Used to build a chain of segments.
//
typedef struct SegmentLink
{
Integer left;
Integer right;
struct SegmentLink* nextSegment;
}
SegmentLink, *SegmentLinkAddr;
#define EndOfChain ((SegmentLinkAddr) NULL)
//
// This describes a line segment as it is stored as part of a shape being accumulated.
// It stores the coordinates of the start and end of a line segment. If it has been
// connected to another line segment, the left and right pointers refer to other lines it
// has been attached to. (left < right. If line is vertical, left means top, right means bottom,
// since top < bottom). If a shape is incomplete, then it may not be connected to another
// line on one or both sides, but a segment on the `active' list may point to it.
//
typedef struct LineSegment *LineSegmentAddr;
typedef struct LineSegment
{
Coordinate left;
Coordinate right;
LineSegmentAddr leftNext;
LineSegmentAddr rightNext;
Boolean used; // used to mark that this linesegment has been touched.
} LineSegment;
#define NoLine ((LineSegmentAddr) NULL)
//
// If a segment of a line/space is being considered, then an ActiveSegment is stored on
// the Active list. Such a segment consists of a left and right x coordinate, and pointers
// to the line or lines that the area this segment will attach to.
//
typedef struct ActiveSegment * ActiveSegmentAddr;
typedef struct ActiveSegment
{
Integer left;
Integer right;
LineSegmentAddr leftLine;
LineSegmentAddr rightLine;
ActiveSegmentAddr next;
ActiveSegmentAddr previous;
}
ActiveSegment;
#define EndOfActiveList ((ActiveSegmentAddr) NULL)
//
// each SegmentGroup holds all the segments, from the region data, that occurr on
// one Y coordinate. So, this stores the y they occrr on, the chain of segments, and a
// pointer to the next segment.
//
typedef struct SegmentGroup *SegmentGroupAddr;
typedef struct SegmentGroup
{
Integer y;
SegmentLinkAddr segmentData;
SegmentGroupAddr next;
}
SegmentGroup;
#define EndOfGroups NULL
//
// This stucture is used to hold the shapes that are built from the REgion data
// It holds a pointer to the next shape, and a pointer to the first line segment of the shape.
typedef struct Shape *ShapeAddr;
typedef struct Shape
{
LineSegmentAddr theLine;
ShapeAddr nextShape;
} Shape;
#define NoShape ((ShapeAddr) NULL)
//
// Define kinds of segment intersection
//
typedef enum
{
None,
TouchOuterLeft, TouchOuterRight,
TouchInnerLeft, TouchInnerRight,
TouchInnerLeftExtendRight, TouchInnerRightExtendLeft,
LeftOverlap, RightOverlap,
Larger, Within,
Equal
}
OverlapKind;
//
// Used to store what direction a routine is `moving' in.
//
typedef enum
{
toLeft, toRight
}
DirectionType;
#define EndOfRegion 32767
#define EndOfRegionLine 32767
@interface regionConverter:ResultObject
{
ActiveSegmentAddr ActiveList;
ShapeAddr ShapeStorage;
SegmentGroupAddr RegionData;
PICTRect* boundsRect;
}
- ConvertRegionFrom: PictFile To: PsFile;
- ReadInRegionFrom: PictFile;
- ConvertRegionData;
-WriteTo: PsFile;
- WriteShapeFromLine: (LineSegmentAddr) startLine To: PsFile;
- (OverlapKind) CheckHowSegment: (SegmentAddr) segment
Intersects: (ActiveSegmentAddr) active;
-AddSegmentFrom: (Integer) left To: (Integer) right ToGroup: (SegmentGroupAddr) group;
-(SegmentAddr) GetNextSegmentFromGroup: (SegmentGroupAddr) group;
- AddShapeFrom: (Integer) left To: (Integer) right At: (Integer) y;
-(LineSegmentAddr) AddAntiShapeFrom: (Integer) left To: (Integer) right At: (Integer) y;
- (LineSegmentAddr) AddLineFrom: (Integer) left To: (Integer) right At: (Integer) y
WithLeft: (LineSegmentAddr) leftline AndRight: (LineSegmentAddr) rightline;
- AddActiveFrom: (Integer) left To: (Integer) right WithLeft:
(LineSegmentAddr) leftline AndRight: (LineSegmentAddr) rightline;
- RemoveActive: (ActiveSegmentAddr) theActive;
- (ActiveSegmentAddr) FindFirstActiveLeftIn: (Integer) left To: (Integer) right;
- CleanUp;
@end
#define ERR_BADDATA -1000
#define ERR_WEIRDDATA 1000
#define ERR_BADSIZE 500
#define ERR_NOSEGMENTS 100
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.