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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Poly_Triangle_HeaderFile
18 #define _Poly_Triangle_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_OutOfRange.hxx>
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
29 //! triangulation of a shape, and represents a point on the surface.
36 //! Constructs a triangle and sets all indices to zero.
37 Poly_Triangle() { myNodes[0] = myNodes[1] = myNodes[2] = 0; }
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)
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)
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)
60 Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::Set(), invalid index");
61 myNodes[theIndex - 1] = theNode;
64 //! Returns the node indices of this triangle.
65 void Get (Standard_Integer& theN1, Standard_Integer& theN2, Standard_Integer& theN3) const
72 //! Get the node of given Index.
73 //! Raises OutOfRange from Standard if Index is not in 1,2,3
74 Standard_Integer Value (const Standard_Integer theIndex) const
76 Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::Value(), invalid index");
77 return myNodes[theIndex - 1];
80 Standard_Integer operator() (const Standard_Integer Index) const { return Value(Index); }
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)
86 Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3, "Poly_Triangle::ChangeValue(), invalid index");
87 return myNodes[theIndex - 1];
90 Standard_Integer& operator() (const Standard_Integer Index) { return ChangeValue(Index); }
94 Standard_Integer myNodes[3];
98 #endif // _Poly_Triangle_HeaderFile