b311480e |
1 | // Created on: 2007-12-25 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #ifndef Poly_CoherentLink_HeaderFile |
17 | #define Poly_CoherentLink_HeaderFile |
18 | |
19 | #include <Standard_TypeDef.hxx> |
20 | |
21 | class Poly_CoherentTriangle; |
22 | class Poly_CoherentTriangulation; |
23 | |
24 | /** |
25 | * Link between two mesh nodes that is created by existing triangle(s). |
26 | * Keeps reference to the opposite node of each incident triangle. |
27 | * The referred node with index "0" is always on the left side of the link, |
28 | * the one with the index "1" is always on the right side. |
29 | * It is possible to find both incident triangles using the method |
30 | * Poly_CoherentTriangulation::FindTriangle(). |
31 | * <p> |
32 | * Any Link can store an arbitrary pointer that is called Attribute. |
33 | */ |
34 | |
35 | class Poly_CoherentLink |
36 | { |
37 | public: |
38 | // ---------- PUBLIC METHODS ---------- |
39 | |
40 | /** |
41 | * Empty constructor. |
42 | */ |
43 | Standard_EXPORT Poly_CoherentLink (); |
44 | |
45 | /** |
46 | * Constructor. Creates a Link that has no reference to 'opposite nodes'. |
47 | * This constructor is useful to create temporary object that is not |
48 | * inserted into any existing triangulation. |
49 | */ |
50 | inline Poly_CoherentLink (const Standard_Integer iNode0, |
51 | const Standard_Integer iNode1) |
52 | : myAttribute (0L) |
53 | { |
54 | myNode[0] = iNode0; myNode[1] = iNode1; |
55 | myOppositeNode[0] = -1; myOppositeNode[1] = -1; |
56 | } |
57 | |
58 | /** |
59 | * Constructor, takes a triangle and a side. A link is created always such |
60 | * that myNode[0] < myNode[1]. Unlike the previous constructor, this one |
61 | * assigns the 'opposite node' fields. This constructor is used when a |
62 | * link is inserted into a Poly_CoherentTriangulation structure. |
63 | * @param theTri |
64 | * Triangle containing the link that is created |
65 | * @param iSide |
66 | * Can be 0, 1 or 2. Index of the node |
67 | */ |
68 | Standard_EXPORT Poly_CoherentLink (const Poly_CoherentTriangle& theTri, |
69 | Standard_Integer iSide); |
70 | |
71 | /** |
72 | * Return the node index in the current triangulation. |
73 | * @param ind |
74 | * 0 or 1 making distinction of the two nodes that constitute the Link. |
75 | * Node(0) always returns a smaller number than Node(1). |
76 | */ |
77 | inline Standard_Integer Node (const Standard_Integer ind) const |
78 | { return myNode[ind & 0x1]; } |
79 | |
80 | /** |
81 | * Return the opposite node (belonging to the left or right incident triangle) |
82 | * index in the current triangulation. |
83 | * @param ind |
84 | * 0 or 1 making distinction of the two involved triangles: 0 on the left, |
85 | * 1 on the right side of the Link. |
86 | */ |
87 | inline Standard_Integer OppositeNode (const Standard_Integer ind) const |
88 | { return myOppositeNode[ind & 0x1]; } |
89 | |
90 | /** |
91 | * Query the attribute of the Link. |
92 | */ |
93 | inline Standard_Address GetAttribute () const |
94 | { return myAttribute; } |
95 | |
96 | /** |
97 | * Set the attribute of the Link. |
98 | */ |
99 | inline void SetAttribute (const Standard_Address theAtt) |
100 | { myAttribute = theAtt; } |
101 | |
102 | /** |
103 | * Query the status of the link - if it is an invalid one. |
104 | * An invalid link has Node members equal to -1. |
105 | */ |
106 | inline Standard_Boolean IsEmpty () const |
107 | { return myNode[0] < 0 || myNode[1] < 0; } |
108 | |
109 | /** |
110 | * Invalidate this Link. |
111 | */ |
112 | inline void Nullify () |
113 | { |
114 | myNode[0] = -1; myNode[1] = -1; |
115 | myOppositeNode[0] = -1; myOppositeNode[1] = -1; |
116 | } |
117 | |
118 | |
119 | protected: |
120 | // ---------- PROTECTED METHODS ---------- |
121 | |
122 | |
123 | |
124 | private: |
125 | // ---------- PRIVATE FIELDS ---------- |
126 | Standard_Integer myNode[2]; |
127 | Standard_Integer myOppositeNode[2]; |
128 | Standard_Address myAttribute; |
129 | |
130 | friend class Poly_CoherentTriangulation; |
131 | }; |
132 | |
133 | #endif |