---Purpose:
-- Prohibits the creator by copy
--
- Assign (me:out; Other : CArray1 from BOPTColStd)
+ Assign (me:out; Other :
+ CArray1 from BOPTColStd)
returns CArray1 from BOPTColStd
is private;
---C++: alias operator =
---Purpose:
-- Prohibits the operator =
--
- Resize(me: in out; theNewLength: Integer from Standard);
+ Resize(me: in out;
+ theNewLength: Integer from Standard);
---Purpose:
-- destroy current content and realloc the new size
--
-- Frees the allocated area corresponding to the
-- array.
--
- Length (me) returns Integer from Standard;
+ Length (me)
+ returns Integer from Standard;
---Purpose:
-- Returns the number of elements of <me>
--
- Extent (me) returns Integer from Standard;
+ Extent (me)
+ returns Integer from Standard;
---Purpose:
-- The same as Length().
---
- FactLength (me) returns Integer from Standard;
+ FactLength (me)
+ returns Integer from Standard;
---Purpose:
-- Returns the number of elements of <me>.
---
- Append (me:out; Value: Array1Item)
+ Append (me:out;
+ Value: Array1Item)
returns Integer from Standard
raises OutOfMemory from Standard;
---Purpose:
-- Remove the Item[Index] from the array.
---
- Remove (me:out; Index:Integer from Standard)
+ Remove (me:out;
+ Index:Integer from Standard)
raises OutOfMemory from Standard;
---Purpose:
-- Appends the Value at the end of me
---
- Value (me; Index:Integer from Standard) returns any Array1Item
+ Value (me;
+ Index:Integer from Standard)
+ returns any Array1Item
---C++: alias operator ()
---C++: return const &
raises OutOfRange from Standard;
-- array.
--
- ChangeValue (me: in out; Index:Integer from Standard) returns any Array1Item
+ ChangeValue (me: in out;
+ Index:Integer from Standard)
+ returns any Array1Item
---C++: alias operator ()
---C++: return &
raises OutOfRange from Standard;
-- Returns the value of the Index-th element of the
-- array.
- SetBlockLength(me:out; aBL: Integer from Standard);
+ SetBlockLength(me:out;
+ aBL: Integer from Standard);
---Purpose:
-- Sets the size of the allocated block
---
returns Integer from Standard;
---Purpose:
-- Returns the current size of the allocated block
- ---
- IsInvalidIndex (me; Index:Integer from Standard)
+ ---
+ IsInvalidIndex (me;
+ Index:Integer from Standard)
returns Boolean from Standard
is private;
---Purpose:
-- Checks the input value of an Index for validity in
-- array.
-
+
+ --modified by NIZNHY-PKV Wed Nov 09 09:32:13 2011f
+ Purge(me:out);
+ ---Purpose:
+ -- Release the memory that is allocated but unused.
+ --
+ --modified by NIZNHY-PKV Wed Nov 09 09:32:16 2011t
+
fields
-
myStart : Address;
myLength : Integer;
myFactLength : Integer;
//function : BOPTools_CArray1::BOPTools_CArray1
//purpose :
//=======================================================================
- BOPTColStd_CArray1::BOPTColStd_CArray1
- (const Standard_Integer aLength,
- const Standard_Integer aBlockLength)
+BOPTColStd_CArray1::BOPTColStd_CArray1 (const Standard_Integer aLength,
+ const Standard_Integer aBlockLength)
:
myStart(NULL),
myLength(0),
//function : Resize
//purpose :
//=======================================================================
- void BOPTColStd_CArray1::Resize(const Standard_Integer aNL)
+void BOPTColStd_CArray1::Resize(const Standard_Integer aNL)
{
Array1Item* p = NULL;
if (aNL>0) {
if (!p) {
Standard_OutOfMemory::Raise
- ("IntBOPTools_CArray1 : Allocation failed.");
+ ("BOPTools_CArray1 : Allocation failed.");
}
else {
//function : Remove
//purpose :
//=======================================================================
- void BOPTColStd_CArray1::Remove(const Standard_Integer anInd)
+void BOPTColStd_CArray1::Remove(const Standard_Integer anInd)
{
- if (myIsAllocated) {
- if (IsInvalidIndex(anInd)) {
- Standard_OutOfMemory::Raise
- ("IntBOPTools_CArray1 : Attempt to remove inexisting Item.");
- }
-
- const Standard_Integer aNFL=myFactLength-1;
+ if (!myIsAllocated) {
+ return;
+ }
- Array1Item *p=NULL;
- p = new Array1Item[aNFL];
+ if (IsInvalidIndex(anInd)) {
+ Standard_OutOfMemory::Raise
+ ("BOPTools_CArray1 : Attempt to remove inexisting Item.");
+ }
- if (!p) {
- Standard_OutOfMemory::Raise
- ("IntBOPTools_CArray1::Append: Allocation failed.");
+ const Standard_Integer aNFL=myFactLength-1;
+ Array1Item *p=NULL;
+ p = new Array1Item[aNFL];
+
+ if (!p) {
+ Standard_OutOfMemory::Raise
+ ("BOPTools_CArray1::Append: Allocation failed.");
}
-
- Standard_Integer i, j, anIndx, iLength;
-
- iLength=myLength;
-
- anIndx=anInd-1;
- for (i=0, j=0; i<myLength; ++i) {
- if (i!=anIndx) {
- p[j]= ((Array1Item *)myStart)[i];
- j++;
- }
+
+ Standard_Integer i, j, anIndx, iLength;
+
+ iLength=myLength;
+
+ anIndx=anInd-1;
+ for (i=0, j=0; i<myLength; ++i) {
+ if (i!=anIndx) {
+ p[j]= ((Array1Item *)myStart)[i];
+ j++;
}
-
- Destroy();
-
- myFactLength=aNFL;
- myLength=iLength-1;
- myIsAllocated=Standard_True;
- myStart = (void*) p;
}
+
+ Destroy();
+
+ myFactLength=aNFL;
+ myLength=iLength-1;
+ myIsAllocated=Standard_True;
+ myStart = (void*) p;
}
//=======================================================================
//function : Append
Destroy();
+
myFactLength=iLengthToAllocate;
myIsAllocated=Standard_True;
myStart = (void*) p;
//function : IsInvalidIndex
//purpose :
//=======================================================================
- Standard_Boolean BOPTColStd_CArray1::IsInvalidIndex
- (const Standard_Integer anInd)const
+Standard_Boolean BOPTColStd_CArray1::IsInvalidIndex
+ (const Standard_Integer anInd)const
{
Standard_Boolean aFlag;
Standard_Integer anIndx=anInd-1;
//function : Destroy
//purpose :
//=======================================================================
- void BOPTColStd_CArray1::Destroy()
+void BOPTColStd_CArray1::Destroy()
{
if (myIsAllocated) {
delete [] (Array1Item *)myStart;
myLength=0;
myStart=NULL;
}
- //myStart=NULL;
}
+
//=======================================================================
//function : Length
//purpose :
//=======================================================================
- Standard_Integer BOPTColStd_CArray1::Length() const
+Standard_Integer BOPTColStd_CArray1::Length() const
{
return myLength;
}
//function : Extent
//purpose :
//=======================================================================
- Standard_Integer BOPTColStd_CArray1::Extent() const
+Standard_Integer BOPTColStd_CArray1::Extent() const
{
return myLength;
}
//function : FactLength
//purpose :
//=======================================================================
- Standard_Integer BOPTColStd_CArray1::FactLength() const
+Standard_Integer BOPTColStd_CArray1::FactLength() const
{
return myFactLength;
}
//function : SetBlockLength
//purpose :
//=======================================================================
- void BOPTColStd_CArray1::SetBlockLength(const Standard_Integer aBL)
+void BOPTColStd_CArray1::SetBlockLength(const Standard_Integer aBL)
{
- if (aBL > 0)
+ if (aBL > 0) {
myBlockLength=aBL;
+ }
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
- const Array1Item& BOPTColStd_CArray1::Value
+const Array1Item& BOPTColStd_CArray1::Value
(const Standard_Integer Index) const
{
if (IsInvalidIndex(Index)) {
//function : ChangeValue
//purpose :
//=======================================================================
- Array1Item& BOPTColStd_CArray1::ChangeValue
+Array1Item& BOPTColStd_CArray1::ChangeValue
(const Standard_Integer Index)
{
if (IsInvalidIndex(Index)) {
}
return ((Array1Item *)myStart)[Index-1];
}
+//modified by NIZNHY-PKV Wed Nov 09 10:03:01 2011f
+//=======================================================================
+//function : Purge
+//purpose :
+//=======================================================================
+void BOPTColStd_CArray1::Purge()
+{
+ if (!myIsAllocated) {
+ return;
+ }
+ //
+ if (myLength>0 && myLength<myFactLength) {
+ Standard_Integer i, aLength;
+ Array1Item *p = NULL;
+ //
+ p=new Array1Item[myLength];
+ if (!p) {
+ Standard_OutOfMemory::Raise
+ ("BOPTools_CArray1 : Allocation failed.");
+ }
+ //
+ for (i=0; i<myLength; i++) {
+ p[i]=((Array1Item *)myStart)[i];
+ }
+ //
+ aLength=myLength;
+ //
+ Destroy();
+ //
+ myIsAllocated=Standard_True;
+ myLength=aLength;
+ myFactLength=myLength;
+ myStart = (void*) p;
+ }
+}
+//modified by NIZNHY-PKV Wed Nov 09 10:03:07 2011t
+/*
+//=======================================================================
+//function : Dump
+//purpose :
+//=======================================================================
+void BOPTColStd_CArray1::Dump() const
+{
+ printf("\n-- BOPTColStd_CArray1::Dump --\n");
+ printf("myIsAllocated =%d\n", myIsAllocated);
+ printf("myLength =%d\n", myLength);
+ printf("myFactLength =%d\n", myFactLength);
+ printf("myBlockLength =%d\n", myBlockLength);
+}
+*/
#include <OSD_Chronometer.hxx>
#include <BRepTools.hxx>
+#include <BOPTColStd_CArray1OfInteger.hxx>
static
Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
void PrintState (Draw_Interpretor& aDI,
const TopAbs_State& aState);
+//modified by NIZNHY-PKV Thu Nov 10 12:11:15 2011f
+static
+ void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
+ Draw_Interpretor& aDI);
+//modified by NIZNHY-PKV Thu Nov 10 12:11:18 2011t
+
static Standard_Integer bhaspc (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer baddve (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bisclosed (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bclassify (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer b2dclassify (Draw_Interpretor& , Standard_Integer , const char** );
-//modified by NIZNHY-PKV Mon May 29 11:44:24 2006f
static Standard_Integer bhole (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , const char** );
-//modified by NIZNHY-PKV Mon May 29 11:44:28 2006t
-
//=======================================================================
//function : LowCommands
//purpose :
__FILE__, bclassify , g);
theCommands.Add("b2dclassify" , "Use >bclassify Face Point2d [Tol2D=Tol(Face)] ",
__FILE__, b2dclassify , g);
- //modified by NIZNHY-PKV Mon May 29 11:45:33 2006f
theCommands.Add("bhole" , "Use bhole" , __FILE__, bhole , g);
theCommands.Add("bxhole" , "Use bxhole" , __FILE__, bxhole , g);
- //modified by NIZNHY-PKV Mon May 29 11:45:37 2006t
}
//=======================================================================
}
//
-//modified by NIZNHY-PKV Mon May 29 11:40:29 2006f
//=======================================================================
//function : bhole
//purpose :
//
return 0;
}
-//modified by NIZNHY-PKV Mon May 29 11:40:31 2006t
return 0;
}
+#include <BOPTColStd_CArray1OfInteger.hxx>
+//=======================================================================
+//function : DumpArray
+//purpose :
+//=======================================================================
+void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
+ Draw_Interpretor& aDI)
+{
+ Standard_Integer iLength, iFactLength, iBlockLength;
+ //
+ iLength=aC.Length();
+ iFactLength=aC.FactLength();
+ iBlockLength=aC.BlockLength();
+ //
+ aDI<< "Length: " <<iLength << "\n";
+ aDI<< "FactLength: " <<iFactLength << "\n";
+ aDI<< "BlockLength: " <<iBlockLength << "\n";
+}
+//=======================================================================
+//function : bcarray
+//purpose :
+//=======================================================================
+Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+
+ if (argc != 1) {
+ di << "Usage : " << argv[0] << "\n";
+ return 1;
+ }
+
+ Standard_Integer i, aNb, aBL;
+ BOPTColStd_CArray1OfInteger aC;
+ //
+ aBL=100000;
+ aC.SetBlockLength(aBL);
+ //
+ for (i=1; i<=10; ++i) {
+ aC.Append(-i*10);
+ }
+ di<< "\nstate before release the unused memory\n";
+ DumpArray(aC, di);
+ //
+ aC.Purge();
+ //
+ di<< "\nstate after release the unused memory\n";
+ DumpArray(aC, di);
+ //
+ return 0;
+}
+
void QAOCC::Commands(Draw_Interpretor& theCommands) {
const char *group = "QAOCC";
theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
+ theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
return;
}