- if(!aMED->_is_nil()){
- CORBA::Short aTag = mySObject->Tag();
- SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather();
- SALOMEDS::SObject_var aMeshSObj;
- CORBA::Boolean aBool = aMedCompSObj->FindSubObject(aTag+1,aMeshSObj);
- if(!aBool) throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!");
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found.");
- SALOMEDS::ChildIterator_var aMeshIterator = aStudy->NewChildIterator(aMeshSObj);
- for(; aMeshIterator->More(); aMeshIterator->Next()){
- aMeshSObj = aMeshIterator->Value();
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'");
- CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj);
- if(CORBA::is_nil(aMedMesh)) continue;
- SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh);
- if(aMEDMesh->_is_nil()) continue;
- CORBA::String_var aMeshName = aMEDMesh->getName();
- VISU::TMesh &aMesh = myMeshMap[aMeshName.in()];
- aMesh.myDim = aMEDMesh->getSpaceDimension();
- aMesh.myName = aMeshName.in();
- VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()];
- aMesh2.myMesh = aMEDMesh;
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh.myDim);
- SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aMeshSObj);
- for(; aSupportIterator->More(); aSupportIterator->Next()){
- SALOMEDS::SObject_var aSupportSObj = aSupportIterator->Value();
- CORBA::Object_var aMedSupport = SObjectToObject(aSupportSObj);
- if(CORBA::is_nil(aMedSupport)) continue;
- SALOME_MED::SUPPORT_var aMEDSupport = SALOME_MED::SUPPORT::_narrow(aMedSupport);
- if(aMEDSupport->_is_nil()) continue;
- SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity();
- VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity];
- CORBA::String_var aSupportName = aMEDSupport->getName();
- bool isDataPresent = false;
- if(aMEDSupport->isOnAllElements()){
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - Support isOnAllElements = '"<<aSupportName<<"' anEntity = "<<anEntity);
- //Check, if there is any data on the support?
- SALOME_MED::MESH_var aMeshOnSupport = aMEDSupport->getMesh();
- if(anEntity == VISU::NODE_ENTITY){
- if(aMeshOnSupport->getNumberOfNodes() > 0)
- isDataPresent = true;
- }else{
- int iGeomElemEnd;
- int* aGeomElemVector;
- GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd);
- const SALOME_MED::medEntityMesh& aMedEntity = aVisu2MedEntity[anEntity];
- for (int iGeomElem = 0, aCounter = 0; iGeomElem < iGeomElemEnd; iGeomElem++) {
- int medId = GetIdMEDType(aGeomElemVector[iGeomElem]);
- SALOME_MED::medGeometryElement aMedType = salome_med2vtk[medId].medType;
- med_int iNumElemEnd = aMeshOnSupport->getNumberOfElements(aMedEntity,aMedType);
- if(iNumElemEnd > 0) {
- isDataPresent = true;
- break;
- }
- }
- }
- if(!isDataPresent) continue;
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- aMeshOnEntity.myEntity = anEntity;
- aMeshOnEntity.myMeshName = aMeshName.in();
- VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
- aMeshOnEntity2.mySupport = aMEDSupport;
- }else{
- SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
- if(!aMEDFamily->_is_nil()) {
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFamily = '"<<aSupportName<<"' anEntity = "<<anEntity);
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aSupportName.in()];
- aFamily.myName = aSupportName.in();
- aFamily.myEntity = anEntity;
- aFamily.myId = aMEDFamily->getIdentifier();
- VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity];
- VISUMED::TFamily& aFamily2 = aMeshOnEntity2.myFamilyMap[aSupportName.in()];
- aFamily2.myFamily = aMEDFamily;
- }
- SALOME_MED::GROUP_var aMEDGroup = SALOME_MED::GROUP::_narrow(aMedSupport);
- if(!aMEDGroup->_is_nil()) {
- if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup = '"<<aSupportName<<"' anEntity = "<<anEntity);
- VISUMED::TGroupMap& aGroupMap2 = aMesh2.myGroupMap;
- VISUMED::TGroup& aGroup2 = aGroupMap2[aSupportName.in()];
- aGroup2.myGroup = aMEDGroup;
- //VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
- //VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- //VISU::TGroup& aGroup = aGroupMap[aSupportName.in()];
- //aGroup.myName = aSupportName.in();
- //aGroup.myMeshName = aMesh.myName;
- SALOME_MED::Family_array_var aFamilies = aMEDGroup->getFamilies();
- int iFamilyEnd = aFamilies->length();
- for(int iFamaily = 0; iFamaily < iFamilyEnd; iFamaily++){
- aMEDFamily = aFamilies[iFamaily];
- CORBA::String_var aFamilyName = aMEDFamily->getName();
- VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity];
- VISU::TFamily& aFamily = aMeshOnEntity.myFamilyMap[aFamilyName.in()];
- VISU::TBindGroups& aBindGroups = aFamily.myGroups;
- aBindGroups.insert(aSupportName.in());
- }
- }
- }
- }
- //Correction of TMesh.TGroupMap
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
- if(aMeshOnEntityMap.empty()) continue;
- VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
- VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
- const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
- const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
- if(aFamilyMap.empty()) continue;
- VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
- for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
- const VISU::TFamily& aFamily = aFamilyMapIter->second;
- const VISU::TBindGroups& aBindGroups = aFamily.myGroups;
- if(aBindGroups.empty()) continue;
- VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin();
- for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){
- const string& aGroupName = *aBindGroupsIter;
- VISU::TGroup& aGroup = aGroupMap[aGroupName];
- aGroup.myName = aGroupName;
- aGroup.myMeshName = aMesh.myName;
- VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity);
- aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity);
- }
- }
- }
+ return Build(aMED);
+ }
+
+ SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject);
+ return Build(aTimeStampIterator);
+}
+
+
+namespace{
+
+ using namespace boost;
+
+ //---------------------------------------------------------------
+ struct TSObjectByName
+ {
+ std::string myName;
+ typedef tuple<SALOMEDS::SObject_var> TRet;
+
+ TSObjectByName(const std::string& theName):
+ myName(theName)
+ {}
+
+ TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(theSObj->FindAttribute(anAttr,"AttributeName")){
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ CORBA::String_var aValue = aName->Value();
+ theIsSuccess = (myName == aValue.in());
+ if(theIsSuccess)
+ return TRet(SALOMEDS::SObject::_duplicate(theSObj));
+ }
+ return TRet();
+ }
+
+ };
+
+
+ //---------------------------------------------------------------
+ struct TMeshByName
+ {
+ std::string myName;
+ typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
+
+ TMeshByName(const std::string& theName):
+ myName(theName)
+ {}
+
+ TRet operator()(SALOMEDS::SObject_ptr theSObj, bool& theIsSuccess)
+ {
+ CORBA::Object_var anObj = VISU::SObjectToObject(theSObj);
+ if(!CORBA::is_nil(anObj)){
+ SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
+ if(!CORBA::is_nil(aMesh)){
+ CORBA::String_var aName = aMesh->getName();
+ theIsSuccess = (myName == aName.in());
+ if(theIsSuccess)
+ return TRet(aMesh,SALOMEDS::SObject::_duplicate(theSObj));
+ }