1 // Copyright (C) 2011-2013 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
19 // File : HOMARD_DriverTools.cxx
20 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22 // ----------------------------------------------------------------------------
24 #include "HOMARD_DriverTools.hxx"
25 #include "HOMARD_Boundary.hxx"
26 #include "HOMARD_Cas.hxx"
27 #include "HOMARD_Hypothesis.hxx"
28 #include "HOMARD_Iteration.hxx"
29 #include "HOMARD_Zone.hxx"
30 #include "HOMARD_YACS.hxx"
33 #include "utilities.h"
38 std::string SEPARATOR = "|" ;
41 \brief Read next chunk of data from the string
44 The function tries to read next chunk of the data from the input string \a str.
45 The parameter \a start specifies the start position of next chunk. If the operation
46 read the chunk successfully, after its completion this parameter will refer to the
47 start position of the next chunk. The function returns resulting chunk as a string.
48 The status of the operation is returned via \a ok parameter.
50 \param str source data stream string
51 \param start start position to get next chunk
52 \param ok in this variable the status of the chunk reading operation is returned
53 \return next chunk read from the string
55 static std::string getNextChunk( const std::string& str, std::string::size_type& start, bool& ok )
57 std::string chunk = "";
59 if ( start <= str.size() ) {
60 std::string::size_type end = str.find( separator(), start );
61 chunk = str.substr( start, end == std::string::npos ? std::string::npos : end-start );
62 start = end == std::string::npos ? str.size()+1 : end + separator().size();
69 \brief Get persistence signature
70 \param type persistence entity type
71 \return persistence signature
73 std::string GetSignature( SignatureType type )
75 std::string signature = "";
77 case Case: signature = "CASE"; break;
78 case Zone: signature = "ZONE"; break;
79 case Hypothesis: signature = "HYPO"; break;
80 case Iteration: signature = "ITER"; break;
81 case Boundary: signature = "BOUNDARY"; break;
82 case YACS: signature = "YACS"; break;
85 signature += separator();
90 \brief Get data separator
91 \return string that is used to separate data entities in the stream
93 std::string separator()
98 // =======================
100 // =======================
102 \brief Dump case to the string
103 \param cas case being dumped
104 \return string representation of the case
106 std::string Dump( const HOMARD_Cas& cas )
108 std::stringstream os;
111 MESSAGE( ". Sauvegarde du cas "<<cas.GetName());
113 os << separator() << cas.GetDirName();
114 os << separator() << cas.GetConfType();
116 std::vector<double> coor = cas.GetBoundingBox();
117 os << separator() << coor.size();
118 for ( int i = 0; i < coor.size(); i++ )
119 os << separator() << coor[i];
121 std::list<std::string> ListString = cas.GetIterations();
122 os << separator() << ListString.size();
123 std::list<std::string>::const_iterator it;
124 for ( it = ListString.begin(); it != ListString.end(); ++it )
125 os << separator() << *it;
127 ListString = cas.GetGroups();
128 os << separator() << ListString.size();
129 for ( it = ListString.begin(); it != ListString.end(); ++it )
130 os << separator() << *it;
131 ListString = cas.GetBoundaryGroup();
132 os << separator() << ListString.size();
133 for ( it = ListString.begin(); it != ListString.end(); ++it )
134 os << separator() << *it;
136 os << separator() << cas.GetPyram();
139 // MESSAGE( ". Fin avec "<<saux);
148 \brief Dump iteration to the string
149 \param iteration iteration being dumped
150 \return string representation of the iteration
152 std::string Dump( const HOMARD_Iteration& iteration )
154 std::stringstream os;
157 MESSAGE( ". Sauvegarde de l'iteration "<<iteration.GetName());
158 os << iteration.GetName();
159 os << separator() << iteration.GetState();
160 os << separator() << iteration.GetNumber();
161 os << separator() << iteration.GetMeshFile();
162 os << separator() << iteration.GetLogFile();
163 os << separator() << iteration.GetMeshName();
164 os << separator() << iteration.GetFieldFile();
165 os << separator() << iteration.GetTimeStep();
166 os << separator() << iteration.GetRank();
167 os << separator() << iteration.GetIterParentName();
169 std::list<std::string> ListString = iteration.GetIterations();
170 os << separator() << ListString.size();
171 std::list<std::string>::const_iterator it;
172 for ( it = ListString.begin(); it != ListString.end(); ++it )
173 os << separator() << *it;
175 os << separator() << iteration.GetHypoName();
176 os << separator() << iteration.GetCaseName();
177 os << separator() << iteration.GetDirNameLoc();
180 // MESSAGE( ". Fin avec "<<saux);
188 \brief Dump hypothesis to the string
189 \param hypothesis hypothesis being dumped
190 \return string representation of the hypothesis
192 std::string Dump( const HOMARD_Hypothesis& hypothesis )
194 std::stringstream os;
197 MESSAGE( ". Sauvegarde de l'hypothese "<<hypothesis.GetName());
198 os << hypothesis.GetName();
199 os << separator() << hypothesis.GetCaseCreation();
200 os << separator() << hypothesis.GetAdapType();
201 os << separator() << hypothesis.GetRefinType();
202 os << separator() << hypothesis.GetUnRefType();
203 os << separator() << hypothesis.GetFieldName();
204 os << separator() << hypothesis.GetRefinThrType();
205 os << separator() << hypothesis.GetThreshR();
206 os << separator() << hypothesis.GetUnRefThrType();
207 os << separator() << hypothesis.GetThreshC();
208 os << separator() << hypothesis.GetUseField();
209 os << separator() << hypothesis.GetUseComp();
210 os << separator() << hypothesis.GetTypeFieldInterp();
212 std::list<std::string> ListString = hypothesis.GetIterations();
213 std::list<std::string>::const_iterator it;
214 os << separator() << ListString.size();
215 for ( it = ListString.begin(); it != ListString.end(); ++it )
216 os << separator() << *it;
218 ListString = hypothesis.GetZones();
219 os << separator() << ListString.size();
220 for ( it = ListString.begin(); it != ListString.end(); ++it )
221 os << separator() << *it;
223 ListString = hypothesis.GetComps();
224 os << separator() << ListString.size();
225 for ( it = ListString.begin(); it != ListString.end(); ++it )
226 os << separator() << *it;
228 ListString = hypothesis.GetGroups();
229 os << separator() << ListString.size();
230 for ( it = ListString.begin(); it != ListString.end(); ++it )
231 os << separator() << *it;
233 ListString = hypothesis.GetFieldInterps();
234 os << separator() << ListString.size();
235 for ( it = ListString.begin(); it != ListString.end(); ++it )
236 os << separator() << *it;
238 os << separator() << hypothesis.GetNivMax();
239 os << separator() << hypothesis.GetDiamMin();
240 os << separator() << hypothesis.GetAdapInit();
241 os << separator() << hypothesis.GetLevelOutput();
244 // MESSAGE( ". Fin avec "<<saux);
253 \brief Dump zone to the string
254 \param zone zone being dumped
255 \return string representation of the zone
257 std::string Dump( const HOMARD_Zone& zone )
259 std::stringstream os;
261 MESSAGE( ". Sauvegarde de la zone "<<zone.GetName());
262 os << zone.GetName();
263 os << separator() << zone.GetType();
265 std::vector<double> coords = zone.GetCoords();
266 for ( int i = 0; i < coords.size(); i++ )
267 os << separator() << ( i < coords.size() ? coords[i] : 0. );
269 std::vector<double> limit = zone.GetLimit();
270 for ( int i = 0; i < 3; i++ )
271 os << separator() << ( i < limit.size() ? limit[i] : 0. );
273 std::list<std::string> hypos = zone.GetHypo();
274 os << separator() << hypos.size();
275 std::list<std::string>::const_iterator it;
276 for ( it = hypos.begin(); it != hypos.end(); ++it )
277 os << separator() << *it;
280 // MESSAGE( ". Fin avec "<<saux);
284 // ==============================
285 // 1.5. Archivage d'une frontiere
286 // ==============================
289 \brief Dump boundary to the string
290 \param boundary boundary being dumped
291 \return string representation of the boundary
293 std::string Dump( const HOMARD_Boundary& boundary )
295 std::stringstream os;
297 MESSAGE( ". Sauvegarde de la frontiere "<<boundary.GetName());
299 int BoundaryType = boundary.GetType() ;
301 os << boundary.GetName() ;
302 os << separator() << BoundaryType ;
303 os << separator() << boundary.GetCaseCreation() ;
305 if ( BoundaryType == 0 )
307 os << separator() << boundary.GetMeshName();
308 os << separator() << boundary.GetMeshFile();
311 std::vector<double> coor = boundary.GetCoords() ;
312 for ( int i = 0; i < coor.size(); i++ )
313 os << separator() << coor[i];
314 std::vector<double> limit = boundary.GetLimit();
315 for ( int i = 0; i < limit.size(); i++ )
316 os << separator() << limit[i];
319 std::list<std::string> ListString = boundary.GetGroups();
320 std::list<std::string>::const_iterator it;
321 os << separator() << ListString.size();
322 for ( it = ListString.begin(); it != ListString.end(); ++it )
323 os << separator() << *it;
326 // MESSAGE( ". Fin avec "<<saux);
336 \brief Dump YACS to the string
337 \param yacs yacs being dumped
338 \return string representation of the zone
340 std::string Dump( const HOMARD_YACS& yacs )
342 std::stringstream os;
344 MESSAGE( ". Sauvegarde du schema YACS "<<yacs.GetName());
345 os << yacs.GetName();
346 os << separator() << yacs.GetType();
349 // MESSAGE( ". Fin avec "<<saux);
353 // 2. Restauration des objets
354 // ==========================
356 // ==========================
359 \brief Restore case from the string
360 \param cas case being restored
361 \param stream string representation of the case
362 \return \c true if case is correctly restored or \c false otherwise
364 bool Restore( HOMARD_Cas& cas, const std::string& stream )
366 MESSAGE( ". Restoration du cas ");
367 std::string::size_type start = 0;
368 std::string chunk, chunkNext;
371 chunk = getNextChunk( stream, start, ok );
372 if ( !ok ) return false;
373 cas.SetName( chunk.c_str() );
375 chunk = getNextChunk( stream, start, ok );
376 if ( !ok ) return false;
377 cas.SetDirName( chunk.c_str() );
379 chunk = getNextChunk( stream, start, ok );
380 if ( !ok ) return false;
381 cas.SetConfType( atoi( chunk.c_str() ) );
383 chunk = getNextChunk( stream, start, ok );
384 if ( !ok ) return false;
386 int size = atoi( chunk.c_str() );
387 std::vector<double> boite;
388 boite.resize( size );
389 for ( int i = 0; i < size; i++ ) {
390 chunk = getNextChunk( stream, start, ok );
391 if ( !ok ) return false;
392 boite[i] = strtod( chunk.c_str(), 0 );
394 cas.SetBoundingBox( boite );
396 chunk = getNextChunk( stream, start, ok );
397 if ( !ok ) return false;
399 size = atoi( chunk.c_str() );
400 for ( int i = 0; i < size; i++ ) {
401 chunk = getNextChunk( stream, start, ok );
402 if ( !ok ) return false;
403 cas.AddIteration( chunk.c_str() );
406 chunk = getNextChunk( stream, start, ok );
407 if ( !ok ) return false;
408 size = atoi( chunk.c_str() );
409 for ( int i = 0; i < size; i++ )
411 chunk = getNextChunk( stream, start, ok );
412 if ( !ok ) return false;
413 cas.AddGroup( chunk.c_str() );
416 chunk = getNextChunk( stream, start, ok );
417 if ( !ok ) return false;
418 size = atoi( chunk.c_str() );
419 for ( int i = 0; i < size; i++ ) {
420 chunk = getNextChunk( stream, start, ok );
421 if ( !ok ) return false;
423 chunkNext = getNextChunk( stream, start, ok );
424 if ( !ok ) return false;
425 cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() );
428 chunk = getNextChunk( stream, start, ok );
429 if ( !ok ) return false;
430 cas.SetPyram( atoi( chunk.c_str() ) );
439 \brief Restore iteration from the string
440 \param iteration iteration being restored
441 \param stream string representation of the iteration
442 \return \c true if iteration is correctly restored or \c false otherwise
444 bool Restore( HOMARD_Iteration& iteration, const std::string& stream )
446 std::string::size_type start = 0;
449 chunk = getNextChunk( stream, start, ok );
450 if ( !ok ) return false;
452 iteration.SetName( chunk.c_str() );
453 chunk = getNextChunk( stream, start, ok );
454 if ( !ok ) return false;
455 iteration.SetState( atoi( chunk.c_str() ) );
456 chunk = getNextChunk( stream, start, ok );
457 if ( !ok ) return false;
458 iteration.SetNumber( atoi( chunk.c_str() ) );
459 chunk = getNextChunk( stream, start, ok );
460 if ( !ok ) return false;
461 iteration.SetMeshFile( chunk.c_str() );
462 chunk = getNextChunk( stream, start, ok );
463 if ( !ok ) return false;
464 iteration.SetLogFile( chunk.c_str() );
465 chunk = getNextChunk( stream, start, ok );
466 if ( !ok ) return false;
467 iteration.SetMeshName( chunk.c_str() );
468 chunk = getNextChunk( stream, start, ok );
469 if ( !ok ) return false;
470 iteration.SetFieldFile( chunk.c_str() );
473 chunk = getNextChunk( stream, start, ok );
474 if ( !ok ) return false;
475 timestep = atoi( chunk.c_str() );
476 chunk = getNextChunk( stream, start, ok );
477 if ( !ok ) return false;
478 rank = atoi( chunk.c_str() );
479 iteration.SetTimeStepRank( timestep, rank );
480 chunk = getNextChunk( stream, start, ok );
481 if ( !ok ) return false;
482 iteration.SetIterParentName( chunk.c_str() );
484 chunk = getNextChunk( stream, start, ok );
485 if ( !ok ) return false;
486 int size = atoi( chunk.c_str() );
487 for ( int i = 0; i < size; i++ ) {
488 chunk = getNextChunk( stream, start, ok );
489 if ( !ok ) return false;
490 iteration.LinkNextIteration( chunk.c_str() );
493 chunk = getNextChunk( stream, start, ok );
494 if ( !ok ) return false;
495 iteration.SetHypoName( chunk.c_str() );
496 chunk = getNextChunk( stream, start, ok );
497 if ( !ok ) return false;
498 iteration.SetCaseName( chunk.c_str() );
499 chunk = getNextChunk( stream, start, ok );
500 if ( !ok ) return false;
501 iteration.SetDirNameLoc( chunk.c_str() );
510 \brief Restore hypothesis from the string
511 \param hypothesis hypothesis being restored
512 \param stream string representation of the hypothesis
513 \return \c true if hypothesis is correctly restored or \c false otherwise
515 bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream )
517 std::string::size_type start = 0;
518 std::string chunk, chunkNext;
521 chunk = getNextChunk( stream, start, ok );
522 if ( !ok ) return false;
523 hypothesis.SetName( chunk.c_str() );
525 chunk = getNextChunk( stream, start, ok );
526 if ( !ok ) return false;
527 hypothesis.SetCaseCreation( chunk.c_str() );
529 chunk = getNextChunk( stream, start, ok );
530 if ( !ok ) return false;
531 hypothesis.SetAdapType( atoi( chunk.c_str() ) );
533 chunk = getNextChunk( stream, start, ok );
534 if ( !ok ) return false;
535 int typeraff = atoi( chunk.c_str() );
536 chunk = getNextChunk( stream, start, ok );
537 if ( !ok ) return false;
538 int typedera = atoi( chunk.c_str() );
539 hypothesis.SetRefinTypeDera( typeraff, typedera );
541 chunk = getNextChunk( stream, start, ok );
542 if ( !ok ) return false;
543 hypothesis.SetField( chunk.c_str() );
545 chunk = getNextChunk( stream, start, ok );
546 if ( !ok ) return false;
547 int typethr = atoi( chunk.c_str() );
548 chunk = getNextChunk( stream, start, ok );
549 if ( !ok ) return false;
550 double threshr = strtod( chunk.c_str(), 0 );
551 hypothesis.SetRefinThr( typethr, threshr );
553 chunk = getNextChunk( stream, start, ok );
554 if ( !ok ) return false;
555 int typethc = atoi( chunk.c_str() );
556 chunk = getNextChunk( stream, start, ok );
557 if ( !ok ) return false;
558 double threshc = strtod( chunk.c_str(), 0 );
559 hypothesis.SetUnRefThr( typethc, threshc );
561 chunk = getNextChunk( stream, start, ok );
562 if ( !ok ) return false;
563 hypothesis.SetUseField(atoi(chunk.c_str()));
565 chunk = getNextChunk( stream, start, ok );
566 if ( !ok ) return false;
567 hypothesis.SetUseComp(atoi(chunk.c_str()));
569 chunk = getNextChunk( stream, start, ok );
570 if ( !ok ) return false;
571 hypothesis.SetTypeFieldInterp(atoi(chunk.c_str()));
573 chunk = getNextChunk( stream, start, ok );
574 if ( !ok ) return false;
575 int size = atoi( chunk.c_str() );
576 for ( int i = 0; i < size; i++ ) {
577 chunk = getNextChunk( stream, start, ok );
578 if ( !ok ) return false;
579 hypothesis.LinkIteration( chunk.c_str() );
582 chunk = getNextChunk( stream, start, ok );
583 if ( !ok ) return false;
584 size = atoi( chunk.c_str() );
585 for ( int i = 0; i < size; i++ ) {
586 chunk = getNextChunk( stream, start, ok );
587 if ( !ok ) return false;
589 chunkNext = getNextChunk( stream, start, ok );
590 int typeuse = atoi( chunkNext.c_str() );
591 if ( !ok ) return false;
592 hypothesis.AddZone( chunk.c_str(), typeuse );
595 chunk = getNextChunk( stream, start, ok );
596 if ( !ok ) return false;
597 size = atoi( chunk.c_str() );
598 for ( int i = 0; i < size; i++ ) {
599 chunk = getNextChunk( stream, start, ok );
600 if ( !ok ) return false;
601 hypothesis.AddComp( chunk.c_str() );
604 chunk = getNextChunk( stream, start, ok );
605 if ( !ok ) return false;
606 size = atoi( chunk.c_str() );
607 for ( int i = 0; i < size; i++ ) {
608 chunk = getNextChunk( stream, start, ok );
609 if ( !ok ) return false;
610 hypothesis.AddGroup( chunk.c_str() );
613 chunk = getNextChunk( stream, start, ok );
614 if ( !ok ) return false;
615 size = atoi( chunk.c_str() );
616 for ( int i = 0; i < size; i++ ) {
617 chunk = getNextChunk( stream, start, ok );
618 if ( !ok ) return false;
620 chunkNext = getNextChunk( stream, start, ok );
621 int TypeInterp = atoi( chunkNext.c_str() );
622 if ( !ok ) return false;
623 hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp );
626 chunk = getNextChunk( stream, start, ok );
627 if ( !ok ) return false;
628 hypothesis.SetNivMax( atoi( chunk.c_str() ) );
630 chunk = getNextChunk( stream, start, ok );
631 if ( !ok ) return false;
632 hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) );
634 chunk = getNextChunk( stream, start, ok );
635 if ( !ok ) return false;
636 hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) );
638 chunk = getNextChunk( stream, start, ok );
639 if ( !ok ) return false;
640 hypothesis.SetLevelOutput( strtod( chunk.c_str(), 0 ) );
650 \brief Restore zone from the string
651 \param zone zone being restored
652 \param stream string representation of the zone
653 \return \c true if zone is correctly restored or \c false otherwise
655 bool Restore( HOMARD_Zone& zone, const std::string& stream )
657 std::string::size_type start = 0;
661 chunk = getNextChunk( stream, start, ok );
662 if ( !ok ) return false;
663 zone.SetName( chunk.c_str() );
665 chunk = getNextChunk( stream, start, ok );
666 if ( !ok ) return false;
667 int ZoneType = atoi( chunk.c_str() ) ;
668 zone.SetType( ZoneType );
669 // Les coordonnees des zones : le nombre depend du type
670 std::vector<double> coords;
672 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { lgcoords = 6 ; }
673 else if ( ZoneType == 4 ) { lgcoords = 4 ; }
674 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { lgcoords = 8 ; }
675 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { lgcoords = 9 ; }
677 coords.resize( lgcoords );
678 for ( int i = 0; i < lgcoords; i++ ) {
679 chunk = getNextChunk( stream, start, ok );
680 if ( !ok ) return false;
681 coords[i] = strtod( chunk.c_str(), 0 );
683 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) )
684 { zone.SetBox( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] ); }
685 else if ( ZoneType == 4 )
686 { zone.SetSphere( coords[0], coords[1], coords[2], coords[3] ); }
687 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) )
688 { zone.SetCylinder( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7] ); }
689 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) )
690 { zone.SetPipe( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7], coords[8] ); }
691 // Remarque : la taille de coords est suffisante pour les limites
692 for ( int i = 0; i < 3; i++ ) {
693 chunk = getNextChunk( stream, start, ok );
694 if ( !ok ) return false;
695 coords[i] = strtod( chunk.c_str(), 0 );
697 zone.SetLimit( coords[0], coords[1], coords[2]);
699 chunk = getNextChunk( stream, start, ok );
700 if ( !ok ) return false;
701 int size = atoi( chunk.c_str() );
702 for ( int i = 0; i < size; i++ ) {
703 chunk = getNextChunk( stream, start, ok );
704 if ( !ok ) return false;
705 zone.AddHypo( chunk.c_str() );
711 // =================================
712 // 2.5. Restauration d'une frontiere
713 // =================================
716 \brief Restore boundary from the string
717 \param boundary boundary being restored
718 \param stream string representation of the boundary
719 \return \c true if the boundary is correctly restored or \c false otherwise
721 bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
723 std::string::size_type start = 0;
727 chunk = getNextChunk( stream, start, ok );
728 if ( !ok ) return false;
729 boundary.SetName( chunk.c_str() );
731 chunk = getNextChunk( stream, start, ok );
732 if ( !ok ) return false;
733 int BoundaryType = atoi( chunk.c_str() ) ;
734 boundary.SetType( BoundaryType );
736 chunk = getNextChunk( stream, start, ok );
737 if ( !ok ) return false;
738 boundary.SetCaseCreation( chunk.c_str() );
740 // Si analytique, les coordonnees des frontieres : le nombre depend du type
741 // Si discret, le maillage
743 if ( BoundaryType == 1 ) { lgcoords = 7 ; }
744 else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
745 else { lgcoords = 0 ; }
749 chunk = getNextChunk( stream, start, ok );
750 if ( !ok ) return false;
751 boundary.SetMeshName( chunk.c_str() );
753 chunk = getNextChunk( stream, start, ok );
754 if ( !ok ) return false;
755 boundary.SetMeshFile( chunk.c_str() );
758 { std::vector<double> coords;
759 coords.resize( lgcoords );
760 for ( int i = 0; i < lgcoords; i++ ) {
761 chunk = getNextChunk( stream, start, ok );
762 if ( !ok ) return false;
763 coords[i] = strtod( chunk.c_str(), 0 );
765 if ( BoundaryType == 1 )
766 { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
767 else if ( BoundaryType == 2 )
768 { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
769 else if ( BoundaryType == 3 )
770 { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
771 else if ( BoundaryType == 4 )
772 { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
773 // Remarque : la taille de coords est suffisante pour les limites
774 for ( int i = 0; i < 3; i++ ) {
775 chunk = getNextChunk( stream, start, ok );
776 if ( !ok ) return false;
777 coords[i] = strtod( chunk.c_str(), 0 );
779 boundary.SetLimit( coords[0], coords[1], coords[2]);
782 chunk = getNextChunk( stream, start, ok );
783 if ( !ok ) return false;
784 int size = atoi( chunk.c_str() );
785 for ( int i = 0; i < size; i++ ) {
786 chunk = getNextChunk( stream, start, ok );
787 if ( !ok ) return false;
788 boundary.AddGroup( chunk.c_str() );
795 // ==================================
796 // 2.6. Restauration d'un schema YACS
797 // ==================================
800 \brief Restore a schema YACS from the string
801 \param yacs yacs being restored
802 \param stream string representation of the schema yacs
803 \return \c true if yacs is correctly restored or \c false otherwise
805 bool Restore( HOMARD_YACS& yacs, const std::string& stream )
807 std::string::size_type start = 0;
811 chunk = getNextChunk( stream, start, ok );
812 if ( !ok ) return false;
813 yacs.SetName( chunk.c_str() );
815 chunk = getNextChunk( stream, start, ok );
816 if ( !ok ) return false;
817 int YACSType = atoi( chunk.c_str() ) ;
818 yacs.SetType( YACSType );
823 } // namespace HOMARD /end/