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"
28 #include "VISU_ConvertorUtils.hxx"
32 #include <vtkCellType.h>
34 #include <qfileinfo.h>
35 #include <qstringlist.h>
41 static int MYDEBUG = 1;
43 static int MYDEBUG = 0;
46 void parseFile(const char* theFileName) {
48 cout<<"'"<<theFileName<<"'...\n";
49 auto_ptr<VISU_Convertor> aCon(CreateConvertor(theFileName));
52 const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
53 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
54 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
55 const string& aMeshName = aMeshMapIter->first;
56 const VISU::TMesh& aMesh = aMeshMapIter->second;
57 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
58 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
60 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
61 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
62 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
63 const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
64 const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
65 VISU::TFieldMap::const_reverse_iterator aFieldMapIter = aFieldMap.rbegin();
66 for(; aFieldMapIter != aFieldMap.rend(); aFieldMapIter++){
67 const string& aFieldName = aFieldMapIter->first;
68 const VISU::TField& aField = aFieldMapIter->second;
69 const VISU::TField::TValField& aValField = aField.myValField;
70 VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
71 for(; aValFieldIter != aValField.end(); aValFieldIter++){
72 int aTimeStamp = aValFieldIter->first;
73 aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
80 const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
81 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
82 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
83 const string& aGroupName = aGroupMapIter->first;
84 aCon->GetMeshOnGroup(aMeshName,aGroupName);
87 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
88 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
89 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
90 const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
91 //aCon->GetMeshOnEntity(aMeshName,anEntity);
92 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
93 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
94 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
95 const string& aFamilyName = aFamilyMapIter->first;
96 aCon->GetMeshOnEntity(aMeshName,anEntity,aFamilyName);
99 //Import mesh on entity
100 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
101 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
102 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
103 aCon->GetMeshOnEntity(aMeshName,anEntity);
108 }catch(std::runtime_error& exc){
109 MESSAGE("Follow exception was accured in file:"<<theFileName<<"\n"<<exc.what());
111 MESSAGE("Unknown exception was accured in VISU_Convertor_impl in file:"<<theFileName);
115 int main(int argc, char** argv){
118 QFileInfo fi(argv[1]);
119 for(int i = 0; i < 1; i++){
122 QDir aDir(fi.absFilePath());
123 QStringList aStringList = aDir.entryList("*.med",QDir::Files);
124 int jEnd = aStringList.count();
125 for(int j = 0; j < jEnd; j++){
126 parseFile(aDir.filePath(aStringList[j]).latin1());
135 }catch(std::runtime_error& exc){
136 cout<<"Follow exception was accured :\n"<<exc.what()<<endl;
138 cout<<"Unknown exception was accured in VISU_Convertor_impl"<<endl;