|
From: <bma...@us...> - 2003-02-18 16:50:37
|
Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/refonde
In directory sc8-pr-cvs1:/tmp/cvs-serv21359
Modified Files:
RefondeModeleProprietes.java
Log Message:
Ajout des domaines poreux dans le modèle, gestion de la sauvegarde/restitution.
Index: RefondeModeleProprietes.java
===================================================================
RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/refonde/RefondeModeleProprietes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RefondeModeleProprietes.java 30 Jan 2003 13:09:46 -0000 1.1
--- RefondeModeleProprietes.java 18 Feb 2003 16:50:33 -0000 1.2
***************
*** 31,34 ****
--- 31,36 ----
// private Hashtable bord2Gp=new Hashtable();
boolean modifie;
+ /** Domaines poreux */
+ private Vector poreux_=new Vector();
/**
***************
*** 101,104 ****
--- 103,129 ----
/**
+ * Ajoute d'un domaine poreux.
+ */
+ public void addDomainePoreux(RefondeDomainePoreux _dm) {
+ poreux_.add(_dm);
+ modifie=true;
+ }
+
+ /**
+ * Suppression d'un domaine poreux.
+ */
+ public void removeDomainePoreux(RefondeDomainePoreux _dm) {
+ poreux_.remove(_dm);
+ modifie=true;
+ }
+
+ /**
+ * Retourne les domaines poreux.
+ */
+ public RefondeDomainePoreux[] getDomainesPoreux() {
+ return (RefondeDomainePoreux[])poreux_.toArray(new RefondeDomainePoreux[0]);
+ }
+
+ /**
* Lecture d'un modele de propriétés.
* @param _fichier Nom du fichier modele de propriétés.
***************
*** 155,160 ****
// Lecture par version
! if (version.compareTo("5.06")<=0) prp.lire506(_projet,file);
! else prp.lire(_projet,file);
}
catch (NumberFormatException _exc) {
--- 180,187 ----
// Lecture par version
! if (version.compareTo("5.06")<=0) prp.lire506(_projet,file);
! else if (version.compareTo("5.14")<=0) prp.lire514(_projet,file);
! // Ajout des domaines poreux
! else prp.lire(_projet,file);
}
catch (NumberFormatException _exc) {
***************
*** 197,201 ****
/**
! * Lecture des informations sur version 506
*/
private void lire506(RefondeProjet _projet, StreamTokenizer _file)
--- 224,228 ----
/**
! * Lecture des informations sur version 506 et moins
*/
private void lire506(RefondeProjet _projet, StreamTokenizer _file)
***************
*** 292,298 ****
/**
! * Lecture des informations sur version courante
*/
! private void lire(RefondeProjet _projet, StreamTokenizer _file)
throws IOException {
RefondePropriete[] prs;
--- 319,325 ----
/**
! * Lecture des informations sur version 514 et moins
*/
! private void lire514(RefondeProjet _projet, StreamTokenizer _file)
throws IOException {
RefondePropriete[] prs;
***************
*** 432,435 ****
--- 459,663 ----
/**
+ * Lecture des informations sur version courante
+ */
+ private void lire(RefondeProjet _projet, StreamTokenizer _file)
+ throws IOException {
+ RefondePropriete[] prs;
+ RefondeGroupeProprietes gp;
+ RefondePolyligne pl;
+ RefondeDomaineDigue dm;
+ RefondeGeometrie geo=_projet.getGeometrie();
+
+ Vector vdms=geo.getDomaines();
+ Vector vpls=geo.getPolylignes();
+
+ int tpPr;
+ int tpGp;
+ double valPr;
+ int nbGp;
+ double val;
+ int ival;
+
+ // Identifiant de géométrie
+ if (_file.nextToken()!=WORD || !_file.sval.equals("<identifiant_geometrie>"))
+ throw new IOException();
+ if (_file.nextToken()!=WORD || Integer.parseInt(_file.sval)!=geo.identifiant())
+ throw new RefondeIOException(
+ "Le numéro de version de la géométrie n'est pas compatible avec le projet");
+
+ //--- Groupes de propriétés de bord --------------------------------------
+
+ while (_file.nextToken()==WORD && !_file.sval.equals("<fin>")) {
+
+ // Numéro de polyligne
+ ival=Integer.parseInt(_file.sval);
+ if (ival<0 || ival>vpls.size()-1) throw new IOException();
+ pl=(RefondePolyligne)vpls.get(ival);
+
+ // Type de groupe
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (_file.sval.equals("ouvert_entree"))
+ tpGp=RefondeGroupeProprietes.HOULE_BORD_OUVERT_ENTREE;
+ else if (_file.sval.equals("ouvert_sortie"))
+ tpGp=RefondeGroupeProprietes.HOULE_BORD_OUVERT_SORTIE;
+ else if (_file.sval.equals("semi_reflechissant"))
+ tpGp=RefondeGroupeProprietes.HOULE_BORD_SEMI_REFLECHISSANT;
+ else throw new IOException();
+
+ // Pour chaque propriété
+
+ prs=new RefondePropriete[RefondeGroupeProprietes.typesProprietes[tpGp].length];
+ for (int i=0; i<prs.length; i++) {
+
+ // Type de propriété
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (_file.sval.equals("reflexion")) tpPr=RefondePropriete.REFLEXION;
+ else throw new IOException();
+ if (tpPr!=RefondeGroupeProprietes.typesProprietes[tpGp][i])
+ throw new IOException();
+
+ // Comportement (stationnaire uniquement autorisé)
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (!_file.sval.equals("stationnaire")) throw new IOException();
+
+ // Valeur de la propriété
+ if (_file.nextToken()!=WORD) throw new IOException();
+ valPr=Double.parseDouble(_file.sval);
+
+ prs[i]=new RefondePropriete(tpPr,valPr);
+ }
+
+ if (_file.nextToken()!=WORD || !_file.sval.equals("<fin>"))
+ throw new IOException();
+
+ gp=new RefondeGroupeProprietes(tpGp,prs);
+ pl.setGroupeProprietes(gp);
+ }
+
+ //--- Groupes de propriétés de fond --------------------------------------
+
+ // Nombre de groupes de propriétés de fond
+ if (_file.nextToken()!=WORD || !_file.sval.equals("<proprietes_fond>"))
+ throw new IOException();
+ if (_file.nextToken()!=WORD) throw new IOException();
+ nbGp=Integer.parseInt(_file.sval);
+
+ // Groupes de propriétés
+ for (int i=0; i<nbGp; i++) {
+
+ // Numéro de domaine
+ if (_file.nextToken()!=WORD) throw new IOException();
+ ival=Integer.parseInt(_file.sval);
+ if (ival<0 || ival>vpls.size()-1) throw new IOException();
+ if (!(vdms.get(ival) instanceof RefondeDomaineDigue))
+ throw new IOException();
+ dm=(RefondeDomaineDigue)vdms.get(ival);
+
+ // Type du groupe de propriété
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (_file.sval.equals("digue_transmissible"))
+ tpGp=RefondeGroupeProprietes.HOULE_FOND_DIGUE_TRANSMISSIBLE;
+ else if (_file.sval.equals("digue_perforee"))
+ tpGp=RefondeGroupeProprietes.HOULE_FOND_PAROI_PERFOREE;
+ else throw new IOException();
+
+ // Pour chaque propriété
+
+ prs=new RefondePropriete[RefondeGroupeProprietes.typesProprietes[tpGp].length];
+ for (int j=0; j<prs.length; j++) {
+
+ // Type de propriété
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (_file.sval.equals("perte_charge_i" )) tpPr=RefondePropriete.PERTE_CHARGE_I;
+ else if (_file.sval.equals("perte_charge_r" )) tpPr=RefondePropriete.PERTE_CHARGE_R;
+ else if (_file.sval.equals("porosite" )) tpPr=RefondePropriete.POROSITE;
+ else if (_file.sval.equals("contraction" )) tpPr=RefondePropriete.CONTRACTION;
+ else if (_file.sval.equals("intg_verticale" )) tpPr=RefondePropriete.INTG_VERTICALE;
+ else if (_file.sval.equals("reflexion" )) tpPr=RefondePropriete.REFLEXION;
+ else if (_file.sval.equals("transmission" )) tpPr=RefondePropriete.TRANSMISSION;
+ else if (_file.sval.equals("dp_reflexion" )) tpPr=RefondePropriete.DP_REFLEXION;
+ else if (_file.sval.equals("dp_transmission")) tpPr=RefondePropriete.DP_TRANSMISSION;
+ else throw new IOException();
+ if (tpPr!=RefondeGroupeProprietes.typesProprietes[tpGp][j])
+ throw new IOException();
+
+ // Comportement (stationnaire uniquement autorisé)
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (!_file.sval.equals("stationnaire")) throw new IOException();
+
+ // Valeur de la propriété
+ if (_file.nextToken()!=WORD) throw new IOException();
+ valPr=Double.parseDouble(_file.sval);
+
+ prs[j]=new RefondePropriete(tpPr,valPr);
+ }
+
+ gp=new RefondeGroupeProprietes(tpGp,prs);
+ dm.setGroupeProprietes(gp);
+ }
+
+ //--- Domaines poreux -----------------------------------------------------
+
+ {
+ // Nombre de domaines poreux
+ if (_file.nextToken()!=WORD || !_file.sval.equals("<domaines_poreux>"))
+ throw new IOException();
+ if (_file.nextToken()!=WORD) throw new IOException();
+ int nb=Integer.parseInt(_file.sval);
+
+ // Domaines poreux
+ for (int i=0; i<nb; i++) {
+ RefondeDomainePoreux dmp=new RefondeDomainePoreux();
+ GrPoint[] pts=dmp.getPoints();
+ GrPoint[] ptsPlan=dmp.getPointsPlan();
+
+ // Limites xmin, xmax, ymin, ymax
+ if (_file.nextToken()!=WORD) throw new IOException();
+ pts[0].x=Double.parseDouble(_file.sval);
+ if (_file.nextToken()!=WORD) throw new IOException();
+ pts[1].x=Double.parseDouble(_file.sval);
+ if (_file.nextToken()!=WORD) throw new IOException();
+ pts[0].y=Double.parseDouble(_file.sval);
+ if (_file.nextToken()!=WORD) throw new IOException();
+ pts[1].y=Double.parseDouble(_file.sval);
+
+ // Points du plan
+ for (int j=0; j<ptsPlan.length; j++) {
+ //... x
+ if (_file.nextToken()!=WORD) throw new IOException();
+ ptsPlan[j].x=Double.parseDouble(_file.sval);
+ //... y
+ if (_file.nextToken()!=WORD) throw new IOException();
+ ptsPlan[j].y=Double.parseDouble(_file.sval);
+ //... z
+ if (_file.nextToken()!=WORD) throw new IOException();
+ ptsPlan[j].z=Double.parseDouble(_file.sval);
+ //... z automatique ou manuel
+ if (_file.nextToken()!=WORD) throw new IOException();
+ if (_file.sval.equals("z_automatique")) dmp.setZAutomatique(true,j);
+ else if (_file.sval.equals("z_manuel")) dmp.setZAutomatique(false,j);
+ else throw new IOException();
+ }
+
+ //... Porosité
+ if (_file.nextToken()!=WORD) throw new IOException();
+ dmp.porosite_=Double.parseDouble(_file.sval);
+ //... Coefficient de frottement
+ if (_file.nextToken()!=WORD) throw new IOException();
+ dmp.coefFrottement_=Double.parseDouble(_file.sval);
+ //... Perméabilité
+ if (_file.nextToken()!=WORD) throw new IOException();
+ dmp.permeabilite_=Double.parseDouble(_file.sval);
+ //... Coefficient de masse virtuelle
+ if (_file.nextToken()!=WORD) throw new IOException();
+ dmp.coefMasse_=Double.parseDouble(_file.sval);
+
+ dmp.setPoints(pts);
+ addDomainePoreux(dmp);
+ }
+ }
+ }
+
+ /**
* Ecriture des informations sur le fichier associé
*/
***************
*** 463,467 ****
file.println();
! // Groupes de propriétés de bord
for (int i=0; i<vpls.size(); i++) {
--- 691,695 ----
file.println();
! //--- Groupes de propriétés de bord ------------------------------------
for (int i=0; i<vpls.size(); i++) {
***************
*** 507,511 ****
file.println();
! // Groupes de propriétés de fond
// Nombre de groupes de propriétés de fond
--- 735,739 ----
file.println();
! //--- Groupes de propriétés de fond ------------------------------------
// Nombre de groupes de propriétés de fond
***************
*** 552,555 ****
--- 780,824 ----
file.println(prs[j].getValeur());
}
+ }
+ file.println();
+
+ //--- Domaines poreux ---------------------------------------------------
+
+ // Nombre de domaines poreux
+ file.println("<domaines_poreux> ; "+poreux_.size());
+
+ // Domaines poreux
+ for (int i=0; i<poreux_.size(); i++) {
+ RefondeDomainePoreux dmp=(RefondeDomainePoreux)poreux_.get(i);
+ GrPoint[] pts=dmp.getPoints();
+ GrPoint[] ptsPlan=dmp.getPointsPlan();
+
+ // Limites xmin, xmax, ymin, ymax
+ file.print(pts[0].x+" ; ");
+ file.print(pts[1].x+" ; ");
+ file.print(pts[0].y+" ; ");
+ file.println(pts[1].y);
+
+ // Points du plan
+ for (int j=0; j<ptsPlan.length; j++) {
+ //... x
+ file.print(ptsPlan[j].x+" ; ");
+ //... y
+ file.print(ptsPlan[j].y+" ; ");
+ //... z
+ file.print(ptsPlan[j].z+" ; ");
+ //... z automatique ou manuel
+ if (dmp.isZAutomatique(j)) file.println("z_automatique");
+ else file.println("z_manuel");
+ }
+
+ //... Porosité
+ file.print(dmp.porosite_+" ; ");
+ //... Coefficient de frottement
+ file.print(dmp.coefFrottement_+" ; ");
+ //... Perméabilité
+ file.print(dmp.permeabilite_+" ; ");
+ //... Coefficient de masse virtuelle
+ file.println(dmp.coefMasse_);
}
}
|