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
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_Polygon2D_HeaderFile
18 #define _Poly_Polygon2D_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22 
23 #include <Standard_Real.hxx>
24 #include <TColgp_Array1OfPnt2d.hxx>
25 #include <Standard_Transient.hxx>
26 #include <Standard_Integer.hxx>
27 class Standard_NullObject;
28 
29 
30 class Poly_Polygon2D;
31 DEFINE_STANDARD_HANDLE(Poly_Polygon2D, Standard_Transient)
32 
33 //! Provides a polygon in 2D space (for example, in the
34 //! parametric space of a surface). It is generally an
35 //! approximate representation of a curve.
36 //! A Polygon2D is defined by a table of nodes. Each node is
37 //! a 2D point. If the polygon is closed, the point of closure is
38 //! repeated at the end of the table of nodes.
39 class Poly_Polygon2D : public Standard_Transient
40 {
41 
42 public:
43 
44 
45   //! Constructs a 2D polygon defined by the table of points, <Nodes>.
46   Standard_EXPORT Poly_Polygon2D(const TColgp_Array1OfPnt2d& Nodes);
47 
48   //! Returns the deflection of this polygon.
49   //! Deflection is used in cases where the polygon is an
50   //! approximate representation of a curve. Deflection
51   //! represents the maximum distance permitted between any
52   //! point on the curve and the corresponding point on the polygon.
53   //! By default the deflection value is equal to 0. An algorithm
54   //! using this 2D polygon with a deflection value equal to 0
55   //! considers that it is working with a true polygon and not with
56   //! an approximate representation of a curve. The Deflection
57   //! function is used to modify the deflection value of this polygon.
58   //! The deflection value can be used by any algorithm working  with 2D polygons.
59   //! For example:
60   //! -   An algorithm may use a unique deflection value for all
61   //! its polygons. In this case it is not necessary to use the
62   //! Deflection function.
63   //! -   Or an algorithm may want to attach a different
64   //! deflection to each polygon. In this case, the Deflection
65   //! function is used to set a value on each polygon, and
66   //! later to fetch the value.
67   Standard_EXPORT Standard_Real Deflection() const;
68 
69   //! Sets the deflection of this polygon to D
70   Standard_EXPORT void Deflection (const Standard_Real D);
71 
72   //! Returns the number of nodes in this polygon.
73   //! Note: If the polygon is closed, the point of closure is
74   //! repeated at the end of its table of nodes. Thus, on a closed
75   //! triangle, the function NbNodes returns 4.
76     Standard_Integer NbNodes() const;
77 
78   //! Returns the table of nodes for this polygon.
79   Standard_EXPORT const TColgp_Array1OfPnt2d& Nodes() const;
80 
81 
82 
83 
84   DEFINE_STANDARD_RTTIEXT(Poly_Polygon2D,Standard_Transient)
85 
86 protected:
87 
88 
89 
90 
91 private:
92 
93 
94   Standard_Real myDeflection;
95   TColgp_Array1OfPnt2d myNodes;
96 
97 
98 };
99 
100 
101 #include <Poly_Polygon2D.lxx>
102 
103 
104 
105 
106 
107 #endif // _Poly_Polygon2D_HeaderFile
108