Salome HOME
d68ef3b5bd2d9d3e45682382103710af3bf53989
[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 static string _label_dataset = "2417";
15
16 void UNV2417::Read(std::ifstream& in_stream, TDataSet& theDataSet)
17 {
18   if(!in_stream.good())
19     EXCEPTION(runtime_error,"ERROR: Input file not good.");
20
21   /*
22    * adjust the \p istream to our
23    * position
24    */
25   if(!beginning_of_dataset(in_stream,_label_dataset))
26     EXCEPTION(runtime_error,"WARNING: Could not find "<<_label_dataset<<" dataset!");
27
28   TGroupId aId;
29   for(; !in_stream.eof();){
30     in_stream >> aId ;
31     if(aId == -1){
32       // end of dataset is reached
33       break;
34     }
35
36     int n_nodes;
37     TRecord aRec;
38     int aTmp;
39     in_stream>>aTmp; // miss not necessary values
40     in_stream>>aTmp;
41     in_stream>>aTmp;
42     in_stream>>aTmp;
43     in_stream>>aTmp;
44     in_stream>>n_nodes;
45
46     int aElType;
47     int aElId;
48     int aNum;
49     for(int j=0; j < n_nodes; j++){
50       in_stream>>aElType;
51       in_stream>>aElId;
52       switch (aElType) {
53       case 7: // Nodes
54         aNum = aRec.NodeList.size();
55         aRec.NodeList.resize(aNum + 1);
56         aRec.NodeList[aNum] = aElId;
57         break;
58       case 8: // Elements
59         aNum = aRec.ElementList.size();
60         aRec.ElementList.resize(aNum + 1);
61         aRec.ElementList[aNum] = aElId;
62         break;
63       }
64     }
65     theDataSet.insert(TDataSet::value_type(aId,aRec));
66   }
67
68 }