File: geo2DInteger.h

package info (click to toggle)
ted 2.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 13,944 kB
  • ctags: 20,273
  • sloc: ansic: 167,980; makefile: 12,518; sh: 263
file content (81 lines) | stat: -rw-r--r-- 2,207 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/************************************************************************/
/*									*/
/*  Various definitions relating to document geometry.			*/
/*									*/
/************************************************************************/

#   ifndef		GEO_2D_INTEGER_H
#   define		GEO_2D_INTEGER_H

typedef struct DocumentRectangle
    {
    int		drX0;
    int		drY0;
    int		drX1;
    int		drY1;
    } DocumentRectangle;

#   define RECTDEB(dr) appDebug( "%s(%3d): %s= [%d..%d x %d..%d]\n",	\
			    __FILE__, __LINE__, #dr,			\
			    (dr)->drX0, (dr)->drX1,			\
			    (dr)->drY0, (dr)->drY1 )

typedef struct Point2DI
    {
    int		p2diX;
    int		p2diY;
    } Point2DI;

# define geo2DIPointInBox( p, b ) \
		    ( (p)->p2diX >= (b)->drX0 && \
		      (p)->p2diX <= (b)->drX1 && \
		      (p)->p2diY >= (b)->drY0 && \
		      (p)->p2diY <= (b)->drY1 )

/************************************************************************/
/*									*/
/*  Routine declarations.						*/
/*									*/
/************************************************************************/

extern void docInitRectangle(	DocumentRectangle *		dr );

extern void docUnionRectangle(	DocumentRectangle *		dr,
				const DocumentRectangle *	dr1,
				const DocumentRectangle *	dr2	);

extern void docNormalizeRectangle(
				DocumentRectangle *		drTo,
				const DocumentRectangle *	drFrom );

extern int docIntersectRectangle(	DocumentRectangle *		dr,
					const DocumentRectangle *	dr1,
					const DocumentRectangle *	dr2 );

extern int geo2DIIntersectSegments(	Point2DI *		p1,
					Point2DI *		p2,
					double *		pXab1,
					double *		pXab2,
					double *		pXcd1,
					double *		pXcd2,
					const Point2DI *	ab,
					const Point2DI *	cd );

extern double geo2DIDistanceToLine(	const Point2DI *	ab,
					const Point2DI *	c );

extern double geo2DIProjectionOnLine(	const Point2DI *	ab,
					const Point2DI *	c );

extern int geo2DIPointInPolygon(	const Point2DI *	p,
					const Point2DI *	points,
					int			pointCount );

extern int geo2DIClipSegmentToRectangle(
				Point2DI			vpChanged[2],
				double *			pXp0,
				double *			pXp1,
				const Point2DI			vp[2],
				const DocumentRectangle *	dr );

#   endif	/*	GEO_2D_INTEGER_H */