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 "VISU_Convertor.hxx"
31 #include <vtkCellType.h>
33 #include <qfileinfo.h>
34 #include <qstringlist.h>
40 static int MYDEBUG = 1;
42 static int MYDEBUG = 0;
45 void parseFile(const char* theFileName) throw(std::runtime_error&){
47 cout<<"'"<<theFileName<<"'...";
48 auto_ptr<VISU_Convertor> aCon(CreateConvertor(theFileName));
49 const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
51 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
52 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
53 const string& aMeshName = aMeshMapIter->first;
54 const VISU::TMesh& aMesh = aMeshMapIter->second;
55 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
56 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
58 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
59 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
60 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
61 const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
62 const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
63 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
64 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
65 const string& aFieldName = aFieldMapIter->first;
66 const VISU::TField& aField = aFieldMapIter->second;
67 const VISU::TField::TValField& aValField = aField.myValField;
68 VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
69 for(; aValFieldIter != aValField.end(); aValFieldIter++){
70 int aTimeStamp = aValFieldIter->first;
71 aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
76 const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
77 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
78 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
79 const string& aGroupName = aGroupMapIter->first;
80 aCon->GetMeshOnGroup(aMeshName,aGroupName);
83 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
84 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
85 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
86 const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
87 //aCon->GetMeshOnEntity(aMeshName,anEntity);
88 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
89 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
90 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
91 const string& aFamilyName = aFamilyMapIter->first;
92 aCon->GetMeshOnEntity(aMeshName,anEntity,aFamilyName);
95 //Import mesh on entity
96 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
97 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
98 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
99 aCon->GetMeshOnEntity(aMeshName,anEntity);
103 }catch(std::runtime_error& exc){
104 MESSAGE("Follow exception was accured in file:"<<theFileName<<"\n"<<exc.what());
106 MESSAGE("Unknown exception was accured in VISU_Convertor_impl in file:"<<theFileName);
110 int main(int argc, char** argv){
113 QFileInfo fi(argv[1]);
114 for(int i = 0; i < 1; i++){
117 QDir aDir(fi.absFilePath());
118 QStringList aStringList = aDir.entryList("*.med",QDir::Files);
119 int jEnd = aStringList.count();
120 for(int j = 0; j < jEnd; j++){
121 parseFile(aDir.filePath(aStringList[j]).latin1());
130 }catch(std::runtime_error& exc){
131 cout<<"Follow exception was accured :\n"<<exc.what()<<endl;
133 cout<<"Unknown exception was accured in VISU_Convertor_impl"<<endl;