0031137: Modeling Data, BinTools_ShapeSet - avoid allocation of temporary arrays
[occt.git] / src / Poly / Poly_PolygonOnTriangulation.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-02-21
2// Created by: Laurent PAINNOT
3// Copyright (c) 1996-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_PolygonOnTriangulation_HeaderFile
18#define _Poly_PolygonOnTriangulation_HeaderFile
19
42cf5bc1 20
6b467e52 21#include <Standard_Type.hxx>
25e59720 22#include <Standard_Transient.hxx>
6b467e52 23#include <TColStd_Array1OfInteger.hxx>
42cf5bc1 24#include <TColStd_Array1OfReal.hxx>
6b467e52 25#include <TColStd_HArray1OfReal.hxx>
42cf5bc1 26
25e59720 27DEFINE_STANDARD_HANDLE(Poly_PolygonOnTriangulation, Standard_Transient)
42cf5bc1 28
29//! This class provides a polygon in 3D space, based on the triangulation
30//! of a surface. It may be the approximate representation of a
31//! curve on the surface, or more generally the shape.
32//! A PolygonOnTriangulation is defined by a table of
33//! nodes. Each node is an index in the table of nodes specific
34//! to a triangulation, and represents a point on the surface. If
35//! the polygon is closed, the index of the point of closure is
36//! repeated at the end of the table of nodes.
37//! If the polygon is an approximate representation of a curve
38//! on a surface, you can associate with each of its nodes the
39//! value of the parameter of the corresponding point on the
40//! curve.represents a 3d Polygon
25e59720 41class Poly_PolygonOnTriangulation : public Standard_Transient
42cf5bc1 42{
42cf5bc1 43public:
44
6b467e52 45 //! Constructs a 3D polygon on the triangulation of a shape with specified size of nodes.
46 Standard_EXPORT Poly_PolygonOnTriangulation (const Standard_Integer theNbNodes,
47 const Standard_Boolean theHasParams);
48
42cf5bc1 49 //! Constructs a 3D polygon on the triangulation of a shape,
50 //! defined by the table of nodes, <Nodes>.
51 Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes);
42cf5bc1 52
53 //! Constructs a 3D polygon on the triangulation of a shape, defined by:
54 //! - the table of nodes, Nodes, and the table of parameters, <Parameters>.
55 //! where:
56 //! - a node value is an index in the table of nodes specific
57 //! to an existing triangulation of a shape
58 //! - and a parameter value is the value of the parameter of
59 //! the corresponding point on the curve approximated by
60 //! the constructed polygon.
61 //! Warning
62 //! The tables Nodes and Parameters must be the same size.
63 //! This property is not checked at construction time.
64 Standard_EXPORT Poly_PolygonOnTriangulation(const TColStd_Array1OfInteger& Nodes, const TColStd_Array1OfReal& Parameters);
8156dddd 65
66 //! Creates a copy of current polygon
67 Standard_EXPORT virtual Handle(Poly_PolygonOnTriangulation) Copy() const;
68
42cf5bc1 69 //! Returns the deflection of this polygon
6b467e52 70 Standard_Real Deflection() const { return myDeflection; }
71
72 //! Sets the deflection of this polygon.
42cf5bc1 73 //! See more on deflection in Poly_Polygones2D.
6b467e52 74 void Deflection (const Standard_Real theDefl) { myDeflection = theDefl; }
42cf5bc1 75
76 //! Returns the number of nodes for this polygon.
77 //! Note: If the polygon is closed, the point of closure is
78 //! repeated at the end of its table of nodes. Thus, on a closed
79 //! triangle, the function NbNodes returns 4.
6b467e52 80 Standard_Integer NbNodes() const { return myNodes.Length(); }
81
42cf5bc1 82 //! Returns the table of nodes for this polygon. A node value
83 //! is an index in the table of nodes specific to an existing
84 //! triangulation of a shape.
6b467e52 85 const TColStd_Array1OfInteger& Nodes() const { return myNodes; }
86
87 //! Returns the table of nodes for this polygon for modification.
88 TColStd_Array1OfInteger& ChangeNodes() { return myNodes; }
42cf5bc1 89
90 //! Returns true if parameters are associated with the nodes in this polygon.
6b467e52 91 Standard_Boolean HasParameters() const { return !myParameters.IsNull(); }
92
42cf5bc1 93 //! Returns the table of the parameters associated with each node in this polygon.
94 //! Warning
95 //! Use the function HasParameters to check if parameters
96 //! are associated with the nodes in this polygon.
6b467e52 97 const Handle(TColStd_HArray1OfReal)& Parameters() const { return myParameters; }
42cf5bc1 98
6b467e52 99 //! Returns the table of the parameters associated with each node in this polygon.
100 //! Warning! HasParameters() should be called beforehand to check if parameters array is allocated.
101 TColStd_Array1OfReal& ChangeParameters() { return myParameters->ChangeArray1(); }
42cf5bc1 102
6b467e52 103 //! Sets the table of the parameters associated with each node in this polygon.
104 //! Raises exception if array size doesn't much number of polygon nodes.
105 Standard_EXPORT void SetParameters (const Handle(TColStd_HArray1OfReal)& theParameters);
42cf5bc1 106
25e59720 107 DEFINE_STANDARD_RTTIEXT(Poly_PolygonOnTriangulation,Standard_Transient)
42cf5bc1 108
42cf5bc1 109private:
110
42cf5bc1 111 Standard_Real myDeflection;
112 TColStd_Array1OfInteger myNodes;
113 Handle(TColStd_HArray1OfReal) myParameters;
114
42cf5bc1 115};
116
42cf5bc1 117#endif // _Poly_PolygonOnTriangulation_HeaderFile