1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "UNV2417_Structure.hxx"
21 #include "UNV_Utilities.hxx"
28 using namespace UNV2417;
31 static int MYDEBUG = 0;
33 static int MYDEBUG = 0;
37 static string _group_labels[] = {"2417", "2429", "2430", "2432",
38 "2435", "2452", "2467", "2477"};
41 static string _label_dataset = "2467";
43 void UNV2417::Read(std::ifstream& in_stream, TDataSet& theDataSet)
46 EXCEPTION(runtime_error,"ERROR: Input file not good.");
48 std::string olds, news;
51 in_stream >> olds >> news;
53 * a "-1" followed by a number means the beginning of a dataset
54 * stop combing at the end of the file
56 while( ((olds != "-1") || (news == "-1") ) && !in_stream.eof() ){
62 for (int i = 0; i < NBGROUP; i++) {
63 if (news == _group_labels[i]) {
64 ReadGroup(news, in_stream, theDataSet);
72 void UNV2417::ReadGroup(const std::string& myGroupLabel, std::ifstream& in_stream, TDataSet& theDataSet)
75 for(; !in_stream.eof();){
78 // end of dataset is reached
85 in_stream>>aTmp; // miss not necessary values
93 std::getline(in_stream, aRec.GroupName, '\n'); // Finalise previous reading
94 std::getline(in_stream, aRec.GroupName, '\n');
99 for(int j=0; j < n_nodes; j++){
102 if ((myGroupLabel.compare("2435") == 0) ||
103 (myGroupLabel.compare("2452") == 0) ||
104 (myGroupLabel.compare("2467") == 0) ||
105 (myGroupLabel.compare("2477") == 0)) {
111 aNum = aRec.NodeList.size();
112 aRec.NodeList.resize(aNum + 1);
113 aRec.NodeList[aNum] = aElId;
116 aNum = aRec.ElementList.size();
117 aRec.ElementList.resize(aNum + 1);
118 aRec.ElementList[aNum] = aElId;
122 theDataSet.insert(TDataSet::value_type(aId,aRec));
128 void UNV2417::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
130 if(!out_stream.good())
131 EXCEPTION(runtime_error,"ERROR: Output file not good.");
134 * Write beginning of dataset
137 out_stream<<" "<<_label_dataset<<"\n";
139 TDataSet::const_iterator anIter = theDataSet.begin();
140 for(; anIter != theDataSet.end(); anIter++){
141 const TGroupId& aLabel = anIter->first;
142 const TRecord& aRec = anIter->second;
143 int aNbNodes = aRec.NodeList.size();
144 int aNbElements = aRec.ElementList.size();
145 int aNbRecords = aNbNodes + aNbElements;
147 out_stream<<std::setw(10)<<aLabel; /* group ID */
148 out_stream<<std::setw(10)<<0;
149 out_stream<<std::setw(10)<<0;
150 out_stream<<std::setw(10)<<0;
151 out_stream<<std::setw(10)<<0;
152 out_stream<<std::setw(10)<<0;
153 out_stream<<std::setw(10)<<0;
154 out_stream<<std::setw(10)<<aNbRecords<<std::endl;
156 out_stream<<aRec.GroupName<<std::endl;
159 for (i = 0; i < aNbNodes; i++) {
161 out_stream<<std::endl;
164 out_stream<<std::setw(10)<<7;
165 out_stream<<std::setw(10)<<aRec.NodeList[i];
166 out_stream<<std::setw(10)<<0;
167 out_stream<<std::setw(10)<<0;
170 for (i = 0; i < aNbElements; i++) {
172 out_stream<<std::endl;
175 out_stream<<std::setw(10)<<8;
176 out_stream<<std::setw(10)<<aRec.ElementList[i];
177 out_stream<<std::setw(10)<<0;
178 out_stream<<std::setw(10)<<0;
181 out_stream<<std::endl;
185 * Write end of dataset