summaryrefslogtreecommitdiff
path: root/inc/Poly_CoherentTriangle.hxx
blob: ddf0ddc9d92af0b91af7627a093077825c4b19f0 (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// File:      Poly_CoherentTriangle.hxx
// Created:   24.11.07 14:36
// Author:    Alexander GRIGORIEV
// Copyright: Open Cascade 2007


#ifndef Poly_CoherentTriangle_HeaderFile
#define Poly_CoherentTriangle_HeaderFile

#include <Standard_TypeDef.hxx>

class Poly_CoherentTrianguation;
class Poly_CoherentLink;

/**
 * Data class used in Poly_CoherentTriangultion.
 * Implements a triangle with references to its neighbours.
 */

class Poly_CoherentTriangle 
{
 public:
  // ---------- PUBLIC METHODS ----------

  /**
   * Empty constructor.
   */
  Standard_EXPORT Poly_CoherentTriangle    ();

  /**
   * Constructor.
   */
  Standard_EXPORT Poly_CoherentTriangle    (const Standard_Integer iNode0,
                                            const Standard_Integer iNode1,
                                            const Standard_Integer iNode2);

  /**
   * Query the node index in the position given by the parameter 'ind'
   */
  inline Standard_Integer  Node            (const Standard_Integer ind) const
  { return myNodes[ind]; }

//   /**
//    * Set the Node at the given position 'ind'.
//    */ 
//   inline void              SetNode         (const Standard_Integer ind,
//                                             const Standard_Integer iNode)
//   { myNodes[ind] = iNode; }

  /**
   * Query if this is a valid triangle.
   */
  inline Standard_Boolean  IsEmpty         () const
  { return myNodes[0] < 0 || myNodes[1] < 0 || myNodes[2] < 0; }

  /**
   * Create connection with another triangle theTri.
   * This method creates both connections: in this triangle and in theTri. You
   * do not need to call the same method on triangle theTr.
   * @param iConn
   *   Can be 0, 1 or 2 - index of the node that is opposite to the connection
   *   (shared link).
   * @param theTr
   *   Triangle that is connected on the given link.
   * @return
   *   True if successful, False if the connection is rejected
   *   due to improper topology.
   */
  Standard_EXPORT Standard_Boolean
                           SetConnection   (const Standard_Integer  iConn,
                                            Poly_CoherentTriangle&  theTr);
  
  /**
   * Create connection with another triangle theTri.
   * This method creates both connections: in this triangle and in theTri.
   * This method is slower than the previous one, because it makes analysis
   * what sides of both triangles are connected.
   * @param theTri
   *   Triangle that is connected.
   * @return
   *   True if successful, False if the connection is rejected
   *   due to improper topology.
   */
  Standard_EXPORT Standard_Boolean
                           SetConnection   (Poly_CoherentTriangle& theTri);

  /**
   * Remove the connection with the given index.
   * @param iConn
   *   Can be 0, 1 or 2 - index of the node that is opposite to the connection
   *   (shared link).
   */
  Standard_EXPORT void     RemoveConnection(const Standard_Integer iConn);

  /**
   * Remove the connection with the given Triangle.
   * @return
   *  True if successfuol or False if the connection has not been found.
   */
  Standard_EXPORT Standard_Boolean
                           RemoveConnection(Poly_CoherentTriangle& theTri);

  /**
   * Query the number of connected triangles.
   */
  inline Standard_Integer  NConnections    () const
  { return myNConnections; }

  /**
   * Query the connected node on the given side.
   * Returns -1 if there is no connection on the specified side.
   */
  inline Standard_Integer  GetConnectedNode(const Standard_Integer iConn) const
  { return myNodesOnConnected[iConn]; }

  /**
   * Query the connected triangle on the given side.
   * Returns NULL if there is no connection on the specified side.
   */
  inline const Poly_CoherentTriangle *
                           GetConnectedTri (const Standard_Integer iConn) const
  { return mypConnected[iConn]; }

  /**
   * Query the Link associate with the given side of the Triangle.
   * May return NULL if there are no links in the triangulation.
   */
  inline const Poly_CoherentLink *
                           GetLink         (const Standard_Integer iLink) const
  { return mypLink[iLink]; }

  /**
   * Retuns the index of the connection with the given triangle, or -1 if not
   * found.
   */
  Standard_EXPORT Standard_Integer
                           FindConnection  (const Poly_CoherentTriangle&) const;

 protected:
  // ---------- PROTECTED METHODS ----------



 private:
  // ---------- PRIVATE FIELDS ----------

  Standard_Integer              myNConnections;
  Standard_Integer              myNodes[3];
  Standard_Integer              myNodesOnConnected[3];
  const Poly_CoherentTriangle * mypConnected[3];
  const Poly_CoherentLink     * mypLink[3];

  friend class Poly_CoherentTriangulation;
};


#endif