1 // Created on: 1996-02-21
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1996-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_PolygonOnTriangulation_HeaderFile
18 #define _Poly_PolygonOnTriangulation_HeaderFile
21 #include <Standard_Type.hxx>
22 #include <Standard_Transient.hxx>
23 #include <TColStd_Array1OfInteger.hxx>
24 #include <TColStd_Array1OfReal.hxx>
25 #include <TColStd_HArray1OfReal.hxx>
27 DEFINE_STANDARD_HANDLE(Poly_PolygonOnTriangulation, Standard_Transient)
29 //! This class provides a polygon in 3D space, based on the triangulation
30 //! of a surface. It may be the approximate representation of a
31 //! curve on the surface, or more generally the shape.
32 //! A PolygonOnTriangulation is defined by a table of
33 //! nodes. Each node is an index in the table of nodes specific
34 //! to a triangulation, and represents a point on the surface. If
35 //! the polygon is closed, the index of the point of closure is
36 //! repeated at the end of the table of nodes.
37 //! If the polygon is an approximate representation of a curve
38 //! on a surface, you can associate with each of its nodes the
39 //! value of the parameter of the corresponding point on the
40 //! curve.represents a 3d Polygon
41 class Poly_PolygonOnTriangulation : public Standard_Transient
45 //! Constructs a 3D polygon on the triangulation of a shape with specified size of nodes.
46 Standard_EXPORT Poly_PolygonOnTriangulation (const Standard_Integer theNbNodes,
47 const Standard_Boolean theHasParams);
49 //! Constructs a 3D polygon on the triangulation of a shape,
50 //! defined by the table of nodes, <Nodes>.
51 Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes);
53 //! Constructs a 3D polygon on the triangulation of a shape, defined by:
54 //! - the table of nodes, Nodes, and the table of parameters, <Parameters>.
56 //! - a node value is an index in the table of nodes specific
57 //! to an existing triangulation of a shape
58 //! - and a parameter value is the value of the parameter of
59 //! the corresponding point on the curve approximated by
60 //! the constructed polygon.
62 //! The tables Nodes and Parameters must be the same size.
63 //! This property is not checked at construction time.
64 Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes, const TColStd_Array1OfReal& Parameters);
66 //! Creates a copy of current polygon
67 Standard_EXPORT virtual Handle(Poly_PolygonOnTriangulation) Copy() const;
69 //! Returns the deflection of this polygon
70 Standard_Real Deflection() const { return myDeflection; }
72 //! Sets the deflection of this polygon.
73 //! See more on deflection in Poly_Polygones2D.
74 void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
76 //! Returns the number of nodes for this polygon.
77 //! Note: If the polygon is closed, the point of closure is
78 //! repeated at the end of its table of nodes. Thus, on a closed
79 //! triangle, the function NbNodes returns 4.
80 Standard_Integer NbNodes() const { return myNodes.Length(); }
82 //! Returns the table of nodes for this polygon. A node value
83 //! is an index in the table of nodes specific to an existing
84 //! triangulation of a shape.
85 const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
87 //! Returns the table of nodes for this polygon for modification.
88 TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
90 //! Returns true if parameters are associated with the nodes in this polygon.
91 Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
93 //! Returns the table of the parameters associated with each node in this polygon.
95 //! Use the function HasParameters to check if parameters
96 //! are associated with the nodes in this polygon.
97 const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
99 //! Returns the table of the parameters associated with each node in this polygon.
100 //! Warning! HasParameters() should be called beforehand to check if parameters array is allocated.
101 TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
103 //! Sets the table of the parameters associated with each node in this polygon.
104 //! Raises exception if array size doesn't much number of polygon nodes.
105 Standard_EXPORT void SetParameters (const Handle(TColStd_HArray1OfReal)& theParameters);
107 //! Dumps the content of me into the stream
108 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
110 DEFINE_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation,Standard_Transient)
114 Standard_Real myDeflection;
115 TColStd_Array1OfInteger myNodes;
116 Handle(TColStd_HArray1OfReal) myParameters;
120 #endif // _Poly_PolygonOnTriangulation_HeaderFile