0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[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 #include <Poly_Polygon3D.hxx>
18
19 IMPLEMENT_STANDARD_RTTIEXT(Poly_Polygon3D,Standard_Transient)
20
21 //=======================================================================
22 //function : Poly_Polygon3D
23 //purpose  :
24 //=======================================================================
25 Poly_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
36 //=======================================================================
37 //function : Poly_Polygon3D
38 //purpose  : 
39 //=======================================================================
40 Poly_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
54 Poly_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
69 //=======================================================================
70 //function : Copy
71 //purpose  : 
72 //=======================================================================
73
74 Handle(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 }
84
85 //=======================================================================
86 //function : DumpJson
87 //purpose  : 
88 //=======================================================================
89 void 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 }