1 // Copyright (C) 2007-2023 CEA, EDF
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, or (at your option) any later version.
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)
27 #include "ghs3dprl_msg_parser.h"
28 #include "ghs3dprl_mesh_wrap.h"
30 //************************************
31 bool ghs3dprl_msg_parser::startDocument()
36 neighbours="neighbours";
38 neighbour="neighbour";
51 verbose=false; //true; //false;
55 //************************************
56 bool ghs3dprl_msg_parser::startElement(const QString &/*namespaceURI*/,
57 const QString &/*localName*/,
59 const QXmlAttributes &attrs)
62 if (verbose) std::cout<<indent.toLatin1().constData()<<qName.toLatin1().constData()<<std::endl;
63 typel=qName; shorttypel="";
71 if (qName==neighbours)
74 if (attrs.count()>0 && attrs.localName(0)==count)
76 neighbourscount=attrs.value(0).toLong(&ok, 10);
78 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
79 "="<<neighbourscount<<std::endl;
87 if (attrs.count()>0 && attrs.localName(0)==indice)
89 neighbourindice=attrs.value(0).toLong(&ok, 10);
91 //mailw.neighbourindices[mailw.neighbourcourant]=neighbourindice;
92 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
93 "="<<neighbourindice<<std::endl;
101 sendreceive="s/r=send ";
102 shortsendreceive="SE ";
109 sendreceive="s/r=receive ";
110 shortsendreceive="RE ";
118 if (attrs.count()>0 && attrs.localName(0)==count)
120 nbcount=attrs.value(0).toLong(&ok, 10);
121 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
122 "="<<nbcount<<std::endl;
131 if (attrs.count()>0 && attrs.localName(0)==count)
133 nbcount=attrs.value(0).toLong(&ok, 10);
134 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
135 "="<<nbcount<<std::endl;
144 if (attrs.count()>0 && attrs.localName(0)==count)
146 nbcount=attrs.value(0).toLong(&ok, 10);
147 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
148 "="<<nbcount<<std::endl;
157 if (attrs.count()>0 && attrs.localName(0)==count)
159 nbcount=attrs.value(0).toLong(&ok, 10);
160 if (verbose) std::cout<<indent.toLatin1().constData()<<attrs.localName(0).toLatin1().constData()<<
161 "="<<nbcount<<std::endl;
166 /*for( int i=0; i<attrs.count(); i++ )
168 std::cout<<indent.toLatin1().constData()<<attrs.localName(i).toLatin1().constData()<<"="<<attrs.value(i)<<std::endl;
174 //************************************
175 bool ghs3dprl_msg_parser::endElement(const QString &/*namespaceURI*/,
176 const QString &/*localName*/,
177 const QString &qName)
179 indent.remove((uint)0,3);
180 if (verbose) std::cout<<indent.toLatin1().constData()<<"\\"<<qName.toLatin1().constData()<<std::endl;
181 nbcount=0; //precaution
182 if (qName==send || qName==receive)
196 //************************************
197 bool ghs3dprl_msg_parser::characters(const QString &strini)
202 //filtre rc,lf,tab et blancs successifs
203 QString str=strini.simplified();
204 //if ( str.length() == 1 && str=="\n" )
207 //std::cout<<"EMPTY_LINE_CR"<<std::endl;
214 double ver=str.toDouble(&ok);
217 std::cout<<"version "<<str.toLatin1().constData()<<" fichier .msg inconnue"<<std::endl;
222 nb=str.count(' ',Qt::CaseSensitive) + 1; //nb chiffres detectes
225 //lecture vecteurs d'entiers separateur blanc
227 tmint=new med_int[nb];
228 //printf("%staille attendue=%i taille vue=%i\n",(const char *)indent.toLatin1().constData(),nbcount,nb);
231 tmint[i]=str.section(' ',i,i).toLong(&ok);
232 //printf("tmint[%i]=%i\n",i,tmint[i]);
234 } while ((i<nb) && ok );
237 std::cout<<"pb conversion "<<i<<" eme entier="<<str.section(' ',i-1,i-1).toLatin1().constData()<<std::endl;
238 std::cout<<indent.toLatin1().constData()<<"etat="<<etat<<" nb="<<nb<<std::endl<<str.toLatin1().constData()<<std::endl;
243 tmint=new med_int[nb];
244 tmint[0]=str.toLong(&ok);
247 std::cout<<"pb conversion 1er entier="<<str.toLatin1().constData()<<std::endl;
248 std::cout<<indent.toLatin1().constData()<<"etat="<<etat<<" nb="<<nb<<std::endl;
253 //lecture ok stockage de tlong dans mailw.mestab
254 CVWtab *montab=new CVWtab(nb,tmint);
256 /*std::cout<<"InsertKey type="<<typel<<" "<<sendreceive<<
257 " neighbour="<<neighbourindice<<
258 " file="<<mailw->nofile<<std::endl;*/
259 tmp=tmp.sprintf("MS%ld NE%ld ",
260 mailw->nofile,neighbourindice)+
261 shorttypel+shortsendreceive;
262 tmp=tmp.simplified();
263 ok=mailw->insert_key(tmp,montab);