]> OCCT Git - occt-copy.git/commitdiff
0024971: Incomplete interface of NCollection classes
authorabv <abv@opencascade.com>
Wed, 11 Jun 2014 06:43:27 +0000 (10:43 +0400)
committerapn <apn@opencascade.com>
Wed, 11 Jun 2014 06:44:16 +0000 (10:44 +0400)
NCollection classes amended to be compatible with TCollection equivalents:

- List and Maps: copy constructor is used for placement of new items in collection instead of assignment operator, thus default constructor is not necessary any more for the item class
- Constructors with additional argument of element type added in array classes operated by Handle, defined by NCollection_DefineHArray*.hxx, allowing to initialize array immediately by specified value
- Non-const methods First() and Last() are added in List class, and method Value() in TListIterator class
- Method Append() accepting Handle(HSequence) provided in NCollection_DefineHSequence.hxx
- Default implementation of global function IsEqual() is provided as template (using operator ==)

Code using lists and maps of sequences is refactored to operate sequence by Handle (since Sequence does not to have public copy constructor).

In addition, error checking code is simplified to use macros _Raise_if instead of custom #ifdefs with the same meaning.
Comments within declaration of instances of generic classes in CDL removed.

Fixed bug in copy constructor of NCollection_BaseVector leading to corrupt data if original vector is empty; simplistic test command for vectors is added.

31 files changed:
src/AIS/AIS_LocalContext_1.cxx
src/CDM/CDM.cdl
src/IGESBasic/IGESBasic.cdl
src/Interface/Interface.cdl
src/MeshTest/MeshTest_CheckTopology.cxx
src/MeshTest/MeshTest_CheckTopology.hxx
src/MeshVS/MeshVS_Mesh.cxx
src/NCollection/NCollection_Array1.hxx
src/NCollection/NCollection_Array2.hxx
src/NCollection/NCollection_BaseVector.hxx
src/NCollection/NCollection_DataMap.hxx
src/NCollection/NCollection_DefaultHasher.hxx
src/NCollection/NCollection_DefineHArray1.hxx
src/NCollection/NCollection_DefineHArray2.hxx
src/NCollection/NCollection_DefineHSequence.hxx
src/NCollection/NCollection_DoubleMap.hxx
src/NCollection/NCollection_IndexedDataMap.hxx
src/NCollection/NCollection_IndexedMap.hxx
src/NCollection/NCollection_List.hxx
src/NCollection/NCollection_Map.hxx
src/NCollection/NCollection_Sequence.hxx
src/NCollection/NCollection_TListIterator.hxx
src/NCollection/NCollection_TListNode.hxx
src/Prs3d/Prs3d_NListOfSequenceOfPnt.hxx
src/Prs3d/Prs3d_WFShape.cxx
src/QANCollection/QANCollection_Test.cxx
src/SelectMgr/FILES
src/SelectMgr/SelectMgr_DataMapOfObjectOwners.hxx [deleted file]
src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx
src/StdPrs/StdPrs_WFRestrictedFace.cxx
src/StdPrs/StdPrs_WFSurface.cxx

index 5ab1b8f30664f29c4ebbc89b3cc0d7d2d389d064..a7e22e8a028dd894d06a5a5dd40bab7cabb6e27d 100644 (file)
 #include <Select3D_SensitiveTriangulation.hxx>
 #include <SelectBasics_SensitiveEntity.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <NCollection_Map.hxx>
+
 #ifdef OCC9026
 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
 #endif
 #include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
 #include <OSD_Environment.hxx>
-#include <SelectMgr_DataMapOfObjectOwners.hxx>
 
 #include <Geom_Transformation.hxx>
 #include <AIS_Selection.hxx>
@@ -565,8 +567,10 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
   if( Sel.IsNull() ) return;
 #endif
 
-  Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
+  typedef NCollection_DataMap <Handle(SelectMgr_SelectableObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > SelectMgr_DataMapOfObjectOwners;
   SelectMgr_DataMapOfObjectOwners aMap;
+
+  Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
   
   // to avoid problems when there is a loop searching for selected objects...
 #if !defined OCC189 && !defined USE_MAP
@@ -602,18 +606,20 @@ void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
       if ( Ownr->IsAutoHilight() )
         Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
       else if ( aMap.IsBound (SO) )
-        aMap.ChangeFind(SO).Append ( Ownr );        
+        aMap(SO)->Append ( Ownr );        
       else {
-        SelectMgr_SequenceOfOwner aSeq;
-        aSeq.Append ( Ownr );
+        NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq = new SelectMgr_SequenceOfOwner;
+        aSeq->Append ( Ownr );
         aMap.Bind ( SO, aSeq );
       }      
     }
   }
 
-  for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners aMapIter(aMap); 
+  for ( SelectMgr_DataMapOfObjectOwners::Iterator aMapIter(aMap); 
         aMapIter.More(); aMapIter.Next() )
-    aMapIter.Key()->HilightSelected ( myMainPM, aMapIter.Value() );
+  {
+    aMapIter.Key()->HilightSelected (myMainPM, *aMapIter.Value());
+  }
 
   if (updateviewer)
   {
@@ -636,8 +642,7 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
   if( Sel.IsNull() ) return;
 #endif
   Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
-  SelectMgr_DataMapOfObjectOwners anObjMap;
-  SelectMgr_SequenceOfOwner anOwnSeq;
+  NCollection_Map<Handle(SelectMgr_SelectableObject)> anObjMap;
   
 #if !defined OCC189 && !defined USE_MAP  
   const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
@@ -657,9 +662,9 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
 #ifdef BUC60876
        Handle(SelectMgr_SelectableObject) SO  = Ownr->Selectable();
        Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
-  anObjMap.Bind ( IO, anOwnSeq );
+        anObjMap.Add (IO);
 
-  HM = GetHiMod(IO);
+        HM = GetHiMod(IO);
 #endif
        Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
        if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
@@ -677,10 +682,12 @@ void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
     }
   }
   
-  for ( SelectMgr_DataMapIteratorOfMapOfObjectOwners anIter1 ( anObjMap ); 
+  for (NCollection_Map<Handle(SelectMgr_SelectableObject)>::Iterator anIter1 ( anObjMap ); 
         anIter1.More(); anIter1.Next() )
+  {
     if ( !anIter1.Key()->IsAutoHilight() )
       anIter1.Key()->ClearSelected();
+  }
 
   if(updateviewer){
 #ifdef BUC60774
index f9caf62d78f7200a35d7e255be7a0dcd942b21e8..7e5198e8471953cfb91262fddff22c13c62e8a05 100644 (file)
@@ -44,10 +44,10 @@ is
     ---Purpose: this map will allows to get a directory object from a name.
 
     private class PresentationDirectory instantiates DataMap from TCollection 
-    ---Purpose: this map will allows to get a directory object from a name.
         (ExtendedString from TCollection,
          Document from CDM,
          ExtendedString from TCollection);
+    ---Purpose: this map will allows to get a directory object from a name.
          
     private pointer DocumentPointer to Document from CDM;
     private class Reference;    
index aab1fd9476da6dabf2f18d3e29aee11419c67d94..a376e5c8ef5bb20620fa78b3243c565be0be7ff6 100644 (file)
@@ -92,40 +92,30 @@ is
 
     -- The class instantiations :
 
---    class Array1OfHArray1OfInteger instantiates 
---        Array1 from TCollection (HArray1OfInteger from TColStd);
---    class Array1OfHArray1OfReal    instantiates 
---        Array1 from TCollection (HArray1OfReal from TColStd);
---    class Array1OfHArray1OfXY      instantiates 
---        Array1 from TCollection (HArray1OfXY   from TColgp);
---    class Array1OfHArray1OfXYZ     instantiates 
---        Array1 from TCollection (HArray1OfXYZ  from TColgp);
     class Array2OfHArray1OfReal    instantiates 
         Array2 from TCollection (HArray1OfReal from TColStd);
---    class Array1OfHArray1OfIGESEntity instantiates 
---        Array1 from TCollection (HArray1OfIGESEntity from IGESData);
     class Array1OfLineFontEntity instantiates
         Array1 from TCollection (LineFontEntity from IGESData);
 
     class HArray1OfHArray1OfInteger instantiates
-    -- HArray1 from TCollection (HArray1OfInteger from TColStd,Array1OfHArray1OfInteger);
        JaggedArray from Interface (HArray1OfInteger     from TColStd);
+    -- HArray1 from TCollection (HArray1OfInteger from TColStd,Array1OfHArray1OfInteger);
     class HArray1OfHArray1OfReal    instantiates
-    -- HArray1 from TCollection (HArray1OfReal from TColStd,Array1OfHArray1OfReal);
        JaggedArray from Interface (HArray1OfReal        from TColStd);
+    -- HArray1 from TCollection (HArray1OfReal from TColStd,Array1OfHArray1OfReal);
     class HArray1OfHArray1OfXY      instantiates
-    -- HArray1 from TCollection (HArray1OfXY   from TColgp, Array1OfHArray1OfXY);
        JaggedArray from Interface (HArray1OfXY          from TColgp);
+    -- HArray1 from TCollection (HArray1OfXY   from TColgp, Array1OfHArray1OfXY);
     class HArray1OfHArray1OfXYZ     instantiates
-    -- HArray1 from TCollection (HArray1OfXYZ  from TColgp, Array1OfHArray1OfXYZ);
        JaggedArray from Interface (HArray1OfXYZ         from TColgp);
+    -- HArray1 from TCollection (HArray1OfXYZ  from TColgp, Array1OfHArray1OfXYZ);
 
     class HArray2OfHArray1OfReal    instantiates HArray2 from TCollection
         (HArray1OfReal from TColStd,Array2OfHArray1OfReal);
 
     class HArray1OfHArray1OfIGESEntity instantiates
-    -- HArray1 from TCollection (HArray1OfIGESEntity from IGESData,Array1OfHArray1OfIGESEntity);
        JaggedArray from Interface (HArray1OfIGESEntity  from IGESData);
+    -- HArray1 from TCollection (HArray1OfIGESEntity from IGESData,Array1OfHArray1OfIGESEntity);
 
     class HArray1OfLineFontEntity   instantiates HArray1 from TCollection
         (LineFontEntity from IGESData,Array1OfLineFontEntity);
index 48f0a3b49946fd2e6a1e54c9d370f4f538161285..93025c84224f7bb15273ee2c77db55382679f171 100644 (file)
@@ -128,15 +128,13 @@ is
 
        -- --  Instantiations  -- --
 
-    private class  SequenceOfCheck  instantiates           -- for HSequence
+    private class  SequenceOfCheck  instantiates
         Sequence from TCollection (Check);
-    private class HSequenceOfCheck  instantiates           -- Transient
+    private class HSequenceOfCheck  instantiates
        HSequence from TCollection (Check,SequenceOfCheck);
 
-    class Array1OfFileParameter instantiates               -- for ParamList :
+    class Array1OfFileParameter instantiates
         Array1 from TCollection    (FileParameter);
---    class HArray1OfFileParameter instantiates                           -- Array, Transient
---        HArray1 from TCollection   (FileParameter,Array1OfFileParameter);
 
     --  Useful Instantiations to define Data
 
index 83c7bb25bec7c3eabfa3a374e4890f24bf9933ad..8829f63ee3fa5bc2712d8ddd0e98ad79bbc54109 100644 (file)
@@ -160,13 +160,12 @@ void MeshTest_CheckTopology::Perform (Draw_Interpretor& di)
          if (aMapBndNodes.Contains(n1) && aMapBndNodes.Contains(n2))
            continue;
          if (!myMapFaceLinks.Contains(iF)) {
-           //myMapFaceLinks.Add(iF, TColStd_SequenceOfInteger());
-            TColStd_SequenceOfInteger tmpSeq;
+            Handle(TColStd_HSequenceOfInteger) tmpSeq = new TColStd_HSequenceOfInteger;
            myMapFaceLinks.Add(iF, tmpSeq);
           }
-         TColStd_SequenceOfInteger& aSeq = myMapFaceLinks.ChangeFromKey(iF);
-         aSeq.Append(n1);
-         aSeq.Append(n2);
+         Handle(TColStd_HSequenceOfInteger)& aSeq = myMapFaceLinks.ChangeFromKey(iF);
+         aSeq->Append(n1);
+         aSeq->Append(n2);
        }
       }
     }
