| 
      
      
      From: <de...@us...> - 2003-03-18 14:41:44
       | 
| Update of /cvsroot/fudaa/fudaa_devel/dodico/src/org/fudaa/dodico/telemac/io In directory sc8-pr-cvs1:/tmp/cvs-serv30158/dodico/src/org/fudaa/dodico/telemac/io Added Files: TelemacCLReader.java Log Message: ajout des classes io pour telemac --- NEW FILE: TelemacCLReader.java --- /* * @file TelemacCIReader.java * @creation 14 mars 2003 * @modification $Date: 2003/03/18 14:41:40 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail de...@fu... */ package org.fudaa.dodico.telemac.io; import java.io.EOFException; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import org.fudaa.dodico.commun.DodicoLib; import org.fudaa.dodico.fortran.FortranReader; import org.fudaa.dodico.tr.TrReaderAbstract; /** * * @author deniger * @version $Id: TelemacCLReader.java,v 1.1 2003/03/18 14:41:40 deniger Exp $ */ public class TelemacCLReader extends TrReaderAbstract { FortranReader in_; TelemacCLAdapter inter_; int nbPoint_; TelemacCLFileFormat format_; public TelemacCLReader() { this(null); } public TelemacCLReader(TelemacCLFileFormat _f) { super(TelemacCLFileFormat.NB_FILE); format_=_f; if(format_==null) format_=TelemacCLFileFormat.getInstance(); } public void setIn(Reader _r) { if (_r != null) in_ = new FortranReader(_r); } public void setIn(Reader _r, int _sz) { if (_r != null) in_ = new FortranReader(_r, _sz); } public void setNBPointExpected(int _i) { nbPoint_ = _i; } /** * @see org.fudaa.dodico.tr.TrReaderAbstract#read() */ public void read() throws IOException { if (in_ == null) { getAnalyzeFor(0).addTranslateError("Le flux est nul."); return; } in_.setJumpBlankLine(true); ArrayList l = null; if (nbPoint_ > 0) l = new ArrayList(nbPoint_); else l = new ArrayList(100); //Au hasard :-) int index = 0; int nbField; try { TelemacCLLine cl; while (true) { in_.readFields(); nbField = in_.getNumberOfFields(); if (nbField != 13) { getAnalyzeFor(0).addError( "Ligne non valide: elle doit contenir 12 champs", in_); if (nbField == 14) { getAnalyzeFor(0).addInfo("Maillage cartésien non supporté", in_); } return; } cl = new TelemacCLLine(); cl.lihbor_ = in_.intField(0); if(!format_.isCodeHauteur(cl.lihbor_)) { getAnalyzeFor(0).addError(DodicoLib.geti18n("Code inconnu pour la hauteur")+" "+cl.lihbor_, in_, true); return; } cl.liubor_ = in_.intField(1); if(!format_.isCodeVitesse(cl.liubor_)) { getAnalyzeFor(0).addError(DodicoLib.geti18n("Code inconnu pour la vitesse u")+" "+cl.lihbor_, in_, true); return; } cl.livbor_ = in_.intField(2); if(!format_.isCodeVitesse(cl.livbor_)) { getAnalyzeFor(0).addError(DodicoLib.geti18n("Code inconnu pour la vitesse v")+" "+cl.lihbor_, in_, true); return; } cl.hbor_ = in_.doubleField(3); cl.ubor_ = in_.doubleField(4); cl.vbor_ = in_.doubleField(5); cl.aubor_ = in_.doubleField(6); cl.litbor_ = in_.intField(7); if(!format_.isCodeTraceur(cl.litbor_)) { getAnalyzeFor(0).addError(DodicoLib.geti18n("Code inconnu pour le traceur")+" "+cl.lihbor_, in_, true); return; } cl.tbor_ = in_.doubleField(8); cl.atbor_ = in_.doubleField(9); cl.btbor_ = in_.doubleField(10); cl.n_ = in_.intField(11); cl.k_ = in_.intField(12); index++; if (cl.k_ != index) { getAnalyzeFor(0).addError("L'index donne est invalide", in_, true); getAnalyzeFor(0).addInfo( DodicoLib.geti18n("index donné") + ": " + cl.k_ + DodicoLib.LINE_SEP + DodicoLib.geti18n("index attendu") + ": " + index, in_, true); return; } l.add(cl); } } catch (EOFException _oef) { if (DodicoLib.DEBUG) System.out.println("Lecture terminée"); } catch (NumberFormatException _ex) { getAnalyzeFor(0).addError( DodicoLib.geti18n("Format invalide") + " " + _ex.getMessage(), in_); return; } int n=l.size(); inter_=null; if(n>0) { TelemacCLLine[] lines=new TelemacCLLine[n]; l.toArray(lines); inter_=new TelemacCLAdapter(lines); } } /** * @see org.fudaa.dodico.tr.TrReaderAbstract#getInterface() */ public Object getInterface() { return getTelemacCLInterface(); } public TelemacCLInterface getTelemacCLInterface() { return inter_; } /** * @see org.fudaa.dodico.tr.TrReaderWriterAbstract#close() */ public IOException[] close() { return null; } } |