1 // Copyright (C) 2007-2008 OPEN CASCADE, CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : ghs3dprl_mesh_parser.cxx
22 // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
28 #include "ghs3dprl_msg_parser.h"
29 #include "ghs3dprl_mesh_wrap.h"
31 using namespace med_2_2;
33 //************************************
34 bool ghs3dprl_msg_parser::startDocument()
39 neighbours="neighbours";
41 neighbour="neighbour";
54 verbose=false; //true; //false;
58 //************************************
59 bool ghs3dprl_msg_parser::startElement(const QString &namespaceURI,
60 const QString &localName,
62 const QXmlAttributes &attrs)
65 if (verbose) std::cout<<indent.toLatin1().constData()<<qName.toLatin1().constData()<<std::endl;
66 typel=qName; shorttypel="";
74 if (qName==neighbours)
77 if (attrs.count()>0 && attrs.localName(0)==count)
79 neighbourscount=attrs.value(0).toLong(&ok, 10);
81 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
82 "="<<neighbourscount<<std::endl;
90 if (attrs.count()>0 && attrs.localName(0)==indice)
92 neighbourindice=attrs.value(0).toLong(&ok, 10);
94 //mailw.neighbourindices[mailw.neighbourcourant]=neighbourindice;
95 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
96 "="<<neighbourindice<<std::endl;
104 sendreceive="s/r=send ";
105 shortsendreceive="SE ";
112 sendreceive="s/r=receive ";
113 shortsendreceive="RE ";
121 if (attrs.count()>0 && attrs.localName(0)==count)
123 nbcount=attrs.value(0).toLong(&ok, 10);
124 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
125 "="<<nbcount<<std::endl;
134 if (attrs.count()>0 && attrs.localName(0)==count)
136 nbcount=attrs.value(0).toLong(&ok, 10);
137 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
138 "="<<nbcount<<std::endl;
147 if (attrs.count()>0 && attrs.localName(0)==count)
149 nbcount=attrs.value(0).toLong(&ok, 10);
150 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
151 "="<<nbcount<<std::endl;
160 if (attrs.count()>0 && attrs.localName(0)==count)
162 nbcount=attrs.value(0).toLong(&ok, 10);
163 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
164 "="<<nbcount<<std::endl;
169 /*for( int i=0; i<attrs.count(); i++ )
171 std::cout<<indent.toLatin1().constData()<<attrs.localName(i).toLatin1().constData()<<"="<<attrs.value(i)<<std::endl;
177 //************************************
178 bool ghs3dprl_msg_parser::endElement(const QString &namespaceURI,
179 const QString &localName,
180 const QString &qName)
182 indent.remove((uint)0,3);
183 if (verbose) std::cout<<indent.toLatin1().constData()<<"\\"<<qName.toLatin1().constData()<<std::endl;
184 nbcount=0; //precaution
185 if (qName==send || qName==receive)
199 //************************************
200 bool ghs3dprl_msg_parser::characters(const QString &strini)
205 //filtre rc,lf,tab et blancs successifs
206 QString str=strini.simplified();
207 //if ( str.length() == 1 && str=="\n" )
210 //std::cout<<"EMPTY_LINE_CR"<<std::endl;
217 double ver=str.toDouble(&ok);
220 std::cout<<"version "<<str.toLatin1().constData()<<" fichier .msg inconnue"<<std::endl;
225 nb=str.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
228 //lecture vecteurs d'entiers separateur blanc
230 tmint=new med_int[nb];
231 //printf("%staille attendue=%i taille vue=%i\n",(const char *)indent.toLatin1().constData(),nbcount,nb);
234 tmint[i]=str.section(' ',i,i).toLong(&ok);
235 //printf("tmint[%i]=%i\n",i,tmint[i]);
237 } while ((i<nb) && ok );
240 std::cout<<"pb conversion "<<i<<" eme entier="<<str.section(' ',i-1,i-1).toLatin1().constData()<<std::endl;
241 std::cout<<indent.toLatin1().constData()<<"etat="<<etat<<" nb="<<nb<<std::endl<<str.toLatin1().constData()<<std::endl;
246 tmint=new med_int[nb];
247 tmint[0]=str.toLong(&ok);
250 std::cout<<"pb conversion 1er entier="<<str.toLatin1().constData()<<std::endl;
251 std::cout<<indent.toLatin1().constData()<<"etat="<<etat<<" nb="<<nb<<std::endl;
256 //lecture ok stockage de tlong dans mailw.mestab
257 CVWtab *montab=new CVWtab(nb,tmint);
259 /*std::cout<<"InsertKey type="<<typel<<" "<<sendreceive<<
260 " neighbour="<<neighbourindice<<
261 " file="<<mailw->nofile<<std::endl;*/
262 tmp=tmp.sprintf("MS%ld NE%ld ",
263 mailw->nofile,neighbourindice)+
264 shorttypel+shortsendreceive;
265 tmp=tmp.simplified();
266 ok=mailw->insert_key(tmp,montab);