1 /*! \file kbool/include/kbool/link.h 2 \brief Part of a graph, connection between nodes (Header) 3 \author Klaas Holwerda or Julian Smart 4 5 Copyright: 2001-2004 (C) Klaas Holwerda 6 7 Licence: see kboollicense.txt 8 9 RCS-ID: $Id: link.h,v 1.1 2005/05/24 19:13:37 titato Exp $ 10 */ 11 12 #ifndef LINK_H 13 #define LINK_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/_lnk_itr.h" 21 22 enum LinkStatus {IS_LEFT,IS_ON,IS_RIGHT}; 23 24 class LPoint; 25 class Node; 26 class Record; 27 28 //! segment within a graph 29 /* 30 A Graph contains a list of KBoolLink, the KBoolLink or connected by Node's. 31 Several KBoolLink can be connected to one Node. 32 A KBoolLink has a direction defined by its begin and end node. 33 Node do have a list of connected KBoolLink's. 34 So one can walk trough a graph in two ways: 35 1- via its KBoolLink list 36 2- via the node connected to the KBoolLink's 37 */ 38 class A2DKBOOLDLLEXP KBoolLink 39 { 40 protected: 41 Bool_Engine* _GC; 42 public: 43 44 //! contructors 45 KBoolLink(Bool_Engine* GC); 46 47 //! contructors 48 KBoolLink(int graphnr, int user_data, Node* begin, Node* end, Bool_Engine* GC); 49 50 //! contructors 51 KBoolLink(Node *begin, Node *end, Bool_Engine* GC); 52 53 //! destructors 54 ~KBoolLink(); 55 56 57 //! Merges the other node with argument 58 void MergeNodes(Node* const); 59 60 //! outproduct of two links 61 LinkStatus OutProduct(KBoolLink* const two,double accur); 62 63 //! link three compared to this and two 64 LinkStatus PointOnCorner(KBoolLink* const, KBoolLink* const); 65 66 //! Removes argument from the link 67 void Remove(Node*); 68 69 //! replaces olddone in the link by newnode 70 void Replace(Node* oldnode, Node* newnode); 71 72 //!top hole marking 73 void SetTopHole(bool value); 74 75 //!top hole marking 76 bool IsTopHole(); 77 78 //! Marking functions 79 void UnMark(); 80 //! Marking functions 81 void Mark(); 82 //! Marking functions 83 void SetMark(bool); 84 //! Marking functions 85 bool IsMarked(); 86 87 //! holelink Marking functions SetHoleLink(bool val)88 void SetHoleLink(bool val){ m_holelink = val;}; 89 90 //! holelink Marking functions GetHoleLink()91 bool GetHoleLink(){ return m_holelink;}; 92 93 //! Bin functions 94 void SetNotBeenHere(); 95 //! Bin functions 96 void SetBeenHere(); 97 //! Have you been here ?? 98 bool BeenHere(); 99 100 //! Removes all the references to this 101 void UnLink(); 102 103 //! functions for maximum performance 104 Node* GetBeginNode(); 105 106 //! Datamember access functions 107 Node* GetEndNode(); 108 Node* GetLowNode(); 109 Node* GetHighNode(); 110 111 //! Returns a next link beginning with argument 112 KBoolLink* Forth(Node*); 113 114 int GetGraphNum(); 115 bool GetInc(); 116 bool GetLeftA(); 117 bool GetLeftB(); 118 bool GetRightA(); 119 bool GetRightB(); 120 void GetLRO(LPoint*, int&, int&, double); 121 122 //! Return a node not equal to arg. 123 Node* GetOther(const Node* const); 124 //! Is this link unused ? 125 bool IsUnused(); 126 127 //! Used for given operation ? 128 bool IsMarked(BOOL_OP operation); 129 130 //! return true if Left side is marked true for operation 131 bool IsMarkedLeft(BOOL_OP operation); 132 133 //! return true if Right side is marked true for operation 134 bool IsMarkedRight(BOOL_OP operation); 135 136 //! is this a hole link for given operation 137 bool IsHole(BOOL_OP operation); 138 139 //! set the hole mark 140 void SetHole(bool); 141 142 //! is the hole mark set? 143 bool GetHole(); 144 145 //! Are the nodes on about the same coordinates ? 146 bool IsZero(B_INT marge ); 147 bool ShorterThan(B_INT marge ); 148 149 //! Resets the link 150 void Reset(Node* begin, Node* end, int graphnr = 0); 151 void Set(Node* begin, Node* end); 152 void SetBeginNode(Node*); 153 void SetEndNode(Node*); 154 void SetGraphNum(int); 155 void SetInc(bool); 156 void SetLeftA(bool); 157 void SetLeftB(bool); 158 void SetRightA(bool); 159 void SetRightB(bool); 160 void SetGroup(GroupType); 161 GroupType Group(); 162 163 //! Flag calculation (internal only) 164 void SetLineTypes(); 165 void Reset(); 166 void Reset_flags(); 167 168 //!put in this direction 169 void Redirect(Node* a_node); 170 171 void TakeOverOperationFlags( KBoolLink* link ); 172 SetRecordNode(DL_Node<Record * > * recordNode)173 void SetRecordNode( DL_Node<Record*>* recordNode ) { m_record = recordNode; } 174 GetRecordNode()175 DL_Node<Record*>* GetRecordNode() { return m_record; } 176 177 // user data 178 int m_user_data; 179 180 protected: 181 182 //! The mainitems of a link 183 Node *m_beginnode, *m_endnode; 184 //! Marker for walking over the graph 185 bool m_bin : 1; 186 //! Is this a part of hole ? 187 bool m_hole : 1; 188 //! link that is toplink of hole? 189 bool m_hole_top : 1; 190 //! going in one more time in this graph if true else going out one time 191 bool m_Inc : 1; 192 //! Is left in polygongroup A 193 bool m_LeftA : 1; 194 //! Is right in polygon group A 195 bool m_RightA : 1; 196 //! Is left in polygon group B 197 bool m_LeftB : 1; 198 //! Is right in polygongroup B 199 bool m_RightB : 1; 200 //! General purose marker, internally unused 201 bool m_mark : 1; 202 //! link for linking holes 203 bool m_holelink : 1; 204 205 //! Marker for Merge Left 206 bool m_merge_L : 1; 207 //! Marker for substract a-b Left 208 bool m_a_substract_b_L: 1; 209 //! Marker for substract b-a Left 210 bool m_b_substract_a_L: 1; 211 //! Marker for intersect Left 212 bool m_intersect_L: 1; 213 //! Marker for X-OR Left 214 bool m_exor_L: 1; 215 216 //! Marker for Merge Right 217 bool m_merge_R : 1; 218 //! Marker for substract a-b Right 219 bool m_a_substract_b_R: 1; 220 //! Marker for substract b-a Right 221 bool m_b_substract_a_R: 1; 222 //! Marker for intersect Right 223 bool m_intersect_R: 1; 224 //! Marker for X-OR Right 225 bool m_exor_R: 1; 226 227 //! belongs to group A or B 228 GroupType m_group : 1; 229 230 //! belongs to this polygon part in the graph. 231 int m_graphnum; 232 233 DL_Node<Record*>* m_record; 234 }; 235 236 #endif 237 238