Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:50:39

0001 // Created on: 1995-03-06
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Poly_Triangle_HeaderFile
0018 #define _Poly_Triangle_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 #include <Standard_Integer.hxx>
0024 #include <Standard_OutOfRange.hxx>
0025 
0026 //! Describes a component triangle of a triangulation (Poly_Triangulation object).
0027 //! A Triangle is defined by a triplet of nodes within [1, Poly_Triangulation::NbNodes()] range.
0028 //! Each node is an index in the table of nodes specific to an existing
0029 //! triangulation of a shape, and represents a point on the surface.
0030 class Poly_Triangle
0031 {
0032 public:
0033   DEFINE_STANDARD_ALLOC
0034 
0035   //! Constructs a triangle and sets all indices to zero.
0036   Poly_Triangle() { myNodes[0] = myNodes[1] = myNodes[2] = 0; }
0037 
0038   //! Constructs a triangle and sets its three indices,
0039   //! where these node values are indices in the table of nodes specific to an existing
0040   //! triangulation of a shape.
0041   Poly_Triangle(const Standard_Integer theN1,
0042                 const Standard_Integer theN2,
0043                 const Standard_Integer theN3)
0044   {
0045     myNodes[0] = theN1;
0046     myNodes[1] = theN2;
0047     myNodes[2] = theN3;
0048   }
0049 
0050   //! Sets the value of the three nodes of this triangle.
0051   void Set(const Standard_Integer theN1, const Standard_Integer theN2, const Standard_Integer theN3)
0052   {
0053     myNodes[0] = theN1;
0054     myNodes[1] = theN2;
0055     myNodes[2] = theN3;
0056   }
0057 
0058   //! Sets the value of node with specified index of this triangle.
0059   //! Raises Standard_OutOfRange if index is not in 1,2,3
0060   void Set(const Standard_Integer theIndex, const Standard_Integer theNode)
0061   {
0062     Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3,
0063                                  "Poly_Triangle::Set(), invalid index");
0064     myNodes[theIndex - 1] = theNode;
0065   }
0066 
0067   //! Returns the node indices of this triangle.
0068   void Get(Standard_Integer& theN1, Standard_Integer& theN2, Standard_Integer& theN3) const
0069   {
0070     theN1 = myNodes[0];
0071     theN2 = myNodes[1];
0072     theN3 = myNodes[2];
0073   }
0074 
0075   //! Get the node of given Index.
0076   //! Raises OutOfRange from Standard if Index is not in 1,2,3
0077   Standard_Integer Value(const Standard_Integer theIndex) const
0078   {
0079     Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3,
0080                                  "Poly_Triangle::Value(), invalid index");
0081     return myNodes[theIndex - 1];
0082   }
0083 
0084   Standard_Integer operator()(const Standard_Integer Index) const { return Value(Index); }
0085 
0086   //! Get the node of given Index.
0087   //! Raises OutOfRange if Index is not in 1,2,3
0088   Standard_Integer& ChangeValue(const Standard_Integer theIndex)
0089   {
0090     Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > 3,
0091                                  "Poly_Triangle::ChangeValue(), invalid index");
0092     return myNodes[theIndex - 1];
0093   }
0094 
0095   Standard_Integer& operator()(const Standard_Integer Index) { return ChangeValue(Index); }
0096 
0097 protected:
0098   Standard_Integer myNodes[3];
0099 };
0100 
0101 #endif // _Poly_Triangle_HeaderFile