@@ -193,10 +192,10 @@ void MeshTest_CheckTopology::GetFreeLink(const Standard_Integer theFaceIndex,
                                         Standard_Integer& theNode1,
                                         Standard_Integer& theNode2) const
 {
-  const TColStd_SequenceOfInteger& aSeq = myMapFaceLinks(theFaceIndex);
+  const Handle(TColStd_HSequenceOfInteger)& aSeq = myMapFaceLinks(theFaceIndex);
   Standard_Integer aInd = (theLinkIndex-1)*2 + 1;
-  theNode1 = aSeq(aInd);
-  theNode2 = aSeq(aInd+1);
+  theNode1 = aSeq->Value(aInd);
+  theNode2 = aSeq->Value(aInd+1);
 }
 
 //=======================================================================
index dd5858022a15abe76455e1fdd8b3785360395a56..a3e5e6574387dc7d6b1ea7dd6e5e92957c1f20c5 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <TopoDS_Shape.hxx>
 #include <NCollection_IndexedDataMap.hxx>
-#include <TColStd_SequenceOfInteger.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
 #include <TColStd_SequenceOfReal.hxx>
 #include <Draw_Interpretor.hxx>
 
@@ -58,7 +58,7 @@ public:
 
   //! returns the number free links on a face with the given index
   Standard_Integer NbFreeLinks(const Standard_Integer theIndex) const
-  { return myMapFaceLinks(theIndex).Length() / 2; }
+  { return myMapFaceLinks(theIndex)->Length() / 2; }
 
   //! gets the numbers of nodes of a free link with the given index
   //! in the face with the given index
@@ -103,7 +103,7 @@ public:
 
 private:
   TopoDS_Shape myShape;
-  NCollection_IndexedDataMap<Standard_Integer,TColStd_SequenceOfInteger>
+  NCollection_IndexedDataMap<Standard_Integer,Handle(TColStd_HSequenceOfInteger)>
                myMapFaceLinks;
 
   TColStd_SequenceOfInteger myErrors;
index e519f7f51b633f5468a8d558e25a2bc680084963..91cbe6c706da2b9ee5a656254db7f6f17ca18f6b 100644 (file)
@@ -1024,12 +1024,6 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage
   if ( myHilighter.IsNull() )
     return;
 
-  SelectMgr_SequenceOfOwner theOwners;
-  //new functionality
-
-  //if ( myHilightPrs.IsNull() )
-  //  myHilightPrs = new Prs3d_Presentation ( PM->StructureManager() );
-
   Handle( Prs3d_Presentation ) aHilightPrs;
   aHilightPrs = GetHilightPresentation( PM );
 
index 5fb476a370c1fcf430ef34c59de3c1e2cc75c693..580fa69bd307f21fe1f2a23c51db8bb2f471b38a 100644 (file)
 #ifndef NCollection_Array1_HeaderFile
 #define NCollection_Array1_HeaderFile
 
-#ifndef No_Exception
 #include <Standard_DimensionMismatch.hxx>
 #include <Standard_OutOfMemory.hxx>
 #include <Standard_OutOfRange.hxx>
-#endif
 
 #include <NCollection_DefineAlloc.hxx>
 #include <NCollection_StlIterator.hxx>
@@ -163,15 +161,9 @@ public:
                 myUpperBound                             (theUpper),
                 myDeletable                              (Standard_True)
   {
-#if !defined No_Exception && !defined No_Standard_RangeError
-    if (theUpper < theLower)
-      Standard_RangeError::Raise ("NCollection_Array1::Create");
-#endif
+    Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
     TheItemType* pBegin = new TheItemType[Length()];
-#if !defined No_Exception && !defined No_Standard_OutOfMemory
-    if (!pBegin)
-      Standard_OutOfMemory::Raise ("NCollection_Array1 : Allocation failed");
-#endif
+    Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
 
     myData = pBegin - theLower;
   }
@@ -183,10 +175,7 @@ public:
     myDeletable                                 (Standard_True)
   {
     TheItemType* pBegin = new TheItemType[Length()];
-#if !defined No_Exception && !defined No_Standard_OutOfMemory
-    if (!pBegin)
-      Standard_OutOfMemory::Raise ("NCollection_Array1 : Allocation failed");
-#endif
+    Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
     myData = pBegin - myLowerBound;
 
     *this = theOther;
@@ -200,10 +189,7 @@ public:
     myUpperBound                                (theUpper),
     myDeletable                                 (Standard_False)
   {
-#if !defined No_Exception && !defined No_Standard_RangeError
-    if (theUpper < theLower)
-      Standard_RangeError::Raise ("NCollection_Array1::Array1");
-#endif
+    Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
     myData = (TheItemType *) &theBegin - theLower; 
   }
 
@@ -242,10 +228,7 @@ public:
   {
     if (&theOther == this)
       return *this;
-#if !defined No_Exception && !defined No_Standard_DimensionMismatch
-    if (Length() != theOther.Length())
-      Standard_DimensionMismatch::Raise ("NCollection_Array1::operator=");
-#endif
+    Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array1::operator=");
     TheItemType * pMyItem        = &myData[myLowerBound];
     TheItemType * const pEndItem = &(theOther.myData)[theOther.myUpperBound];
     TheItemType * pItem          = &(theOther.myData)[theOther.myLowerBound];
@@ -286,10 +269,7 @@ public:
   //! Constant value access
   const TheItemType& Value (const Standard_Integer theIndex) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < myLowerBound || theIndex > myUpperBound)
-      Standard_OutOfRange::Raise ("NCollection_Array1::Value");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::Value");
     return myData[theIndex];
   }
 
@@ -300,10 +280,7 @@ public:
   //! Variable value access
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < myLowerBound || theIndex > myUpperBound)
-      Standard_OutOfRange::Raise ("NCollection_Array1::ChangeValue");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::ChangeValue");
     return myData[theIndex];
   }
 
@@ -315,10 +292,7 @@ public:
   void SetValue (const Standard_Integer theIndex,
                  const TheItemType&     theItem)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < myLowerBound || theIndex > myUpperBound)
-      Standard_OutOfRange::Raise ("NCollection_Array1::SetValue");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::SetValue");
     myData[theIndex] = theItem;
   }
 
