#include <DriverMED_Family.h>
Public Member Functions | |
| DriverMED_Family () | |
| Default constructor. | |
| MED::PFamilyInfo | GetFamilyInfo (const MED::PWrapper &theWrapper, const MED::PMeshInfo &theMeshInfo) const |
| Create TFamilyInfo for this family. | |
| const ElementsSet & | GetElements () const |
| Returns elements of this family. | |
| int | GetId () const |
| Returns a family ID. | |
| void | SetId (const int theId) |
| Sets a family ID. | |
| void | AddElement (const SMDS_MeshElement *theElement) |
| const MED::TStringSet & | GetGroupNames () const |
| void | AddGroupName (std::string theGroupName) |
| void | SetType (const SMDSAbs_ElementType theType) |
| SMDSAbs_ElementType | GetType () |
| const std::set < SMDSAbs_ElementType > & | GetTypes () const |
| bool | MemberOf (std::string theGroupName) const |
| int | GetGroupAttributVal () const |
| void | SetGroupAttributVal (int theValue) |
Static Public Member Functions | |
| static DriverMED_FamilyPtrList | MakeFamilies (const SMESHDS_SubMeshPtrMap &theSubMeshes, const SMESHDS_GroupBasePtrList &theGroups, const bool doGroupOfNodes, const bool doGroupOfEdges, const bool doGroupOfFaces, const bool doGroupOfVolumes) |
| Methods for groups storing to MED. | |
Private Member Functions | |
| void | Init (SMESHDS_GroupBase *group) |
| Initialize the tool by SMESHDS_GroupBase. | |
| void | Split (DriverMED_FamilyPtr by, DriverMED_FamilyPtr common) |
| Remove from <Elements> elements, common with <by>, Remove from <by> elements, common with <Elements>, Create family <common> from common elements, with combined groups list. | |
| bool | IsEmpty () const |
| Check, if this family has empty list of elements. | |
Static Private Member Functions | |
| static DriverMED_FamilyPtrList | SplitByType (SMESHDS_SubMesh *theSubMesh, const int theId) |
| Split <theSubMesh> on some parts (families) on the basis of the elements type. | |
Private Attributes | |
| int | myId |
| SMDSAbs_ElementType | myType |
| ElementsSet | myElements |
| MED::TStringSet | myGroupNames |
| int | myGroupAttributVal |
| std::set< SMDSAbs_ElementType > | myTypes |
Definition at line 56 of file DriverMED_Family.h.
| DriverMED_Family::DriverMED_Family | ( | ) |
| void DriverMED_Family::AddElement | ( | const SMDS_MeshElement * | theElement | ) |
Definition at line 71 of file DriverMED_Family.cxx.
{
myElements.insert(theElement);
}
| void DriverMED_Family::AddGroupName | ( | std::string | theGroupName | ) |
Definition at line 78 of file DriverMED_Family.cxx.
{
myGroupNames.insert(theGroupName);
}
| const ElementsSet & DriverMED_Family::GetElements | ( | ) | const |
Returns elements of this family.
Definition at line 50 of file DriverMED_Family.cxx.
{
return myElements;
}
| MED::PFamilyInfo DriverMED_Family::GetFamilyInfo | ( | const MED::PWrapper & | theWrapper, |
| const MED::PMeshInfo & | theMeshInfo | ||
| ) | const |
Create TFamilyInfo for this family.
Definition at line 320 of file DriverMED_Family.cxx.
{
ostringstream aStr;
aStr << "FAM_" << myId;
set<string>::const_iterator aGrIter = myGroupNames.begin();
for(; aGrIter != myGroupNames.end(); aGrIter++){
aStr << "_" << *aGrIter;
}
string aValue = aStr.str();
// PAL19785,0019867 - med forbids whitespace to be the last char in the name
int maxSize;
if ( theWrapper->GetVersion() == MED::eV2_1 )
maxSize = MED::GetNOMLength<MED::eV2_1>();
else
maxSize = MED::GetNOMLength<MED::eV2_2>();
int lastCharPos = min( maxSize, (int) aValue.size() ) - 1;
while ( isspace( aValue[ lastCharPos ] ))
aValue.resize( lastCharPos-- );
MED::PFamilyInfo anInfo;
if(myId == 0 || myGroupAttributVal == 0){
anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
aValue,
myId,
myGroupNames);
}else{
MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description,
MED::TIntVector anAttrIds (1, myId); // Id=0,
MED::TIntVector anAttrVals (1, myGroupAttributVal);
anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
aValue,
myId,
myGroupNames,
anAttrDescs,
anAttrIds,
anAttrVals);
}
// cout << endl;
// cout << "Groups: ";
// set<string>::iterator aGrIter = myGroupNames.begin();
// for (; aGrIter != myGroupNames.end(); aGrIter++)
// {
// cout << " " << *aGrIter;
// }
// cout << endl;
//
// cout << "Elements: ";
// set<const SMDS_MeshElement *>::iterator anIter = myElements.begin();
// for (; anIter != myElements.end(); anIter++)
// {
// cout << " " << (*anIter)->GetID();
// }
// cout << endl;
return anInfo;
}
| int DriverMED_Family::GetGroupAttributVal | ( | ) | const |
Definition at line 121 of file DriverMED_Family.cxx.
{
return myGroupAttributVal;
}
| const MED::TStringSet & DriverMED_Family::GetGroupNames | ( | ) | const |
Definition at line 113 of file DriverMED_Family.cxx.
{
return myGroupNames;
}
| int DriverMED_Family::GetId | ( | ) | const |
| SMDSAbs_ElementType DriverMED_Family::GetType | ( | ) |
Definition at line 92 of file DriverMED_Family.cxx.
{
return myType;
}
| const std::set< SMDSAbs_ElementType > & DriverMED_Family::GetTypes | ( | ) | const |
Definition at line 99 of file DriverMED_Family.cxx.
{
return myTypes;
}
| void DriverMED_Family::Init | ( | SMESHDS_GroupBase * | group | ) | [private] |
Initialize the tool by SMESHDS_GroupBase.
Definition at line 384 of file DriverMED_Family.cxx.
References SMESHDS_GroupBase.GetColor(), SMESHDS_GroupBase.GetElements(), SMESHDS_GroupBase.GetStoreName(), and SMESHDS_GroupBase.GetType().
{
// Elements
myElements.clear();
SMDS_ElemIteratorPtr elemIt = theGroup->GetElements();
while (elemIt->more())
{
myElements.insert(elemIt->next());
}
// Type
myType = theGroup->GetType();
// Groups list
myGroupNames.clear();
myGroupNames.insert(string(theGroup->GetStoreName()));
Quantity_Color aColor = theGroup->GetColor();
double aRed = aColor.Red();
double aGreen = aColor.Green();
double aBlue = aColor.Blue();
int aR = int( aRed*255 );
int aG = int( aGreen*255 );
int aB = int( aBlue*255 );
// cout << "aRed = " << aR << endl;
// cout << "aGreen = " << aG << endl;
// cout << "aBlue = " << aB << endl;
myGroupAttributVal = (int)(aR*1000000 + aG*1000 + aB);
//cout << "myGroupAttributVal = " << myGroupAttributVal << endl;
}
| bool DriverMED_Family::IsEmpty | ( | ) | const [private] |
Check, if this family has empty list of elements.
Definition at line 135 of file DriverMED_Family.cxx.
{
return myElements.empty();
}
| DriverMED_FamilyPtrList DriverMED_Family::MakeFamilies | ( | const SMESHDS_SubMeshPtrMap & | theSubMeshes, |
| const SMESHDS_GroupBasePtrList & | theGroups, | ||
| const bool | doGroupOfNodes, | ||
| const bool | doGroupOfEdges, | ||
| const bool | doGroupOfFaces, | ||
| const bool | doGroupOfVolumes | ||
| ) | [static] |
Methods for groups storing to MED.
Split each group from list <aGroups> on some parts (families) on the basis of the elements membership in other groups from this list.
Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes> on some parts (families) on the basis of the elements membership in other groups from <theGroups> and other sub-meshes from <theSubMeshes>. Resulting families have no common elements.
Resulting families have no common elements.
Definition at line 149 of file DriverMED_Family.cxx.
References FIRST_ELEM_FAMILY, FIRST_NODE_FAMILY, SMESHDS_SubMesh.IsComplexSubmesh(), REST_EDGES_FAMILY, REST_FACES_FAMILY, REST_NODES_FAMILY, REST_VOLUMES_FAMILY, SMDSAbs_All, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Node, and SMDSAbs_Volume.
Referenced by DriverMED_W_SMESHDS_Mesh.Perform().
{
DriverMED_FamilyPtrList aFamilies;
string anAllNodesGroupName = "Group_Of_All_Nodes";
string anAllEdgesGroupName = "Group_Of_All_Edges";
string anAllFacesGroupName = "Group_Of_All_Faces";
string anAllVolumesGroupName = "Group_Of_All_Volumes";
// Reserve four ids for families of free elements
// (1 - nodes, -1 - edges, -2 - faces, -3 - volumes).
// 'Free' means here not belonging to any group.
int aNodeFamId = FIRST_NODE_FAMILY;
int aElemFamId = FIRST_ELEM_FAMILY;
// Process sub-meshes
SMESHDS_SubMeshPtrMap::const_iterator aSMIter = theSubMeshes.begin();
for (; aSMIter != theSubMeshes.end(); aSMIter++)
{
const int anId = aSMIter->first;
SMESHDS_SubMesh* aSubMesh = aSMIter->second;
if ( aSubMesh->IsComplexSubmesh() )
continue; // submesh containing other submeshs
DriverMED_FamilyPtrList aSMFams = SplitByType(aSubMesh,anId);
DriverMED_FamilyPtrList::iterator aSMFamsIter = aSMFams.begin();
for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++)
{
DriverMED_FamilyPtr aFam2 = (*aSMFamsIter);
DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end())
{
DriverMED_FamilyPtr aFam1 = *aFamsIter;
DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType)
{
DriverMED_FamilyPtr aCommon (new DriverMED_Family);
aFam1->Split(aFam2, aCommon);
if (!aCommon->IsEmpty())
{
aFamilies.push_back(aCommon);
}
if (aFam1->IsEmpty())
{
aFamilies.erase(aCurrIter);
}
if (aFam2->IsEmpty())
break;
}
}
// The rest elements of family
if (!aFam2->IsEmpty())
{
aFamilies.push_back(aFam2);
}
}
}
// Process groups
SMESHDS_GroupBasePtrList::const_iterator aGroupsIter = theGroups.begin();
for (; aGroupsIter != theGroups.end(); aGroupsIter++)
{
DriverMED_FamilyPtr aFam2 (new DriverMED_Family);
aFam2->Init(*aGroupsIter);
DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
while (aFamsIter != aFamilies.end())
{
DriverMED_FamilyPtr aFam1 = *aFamsIter;
DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
if (aFam1->myType == aFam2->myType)
{
DriverMED_FamilyPtr aCommon (new DriverMED_Family);
aFam1->Split(aFam2, aCommon);
if (!aCommon->IsEmpty())
{
aCommon->SetGroupAttributVal(0);
aFamilies.push_back(aCommon);
}
if (aFam1->IsEmpty())
{
aFamilies.erase(aCurrIter);
}
if (aFam2->IsEmpty())
break;
}
}
// The rest elements of group
if (!aFam2->IsEmpty())
{
aFamilies.push_back(aFam2);
}
}
DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
for (; aFamsIter != aFamilies.end(); aFamsIter++)
{
DriverMED_FamilyPtr aFam = *aFamsIter;
if (aFam->myType == SMDSAbs_Node) {
aFam->SetId(aNodeFamId++);
if (doGroupOfNodes) aFam->myGroupNames.insert(anAllNodesGroupName);
}
else {
aFam->SetId(aElemFamId--);
if (aFam->myType == SMDSAbs_Edge) {
if (doGroupOfEdges) aFam->myGroupNames.insert(anAllEdgesGroupName);
}
else if (aFam->myType == SMDSAbs_Face) {
if (doGroupOfFaces) aFam->myGroupNames.insert(anAllFacesGroupName);
}
else if (aFam->myType == SMDSAbs_Volume) {
if (doGroupOfVolumes) aFam->myGroupNames.insert(anAllVolumesGroupName);
}
}
}
// Create families for elements, not belonging to any group
if (doGroupOfNodes)
{
DriverMED_FamilyPtr aFreeNodesFam (new DriverMED_Family);
aFreeNodesFam->SetId(REST_NODES_FAMILY);
aFreeNodesFam->myType = SMDSAbs_Node;
aFreeNodesFam->myGroupNames.insert(anAllNodesGroupName);
aFamilies.push_back(aFreeNodesFam);
}
if (doGroupOfEdges)
{
DriverMED_FamilyPtr aFreeEdgesFam (new DriverMED_Family);
aFreeEdgesFam->SetId(REST_EDGES_FAMILY);
aFreeEdgesFam->myType = SMDSAbs_Edge;
aFreeEdgesFam->myGroupNames.insert(anAllEdgesGroupName);
aFamilies.push_back(aFreeEdgesFam);
}
if (doGroupOfFaces)
{
DriverMED_FamilyPtr aFreeFacesFam (new DriverMED_Family);
aFreeFacesFam->SetId(REST_FACES_FAMILY);
aFreeFacesFam->myType = SMDSAbs_Face;
aFreeFacesFam->myGroupNames.insert(anAllFacesGroupName);
aFamilies.push_back(aFreeFacesFam);
}
if (doGroupOfVolumes)
{
DriverMED_FamilyPtr aFreeVolumesFam (new DriverMED_Family);
aFreeVolumesFam->SetId(REST_VOLUMES_FAMILY);
aFreeVolumesFam->myType = SMDSAbs_Volume;
aFreeVolumesFam->myGroupNames.insert(anAllVolumesGroupName);
aFamilies.push_back(aFreeVolumesFam);
}
DriverMED_FamilyPtr aNullFam (new DriverMED_Family);
aNullFam->SetId(0);
aNullFam->myType = SMDSAbs_All;
aFamilies.push_back(aNullFam);
return aFamilies;
}
| bool DriverMED_Family::MemberOf | ( | std::string | theGroupName | ) | const |
Definition at line 106 of file DriverMED_Family.cxx.
{
return myGroupNames.find(theGroupName) != myGroupNames.end();
}
| void DriverMED_Family::SetGroupAttributVal | ( | int | theValue | ) |
Definition at line 128 of file DriverMED_Family.cxx.
{
myGroupAttributVal = theValue;
}
| void DriverMED_Family::SetId | ( | const int | theId | ) |
| void DriverMED_Family::SetType | ( | const SMDSAbs_ElementType | theType | ) |
Definition at line 85 of file DriverMED_Family.cxx.
| void DriverMED_Family::Split | ( | DriverMED_FamilyPtr | by, |
| DriverMED_FamilyPtr | common | ||
| ) | [private] |
Remove from <Elements> elements, common with <by>, Remove from <by> elements, common with <Elements>, Create family <common> from common elements, with combined groups list.
Remove from <myElements> elements, common with <by>, Remove from <by> elements, common with <myElements>, Create family <common> from common elements, with combined groups list.
Definition at line 493 of file DriverMED_Family.cxx.
{
// Elements
ElementsSet::iterator anIter = by->myElements.begin();
while ( anIter != by->myElements.end())
{
if (myElements.find(*anIter) != myElements.end())
{
common->myElements.insert(*anIter);
myElements.erase(*anIter);
by->myElements.erase(anIter++);
}
else
anIter++;
}
if (!common->IsEmpty())
{
// Groups list
common->myGroupNames = myGroupNames;
MED::TStringSet::iterator aGrNamesIter = by->myGroupNames.begin();
for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++)
{
common->myGroupNames.insert(*aGrNamesIter);
}
// Type
common->myType = myType;
}
}
| DriverMED_FamilyPtrList DriverMED_Family::SplitByType | ( | SMESHDS_SubMesh * | theSubMesh, |
| const int | theId | ||
| ) | [static, private] |
Split <theSubMesh> on some parts (families) on the basis of the elements type.
Definition at line 423 of file DriverMED_Family.cxx.
References SMESHDS_SubMesh.GetElements(), SMESHDS_SubMesh.GetNodes(), SMDS_MeshElement.GetType(), SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Node, and SMDSAbs_Volume.
{
DriverMED_FamilyPtrList aFamilies;
DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family);
DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family);
DriverMED_FamilyPtr aVolumesFamily (new DriverMED_Family);
char submeshGrpName[ 30 ];
sprintf( submeshGrpName, "SubMesh %d", theId );
SMDS_NodeIteratorPtr aNodesIter = theSubMesh->GetNodes();
while (aNodesIter->more())
{
const SMDS_MeshNode* aNode = aNodesIter->next();
aNodesFamily->AddElement(aNode);
}
SMDS_ElemIteratorPtr anElemsIter = theSubMesh->GetElements();
while (anElemsIter->more())
{
const SMDS_MeshElement* anElem = anElemsIter->next();
switch (anElem->GetType())
{
case SMDSAbs_Edge:
anEdgesFamily->AddElement(anElem);
break;
case SMDSAbs_Face:
aFacesFamily->AddElement(anElem);
break;
case SMDSAbs_Volume:
aVolumesFamily->AddElement(anElem);
break;
default:
break;
}
}
if (!aNodesFamily->IsEmpty()) {
aNodesFamily->SetType(SMDSAbs_Node);
aNodesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aNodesFamily);
}
if (!anEdgesFamily->IsEmpty()) {
anEdgesFamily->SetType(SMDSAbs_Edge);
anEdgesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(anEdgesFamily);
}
if (!aFacesFamily->IsEmpty()) {
aFacesFamily->SetType(SMDSAbs_Face);
aFacesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aFacesFamily);
}
if (!aVolumesFamily->IsEmpty()) {
aVolumesFamily->SetType(SMDSAbs_Volume);
aVolumesFamily->AddGroupName(submeshGrpName);
aFamilies.push_back(aVolumesFamily);
}
return aFamilies;
}
ElementsSet DriverMED_Family.myElements [private] |
Definition at line 135 of file DriverMED_Family.h.
int DriverMED_Family.myGroupAttributVal [private] |
Definition at line 137 of file DriverMED_Family.h.
MED::TStringSet DriverMED_Family.myGroupNames [private] |
Definition at line 136 of file DriverMED_Family.h.
int DriverMED_Family.myId [private] |
Definition at line 133 of file DriverMED_Family.h.
SMDSAbs_ElementType DriverMED_Family.myType [private] |
Definition at line 134 of file DriverMED_Family.h.
std::set<SMDSAbs_ElementType> DriverMED_Family.myTypes [private] |
Definition at line 138 of file DriverMED_Family.h.