1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
22 #include <math_Memory.hxx>
23 #include <Standard_OutOfRange.hxx>
24 #include <Standard_Failure.hxx>
25 #include <Standard_Integer.hxx>
27 void math_DoubleTab::Allocate()
29 Standard_Integer RowNumber = UppR - LowR + 1;
30 Standard_Integer ColNumber = UppC - LowC + 1;
32 Item** TheAddr = (Item**) Standard::Allocate(RowNumber * sizeof(Item*));
35 Address = (Item*) Standard::Allocate(RowNumber * ColNumber * sizeof(Item));
37 Address = (Item*) Addr;
40 for (Standard_Integer Index = 0; Index < RowNumber; Index++) {
41 TheAddr[Index] = Address;
46 Addr = (Standard_Address) TheAddr;
49 math_DoubleTab::math_DoubleTab(const Standard_Integer LowerRow,
50 const Standard_Integer UpperRow,
51 const Standard_Integer LowerCol,
52 const Standard_Integer UpperCol) :
53 isAllocated(Standard_True),
63 math_DoubleTab::math_DoubleTab(const Item& Tab,
64 const Standard_Integer LowerRow,
65 const Standard_Integer UpperRow,
66 const Standard_Integer LowerCol,
67 const Standard_Integer UpperCol) :
69 isAllocated(Standard_False),
78 void math_DoubleTab::Init(const Item& InitValue)
80 for (Standard_Integer i = LowR; i <= UppR; i++) {
81 for (Standard_Integer j = LowC; j <= UppC; j++) {
82 ((Item**) Addr)[i][j] = InitValue;
89 math_DoubleTab::math_DoubleTab(const math_DoubleTab& Other) :
90 isAllocated(Standard_True),
98 Standard_Address target = (Standard_Address) &Value(LowR,LowC);
99 Standard_Address source = (Standard_Address) &Other.Value(LowR,LowC);
101 memmove(target,source,
102 (int)((UppR - LowR + 1) * (UppC - LowC + 1) * sizeof(Item)));
107 void math_DoubleTab::Free()
111 Standard_Address it = (Standard_Address)&Value(LowR,LowC);
115 Standard_Address it = (Standard_Address)(((Item**)Addr) + LowR);
122 void math_DoubleTab::SetLowerRow(const Standard_Integer LowerRow)
124 Item** TheAddr = (Item**)Addr;
125 Addr = (Standard_Address) (TheAddr + LowR - LowerRow);
126 UppR = UppR - LowR + LowerRow;
131 void math_DoubleTab::SetLowerCol(const Standard_Integer LowerCol)
133 Item** TheAddr = (Item**) Addr;
134 for (Standard_Integer Index = LowR; Index <= UppR; Index++) {
135 TheAddr[Index] = TheAddr[Index] + LowC - LowerCol;
138 UppC = UppC - LowC + LowerCol;