0025923: Remove small wires on face read from STEP
[occt.git] / src / PCollection / PCollection_HArray2.gxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // --------------------------------------------------------------------
16 // HArray2 Implementation :
17 // Last Revision : Feb,10 1992 J.P Tirault
18 //                 Implementation of ShallowCopy, ShallowDump
19 //                 methods.
20 // --------------------------------------------------------------------
21
22
23 // --------------------------------------------------------------------
24 //                            Exceptions raised
25 // --------------------------------------------------------------------
26 #include <Standard_OutOfRange.hxx>
27 #include <Standard_RangeError.hxx>
28 #include <Standard_NotImplemented.hxx>
29
30 // --------------------------------------------------------------------
31 //                            Constructor 
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) )
38 {
39   Standard_RangeError_Raise_if((C2-C1+1 <= 0  || R2-R1+1 <= 0 ),
40                   "Attempt to create a Double Array with negative size");
41
42   myLowerRow = R1;
43   myLowerCol = C1;
44   myUpperRow = R2;
45   myUpperCol = C2;
46
47 }
48
49 // ----------------------------------------------------------------------
50 //                 datas
51 // ----------------------------------------------------------------------
52
53 Standard_Address PCollection_HArray2::Datas() const
54 {
55   return ((Standard_Address)Data.Lock());
56 }
57
58
59 // --------------------------------------------------------------------
60 //                            Constructor 
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) )
68 {
69   Standard_RangeError_Raise_if((C2-C1+1 <= 0  || R2-R1+1 <= 0 ),
70                   "Attempt to create a Double Array with negative size");
71
72   myLowerRow = R1;
73   myLowerCol = C1;
74   myUpperRow = R2;
75   myUpperCol = C2;
76   Standard_Integer Size = Data.Length();
77
78   for (Standard_Integer I = 0; I < Size ; I++) Data.SetValue(I,V); 
79 }
80
81
82 // --------------------------------------------------------------------
83 //                            Destructor : Not Implemented
84 // --------------------------------------------------------------------
85
86 /*
87 void PCollection_HArray2::~PCollection_HArray2 () 
88 {
89         delete Data ;
90 }
91 */
92
93 /* Anciens INLINE */
94
95 // --------------------------------------------------------------------
96 //                            SetValue
97 // --------------------------------------------------------------------
98 void PCollection_HArray2::SetValue ( const Standard_Integer Row,
99                                          const Standard_Integer Col,
100                                          const Item& Value)
101 {
102   Standard_OutOfRange_Raise_if((Row <myLowerRow || Row > myUpperRow ||
103                                 Col <myLowerCol || Col > myUpperCol),
104                                "Index out of range in HArray2::SetValue");
105
106   Data.SetValue((Row-myLowerRow)*(myUpperCol-myLowerCol+1)+
107                 (Col-myLowerCol), Value) ;
108 }
109
110
111 // --------------------------------------------------------------------
112 //                            Value
113 // --------------------------------------------------------------------
114 Item PCollection_HArray2::Value (const Standard_Integer Row,
115                                      const Standard_Integer Col) const
116 {
117   Standard_OutOfRange_Raise_if((Row <myLowerRow || Row > myUpperRow ||
118                                 Col <myLowerCol || Col > myUpperCol),
119                                "Index out of range in HArray2::SetValue");
120
121   return Data((Row-myLowerRow) * (myUpperCol-myLowerCol+1) +
122               (Col-myLowerCol)) ;
123 }
124
125
126 // ------------------------------------------------------------------
127 //
128 // ------------------------------------------------------------------
129 PCollection_FieldOfHArray2 PCollection_HArray2::Field () const
130 {
131   return Data ;
132 }
133