0031137: Modeling Data, BinTools_ShapeSet - avoid allocation of temporary arrays
[occt.git] / src / Poly / Poly_Polygon3D.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-03-07
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_Polygon3D_HeaderFile
18#define _Poly_Polygon3D_HeaderFile
19
42cf5bc1 20#include <Standard_Type.hxx>
25e59720 21#include <Standard_Transient.hxx>
6b467e52 22#include <TColgp_Array1OfPnt.hxx>
42cf5bc1 23#include <TColStd_Array1OfReal.hxx>
6b467e52 24#include <TColStd_HArray1OfReal.hxx>
42cf5bc1 25
25e59720 26DEFINE_STANDARD_HANDLE(Poly_Polygon3D, Standard_Transient)
42cf5bc1 27
28//! This class Provides a polygon in 3D space. It is generally an approximate representation of a curve.
29//! A Polygon3D is defined by a table of nodes. Each node is
30//! a 3D point. If the polygon is closed, the point of closure is
31//! repeated at the end of the table of nodes.
32//! If the polygon is an approximate representation of a curve,
33//! you can associate with each of its nodes the value of the
34//! parameter of the corresponding point on the curve.
25e59720 35class Poly_Polygon3D : public Standard_Transient
42cf5bc1 36{
42cf5bc1 37public:
38
6b467e52 39 //! Constructs a 3D polygon with specific number of nodes.
40 Standard_EXPORT Poly_Polygon3D (const Standard_Integer theNbNodes,
41 const Standard_Boolean theHasParams);
42
43 //! Constructs a 3D polygon defined by the table of points, Nodes.
42cf5bc1 44 Standard_EXPORT Poly_Polygon3D(const TColgp_Array1OfPnt& Nodes);
45
46 //! Constructs a 3D polygon defined by
47 //! the table of points, Nodes, and the parallel table of
48 //! parameters, Parameters, where each value of the table
49 //! Parameters is the parameter of the corresponding point
50 //! on the curve approximated by the constructed polygon.
51 //! Warning
52 //! Both the Nodes and Parameters tables must have the
53 //! same bounds. This property is not checked at construction time.
54 Standard_EXPORT Poly_Polygon3D(const TColgp_Array1OfPnt& Nodes, const TColStd_Array1OfReal& Parameters);
8156dddd 55
56 //! Creates a copy of current polygon
57 Standard_EXPORT virtual Handle(Poly_Polygon3D) Copy() const;
42cf5bc1 58
59 //! Returns the deflection of this polygon
6b467e52 60 Standard_Real Deflection() const { return myDeflection; }
61
62 //! Sets the deflection of this polygon. See more on deflection in Poly_Polygon2D
63 void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
42cf5bc1 64
65 //! Returns the number of nodes in this polygon.
66 //! Note: If the polygon is closed, the point of closure is
67 //! repeated at the end of its table of nodes. Thus, on a closed
68 //! triangle the function NbNodes returns 4.
6b467e52 69 Standard_Integer NbNodes() const { return myNodes.Length(); }
70
42cf5bc1 71 //! Returns the table of nodes for this polygon.
6b467e52 72 const TColgp_Array1OfPnt& Nodes() const { return myNodes; }
73
74 //! Returns the table of nodes for this polygon.
75 TColgp_Array1OfPnt& ChangeNodes() { return myNodes; }
76
42cf5bc1 77 //! Returns the table of the parameters associated with each node in this polygon.
78 //! HasParameters function checks if parameters are associated with the nodes of this polygon.
6b467e52 79 Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
42cf5bc1 80
81 //! Returns true if parameters are associated with the nodes
82 //! in this polygon.
6b467e52 83 const TColStd_Array1OfReal& Parameters() const { return myParameters->Array1(); }
84
42cf5bc1 85 //! Returns the table of the parameters associated with each node in this polygon.
86 //! ChangeParameters function returnes the array as shared. Therefore if the table is selected by
87 //! reference you can, by simply modifying it, directly modify
88 //! the data structure of this polygon.
6b467e52 89 TColStd_Array1OfReal& ChangeParameters() const { return myParameters->ChangeArray1(); }
42cf5bc1 90
25e59720 91 DEFINE_STANDARD_RTTIEXT(Poly_Polygon3D,Standard_Transient)
42cf5bc1 92
42cf5bc1 93private:
94
42cf5bc1 95 Standard_Real myDeflection;
96 TColgp_Array1OfPnt myNodes;
97 Handle(TColStd_HArray1OfReal) myParameters;
98
42cf5bc1 99};
100
42cf5bc1 101#endif // _Poly_Polygon3D_HeaderFile