1 // Created on: 1995-03-09
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_Polygon2D_HeaderFile
18 #define _Poly_Polygon2D_HeaderFile
20 #include <Standard_Type.hxx>
21 #include <TColgp_Array1OfPnt2d.hxx>
22 #include <Standard_Transient.hxx>
24 DEFINE_STANDARD_HANDLE(Poly_Polygon2D, Standard_Transient)
26 //! Provides a polygon in 2D space (for example, in the
27 //! parametric space of a surface). It is generally an
28 //! approximate representation of a curve.
29 //! A Polygon2D is defined by a table of nodes. Each node is
30 //! a 2D point. If the polygon is closed, the point of closure is
31 //! repeated at the end of the table of nodes.
32 class Poly_Polygon2D : public Standard_Transient
36 //! Constructs a 2D polygon with specified number of nodes.
37 Standard_EXPORT explicit Poly_Polygon2D (const Standard_Integer theNbNodes);
39 //! Constructs a 2D polygon defined by the table of points, <Nodes>.
40 Standard_EXPORT Poly_Polygon2D(const TColgp_Array1OfPnt2d& Nodes);
42 //! Returns the deflection of this polygon.
43 //! Deflection is used in cases where the polygon is an
44 //! approximate representation of a curve. Deflection
45 //! represents the maximum distance permitted between any
46 //! point on the curve and the corresponding point on the polygon.
47 //! By default the deflection value is equal to 0. An algorithm
48 //! using this 2D polygon with a deflection value equal to 0
49 //! considers that it is working with a true polygon and not with
50 //! an approximate representation of a curve. The Deflection
51 //! function is used to modify the deflection value of this polygon.
52 //! The deflection value can be used by any algorithm working with 2D polygons.
54 //! - An algorithm may use a unique deflection value for all
55 //! its polygons. In this case it is not necessary to use the
56 //! Deflection function.
57 //! - Or an algorithm may want to attach a different
58 //! deflection to each polygon. In this case, the Deflection
59 //! function is used to set a value on each polygon, and
60 //! later to fetch the value.
61 Standard_Real Deflection() const { return myDeflection; }
63 //! Sets the deflection of this polygon.
64 void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
66 //! Returns the number of nodes in this polygon.
67 //! Note: If the polygon is closed, the point of closure is
68 //! repeated at the end of its table of nodes. Thus, on a closed
69 //! triangle, the function NbNodes returns 4.
70 Standard_Integer NbNodes() const { return myNodes.Length(); }
72 //! Returns the table of nodes for this polygon.
73 const TColgp_Array1OfPnt2d& Nodes() const { return myNodes; }
75 //! Returns the table of nodes for this polygon.
76 TColgp_Array1OfPnt2d& ChangeNodes() { return myNodes; }
78 DEFINE_STANDARD_RTTIEXT(Poly_Polygon2D,Standard_Transient)
82 Standard_Real myDeflection;
83 TColgp_Array1OfPnt2d myNodes;
87 #endif // _Poly_Polygon2D_HeaderFile