using MED::EBooleen;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
static int MYVALUEDEBUG = 0;
-static int MYMEMORYDEBUG = 0;
-static int MYTHREADDEBUG = 0;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
#define _DEXCEPT_
#else
static int MYDEBUG = 0;
static int MYVALUEDEBUG = 0;
-static int MYMEMORYDEBUG = 0;
-static int MYTHREADDEBUG = 0;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
#endif
PMEDProfile aProfile = theValForTime.myProfile;
TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
//---------------------------------------------------------------
- typedef std::map<TInt,TInt> TFamilyCounterMap;
-
void
BuildMeshOnEntityMap(PMEDMesh theMesh,
- TFamilyCounterMap& theFamilyID2CellsSize,
const MED::TEntityInfo& theEntityInfo,
const MED::PNodeInfo& theNodeInfo,
const MED::PWrapper& theMEDWrapper)
{
TTimerLog aTimerLog("BuildMeshOnEntityMap");
INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
+
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
const std::string& aMeshName = theMesh->myName;
TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName;
aMeshOnEntity->myGeom2Size = aGeom2Size;
-
+ TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+
INITMSG(MYDEBUG,
"- aMEntity = "<<aMEntity<<
"; aVEntity = "<<aVEntity<<
for(TInt iElem = 0; iElem < theMesh->myNbPoints; iElem++){
TInt aFamId = theNodeInfo->GetFamNum(iElem);
if(aFamId != 0)
- theFamilyID2CellsSize[aFamId] += 2;
+ aFamilyID2CellsSize[aFamId] += 2;
}
INITMSG(MYDEBUG,
aMeshOnEntity->myCellsSize += aNbConn;
TInt aFamId = aPolygoneInfo->GetFamNum(anElemId);
if(aFamId != 0)
- theFamilyID2CellsSize[aFamId] += aNbConn + 1;
+ aFamilyID2CellsSize[aFamId] += aNbConn + 1;
}
break;
}
aMeshOnEntity->myCellsSize += aCellSize;
TInt aFamId = aPolyedreInfo->GetFamNum(anElemId);
if(aFamId != 0)
- theFamilyID2CellsSize[aFamId] += aCellSize + 1;
+ aFamilyID2CellsSize[aFamId] += aCellSize + 1;
}
break;
}
for(TInt iElem = 0; iElem < aNbElem; iElem++){
TInt aFamId = aCellInfo->GetFamNum(iElem);
if(aFamId != 0)
- theFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
+ aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
}
}} // end switch(...)
}
}
- //---------------------------------------------------------------
- struct TFieldMinMax
- {
- VISU::PMEDField myField;
- MED::PFieldInfo myFieldInfo;
- TInt myNbTimeStamps;
- MED::EEntiteMaillage myMEntity;
- MED::TGeom2Size myGeom2Size;
- MED::TMKey2Profile myMKey2Profile;
- MED::TKey2Gauss myKey2Gauss;
- MED::PWrapper myMEDWrapper;
-
- TFieldMinMax(const VISU::PMEDField& theField,
- const MED::PFieldInfo& theFieldInfo,
- TInt theNbTimeStamps,
- MED::EEntiteMaillage theMEntity,
- const MED::TGeom2Size& theGeom2Size,
- const MED::TMKey2Profile& theMKey2Profile,
- const MED::TKey2Gauss& theKey2Gauss,
- const MED::PWrapper& theMEDWrapper):
- myField(theField),
- myFieldInfo(theFieldInfo),
- myNbTimeStamps(theNbTimeStamps),
- myMEntity(theMEntity),
- myGeom2Size(theGeom2Size),
- myMKey2Profile(theMKey2Profile),
- myKey2Gauss(theKey2Gauss),
- myMEDWrapper(theMEDWrapper)
- {
- INITMSG(MYMEMORYDEBUG,"TFieldMinMax() - "<<this<<endl);
- }
-
- ~TFieldMinMax()
- {
- INITMSG(MYMEMORYDEBUG,"~TFieldMinMax() - "<<this<<endl);
- }
-
- void
- Calculate()
- {
- INITMSG(MYTHREADDEBUG,"TFieldMinMax::Calculate() - "<<this<<
- "; aFieldName = '"<<myField->myName<<"'"<<
- "; myNbTimeStamps = "<<myNbTimeStamps<<
- endl);
-
- TInt aNbComp = myField->myNbComp;
- int aNbComp2 = aNbComp;
- if(aNbComp == 2 || aNbComp == 4)
- aNbComp2 = 2;
- else if(aNbComp > 4)
- aNbComp2 = 3;
-
- TValField& aValField = myField->myValField;
- TMinMaxArr& aMinMaxArr = myField->myMinMaxArr;
- for(TInt iTimeStamp = 1; iTimeStamp <= myNbTimeStamps; iTimeStamp++){
- INITMSG(MYTHREADDEBUG,"- "<<this<<"; iTimeStamp = "<<iTimeStamp<<endl);
-
- MED::PTimeStampInfo aTimeStampInfo = myMEDWrapper->GetPTimeStampInfo(myFieldInfo,
- myMEntity,
- myGeom2Size,
- iTimeStamp);
- MED::PTimeStampVal aTimeStampVal = myMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
- myMKey2Profile,
- myKey2Gauss);
- PMEDValForTime aValForTime = aValField[iTimeStamp];
-
- const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
-
- PMEDProfile aProfile = aValForTime->myProfile;
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
- for(; anIter != aGeom2SubProfile.end(); anIter++){
- VISU::EGeometry aEGeom = anIter->first;
- PMEDSubProfile aSubProfile(anIter->second);
-
- TInt aNbElem = aSubProfile->myNbCells;
- TInt aNbGauss = aValForTime->GetNbGauss(aEGeom);
-
- if(aSubProfile->myStatus != eRemoveAll){
- INITMSG(MYTHREADDEBUG,
- "- "<<this<<
- "; aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- endl);
-
- MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
- const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
-
- // To calculate min/max per components
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
- TMinMax& aMinMax = aMinMaxArr[iComp+1];
- float& aMin = aMinMax.first;
- float& aMax = aMinMax.second;
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const float& aVal = aMValueSlice[iGauss];
- aMin = min(aMin,aVal);
- aMax = max(aMax,aVal);
- }
- }
- }
-
- // To calculate min/max per vector modulus
- TMinMax& aMinMax = aMinMaxArr[0];
- float& aMin = aMinMax.first;
- float& aMax = aMinMax.second;
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
- float aValue = 0.0;
- for(TInt iComp = 0; iComp < aNbComp2; iComp++){
- float aVal = aMValueSlice[iComp];
- aValue += aVal*aVal;
- }
- aValue = sqrt(aValue);
- aMin = min(aMin,aValue);
- aMax = max(aMax,aValue);
- }
- }
- }
- }
- }
- for(TInt iComp = 0; iComp <= aNbComp; iComp++){
- VISU::TMinMax aMinMax = myField->GetMinMax(iComp);
- INITMSG(MYTHREADDEBUG,"- "<<this<<"; "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
- }
- }
- };
- typedef SharedPtr<TFieldMinMax> PFieldMinMax;
-
-
- //---------------------------------------------------------------
- void
- GetFieldMinMax(PFieldMinMax theFieldMinMax)
- {
- theFieldMinMax->Calculate();
- }
-
-
- //---------------------------------------------------------------
- struct TCalculateMinMax
- {
- VISU::PMEDMesh myMesh;
- MED::TEntityInfo myEntityInfo;
- MED::TMKey2Profile myMKey2Profile;
- MED::TKey2Gauss myKey2Gauss;
- MED::PWrapper myMEDWrapper;
-
- TCalculateMinMax(const VISU::PMEDMesh& theMesh,
- const MED::TEntityInfo& theEntityInfo,
- const MED::TMKey2Profile& theMKey2Profile,
- const MED::TKey2Gauss& theKey2Gauss,
- const MED::PWrapper& theMEDWrapper):
- myMesh(theMesh),
- myEntityInfo(theEntityInfo),
- myMKey2Profile(theMKey2Profile),
- myKey2Gauss(theKey2Gauss),
- myMEDWrapper(theMEDWrapper)
- {
- INITMSG(MYMEMORYDEBUG,"TCalculateMinMax() - "<<this<<endl);
- }
-
- ~TCalculateMinMax()
- {
- INITMSG(MYMEMORYDEBUG,"~TCalculateMinMax() - "<<this<<endl);
- }
-
- void
- Calculate()
- {
- TInt aNbFields = myMEDWrapper->GetNbFields();
- MED::PMeshInfo aMeshInfo = myMesh->myMeshInfo;
- const std::string& aMeshName = myMesh->myName;
- INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<<aNbFields<<"\n");
- for(TInt iField = 1; iField <= aNbFields; iField++){
- MED::PFieldInfo aFieldInfo = myMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
- TInt aNbComp = aFieldInfo->GetNbComp();
- std::string aFieldName = aFieldInfo->GetName();
-
- MED::TGeom2Size aGeom2Size;
- MED::EEntiteMaillage aMEntity;
- TInt aNbTimeStamps = myMEDWrapper->GetNbTimeStamps(aFieldInfo,
- myEntityInfo,
- aMEntity,
- aGeom2Size);
- if(aNbTimeStamps < 1)
- continue;
-
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = myMesh->myMeshOnEntityMap[aVEntity];
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- PMEDField aField = aFieldMap[aFieldName];
-
- PFieldMinMax aFieldMinMax(new TFieldMinMax(aField,
- aFieldInfo,
- aNbTimeStamps,
- aMEntity,
- aGeom2Size,
- myMKey2Profile,
- myKey2Gauss,
- myMEDWrapper));
-
- boost::thread aThread(boost::bind(&GetFieldMinMax,aFieldMinMax));
- }
- }
- };
- typedef SharedPtr<TCalculateMinMax> PCalculateMinMax;
-
-
- //---------------------------------------------------------------
- void
- CalculateMinMax(PCalculateMinMax theCalculateMinMax)
- {
- theCalculateMinMax->Calculate();
- }
-
-
//---------------------------------------------------------------
void
BuildFieldMap(PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
- const MED::TMKey2Profile& theMKey2Profile,
- const MED::TKey2Gauss& theKey2Gauss,
MED::PWrapper theMEDWrapper)
{
TTimerLog aTimerLog("BuildFieldMap");
const std::string& aMeshName = theMesh->myName;
INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
for(TInt iField = 1; iField <= aNbFields; iField++){
- TTimerLog aTimerLog("BuildFieldMap - GetPFieldInfo");
+ TTimerLog aTimerLog("GetPFieldInfo");
MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
TInt aNbComp = aFieldInfo->GetNbComp();
std::string aFieldName = aFieldInfo->GetName();
}
for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
- TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampInfo");
+ TTimerLog aTimerLog("GetPTimeStampInfo");
MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
aMEntity,
aGeom2Size,
iTimeStamp);
TFloat aDt = aTimeStampInfo->GetDt();
std::string anUnitDt = aTimeStampInfo->GetUnitDt();
- {
- TTimerLog aTimerLog("BuildFieldMap - GetPTimeStampVal");
- MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
- theMKey2Profile,
- theKey2Gauss);
- TValField& aValField = aField->myValField;
- PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
- aValForTime->myId = iTimeStamp;
- aValForTime->myFieldName = aField->myName;
- aValForTime->myEntity = aField->myEntity;
- aValForTime->myMeshName = aField->myMeshName;
- aValForTime->myNbGauss = aTimeStampInfo->GetNbGauss();
- aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
- INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
-
- InitGaussProfile(theMEDWrapper,
- aMeshInfo,
- aTimeStampVal,
- aMeshOnEntity,
- aMEntity,
- aGeom2Size,
- aValForTime);
- }
+
+ TValField& aValField = aField->myValField;
+ PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
+ aValForTime->myId = iTimeStamp;
+ aValForTime->myFieldName = aField->myName;
+ aValForTime->myEntity = aField->myEntity;
+ aValForTime->myMeshName = aField->myMeshName;
+ aValForTime->myNbGauss = aTimeStampInfo->GetNbGauss();
+ aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
+ INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
}
}
}
//---------------------------------------------------------------
void
BuildFamilyMap(PMEDMesh theMesh,
- const TFamilyCounterMap& theFamilyID2CellsSize,
const MED::TEntityInfo& theEntityInfo,
const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
const MED::TFamilyInfoSet& theFamilyInfoSet,
{
TTimerLog aTimerLog("BuildFamilyMap");
INITMSG(MYDEBUG,"BuildFamilyMap\n");
+
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
MED::TEntity2FamilySet aEntity2FamilySet = MED::GetEntity2FamilySet(theMEDWrapper,theEntity2TGeom2ElemInfo,theFamilyInfoSet);
MED::TEntity2FamilySet::const_iterator aEntity2FamilySetIter = aEntity2FamilySet.begin();
TEntity aVEntity = MEDEntityToVTK(aMEntity);
PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
if(aFamilyTSizeSet.empty())
aFamily->myNbCells = aSize;
aFamily->myCellsSize = 0;
- TFamilyCounterMap::const_iterator anIter = theFamilyID2CellsSize.find(anId);
- if(anIter != theFamilyID2CellsSize.end())
+ TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
+ if(anIter != aFamilyID2CellsSize.end())
aFamily->myCellsSize = anIter->second;
INITMSG(MY_FAMILY_DEBUG,
{
TTimerLog aTimerLog("BuildGroupMap");
INITMSG(MYDEBUG,"BuildGroupMap\n");
+
TGroupMap& aGroupMap = theMesh->myGroupMap;
MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
//---------------------------------------------------------------
VISU_Convertor*
VISU_MedConvertor
-::Build()
+::BuildEntities()
{
- TTimerLog aTimerLog("Build");
+ TTimerLog aTimerLog("BuildEntities");
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
- MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
- MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
-
TInt aNbMeshes = aMed->GetNbMeshes();
TMeshMap& aMeshMap = myMeshMap;
- MSG(MYDEBUG,"VISU_MedConvertor::Build()");
- INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
+ INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
#ifndef _DEXCEPT_
try{
#endif
+ TTimerLog aTimerLog("GetPMeshInfo");
+
MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+ TInt aDim = aMeshInfo->GetDim();
MED::PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
- MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
-
- MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
- MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,aEntityInfo);
-
- // creating TMesh structure and TMeshOnEntityMap
- TInt aDim = aMeshInfo->GetDim();
- std::string aMeshName = aMeshInfo->GetName();
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+ // creating TMesh structure and TMeshOnEntityMap
PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
aMesh->myDim = aDim;
aMesh->myName = aMeshName;
aMesh->myNbPoints = aNodeInfo->GetNbElem();
aMesh->myMeshInfo = aMeshInfo;
- aMesh->myEntityInfo = aEntityInfo;
+ aMesh->myEntityInfo = anEntityInfo;
aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
#ifndef _DEXCEPT_
try{
#endif
- BEGMSG(MYDEBUG,"aEntityInfo.size() = "<<aEntityInfo.size()<<"\n");
- TFamilyCounterMap aFamilyID2CellsSize;
+ BEGMSG(MYDEBUG,"anEntityInfo.size() = "<<anEntityInfo.size()<<"\n");
BuildMeshOnEntityMap(aMesh,
- aFamilyID2CellsSize,
- aEntityInfo,
+ anEntityInfo,
aNodeInfo,
aMed);
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildFields()
+{
+ TTimerLog aTimerLog("BuildFields");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog("GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+ INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+#ifndef _DEXCEPT_
+ try{
+#endif
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
BuildFieldMap(aMesh,
- aEntityInfo,
- aMKey2Profile,
- aKey2Gauss,
+ anEntityInfo,
aMed);
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildMinMax()
+{
+ TTimerLog aTimerLog("BuildMinMax");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
-#ifdef _LOAD_FAMILIES_
+ MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
+ MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog("BuildMinMax - GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TInt aNbFields = aMed->GetNbFields();
+
+ INITMSG(MYDEBUG,
+ "- aMeshName = '"<<aMeshName<<"'"<<
+ "; aNbFields = "<<aNbFields<<"\n");
+
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+ for(TInt iField = 1; iField <= aNbFields; iField++){
+ TTimerLog aTimerLog("BuildMinMax - GetPFieldInfo()");
+ MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
+ std::string aFieldName = aFieldInfo->GetName();
+ INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
+
+ MED::TGeom2Size aGeom2Size;
+ MED::EEntiteMaillage aMEntity;
+ TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,
+ anEntityInfo,
+ aMEntity,
+ aGeom2Size);
+ if(aNbTimeStamps < 1)
+ continue;
+
+ TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ PMEDField aField = aFieldMap[aFieldName];
+
+ TInt aNbComp = aField->myNbComp;
+ int aNbComp2 = aNbComp;
+ if(aNbComp == 2 || aNbComp == 4)
+ aNbComp2 = 2;
+ else if(aNbComp > 4)
+ aNbComp2 = 3;
+
+ TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
+ for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
+ TTimerLog aTimerLog("BuildMinMax - GetPTimeStampInfo()");
+ INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
+
+ MED::PTimeStampInfo aTimeStampInfo = aMed->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ iTimeStamp);
+
+ MED::PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStampInfo,
+ aMKey2Profile,
+ aKey2Gauss);
+
+ const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
+
+ const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
+ MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const MED::TMeshValue& aMMeshValue = anIter->second;
+ MED::EGeometrieElement aMGeom = anIter->first;
+
+ TInt aNbElem = aMMeshValue.myNbElem;
+ TInt aNbGauss = aMMeshValue.myNbGauss;
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ // To calculate min/max per components
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+ TMinMax& aMinMax = aMinMaxArr[iComp+1];
+ float& aMin = aMinMax.first;
+ float& aMax = aMinMax.second;
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const float& aVal = aMValueSlice[iGauss];
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ }
+ }
+ }
+
+ // To calculate min/max per vector modulus
+ TMinMax& aMinMax = aMinMaxArr[0];
+ float& aMin = aMinMax.first;
+ float& aMax = aMinMax.second;
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+ float aValue = 0.0;
+ for(TInt iComp = 0; iComp < aNbComp2; iComp++){
+ float aVal = aMValueSlice[iComp];
+ aValue += aVal*aVal;
+ }
+ aValue = sqrt(aValue);
+ aMin = min(aMin,aValue);
+ aMax = max(aMax,aValue);
+ }
+ }
+ }
+ }
+ for(TInt iComp = 0; iComp <= aNbComp; iComp++){
+ VISU::TMinMax aMinMax = aField->GetMinMax(iComp);
+ INITMSG(MYDEBUG,"- "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
+ }
+ }
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
+#endif
+ }
+
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_MedConvertor
+::BuildGroups()
+{
+ TTimerLog aTimerLog("BuildGroups");
+ MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
+
+ TInt aNbMeshes = aMed->GetNbMeshes();
+ TMeshMap& aMeshMap = myMeshMap;
+
+ INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
+
+ for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
+#ifndef _DEXCEPT_
+ try{
+#endif
+ TTimerLog aTimerLog("GetPMeshInfo");
+
+ MED::PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
+ std::string aMeshName = aMeshInfo->GetName();
+
+ TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ if(anIter == aMeshMap.end())
+ continue;
+ PMEDMesh aMesh = anIter->second;
+
+ INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
+
+ MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+
+ MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
+ MED::GetEntity2TGeom2ElemInfo(aMed,aMeshInfo,anEntityInfo);
+
+#ifndef _DEXCEPT_
+ try{
+#endif
MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(aMed,aMeshInfo);
BuildFamilyMap(aMesh,
- aFamilyID2CellsSize,
- aEntityInfo,
+ anEntityInfo,
anEntity2TGeom2ElemInfo,
aFamilyInfoSet,
aMed);
BuildGroupMap(aMesh,
aFamilyInfoSet);
-#endif
- PCalculateMinMax aCalculateMinMax(new TCalculateMinMax(aMesh,
- aEntityInfo,
- aMKey2Profile,
- aKey2Gauss,
- aMed));
-
- boost::thread aThread(boost::bind(&CalculateMinMax,aCalculateMinMax));
#ifndef _DEXCEPT_
}catch(std::exception& exc){
MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
VISU::PMeshOnEntityImpl theMeshOnEntity)
{
TTimerLog aTimerLog("LoadMeshOnEntity");
+ INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
+
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
const TEntity& anEntity = theMeshOnEntity->myEntity;
VISU::PFamilyImpl theFamily)
{
TTimerLog aTimerLog("LoadFamilyOnEntity");
+ INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
+
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
const TEntity& anEntity = theMeshOnEntity->myEntity;
const VISU::TFamilySet& theFamilySet)
{
TTimerLog aTimerLog("LoadMeshOnGroup");
+ INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
+
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
VISU::PValForTimeImpl theValForTime)
{
TTimerLog aTimerLog("LoadValForTimeOnMesh");
+ INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
+
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
const TEntity& anEntity = theMeshOnEntity->myEntity;
VISU::PValForTimeImpl theValForTime)
{
TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
+ INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
+
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
const TEntity& anEntity = theMeshOnEntity->myEntity;
aMKey2Profile,
aKey2Gauss);
+ InitGaussProfile(theMed,
+ aMeshInfo,
+ aTimeStampVal,
+ theMeshOnEntity,
+ aMEntity,
+ aGeom2Size,
+ theValForTime);
+
LoadProfile(theMed,
theMesh,
aTimeStampVal,
PMEDProfile aProfile = theValForTime->myProfile;
TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
TInt aNbComp = theField->myNbComp;
INITMSGA(MYDEBUG,0,
VISU::PMEDField theField,
VISU::PMEDValForTime theValForTime)
{
- TTimerLog aTimerLog("LoadValForTimeOnMesh");
PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
return LoadValForTime(theMed,
theMesh,
VISU::PMEDField theField,
VISU::PMEDValForTime theValForTime)
{
- TTimerLog aTimerLog("LoadValForTimeOnGaussPts");
PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
return LoadValForTime(theMed,
theMesh,
#include "SALOMEDS_Tool.hxx"
#include "HDFascii.hxx"
+#include "SUIT_Session.h"
+#include "SALOME_Event.hxx"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
// QT Includes
#include <qstring.h>
#include <qfileinfo.h>
int
-VISU::Result_i::
-IsPossible()
+VISU::Result_i
+::IsPossible()
{
try{
float aSize = myInput->GetSize();
}
+//---------------------------------------------------------------
CORBA::Boolean
-VISU::Result_i::
-BuildAll()
+VISU::Result_i
+::BuildAll()
{
if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
if(myIsDone) return 1;
}
-VISU::Storable*
-VISU::Result_i::
-Build(SALOMEDS::SObject_ptr theSObject)
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildEntities(SALOMEDS::SObject_ptr theSObject)
{
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
- aStudyBuilder->NewCommand(); // There is a transaction
- if(MYDEBUG) MESSAGE("Result_i::Build");
- try{
- const TMeshMap& aMeshMap = myInput->GetMeshMap();
- if(aMeshMap.empty())
- throw std::runtime_error("Build - There is no any mesh information in the file !!!");
+ QString aComment;
+ myInput->BuildEntities();
+ string aRefFatherEntry = GetRefFatherEntry();
+ const TMeshMap& aMeshMap = myInput->GetMeshMap();
+ TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
mySComponent = FindOrCreateVisuComponent(myStudyDocument);
- CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID());
- string aRefFatherEntry = GetRefFatherEntry();
- QString aComment;
+ CORBA::String_var aSComponentEntry = mySComponent->GetID();
+ CORBA::String_var anIOR(GetID());
aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
GetComment(),
VISU::TRESULT,
aComment.latin1(),
true);
mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
- if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!");
if(!CORBA::is_nil(theSObject)){
CORBA::String_var aString = theSObject->GetID();
CreateReference(myStudyDocument,aResultEntry,aString.in());
TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
const string& aMeshName = aMeshMapIter->first;
- const VISU::PMesh aMesh = aMeshMapIter->second;
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+ const PMesh& aMesh = aMeshMapIter->second;
+ const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ if(aMeshOnEntityMap.empty())
+ continue;
+
aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
- aMeshName.c_str(),aMesh->myDim);
- string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(),
- "",aMeshName.c_str(),"",aComment.latin1(),true);
- if(aMeshOnEntityMap.empty()) continue;
- aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str());
- string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(),
- "","Families","",aComment.latin1(),true);
- //Import entities and according families
- aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- typedef std::map<std::string,std::string> TComment2EntryMap;
- TComment2EntryMap aComment2EntryMap;
- typedef std::map<VISU::TEntity,std::string> TEntity2EntryMap;
- TEntity2EntryMap aEntity2EntryMap;
+ aMeshName.c_str(),
+ aMesh->myDim);
+ aMesh->myEntry =
+ CreateAttributes(myStudyDocument,
+ aResultEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ aMeshName.c_str(),
+ "",
+ aComment.latin1(),
+ true);
+
+ aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+ aMeshName.c_str());
+ string aSubMeshesEntry =
+ CreateAttributes(myStudyDocument,
+ aMesh->myEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ "Families",
+ "",
+ aComment.latin1(),
+ true);
+ //Import entities
+ TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
- const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+ const TEntity& anEntity = aMeshOnEntityMapIter->first;
+ const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ string anEntityName;
+ switch(anEntity){
+ case NODE_ENTITY:
+ anEntityName = "onNodes";
+ break;
+ case EDGE_ENTITY:
+ anEntityName = "onEdges";
+ break;
+ case FACE_ENTITY:
+ anEntityName = "onFaces";
+ break;
+ case CELL_ENTITY:
+ anEntityName = "onCells";
+ break;
+ default:
+ continue;
+ }
+
aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
VISU::TENTITY,
aMeshName.c_str(),
anEntity);
- string anEntityName;
- switch(anEntity){
- case VISU::NODE_ENTITY : anEntityName = "onNodes"; break;
- case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break;
- case VISU::FACE_ENTITY : anEntityName = "onFaces"; break;
- case VISU::CELL_ENTITY : anEntityName = "onCells"; break;
- default:
- throw std::runtime_error("Build >> Value of entity is incorrect!");
+
+ aMeshOnEntity->myEntry =
+ CreateAttributes(myStudyDocument,
+ aSubMeshesEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ anEntityName.c_str(),
+ "",
+ aComment.latin1(),
+ true);
+ }
+ }
+ }
+}
+
+
+//---------------------------------------------------------------
+namespace
+{
+ struct TMemManager
+ {
+ VISU::Result_i* myResult;
+ TMemManager(VISU::Result_i* theResult):
+ myResult(theResult)
+ {
+ myResult->Register();
+ }
+
+ ~TMemManager()
+ {
+ myResult->Destroy();
+ }
+ };
+
+ struct TUpdateObjBrowser: public SALOME_Event
+ {
+ int myStudyId;
+
+ TUpdateObjBrowser(const int theStudyId):
+ myStudyId(theStudyId)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> anApplications = aSession->applications();
+ QPtrListIterator<SUIT_Application> anIter (anApplications);
+ while (SUIT_Application* aSApp = anIter.current()) {
+ if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ if (myStudyId == aCStudy->StudyId()) {
+ MESSAGE("Result_i::updateObjectBrowser");
+ anApp->updateObjectBrowser();
+ break;
+ }
+ }
+ }
}
- aEntity2EntryMap[anEntity] = CreateAttributes
- (myStudyDocument, aSubMeshesEntry.c_str(), aRefFatherEntry.c_str(),
- "", anEntityName.c_str(), "", aComment.latin1(), true);
- const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
- const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
- VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
- for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
- const string& aFamilyName = aFamilyMapIter->first;
- aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
- VISU::TFAMILY,
- aMeshName.c_str(),
- anEntity,
- aFamilyName.c_str());
- aComment2EntryMap[aComment.latin1()] =
+ ++anIter;
+ }
+ }
+ };
+}
+
+void
+VISU::Result_i
+::BuildGroups()
+{
+ TMemManager aMemManager(this);
+
+ QString aComment;
+ myInput->BuildGroups();
+ string aRefFatherEntry = GetRefFatherEntry();
+ const TMeshMap& aMeshMap = myInput->GetMeshMap();
+ TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+ const string& aMeshName = aMeshMapIter->first;
+ const PMesh& aMesh = aMeshMapIter->second;
+
+ const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ if(aMeshOnEntityMap.empty())
+ continue;
+
+ TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+ for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+ const TEntity& anEntity = aMeshOnEntityMapIter->first;
+ const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+ for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
+ const string& aFamilyName = aFamilyMapIter->first;
+ const PFamily& aFamily = aFamilyMapIter->second;
+ aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
+ TFAMILY,
+ aMeshName.c_str(),
+ anEntity,
+ aFamilyName.c_str());
+ aFamily->myEntry =
+ CreateAttributes(myStudyDocument,
+ aMeshOnEntity->myEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ aFamilyName.c_str(),
+ "",
+ aComment.latin1(),
+ true);
+ }
+ }
+ //Importing groups
+ const TGroupMap& aGroupMap = aMesh->myGroupMap;
+ if(!aGroupMap.empty()){
+ aComment.sprintf("myComment=GROUPS;myMeshName=%s",
+ aMeshName.c_str());
+ string aGroupsEntry =
+ CreateAttributes(myStudyDocument,
+ aMesh->myEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ "Groups",
+ "",
+ aComment.latin1(),
+ true);
+ TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
+ for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
+ const string& aGroupName = aGroupMapIter->first;
+ const PGroup& aGroup = aGroupMapIter->second;
+ aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
+ TGROUP,aMeshName.c_str(),aGroupName.c_str());
+ aGroup->myEntry =
+ CreateAttributes(myStudyDocument,
+ aGroupsEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ aGroupName.c_str(),
+ "",
+ aComment.latin1(),
+ true);
+ const TFamilySet& aFamilySet = aGroup->myFamilySet;
+ TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
+ for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
+ const PFamily& aFamily = *aFamilyIter;
+ CreateReference(myStudyDocument,
+ aGroup->myEntry,
+ aFamily->myEntry);
+ }
+ }
+ }
+ }
+
+ ProcessVoidEvent(new TUpdateObjBrowser(myStudyDocument->StudyId()));
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildFields()
+{
+ TMemManager aMemManager(this);
+
+ QString aComment;
+ myInput->BuildFields();
+ string aRefFatherEntry = GetRefFatherEntry();
+ const TMeshMap& aMeshMap = myInput->GetMeshMap();
+ TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+ const string& aMeshName = aMeshMapIter->first;
+ const PMesh& aMesh = aMeshMapIter->second;
+
+ const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ if(aMeshOnEntityMap.empty())
+ continue;
+
+ //Import fields
+ string aFieldsEntry;
+ bool anIsFieldsEntryCreated = false;
+
+ TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+ for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+ const TEntity& anEntity = aMeshOnEntityMapIter->first;
+ const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+ const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+ for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
+ if(!anIsFieldsEntryCreated){
+ aComment.sprintf("myComment=FIELDS;myMeshName=%s",
+ aMeshName.c_str());
+ aFieldsEntry =
CreateAttributes(myStudyDocument,
- aEntity2EntryMap[anEntity].c_str(),
+ aMesh->myEntry.c_str(),
aRefFatherEntry.c_str(),
"",
- aFamilyName.c_str(),
+ "Fields",
"",
aComment.latin1(),
true);
+ anIsFieldsEntryCreated = true;
}
- }
- //Importing groups
- const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
- if(aGroupMap.size() > 0){
- aComment.sprintf("myComment=GROUPS;myMeshName=%s",
- aMeshName.c_str());
- string aGroupsEntry =
+ const string& aFieldName = aFieldMapIter->first;
+ const PField& aField = aFieldMapIter->second;
+ const TValField& aValField = aField->myValField;
+ QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]);
+ aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
+ VISU::TFIELD,
+ aMeshName.c_str(),
+ anEntity,
+ aFieldName.c_str(),
+ aValField.size(),
+ aField->myNbComp);
+ aField->myEntry =
CreateAttributes(myStudyDocument,
- aMeshEntry.c_str(),
+ aFieldsEntry.c_str(),
aRefFatherEntry.c_str(),
"",
- "Groups",
+ aFieldNameWithUnit.latin1(),
"",
aComment.latin1(),
true);
- VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
- for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
- const string& aGroupName = aGroupMapIter->first;
- aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
- VISU::TGROUP,aMeshName.c_str(),aGroupName.c_str());
- string aGroupEntry = CreateAttributes(myStudyDocument,aGroupsEntry.c_str(),aRefFatherEntry.c_str(),
- "",aGroupName.c_str(),"",aComment.latin1(),true);
- const VISU::PGroup aGroup = aGroupMapIter->second;
- const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
- VISU::TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
- for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
- const VISU::PFamily& aFamily = *aFamilyIter;
- const string& aFamilyName = aFamily->myName;
- const VISU::TEntity& anEntity = aFamily->myEntity;
- aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
- VISU::TFAMILY,
- aMeshName.c_str(),
- anEntity,
- aFamilyName.c_str());
- TComment2EntryMap::const_iterator anIter = aComment2EntryMap.find(aComment.latin1());
- if(anIter != aComment2EntryMap.end()){
- const std::string& anEntry = anIter->second;
- CreateReference(myStudyDocument,aGroupEntry,anEntry);
- }
- }
- }
- }
- //Import fields
- string aFieldsEntry;
- bool isFieldEntryCreated = 0;
- aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
- const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
- const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
- const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
- for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
- if(!isFieldEntryCreated){
- aComment.sprintf("myComment=FIELDS;myMeshName=%s",
- aMeshName.c_str());
- aFieldsEntry =
- CreateAttributes(myStudyDocument,
- aMeshEntry.c_str(),
- aRefFatherEntry.c_str(),
- "",
- "Fields",
- "",
- aComment.latin1(),
- true);
- isFieldEntryCreated = true;
- }
- const string& aFieldName = aFieldMapIter->first;
- const VISU::PField aField = aFieldMapIter->second;
- const VISU::TValField& aValField = aField->myValField;
- QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField->myUnitNames[0]);
- aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
- VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField->myNbComp);
- string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(),
- "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true);
- CreateReference(myStudyDocument,aFieldEntry,aEntity2EntryMap[anEntity]);
- VISU::TValField::const_iterator aValFieldIter = aValField.begin();
- for(; aValFieldIter != aValField.end(); aValFieldIter++){
- int aTimeStamp = aValFieldIter->first;
- const VISU::PValForTime aValForTime = aValFieldIter->second;
- aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField->myNbComp);
- string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
- CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(),
- "",aTimeStampId.c_str(),"",aComment.latin1(),true);
- }
+ CreateReference(myStudyDocument,
+ aField->myEntry,
+ aMeshOnEntity->myEntry);
+ TValField::const_iterator aValFieldIter = aValField.begin();
+ for(; aValFieldIter != aValField.end(); aValFieldIter++){
+ int aTimeStamp = aValFieldIter->first;
+ const PValForTime& aValForTime = aValFieldIter->second;
+ aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
+ VISU::TTIMESTAMP,
+ aMeshName.c_str(),
+ anEntity,
+ aFieldName.c_str(),
+ aTimeStamp,
+ aField->myNbComp);
+ string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
+ aValForTime->myEntry =
+ CreateAttributes(myStudyDocument,
+ aField->myEntry.c_str(),
+ aRefFatherEntry.c_str(),
+ "",
+ aTimeStampId.c_str(),
+ "",
+ aComment.latin1(),
+ true);
}
}
}
- bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
- if(isBuildAll) BuildAll();
+ }
+
+ ProcessVoidEvent(new TUpdateObjBrowser(myStudyDocument->StudyId()));
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::BuildMinMax()
+{
+ TMemManager aMemManager(this);
+
+ myInput->BuildMinMax();
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::Build(SALOMEDS::SObject_ptr theSObject)
+{
+ bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
+ if(isBuildAll)
+ return BuildAll(theSObject);
+ else{
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+
+ BuildEntities(theSObject);
+
+ boost::thread(boost::bind(&Result_i::BuildFields,this));
+
+ boost::thread(boost::bind(&Result_i::BuildGroups,this));
+
+ boost::thread(boost::bind(&Result_i::BuildMinMax,this));
+
+ aStudyBuilder->CommitCommand();
+
+ return this;
+ }
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::BuildAll(SALOMEDS::SObject_ptr theSObject)
+{
+ SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
+ aStudyBuilder->NewCommand(); // There is a transaction
+
+ if(MYDEBUG) MESSAGE("Result_i::Build");
+ try{
+ BuildEntities(theSObject);
+ BuildFields();
+ BuildGroups();
+ BuildAll();
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
return NULL;
INFOS("Unknown exception was occured!!!");
return NULL;
}
+
aStudyBuilder->CommitCommand();
+
return this;
}
+//---------------------------------------------------------------
VISU::Storable*
VISU::Result_i::
Create(const char* theFileName)
}
+//---------------------------------------------------------------
VISU::Storable*
VISU::Result_i::
Create(SALOMEDS::SObject_ptr theMedSObject)
return NULL;
}
+
+//---------------------------------------------------------------
VISU::Storable*
VISU::Result_i::
Create(SALOME_MED::FIELD_ptr theField)
}
+//---------------------------------------------------------------
VISU::Storable*
VISU::Result_i::
Restore(SALOMEDS::SObject_ptr theSObject,
return NULL;
}
-VISU::Result_i::TInput* VISU::Result_i::GetInput() {
+//---------------------------------------------------------------
+VISU::Result_i::TInput*
+VISU::Result_i
+::GetInput()
+{
return myInput;
}
-void VISU::Result_i::ToStream(std::ostringstream& theStr){
+//---------------------------------------------------------------
+void
+VISU::Result_i
+::ToStream(std::ostringstream& theStr)
+{
if(MYDEBUG) MESSAGE(GetComment());
Storable::DataToStream(theStr,"myName",myName.c_str());
Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
Storable::DataToStream(theStr,"myCreationId",myCreationId);
}
+
+//---------------------------------------------------------------
VISU::Storable*
-VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
- const string& thePrefix,
- const Storable::TRestoringMap& theMap)
+VISU::Result_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix,
+ const Storable::TRestoringMap& theMap)
{
SALOMEDS::Study_var aStudy = theSObject->GetStudy();
return pResult->Restore(theSObject,theMap,thePrefix);
}
-string VISU::Result_i::GetRefFatherEntry() {
+
+//---------------------------------------------------------------
+string
+VISU::Result_i
+::GetRefFatherEntry()
+{
//return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry();
return "";
}
-string VISU::Result_i::GetEntry(){
+string
+VISU::Result_i
+::GetEntry()
+{
CORBA::String_var anEntry = mySObject->GetID();
return string(anEntry);
}
-const SALOMEDS::SObject_var& VISU::Result_i::GetSObject() const { return mySObject;}
-const SALOMEDS::Study_var& VISU::Result_i::GetStudyDocument() const { return myStudyDocument;}
-const SALOMEDS::SComponent_var& VISU::Result_i::GetSComponent() const { return mySComponent;}
-std::string VISU::Result_i::GetEntry(const std::string& theComment)
+const SALOMEDS::SObject_var&
+VISU::Result_i
+::GetSObject() const
+{
+ return mySObject;
+}
+
+const SALOMEDS::Study_var&
+VISU::Result_i
+::GetStudyDocument() const
+{
+ return myStudyDocument;
+}
+
+const SALOMEDS::SComponent_var&
+VISU::Result_i
+::GetSComponent() const
+{
+ return mySComponent;
+}
+
+std::string
+VISU::Result_i
+::GetEntry(const std::string& theComment)
{
return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str());
}
-VISU::Result_i::~Result_i()
+
+//---------------------------------------------------------------
+VISU::Result_i
+::~Result_i()
{
MESSAGE("Result_i::~Result_i() - this = "<<this);
if (mySourceId == eRestoredFile) {