using namespace VISU;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
case ePENTA15: return VTK_WEDGE;
case ePYRA5: return VTK_PYRAMID;
case ePYRA13: return VTK_PYRAMID;
+ case ePOLYGONE: return VTK_POLYGON;
+ case ePOLYEDRE: return VTK_CONVEX_POINT_SET;
}
return -1;
}
case VTK_HEXAHEDRON: return eHEXA8;
case VTK_WEDGE: return ePENTA6;
case VTK_PYRAMID: return ePYRA5;
+ case VTK_POLYGON: return ePOLYGONE;
+ case VTK_CONVEX_POINT_SET: return ePOLYEDRE;
}
return EGeometrieElement(-1);
}
MSG(MYDEBUG,"VISU_MedConvertor::Build()");
INITMSG(MYDEBUG,"GetNbMeshes() = "<<aNbMeshes<<"\n");
- for(TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++){
-
+ for (TInt iMesh = 1; iMesh <= aNbMeshes; iMesh++) {
+ try {
PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh);
-
- PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+ PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
+
MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
- TCellGroup aCellGroup = GetCellsByEntity(aMed,aMeshInfo,aEntityInfo);
+ TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo);
TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo);
- TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aCellGroup,aFamilyGroup);
+ TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aElemGroup,aFamilyGroup);
TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup);
aMeshOnEntity->myCellsSize = 0;
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
const EGeometrieElement& aGeom = anTGeomIter->first;
- int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom));
- PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aCellInfo->GetNbElem();
- aMeshOnEntity->myNbCells += aNbElem;
- aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
- "; myNbCells = "<<aMeshOnEntity->myNbCells<<
- "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
-
- for(TInt iElem = 0; iElem < aMesh->myNbPoints; iElem++){
- TInt aFamId = aCellInfo->GetFamNum(iElem);
- if(aFamId != 0){
- aFamilyNbCellsCounterMap[aFamId] += 1;
- aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
+
+ switch(aGeom){
+ case ePOLYGONE:
+ {
+ PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aPolygoneInfo->GetNbElem();
+ TElemNum aConn = aPolygoneInfo->GetConnectivite();
+ TElemNum aIndex = aPolygoneInfo->GetIndex();
+ TInt aNbIndex = aIndex.size();
+ TInt aNbConn = aConn.size();
+
+ aMeshOnEntity->myNbCells += aNbElem;
+
+ for (int ii = 0; ii<aNbElem ; ii++){
+ int aNbConnii = aPolygoneInfo->GetNbConn(ii);
+ aMeshOnEntity->myCellsSize += aNbConnii;
+ }
+ INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+ "; myNbPolygones = "<<aNbElem<<
+ "; nbConn= "<<aNbConn<<"\n");
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ TInt aFamId = aPolygoneInfo->GetFamNum(iElem);
+ if(aFamId != 0){
+ aFamilyNbCellsCounterMap[aFamId] += 1;
+ ADDMSG(MYDEBUG,"aFamId="<<aFamId<<" ");
+ aFamilyCellsSizeCounterMap[aFamId] += aPolygoneInfo->GetNbConn(iElem) + 1;
+ }
+ }
+ ADDMSG(MYDEBUG,endl);
+ break;
}
- }
+ case ePOLYEDRE:
+ {
+ PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aPolyedreInfo->GetNbElem();
+ TElemNum aConn = aPolyedreInfo->GetConnectivite();
+ TElemNum aIndex = aPolyedreInfo->GetIndex();
+ TInt aNbIndex = aIndex.size();
+ TInt aNbConn = aConn.size();
+
+ aMeshOnEntity->myNbCells += aNbElem;
+
+ for (int ii = 0; ii<aNbElem ; ii++){
+ int aNbConnii = aPolyedreInfo->GetNbConn(ii);
+ aMeshOnEntity->myCellsSize += aNbConnii;
+ }
+ INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+ "; myNbPolyedres = "<<aNbElem<<
+ "; nbConn= "<<aNbConn<<"\n");
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ TInt aFamId = aPolyedreInfo->GetFamNum(iElem);
+ std::string aName = aPolyedreInfo->GetElemName(iElem);
+ if(aFamId != 0){
+ aFamilyNbCellsCounterMap[aFamId] += 1;
+ ADDMSG(MYDEBUG,"(aFamId="<<aFamId<<";Name='"<<aName<<"') ");
+ aFamilyCellsSizeCounterMap[aFamId] += aPolyedreInfo->GetNbConn(iElem) + 1;
+ }
+ }
+ ADDMSG(MYDEBUG,endl);
+ break;
+ }
+ default:
+ {
+ int aVNbNodes = VTKGeom2NbNodes(MEDGeomToVTK(aGeom));
+ PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aCellInfo->GetNbElem();
+ aMeshOnEntity->myNbCells += aNbElem;
+ aMeshOnEntity->myCellsSize += aNbElem*(aVNbNodes+1);
+ INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<
+ "; myNbCells = "<<aMeshOnEntity->myNbCells<<
+ "; myCellsSize = "<<aMeshOnEntity->myCellsSize<<"\n");
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ TInt aFamId = aCellInfo->GetFamNum(iElem);
+ if(aFamId != 0){
+ aFamilyNbCellsCounterMap[aFamId] += 1;
+ ADDMSG(MYDEBUG,"aFamId = "<<aFamId<<" ");
+ aFamilyCellsSizeCounterMap[aFamId] += aVNbNodes + 1;
+ }
+ }
+ ADDMSG(MYDEBUG,endl);
+ }
+ } // end switch(...)
}
}
}
TEntity aVEntity = MEDEntityToVTK(aMEntity);
VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+
+ if(aFamilyGroup.empty())
+ continue;
INITMSG(MYDEBUG,"aMEntity = "<<aMEntity<<"; aVEntity = "<<aVEntity<<"\n");
TFamilyGroup::const_iterator aFamilyGroupIter = aFamilyGroup.begin();
const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
for (; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
- const string& aFamilyName = aFamilyMapIter->first;
+ const string& aName = aFamilyMapIter->first;
aFamily = aFamilyMapIter->second;
- if(aFamily){
- TFamilyGroup::const_iterator aGroupInfoIter = aFamilyGroup.begin();
- for(; aGroupInfoIter != aFamilyGroup.end(); aGroupInfoIter++){
- const PFamilyInfo& aFamilyInfo = *aGroupInfoIter;
- if(aFamilyInfo->GetName() == aFamilyName){
- aVEntity = aFamily->myEntity;
- goto exit_lable;
- }
- }
+ if(aName == aFamilyName){
+ aVEntity = aFamily->myEntity;
+ goto exit_lable;
}
}
}
exit_lable:
if(aFamily && aVEntity >= 0){
aGroup->myFamilyAndEntitySet.insert(TFamilyAndEntity(aFamilyName,aVEntity));
- INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; aVEntity = "<<aVEntity<<"\n");
+ INITMSG(MYDEBUG,"aFamilyName = '"<<aFamilyName<<"'; '"<<aFamily->myName<<"'; aVEntity = "<<aVEntity<<"\n");
aGroup->myNbCells += aFamily->myNbCells;
aGroup->myCellsSize += aFamily->myCellsSize;
}
}
- BEGMSG(MYDEBUG,"VISU::TField:\n");
-
TInt aNbFields = aMed->GetNbFields();
+ BEGMSG(MYDEBUG,"VISU::TField: NbFields="<<aNbFields<<"\n");
for(TInt iField = 1; iField <= aNbFields; iField++){
PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField);
TInt aNbComp = aFieldInfo->GetNbComp();
const string& aFieldName = aFieldInfo->GetName();
+ MED::TErr anErr;
MED::TGeom aTGeom;
EEntiteMaillage aMEntity;
- TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom);
+ TInt aNbTimeStamps = aMed->GetNbTimeStamps(aFieldInfo,aEntityInfo,aMEntity,aTGeom,&anErr);
+ if (anErr < 0 || aNbTimeStamps < 1)
+ continue;
TEntity aVEntity = MEDEntityToVTK(aMEntity);
VISU::PMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
PTimeStampInfo aTimeStamp = aMed->GetPTimeStampInfo(aFieldInfo,
aMEntity,
aTGeom,
- iTimeStamp);
+ iTimeStamp,
+ &anErr);
+ if (anErr < 0)
+ continue;
+
TFloat aDt = aTimeStamp->GetDt();
const string& anUnitDt = aTimeStamp->GetUnitDt();
- PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp);
+ PTimeStampVal aTimeStampVal = aMed->GetPTimeStampVal(aTimeStamp,&anErr);
TValField& aValField = aField->myValField;
PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
aValForTime->myId = iTimeStamp;
INITMSG(MYDEBUG,"aDt = "<<aDt<<", "<<anUnitDt<<"\n");
}
}
+ } catch (std::runtime_error& exc){
+ MSG(MYDEBUG,"Follow exception wqs occured in:\n"<<exc.what());
+ } catch(...){
+ EXCEPTION(runtime_error,"Unknown exception !!!");
+ }
}
return this;
int isPointsUpdated;
if(anEntity == VISU::NODE_ENTITY)
isPointsUpdated = LoadPoints(aMed,aMesh,theFamilyName);
- else
+ else
isPointsUpdated = LoadPoints(aMed,aMesh);
int isCellsOnEntityUpdated = LoadCellsOnEntity(aMed,aMesh,theMeshOnEntity,theFamilyName);
if(aFamily && aNbElem > 0){
VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[VTK_VERTEX];
for (int iElem = 0; iElem < aNbElem; iElem++)
- if(aNodeInfo->GetElemNum(iElem) == aFamily->myId)
+ if(aNodeInfo->GetFamNum(iElem) == aFamily->myId)
aSubMeshOnCellType.insert(iElem);
}
return 1;
PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
//Check on loading already done
bool isCellsLoaded = !theMeshOnEntity->myCellsConn.empty();
- if(isCellsLoaded)
+ if(isCellsLoaded)
if(!aFamily)
return 0;
else if(!aFamily->mySubMesh.empty())
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
const EGeometrieElement& aGeom = anTGeomIter->first;
int aVTKGeomType = MEDGeomToVTK(aGeom);
- int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType);
-
- PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
- TInt aNbElem = aCellInfo->GetNbElem();
-
- if(!isCellsLoaded){
- VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType];
- aConnForCellType.resize(aNbElem);
-
- int aMNbNodes = MEDGeom2NbNodes(aGeom);
- vector<TInt> aConnect(aMNbNodes);
-
- for (int iElem = 0; iElem < aNbElem; iElem++) {
- VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem];
- anArray.resize(aVNbNodes);
+ ADDMSG(MYDEBUG,"LoadCellsOnEntity aGeom="<<aGeom<<"\n");
+ switch(aGeom){
+ case ePOLYGONE:
+ {
+ PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aPolygoneInfo->GetNbElem();
+
+ if(!isCellsLoaded){
+ VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolygoneType = aCellsConn[aVTKGeomType];
+ aConnForPolygoneType.resize(aNbElem);
+
+ int aMNbNodes = aPolygoneInfo->GetConnDim();
+
+ vector<TInt> aConnect(aMNbNodes);
+ vector<TInt> aIndex = aPolygoneInfo->GetIndex();
+
+ for (int iElem = 0; iElem < aNbElem; iElem++) {
+ VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolygoneType[iElem];
+ int aNbConn = aPolygoneInfo->GetNbConn(iElem);
+
+ anArray.resize(aNbConn);
+
+ aConnect = aPolygoneInfo->GetConnectivite();
+
+ for (int i=0;i<aNbConn;i++){
+ anArray[i] = aConnect[aIndex[iElem]-1+i]-1;
+ }
+ }
+ }
+ if(aFamily){
+ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
+ for(int iElem = 0; iElem < aNbElem; iElem++)
+ if(aPolygoneInfo->GetFamNum(iElem) == aFamily->myId)
+ aSubMeshOnCellType.insert(iElem);
+ }
+ break;
+ }
+ case ePOLYEDRE:
+ {
+ PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aPolyedreInfo->GetNbElem();
+
+ int aMNbNodes = aPolyedreInfo->GetNbConn();
+ vector<TInt> aConnect(aMNbNodes);
+ aConnect = aPolyedreInfo->GetConnectivite();
+
+ if(!isCellsLoaded){
+ VISU::TMeshOnEntityImpl::TConnForCellType& aConnForPolyedreType = aCellsConn[aVTKGeomType];
+ aConnForPolyedreType.resize(aNbElem);
+
+ vector<TInt> aFacesIndex = aPolyedreInfo->GetFacesIndex();
+ vector<TInt> aIndex = aPolyedreInfo->GetIndex();
+
+ for (int iElem = 0; iElem < aNbElem; iElem++) {
+ set<TInt> aArrayNew;
+ VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForPolyedreType[iElem];
+
+ int aInd1 = aIndex[iElem]-1;
+ int aInd2 = aIndex[iElem+1]-2;
+
+ for (int i=aInd1;i<=aInd2;i++){
+ for (int j=aFacesIndex[i]-1;j<aFacesIndex[i+1]-1;j++){
+ aArrayNew.insert(aConnect[j]);
+ }
+ }
+
+ int aNbConnNew = aArrayNew.size();
+ anArray.resize(aNbConnNew);
+ set<TInt>::iterator aIter = aArrayNew.begin();
+ for (int i=0; aIter!=aArrayNew.end();aIter++, i++)
+ anArray[i] = (*aIter)-1;
- if(anIsNodeNum){
- for(int i = 0; i < aMNbNodes; i++){
- aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1];
}
- }else{
- for(int i = 0; i < aMNbNodes; i++){
- aConnect[i] = aCellInfo->GetConn(iElem,i)-1;
+ }
+ if(aFamily){
+ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
+ for(int iElem = 0; iElem < aNbElem; iElem++)
+ if(aPolyedreInfo->GetFamNum(iElem) == aFamily->myId)
+ aSubMeshOnCellType.insert(iElem);
+ }
+ break;
+ }
+ default:
+ {
+ int aVNbNodes = VTKGeom2NbNodes(aVTKGeomType);
+
+ PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aGeom);
+ TInt aNbElem = aCellInfo->GetNbElem();
+
+ if(!isCellsLoaded){
+ VISU::TMeshOnEntityImpl::TConnForCellType& aConnForCellType = aCellsConn[aVTKGeomType];
+ aConnForCellType.resize(aNbElem);
+
+ int aMNbNodes = MEDGeom2NbNodes(aGeom);
+ vector<TInt> aConnect(aMNbNodes);
+
+ for (int iElem = 0; iElem < aNbElem; iElem++) {
+ VISU::TMeshOnEntityImpl::TConnect& anArray = aConnForCellType[iElem];
+ anArray.resize(aVNbNodes);
+
+ if(anIsNodeNum){
+ for(int i = 0; i < aMNbNodes; i++){
+ aConnect[i] = aNodeIdMap[aCellInfo->GetConn(iElem,i)-1];
+ }
+ }else{
+ for(int i = 0; i < aMNbNodes; i++){
+ aConnect[i] = aCellInfo->GetConn(iElem,i)-1;
+ }
+ }
+
+ switch(aGeom){
+ case eTETRA4:
+ case eTETRA10:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[1];
+ anArray[2] = aConnect[3];
+ anArray[3] = aConnect[2];
+ break;
+ case ePYRA5:
+ case ePYRA13:
+ anArray[0] = aConnect[0];
+ anArray[1] = aConnect[3];
+ anArray[2] = aConnect[2];
+ anArray[3] = aConnect[1];
+ anArray[4] = aConnect[4];
+ break;
+ default:
+ for(int iNode = 0; iNode < aVNbNodes; iNode++)
+ anArray[iNode] = aConnect[iNode];
+ }
+ for(int iNode = 0; iNode < aVNbNodes; iNode++)
+ if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
+ EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<<aNbPoints<<") "<<
+ "<= anArray["<<iElem<<"]"<<
+ "["<<iNode<<"]"<<
+ "("<<anArray[iNode]<<") < 0");
}
}
-
- switch(aGeom){
- case eTETRA4:
- case eTETRA10:
- anArray[0] = aConnect[0];
- anArray[1] = aConnect[1];
- anArray[2] = aConnect[3];
- anArray[3] = aConnect[2];
- break;
- case ePYRA5:
- case ePYRA13:
- anArray[0] = aConnect[0];
- anArray[1] = aConnect[3];
- anArray[2] = aConnect[2];
- anArray[3] = aConnect[1];
- anArray[4] = aConnect[4];
- break;
- default:
- for(int iNode = 0; iNode < aVNbNodes; iNode++)
- anArray[iNode] = aConnect[iNode];
+ //Filling aFamily SubMesh
+ if(aFamily){
+ VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
+ for(int iElem = 0; iElem < aNbElem; iElem++)
+ if(aCellInfo->GetFamNum(iElem) == aFamily->myId)
+ aSubMeshOnCellType.insert(iElem);
}
- for(int iNode = 0; iNode < aVNbNodes; iNode++)
- if(anArray[iNode] < 0 || aNbPoints <= anArray[iNode])
- EXCEPTION(runtime_error,"ImportCells >> aNbPoints("<<aNbPoints<<") "<<
- "<= anArray["<<iElem<<"]"<<
- "["<<iNode<<"]"<<
- "("<<anArray[iNode]<<") < 0");
}
}
- //Filling aFamily SubMesh
- if(aFamily){
- VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aFamily->mySubMesh[aVTKGeomType];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aCellInfo->GetFamNum(iElem) == aFamily->myId)
- aSubMeshOnCellType.insert(iElem);
- }
}
return 1;
}catch(std::runtime_error& exc){
TInt aNbComp = theField->myNbComp;
PTimeStampVal aTimeStampVal = theMed->GetPTimeStampVal(aTimeStampInfo);
-
+ bool anIsTrimmed = theField->myIsTrimmed;
INITMSG(MYDEBUG,"LoadField - aMeshName = '"<<aMeshName<<
"'; aFieldName = '"<<aFieldInfo->GetName()<<
"'; aMEntity = "<<aMEntity<<
INITMSG(MYDEBUG,"LoadField - aGeom = "<<aGeom<<"; aNbElem = '"<<aNbElem<<endl);
if(aTGeom.find(aGeom) == aTGeom.end()){
- theField->myDataSize -= aNbElem*theField->myNbComp;
- theField->myIsTrimmed = true;
+ if(!theField->myIsTrimmed){
+ theField->myDataSize -= aNbElem*theField->myNbComp;
+ anIsTrimmed = true;
+ }
}else{
int aVTKGeomType = MEDGeomToVTK(aGeom);
VISU::TValForTimeImpl::TValForCellsWithType& anArray = theValForTime->myValForCells[aVTKGeomType];
}
}
}
+ theField->myIsTrimmed = anIsTrimmed;
return 1;
}