0028470: Foundation Classes, NCollection_Array1 - add Resize() method for re-allocati...
[occt.git] / src / Poly / Poly_Polygon3D.cxx
1 // Created on: 1995-03-07
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
18 #include <gp_Pnt.hxx>
19 #include <Poly_Polygon3D.hxx>
20 #include <Standard_NullObject.hxx>
21 #include <Standard_Type.hxx>
22
23 IMPLEMENT_STANDARD_RTTIEXT(Poly_Polygon3D,MMgt_TShared)
24
25 //=======================================================================
26 //function : Poly_Polygon3D
27 //purpose  : 
28 //=======================================================================
29 Poly_Polygon3D::Poly_Polygon3D(const TColgp_Array1OfPnt& Nodes): 
30     myDeflection(0.),
31     myNodes(1, Nodes.Length())
32 {
33   Standard_Integer i, j= 1;
34   for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
35     myNodes(j++) = Nodes(i);
36 }
37
38 //=======================================================================
39 //function : Poly_Polygon3D
40 //purpose  : 
41 //=======================================================================
42
43 Poly_Polygon3D::Poly_Polygon3D(const TColgp_Array1OfPnt&   Nodes,
44                                const TColStd_Array1OfReal& P): 
45     myDeflection(0.),
46     myNodes(1, Nodes.Length())
47     
48 {
49   myParameters = new TColStd_HArray1OfReal(1, P.Length());
50   Standard_Integer i, j= 1;
51   for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
52     myNodes(j) = Nodes(i);
53     myParameters->SetValue(j, P(i));
54     j++;
55   }
56 }
57
58 //=======================================================================
59 //function : Copy
60 //purpose  : 
61 //=======================================================================
62
63 Handle(Poly_Polygon3D) Poly_Polygon3D::Copy() const
64 {
65   Handle(Poly_Polygon3D) aCopy;
66   if (myParameters.IsNull())
67     aCopy = new Poly_Polygon3D(myNodes);
68   else
69     aCopy = new Poly_Polygon3D(myNodes, myParameters->Array1());
70   aCopy->Deflection(myDeflection);
71   return aCopy;
72 }
73
74
75 //=======================================================================
76 //function : Deflection
77 //purpose  : 
78 //=======================================================================
79
80 Standard_Real Poly_Polygon3D::Deflection() const 
81 {
82   return myDeflection;
83 }
84
85 //=======================================================================
86 //function : Deflection
87 //purpose  : 
88 //=======================================================================
89
90 void Poly_Polygon3D::Deflection(const Standard_Real D)
91 {
92   myDeflection = D;
93 }
94
95 //=======================================================================
96 //function : Nodes
97 //purpose  : 
98 //=======================================================================
99
100 const TColgp_Array1OfPnt& Poly_Polygon3D::Nodes() const 
101 {
102   return myNodes;
103 }
104
105 //=======================================================================
106 //function : HasParameters
107 //purpose  : 
108 //=======================================================================
109
110 Standard_Boolean Poly_Polygon3D::HasParameters() const 
111 {
112   return !myParameters.IsNull();
113 }
114
115
116 //=======================================================================
117 //function : Parameters
118 //purpose  : 
119 //=======================================================================
120
121 const TColStd_Array1OfReal& Poly_Polygon3D::Parameters() const 
122 {
123   return myParameters->Array1();
124 }
125
126 //=======================================================================
127 //function : ChangeParameters
128 //purpose  : 
129 //=======================================================================
130
131 TColStd_Array1OfReal& Poly_Polygon3D::ChangeParameters() const 
132 {
133   return myParameters->ChangeArray1();
134 }
135
136