mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-29 02:40:35 +05:00
PAL10196. Rename GetGroupNames() -> GetGroupNamesAndTypes(), add checkFamilyId()
This commit is contained in:
parent
c278e57c77
commit
d7407cdcae
@ -184,6 +184,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
|||||||
if(MYDEBUG) MESSAGE(aGroupName);
|
if(MYDEBUG) MESSAGE(aGroupName);
|
||||||
aFamily->AddGroupName(aGroupName);
|
aFamily->AddGroupName(aGroupName);
|
||||||
}
|
}
|
||||||
|
aFamily->SetId( aFamId );
|
||||||
myFamilies[aFamId] = aFamily;
|
myFamilies[aFamId] = aFamily;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,6 +232,7 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
|||||||
EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
|
EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
|
||||||
TInt aNbElems = aNodeInfo->GetNbElem();
|
TInt aNbElems = aNodeInfo->GetNbElem();
|
||||||
if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
|
if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
|
||||||
|
DriverMED_FamilyPtr aFamily = myFamilies.begin()->second;
|
||||||
for(TInt iElem = 0; iElem < aNbElems; iElem++){
|
for(TInt iElem = 0; iElem < aNbElems; iElem++){
|
||||||
double aCoords[3] = {0.0, 0.0, 0.0};
|
double aCoords[3] = {0.0, 0.0, 0.0};
|
||||||
for(TInt iDim = 0; iDim < 3; iDim++)
|
for(TInt iDim = 0; iDim < 3; iDim++)
|
||||||
@ -247,10 +249,10 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
|||||||
|
|
||||||
// Save reference to this node from its family
|
// Save reference to this node from its family
|
||||||
TInt aFamNum = aNodeInfo->GetFamNum(iElem);
|
TInt aFamNum = aNodeInfo->GetFamNum(iElem);
|
||||||
if (myFamilies.find(aFamNum) != myFamilies.end())
|
if ( checkFamilyID ( aFamily, aFamNum ))
|
||||||
{
|
{
|
||||||
myFamilies[aFamNum]->AddElement(aNode);
|
aFamily->AddElement(aNode);
|
||||||
myFamilies[aFamNum]->SetType(SMDSAbs_Node);
|
aFamily->SetType(SMDSAbs_Node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +345,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
|||||||
SMDS_MeshElement* anElement = NULL;
|
SMDS_MeshElement* anElement = NULL;
|
||||||
TInt aFamNum = aCellInfo->GetFamNum(iElem);
|
TInt aFamNum = aCellInfo->GetFamNum(iElem);
|
||||||
try{
|
try{
|
||||||
|
//MESSAGE("Try to create element # " << iElem << " with id = "
|
||||||
|
// << aCellInfo->GetElemNum(iElem));
|
||||||
switch(aGeom){
|
switch(aGeom){
|
||||||
case eSEG2:
|
case eSEG2:
|
||||||
case eSEG3:
|
case eSEG3:
|
||||||
@ -491,10 +495,11 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
|
|||||||
if (aResult < DRS_WARN_RENUMBER)
|
if (aResult < DRS_WARN_RENUMBER)
|
||||||
aResult = DRS_WARN_RENUMBER;
|
aResult = DRS_WARN_RENUMBER;
|
||||||
}
|
}
|
||||||
if (myFamilies.find(aFamNum) != myFamilies.end()) {
|
if ( checkFamilyID ( aFamily, aFamNum ))
|
||||||
|
{
|
||||||
// Save reference to this element from its family
|
// Save reference to this element from its family
|
||||||
myFamilies[aFamNum]->AddElement(anElement);
|
aFamily->AddElement(anElement);
|
||||||
myFamilies[aFamNum]->SetType(anElement->GetType());
|
aFamily->SetType(anElement->GetType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,25 +547,24 @@ list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus)
|
|||||||
return aMeshNames;
|
return aMeshNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> DriverMED_R_SMESHDS_Mesh::GetGroupNames()
|
list<TNameAndType> DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes()
|
||||||
{
|
{
|
||||||
list<string> aResult;
|
list<TNameAndType> aResult;
|
||||||
set<string> aResGroupNames;
|
set<TNameAndType> aResGroupNames;
|
||||||
|
|
||||||
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
|
map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
|
||||||
for (; aFamsIter != myFamilies.end(); aFamsIter++)
|
for (; aFamsIter != myFamilies.end(); aFamsIter++)
|
||||||
{
|
{
|
||||||
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
|
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
|
||||||
const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
|
const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
|
||||||
set<string>::iterator aGrNamesIter = aGroupNames.begin();
|
set<string>::const_iterator aGrNamesIter = aGroupNames.begin();
|
||||||
for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
|
for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
|
||||||
{
|
{
|
||||||
string aName = *aGrNamesIter;
|
TNameAndType aNameAndType = make_pair( *aGrNamesIter, aFamily->GetType() );
|
||||||
// Check, if this is a Group or SubMesh name
|
// Check, if this is a Group or SubMesh name
|
||||||
//if (aName.substr(0, 5) == string("Group")) {
|
//if (aName.substr(0, 5) == string("Group")) {
|
||||||
if (aResGroupNames.find(aName) == aResGroupNames.end()) {
|
if ( aResGroupNames.insert( aNameAndType ).second ) {
|
||||||
aResGroupNames.insert(aName);
|
aResult.push_back( aNameAndType );
|
||||||
aResult.push_back(aName);
|
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@ -578,10 +582,10 @@ void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
|
|||||||
for (; aFamsIter != myFamilies.end(); aFamsIter++)
|
for (; aFamsIter != myFamilies.end(); aFamsIter++)
|
||||||
{
|
{
|
||||||
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
|
DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
|
||||||
if (aFamily->MemberOf(aGroupName))
|
if (aFamily->GetType() == theGroup->GetType() && aFamily->MemberOf(aGroupName))
|
||||||
{
|
{
|
||||||
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
|
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
|
||||||
set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
|
set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElements.begin();
|
||||||
const SMDS_MeshElement * element = 0;
|
const SMDS_MeshElement * element = 0;
|
||||||
for (; anElemsIter != anElements.end(); anElemsIter++)
|
for (; anElemsIter != anElements.end(); anElemsIter++)
|
||||||
{
|
{
|
||||||
@ -607,7 +611,7 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh,
|
|||||||
if (aFamily->MemberOf(aName))
|
if (aFamily->MemberOf(aName))
|
||||||
{
|
{
|
||||||
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
|
const set<const SMDS_MeshElement *>& anElements = aFamily->GetElements();
|
||||||
set<const SMDS_MeshElement *>::iterator anElemsIter = anElements.begin();
|
set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElements.begin();
|
||||||
if (aFamily->GetType() == SMDSAbs_Node)
|
if (aFamily->GetType() == SMDSAbs_Node)
|
||||||
{
|
{
|
||||||
for (; anElemsIter != anElements.end(); anElemsIter++)
|
for (; anElemsIter != anElements.end(); anElemsIter++)
|
||||||
@ -676,3 +680,20 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*!
|
||||||
|
* \brief Ensure aFamily to have required ID
|
||||||
|
* \param aFamily - a family to check and update
|
||||||
|
* \param anID - an ID aFamily should have
|
||||||
|
* \retval bool - true if successful
|
||||||
|
*/
|
||||||
|
bool DriverMED_R_SMESHDS_Mesh::checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const
|
||||||
|
{
|
||||||
|
if ( !aFamily || aFamily->GetId() != anID ) {
|
||||||
|
map<int, DriverMED_FamilyPtr>::const_iterator i_fam = myFamilies.find(anID);
|
||||||
|
if ( i_fam == myFamilies.end() )
|
||||||
|
return false;
|
||||||
|
aFamily = i_fam->second;
|
||||||
|
}
|
||||||
|
return ( aFamily->GetId() == anID );
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,14 @@ class SMESHDS_Mesh;
|
|||||||
class SMESHDS_Group;
|
class SMESHDS_Group;
|
||||||
class SMESHDS_SubMesh;
|
class SMESHDS_SubMesh;
|
||||||
|
|
||||||
|
typedef std::pair< std::string, SMDSAbs_ElementType > TNameAndType;
|
||||||
|
|
||||||
class DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
class DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Status Perform();
|
virtual Status Perform();
|
||||||
|
|
||||||
std::list<std::string> GetGroupNames();
|
std::list< TNameAndType > GetGroupNamesAndTypes();
|
||||||
void GetGroup(SMESHDS_Group* theGroup);
|
void GetGroup(SMESHDS_Group* theGroup);
|
||||||
void CreateAllSubMeshes();
|
void CreateAllSubMeshes();
|
||||||
void GetSubMesh(SMESHDS_SubMesh* theSubMesh, const int theId);
|
void GetSubMesh(SMESHDS_SubMesh* theSubMesh, const int theId);
|
||||||
@ -49,6 +51,15 @@ class DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
|
|||||||
std::list<std::string> GetMeshNames(Status& theStatus);
|
std::list<std::string> GetMeshNames(Status& theStatus);
|
||||||
void SetMeshName(std::string theMeshName);
|
void SetMeshName(std::string theMeshName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*!
|
||||||
|
* \brief Ensure aFamily has required ID
|
||||||
|
* \param aFamily - a family to check
|
||||||
|
* \param anID - an ID aFamily should have
|
||||||
|
* \retval bool - true if successful
|
||||||
|
*/
|
||||||
|
bool checkFamilyID(DriverMED_FamilyPtr & aFamily, int anID) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string myMeshName;
|
std::string myMeshName;
|
||||||
std::map<int, DriverMED_FamilyPtr> myFamilies;
|
std::map<int, DriverMED_FamilyPtr> myFamilies;
|
||||||
|
Loading…
Reference in New Issue
Block a user