0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / Poly / Poly_Polygon3D.cxx
CommitLineData
b311480e 1// Created on: 1995-03-07
2// Created by: Laurent PAINNOT
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17#include <Poly_Polygon3D.hxx>
7fd59977 18
25e59720 19IMPLEMENT_STANDARD_RTTIEXT(Poly_Polygon3D,Standard_Transient)
92efcf78 20
6b467e52 21//=======================================================================
22//function : Poly_Polygon3D
23//purpose :
24//=======================================================================
25Poly_Polygon3D::Poly_Polygon3D (const Standard_Integer theNbNodes,
26 const Standard_Boolean theHasParams)
27: myDeflection (0.0),
28 myNodes (1, theNbNodes)
29{
30 if (theHasParams)
31 {
32 myParameters = new TColStd_HArray1OfReal (1, theNbNodes);
33 }
34}
35
7fd59977 36//=======================================================================
37//function : Poly_Polygon3D
38//purpose :
39//=======================================================================
7fd59977 40Poly_Polygon3D::Poly_Polygon3D(const TColgp_Array1OfPnt& Nodes):
41 myDeflection(0.),
42 myNodes(1, Nodes.Length())
43{
44 Standard_Integer i, j= 1;
45 for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
46 myNodes(j++) = Nodes(i);
47}
48
49//=======================================================================
50//function : Poly_Polygon3D
51//purpose :
52//=======================================================================
53
54Poly_Polygon3D::Poly_Polygon3D(const TColgp_Array1OfPnt& Nodes,
55 const TColStd_Array1OfReal& P):
56 myDeflection(0.),
57 myNodes(1, Nodes.Length())
58
59{
60 myParameters = new TColStd_HArray1OfReal(1, P.Length());
61 Standard_Integer i, j= 1;
62 for (i = Nodes.Lower(); i <= Nodes.Upper(); i++) {
63 myNodes(j) = Nodes(i);
64 myParameters->SetValue(j, P(i));
65 j++;
66 }
67}
68
8156dddd 69//=======================================================================
70//function : Copy
71//purpose :
72//=======================================================================
73
74Handle(Poly_Polygon3D) Poly_Polygon3D::Copy() const
75{
76 Handle(Poly_Polygon3D) aCopy;
77 if (myParameters.IsNull())
78 aCopy = new Poly_Polygon3D(myNodes);
79 else
80 aCopy = new Poly_Polygon3D(myNodes, myParameters->Array1());
81 aCopy->Deflection(myDeflection);
82 return aCopy;
83}
bc73b006 84
85//=======================================================================
86//function : DumpJson
87//purpose :
88//=======================================================================
89void Poly_Polygon3D::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
90{
91 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
92
93 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDeflection)
94 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNodes.Size())
95 if (!myParameters.IsNull())
96 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myParameters->Size())
97}