1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File: VISUConvertor.cxx
24 // Author: Alexey PETROV
27 #include "MED_Structures.hxx"
28 #include "MED_Wrapper.hxx"
29 #include "MED_Utilities.hxx"
34 static int MYDEBUG = 1;
36 static int MYDEBUG = 0;
40 void ReadMed(const char* theFileName){
42 TWrapper aMed(theFileName);
43 string aFileName = theFileName;
45 TWrapper aMedW(aFileName);
47 int aNbMeshes = aMed.GetNbMeshes();
48 MESSAGE("GetNbMeshes() = "<<aNbMeshes);
51 for(int iMesh = 0; iMesh < aNbMeshes; iMesh++){
52 PMeshInfo aMeshInfo(new TMeshInfo());
53 PMeshInfo aNewMeshInfo(new TMeshInfo());
54 aMed.GetMeshInfo(iMesh+1,*aMeshInfo);
55 int aDim = aMeshInfo->myDim;
56 aName = aMeshInfo->GetName();
57 MESSAGE("GetMeshInfo - aName = '"<<aName<<"'; aDim = "<<aDim);
58 *aNewMeshInfo = *aMeshInfo;
60 aNewMeshInfo->SetName(aName);
61 aMedW.SetMeshInfo(*aNewMeshInfo);
63 TEntityInfo aEntityInfo = aMed.GetEntityInfo(*aMeshInfo);
65 med_int aNbFields = aMed.GetNbFields();
66 MESSAGE("GetNbFields() = "<<aNbFields);
67 for(int iField = 0; iField < aNbFields; iField++){
68 med_int aNbComp = aMed.GetNbComp(iField+1);
69 PFieldInfo aFieldInfo(new TFieldInfo(aMeshInfo,aNbComp));
70 aMed.GetFieldInfo(iField+1,*aFieldInfo);
71 MESSAGE("\taName = '"<<aFieldInfo->GetName()<<"'; aNbComp = "<<aNbComp<<"; ");
72 aMedW.SetFieldInfo(*aFieldInfo);
73 med_entite_maillage anEntity;
75 med_int aNbTimeStamps = aMed.GetNbTimeStamps(*aFieldInfo,aEntityInfo,
77 MESSAGE("GetNbTimeStamps = "<<aNbTimeStamps);
78 PTimeStampInfo aTimeStampInfo(new TTimeStampInfo(aFieldInfo,anEntity,aTGeom));
79 for(int iTimeStamp = 0; iTimeStamp < aNbTimeStamps; iTimeStamp++){
80 aMed.GetTimeStampInfo(iTimeStamp+1, *aTimeStampInfo);
82 TTimeStampVal aTimeStampVal(aTimeStampInfo);
83 aMed.GetTimeStampVal(aTimeStampVal);
84 aMedW.SetTimeStamp(aTimeStampVal);
86 TMeshValue& aMeshValue = aTimeStampVal.myMeshValue;
87 TMeshValue::iterator aMeshValueIter = aMeshValue.begin();
88 for(; aMeshValueIter != aMeshValue.end(); aMeshValueIter++){
89 med_geometrie_element aGeom = aMeshValueIter->first;
90 TValue aValue = aMeshValueIter->second;
91 MESSAGE("\t\taGeom = "<<aGeom<<"; aValue = "<<aValue.size()<<": ");
92 for(int i = 0, iEnd = aValue.size()/aNbComp; i < iEnd; i++){
93 for(int j = 0, ij = i*aNbComp; j < aNbComp; j++, ij++){
94 //MESSAGE(aValue[ij]<<",");
103 int aNbFam = aMed.GetNbFamilies(*aMeshInfo);
104 MESSAGE("GetNbFamilies() = "<<aNbFam);
105 for(int iFam = 0; iFam < aNbFam; iFam++){
106 int aNbAttr = aMed.GetNbFamAttr(iFam+1,*aMeshInfo);
107 int aNbGroup = aMed.GetNbFamGroup(iFam+1,*aMeshInfo);
108 PFamilyInfo aFamilyInfo(new TFamilyInfo(aMeshInfo,aNbGroup,aNbAttr));
109 aMed.GetFamilyInfo(iFam+1,*aFamilyInfo);
110 aName = aFamilyInfo->GetName();
111 MESSAGE("\taName = '"<<aName<<"'; aNbAttr = "<<aNbAttr<<"; aNbGroup = "<<aNbGroup);
113 aFamilyInfo->SetName(aName);
114 aFamilyInfo->myMeshInfo = aNewMeshInfo;
115 aName = aFamilyInfo->GetName();
116 for(int iGroup = 0; iGroup < aNbGroup; iGroup++){
117 aName = aFamilyInfo->GetGroupName(iGroup);
118 MESSAGE("\t\taGroupName = '"<<aName<<"'");
120 aFamilyInfo->SetGroupName(iGroup,aName);
123 aMedW.SetFamilyInfo(*aFamilyInfo);
126 MESSAGE("GetEntityInfo - aNbEntities = "<<aEntityInfo.size());
127 TEntityInfo::iterator anEntityInfoIter = aEntityInfo.begin();
128 for(; anEntityInfoIter != aEntityInfo.end(); anEntityInfoIter++){
129 const med_entite_maillage& anEntity = anEntityInfoIter->first;
130 MESSAGE("\tanEntity = "<<anEntity);
131 if(anEntity == MED_NOEUD){
132 int aNbNodes = aMed.GetNbNodes(*aMeshInfo);
133 PNodeInfo aNodeInfo(new TNodeInfo(aMeshInfo,aNbNodes));
134 aMed.GetNodeInfo(*aNodeInfo);
135 MESSAGE("\tGetNodeInfo - aNbNodes = "<<aNbNodes<<": ");
136 TNodeCoord& aCoord = aNodeInfo->myCoord;
137 for(int iNode = 0; iNode < aNbNodes; iNode++){
138 for(int iDim = 0, anId = iNode*aDim; iDim < aDim; iDim++, anId++){
139 //MESSAGE(aCoord[anId]<<",");
145 aNodeInfo->myMeshInfo = aNewMeshInfo;
146 aMedW.SetNodeInfo(*aNodeInfo);
149 TGeom& aTGeom = anEntityInfoIter->second;
150 TGeom::iterator anTGeomIter = aTGeom.begin();
151 for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
152 const med_geometrie_element& aGeom = anTGeomIter->first;
153 med_int& aNbElem = anTGeomIter->second;
154 MESSAGE("\t\taGeom = "<<aGeom<<"; aNbElem = "<<aNbElem<<": ");
155 PCellInfo aCellInfo(new TCellInfo(aMeshInfo,aNbElem,anEntity,aGeom));
156 aMed.GetCellInfo(*aCellInfo);
157 for(int iElem = 0; iElem < aCellInfo->myNbElem; iElem++){
158 int i = iElem*aCellInfo->myConnDim;
159 for(int iConn = 0; iConn < aCellInfo->myConnDim; iConn++, i++){
160 //MESSAGE(aCellInfo->myConn[i]<<",");
165 aCellInfo->myMeshInfo = aNewMeshInfo;
166 aMedW.SetCellInfo(*aCellInfo);
175 int main(int argc, char** argv){
180 }catch(std::exception& exc){
181 MESSAGE("Follow exception was accured :\n"<<exc.what());
183 MESSAGE("Unknown exception was accured in VISU_Convertor_impl");