0020918: EDF 1447 SMESH: Mesh common borders

+  void SetPersistentId(int id);
+  int GetPersistentId() const;
+  int MaxSubMeshIndex() const;
This commit is contained in:
eap 2010-11-12 14:33:09 +00:00
parent c80623eeac
commit e708406444
2 changed files with 40 additions and 3 deletions

View File

@ -61,6 +61,7 @@ SMESHDS_Mesh::SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode):
{ {
myScript = new SMESHDS_Script(theIsEmbeddedMode); myScript = new SMESHDS_Script(theIsEmbeddedMode);
myCurSubMesh = 0; myCurSubMesh = 0;
SetPersistentId(theMeshID);
} }
//======================================================================= //=======================================================================
@ -69,6 +70,28 @@ bool SMESHDS_Mesh::IsEmbeddedMode()
return myIsEmbeddedMode; return myIsEmbeddedMode;
} }
//================================================================================
/*!
* \brief Store ID persistent during lifecycle
*/
//================================================================================
void SMESHDS_Mesh::SetPersistentId(int id)
{
if (NbNodes() == 0)
myPersistentID = id;
}
//================================================================================
/*!
* \brief Return ID persistent during lifecycle
*/
//================================================================================
int SMESHDS_Mesh::GetPersistentId() const
{
return myPersistentID;
}
//======================================================================= //=======================================================================
//function : ShapeToMesh //function : ShapeToMesh
//purpose : //purpose :
@ -1247,6 +1270,17 @@ const TopoDS_Shape& SMESHDS_Mesh::IndexToShape(int ShapeIndex) const
return nullShape; return nullShape;
} }
//================================================================================
/*!
* \brief Return max index of sub-mesh
*/
//================================================================================
int SMESHDS_Mesh::MaxSubMeshIndex() const
{
return myShapeIndexToSubMesh.empty() ? 0 : myShapeIndexToSubMesh.rbegin()->first;
}
//======================================================================= //=======================================================================
//function : ShapeToIndex //function : ShapeToIndex
//purpose : //purpose :

View File

@ -50,7 +50,7 @@
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include <map> #include <map>
/* /*
* Using of native haah_map isn't portable and don't work on WIN32 platform. * Using of native hash_map isn't portable and don't work on WIN32 platform.
* So this functionality implement on new NCollection_DataMap technology * So this functionality implement on new NCollection_DataMap technology
*/ */
#include "SMESHDS_DataMapOfShape.hxx" #include "SMESHDS_DataMapOfShape.hxx"
@ -61,6 +61,8 @@ class SMESHDS_EXPORT SMESHDS_Mesh:public SMDS_Mesh{
public: public:
SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode); SMESHDS_Mesh(int theMeshID, bool theIsEmbeddedMode);
bool IsEmbeddedMode(); bool IsEmbeddedMode();
void SetPersistentId(int id);
int GetPersistentId() const;
void ShapeToMesh(const TopoDS_Shape & S); void ShapeToMesh(const TopoDS_Shape & S);
TopoDS_Shape ShapeToMesh() const; TopoDS_Shape ShapeToMesh() const;
@ -423,6 +425,7 @@ public:
int ShapeToIndex(const TopoDS_Shape & aShape) const; int ShapeToIndex(const TopoDS_Shape & aShape) const;
const TopoDS_Shape& IndexToShape(int ShapeIndex) const; const TopoDS_Shape& IndexToShape(int ShapeIndex) const;
int MaxShapeIndex() const { return myIndexToShape.Extent(); } int MaxShapeIndex() const { return myIndexToShape.Extent(); }
int MaxSubMeshIndex() const;
SMESHDS_SubMesh * NewSubMesh(int Index); SMESHDS_SubMesh * NewSubMesh(int Index);
int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE); int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE);
@ -449,7 +452,7 @@ private:
if ( it == myShapeIndexToSubMesh.end() ) if ( it == myShapeIndexToSubMesh.end() )
it = myShapeIndexToSubMesh.insert( std::make_pair(Index, new SMESHDS_SubMesh() )).first; it = myShapeIndexToSubMesh.insert( std::make_pair(Index, new SMESHDS_SubMesh() )).first;
it->second->AddNode( aNode ); // add aNode to submesh it->second->AddNode( aNode ); // add aNode to submesh
} }
/*int HashCode( const TopoDS_Shape& S, const Standard_Integer theUpper ) const /*int HashCode( const TopoDS_Shape& S, const Standard_Integer theUpper ) const
{ {
@ -462,7 +465,7 @@ private:
ShapeToHypothesis myShapeToHypothesis; ShapeToHypothesis myShapeToHypothesis;
int myMeshID; int myMeshID, myPersistentID;
TopoDS_Shape myShape; TopoDS_Shape myShape;
typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh; typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;