// Copyright (c) 1998-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include // ---------------------------------------------------------------------- // HArray1 implementation: // Last Revision : Feb,10 1992 J.P Tirault // Implementation of ShallowCopy, ShallowDump // methods. // ---------------------------------------------------------------------- // Constructor // ---------------------------------------------------------------------- PCollection_HArray1::PCollection_HArray1 (const Standard_Integer First, const Standard_Integer Last) : Data (Last-First+1) { Standard_Integer Size = Last-First+1; if( Size <= 0 ) Standard_RangeError::Raise(); LowerBound = First ; UpperBound = Last ; } // ---------------------------------------------------------------------- // datas // ---------------------------------------------------------------------- Standard_Address PCollection_HArray1::Datas() const { return ((Standard_Address)Data.Lock()); } // ---------------------------------------------------------------------- // Constructor // ---------------------------------------------------------------------- PCollection_HArray1::PCollection_HArray1 (const Standard_Integer First, const Standard_Integer Last, const Item& V) :Data (Last-First+1) { Standard_Integer Size = Last-First+1; if( Size <= 0 ) Standard_RangeError::Raise(); LowerBound = First ; UpperBound = Last ; for(Standard_Integer I = 0 ; I < Size ; I++) Data.SetValue(I, V); } // ---------------------------------------------------------------------- // Destructor // ---------------------------------------------------------------------- /* void PCollection_HArray1::~PCollection_HArray1 () { delete Data ; } */ // ---------------------------------------------------------------------- // ShallowCopy // ---------------------------------------------------------------------- Handle(Standard_Persistent) PCollection_HArray1::ShallowCopy() const { PCollection_HArray1* TheCopy = new PCollection_HArray1(*this); // PCollection_FieldOfHArray1 DataCopy (Data); // TheCopy->Data = DataCopy; return TheCopy; } // ---------------------------------------------------------------------- // ShallowDump // ---------------------------------------------------------------------- void PCollection_HArray1::ShallowDump(Standard_OStream& S) const { ::ShallowDump(Data,S); } /* Anciens INLINE */ // ---------------------------------------------------------------------- // SetValue // ---------------------------------------------------------------------- void PCollection_HArray1::SetValue ( const Standard_Integer Index, const Item& Value) { Standard_OutOfRange_Raise_if((Index < LowerBound || Index > UpperBound), "Index out of range in HArray1::SetValue"); Data.SetValue(Index-LowerBound, Value) ; } // ---------------------------------------------------------------------- // Value // ---------------------------------------------------------------------- Item PCollection_HArray1::Value ( const Standard_Integer Index) const { Standard_OutOfRange_Raise_if((Index < LowerBound || Index > UpperBound), "Index out of range in HArray1::operator()"); return Data(Index-LowerBound); } // ------------------------------------------------------------------ // // ------------------------------------------------------------------ PCollection_FieldOfHArray1 PCollection_HArray1::Field () const { return Data ; }