From: <de...@us...> - 2009-02-23 22:38:23
|
Revision: 4492 http://fudaa.svn.sourceforge.net/fudaa/?rev=4492&view=rev Author: deniger Date: 2009-02-23 22:38:17 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinAdapter.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinGridSourceAdapter.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinInterface.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageAdapter.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapter.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapterAbstract.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReader.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReaderInfo.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinWriter.java branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJSerafin.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeConfigureTarget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbePersist.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportActSerafin.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportSerafinFormatAdapter.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileTreeModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrCourbeTemporelleManager.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrEvolutionManager.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/ScopCourbeTreeModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeTreeModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderCommonAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderComposite.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderInterface.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderReflux.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderSerafin.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceRubar.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionFusionGraphes.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/supg_column.volfin branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/volfin Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinAdapter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinAdapter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -28,6 +28,20 @@ public class SerafinAdapter implements SerafinInterface { /** + * @return the isVolumique + */ + public boolean isVolumique() { + return isVolumique_; + } + + /** + * @param _isVolumique the isVolumique to set + */ + public void setVolumique(boolean _isVolumique) { + isVolumique_ = _isVolumique; + } + + /** * Les donnees sont stockees par pas de temps puis par variables. donneesParTemps_[0] pas de temps 1 variables 1 * donneesParTemps_[1] pas de temps 1 variables 2 ..... donneesParTemps_[Nbv1-1] pas de temps 1 variables Nbv1 * donneesParTemps_[Nbv1] pas de temps 2 variables 1 @@ -61,6 +75,9 @@ private String[] uniteVariables_; SerafinNewReaderInfo info_; int[] ipoboFr_; + + private boolean isVolumique_; + /** * rien. */ @@ -71,9 +88,7 @@ } protected boolean majGridFond(final int _timeStep) { - if (_timeStep < 0) { - return false; - } + if (_timeStep < 0) { return false; } final String[] fond = SerafinFileFormat.getCommonVariableFond(); int numVariable = -1; for (int i = 0; i < fond.length; i++) { @@ -82,9 +97,7 @@ break; } } - if (numVariable < 0) { - return false; - } + if (numVariable < 0) { return false; } try { maillage_ = new EfGridBathyAdapter(new EfDataNode(getDonnees(_timeStep, numVariable)), maillage_); } catch (final IOException _evt) { @@ -97,11 +110,11 @@ } public boolean containsElementData() { - return false; + return isVolumique_; } public boolean containsNodeData() { - return true; + return !isVolumique_; } /** @@ -110,27 +123,23 @@ * @return toutes les valeurs dans l'ordre donne des point. */ public double[] getDonnees(final int _pasTemps, final int _numVariable) throws IOException { - if (nbv1_ <= 0) { - return null; - } - if (info_ != null) { - return info_.getDouble(_numVariable, _pasTemps); - } + if (nbv1_ <= 0) { return null; } + if (info_ != null) { return info_.getDouble(_numVariable, _pasTemps); } return donneesParTemps_[_pasTemps * nbv1_ + _numVariable]; } - public double getEltValue(final int _valueIdx, final int _eltIdx, final int _timeStep) { - return 0; - } + // public double getEltValue(final int _valueIdx, final int _eltIdx, final int _timeStep) { + // return 0; + // } + // + // public String getEltValueId(final int _valueIdx) { + // return null; + // } + // + // public int getEltValueNb() { + // return 0; + // } - public String getEltValueId(final int _valueIdx) { - return null; - } - - public int getEltValueNb() { - return 0; - } - public FileFormat getFileFormat() { return SerafinFileFormat.getInstance(); } @@ -205,9 +214,7 @@ } public double getTimeStep(final int _i) { - if (temps_ == null) { - return 0; - } + if (temps_ == null) { return 0; } return temps_[_i]; } @@ -249,12 +256,8 @@ * @return Donnees */ public double getValue(final int _numVariable, final int _pasTemps, final int _i) throws IOException { - if (nbv1_ <= 0) { - return 0; - } - if (info_ != null) { - return info_.getDouble(_numVariable, _pasTemps)[_i]; - } + if (nbv1_ <= 0) { return 0; } + if (info_ != null) { return info_.getDouble(_numVariable, _pasTemps)[_i]; } return donneesParTemps_[_pasTemps * nbv1_ + _numVariable][_i]; } @@ -300,7 +303,7 @@ } public boolean isElement(final int _idx) { - return false; + return isVolumique_; } /** Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinGridSourceAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinGridSourceAdapter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinGridSourceAdapter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -44,11 +44,11 @@ } public boolean containsElementData() { - return false; + return isVolumique(); } public boolean containsNodeData() { - return true; + return !isVolumique(); } public double getEltValue(final int _valueIdx, final int _eltIdx, final int _timeStep) { @@ -86,9 +86,7 @@ public int[] getIpoboInitial() { if (source_.getGrid().getFrontiers() == null) { source_.getGrid().computeBord(null, null); - if (source_.getGrid().getFrontiers() == null) { - return null; - } + if (source_.getGrid().getFrontiers() == null) { return null; } } return source_.getGrid().getFrontiers().getIpobo(source_.getGrid().getPtsNb()); } @@ -96,9 +94,7 @@ public int[] getIpoboFr() { if (source_.getGrid().getFrontiers() == null) { source_.getGrid().computeBord(null, null); - if (source_.getGrid().getFrontiers() == null) { - return null; - } + if (source_.getGrid().getFrontiers() == null) { return null; } } return source_.getGrid().getFrontiers().getArray(); } @@ -128,6 +124,10 @@ .getGrid().getPtZ(_ptIdx) : source_.getValue(_numVariable - 1, _pasTemps, _ptIdx)); } + public boolean isVolumique() { + return false; + } + public String getValueId(final int _i) { return fondInValue_ ? source_.getValueId(_i) : (_i == 0 ? fond_ : source_.getValueId(_i)); } @@ -137,7 +137,7 @@ } public boolean isElement(final int _idx) { - return false; + return isVolumique(); } /** Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinInterface.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinInterface.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinInterface.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -84,4 +84,9 @@ int getTimeStepNb(); double getTimeStep(int _i); + + /** + * @return true si les r\xE9sultats sont d\xE9finies aux \xE9l\xE9ments + */ + boolean isVolumique(); } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageAdapter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageAdapter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -129,9 +129,7 @@ * @return M */ public String getUnite(final int _i) { - if (_i == 0) { - return "M"; - } + if (_i == 0) { return "M"; } return null; } @@ -178,9 +176,7 @@ * @param _pasTemps le pas de temps (doit etre = \xE0 0) */ public double getValue(final int _numVariable, final int _pasTemps, final int _i) { - if (_pasTemps != 0) { - return 0; - } + if (_pasTemps != 0) { return 0; } if (_numVariable == 0) { return maill_.getPtZ(_i); } else if ((bottom_ != null) && (_numVariable == 1)) { @@ -190,6 +186,10 @@ } } + public boolean isVolumique() { + return false; + } + /** * */ Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -3,13 +3,14 @@ * @modification $Date: 2007-01-10 09:04:27 $ * @license GNU General Public License 2 * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne -* @mail de...@fu... + * @mail de...@fu... */ package org.fudaa.dodico.telemac.io; import org.fudaa.ctulu.collection.CtuluCollectionDouble; import org.fudaa.dodico.ef.EfGridInterface; + /** * @author deniger * @version $Id: SerafinMaillageBuilderAdapter.java,v 1.11 2007-01-10 09:04:27 deniger Exp $ @@ -21,69 +22,69 @@ /** * Par defaut le format colonne est choisi. + * * @param _ft la verison * @param _m le maillage support */ public SerafinMaillageBuilderAdapter(final SerafinFileFormatVersionInterface _ft, final EfGridInterface _m) { - super(_ft,_m); + super(_ft, _m); } - public final double getFirstTimeStep(){ + + public final double getFirstTimeStep() { return firstTimeStep_; } - public double getTimeStep(final int _i){ + + public double getTimeStep(final int _i) { return firstTimeStep_; } /** * */ - public int getTimeStepNb(){ + public int getTimeStepNb() { return 1; } /** * Ne renvoie que les donnees pour le fond ou pour la friction si definie. + * * @param _numVariable le numero de la variable * @param _i l'index du point * @param _pasTemps le pas de temps (doit etre = \xE0 0) */ - public double getValue(final int _numVariable,final int _pasTemps,final int _i){ - if (_pasTemps != 0) { - return 0; - } + public double getValue(final int _numVariable, final int _pasTemps, final int _i) { + if (_pasTemps != 0) { return 0; } return values_[_numVariable].getValue(_i); } - - public String getValueId(final int _i){ + public String getValueId(final int _i) { return valuesName_[_i]; } - public int getValueNb(){ + public int getValueNb() { return values_ == null ? 0 : values_.length; } - - - - public boolean isElement(final int _idx){ - return false; + public boolean isVolumique() { + return isVolumique_; } - public final void setFirstTimeStep(final double _firstTimeStep){ + public final void setFirstTimeStep(final double _firstTimeStep) { firstTimeStep_ = _firstTimeStep; } + boolean isVolumique_; + /** * @param _title les noms des valeurs a ajoutees * @param _values les valeurs en chaque point * @param _units les unites */ - public void setValues(final String[] _title,final CtuluCollectionDouble[] _values,final String[] _units){ + public void setValues(final String[] _title, final CtuluCollectionDouble[] _values, final String[] _units) { valuesName_ = _title; values_ = _values; units_ = _units; + isVolumique_ = _values != null && _values[0] != null && _values[0].getSize() == getGrid().getEltNb(); } - } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapterAbstract.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapterAbstract.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinMaillageBuilderAdapterAbstract.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -42,25 +42,13 @@ } public boolean containsElementData() { - return false; + return isVolumique(); } public boolean containsNodeData() { - return true; + return !isVolumique(); } - public double getEltValue(final int _valueIdx, final int _eltIdx, final int _timeStep) { - return 0; - } - - public String getEltValueId(final int _valueIdx) { - return null; - } - - public int getEltValueNb() { - return 0; - } - /** * */ @@ -87,9 +75,7 @@ public int[] getIpoboInitial() { if (maill_.getFrontiers() == null) { maill_.computeBord(null, null); - if (maill_.getFrontiers() == null) { - return null; - } + if (maill_.getFrontiers() == null) { return null; } } return maill_.getFrontiers().getIpobo(maill_.getPtsNb()); } @@ -97,9 +83,7 @@ public int[] getIpoboFr() { if (maill_.getFrontiers() == null) { maill_.computeBord(null, null); - if (maill_.getFrontiers() == null) { - return null; - } + if (maill_.getFrontiers() == null) { return null; } } return maill_.getFrontiers().getArray(); } @@ -121,7 +105,7 @@ } public boolean isElement(final int _idx) { - return false; + return isVolumique(); } /** Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReader.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReader.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReader.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -38,9 +38,24 @@ */ public class SerafinNewReader extends FileReadOperationAbstract { + /** + * @return the isVolumique + */ + public boolean isVolumique() { + return isVolumique_; + } + + /** + * @param _isVolumique the isVolumique to set + */ + public void setVolumique(boolean _isVolumique) { + isVolumique_ = _isVolumique; + } + FileInputStream in_; NativeNIOHelper helper_; File file_; + boolean isVolumique_; boolean onlyReadLast_; // correctio long readTimeStepFrom_ = -1; @@ -255,17 +270,19 @@ * utilise pour chaque pas de temps. Il y a NPPOIN1 entier par variable et Nbv1 variable. Rappel:les entiers * prennent 4 octets. Rappel:chaque enregistrement est entoure par des entiers d'ou les 4 */ + // TODO fred ici comment savoir si volumique ou resultat aux noeud. + int nbVar = isVolumique_ ? nelem1 : npoin1; if (SerafinFileFormat.isFormatEnColonneCommon(iparam)) { /* - * Dans le cas colonne, on a TEMPS : TEMPS+4 variable1 : 4+NPPOIN1*4+4 variablei : 4+NPPOIN1*4+4 pour chaque - * variable soit: tempo= 4+4+Nbv1*(4+NPPOINT*4+4) d'ou + * Dans le cas colonne, on a TEMPS : TEMPS+4 variable1 : 4+NPPOIN14+4 variablei : 4+NPPOIN14+4 pour chaque + * variable soit: tempo= 4+4+Nbv1(4+NPPOINT4+4) d'ou */ - tempo = 12 + 4 * nbv1 * npoin1 + 8 * nbv1; + tempo = 12 + 4 * nbv1 * nbVar + 8 * nbv1; } else { /* - * Temps,variable1,variablei,... soit 4+(NPPOIN1*4)*Nbv1+4 + * Temps,variable1,variablei,... soit 4+(NPPOIN14)Nbv1+4 */ - tempo = 12 + 4 * nbv1 * npoin1; + tempo = 12 + 4 * nbv1 * nbVar; } // nb d'octets restants a lire divise par nb octets par pas de temps. @@ -283,7 +300,7 @@ final boolean isFormatColonne = SerafinFileFormat.isFormatEnColonneCommon(iparam); final ProgressionUpdater up = new ProgressionUpdater(progress_); up.setValue(7, nbPasTempsEstime, 30, 70); - info = new SerafinNewReaderInfo(npoin1, helper_.getCurrentPosition(), file_); + info = new SerafinNewReaderInfo(nbVar, helper_.getCurrentPosition(), file_, isVolumique_); info.setColonne(isFormatColonne); info.setTimeEnrLength(tempo); info.setOrder(helper_.getOrder()); Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReaderInfo.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReaderInfo.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinNewReaderInfo.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -20,37 +20,46 @@ */ public class SerafinNewReaderInfo { + ByteBuffer buffer_; + + FileChannel channel_; + final File file_; private final long firstTimeStepPos_; private boolean isColonne_; + final int nbValues_; + int nbVar_; + ByteBuffer oneDouble_; private ByteOrder order_; private long timeEnrLength_; - ByteBuffer buffer_; - FileChannel channel_; - int nbPoint_; - final File file_; - int nbVar_; + final boolean volumique_; /** - * @param _nbPoint + * @param _nbValue le nombre de valeur definies. Peut etre le nombre de noeud ou le nombre d'element si resultat + * volumique. * @param _channel */ - public SerafinNewReaderInfo(final int _nbPoint, final long _pos, final File _file) { + public SerafinNewReaderInfo(final int _nbValue, final long _pos, final File _file, boolean _volumique) { super(); - nbPoint_ = _nbPoint; + nbValues_ = _nbValue; file_ = _file; firstTimeStepPos_ = _pos; + volumique_=_volumique; } - private void createChannel() throws IOException { - if (channel_ == null) { - channel_ = new FileInputStream(file_).getChannel(); + public void close() { + if (channel_ == null) { return; } + try { + + channel_.close(); + } catch (final IOException e) { + e.printStackTrace(); } } protected ByteBuffer createBuffer() { if (buffer_ == null) { - buffer_ = ByteBuffer.allocateDirect(4 * nbPoint_); + buffer_ = ByteBuffer.allocateDirect(4 * nbValues_); if (order_ != null) { buffer_.order(order_); } @@ -68,46 +77,12 @@ return oneDouble_; } - public void close() { + private void createChannel() throws IOException { if (channel_ == null) { - return; + channel_ = new FileInputStream(file_).getChannel(); } - try { - - channel_.close(); - } catch (final IOException e) { - e.printStackTrace(); - } } - ByteBuffer oneDouble_; - - public synchronized double getDouble(final int _nbV, final int _timeStep, final int _idxPt) throws IOException { - createChannel(); - createBufferOneDouble(); - long pos = firstTimeStepPos_ + _timeStep * timeEnrLength_; - if (isColonne_) { - // [Seq][t][Seq]+([Seq]pt0,pt1,...[Seq])*nbV1+ [Seq] - // les 12 correspondent a la sequence pour le pas de temps - // ensuite chaque variables demande 2 entier (seq) +nbPoint valeurs - pos += 12 + _nbV * (8 + nbPoint_ * 4) + 4; - } else { - // [Seq][t][v0 in x0][vo in x1][vo in x2]... [Seq] - pos += 4 + 4 + (_nbV * nbPoint_ * 4); - } - pos += _idxPt * 4; - channel_.position(pos); - oneDouble_.rewind(); - channel_.read(oneDouble_); - oneDouble_.rewind(); - return oneDouble_.getFloat(); - } - - public int getTimeStepAvailable() throws IOException { - final long size = channel_ == null ? file_.length() : channel_.size(); - return (int) ((size - firstTimeStepPos_) / timeEnrLength_); - } - /** * @param _nbV le nombre de variable * @param _timeStep le pas de temps @@ -123,24 +98,43 @@ // [Seq][t][Seq]+([Seq]pt0,pt1,...[Seq])*nbV1+ [Seq] // les 12 correspondent a la sequence pour le pas de temps // ensuite chaque variables demande 2 entier (seq) +nbPoint valeurs - pos += 12L + _nbV * (8L + nbPoint_ * 4L) + 4L; + pos += 12L + _nbV * (8L + nbValues_ * 4L) + 4L; } else { // [Seq][t][v0 in x0][vo in x1][vo in x2]... [Seq] - pos += 4L + 4L + (_nbV * nbPoint_ * 4L); + pos += 4L + 4L + (_nbV * nbValues_ * 4L); } - final double[] r = new double[nbPoint_]; - if (!channel_.isOpen()) { - return null; - } + final double[] r = new double[nbValues_]; + if (!channel_.isOpen()) { return null; } channel_.position(pos); channel_.read(buffer_); buffer_.rewind(); - for (int i = 0; i < nbPoint_; i++) { + for (int i = 0; i < nbValues_; i++) { r[i] = buffer_.getFloat(); } return r; } + public synchronized double getDouble(final int _nbV, final int _timeStep, final int _idxPt) throws IOException { + createChannel(); + createBufferOneDouble(); + long pos = firstTimeStepPos_ + _timeStep * timeEnrLength_; + if (isColonne_) { + // [Seq][t][Seq]+([Seq]pt0,pt1,...[Seq])*nbV1+ [Seq] + // les 12 correspondent a la sequence pour le pas de temps + // ensuite chaque variables demande 2 entier (seq) +nbPoint valeurs + pos += 12 + _nbV * (8 + nbValues_ * 4) + 4; + } else { + // [Seq][t][v0 in x0][vo in x1][vo in x2]... [Seq] + pos += 4 + 4 + (_nbV * nbValues_ * 4); + } + pos += _idxPt * 4; + channel_.position(pos); + oneDouble_.rewind(); + channel_.read(oneDouble_); + oneDouble_.rewind(); + return oneDouble_.getFloat(); + } + public final long getFirstTimeStepPos() { return firstTimeStepPos_; } @@ -153,6 +147,18 @@ return timeEnrLength_; } + public int getTimeStepAvailable() throws IOException { + final long size = channel_ == null ? file_.length() : channel_.size(); + return (int) ((size - firstTimeStepPos_) / timeEnrLength_); + } + + /** + * @return the volumique + */ + public boolean isVolumique() { + return volumique_; + } + public final void setColonne(final boolean _isColonne) { isColonne_ = _isColonne; } Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinWriter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinWriter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/SerafinWriter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -33,7 +33,8 @@ import org.fudaa.dodico.h2d.resource.H2dResource; /** - * Classe permettant d'ecrire un fichier serafin (utilise un buffer pour l'ecriture). + * TODO a modifier pour prendre en compte l'aspect volumique. Classe permettant d'ecrire un fichier serafin (utilise un + * buffer pour l'ecriture). * * @version $Id: SerafinWriter.java,v 1.34 2007-05-04 13:47:27 deniger Exp $ * @author Fred Deniger @@ -65,12 +66,8 @@ */ private boolean isDoubleToFloatError(final double _d) { final double d = _d > 0 ? _d : -_d; - if (d > Float.MAX_VALUE) { - return true; - } - if ((d > 0) && (d < Float.MIN_VALUE)) { - return true; - } + if (d > Float.MAX_VALUE) { return true; } + if ((d > 0) && (d < Float.MIN_VALUE)) { return true; } return false; } @@ -234,10 +231,9 @@ final int nbv1 = _donnees.getValueNb(); final int nelem = maillage.getEltNb(); final int npt = maillage.getPtsNb(); + final int nbValues = _donnees.isVolumique() ? nelem : npt; final int nppel = maillage.getElement(0).getPtNb(); - if (stop_) { - return; - } + if (stop_) { return; } final int[] iparam = _donnees.getIparam(); final boolean isIdateDefini = version_.isIdateDefini(iparam); final boolean isFormatColonne = version_.isFormatEnColonne(iparam); @@ -248,9 +244,9 @@ } final long tailleIkle1 = 8L + 4L * nelem * nppel; final long tailleX1 = 8L + npt * 4L; - long tailleTemps = 12L + 4L * nbv1 * npt; + long tailleTemps = 12L + 4L * nbv1 * nbValues; if (isFormatColonne) { - tailleTemps = 12L + 4L * nbv1 * npt + 8L * nbv1; + tailleTemps = 12L + 4L * nbv1 * nbValues + 8L * nbv1; } tailleTotale_ = tailleDebut + tailleIkle1 + tailleX1 * 3L + nbPasTemps * tailleTemps; // TITRE @@ -265,9 +261,7 @@ _out.writeRecord(); // TEXTi LUNITi writeVariables(_donnees, _out, nbv1); - if (stop_) { - return; - } + if (stop_) { return; } // IPARAM // tIA tableau d'entier tempo writeIparam(_out, iparam); @@ -287,9 +281,7 @@ // H2dElement[] elems= maillage.getElts(); EfElement eltIndex; for (int i = 0; i < nelem; i++) { - if (stop_) { - return; - } + if (stop_) { return; } eltIndex = maillage.getElement(i); for (int j = 0; j < nppel; j++) { _out.writeInteger(eltIndex.getPtIndex(j) + 1); @@ -298,22 +290,16 @@ _out.writeRecord(); lu = updateProg(lu + tailleIkle1); writeIpobo(_donnees, _out, npt); - if (stop_) { - return; - } + if (stop_) { return; } lu = updateProg(lu + tailleX1); // H2dPoint[] pts = maillage.getPts(); // X1 writeNodesX(_out, maillage, npt); - if (stop_) { - return; - } + if (stop_) { return; } lu = updateProg(lu + tailleX1); // Y1 writeNodesY(_out, maillage, npt); - if (stop_) { - return; - } + if (stop_) { return; } lu = updateProg(lu + tailleX1); // double[] tDA = donnees_.getPasDeTemps(); for (int t = 0; t < nbPasTemps; t++) { @@ -330,7 +316,7 @@ if (isFormatColonne) { _out.writeRecord(); } - for (int j = 0; j < npt; j++) { + for (int j = 0; j < nbValues; j++) { tD = getCorrectDoubleValue(_donnees.getValue(i, t, j)); if (isDoubleToFloatError(tD)) { analyze_.addError("Erreur de conversion lors de l'\xE9criture des Donn\xE9es", t); @@ -353,9 +339,7 @@ private void writeNodesY(final FortranBinaryOutputStream _out, final EfGridInterface _maillage, final int _npt) throws IOException { for (int i = 0; i < _npt; i++) { - if (stop_) { - return; - } + if (stop_) { return; } final double tD = getCorrectDoubleValue(_maillage.getPtY(i)); if (isDoubleToFloatError(tD)) { analyze_.addError(H2dResource.getS("Erreur de conversion lors de l'\xE9criture des Y"), i); @@ -369,9 +353,7 @@ private void writeNodesX(final FortranBinaryOutputStream _out, final EfGridInterface _maillage, final int _npt) throws IOException { for (int i = 0; i < _npt; i++) { - if (stop_) { - return; - } + if (stop_) { return; } final double tD = getCorrectDoubleValue(_maillage.getPtX(i)); if (isDoubleToFloatError(tD)) { analyze_.addError(H2dResource.getS("Erreur de conversion lors de l'\xE9criture des X"), i); @@ -388,9 +370,7 @@ final int[] ipobo = _inter.getIpoboInitial(); // IPOBO for (int i = 0; i < _npt; i++) { - if (stop_) { - return; - } + if (stop_) { return; } _out.writeInteger(ipobo[i]); } _out.writeRecord(); Modified: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJSerafin.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJSerafin.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJSerafin.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -50,6 +50,25 @@ interfaceTest((SerafinInterface) s.getSource()); } + public void testVolfin() { + File f = getFile("supg_column.volfin"); + final SerafinNewReader r = new SerafinNewReader(); + r.setFile(f); + r.setVolumique(true); + final CtuluIOOperationSynthese s = r.read(); + s.printAnalyze(); + assertFalse(s.containsFatalError()); + SerafinInterface t = (SerafinInterface) s.getSource(); + System.err.println(t.getTitre()); + try { + double[] values = t.getReadingInfo().getDouble(0, 0); + assertEquals(t.getGrid().getEltNb(), values.length); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + protected void interfaceTest(final SerafinInterface _t) { assertNotNull(_t); // TITRE @@ -169,6 +188,10 @@ final int nbTimeStep = initTimeStep + 100; SerafinInterface newInter = new SerafinInterface() { + public boolean isVolumique() { + return r.isVolumique(); + } + public boolean isElement(int _idx) { return r.isElement(_idx); } @@ -191,7 +214,7 @@ public double getValue(int _numVariable, int _pasTemps, int _ptIdx) throws IOException { if (_pasTemps < initTimeStep) { return r.getValue(_numVariable, _pasTemps, _ptIdx); } - return Math.random() ; + return Math.random(); } public String getUnite(int _i) { @@ -208,7 +231,7 @@ public double getTimeStep(int _i) { if (_i < initTimeStep) return r.getTimeStep(_i); - return maxTime + (1+_i - initTimeStep) * delta; + return maxTime + (1 + _i - initTimeStep) * delta; } public SerafinNewReaderInfo getReadingInfo() { Added: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/supg_column.volfin =================================================================== (Binary files differ) Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/supg_column.volfin ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/volfin =================================================================== (Binary files differ) Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/volfin ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -213,9 +213,9 @@ // x = xmax - 6 - _g.getFontMetrics().stringWidth(str); // } tbox_.paintBox(_g, xie,y, str); - int widthBox=5; - if(tbox_.currentWidth_!=-1) - widthBox=tbox_.currentWidth_; +// int widthBox=5; +// if(tbox_.currentWidth_!=-1) +// widthBox=tbox_.currentWidth_; new TraceLigne(marqueur.model_).dessineTrait(_g, xie/*+widthBox/2*/,y , xie/*+widthBox/2*/, ymax); @@ -520,16 +520,16 @@ } - public boolean isNuagePoints_() { + public boolean isNuagePoints() { return nuagePoints_; } - public void setNuagePoints_(boolean nuagePoints_) { - this.nuagePoints_ = nuagePoints_; + public void setNuagePoints(boolean _nuagePoints) { + this.nuagePoints_ = _nuagePoints; } - public boolean setNuagePointEtApplique(boolean nuagePOints){ - setNuagePoints_(nuagePoints_); + public boolean setNuagePointEtApplique(boolean _nuagePOints){ + setNuagePoints(nuagePoints_); fireCourbeAspectChanged(false); //fireCourbeContentChanged(); return true; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeConfigureTarget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeConfigureTarget.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbeConfigureTarget.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -76,7 +76,7 @@ return target_.getFont(); } if (_key == EGCourbeConfigureTarget.PROP_NUAGE_POINTS) { - return target_.isNuagePoints_(); + return target_.isNuagePoints(); } return null; Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbePersist.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbePersist.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGCourbePersist.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -47,7 +47,7 @@ private void fillInfoWith(EGCourbeChild courbe,int idgroupe){ this.Idgroup=idgroupe; title_=courbe.getTitle(); - this.nuagePoints=courbe.isNuagePoints_(); + this.nuagePoints=courbe.isNuagePoints(); Xmin = courbe.getModel().getXMin(); Xmax = courbe.getModel().getXMax(); Ymin = courbe.getModel().getYMin(); @@ -95,10 +95,10 @@ /** * Generate the proper curve in the appropriate group. - * @param groupe + * @param _groupe * @return */ -public EGCourbeChild generateCourbe(EGGroup groupe,Map infos){ +public EGCourbeChild generateCourbe(EGGroup _groupe,Map _infos){ //EGModel model=new EGCourbeModelDefault(abscisses,ordonnees); EGModel model=null; if(classeModel!=null) @@ -109,27 +109,13 @@ //-- ajotu des coordonnees --// model.addValue(abscisses, ordonnees, new CtuluCommandManager()); - - - - //-- donnees specifiques --// - infos.put("GROUPE", groupe); - infos.put("DEFAULTY", ordonnees); - model.setPersistSpecificDatas(dataSpecifiques, infos); + _infos.put("GROUPE", _groupe); + _infos.put("DEFAULTY", ordonnees); + model.setPersistSpecificDatas(dataSpecifiques, _infos); EGCourbeChild courbe=null; - - //-- Verifie dans le cas de rejoue des donnees, il faut peut etre ne pas ajouter la courbe --// -// if(infos.get("MODELREPLAY")!=null && infos.get("MODELREPLAY") instanceof EGCourbeChild){ -// -// //-- on remplace le model par le model rejouee et deja ajout\xE9--// -// courbe=(EGCourbeChild) infos.get("MODELREPLAY"); -// infos.remove("MODELREPLAY"); -// }else{ - - courbe=new EGCourbeChild(groupe,model); -// } + courbe=new EGCourbeChild(_groupe,model); courbe.setTitle(title_); //graphiques @@ -140,7 +126,7 @@ if(tLigneMarqueur_!=null) courbe.setLigneMark(tLigneMarqueur_); - courbe.setNuagePoints_(this.nuagePoints); + courbe.setNuagePoints(this.nuagePoints); if(listeMarqueurs_!=null) courbe.setMarqueurs(listeMarqueurs_); @@ -149,16 +135,16 @@ } - public String getTitle_() { + public String getTitle() { return title_; } - public void setTitle_(String title_) { - this.title_ = title_; + public void setTitle(String _title) { + this.title_ = _title; } public int getIdgroup() { return Idgroup; } - public void setIdgroup(int idgroup) { - Idgroup = idgroup; + public void setIdgroup(int _idgroup) { + Idgroup = _idgroup; } } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportActSerafin.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportActSerafin.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportActSerafin.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -47,6 +47,8 @@ int language_ = DicoLanguage.getCurrentID(); + boolean volumique_; + public MvExportActSerafin(final int[] _initIpobo, final int[] _iparams) { super(SerafinFileFormat.getInstance()); iparams_ = _iparams; @@ -58,7 +60,7 @@ protected CtuluIOOperationSynthese writeExport(final File[] _dest, final EfGridData _last, final ProgressionInterface _prog) { final MvExportSerafinFormatAdapter adapter = new MvExportSerafinFormatAdapter(selectedVar_, _last, - selectedTimeStep_, language_); + selectedTimeStep_, language_, volumique_); if (filter_ == null && initIpobo_ != null) { adapter.setInitIpobo(initIpobo_); } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportSerafinFormatAdapter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportSerafinFormatAdapter.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/export/MvExportSerafinFormatAdapter.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -25,19 +25,30 @@ */ public class MvExportSerafinFormatAdapter extends SerafinMaillageBuilderAdapterAbstract { - final CtuluVariable[] var_; final EfGridData data_; - double[] timeStep_; + int[] initIpobo_; + final boolean isVolumique_; + // pour eviter de recalculer a chaque fois les donn\xE9es. + EfData old_; + int oldTime_ = -1; + int oldVar_ = -1; + double[] timeStep_; + + + + final CtuluVariable[] var_; + /** * @param _var * @param _data */ public MvExportSerafinFormatAdapter(final CtuluVariable[] _var, final EfGridData _data, final double[] _ts, - final int _language) { + final int _language, boolean _volumique) { super((SerafinFileFormatVersionInterface) (SerafinFileFormat.getInstance().getLastVersionInstance(null)), _data .getGrid()); + isVolumique_ = _volumique; var_ = _var == null ? new CtuluVariable[0] : _var; data_ = _data; timeStep_ = var_.length == 0 ? FuEmptyArrays.DOUBLE0 : _ts; @@ -66,16 +77,9 @@ public double getTimeStep(final int _i) { return timeStep_[_i]; } - public int getTimeStepNb() { return timeStep_.length; } - - // pour eviter de recalculer a chaque fois les donn\xE9es. - EfData old_; - int oldVar_ = -1; - int oldTime_ = -1; - public double getValue(final int _numVariable, final int _pasTemps, final int _ptIdx) throws IOException { if (_numVariable != oldVar_ || _pasTemps != oldTime_ || old_ == null) { oldTime_ = _pasTemps; @@ -93,6 +97,10 @@ return valuesName_.length; } + public boolean isVolumique() { + return isVolumique_; + } + public void setInitIpobo(final int[] _initIpobo) { initIpobo_ = _initIpobo; } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileTreeModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileTreeModel.java 2009-02-23 17:38:31 UTC (rev 4491) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileTreeModel.java 2009-02-23 22:38:17 UTC (rev 4492) @@ -80,903 +80,883 @@ * @version $Id: MvProfileTreeModel.java,v 1.12 2007-06-13 14:46:13 deniger Exp $ */ public class MvProfileTreeModel extends EGGrapheTreeModel implements Target { - FudaaCourbeTimeListModel timeModel_; - EfLineIntersectionsResultsMng resNode_; - EfLineIntersectionsResultsBuilder builderNode_; - EfLineIntersectionsResultsBuilder builderMesh_; - EfLineIntersectionsResultsMng resMesh_; + FudaaCourbeTimeListModel timeModel_; + EfLineIntersectionsResultsMng resNode_; + EfLineIntersectionsResultsBuilder builderNode_; + EfLineIntersectionsResultsBuilder builderMesh_; + EfLineIntersectionsResultsMng resMesh_; - EfLineIntersectionsCorrectionTester tester_; + EfLineIntersectionsCorrectionTester tester_; - /** - * Ligne initialement utilis\xE9e pour la creation de la courbe - */ - LineString initLineNode; - LineString initLineMesh; + /** + * Ligne initialement utilis\xE9e pour la creation de la courbe + */ + LineString initLineNode; + LineString initLineMesh; + public MvProfileTarget target_; - public MvProfileTarget target_; + public MvProfileTreeModel(final MvProfileTarget _target, final EfLineIntersectionsCorrectionTester _tester) { + super(); + timeModel_ = _target.getTimeModel(); + tester_ = _tester; + target_ = _target; + } - public MvProfileTreeModel(final MvProfileTarget _target, final EfLineIntersectionsCorrectionTester _tester) { - super(); - timeModel_ = _target.getTimeModel(); - tester_ = _tester; - target_ = _target; - } + public MvProfileTreeModel(final MvProfileTreeModel _model) { + super(); + timeModel_ = _model.target_.getTimeModel(); + tester_ = _model.tester_; + target_ = _model.target_; + } - public MvProfileTreeModel(final MvProfileTreeModel _model) { - super(); - timeModel_ = _model.target_.getTimeModel(); - tester_ = _model.tester_; - target_ = _model.target_; - } + /** + * ACHTUNG! Constructuer uniquement utilis\xE9 pour la serialization des graphes!! Il faut imp\xE9rativement initialiser la + * variable target_ avec un ProfilDapter apres coup avec le trpostsource qui convient + */ + public MvProfileTreeModel() { + tester_ = new MvProfileCoteTester(); - /** - * ACHTUNG! Constructuer uniquement utilis\xE9 pour la serialization des graphes!! Il faut imp\xE9rativement initialiser la - * variable target_ avec un ProfilDapter apres coup avec le trpostsource qui convient - */ - public MvProfileTreeModel() { - tester_ = new MvProfileCoteTester(); + } - } + public void setNodesResults(final EfLineIntersectionsResultsMng _resNode, + final EfLineIntersectionsResultsBuilder _builderNode) { + resNode_ = _resNode; + builderNode_ = _builderNode; + if (builderNode_ != null) initLineNode = builderNode_.getInitLine(); - public void setNodesResults(final EfLineIntersectionsResultsMng _resNode, - final EfLineIntersectionsResultsBuilder _builderNode) { - resNode_ = _resNode; - builderNode_ = _builderNode; - if(builderNode_!=null ) - initLineNode=builderNode_.getInitLine(); + } + public EfLineIntersectionsResultsBuilder getBuilderFor(final CtuluVariable _v) { + return target_.getData().isElementVar(_v) ? builderMesh_ : builderNode_; + } - } + public void setMeshesResults(final EfLineIntersectionsResultsMng _resMeshes, + final EfLineIntersectionsResultsBuilder _builderMeshes) { + resMesh_ = _resMeshes; + builderMesh_ = _builderMeshes; + if (builderMesh_ != null) initLineMesh = builderMesh_.getInitLine(); - public EfLineIntersectionsResultsBuilder getBuilderFor(final CtuluVariable _v) { - return target_.getData().isElementVar(_v) ? builderMesh_ : builderNode_; - } + } - public void setMeshesResults(final EfLineIntersectionsResultsMng _resMeshes, - final EfLineIntersectionsResultsBuilder _builderMeshes) { - resMesh_ = _resMeshes; - builderMesh_ = _builderMeshes; - if(builderMesh_!=null ) - initLineMesh=builderMesh_.getInitLine(); + public EfLineIntersectionsResultsMng getResMesh() { + return resMesh_; + } - } + public H2dVariableType[] getVariables() { - public EfLineIntersectionsResultsMng getResMesh() { - return resMesh_; - } + final List values = getShownVar(); - public H2dVariableType[] getVariables() { + return null; + } - final List values = getShownVar(); + @Override + public boolean isStructureModifiable() { + return true; + } - return null; - } + public void updateTimeStep(final int[] _idx, final ProgressionInterface _prog) { + blockEvents_ = true; + final FudaaCourbeTimeListModel newModel = target_.getTimeModel(); - @Override - public boolean isStructureModifiable() { - return true; - } + if (newModel != null) { + final boolean structureChanged = newModel.getSize() != timeModel_.getSize(); + // timeModel_.updateFrom(newModel); + if (structureChanged) { + timeModel_.fireStructureChanged(); + } else { + timeModel_.fireContentChanged(); + } + blockEvents_ = false; + BuLib.invokeLater(new Runnable() { - public void updateTimeStep(final int[] _idx, final ProgressionInterface _prog) { - blockEvents_ = true; - final FudaaCourbeTimeListModel newModel = target_.getTimeModel(); + public void run() { + fireCourbeContentChanged(null, true); + if (structureChanged) { + final EGObject[] cs = getSelectedObjects(); + if (cs != null) { + for (int i = 0; i < cs.length; i++) { - if (newModel != null) { - final boolean structureChanged = newModel.getSize() != timeModel_.getSize(); - // timeModel_.updateFrom(newModel); - if (structureChanged) { - timeModel_.fireStructureChanged(); - } else { - timeModel_.fireContentChanged(); - } - blockEvents_ = false; - BuLib.invokeLater(new Runnable() { + if (cs[i] instanceof MvProfileCourbeTime) { + ((MvProfileCourbeTime) cs[i]).selection_.setSelectionInterval(timeModel_.getSize() - 1, timeModel_ + .getSize() - 1); + } + } + } + } + } - public void run() { - fireCourbeContentChanged(null, true); - if (structureChanged) { - final EGObject[] cs = getSelectedObjects(); - if (cs != null) { - for (int i = 0; i < cs.length; i++) { + }); + } - if (cs[i] instanceof MvProfileCourbeTime) { - ((MvProfileCourbeTime) cs[i]).selection_.setSelectionInterval(timeModel_.getSize() - 1, timeModel_ - .getSize() - 1); - } - } - } - } - } + } - }); - } + /** + * Rejoue les donn\xE9es de la polyligne avec les nouvelles infos. Si boolean ecraser est a false, Cree sune nouvelle + * courbe avec le mod\xE8le qui convient. Dans le cas ou ecraser est \xE0 true, on ecrase les infos du modele par ceux des + * param d'entree. Version r\xE9serv\xE9s aux points r\xE9els + * + * @param _model + * @param _src + * @param _idxToAdd + * @param _cmd + * @param _prog + * @param newVariable + * @param ecraser + */ + public void replayPoints(TrPostCommonImplementation impl, TrPostVisuPanel vue2d, MVProfileCourbeModel _model, + final TrPostSource _src, final GISZoneCollectionPoint points, final CtuluCommandContainer _cmd, + final ProgressionInterface _prog, H2dVariableType newVariable, int newTimeStep, boolean ecraser) { + LineString polyligne = new LineString(points, new GeometryFactory()); + // -- ajout de la variable --// + final MvProfileCourbeGroup groupVar = getGroup(newVariable, true); - } + // -- on cree la nouvelle courbe pour la variable correspondante --// + MvProfileTarget target = new TrPostProfileAction.ProfileAdapter(_src, impl.getCurrentProject()); + MvProfileBuilder builder = new MvProfileBuilderFromLine(target, impl, polyligne, vue2d, new MvProfileCoteTester()); + // -- intersectionResultI --// + EfLineIntersectionsResultsI res = builder.getDefaultRes(_model.variable_, impl.getMainProgression()); + // -- EfLineIntersectionsResultsBuilder --// + EfLineIntersectionsResultsBuilder efbuilder = new EfLineIntersectionsResultsBuilder(polyligne, _model.res_, + new MvProfileCoteTester()); + MVProfileCourbeModel newModele = new MVProfileCourbeModel(newVariable, _src, newTimeStep, efbuilder, impl + .getMainProgression()); - /** - * Rejoue les donn\xE9es de la polyligne avec les nouvelles infos. - * Si boolean ecraser est a false, Cree sune nouvelle courbe avec le mod\xE8le qui convient. - * Dans le cas ou ecraser est \xE0 true, on ecrase les infos du modele par ceux des param d'entree. - * Version r\xE9serv\xE9s aux points r\xE9els - * @param _model - * @param _src - * @param _idxToAdd - * @param _cmd - * @param _prog - * @param newVariable - * @param ecraser - */ - public void replayPoints(TrPostCommonImplementation impl,TrPostVisuPanel vue2d,MVProfileCourbeModel _model,final TrPostSource _src, final GISZoneCollectionPoint points, final CtuluCommandContainer _cmd, - final ProgressionInterface _prog, H2dVariableType newVariable,int newTimeStep, boolean ecraser) { - LineString polyligne=new LineString(points,new GeometryFactory()); - //-- ajout de la variable --// - final MvProfileCourbeGroup groupVar = getGroup(newVariable, true); + // -- titre --// + String title = newVariable.toString() + CtuluLibString.ESPACE; + if (newVariable.getCommonUnit() != null) title += "(" + newVariable.getCommonUnit() + ")" + CtuluLibString.ESPACE; + title += _src.getTimeStep(newTimeStep); + // -- on ajoute les extremites du segment choisi --// + title += ", P1(" + format(polyligne.getCoordinateN(0).x, 2) + ";" + format(polyligne.getCoordinateN(0).y, 2) + ")" + + ";" + "P" + polyligne.getNumPoints() + "(" + + format(polyligne.getCoordinateN(polyligne.getNumPoints() - 1).x, 2) + ";" + + format(polyligne.getCoordinateN(polyligne.getNumPoints() - 1).y, 2) + ")"; + newModele.setTitle(title); - //-- on cree la nouvelle courbe pour la variable correspondante --// - MvProfileTarget target=new TrPostProfileAction.ProfileAdapter(_src,impl.getCurrentProject()); - MvProfileBuilder builder=new MvProfileBuilderFromLine(target,impl,polyligne,vue2d,new MvProfileCoteTester()); - //-- intersectionResultI --// - EfLineIntersectionsResultsI res=builder.getDefaultRes(_model.variable_, impl.getMainProgression()); - //-- EfLineIntersectionsResultsBuilder --// - EfLineIntersectionsResultsBuilder efbuilder=new EfLineIntersectionsResultsBuilder(polyligne,_model.res_,new MvProfileCoteTester()); - MVProfileCourbeModel newModele=new MVProfileCourbeModel(newVariable,_src,newTimeStep,efbuilder,impl.getMainProgression()); + // -- creation de la nouvelle courbe --// + MvProfileCourbeTime newchild = new MvProfileCourbeTime(groupVar, newModele, target.getTimeModel()); + groupVar.addEGComponent(newchild); - //-- titre --// - String title=newVariable.toString() + CtuluLibString.ESPACE ; - if(newVariable.getCommonUnit()!=null) - title+="("+newVariable.getCommonUnit()+")"+ CtuluLibString.ESPACE ; - title+=_src.getTimeStep(newTimeStep); - //-- on ajoute les extremites du segment choisi --// - title+=", P1("+format(polyligne.getCoordinateN(0).x,2)+";"+format(polyligne.getCoordinateN(0).y,2)+")"+";"+"P"+polyligne.getNumPoints()+"("+format(polyligne.getCoordinateN(polyligne.getNumPoints()-1).x,2)+";"+format(polyligne.getCoordinateN(polyligne.getNumPoints()-1).y,2)+")"; - newModele.setTitle(title); + // -- si ecraser, on supprime la courbe --// + if (ecraser) { + this.removeModele(_model, _cmd); - //-- creation de la nouvelle courbe --// - MvProfileCourbeTime newchild = new MvProfileCourbeTime(groupVar, newModele, target.getTimeModel()); - groupVar.addEGComponent(newchild); + } + fireStructureChanged(); + } - //-- si ecraser, on supprime la courbe --// - if(ecraser){ - this.removeModele(_model,_cmd); + public void replayPoints(TrPostCommonImplementation impl, TrPostVisuPanel vue2d, MVProfileCourbeModel _model, + final TrPostSource _src, final int[] _idxToAdd, final CtuluCommandContainer _cmd, + final ProgressionInterface _prog, H2dVariableType newVariable, int newTimeStep, boolean ecraser) { + // -- creation de la polyligne --// + GISZoneCollectionPoint points = new GISZoneCollectionPoint(); + for (int i = 0; i < _idxToAdd.length; i++) + points.add(_src.getGrid().getPtX(_idxToAdd[i]), _src.getGrid().getPtY(_idxToAdd[i]), 0); - } + replayPoints(impl, vue2d, _model, _src, points, _cmd, _prog, newVariable, newTimeStep, ecraser); + } + public void replayPoints(TrPostCommonImplementation impl, TrPostVisuPanel vue2d, MVProfileCourbeModel _model, + final TrPostSource _src, final List<GrPoint> _idxToAdd, final CtuluCommandContainer _cmd, + final ProgressionInterface _prog, H2dVariableType newVariable, int newTimeStep, boolean ecraser) { + // -- creation de la polyligne --// + GISZoneCollectionPoint points = new GISZoneCollectionPoint(); + for (GrPoint point : _idxToAdd) + points.add(point.x_, point.y_, point.z_); - fireStructureChanged(); - } + replayPoints(impl, vue2d, _model, _src, points, _cmd, _prog, newVariable, newTimeStep, ecraser); + } - - - public void replayPoints(TrPostCommonImplementation impl,TrPostVisuPanel vue2d,MVProfileCourbeModel _model,final TrPostSource _src, final int[] _idxToAdd, final CtuluCommandContainer _cmd, - final ProgressionInterface _prog, H2dVariableType newVariable,int newTimeStep, boolean ecraser) { - //-- creation de la polyligne --// - GISZoneCollectionPoint points=new GISZoneCollectionPoint(); - for(int i=0;i<_idxToAdd.length;i++) - points.add(_src.getGrid().getPtX(_idxToAdd[i]),_src.getGrid().getPtY(_idxToAdd[i]),0); - - replayPoints(impl, vue2d, _model, _src, points, _cmd, _prog, newVariable, newTimeStep, ecraser); - } - - public void replayPoints(TrPostCommonImplementation impl,TrPostVisuPanel vue2d,MVProfileCourbeModel _model,final TrPostSource _src, final List<GrPoint> _idxToAdd, final CtuluCommandContainer _cmd, - final ProgressionInterface _prog, H2dVariableType newVariable,int newTimeStep, boolean ecraser) { - //-- creation de la polyligne --// - GISZoneCollectionPoint points=new GISZoneCollectionPoint(); - for(GrPoint point:_idxToAdd) - points.add(point.x_,point.y_,point.z_); - - replayPoints(impl, vue2d, _model, _src, points, _cmd, _prog, newVariable, newTimeStep, ecraser); - } + /** + * Methode qui supprime la courbe pour son modele du profil spatial. Supprime \xE9galement le groupe de variable si ce + * dernier ne contient pas d'autres courbes. + * + * @param model de la courbe a supprimer + * @param mng + */ + public void removeModele(MVProfileCourbeModel model, CtuluCommandContainer mng) { + model.isRemovable_ = true; + // -- on recupere le groupe du modele --// + final MvProfileCourbeGroup groupVar = getGroup(model.getVariable(), false); + EGCourbeChild[] liste = new EGCourbeChild[1]; + boolean trouve = false; + for (int i = groupVar.getChildCount() - 1; !trouve && i >= 0; i--) { + final MVProfileCourbeModel res = (MVProfileCourbeModel) groupVar.getCourbeAt(i).getModel(); + if (res == model) { + liste[0] = groupVar.getCourbeAt(i); + trouve = true; + } + } + if (trouve) removeCurves(liste, mng); - /** - * Methode qui supprime la courbe pour son modele du profil spatial. - * Supprime \xE9galement le groupe de variable si ce dernier ne contient pas d'autres courbes. - * @param model de la courbe a supprimer - * @param mng - */ - public void removeModele(MVProfileCourbeModel model,CtuluCommandContainer mng){ - model.isRemovable_=true; - //-- on recupere le groupe du modele --// - final MvProfileCourbeGroup groupVar = getGroup(model.getVariable(), false); - EGCourbeChild[] liste=new EGCourbeChild[1]; - boolean trouve=false; - for (int i = groupVar.getChildCount() - 1;!trouve && i >= 0; i--) { - final MVProfileCourbeModel res = (MVProfileCourbeModel) groupVar.getCourbeAt(i).getModel(); - if (res==model) { - liste[0]=groupVar.getCourbeAt(i); - trouve=true; - } - } - if(trouve) - removeCurves(liste,mng ); + // -- test si le groupe ne contient rien, on le degage --// + if (groupVar.getEGChilds() == null || groupVar.getEGChilds().length == 0) { + this.remove(groupVar); - //-- test si le groupe ne contient rien, on le degage --// - if(groupVar.getEGChilds()==null || groupVar.getEGChilds().length==0){ - this.remove(groupVar); + } + } - } - } + public String format(double value, int nbChiffresSignificatifs) { + String forme = "#."; + for (int i = 0; i < nbChiffresSignificatifs; i++) + forme += "0"; + DecimalFormat df = new DecimalFormat(forme); + return df.format(value); + } - public String format(double value,int nbChiffresSignificatifs){ - String forme="#."; - for(int i=0;i<nbChiffresSignificatifs;i++) - forme+="0"; - DecimalFormat df = new DecimalFormat(forme); - return df.format(value); - } + MvProfileGridPalette paletteGrid_; + public EfLineIntersectionsResultsI[] getDefaultRes() { + return new EfLineIntersectionsResultsI[] { resNode_ == null ? null : resNode_.getDefaultRes(), + resMesh_ == null ? null : resMesh_.getDefaultRes() }; + } - MvProfileGridPalette paletteGrid_; + public static LineString createLineString(final EfLineIntersectionsResultsMng _res) { + if (_res == null) { return null; } + return createLineString(_res.getDefaultRes()); + } - public EfLineIntersectionsResultsI[] getDefaultRes() { - return new EfLineIntersectionsResultsI[] { resNode_ == null ? null : resNode_.getDefaultRes(), - resMesh_ == null ? null : resMesh_.getDefaultRes() }; - } + private static LineString createLineString(final EfLineIntersectionsResultsI _res) { + final Coordinate[] cs = new Coordinate[_res.getNbIntersect()]; + for (int i = cs.length - 1; i >= 0; i--) { + final EfLineIntersection intersect = _res.getIntersect(i); + cs[i] = new Coordinate(intersect.getX(), intersect.getY()); + } + return GISGeometryFactory.INSTANCE.createLineString(cs); + } - public static LineString createLineString(final EfLineIntersectionsResultsMng _res) { - if (_res == null) { return null; } - return createLineString(_res.getDefaultRes()); - } + /** + * Recherche le bon groupe pour les profils spatiaux. peut creer le groupe si booleen est a true. + * + * @param _v + * @param _create + * @return + */ + public MvProfileCourbeGroup getGroup(final CtuluVariable _v, final boolean _create) { + for (int i = getNbEGObject() - 1; i >= 0; i--) { + final EGGroup g = getGroup(i); + if ((g instanceof MvProfileCourbeGroup) && ((MvProfileCourbeGroup) g).getVar() == _v) { return (MvProfileCourbeGroup) g; } + } + if (_create) { + final MvProfileCourbeGroup g = MvProfileFillePanel.createGroupFor(_v); + super.add(g); + return g; + } + return null; - private static LineString createLineString(final EfLineIntersectionsResultsI _res) ... [truncated message content] |