1 /*! \file kbool/include/kbool/line.h
2     \brief Mainy used for calculating crossings
3     \author Klaas Holwerda
4 
5     Copyright: 2001-2004 (C) Klaas Holwerda
6 
7     Licence: see kboollicense.txt
8 
9     RCS-ID: $Id: line.h,v 1.2 2005/06/12 00:03:11 kbluck Exp $
10 */
11 
12 #ifndef LINE_H
13 #define LINE_H
14 
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface
17 #endif
18 
19 #include "kbool/include/booleng.h"
20 #include "kbool/include/link.h"
21 
22 class A2DKBOOLDLLEXP Bool_Engine;
23 
24 // Status of a point to a line
25 enum PointStatus {LEFT_SIDE, RIGHT_SIDE, ON_AREA, IN_AREA};
26 
27 class A2DKBOOLDLLEXP Graph;
28 
29 class A2DKBOOLDLLEXP KBoolLine
30 {
31    protected:
32       Bool_Engine* m_GC;
33 	public:
34 
35 		// constructors and destructor
36 		KBoolLine(Bool_Engine* GC);
37 		KBoolLine(KBoolLink*,Bool_Engine* GC);
38 		~KBoolLine();
39 
40 		void			Set(KBoolLink *);
41 		KBoolLink*		GetLink();
42 
43       //! Get the beginnode from a line
44 		Node*		GetBeginNode();
45 
46       //! Get the endnode from a line
47 		Node*		GetEndNode();
48 
49       //! Check if two lines intersects
50 		int					CheckIntersect(KBoolLine*, double Marge);
51 
52       //! Intersects two lines
53 		int					Intersect(KBoolLine*, double Marge);
54 		int               Intersect_simple(KBoolLine * lijn);
55 		bool				   Intersect2(Node* crossing,KBoolLine * lijn);
56 
57       //!For an infinite line
58 		PointStatus			PointOnLine(Node* a_node, double& Distance, double Marge );
59 
60       //!For a non-infinite line
61 		PointStatus			PointInLine(Node* a_node, double& Distance, double Marge );
62 
63       //! Caclulate Y if X is known
64       B_INT					Calculate_Y(B_INT X);
65 		B_INT         		Calculate_Y_from_X(B_INT X);
66 		void              Virtual_Point( LPoint *a_point, double distance);
67 
68       //! assignment operator
69 		KBoolLine& 			operator=(const KBoolLine&);
70 
71 		Node* 				OffsetContour(KBoolLine* const nextline,Node* last_ins, double factor,Graph *shape);
72 		Node* 				OffsetContour_rounded(KBoolLine* const nextline,Node* _last_ins, double factor,Graph *shape);
73 		bool 				   OkeForContour(KBoolLine* const nextline,double factor,Node* LastLeft,Node* LastRight, LinkStatus& _outproduct);
74 		bool				   Create_Ring_Shape(KBoolLine* nextline,Node** _last_ins_left,Node** _last_ins_right,double factor,Graph *shape);
75 		void 					Create_Begin_Shape(KBoolLine* nextline,Node** _last_ins_left,Node** _last_ins_right,double factor,Graph *shape);
76 		void 					Create_End_Shape(KBoolLine* nextline,Node* _last_ins_left,Node* _last_ins_right,double factor,Graph *shape);
77 
78       //! Calculate the parameters if nessecary
79 		void  CalculateLineParameters();
80 
81       //! Adds a crossing between the intersecting lines
82 		void  AddLineCrossing(B_INT , B_INT , KBoolLine *);
83 
84 		void  AddCrossing(Node *a_node);
85 		Node* AddCrossing(B_INT X, B_INT Y);
86 		bool  ProcessCrossings(TDLI<KBoolLink>* _LI);
87 
88 // Linecrosslist
89 		void	SortLineCrossings();
90 		bool	CrossListEmpty();
91 		DL_List<void*>*		GetCrossList();
92 //		bool	HasInCrossList(Node*);
93 
94 	private:
95 
96       //! Function needed for Intersect
97 		int   ActionOnTable1(PointStatus,PointStatus);
98       //! Function needed for Intersect
99 		int   ActionOnTable2(PointStatus,PointStatus);
100 
101 		double 		m_AA;
102 		double		m_BB;
103 		double		m_CC;
104 		KBoolLink*	m_link;
105 		bool		m_valid_parameters;
106 
107       //! List with crossings through this link
108 		DL_List<void*>	 *linecrosslist;
109 };
110 
111 #endif
112