index 8ef175d36eb5399a7abaa6204c12518cabd38bcd..c03181f25ee4a52c313aa8aa12e326f2253540e7 100644 (file)
 #ifndef NCollection_Array2_HeaderFile
 #define NCollection_Array2_HeaderFile
 
-#ifndef No_Exception
 #include <Standard_DimensionMismatch.hxx>
 #include <Standard_OutOfMemory.hxx>
 #include <Standard_OutOfRange.hxx>
-#endif
 
 #include <NCollection_DefineAlloc.hxx>
 
@@ -171,10 +169,7 @@ public:
   { 
     if (&theOther == this)
       return *this;
-#if !defined No_Exception && !defined No_Standard_DimensionMismatch
-    if (Length() != theOther.Length())
-      Standard_DimensionMismatch::Raise ("NCollection_Array2::operator=");
-#endif
+    Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array2::operator=");
     TheItemType * pMyItem  = myStart;
     TheItemType * pItem    = theOther.myStart;
     const Standard_Integer iSize = Length();
@@ -193,11 +188,8 @@ public:
   const TheItemType& Value (const Standard_Integer theRow,
                             const Standard_Integer theCol) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theRow < myLowerRow || theRow > myUpperRow ||
-        theCol < myLowerCol || theCol > myUpperCol)
-      Standard_OutOfRange::Raise ("NCollection_Array2::Value");
-#endif
+    Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
+                                  theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::Value");
     return myData[theRow][theCol];
   }
 
@@ -210,11 +202,8 @@ public:
   TheItemType& ChangeValue (const Standard_Integer theRow,
                             const Standard_Integer theCol)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theRow < myLowerRow || theRow > myUpperRow ||
-        theCol < myLowerCol || theCol > myUpperCol)
-      Standard_OutOfRange::Raise ("NCollection_Array2::ChangeValue");
-#endif
+    Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
+                                  theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::ChangeValue");
     return myData[theRow][theCol];
   }
 
@@ -228,11 +217,8 @@ public:
                  const Standard_Integer theCol,
                  const TheItemType&     theItem)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theRow < myLowerRow || theRow > myUpperRow ||
-        theCol < myLowerCol || theCol > myUpperCol)
-      Standard_OutOfRange::Raise ("NCollection_Array2::SetValue");
-#endif
+    Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
+                                  theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::SetValue");
     myData[theRow][theCol] = theItem;
   }
   
@@ -251,24 +237,15 @@ public:
   {
     const Standard_Integer iRowSize = myUpperCol - myLowerCol + 1;
     const Standard_Integer iColSize = myUpperRow - myLowerRow + 1;
-#if !defined No_Exception && !defined No_Standard_RangeError
-    if (iRowSize <= 0  || iColSize <= 0)
-      Standard_RangeError::Raise ("NCollection_Array2::Allocate");
-#endif
+    Standard_RangeError_Raise_if (iRowSize <= 0  || iColSize <= 0, "NCollection_Array2::Allocate");
     if (myDeletable) {
       // allocation of the data in the array
       myStart = new TheItemType[iRowSize * iColSize];
-#if !defined No_Exception && !defined No_Standard_OutOfMemory
-      if (!myStart)
-        Standard_OutOfMemory::Raise ("NCollection_Array2 : Allocation failed");
-#endif
+      Standard_OutOfMemory_Raise_if (!myStart, "NCollection_Array2 : Allocation failed");
     }
     // else myStart is set to the beginning of the given array
     TheItemType** pTable = new TheItemType* [iColSize];
-#if !defined No_Exception && !defined No_Standard_OutOfMemory
-    if (!pTable)
-      Standard_OutOfMemory::Raise ("NCollection_Array2 : Allocation failed");
-#endif
+    Standard_OutOfMemory_Raise_if (!pTable, "NCollection_Array2 : Allocation failed");
 
     // Items of pTable point to the '0'th items in the rows of the array
     TheItemType* pRow = myStart - myLowerCol;
index e0fc574676ab0ac134135996c381c1179490f4d4..eefdd2ae8f74e79e9b843129deaf83a6104a117a 100755 (executable)
@@ -177,7 +177,7 @@ protected: //! @name protected methods
     myIncrement  (theOther.myIncrement),
     myLength     (theOther.myLength),
     myCapacity   (GetCapacity(myIncrement) + theOther.myLength / theOther.myIncrement),
-    myNBlocks    (1 + (theOther.myLength - 1)/theOther.myIncrement),
+    myNBlocks    (theOther.myLength == 0 ? 0 : 1 + (theOther.myLength - 1)/theOther.myIncrement),
     myInitBlocks (theInitBlocks)
   {
     myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
index 73c6bb0bd73c22b898e0dc823f26c181f03d4268..f9040b341a2229da35e205c886eeac5377508d22 100644 (file)
@@ -56,8 +56,10 @@ class NCollection_DataMap : public NCollection_BaseMap
     DataMapNode (const TheKeyType&     theKey, 
                  const TheItemType&    theItem, 
                  NCollection_ListNode* theNext) :
-                   NCollection_TListNode<TheItemType> (theItem, theNext) 
-    { myKey = theKey; }
+      NCollection_TListNode<TheItemType> (theItem, theNext),
+      myKey(theKey)
+    {}
+
     //! Key
     const TheKeyType& Key (void) const
     { return myKey; }
@@ -94,28 +96,19 @@ class NCollection_DataMap : public NCollection_BaseMap
     //! Value inquiry
     const TheItemType& Value(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Value");  
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::Value");  
       return ((DataMapNode *) myNode)->Value();
     }
     //! Value change access
     TheItemType& ChangeValue(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::ChangeValue");  
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::ChangeValue");  
       return ((DataMapNode *) myNode)->ChangeValue();
     }
     //! Key
     const TheKeyType& Key (void) const
     { 
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Key");  
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_DataMap::Iterator::Key");  
       return ((DataMapNode *) myNode)->Key();
     }
   };
@@ -280,10 +273,7 @@ class NCollection_DataMap : public NCollection_BaseMap
   //! Find
   const TheItemType& Find(const TheKeyType& theKey) const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_DataMap::Find");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DataMap::Find");
     DataMapNode* p = (DataMapNode*) myData1[Hasher::HashCode(theKey,NbBuckets())];
     while (p) 
     {
@@ -325,10 +315,7 @@ class NCollection_DataMap : public NCollection_BaseMap
   //! ChangeFind
   TheItemType& ChangeFind (const TheKeyType& theKey)
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_DataMap::Find");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DataMap::Find");
     DataMapNode*  p = (DataMapNode*) myData1[Hasher::HashCode(theKey,NbBuckets())];
     while (p) 
     {
index ec33ee3821d0d1d46351675152324a82b44dd192..fc2bb1ebe09a463e3918105c81745cf63900c191 100644 (file)
 //function : HashCode_Proxy
 //purpose  : Function is required to call the global function HashCode.
 //=======================================================================
+
+template <class TheKeyType> 
+inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey, 
+                                        const Standard_Integer Upper)
+{
+  return HashCode (theKey, Upper);
+}
+
+//=======================================================================
+//function : IsEqual
+//purpose  : Default implementation of IsEqual via operator ==
+//=======================================================================
+
 template <class TheKeyType> 
