Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:38

0001 // Created on: 1995-03-09
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Poly_Polygon2D_HeaderFile
0018 #define _Poly_Polygon2D_HeaderFile
0019 
0020 #include <TColgp_Array1OfPnt2d.hxx>
0021 #include <Standard_Transient.hxx>
0022 
0023 DEFINE_STANDARD_HANDLE(Poly_Polygon2D, Standard_Transient)
0024 
0025 //! Provides a polygon in 2D space (for example, in the
0026 //! parametric space of a surface). It is generally an
0027 //! approximate representation of a curve.
0028 //! A Polygon2D is defined by a table of nodes. Each node is
0029 //! a 2D point. If the polygon is closed, the point of closure is
0030 //! repeated at the end of the table of nodes.
0031 class Poly_Polygon2D : public Standard_Transient
0032 {
0033 public:
0034 
0035   //! Constructs a 2D polygon with specified number of nodes.
0036   Standard_EXPORT explicit Poly_Polygon2D (const Standard_Integer theNbNodes);
0037 
0038   //! Constructs a 2D polygon defined by the table of points, <Nodes>.
0039   Standard_EXPORT Poly_Polygon2D(const TColgp_Array1OfPnt2d& Nodes);
0040 
0041   //! Returns the deflection of this polygon.
0042   //! Deflection is used in cases where the polygon is an
0043   //! approximate representation of a curve. Deflection
0044   //! represents the maximum distance permitted between any
0045   //! point on the curve and the corresponding point on the polygon.
0046   //! By default the deflection value is equal to 0. An algorithm
0047   //! using this 2D polygon with a deflection value equal to 0
0048   //! considers that it is working with a true polygon and not with
0049   //! an approximate representation of a curve. The Deflection
0050   //! function is used to modify the deflection value of this polygon.
0051   //! The deflection value can be used by any algorithm working  with 2D polygons.
0052   //! For example:
0053   //! -   An algorithm may use a unique deflection value for all
0054   //! its polygons. In this case it is not necessary to use the
0055   //! Deflection function.
0056   //! -   Or an algorithm may want to attach a different
0057   //! deflection to each polygon. In this case, the Deflection
0058   //! function is used to set a value on each polygon, and
0059   //! later to fetch the value.
0060   Standard_Real Deflection() const { return myDeflection; }
0061 
0062   //! Sets the deflection of this polygon.
0063   void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
0064 
0065   //! Returns the number of nodes in this polygon.
0066   //! Note: If the polygon is closed, the point of closure is
0067   //! repeated at the end of its table of nodes. Thus, on a closed
0068   //! triangle, the function NbNodes returns 4.
0069   Standard_Integer NbNodes() const { return myNodes.Length(); }
0070 
0071   //! Returns the table of nodes for this polygon.
0072   const TColgp_Array1OfPnt2d& Nodes() const { return myNodes; }
0073 
0074   //! Returns the table of nodes for this polygon.
0075   TColgp_Array1OfPnt2d& ChangeNodes() { return myNodes; }
0076   
0077   //! Dumps the content of me into the stream
0078   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0079 
0080   DEFINE_STANDARD_RTTIEXT(Poly_Polygon2D,Standard_Transient)
0081 
0082 private:
0083 
0084   Standard_Real myDeflection;
0085   TColgp_Array1OfPnt2d myNodes;
0086 
0087 };
0088 
0089 #endif // _Poly_Polygon2D_HeaderFile