42cf5bc1 |
1 | // Created on: 1995-03-06 |
2 | // Created by: Laurent PAINNOT |
3 | // Copyright (c) 1995-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Poly_Triangle_HeaderFile |
18 | #define _Poly_Triangle_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
42cf5bc1 |
23 | #include <Standard_Integer.hxx> |
6b467e52 |
24 | #include <Standard_OutOfRange.hxx> |
42cf5bc1 |
25 | |
6b467e52 |
26 | //! Describes a component triangle of a triangulation (Poly_Triangulation object). |
27 | //! A Triangle is defined by a triplet of nodes. |
28 | //! Each node is an index in the table of nodes specific to an existing |
42cf5bc1 |
29 | //! triangulation of a shape, and represents a point on the surface. |
6b467e52 |
30 | class Poly_Triangle |
42cf5bc1 |
31 | { |
32 | public: |
33 | |
34 | DEFINE_STANDARD_ALLOC |
35 | |
42cf5bc1 |
36 | //! Constructs a triangle and sets all indices to zero. |
6b467e52 |
37 | Poly_Triangle() { myNodes[0] = myNodes[1] = myNodes[2] = 0; } |
38 | |
39 | //! Constructs a triangle and sets its three indices, |
40 | //! where these node values are indices in the table of nodes specific to an existing triangulation of a shape. |
41 | Poly_Triangle (const Standard_Integer theN1, const Standard_Integer theN2, const Standard_Integer theN3) |
42 | { |
43 | myNodes[0] = theN1; |
44 | myNodes[1] = theN2; |
45 | myNodes[2] = theN3; |
46 | } |
47 | |
48 | //! Sets the value of the three nodes of this triangle. |
49 | void Set (const Standard_Integer theN1, const Standard_Integer theN2, const Standard_Integer theN3) |
50 | { |
51 | myNodes[0] = theN1; |
52 | myNodes[1] = theN2; |
53 | myNodes[2] = theN3; |
54 | } |
42cf5bc1 |
55 | |
6b467e52 |
56 | //! Sets the value of node with specified index of this triangle. |
57 | //! Raises Standard_OutOfRange if index is not in 1,2,3 |
58 | void Set (const Standard_Integer theIndex, const Standard_Integer theNode) |
59 | { |
60 | Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::Set(), invalid index"); |
61 | myNodes[theIndex - 1] = theNode; |
62 | } |
63 | |
64 | //! Returns the node indices of this triangle. |
65 | void Get (Standard_Integer& theN1, Standard_Integer& theN2, Standard_Integer& theN3) const |
66 | { |
67 | theN1 = myNodes[0]; |
68 | theN2 = myNodes[1]; |
69 | theN3 = myNodes[2]; |
70 | } |
71 | |
42cf5bc1 |
72 | //! Get the node of given Index. |
73 | //! Raises OutOfRange from Standard if Index is not in 1,2,3 |
6b467e52 |
74 | Standard_Integer Value (const Standard_Integer theIndex) const |
75 | { |
76 | Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::Value(), invalid index"); |
77 | return myNodes[theIndex - 1]; |
78 | } |
42cf5bc1 |
79 | |
6b467e52 |
80 | Standard_Integer operator() (const Standard_Integer Index) const { return Value(Index); } |
42cf5bc1 |
81 | |
6b467e52 |
82 | //! Get the node of given Index. |
83 | //! Raises OutOfRange if Index is not in 1,2,3 |
84 | Standard_Integer& ChangeValue (const Standard_Integer theIndex) |
85 | { |
86 | Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::ChangeValue(), invalid index"); |
87 | return myNodes[theIndex - 1]; |
88 | } |
42cf5bc1 |
89 | |
6b467e52 |
90 | Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); } |
42cf5bc1 |
91 | |
92 | private: |
93 | |
42cf5bc1 |
94 | Standard_Integer myNodes[3]; |
95 | |
42cf5bc1 |
96 | }; |
97 | |
42cf5bc1 |
98 | #endif // _Poly_Triangle_HeaderFile |