-  static Standard_Integer HashCode_Proxy(const TheKeyType& theKey, 
-                                         const Standard_Integer Upper) {
-  return HashCode(theKey, Upper);
+inline Standard_Boolean IsEqual (const TheKeyType& theKey1, 
+                                 const TheKeyType& theKey2)
+{
+  return theKey1 == theKey2;
 }
 
 //=======================================================================
 //function : IsEqual_Proxy
 //purpose  : Function is required to call the global function IsEqual.
 //=======================================================================
+
 template <class TheKeyType> 
-  static Standard_Boolean IsEqual_Proxy(const TheKeyType& theKey1, 
-                                        const TheKeyType& theKey2) {
-  return IsEqual(theKey1, theKey2);
+inline Standard_Boolean IsEqual_Proxy (const TheKeyType& theKey1, 
+                                       const TheKeyType& theKey2)
+{
+  return IsEqual (theKey1, theKey2);
 }
 
 
index 2feea11a9b6dab5abbb48fd04a9cf79ac50c13fd..c3244464e9c05ff314a9b4c707b863abc8c2564f 100644 (file)
 //      Declaration of Array1 class managed by Handle
 
 #define DEFINE_HARRAY1(HClassName, _Array1Type_)                               \
-\
-class HClassName : public _Array1Type_,                                        \
-                   public MMgt_TShared {                                       \
+class HClassName : public _Array1Type_, public MMgt_TShared {                  \
  public:                                                                       \
    DEFINE_STANDARD_ALLOC                                                       \
    DEFINE_NCOLLECTION_ALLOC                                                    \
-   inline                     HClassName    (const Standard_Integer theLower,  \
-                                             const Standard_Integer theUpper); \
-   inline                     HClassName    (const _Array1Type_&);             \
-   inline const _Array1Type_& Array1        () const;                          \
-   inline _Array1Type_&       ChangeArray1  ();                                \
-   DEFINE_STANDARD_RTTI (HClassName)                                           \
+   HClassName (const Standard_Integer theLower,                                \
+               const Standard_Integer theUpper) :                              \
+     _Array1Type_ (theLower,theUpper)  {}                                      \
+   HClassName (const Standard_Integer theLower,                                \
+               const Standard_Integer theUpper,                                \
+               const _Array1Type_::value_type& theValue) :                     \
+     _Array1Type_ (theLower,theUpper)  { Init (theValue); }                    \
+   HClassName  (const _Array1Type_& theOther) : _Array1Type_(theOther) {}      \
+   const _Array1Type_& Array1 () const { return *this; }                       \
+   _Array1Type_& ChangeArray1 ()       { return *this; }                       \
+   DEFINE_STANDARD_RTTI (HClassName)                              \
 };                                                                             \
-                                                                               \
-DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)                              \
-                                                                               \
-inline HClassName::HClassName (const Standard_Integer theLower,                \
-                               const Standard_Integer theUpper) :              \
-       _Array1Type_ (theLower,theUpper),                                       \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline HClassName::HClassName (const _Array1Type_& theOther) :                 \
-       _Array1Type_(theOther),                                                 \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline const _Array1Type_& HClassName::Array1 () const                         \
-{ return * (const _Array1Type_ *) this; }                                      \
-                                                                               \
-inline _Array1Type_& HClassName::ChangeArray1 ()                               \
-{ return * (_Array1Type_ *) this; }                                            \
+DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)
 
 #define IMPLEMENT_HARRAY1(HClassName)                                          \
 IMPLEMENT_STANDARD_HANDLE  (HClassName, MMgt_TShared)                          \
index 32f759b548c1d88239287c59d01a644e6f7a96a4..2c47b13cb4b679615aa2430c9962ae5f80696a55 100644 (file)
 //      Declaration of Array2 class managed by Handle
 
 #define DEFINE_HARRAY2(HClassName, _Array2Type_)                               \
-\
-class HClassName : public _Array2Type_,                                        \
-                   public MMgt_TShared {                                       \
+class HClassName : public _Array2Type_, public MMgt_TShared {                  \
  public:                                                                       \
    DEFINE_STANDARD_ALLOC                                                       \
    DEFINE_NCOLLECTION_ALLOC                                                    \
-   inline                     HClassName  (const Standard_Integer theRowLower, \
-                                           const Standard_Integer theRowUpper, \
-                                           const Standard_Integer theColLower, \
-                                           const Standard_Integer theColUpper);\
-   inline                     HClassName  (const _Array2Type_&);               \
-   inline const _Array2Type_& Array2      () const;                            \
-   inline _Array2Type_&       ChangeArray2();                                  \
-   DEFINE_STANDARD_RTTI (HClassName)                                           \
+   HClassName  (const Standard_Integer theRowLow,                              \
+                const Standard_Integer theRowUpp,                              \
+                const Standard_Integer theColLow,                              \
+                const Standard_Integer theColUpp) :                            \
+     _Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp) {}              \
+   HClassName  (const Standard_Integer theRowLow,                              \
+                const Standard_Integer theRowUpp,                              \
+                const Standard_Integer theColLow,                              \
+                const Standard_Integer theColUpp,                              \
+                const _Array2Type_::value_type& theValue) :                    \
+     _Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp)                 \
+   { Init (theValue); }                                                        \
+   HClassName  (const _Array2Type_& theOther) : _Array2Type_(theOther) {}      \
+   const _Array2Type_& Array2 () const { return *this; }                       \
+   _Array2Type_& ChangeArray2 ()       { return *this; }                       \
+   DEFINE_STANDARD_RTTI (HClassName)                              \
 };                                                                             \
-                                                                               \
-DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)                              \
-                                                                               \
-inline HClassName::HClassName (const Standard_Integer theRowLow,               \
-                               const Standard_Integer theRowUpp,               \
-                               const Standard_Integer theColLow,               \
-                               const Standard_Integer theColUpp) :             \
-       _Array2Type_ (theRowLow, theRowUpp, theColLow, theColUpp),              \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline HClassName::HClassName (const _Array2Type_& theOther) :                 \
-       _Array2Type_(theOther),                                                 \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline const _Array2Type_& HClassName::Array2 () const                         \
-{ return * (const _Array2Type_ *) this; }                                      \
-                                                                               \
-inline _Array2Type_& HClassName::ChangeArray2 ()                               \
-{ return * (_Array2Type_ *) this; }                                            \
+DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)
 
 #define IMPLEMENT_HARRAY2(HClassName)                                          \
 IMPLEMENT_STANDARD_HANDLE  (HClassName, MMgt_TShared)                          \
index 3a81f1fb24c102dfeac1d83ebc93d6d3d5b73101..cc2a2d6a3224e478fd3509d2dfca97153e29f4e9 100644 (file)
 //      Declaration of Sequence class managed by Handle
 
 #define DEFINE_HSEQUENCE(HClassName, _SequenceType_)                           \
-\
-class HClassName : public _SequenceType_,                                      \
-                   public MMgt_TShared {                                       \
+DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)                              \
+class HClassName : public _SequenceType_, public MMgt_TShared {                \
  public:                                                                       \
    DEFINE_STANDARD_ALLOC                                                       \
    DEFINE_NCOLLECTION_ALLOC                                                    \
-   inline                       HClassName ();                                 \
-   inline                       HClassName (const _SequenceType_&);            \
-   inline const _SequenceType_& Sequence        () const;                      \
-   inline _SequenceType_&       ChangeSequence  ();                            \
-   DEFINE_STANDARD_RTTI (HClassName)                                           \
-};                                                                             \
-                                                                               \
-DEFINE_STANDARD_HANDLE (HClassName, MMgt_TShared)                              \
-                                                                               \
-inline HClassName::HClassName () :                                             \
-       _SequenceType_(),                                                       \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline HClassName::HClassName (const _SequenceType_& anOther) :                \
-       _SequenceType_(anOther),                                                \
-       MMgt_TShared() {}                                                       \
-                                                                               \
-inline const _SequenceType_& HClassName::Sequence () const                     \
-{ return * (const _SequenceType_ *) this; }                                    \
-                                                                               \
-inline _SequenceType_& HClassName::ChangeSequence ()                           \
-{ return * (_SequenceType_ *) this; }                                          \
+   HClassName () {}                                                            \
+   HClassName (const _SequenceType_& theOther) : _SequenceType_(theOther) {}   \
+   const _SequenceType_& Sequence () const { return *this; }                   \
+   void Append (const _SequenceType_::value_type& theItem) {                   \
+     _SequenceType_::Append (theItem);                                         \
+   }                                                                           \
+   void Append (_SequenceType_& theSequence) {                                 \
+     _SequenceType_::Append (theSequence);                                     \
+   }                                                                           \
+   _SequenceType_& ChangeSequence ()       { return *this; }                   \
+   void Append (const Handle(HClassName)& theOther) {                          \
+     _SequenceType_::Append (theOther->ChangeSequence());                      \
+   }                                                                           \
+   DEFINE_STANDARD_RTTI (HClassName)                              \
+};
 
 #define IMPLEMENT_HSEQUENCE(HClassName)                                        \
 IMPLEMENT_STANDARD_HANDLE  (HClassName, MMgt_TShared)                          \
index e450ddcb95e3df55acb176421d0561a243ea0ec9..6f2a59ab37ef42a8c88c1e09a56ebc94ea85770d 100644 (file)
@@ -50,10 +50,10 @@ class NCollection_DoubleMap : public NCollection_BaseMap
                    const TheKey2Type&    theKey2, 
                    NCollection_ListNode* theNext1, 
                    NCollection_ListNode* theNext2) :
-                   NCollection_TListNode<TheKey2Type> (theKey2, theNext1)
+      NCollection_TListNode<TheKey2Type> (theKey2, theNext1),
+      myKey1(theKey1),
+      myNext2((DoubleMapNode*)theNext2)
     { 
-      myKey1 = theKey1;
-      myNext2 = (DoubleMapNode *) theNext2;
     }
     //! Key1
     const TheKey1Type& Key1 (void)
@@ -97,28 +97,19 @@ class NCollection_DoubleMap : public NCollection_BaseMap
     //! Key1 inquiry
     const TheKey1Type& Key1(void) const
     {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-         Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Key1");
-#endif
+      Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Key1");
       return ((DoubleMapNode *) myNode)->Key1();
     }
     //! Key2 inquiry
     const TheKey2Type& Key2(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-         Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Key2");
-#endif
+      Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Key2");
       return ((DoubleMapNode *) myNode)->Key2();
     }
     //! Value access
     const TheKey2Type& Value(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-         Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Iterator::Value");
-#endif
+      Standard_NoSuchObject_Raise_if (!More(), "NCollection_DoubleMap::Iterator::Value");
       return ((DoubleMapNode *) myNode)->Value();
     }
     //! Value change access - denied
@@ -402,10 +393,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
   //! Find1
   const TheKey2Type& Find1(const TheKey1Type& theKey1) const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Find1");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find1");
     DoubleMapNode * pNode1 = 
       (DoubleMapNode *) myData1[Hasher1::HashCode(theKey1,NbBuckets())];
     while (pNode1)
@@ -421,10 +409,7 @@ class NCollection_DoubleMap : public NCollection_BaseMap
   //! Find2
   const TheKey1Type& Find2(const TheKey2Type& theKey2) const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_DoubleMap::Find2");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_DoubleMap::Find2");
     DoubleMapNode * pNode2 = 
       (DoubleMapNode *) myData2[Hasher2::HashCode(theKey2,NbBuckets())];
     while (pNode2)
