7 #ifndef SMESH_Array2_HeaderFile 8 #define SMESH_Array2_HeaderFile 11 #include <Standard_DimensionMismatch.hxx> 12 #include <Standard_OutOfMemory.hxx> 13 #include <Standard_OutOfRange.hxx> 16 #include <NCollection_Array2.hxx> 20 #pragma warning (disable:4291) 62 virtual Standard_Boolean
More (
void)
const 68 virtual const TheItemType&
Value (
void)
const 74 void*
operator new(
size_t theSize,
75 const Handle(NCollection_BaseAllocator)& theAllocator)
76 {
return theAllocator->Allocate(theSize); }
88 const Standard_Integer theRowUpper,
89 const Standard_Integer theColLower,
90 const Standard_Integer theColUpper) :
114 const Standard_Integer theRowLower,
115 const Standard_Integer theRowUpper,
116 const Standard_Integer theColLower,
117 const Standard_Integer theColUpper) :
125 myStart = (TheItemType *) &theBegin;
130 void Init (
const TheItemType& theValue)
133 for(pCur =
myStart; pCur<pEnd; pCur++)
138 virtual Standard_Integer
Size (
void)
const 173 if (&theOther ==
this)
175 #if !defined No_Exception && !defined No_Standard_DimensionMismatch 176 if (
Length() != theOther.Size())
177 Standard_DimensionMismatch::Raise (
"SMESH_Array2::Assign");
180 theOther.CreateIterator();
182 for (TheItemType* pItem=
myStart;
184 pItem++, anIter2.Next())
185 *pItem = anIter2.Value();
191 if (&theOther ==
this)
193 #if !defined No_Exception && !defined No_Standard_DimensionMismatch 195 Standard_DimensionMismatch::Raise (
"SMESH_Array2::operator=");
197 TheItemType * pMyItem =
myStart;
198 TheItemType * pItem = theOther.
myStart;
199 const Standard_Integer iSize =
Length();
200 for (Standard_Integer i=0; i < iSize; i++, pItem++, pMyItem++)
206 const TheItemType&
Value (
const Standard_Integer theRow,
207 const Standard_Integer theCol)
const 209 #if !defined No_Exception && !defined No_Standard_OutOfRange 210 if (theRow < myLowerRow || theRow >
myUpperRow ||
212 Standard_OutOfRange::Raise (
"SMESH_Array2::Value");
214 return myData[theRow][theCol];
218 const TheItemType&
operator() (
const Standard_Integer theRow,
219 const Standard_Integer theCol)
const 220 {
return Value (theRow,theCol); }
224 const Standard_Integer theCol)
226 #if !defined No_Exception && !defined No_Standard_OutOfRange 227 if (theRow < myLowerRow || theRow >
myUpperRow ||
229 Standard_OutOfRange::Raise (
"SMESH_Array2::ChangeValue");
231 return myData[theRow][theCol];
236 const Standard_Integer theCol)
241 const Standard_Integer theCol,
242 const TheItemType& theItem)
244 #if !defined No_Exception && !defined No_Standard_OutOfRange 245 if (theRow < myLowerRow || theRow >
myUpperRow ||
247 Standard_OutOfRange::Raise (
"SMESH_Array2::SetValue");
249 myData[theRow][theCol] = theItem;
267 #if !defined No_Exception && !defined No_Standard_RangeError 268 if (iRowSize <= 0 || iColSize <= 0)
269 Standard_RangeError::Raise (
"SMESH_Array2::Allocate");
273 myStart =
new TheItemType[iRowSize * iColSize];
274 #if !defined No_Exception && !defined No_Standard_OutOfMemory 276 Standard_OutOfMemory::Raise (
"SMESH_Array2 : Allocation failed");
280 TheItemType** pTable =
new TheItemType* [iColSize];
281 #if !defined No_Exception && !defined No_Standard_OutOfMemory 283 Standard_OutOfMemory::Raise (
"SMESH_Array2 : Allocation failed");
288 for (Standard_Integer i = 0; i < iColSize; i++)
301 {
return *(
new (this->IterAllocator())
Iterator(*
this)); }
320 #pragma warning (default:4291) Standard_Integer myUpperCol
SMESH_Array2 & operator=(const SMESH_Array2 &theOther)
operator= (array to array)
class Handle(MeshVS_DataSource3D)
Standard_Integer myLowerCol
~SMESH_Array2(void)
Destructor - releases the memory.
virtual void Next(void)
Make step.
Standard_Integer UpperCol(void) const
UpperCol.
SMESH_Array2 * myArray
Pointer to the array being iterated.
Standard_Boolean IsDeletable(void) const
myDeletable flag
TheItemType * myStart
Pointer to the memory array.
virtual Standard_Boolean More(void) const
Check end.
void Init(const SMESH_Array2 &theArray)
Initialisation.
SMESH_Array2(const Standard_Integer theRowLower, const Standard_Integer theRowUpper, const Standard_Integer theColLower, const Standard_Integer theColUpper)
Constructor.
Standard_Integer myUpperRow
virtual TheItemType & ChangeValue(void) const
Variable value access.
const TheItemType & operator()(const Standard_Integer theRow, const Standard_Integer theCol) const
operator() - alias to ChangeValue
SMESH_Array2(const TheItemType &theBegin, const Standard_Integer theRowLower, const Standard_Integer theRowUpper, const Standard_Integer theColLower, const Standard_Integer theColUpper)
C array-based constructor.
Purpose: The class Array2 represents bi-dimensional arrays of fixed size known at run time...
Standard_Integer mySize
Total amount of items.
void Allocate(void)
Allocate memory for the array, set up indirection table.
Standard_Integer ColLength(void) const
ColLength.
TheItemType ** myData
Pointer to the row pointers table.
Standard_Integer RowLength(void) const
RowLength.
virtual Standard_Integer Size(void) const
Size (number of items)
SMESH_Array2(const SMESH_Array2 &theOther)
Copy constructor.
const TheItemType & Value(const Standard_Integer theRow, const Standard_Integer theCol) const
Constant value access.
virtual void Assign(const NCollection_Array2< TheItemType > &theOther)
Assign.
virtual const TheItemType & Value(void) const
Constant value access.
Standard_Integer LowerRow(void) const
LowerRow.
void SetValue(const Standard_Integer theRow, const Standard_Integer theCol, const TheItemType &theItem)
SetValue.
Standard_Boolean myDeletable
Flag showing who allocated the array.
virtual TYPENAME NCollection_Array2< TheItemType >::Iterator & CreateIterator(void) const
Creates Iterator for use on BaseCollection.
Standard_Integer Length(void) const
Length (number of items)
TheItemType & ChangeValue(const Standard_Integer theRow, const Standard_Integer theCol)
Variable value access.
Iterator(const SMESH_Array2 &theArray)
Constructor with initialisation.
Standard_Integer UpperRow(void) const
UpperRow.
Standard_Integer myCurrent
Index of the current item.
void Init(const TheItemType &theValue)
Initialise the values.
Standard_Integer myLowerRow
Iterator(void)
Empty constructor - for later Init.
Standard_Integer LowerCol(void) const
LowerCol.