42cf5bc1 |
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 | |
42cf5bc1 |
20 | #include <Standard_Type.hxx> |
42cf5bc1 |
21 | #include <TColgp_Array1OfPnt2d.hxx> |
25e59720 |
22 | #include <Standard_Transient.hxx> |
42cf5bc1 |
23 | |
25e59720 |
24 | DEFINE_STANDARD_HANDLE(Poly_Polygon2D, Standard_Transient) |
42cf5bc1 |
25 | |
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. |
25e59720 |
32 | class Poly_Polygon2D : public Standard_Transient |
42cf5bc1 |
33 | { |
42cf5bc1 |
34 | public: |
35 | |
6b467e52 |
36 | //! Constructs a 2D polygon with specified number of nodes. |
37 | Standard_EXPORT explicit Poly_Polygon2D (const Standard_Integer theNbNodes); |
38 | |
42cf5bc1 |
39 | //! Constructs a 2D polygon defined by the table of points, <Nodes>. |
40 | Standard_EXPORT Poly_Polygon2D(const TColgp_Array1OfPnt2d& Nodes); |
6b467e52 |
41 | |
42cf5bc1 |
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. |
53 | //! For example: |
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. |
6b467e52 |
61 | Standard_Real Deflection() const { return myDeflection; } |
62 | |
63 | //! Sets the deflection of this polygon. |
64 | void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; } |
65 | |
42cf5bc1 |
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. |
6b467e52 |
70 | Standard_Integer NbNodes() const { return myNodes.Length(); } |
42cf5bc1 |
71 | |
6b467e52 |
72 | //! Returns the table of nodes for this polygon. |
73 | const TColgp_Array1OfPnt2d& Nodes() const { return myNodes; } |
42cf5bc1 |
74 | |
6b467e52 |
75 | //! Returns the table of nodes for this polygon. |
76 | TColgp_Array1OfPnt2d& ChangeNodes() { return myNodes; } |
bc73b006 |
77 | |
78 | //! Dumps the content of me into the stream |
79 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
42cf5bc1 |
80 | |
25e59720 |
81 | DEFINE_STANDARD_RTTIEXT(Poly_Polygon2D,Standard_Transient) |
42cf5bc1 |
82 | |
42cf5bc1 |
83 | private: |
84 | |
42cf5bc1 |
85 | Standard_Real myDeflection; |
86 | TColgp_Array1OfPnt2d myNodes; |
87 | |
42cf5bc1 |
88 | }; |
89 | |
42cf5bc1 |
90 | #endif // _Poly_Polygon2D_HeaderFile |