]> SALOME platform Git repositories - modules/smesh.git/blob - src/DriverUNV/UNV2417_Structure.cxx
Salome HOME
f5e84926c78144f83f4757f18c955386e1865416
[modules/smesh.git] / src / DriverUNV / UNV2417_Structure.cxx
1 #include "UNV2417_Structure.hxx"
2 #include "UNV_Utilities.hxx"
3
4 using namespace std;
5 using namespace UNV;
6 using namespace UNV2417;
7
8 #ifdef _DEBUG_
9 static int MYDEBUG = 1;
10 #else
11 static int MYDEBUG = 0;
12 #endif
13
14
15 static string _group_labels[] = {"2417", "2429", "2430", "2432", "2435"};
16 #define NBGROUP 5
17
18 //static string _label_dataset = "2435";
19
20 void UNV2417::Read(std::ifstream& in_stream, TDataSet& theDataSet)
21 {
22   if(!in_stream.good())
23     EXCEPTION(runtime_error,"ERROR: Input file not good.");
24
25   std::string olds, news;
26   
27   while(true){
28     in_stream >> olds >> news;
29     /*
30      * a "-1" followed by a number means the beginning of a dataset
31      * stop combing at the end of the file
32      */
33     while( ((olds != "-1") || (news == "-1") ) && !in_stream.eof() ){     
34       olds = news;
35       in_stream >> news;
36     }
37     if(in_stream.eof())
38       return;
39     for (int i = 0; i < NBGROUP; i++) {
40       if (news == _group_labels[i]) {
41         ReadGroup(news, in_stream, theDataSet);
42       }
43     }
44   }
45 }
46
47
48
49 void UNV2417::ReadGroup(const std::string& myGroupLabel, std::ifstream& in_stream, TDataSet& theDataSet)
50 {
51   TGroupId aId;
52   for(; !in_stream.eof();){
53     in_stream >> aId ;
54     if(aId == -1){
55       // end of dataset is reached
56       break;
57     }
58
59     int n_nodes;
60     TRecord aRec;
61     int aTmp;
62     in_stream>>aTmp; // miss not necessary values
63     in_stream>>aTmp;
64     in_stream>>aTmp;
65     in_stream>>aTmp;
66     in_stream>>aTmp;
67     in_stream>>aTmp;
68     in_stream>>n_nodes;
69
70     in_stream>>aRec.GroupName;
71     
72     int aElType;
73     int aElId;
74     int aNum;
75         for(int j=0; j < n_nodes; j++){
76       in_stream>>aElType;
77       in_stream>>aElId;
78       if (myGroupLabel.compare("2435") == 0) {
79         in_stream>>aTmp;
80         in_stream>>aTmp;
81       }
82       switch (aElType) {
83       case 7: // Nodes
84         aNum = aRec.NodeList.size();
85         aRec.NodeList.resize(aNum + 1);
86         aRec.NodeList[aNum] = aElId;
87         break;
88       case 8: // Elements
89         aNum = aRec.ElementList.size();
90         aRec.ElementList.resize(aNum + 1);
91         aRec.ElementList[aNum] = aElId;
92         break;
93       }
94     }
95     theDataSet.insert(TDataSet::value_type(aId,aRec));
96   }
97
98 }