b311480e |
1 | // Created on: 2007-11-24 |
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_CoherentTriangle_HeaderFile |
17 | #define Poly_CoherentTriangle_HeaderFile |
18 | |
19 | #include <Standard_TypeDef.hxx> |
20 | |
21 | class Poly_CoherentTrianguation; |
22 | class Poly_CoherentLink; |
23 | |
24 | /** |
25 | * Data class used in Poly_CoherentTriangultion. |
26 | * Implements a triangle with references to its neighbours. |
27 | */ |
28 | |
29 | class Poly_CoherentTriangle |
30 | { |
31 | public: |
32 | // ---------- PUBLIC METHODS ---------- |
33 | |
34 | /** |
35 | * Empty constructor. |
36 | */ |
37 | Standard_EXPORT Poly_CoherentTriangle (); |
38 | |
39 | /** |
40 | * Constructor. |
41 | */ |
42 | Standard_EXPORT Poly_CoherentTriangle (const Standard_Integer iNode0, |
43 | const Standard_Integer iNode1, |
44 | const Standard_Integer iNode2); |
45 | |
46 | /** |
47 | * Query the node index in the position given by the parameter 'ind' |
48 | */ |
49 | inline Standard_Integer Node (const Standard_Integer ind) const |
50 | { return myNodes[ind]; } |
51 | |
52 | // /** |
53 | // * Set the Node at the given position 'ind'. |
54 | // */ |
55 | // inline void SetNode (const Standard_Integer ind, |
56 | // const Standard_Integer iNode) |
57 | // { myNodes[ind] = iNode; } |
58 | |
59 | /** |
60 | * Query if this is a valid triangle. |
61 | */ |
62 | inline Standard_Boolean IsEmpty () const |
63 | { return myNodes[0] < 0 || myNodes[1] < 0 || myNodes[2] < 0; } |
64 | |
65 | /** |
66 | * Create connection with another triangle theTri. |
67 | * This method creates both connections: in this triangle and in theTri. You |
68 | * do not need to call the same method on triangle theTr. |
69 | * @param iConn |
70 | * Can be 0, 1 or 2 - index of the node that is opposite to the connection |
71 | * (shared link). |
72 | * @param theTr |
73 | * Triangle that is connected on the given link. |
74 | * @return |
75 | * True if successful, False if the connection is rejected |
76 | * due to improper topology. |
77 | */ |
78 | Standard_EXPORT Standard_Boolean |
79 | SetConnection (const Standard_Integer iConn, |
80 | Poly_CoherentTriangle& theTr); |
81 | |
82 | /** |
83 | * Create connection with another triangle theTri. |
84 | * This method creates both connections: in this triangle and in theTri. |
85 | * This method is slower than the previous one, because it makes analysis |
86 | * what sides of both triangles are connected. |
87 | * @param theTri |
88 | * Triangle that is connected. |
89 | * @return |
90 | * True if successful, False if the connection is rejected |
91 | * due to improper topology. |
92 | */ |
93 | Standard_EXPORT Standard_Boolean |
94 | SetConnection (Poly_CoherentTriangle& theTri); |
95 | |
96 | /** |
97 | * Remove the connection with the given index. |
98 | * @param iConn |
99 | * Can be 0, 1 or 2 - index of the node that is opposite to the connection |
100 | * (shared link). |
101 | */ |
102 | Standard_EXPORT void RemoveConnection(const Standard_Integer iConn); |
103 | |
104 | /** |
105 | * Remove the connection with the given Triangle. |
106 | * @return |
107 | * True if successfuol or False if the connection has not been found. |
108 | */ |
109 | Standard_EXPORT Standard_Boolean |
110 | RemoveConnection(Poly_CoherentTriangle& theTri); |
111 | |
112 | /** |
113 | * Query the number of connected triangles. |
114 | */ |
115 | inline Standard_Integer NConnections () const |
116 | { return myNConnections; } |
117 | |
118 | /** |
119 | * Query the connected node on the given side. |
120 | * Returns -1 if there is no connection on the specified side. |
121 | */ |
122 | inline Standard_Integer GetConnectedNode(const Standard_Integer iConn) const |
123 | { return myNodesOnConnected[iConn]; } |
124 | |
125 | /** |
126 | * Query the connected triangle on the given side. |
127 | * Returns NULL if there is no connection on the specified side. |
128 | */ |
129 | inline const Poly_CoherentTriangle * |
130 | GetConnectedTri (const Standard_Integer iConn) const |
131 | { return mypConnected[iConn]; } |
132 | |
133 | /** |
134 | * Query the Link associate with the given side of the Triangle. |
135 | * May return NULL if there are no links in the triangulation. |
136 | */ |
137 | inline const Poly_CoherentLink * |
138 | GetLink (const Standard_Integer iLink) const |
139 | { return mypLink[iLink]; } |
140 | |
141 | /** |
142 | * Retuns the index of the connection with the given triangle, or -1 if not |
143 | * found. |
144 | */ |
145 | Standard_EXPORT Standard_Integer |
146 | FindConnection (const Poly_CoherentTriangle&) const; |
147 | |
148 | protected: |
149 | // ---------- PROTECTED METHODS ---------- |
150 | |
151 | |
152 | |
153 | private: |
154 | // ---------- PRIVATE FIELDS ---------- |
155 | |
156 | Standard_Integer myNConnections; |
157 | Standard_Integer myNodes[3]; |
158 | Standard_Integer myNodesOnConnected[3]; |
159 | const Poly_CoherentTriangle * mypConnected[3]; |
160 | const Poly_CoherentLink * mypLink[3]; |
161 | |
162 | friend class Poly_CoherentTriangulation; |
163 | }; |
164 | |
165 | |
166 | #endif |