index 27f7a0f3364e417370432bf9edf481583018a2b1..0654b4cef77cea8f2df61b9d6745125901988c0c 100644 (file)
@@ -23,9 +23,7 @@
 #include <NCollection_StlIterator.hxx>
 #include <NCollection_DefaultHasher.hxx>
 
-#if !defined No_Exception && !defined No_Standard_OutOfRange
 #include <Standard_OutOfRange.hxx>
-#endif
 
 /**
  * Purpose:     An indexed map is used  to store keys and to  bind
@@ -62,11 +60,11 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
                         const TheItemType&     theItem,
                         NCollection_ListNode*  theNext1, 
                         NCollection_ListNode*  theNext2) :
-                          NCollection_TListNode<TheItemType>(theItem,theNext1)
+      NCollection_TListNode<TheItemType>(theItem,theNext1),
+      myKey1(theKey1),
+      myKey2(theKey2),
+      myNext2((IndexedDataMapNode*)theNext2)
     { 
-      myKey1 = theKey1;
-      myKey2 = theKey2;
-      myNext2 = (IndexedDataMapNode *) theNext2;
     }
     //! Key1
     TheKeyType& Key1 (void)
@@ -116,28 +114,19 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
     //! Value access
     const TheItemType& Value(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::Value");
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::Value");
       return myNode->Value();
     }
     //! ChangeValue access
     TheItemType& ChangeValue(void) const
     {  
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::Iterator::ChangeValue");
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::ChangeValue");
       return myNode->ChangeValue();
     }
     //! Key
     const TheKeyType& Key() const
     {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_DataMap::Iterator::Key");
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedDataMap::Iterator::Key");
       return myNode->Key1();
     }
     //! Performs comparison of two iterators.
@@ -302,10 +291,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
                    const TheKeyType&      theKey1,
                    const TheItemType&     theItem)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < 1 || theIndex > Extent())
-      Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::Substitute");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > Extent(), "NCollection_IndexedDataMap::Substitute");
+
     IndexedDataMapNode * p;
     // check if theKey1 is not already in the map
     Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
@@ -349,10 +336,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! RemoveLast
   void RemoveLast (void)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (Extent() == 0)
-      Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::RemoveLast");
-#endif
+    Standard_OutOfRange_Raise_if (Extent() == 0, "NCollection_IndexedDataMap::RemoveLast");
+
     IndexedDataMapNode * p, * q;
     // Find the node for the last index and remove it
     Standard_Integer iK2 = ::HashCode (Extent(), NbBuckets());
@@ -389,10 +374,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! FindKey
   const TheKeyType& FindKey (const Standard_Integer theKey2) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theKey2 < 1 || theKey2 > Extent())
-      Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindKey");
-#endif
+    Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::FindKey");
+
     IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
     if (aNode == NULL)
     {
@@ -404,10 +387,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! FindFromIndex
   const TheItemType& FindFromIndex (const Standard_Integer theKey2) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theKey2 < 1 || theKey2 > Extent())
-      Standard_OutOfRange::Raise ("NCollection_IndexedDataMap::FindFromIndex");
-#endif
+    Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::FindFromIndex");
+
     IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
     if (aNode == NULL)
     {
@@ -423,10 +404,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! ChangeFromIndex
   TheItemType& ChangeFromIndex (const Standard_Integer theKey2)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theKey2 < 1 || theKey2 > Extent())
-      Standard_OutOfRange::Raise("NCollection_IndexedDataMap::ChangeFromIndex");
-#endif
+    Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::ChangeFromIndex");
+
     IndexedDataMapNode* aNode = nodeFromIndex (theKey2);
     if (aNode == NULL)
     {
@@ -457,10 +436,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! FindFromKey
   const TheItemType& FindFromKey(const TheKeyType& theKey1) const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_IndexedDataMap::FindFromKey");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::FindFromKey");
+
     IndexedDataMapNode * pNode1 = 
       (IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
     while (pNode1)
@@ -476,10 +453,8 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
   //! ChangeFromKey
   TheItemType& ChangeFromKey (const TheKeyType& theKey1)
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise("NCollection_IndexedDataMap::ChangeFromKey");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::ChangeFromKey");
+
     IndexedDataMapNode * pNode1 = 
       (IndexedDataMapNode *) myData1[Hasher::HashCode(theKey1,NbBuckets())];
     while (pNode1)
index 5735c545d812470a8f012d2cfb1d34f7207c5fc5..117732eeef88f8a3b79608516d3df89b59a59cfc 100644 (file)
@@ -24,9 +24,7 @@
 
 #include <NCollection_DefaultHasher.hxx>
 
-#if !defined No_Exception && !defined No_Standard_OutOfRange
 #include <Standard_OutOfRange.hxx>
-#endif
 
 /**
  * Purpose:     An indexed map is used to  store  keys and to bind
@@ -53,10 +51,10 @@ class NCollection_IndexedMap : public NCollection_BaseMap
                     const Standard_Integer theKey2, 
                     NCollection_ListNode*  theNext1, 
                     NCollection_ListNode*  theNext2) :
-                      NCollection_TListNode<TheKeyType> (theKey1, theNext1)
+      NCollection_TListNode<TheKeyType> (theKey1, theNext1),
+      myKey2(theKey2),
+      myNext2((IndexedMapNode*)theNext2)
     { 
-      myKey2 = theKey2;
-      myNext2 = (IndexedMapNode *) theNext2;
     }
     //! Key1
     TheKeyType& Key1 (void)
@@ -103,10 +101,7 @@ class NCollection_IndexedMap : public NCollection_BaseMap
     //! Value access
     const TheKeyType& Value(void) const
     {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise("NCollection_IndexedMap::Iterator::Value");
-#endif
+      Standard_NoSuchObject_Raise_if(!More(), "NCollection_IndexedMap::Iterator::Value");
       return myMap->FindKey(myIndex);
     }
     //! Value change access denied - use Substitute
@@ -267,10 +262,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
   void Substitute (const Standard_Integer theIndex,
                    const TheKeyType& theKey1)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < 1 || theIndex > Extent())
-      Standard_OutOfRange::Raise ("NCollection_IndexedMap::Substitute");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > Extent(), "NCollection_IndexedMap::Substitute");
+
     IndexedMapNode * p;
     // check if theKey1 is not already in the map
     Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
@@ -313,10 +306,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
   //! RemoveLast
   void RemoveLast (void)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (Extent() == 0)
-      Standard_OutOfRange::Raise ("NCollection_IndexedMap::RemoveLast");
-#endif
+    Standard_OutOfRange_Raise_if (Extent() == 0, "NCollection_IndexedMap::RemoveLast");
+
     IndexedMapNode * p, * q;
     // Find the node for the last index and remove it
     Standard_Integer iK2 = ::HashCode (Extent(), NbBuckets());
@@ -353,10 +344,8 @@ class NCollection_IndexedMap : public NCollection_BaseMap
   //! FindKey
   const TheKeyType& FindKey (const Standard_Integer theKey2) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theKey2 < 1 || theKey2 > Extent())
-      Standard_OutOfRange::Raise ("NCollection_IndexedMap::FindKey");
-#endif
+    Standard_OutOfRange_Raise_if (theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedMap::FindKey");
+
     IndexedMapNode * pNode2 =
       (IndexedMapNode *) myData2[::HashCode(theKey2,NbBuckets())];
     while (pNode2)
index 18dc7b3077d563c327e7b0458ffaf88da093dbfb..6ef0b32de5b9e724bf3db569c4b9b7637504ef58 100644 (file)
@@ -19,9 +19,7 @@
 #include <NCollection_TListIterator.hxx>
 #include <NCollection_StlIterator.hxx>
 
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
 #include <Standard_NoSuchObject.hxx>
-#endif
 
 /**
  * Purpose:      Simple list to link  items together keeping the first 
@@ -102,23 +100,31 @@ public:
   //! First item
   const TheItemType& First (void) const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_List::First");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::First");
     return ((const ListNode *) PFirst())->Value();
   }
 
+  //! First item (non-const)
+  TheItemType& First (void)
+  {
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::First");
+    return ((ListNode *) PFirst())->ChangeValue();
+  }
+
   //! Last item
   const TheItemType& Last (void) const
   { 
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (IsEmpty())
-      Standard_NoSuchObject::Raise ("NCollection_List::Last");
-#endif
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::Last");
     return ((const ListNode *) PLast())->Value();
   }
 
+  //! Last item (non-const)
+  TheItemType& Last (void)
+  { 
+    Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_List::Last");
+    return ((ListNode *) PLast())->ChangeValue();
+  }
+
   //! Append one item at the end
   TheItemType& Append (const TheItemType& theItem)
   { 
@@ -249,10 +255,8 @@ public:
     else
     {
       // No - this list has different memory scope
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!theIter.More())
-        Standard_NoSuchObject::Raise ("NCollection_List::InsertAfter");
-#endif
+      Standard_NoSuchObject_Raise_if (!theIter.More(), "NCollection_List::InsertAfter");
+
       Iterator anIter;
       anIter.myPrevious = theIter.myCurrent;
       anIter.myCurrent = theIter.myCurrent->Next();
index fd8866b24cac7ac6637bf33ffeeee8bc3102a561..f12a15095d89d912eb4a94918d2439d72cd0395b 100644 (file)
 #include <NCollection_DefaultHasher.hxx>
 
 #include <Standard_ImmutableObject.hxx>
-
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
 #include <Standard_NoSuchObject.hxx>
-#endif
 
 /**
  * Purpose:     Single hashed Map. This  Map is used  to store and
@@ -96,10 +93,7 @@ class NCollection_Map : public NCollection_BaseMap
     //! Value inquiry
     const TheKeyType& Value(void) const
     {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise ("NCollection_Map::Iterator::Value");  
-#endif
+      Standard_NoSuchObject_Raise_if (!More(), "NCollection_Map::Iterator::Value");  
       return ((MapNode *) myNode)->Value();
     }
     //! Value change access - denied
@@ -109,12 +103,9 @@ class NCollection_Map : public NCollection_BaseMap
       return * (TheKeyType *) NULL; // For compiler
     }
     //! Key
-    const TheKeyType& Key (void)
+    const TheKeyType& Key (void) const
     { 
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-      if (!More())
-        Standard_NoSuchObject::Raise ("NCollection_Map::Iterator::Key");  
-#endif
+      Standard_NoSuchObject_Raise_if (!More(), "NCollection_Map::Iterator::Key");  
       return ((MapNode *) myNode)->Value();
     }
   };
index 2dd5c39b32cf883e55b0e870440bf773883d0f76..98239c0d36bf5c42973bf439c9789094b338a84e 100644 (file)
 #include <NCollection_BaseSequence.hxx>
 #include <NCollection_StlIterator.hxx>
 
-#ifndef No_Exception
 #include <Standard_OutOfRange.hxx>
 #include <Standard_NoSuchObject.hxx>
-#endif
 
 /**
  * Purpose:     Definition of a sequence of elements indexed by
@@ -252,10 +250,7 @@ public:
   void InsertAfter (const Standard_Integer  theIndex, 
                     const TheItemType&      theItem)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex < 0 || theIndex > mySize)
-      Standard_OutOfRange::Raise ("NCollection_Sequence::InsertAfter");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > mySize, "NCollection_Sequence::InsertAfter");
     PInsertAfter (theIndex, new (this->myAllocator) Node (theItem));
   }
 
@@ -269,50 +264,36 @@ public:
   //! First item access
   const TheItemType& First () const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (mySize == 0)
-      Standard_NoSuchObject::Raise ("NCollection_Sequence::First");
-#endif
+    Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::First");
     return ((const Node *) myFirstItem) -> Value();
   }
 
   //! First item access
   TheItemType& ChangeFirst()
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (mySize == 0)
-      Standard_NoSuchObject::Raise ("NCollection_Sequence::ChangeFirst");
-#endif
+    Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::ChangeFirst");
     return ((Node* )myFirstItem)->ChangeValue();
   }
 
   //! Last item access
   const TheItemType& Last () const
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (mySize == 0)
-      Standard_NoSuchObject::Raise ("NCollection_Sequence::Last");
-#endif
+    Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::Last");
     return ((const Node *) myLastItem) -> Value();
   }
 
   //! Last item access
   TheItemType& ChangeLast()
   {
-#if !defined No_Exception && !defined No_Standard_NoSuchObject
-    if (mySize == 0)
-      Standard_NoSuchObject::Raise ("NCollection_Sequence::ChangeLast");
-#endif
+    Standard_NoSuchObject_Raise_if (mySize == 0, "NCollection_Sequence::ChangeLast");
     return ((Node* )myLastItem)->ChangeValue();
   }
 
   //! Constant item access by theIndex
   const TheItemType& Value (const Standard_Integer theIndex) const
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex <= 0 || theIndex > mySize)
-      Standard_OutOfRange::Raise ("NCollection_Sequence::Value");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "NCollection_Sequence::Value");
+
     NCollection_Sequence * const aLocalTHIS = (NCollection_Sequence *) this;
     aLocalTHIS -> myCurrentItem  = Find (theIndex);
     aLocalTHIS -> myCurrentIndex = theIndex;
@@ -326,10 +307,8 @@ public:
   //! Variable item access by theIndex
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
-#if !defined No_Exception && !defined No_Standard_OutOfRange
-    if (theIndex <= 0 || theIndex > mySize)
-      Standard_OutOfRange::Raise ("NCollection_Sequence::ChangeValue");
-#endif
+    Standard_OutOfRange_Raise_if (theIndex <= 0 || theIndex > mySize, "NCollection_Sequence::ChangeValue");
+
     myCurrentItem  = Find (theIndex);
     myCurrentIndex = theIndex;
     return ((Node *) myCurrentItem) -> ChangeValue();
index b2e548ddcae9ab25a5a277a131eb94a7c423bca0..d3927ded5d299fc4f2407271a686a2368f4c921a 100644 (file)
@@ -43,10 +43,16 @@ template <class TheItemType> class NCollection_TListIterator
     myPrevious = myCurrent;
     myCurrent = myCurrent->Next();
   }
+
   //! Constant Value access
   const TheItemType& Value (void) const
   { return ((const NCollection_TListNode<TheItemType>*) myCurrent)->Value(); }
-  //! Variable Value access
+
+  //! Non-const Value access
+  TheItemType& Value (void)
+  { return ((NCollection_TListNode<TheItemType>*) myCurrent)->ChangeValue(); }
+
+  //! Non-const Value access
   TheItemType& ChangeValue (void) const
   { return ((NCollection_TListNode<TheItemType> *)myCurrent)->ChangeValue(); }
 };
index 368fd9cdd90b39e80eb28b61772bc0cff56ec0b8..2bbe687fa3fc6eba8e05bb7d4c3edc6547cceed3 100644 (file)
@@ -29,7 +29,7 @@ template <class TheItemType> class NCollection_TListNode
   //! Constructor
   NCollection_TListNode (const TheItemType& theItem,
                          NCollection_ListNode* theNext=NULL) :
-    NCollection_ListNode  (theNext) { myValue = theItem; }
+    NCollection_ListNode  (theNext), myValue(theItem) { }
   //! Constant value access
   const TheItemType& Value () const { return myValue; }
   //! Variable value access
index 84ed2cecd26e8c4dca1bc9cf5c551b6507d40395..f30eea10140c98cc62f54a37fdc8604be652afbc 100644 (file)
@@ -16,9 +16,9 @@
 #ifndef Prs3d_NListOfSequenceOfPnt_HeaderFile
 #define Prs3d_NListOfSequenceOfPnt_HeaderFile
 
-#include <TColgp_SequenceOfPnt.hxx>
+#include <TColgp_HSequenceOfPnt.hxx>
 #include <NCollection_List.hxx>
 
-typedef NCollection_List<TColgp_SequenceOfPnt> Prs3d_NListOfSequenceOfPnt;
+typedef NCollection_List<Handle(TColgp_HSequenceOfPnt)> Prs3d_NListOfSequenceOfPnt;
 
 #endif
index 7837dff4dd73c1b5abe9e1a74982a5f1f2bd32ff..3c2131ccda14108957399891ae4534be4c14b343 100755 (executable)
@@ -176,7 +176,6 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
   Prs3d_NListOfSequenceOfPnt aWireCurves;
   Prs3d_NListOfSequenceOfPnt aFreeCurves;
   Prs3d_NListOfSequenceOfPnt anUnFreeCurves;
-  TColgp_SequenceOfPnt       aShapePoints;
 
   const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
   const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
@@ -299,17 +298,16 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
     for (anIt.Init (anUIsoCurves); anIt.More(); anIt.Next())
     {
-      aNbVertices += anIt.Value().Length();
+      aNbVertices += anIt.Value()->Length();
     }
     Handle(Graphic3d_ArrayOfPolylines) anUIsoArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
     for (anIt.Init (anUIsoCurves); anIt.More(); anIt.Next())
     {
-      TColgp_SequenceOfPnt aPoints;
-      aPoints.Assign (anIt.Value());
-      anUIsoArray->AddBound (aPoints.Length());
-      for (Standard_Integer anI = 1; anI <= aPoints.Length(); ++anI)
+      const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+      anUIsoArray->AddBound (aPoints->Length());
+      for (Standard_Integer anI = 1; anI <= aPoints->Length(); ++anI)
       {
-        anUIsoArray->AddVertex (aPoints.Value (anI));
+        anUIsoArray->AddVertex (aPoints->Value (anI));
       }
     }
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
@@ -317,23 +315,23 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     aGroup->AddPrimitiveArray (anUIsoArray);
   }
 
+  // NOTE: THIS BLOCK WILL NEVER EXECUTE AS aVIsoCurves IS NOT FILLED!!
   if (aVIsoCurves.Size() > 0)
   {
     aNbBounds = aVIsoCurves.Size();
     Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
     for (anIt.Init (aVIsoCurves); anIt.More(); anIt.Next())
     {
-      aNbVertices += anIt.Value().Length();
+      aNbVertices += anIt.Value()->Length();
     }
     Handle(Graphic3d_ArrayOfPolylines) VIsoArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
     for (anIt.Init (aVIsoCurves); anIt.More(); anIt.Next())
     {
-      TColgp_SequenceOfPnt aPoints;
-      aPoints.Assign (anIt.Value());
-      VIsoArray->AddBound (aPoints.Length());
-      for (int anI = 1; anI <= aPoints.Length(); anI++)
+      const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+      VIsoArray->AddBound (aPoints->Length());
+      for (int anI = 1; anI <= aPoints->Length(); anI++)
       {
-        VIsoArray->AddVertex (aPoints.Value (anI));
+        VIsoArray->AddVertex (aPoints->Value (anI));
       }
     }
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
@@ -445,14 +443,14 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       try
       {
         OCC_CATCH_SIGNALS
-        TColgp_SequenceOfPnt aPoints;
-        if (!AddPolygon (anEdge, aDeflection, aPoints))
+        const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
+        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
             BRepAdaptor_Curve aCurve (anEdge);
             myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer,
-                             aPoints, Standard_False);
+                             aPoints->ChangeSequence(), Standard_False);
             aWireCurves.Append (aPoints);
           }
         }
@@ -481,14 +479,14 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
         try
         {
           OCC_CATCH_SIGNALS
-          TColgp_SequenceOfPnt aPoints;
-          if (!AddPolygon (anEdge, aDeflection, aPoints))
+          const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
+          if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
           {
             if (BRep_Tool::IsGeometric (anEdge))
             {
               BRepAdaptor_Curve aCurve (anEdge);
               myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer,
-                               aPoints, Standard_False);
+                               aPoints->ChangeSequence(), Standard_False);
               aFreeCurves.Append (aPoints);
             }
           }
@@ -516,13 +514,13 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       try
       {
         OCC_CATCH_SIGNALS
-        TColgp_SequenceOfPnt aPoints;
-        if (!AddPolygon (anEdge, aDeflection, aPoints))
+        const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
+        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
             BRepAdaptor_Curve aCurve (anEdge);
-            myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer, aPoints, Standard_False);
+            myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer, aPoints->ChangeSequence(), Standard_False);
             anUnFreeCurves.Append (aPoints);
           }
         }
@@ -546,17 +544,16 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
     for (anIt.Init (aWireCurves); anIt.More(); anIt.Next())
     {
-      aNbVertices += anIt.Value().Length();
+      aNbVertices += anIt.Value()->Length();
     }
     Handle(Graphic3d_ArrayOfPolylines) WireArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
     for (anIt.Init (aWireCurves); anIt.More(); anIt.Next())
     {
-      TColgp_SequenceOfPnt aPoints;
-      aPoints.Assign (anIt.Value());
-      WireArray->AddBound (aPoints.Length());
-      for (anI = 1; anI <= aPoints.Length(); ++anI)
+      const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+      WireArray->AddBound (aPoints->Length());
+      for (anI = 1; anI <= aPoints->Length(); ++anI)
       {
-        WireArray->AddVertex (aPoints.Value (anI));
+        WireArray->AddVertex (aPoints->Value (anI));
       }
     }
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
@@ -570,17 +567,16 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
     for (anIt.Init (aFreeCurves); anIt.More(); anIt.Next())
     {
-      aNbVertices += anIt.Value().Length();
+      aNbVertices += anIt.Value()->Length();
     }
     Handle(Graphic3d_ArrayOfPolylines) aFreeArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
     for (anIt.Init(aFreeCurves); anIt.More(); anIt.Next())
     {
-      TColgp_SequenceOfPnt aPoints;
-      aPoints.Assign (anIt.Value());
-      aFreeArray->AddBound (aPoints.Length());
-      for (anI = 1; anI <= aPoints.Length(); ++anI)
+      const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+      aFreeArray->AddBound (aPoints->Length());
+      for (anI = 1; anI <= aPoints->Length(); ++anI)
       {
-        aFreeArray->AddVertex (aPoints.Value (anI));
+        aFreeArray->AddVertex (aPoints->Value (anI));
       }
     }  
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
@@ -594,17 +590,16 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
     for (anIt.Init (anUnFreeCurves); anIt.More(); anIt.Next())
     {
-      aNbVertices += anIt.Value().Length();
+      aNbVertices += anIt.Value()->Length();
     }
     Handle(Graphic3d_ArrayOfPolylines) anUnFreeArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
     for (anIt.Init (anUnFreeCurves); anIt.More(); anIt.Next())
     {
-      TColgp_SequenceOfPnt aPoints;
-      aPoints.Assign (anIt.Value());
-      anUnFreeArray->AddBound (aPoints.Length());
-      for (anI = 1; anI <= aPoints.Length(); ++anI)
+      const Handle(TColgp_HSequenceOfPnt)& aPoints = anIt.Value();
+      anUnFreeArray->AddBound (aPoints->Length());
+      for (anI = 1; anI <= aPoints->Length(); ++anI)
       {
-        anUnFreeArray->AddVertex (aPoints.Value (anI));
+        anUnFreeArray->AddVertex (aPoints->Value (anI));
       }
     }
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
@@ -613,6 +608,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
   }
 
   // Points
+  TColgp_SequenceOfPnt aShapePoints;
   for (aTool.InitVertex(); aTool.MoreVertex(); aTool.NextVertex())
   {
     aShapePoints.Append (BRep_Tool::Pnt (aTool.GetVertex()));
index 3277937074ce1ec97c0b17611e550d78b06031e6..616c76b89d0a0686f7e3d2ec891080d58aee3164 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <gp_Pnt.hxx>
 
+#include <NCollection_Vector.hxx>
+
 #define ItemType gp_Pnt
 #define Key1Type Standard_Real
 #define Key2Type Standard_Integer
@@ -728,6 +730,32 @@ static Standard_Integer QANColTestList(Draw_Interpretor& di, Standard_Integer ar
   return 0;
 }
 
+//=======================================================================
+//function : QANColTestVector
+//purpose  : 
+//=======================================================================
+static Standard_Integer QANColTestVector (Draw_Interpretor&, Standard_Integer, const char**)
+{
+  // test method Append and copying of empty vector
+  NCollection_Vector<int> aVec;
+  NCollection_Vector<int> aVec2 (aVec);
+  NCollection_Vector<int> aVec3;
+  aVec3 = aVec;
+
+  aVec.Append(5);
+  if (aVec(0) != 5)
+    std::cout << "Error: wrong value in original vector!" << endl;
+  aVec2.Append(5);
+  if (aVec2(0) != 5)
+    std::cout << "Error: wrong value in copy-constructed vector!" << endl;
+  aVec3.Append(5);
+  if (aVec3(0) != 5)
+    std::cout << "Error: wrong value in copied vector!" << endl;
+  std::cout << "Test OK" << endl;
+
+  return 0;
+}
+
 //=======================================================================
 //function : QANColTestSequence
 //purpose  : 
@@ -756,6 +784,5 @@ void QANCollection::CommandsTest(Draw_Interpretor& theCommands) {
   theCommands.Add("QANColTestIndexedDataMap", "QANColTestIndexedDataMap", __FILE__, QANColTestIndexedDataMap, group);  
   theCommands.Add("QANColTestList",           "QANColTestList",           __FILE__, QANColTestList,           group);  
   theCommands.Add("QANColTestSequence",       "QANColTestSequence",       __FILE__, QANColTestSequence,       group);  
-
-  return;
+  theCommands.Add("QANColTestVector",         "QANColTestVector",         __FILE__, QANColTestVector,         group);  
 }
index 0e75a62daa430fbc35d084eb3a908ee40d49ef1f..e3e59f51e37fc37a75408f7d1b5a766d8725e1df 100755 (executable)
@@ -1,2 +1 @@
-SelectMgr_DataMapOfObjectOwners.hxx
 SelectMgr_CompareResults.hxx
\ No newline at end of file
diff --git a/src/SelectMgr/SelectMgr_DataMapOfObjectOwners.hxx b/src/SelectMgr/SelectMgr_DataMapOfObjectOwners.hxx
deleted file mode 100644 (file)
index 8d0c465..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Created on: 2003-10-16
-// Created by: Alexander Solovyov
-// Copyright (c) 2003-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.
-
-#ifndef _SelectMgr_DataMapOfObjectOwners_HeaderFile
-#define _SelectMgr_DataMapOfObjectOwners_HeaderFile
-
-#include <NCollection_DataMap.hxx>
-#include <SelectMgr_SelectableObject.hxx>
-#include <SelectMgr_SequenceOfOwner.hxx>
-
-inline Standard_Boolean IsEqual (const Handle(SelectMgr_SelectableObject)& theH1,
-                                const Handle(SelectMgr_SelectableObject)& theH2)
-{
-  return (theH1 == theH2);
-}
-
-typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), SelectMgr_SequenceOfOwner> SelectMgr_DataMapOfObjectOwners;
-typedef SelectMgr_DataMapOfObjectOwners::Iterator SelectMgr_DataMapIteratorOfMapOfObjectOwners;
-
-#endif
index 53422e24f2b3d797abca29c146a6a62ab39f1b1d..dfe4c045b4ca5d6eff3c5b7f2d30713dd4614557 100644 (file)
@@ -324,8 +324,9 @@ void StdPrs_WFDeflectionRestrictedFace::Add
        GeomAdaptor_Curve GC(BC);
        FindLimits(GC, aLimit,b1, b2);
        if (b2-b1>Precision::Confusion()) {
-         TColgp_SequenceOfPnt Points;
-         StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, Standard_False);
+         Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt;
+         StdPrs_DeflectionCurve::Add (aPresentation, GC, b1, b2, Deflection, 
+                                       Points->ChangeSequence(), anAngle, Standard_False);
          Curves.Append(Points);
        }
       }
@@ -336,8 +337,9 @@ void StdPrs_WFDeflectionRestrictedFace::Add
          anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
        FindLimits(anIso, aLimit,b1, b2);
        if (b2-b1>Precision::Confusion()) {
-         TColgp_SequenceOfPnt Points;
-         StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, Standard_False);
+         Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt;
+         StdPrs_DeflectionCurve::Add (aPresentation, anIso, b1, b2, Deflection, 
+                                       Points->ChangeSequence(), anAngle, Standard_False);
          Curves.Append(Points);
        }
       }
index c97b33ac73b8ac7586a294faf78ef96818a5692f..f84c611987f7ceaccce6bbefd702c26efeb54753 100755 (executable)
@@ -176,7 +176,7 @@ void StdPrs_WFRestrictedFace::Add
       if(b1 == RealFirst() || b2 == RealLast())
         continue;
 
-      TColgp_SequenceOfPnt aPoints;
+      Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt;
       if (!aGeomBSurface.IsNull())
       {
         if (anIsoBuild.IsXLine(anI))
@@ -186,7 +186,8 @@ void StdPrs_WFRestrictedFace::Add
 
         //Note that the isos are the part of the shape, it will be displayed after a computation the whole shape
         //NbPoints = 30 - default parameter for computation of such curves
-        StdPrs_Curve::Add(thePresentation,GeomAdaptor_Curve(aBCurve), b1, b2, theDeflection, aPoints, 30, Standard_False);
+        StdPrs_Curve::Add (thePresentation, GeomAdaptor_Curve(aBCurve), b1, b2, theDeflection, 
+                           aPoints->ChangeSequence(), 30, Standard_False);
         theCurves.Append(aPoints);
       }
       else
@@ -195,7 +196,8 @@ void StdPrs_WFRestrictedFace::Add
           anIsoCurve.Load(GeomAbs_IsoU,anIsoCoord,b1,b2);
         else
           anIsoCurve.Load(GeomAbs_IsoV,anIsoCoord,b1,b2);
-        StdPrs_Curve::Add(thePresentation,anIsoCurve, theDeflection, theDrawer, aPoints, Standard_False);
+        StdPrs_Curve::Add (thePresentation, anIsoCurve, theDeflection, theDrawer, 
+                           aPoints->ChangeSequence(), Standard_False);
         theCurves.Append(aPoints);
       }
     }
index a1e2ecc2701cfd30263ae5aa6e0f029fba836e49..2f1c721fbd1ec5b9811d927f0854e70abae97f21 100644 (file)
@@ -143,7 +143,6 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
     Prs3d_NListOfSequenceOfPnt freeCurves; 
     Prs3d_NListOfSequenceOfPnt UIsoCurves; 
     Prs3d_NListOfSequenceOfPnt VIsoCurves; 
-    TColgp_SequenceOfPnt Pnts;
     
     Standard_Boolean UClosed = aSurface->IsUClosed();
     Standard_Boolean VClosed = aSurface->IsVClosed();
@@ -183,24 +182,24 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       if ( !UClosed ) 
        { 
          anIso.Load(GeomAbs_IsoU,U1,V1,V2);
-         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
-         freeCurves.Append(Pnts);
-         Pnts.Clear();
+          Handle(TColgp_HSequenceOfPnt) aPntsU1 = new TColgp_HSequenceOfPnt;
+         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsU1->ChangeSequence(), Standard_False);
+         freeCurves.Append(aPntsU1);
          anIso.Load(GeomAbs_IsoU,U2,V1,V2);
-         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
-         freeCurves.Append(Pnts);
-         Pnts.Clear();
+          Handle(TColgp_HSequenceOfPnt) aPntsU2 = new TColgp_HSequenceOfPnt;
+         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsU2->ChangeSequence(), Standard_False);
+         freeCurves.Append(aPntsU2);
        }
       if ( !VClosed )
        {
          anIso.Load(GeomAbs_IsoV,V1,U1,U2);
-         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
-         freeCurves.Append(Pnts);
-         Pnts.Clear();
+          Handle(TColgp_HSequenceOfPnt) aPntsV1 = new TColgp_HSequenceOfPnt;
+         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsV1->ChangeSequence(), Standard_False);
+         freeCurves.Append(aPntsV1);
          anIso.Load(GeomAbs_IsoV,V2,U1,U2);
-         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
-         freeCurves.Append(Pnts);
-         Pnts.Clear();
+          Handle(TColgp_HSequenceOfPnt) aPntsV2 = new TColgp_HSequenceOfPnt;
+         StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, aPntsV2->ChangeSequence(), Standard_False);
+         freeCurves.Append(aPntsV2);
        }
     }
     //
@@ -216,9 +215,9 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       Standard_Real du= UClosed ? (U2-U1)/fin : (U2-U1)/(1+fin);
       for (Standard_Integer i=1; i<=fin;i++){
        anIso.Load(GeomAbs_IsoU,U1+du*i,V1,V2);
-       StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
+        Handle(TColgp_HSequenceOfPnt) Pnts = new TColgp_HSequenceOfPnt;
+       StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts->ChangeSequence(), Standard_False);
        UIsoCurves.Append(Pnts);
-       Pnts.Clear();
       }
     }
     fin = aDrawer->VIsoAspect()->Number();
@@ -230,9 +229,9 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       Standard_Real dv= VClosed ?(V2-V1)/fin : (V2-V1)/(1+fin);
       for (Standard_Integer i=1; i<=fin;i++){
        anIso.Load(GeomAbs_IsoV,V1+dv*i,U1,U2);
-       StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False);
+        Handle(TColgp_HSequenceOfPnt) Pnts = new TColgp_HSequenceOfPnt;
+       StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts->ChangeSequence(), Standard_False);
        VIsoCurves.Append(Pnts);
-       Pnts.Clear();
       }
     }
     
@@ -242,15 +241,14 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       nbBounds = UIsoCurves.Size();
       Prs3d_NListIteratorOfListOfSequenceOfPnt It;
       for( It.Init(UIsoCurves); It.More(); It.Next())
-       nbVertices += It.Value().Length();
+       nbVertices += It.Value()->Length();
       Handle(Graphic3d_ArrayOfPolylines) UIsoArray =
        new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
       for( It.Init(UIsoCurves); It.More(); It.Next()) {
-       TColgp_SequenceOfPnt Pnts;
-       Pnts.Assign(It.Value());
-       UIsoArray->AddBound(Pnts.Length());
-       for(int i=1; i<=Pnts.Length(); i++)
-         UIsoArray->AddVertex(Pnts.Value(i));
+        const Handle(TColgp_HSequenceOfPnt)& Pnts = It.Value();
+       UIsoArray->AddBound(Pnts->Length());
+       for(int i=1; i<=Pnts->Length(); i++)
+         UIsoArray->AddVertex(Pnts->Value(i));
       }      
       Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
       TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());
@@ -261,15 +259,14 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       nbBounds = VIsoCurves.Size();
       Prs3d_NListIteratorOfListOfSequenceOfPnt It;
       for( It.Init(VIsoCurves); It.More(); It.Next())
-       nbVertices += It.Value().Length();
+       nbVertices += It.Value()->Length();
       Handle(Graphic3d_ArrayOfPolylines) VIsoArray =
        new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
       for( It.Init(VIsoCurves); It.More(); It.Next()) {
-       TColgp_SequenceOfPnt Pnts;
-       Pnts.Assign(It.Value());
-       VIsoArray->AddBound(Pnts.Length());
-       for(int i=1; i<=Pnts.Length(); i++)
-         VIsoArray->AddVertex(Pnts.Value(i));
+       const Handle(TColgp_HSequenceOfPnt)& Pnts = It.Value();
+       VIsoArray->AddBound(Pnts->Length());
+       for(int i=1; i<=Pnts->Length(); i++)
+         VIsoArray->AddVertex(Pnts->Value(i));
       }
       Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
       TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());
@@ -279,15 +276,14 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation,
       nbBounds = freeCurves.Size();
       Prs3d_NListIteratorOfListOfSequenceOfPnt It;
       for( It.Init(freeCurves); It.More(); It.Next())
-       nbVertices += It.Value().Length();
+       nbVertices += It.Value()->Length();
       Handle(Graphic3d_ArrayOfPolylines) freeArray =
        new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds);
       for( It.Init(freeCurves); It.More(); It.Next()) {
-       TColgp_SequenceOfPnt Pnts;
-       Pnts.Assign(It.Value());
-       freeArray->AddBound(Pnts.Length());
-       for(int i=1; i<=Pnts.Length(); i++)
-         freeArray->AddVertex(Pnts.Value(i));
+       const Handle(TColgp_HSequenceOfPnt)& Pnts = It.Value();
+       freeArray->AddBound(Pnts->Length());
+       for(int i=1; i<=Pnts->Length(); i++)
+         freeArray->AddVertex(Pnts->Value(i));
       }
       Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation);
       TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect());