mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0028782: Shape sewing behavior not consistent for the same CAD file
Get rid of iterations on maps with shape key by replacing simple maps with indexed maps. So iteration is done on integer key. The map containers have been updated to insert into them type definitions of key and value. The new methods RemoveKey() and RemoveFromIndex() have been added to indexed [data] map to be able to remove an arbitrary key from the map. All the code in OCCT has been updated where RemoveLast() and Substitute() methods were used to remove a key from indexed [data] map.
This commit is contained in:
@@ -47,8 +47,14 @@ template < class TheKeyType,
|
||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||
class NCollection_DataMap : public NCollection_BaseMap
|
||||
{
|
||||
public:
|
||||
//! STL-compliant typedef for key type
|
||||
typedef TheKeyType key_type;
|
||||
//! STL-compliant typedef for value type
|
||||
typedef TheItemType value_type;
|
||||
|
||||
public:
|
||||
// **************** Adaptation of the TListNode to the DATAmap
|
||||
public:
|
||||
class DataMapNode : public NCollection_TListNode<TheItemType>
|
||||
{
|
||||
public:
|
||||
|
@@ -40,8 +40,14 @@ template < class TheKey1Type,
|
||||
class Hasher2 = NCollection_DefaultHasher<TheKey2Type> >
|
||||
class NCollection_DoubleMap : public NCollection_BaseMap
|
||||
{
|
||||
public:
|
||||
//! STL-compliant typedef for key1 type
|
||||
typedef TheKey1Type key1_type;
|
||||
//! STL-compliant typedef for key2 type
|
||||
typedef TheKey2Type key2_type;
|
||||
|
||||
public:
|
||||
// **************** Adaptation of the TListNode to the DOUBLEmap
|
||||
public:
|
||||
class DoubleMapNode : public NCollection_TListNode<TheKey2Type>
|
||||
{
|
||||
public:
|
||||
|
@@ -49,8 +49,14 @@ template < class TheKeyType,
|
||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||
class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
{
|
||||
public:
|
||||
//! STL-compliant typedef for key type
|
||||
typedef TheKeyType key_type;
|
||||
//! STL-compliant typedef for value type
|
||||
typedef TheItemType value_type;
|
||||
|
||||
private:
|
||||
//! Adaptation of the TListNode to the INDEXEDDatamap
|
||||
private:
|
||||
class IndexedDataMapNode : public NCollection_TListNode<TheItemType>
|
||||
{
|
||||
public:
|
||||
@@ -435,6 +441,27 @@ class NCollection_IndexedDataMap : public NCollection_BaseMap
|
||||
Decrement();
|
||||
}
|
||||
|
||||
//! Remove the key of the given index.
|
||||
//! Caution! The index of the last key can be changed.
|
||||
void RemoveFromIndex(const Standard_Integer theKey2)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedDataMap::Remove");
|
||||
Standard_Integer aLastInd = Extent();
|
||||
if (theKey2 != aLastInd)
|
||||
Swap(theKey2, aLastInd);
|
||||
RemoveLast();
|
||||
}
|
||||
|
||||
//! Remove the given key.
|
||||
//! Caution! The index of the last key can be changed.
|
||||
void RemoveKey(const TheKeyType& theKey1)
|
||||
{
|
||||
Standard_Integer anIndToRemove = FindIndex(theKey1);
|
||||
if (anIndToRemove > 0) {
|
||||
RemoveFromIndex(anIndToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
//! FindKey
|
||||
const TheKeyType& FindKey (const Standard_Integer theKey2) const
|
||||
{
|
||||
|
@@ -40,9 +40,13 @@ template < class TheKeyType,
|
||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||
class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
{
|
||||
// **************** Adaptation of the TListNode to the INDEXEDmap
|
||||
public:
|
||||
//! STL-compliant typedef for key type
|
||||
typedef TheKeyType key_type;
|
||||
|
||||
private:
|
||||
class IndexedMapNode : public NCollection_TListNode<TheKeyType>
|
||||
// **************** Adaptation of the TListNode to the INDEXEDmap
|
||||
class IndexedMapNode : public NCollection_TListNode<TheKeyType>
|
||||
{
|
||||
public:
|
||||
//! Constructor with 'Next'
|
||||
@@ -398,6 +402,27 @@ class NCollection_IndexedMap : public NCollection_BaseMap
|
||||
Decrement();
|
||||
}
|
||||
|
||||
//! Remove the key of the given index.
|
||||
//! Caution! The index of the last key can be changed.
|
||||
void RemoveFromIndex(const Standard_Integer theKey2)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(theKey2 < 1 || theKey2 > Extent(), "NCollection_IndexedMap::Remove");
|
||||
Standard_Integer aLastInd = Extent();
|
||||
if (theKey2 != aLastInd)
|
||||
Swap(theKey2, aLastInd);
|
||||
RemoveLast();
|
||||
}
|
||||
|
||||
//! Remove the given key.
|
||||
//! Caution! The index of the last key can be changed.
|
||||
void RemoveKey(const TheKeyType& theKey1)
|
||||
{
|
||||
Standard_Integer anIndToRemove = FindIndex(theKey1);
|
||||
if (anIndToRemove > 0) {
|
||||
RemoveFromIndex(anIndToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
//! FindKey
|
||||
const TheKeyType& FindKey (const Standard_Integer theKey2) const
|
||||
{
|
||||
|
@@ -56,9 +56,12 @@ template < class TheKeyType,
|
||||
class Hasher = NCollection_DefaultHasher<TheKeyType> >
|
||||
class NCollection_Map : public NCollection_BaseMap
|
||||
{
|
||||
//! Adaptation of the TListNode to the map notations
|
||||
public:
|
||||
public:
|
||||
//! STL-compliant typedef for key type
|
||||
typedef TheKeyType key_type;
|
||||
|
||||
public:
|
||||
//! Adaptation of the TListNode to the map notations
|
||||
class MapNode : public NCollection_TListNode<TheKeyType>
|
||||
{
|
||||
public:
|
||||
|
Reference in New Issue
Block a user