mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
Improve SMDS: replace std::set with NCollection_List for storage
of inverse connections
This commit is contained in:
parent
eab9bcb035
commit
5d84bc4bdb
@ -19,6 +19,9 @@
|
|||||||
//
|
//
|
||||||
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SMDS_MeshNode.hxx"
|
#include "SMDS_MeshNode.hxx"
|
||||||
#include "SMDS_SpacePosition.hxx"
|
#include "SMDS_SpacePosition.hxx"
|
||||||
@ -44,7 +47,14 @@ SMDS_MeshNode::SMDS_MeshNode(double x, double y, double z):
|
|||||||
|
|
||||||
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
|
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
|
||||||
{
|
{
|
||||||
myInverseElements.erase(parent);
|
NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
|
||||||
|
while (it.More()) {
|
||||||
|
const SMDS_MeshElement* elem = it.Value();
|
||||||
|
if (elem == parent)
|
||||||
|
myInverseElements.Remove(it);
|
||||||
|
else
|
||||||
|
it.Next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -80,24 +90,21 @@ const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
|
|||||||
|
|
||||||
class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator
|
class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
const set<const SMDS_MeshElement*>& mySet;
|
NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
|
||||||
set<const SMDS_MeshElement*>::iterator myIterator;
|
|
||||||
public:
|
public:
|
||||||
SMDS_MeshNode_MyInvIterator(const set<const SMDS_MeshElement*>& s):
|
SMDS_MeshNode_MyInvIterator(const NCollection_List<const SMDS_MeshElement*>& s):
|
||||||
mySet(s)
|
myIterator(s)
|
||||||
{
|
{}
|
||||||
myIterator=mySet.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return myIterator!=mySet.end();
|
return myIterator.More() != Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* current=*myIterator;
|
const SMDS_MeshElement* current=myIterator.Value();
|
||||||
myIterator++;
|
myIterator.Next();
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -112,39 +119,38 @@ SMDS_ElemIteratorPtr SMDS_MeshNode::
|
|||||||
// wanted type elements.
|
// wanted type elements.
|
||||||
class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
|
class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
|
||||||
{
|
{
|
||||||
set<const SMDS_MeshElement*> mySet;
|
NCollection_List<const SMDS_MeshElement*> mySet;
|
||||||
set<const SMDS_MeshElement*>::iterator myIterator;
|
NCollection_List<const SMDS_MeshElement*>::Iterator myIterator;
|
||||||
public:
|
public:
|
||||||
SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type,
|
SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type,
|
||||||
const set<const SMDS_MeshElement*>& s)
|
const NCollection_List<const SMDS_MeshElement*>& s)
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement * e;
|
const SMDS_MeshElement * e;
|
||||||
bool toInsert;
|
bool toInsert;
|
||||||
set<const SMDS_MeshElement*>::iterator it=s.begin();
|
NCollection_List<const SMDS_MeshElement*>::Iterator it(s);
|
||||||
while(it!=s.end())
|
for(; it.More(); it.Next())
|
||||||
{
|
{
|
||||||
e=*it;
|
e=it.Value();
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SMDSAbs_Edge: toInsert=true; break;
|
case SMDSAbs_Edge: toInsert=true; break;
|
||||||
case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
|
case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break;
|
||||||
case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
|
case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break;
|
||||||
}
|
}
|
||||||
if(toInsert) mySet.insert(e);
|
if(toInsert) mySet.Append(e);
|
||||||
it++;
|
|
||||||
}
|
}
|
||||||
myIterator=mySet.begin();
|
myIterator.Init(mySet);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool more()
|
bool more()
|
||||||
{
|
{
|
||||||
return myIterator!=mySet.end();
|
return myIterator.More() != Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SMDS_MeshElement* next()
|
const SMDS_MeshElement* next()
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* current=*myIterator;
|
const SMDS_MeshElement* current=myIterator.Value();
|
||||||
myIterator++;
|
myIterator.Next();
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -199,7 +205,13 @@ SMDSAbs_ElementType SMDS_MeshNode::GetType() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
||||||
{
|
{
|
||||||
myInverseElements.insert(ME);
|
NCollection_List<const SMDS_MeshElement*>::Iterator it(myInverseElements);
|
||||||
|
for (; it.More(); it.Next()) {
|
||||||
|
const SMDS_MeshElement* elem = it.Value();
|
||||||
|
if (elem == ME)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myInverseElements.Append(ME);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -208,12 +220,12 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMDS_MeshNode::ClearInverseElements()
|
void SMDS_MeshNode::ClearInverseElements()
|
||||||
{
|
{
|
||||||
myInverseElements.clear();
|
myInverseElements.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMDS_MeshNode::emptyInverseElements()
|
bool SMDS_MeshNode::emptyInverseElements()
|
||||||
{
|
{
|
||||||
return myInverseElements.empty();
|
return myInverseElements.IsEmpty() != Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -29,9 +29,7 @@
|
|||||||
|
|
||||||
#include "SMDS_MeshElement.hxx"
|
#include "SMDS_MeshElement.hxx"
|
||||||
#include "SMDS_Position.hxx"
|
#include "SMDS_Position.hxx"
|
||||||
|
#include <NCollection_List.hxx>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
|
|
||||||
class SMDS_MeshNode:public SMDS_MeshElement
|
class SMDS_MeshNode:public SMDS_MeshElement
|
||||||
{
|
{
|
||||||
@ -61,7 +59,7 @@ class SMDS_MeshNode:public SMDS_MeshElement
|
|||||||
private:
|
private:
|
||||||
double myX, myY, myZ;
|
double myX, myY, myZ;
|
||||||
SMDS_PositionPtr myPosition;
|
SMDS_PositionPtr myPosition;
|
||||||
std::set<const SMDS_MeshElement*> myInverseElements;
|
NCollection_List<const SMDS_MeshElement*> myInverseElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user