1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // --------------------------------------------------------------------
16 // HArray2 Implementation :
17 // Last Revision : Feb,10 1992 J.P Tirault
18 // Implementation of ShallowCopy, ShallowDump
20 // --------------------------------------------------------------------
23 // --------------------------------------------------------------------
25 // --------------------------------------------------------------------
26 #include <Standard_OutOfRange.hxx>
27 #include <Standard_RangeError.hxx>
28 #include <Standard_NotImplemented.hxx>
30 // --------------------------------------------------------------------
32 // --------------------------------------------------------------------
33 PCollection_HArray2::PCollection_HArray2
34 (const Standard_Integer R1,
35 const Standard_Integer R2,
36 const Standard_Integer C1,
37 const Standard_Integer C2) : Data( (C2-C1+1)*(R2-R1+1) )
39 Standard_RangeError_Raise_if((C2-C1+1 <= 0 || R2-R1+1 <= 0 ),
40 "Attempt to create a Double Array with negative size");
49 // ----------------------------------------------------------------------
51 // ----------------------------------------------------------------------
53 Standard_Address PCollection_HArray2::Datas() const
55 return ((Standard_Address)Data.Lock());
59 // --------------------------------------------------------------------
61 // --------------------------------------------------------------------
62 PCollection_HArray2::PCollection_HArray2
63 (const Standard_Integer R1,
64 const Standard_Integer R2,
65 const Standard_Integer C1,
66 const Standard_Integer C2,
67 const Item& V) : Data ( (C2-C1+1)*(R2-R1+1) )
69 Standard_RangeError_Raise_if((C2-C1+1 <= 0 || R2-R1+1 <= 0 ),
70 "Attempt to create a Double Array with negative size");
76 Standard_Integer Size = Data.Length();
78 for (Standard_Integer I = 0; I < Size ; I++) Data.SetValue(I,V);
82 // --------------------------------------------------------------------
83 // Destructor : Not Implemented
84 // --------------------------------------------------------------------
87 void PCollection_HArray2::~PCollection_HArray2 ()
93 // --------------------------------------------------------------------
95 // --------------------------------------------------------------------
96 Handle(Standard_Persistent) PCollection_HArray2::ShallowCopy() const
98 PCollection_HArray2* TheCopy = new PCollection_HArray2(*this);
99 // PCollection_FieldOfHArray2 DataCopy (Data);
100 // TheCopy->Data = DataCopy;
104 // --------------------------------------------------------------------
106 // --------------------------------------------------------------------
107 void PCollection_HArray2::ShallowDump(Standard_OStream& S) const
109 ::ShallowDump(Data,S);
118 // --------------------------------------------------------------------
120 // --------------------------------------------------------------------
121 void PCollection_HArray2::SetValue ( const Standard_Integer Row,
122 const Standard_Integer Col,
125 Standard_OutOfRange_Raise_if((Row <myLowerRow || Row > myUpperRow ||
126 Col <myLowerCol || Col > myUpperCol),
127 "Index out of range in HArray2::SetValue");
129 Data.SetValue((Row-myLowerRow)*(myUpperCol-myLowerCol+1)+
130 (Col-myLowerCol), Value) ;
134 // --------------------------------------------------------------------
136 // --------------------------------------------------------------------
137 Item PCollection_HArray2::Value (const Standard_Integer Row,
138 const Standard_Integer Col) const
140 Standard_OutOfRange_Raise_if((Row <myLowerRow || Row > myUpperRow ||
141 Col <myLowerCol || Col > myUpperCol),
142 "Index out of range in HArray2::SetValue");
144 return Data((Row-myLowerRow) * (myUpperCol-myLowerCol+1) +
149 // ------------------------------------------------------------------
151 // ------------------------------------------------------------------
152 PCollection_FieldOfHArray2 PCollection_HArray2::Field () const