1 // Copyright (C) 2011-2016 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, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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();
115 os << separator() << cas.GetExtType();
117 std::vector<double> coor = cas.GetBoundingBox();
118 os << separator() << coor.size();
119 for ( int i = 0; i < coor.size(); i++ )
120 os << separator() << coor[i];
122 std::list<std::string> ListString = cas.GetIterations();
123 os << separator() << ListString.size();
124 std::list<std::string>::const_iterator it;
125 for ( it = ListString.begin(); it != ListString.end(); ++it )
126 os << separator() << *it;
128 ListString = cas.GetGroups();
129 os << separator() << ListString.size();
130 for ( it = ListString.begin(); it != ListString.end(); ++it )
131 os << separator() << *it;
132 ListString = cas.GetBoundaryGroup();
133 os << separator() << ListString.size();
134 for ( it = ListString.begin(); it != ListString.end(); ++it )
135 os << separator() << *it;
137 os << separator() << cas.GetPyram();
140 // MESSAGE( ". Fin avec "<<saux);
149 \brief Dump iteration to the string
150 \param iteration iteration being dumped
151 \return string representation of the iteration
153 std::string Dump( const HOMARD_Iteration& iteration )
155 std::stringstream os;
158 MESSAGE( ". Sauvegarde de l'iteration "<<iteration.GetName());
159 os << iteration.GetName();
160 os << separator() << iteration.GetState();
161 os << separator() << iteration.GetNumber();
162 os << separator() << iteration.GetMeshFile();
163 os << separator() << iteration.GetLogFile();
164 os << separator() << iteration.GetMeshName();
165 os << separator() << iteration.GetFieldFile();
166 os << separator() << iteration.GetTimeStep();
167 os << separator() << iteration.GetRank();
168 os << separator() << iteration.GetIterParentName();
170 std::list<std::string> ListString = iteration.GetIterations();
171 os << separator() << ListString.size();
172 std::list<std::string>::const_iterator it;
173 for ( it = ListString.begin(); it != ListString.end(); ++it )
174 os << separator() << *it;
176 os << separator() << iteration.GetHypoName();
177 os << separator() << iteration.GetCaseName();
178 os << separator() << iteration.GetDirNameLoc();
181 // MESSAGE( ". Fin avec "<<saux);
189 \brief Dump hypothesis to the string
190 \param hypothesis hypothesis being dumped
191 \return string representation of the hypothesis
193 std::string Dump( const HOMARD_Hypothesis& hypothesis )
195 std::stringstream os;
198 MESSAGE( ". Sauvegarde de l'hypothese "<<hypothesis.GetName());
199 os << hypothesis.GetName();
200 os << separator() << hypothesis.GetCaseCreation();
201 os << separator() << hypothesis.GetAdapType();
202 os << separator() << hypothesis.GetRefinType();
203 os << separator() << hypothesis.GetUnRefType();
204 os << separator() << hypothesis.GetFieldName();
205 os << separator() << hypothesis.GetRefinThrType();
206 os << separator() << hypothesis.GetThreshR();
207 os << separator() << hypothesis.GetUnRefThrType();
208 os << separator() << hypothesis.GetThreshC();
209 os << separator() << hypothesis.GetUseField();
210 os << separator() << hypothesis.GetUseComp();
211 os << separator() << hypothesis.GetTypeFieldInterp();
213 std::list<std::string> ListString = hypothesis.GetIterations();
214 std::list<std::string>::const_iterator it;
215 os << separator() << ListString.size();
216 for ( it = ListString.begin(); it != ListString.end(); ++it )
217 os << separator() << *it;
219 ListString = hypothesis.GetZones();
220 os << separator() << ListString.size();
221 for ( it = ListString.begin(); it != ListString.end(); ++it )
222 os << separator() << *it;
224 ListString = hypothesis.GetComps();
225 os << separator() << ListString.size();
226 for ( it = ListString.begin(); it != ListString.end(); ++it )
227 os << separator() << *it;
229 ListString = hypothesis.GetGroups();
230 os << separator() << ListString.size();
231 for ( it = ListString.begin(); it != ListString.end(); ++it )
232 os << separator() << *it;
234 ListString = hypothesis.GetFieldInterps();
235 os << separator() << ListString.size();
236 for ( it = ListString.begin(); it != ListString.end(); ++it )
237 os << separator() << *it;
239 os << separator() << hypothesis.GetNivMax();
240 os << separator() << hypothesis.GetDiamMin();
241 os << separator() << hypothesis.GetAdapInit();
242 os << separator() << hypothesis.GetExtraOutput();
245 // MESSAGE( ". Fin avec "<<saux);
254 \brief Dump zone to the string
255 \param zone zone being dumped
256 \return string representation of the zone
258 std::string Dump( const HOMARD_Zone& zone )
260 std::stringstream os;
262 MESSAGE( ". Sauvegarde de la zone "<<zone.GetName());
263 os << zone.GetName();
264 os << separator() << zone.GetType();
266 std::vector<double> coords = zone.GetCoords();
267 for ( int i = 0; i < coords.size(); i++ )
268 os << separator() << ( i < coords.size() ? coords[i] : 0. );
270 std::vector<double> limit = zone.GetLimit();
271 for ( int i = 0; i < 3; i++ )
272 os << separator() << ( i < limit.size() ? limit[i] : 0. );
274 std::list<std::string> hypos = zone.GetHypo();
275 os << separator() << hypos.size();
276 std::list<std::string>::const_iterator it;
277 for ( it = hypos.begin(); it != hypos.end(); ++it )
278 os << separator() << *it;
281 // MESSAGE( ". Fin avec "<<saux);
285 // ==============================
286 // 1.5. Archivage d'une frontiere
287 // ==============================
290 \brief Dump boundary to the string
291 \param boundary boundary being dumped
292 \return string representation of the boundary
294 std::string Dump( const HOMARD_Boundary& boundary )
296 std::stringstream os;
298 MESSAGE( ". Sauvegarde de la frontiere "<<boundary.GetName());
300 int BoundaryType = boundary.GetType() ;
302 os << boundary.GetName() ;
303 os << separator() << BoundaryType ;
304 os << separator() << boundary.GetCaseCreation() ;
306 if ( BoundaryType == 0 )
308 os << separator() << boundary.GetMeshName();
309 os << separator() << boundary.GetMeshFile();
312 std::vector<double> coor = boundary.GetCoords() ;
313 for ( int i = 0; i < coor.size(); i++ )
314 os << separator() << coor[i];
315 std::vector<double> limit = boundary.GetLimit();
316 for ( int i = 0; i < limit.size(); i++ )
317 os << separator() << limit[i];
320 std::list<std::string> ListString = boundary.GetGroups();
321 std::list<std::string>::const_iterator it;
322 os << separator() << ListString.size();
323 for ( it = ListString.begin(); it != ListString.end(); ++it )
324 os << separator() << *it;
327 // MESSAGE( ". Fin avec "<<saux);
337 \brief Dump YACS to the string
338 \param yacs yacs being dumped
339 \return string representation of the zone
341 std::string Dump( const HOMARD_YACS& yacs )
343 std::stringstream os;
345 MESSAGE( ". Sauvegarde du schema YACS "<<yacs.GetName());
346 os << yacs.GetName();
347 os << separator() << yacs.GetType();
350 // MESSAGE( ". Fin avec "<<saux);
354 // 2. Restauration des objets
355 // ==========================
357 // ==========================
360 \brief Restore case from the string
361 \param cas case being restored
362 \param stream string representation of the case
363 \return \c true if case is correctly restored or \c false otherwise
365 bool Restore( HOMARD_Cas& cas, const std::string& stream )
367 MESSAGE( ". Restoration du cas ");
368 std::string::size_type start = 0;
369 std::string chunk, chunkNext;
372 chunk = getNextChunk( stream, start, ok );
373 if ( !ok ) return false;
374 cas.SetName( chunk.c_str() );
376 chunk = getNextChunk( stream, start, ok );
377 if ( !ok ) return false;
378 cas.SetDirName( chunk.c_str() );
380 chunk = getNextChunk( stream, start, ok );
381 if ( !ok ) return false;
382 cas.SetConfType( atoi( chunk.c_str() ) );
384 chunk = getNextChunk( stream, start, ok );
385 if ( !ok ) return false;
386 cas.SetExtType( atoi( chunk.c_str() ) );
388 chunk = getNextChunk( stream, start, ok );
389 if ( !ok ) return false;
391 int size = atoi( chunk.c_str() );
392 std::vector<double> boite;
393 boite.resize( size );
394 for ( int i = 0; i < size; i++ ) {
395 chunk = getNextChunk( stream, start, ok );
396 if ( !ok ) return false;
397 boite[i] = strtod( chunk.c_str(), 0 );
399 cas.SetBoundingBox( boite );
401 chunk = getNextChunk( stream, start, ok );
402 if ( !ok ) return false;
404 size = atoi( chunk.c_str() );
405 for ( int i = 0; i < size; i++ ) {
406 chunk = getNextChunk( stream, start, ok );
407 if ( !ok ) return false;
408 cas.AddIteration( chunk.c_str() );
411 chunk = getNextChunk( stream, start, ok );
412 if ( !ok ) return false;
413 size = atoi( chunk.c_str() );
414 for ( int i = 0; i < size; i++ )
416 chunk = getNextChunk( stream, start, ok );
417 if ( !ok ) return false;
418 cas.AddGroup( chunk.c_str() );
421 chunk = getNextChunk( stream, start, ok );
422 if ( !ok ) return false;
423 size = atoi( chunk.c_str() );
424 for ( int i = 0; i < size; i++ ) {
425 chunk = getNextChunk( stream, start, ok );
426 if ( !ok ) return false;
428 chunkNext = getNextChunk( stream, start, ok );
429 if ( !ok ) return false;
430 cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() );
433 chunk = getNextChunk( stream, start, ok );
434 if ( !ok ) return false;
435 cas.SetPyram( atoi( chunk.c_str() ) );
444 \brief Restore iteration from the string
445 \param iteration iteration being restored
446 \param stream string representation of the iteration
447 \return \c true if iteration is correctly restored or \c false otherwise
449 bool Restore( HOMARD_Iteration& iteration, const std::string& stream )
451 std::string::size_type start = 0;
454 chunk = getNextChunk( stream, start, ok );
455 if ( !ok ) return false;
457 iteration.SetName( chunk.c_str() );
458 chunk = getNextChunk( stream, start, ok );
459 if ( !ok ) return false;
460 iteration.SetState( atoi( chunk.c_str() ) );
461 chunk = getNextChunk( stream, start, ok );
462 if ( !ok ) return false;
463 iteration.SetNumber( atoi( chunk.c_str() ) );
464 chunk = getNextChunk( stream, start, ok );
465 if ( !ok ) return false;
466 iteration.SetMeshFile( chunk.c_str() );
467 chunk = getNextChunk( stream, start, ok );
468 if ( !ok ) return false;
469 iteration.SetLogFile( chunk.c_str() );
470 chunk = getNextChunk( stream, start, ok );
471 if ( !ok ) return false;
472 iteration.SetMeshName( chunk.c_str() );
473 chunk = getNextChunk( stream, start, ok );
474 if ( !ok ) return false;
475 iteration.SetFieldFile( chunk.c_str() );
478 chunk = getNextChunk( stream, start, ok );
479 if ( !ok ) return false;
480 timestep = atoi( chunk.c_str() );
481 chunk = getNextChunk( stream, start, ok );
482 if ( !ok ) return false;
483 rank = atoi( chunk.c_str() );
484 iteration.SetTimeStepRank( timestep, rank );
485 chunk = getNextChunk( stream, start, ok );
486 if ( !ok ) return false;
487 iteration.SetIterParentName( chunk.c_str() );
489 chunk = getNextChunk( stream, start, ok );
490 if ( !ok ) return false;
491 int size = atoi( chunk.c_str() );
492 for ( int i = 0; i < size; i++ ) {
493 chunk = getNextChunk( stream, start, ok );
494 if ( !ok ) return false;
495 iteration.LinkNextIteration( chunk.c_str() );
498 chunk = getNextChunk( stream, start, ok );
499 if ( !ok ) return false;
500 iteration.SetHypoName( chunk.c_str() );
501 chunk = getNextChunk( stream, start, ok );
502 if ( !ok ) return false;
503 iteration.SetCaseName( chunk.c_str() );
504 chunk = getNextChunk( stream, start, ok );
505 if ( !ok ) return false;
506 iteration.SetDirNameLoc( chunk.c_str() );
515 \brief Restore hypothesis from the string
516 \param hypothesis hypothesis being restored
517 \param stream string representation of the hypothesis
518 \return \c true if hypothesis is correctly restored or \c false otherwise
520 bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream )
522 std::string::size_type start = 0;
523 std::string chunk, chunkNext;
526 chunk = getNextChunk( stream, start, ok );
527 if ( !ok ) return false;
528 hypothesis.SetName( chunk.c_str() );
530 chunk = getNextChunk( stream, start, ok );
531 if ( !ok ) return false;
532 hypothesis.SetCaseCreation( chunk.c_str() );
534 chunk = getNextChunk( stream, start, ok );
535 if ( !ok ) return false;
536 hypothesis.SetAdapType( atoi( chunk.c_str() ) );
538 chunk = getNextChunk( stream, start, ok );
539 if ( !ok ) return false;
540 int typeraff = atoi( chunk.c_str() );
541 chunk = getNextChunk( stream, start, ok );
542 if ( !ok ) return false;
543 int typedera = atoi( chunk.c_str() );
544 hypothesis.SetRefinTypeDera( typeraff, typedera );
546 chunk = getNextChunk( stream, start, ok );
547 if ( !ok ) return false;
548 hypothesis.SetField( chunk.c_str() );
550 chunk = getNextChunk( stream, start, ok );
551 if ( !ok ) return false;
552 int typethr = atoi( chunk.c_str() );
553 chunk = getNextChunk( stream, start, ok );
554 if ( !ok ) return false;
555 double threshr = strtod( chunk.c_str(), 0 );
556 hypothesis.SetRefinThr( typethr, threshr );
558 chunk = getNextChunk( stream, start, ok );
559 if ( !ok ) return false;
560 int typethc = atoi( chunk.c_str() );
561 chunk = getNextChunk( stream, start, ok );
562 if ( !ok ) return false;
563 double threshc = strtod( chunk.c_str(), 0 );
564 hypothesis.SetUnRefThr( typethc, threshc );
566 chunk = getNextChunk( stream, start, ok );
567 if ( !ok ) return false;
568 hypothesis.SetUseField(atoi(chunk.c_str()));
570 chunk = getNextChunk( stream, start, ok );
571 if ( !ok ) return false;
572 hypothesis.SetUseComp(atoi(chunk.c_str()));
574 chunk = getNextChunk( stream, start, ok );
575 if ( !ok ) return false;
576 hypothesis.SetTypeFieldInterp(atoi(chunk.c_str()));
578 chunk = getNextChunk( stream, start, ok );
579 if ( !ok ) return false;
580 int size = atoi( chunk.c_str() );
581 for ( int i = 0; i < size; i++ ) {
582 chunk = getNextChunk( stream, start, ok );
583 if ( !ok ) return false;
584 hypothesis.LinkIteration( chunk.c_str() );
587 chunk = getNextChunk( stream, start, ok );
588 if ( !ok ) return false;
589 size = atoi( chunk.c_str() );
590 for ( int i = 0; i < size; i++ ) {
591 chunk = getNextChunk( stream, start, ok );
592 if ( !ok ) return false;
594 chunkNext = getNextChunk( stream, start, ok );
595 int typeuse = atoi( chunkNext.c_str() );
596 if ( !ok ) return false;
597 hypothesis.AddZone( chunk.c_str(), typeuse );
600 chunk = getNextChunk( stream, start, ok );
601 if ( !ok ) return false;
602 size = atoi( chunk.c_str() );
603 for ( int i = 0; i < size; i++ ) {
604 chunk = getNextChunk( stream, start, ok );
605 if ( !ok ) return false;
606 hypothesis.AddComp( chunk.c_str() );
609 chunk = getNextChunk( stream, start, ok );
610 if ( !ok ) return false;
611 size = atoi( chunk.c_str() );
612 for ( int i = 0; i < size; i++ ) {
613 chunk = getNextChunk( stream, start, ok );
614 if ( !ok ) return false;
615 hypothesis.AddGroup( chunk.c_str() );
618 chunk = getNextChunk( stream, start, ok );
619 if ( !ok ) return false;
620 size = atoi( chunk.c_str() );
621 for ( int i = 0; i < size; i++ ) {
622 chunk = getNextChunk( stream, start, ok );
623 if ( !ok ) return false;
625 chunkNext = getNextChunk( stream, start, ok );
626 int TypeInterp = atoi( chunkNext.c_str() );
627 if ( !ok ) return false;
628 hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp );
631 chunk = getNextChunk( stream, start, ok );
632 if ( !ok ) return false;
633 hypothesis.SetNivMax( atoi( chunk.c_str() ) );
635 chunk = getNextChunk( stream, start, ok );
636 if ( !ok ) return false;
637 hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) );
639 chunk = getNextChunk( stream, start, ok );
640 if ( !ok ) return false;
641 hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) );
643 chunk = getNextChunk( stream, start, ok );
644 if ( !ok ) return false;
645 hypothesis.SetExtraOutput( strtod( chunk.c_str(), 0 ) );
655 \brief Restore zone from the string
656 \param zone zone being restored
657 \param stream string representation of the zone
658 \return \c true if zone is correctly restored or \c false otherwise
660 bool Restore( HOMARD_Zone& zone, const std::string& stream )
662 std::string::size_type start = 0;
666 chunk = getNextChunk( stream, start, ok );
667 if ( !ok ) return false;
668 zone.SetName( chunk.c_str() );
670 chunk = getNextChunk( stream, start, ok );
671 if ( !ok ) return false;
672 int ZoneType = atoi( chunk.c_str() ) ;
673 zone.SetType( ZoneType );
674 // Les coordonnees des zones : le nombre depend du type
675 std::vector<double> coords;
677 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { lgcoords = 6 ; }
678 else if ( ZoneType == 4 ) { lgcoords = 4 ; }
679 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { lgcoords = 8 ; }
680 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { lgcoords = 9 ; }
682 coords.resize( lgcoords );
683 for ( int i = 0; i < lgcoords; i++ ) {
684 chunk = getNextChunk( stream, start, ok );
685 if ( !ok ) return false;
686 coords[i] = strtod( chunk.c_str(), 0 );
688 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) )
689 { zone.SetBox( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] ); }
690 else if ( ZoneType == 4 )
691 { zone.SetSphere( coords[0], coords[1], coords[2], coords[3] ); }
692 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) )
693 { zone.SetCylinder( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7] ); }
694 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) )
695 { zone.SetPipe( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7], coords[8] ); }
696 // Remarque : la taille de coords est suffisante pour les limites
697 for ( int i = 0; i < 3; i++ ) {
698 chunk = getNextChunk( stream, start, ok );
699 if ( !ok ) return false;
700 coords[i] = strtod( chunk.c_str(), 0 );
702 zone.SetLimit( coords[0], coords[1], coords[2]);
704 chunk = getNextChunk( stream, start, ok );
705 if ( !ok ) return false;
706 int size = atoi( chunk.c_str() );
707 for ( int i = 0; i < size; i++ ) {
708 chunk = getNextChunk( stream, start, ok );
709 if ( !ok ) return false;
710 zone.AddHypo( chunk.c_str() );
716 // =================================
717 // 2.5. Restauration d'une frontiere
718 // =================================
721 \brief Restore boundary from the string
722 \param boundary boundary being restored
723 \param stream string representation of the boundary
724 \return \c true if the boundary is correctly restored or \c false otherwise
726 bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
728 std::string::size_type start = 0;
732 chunk = getNextChunk( stream, start, ok );
733 if ( !ok ) return false;
734 boundary.SetName( chunk.c_str() );
736 chunk = getNextChunk( stream, start, ok );
737 if ( !ok ) return false;
738 int BoundaryType = atoi( chunk.c_str() ) ;
739 boundary.SetType( BoundaryType );
741 chunk = getNextChunk( stream, start, ok );
742 if ( !ok ) return false;
743 boundary.SetCaseCreation( chunk.c_str() );
745 // Si analytique, les coordonnees des frontieres : le nombre depend du type
746 // Si discret, le maillage
748 if ( BoundaryType == 1 ) { lgcoords = 7 ; }
749 else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
750 else { lgcoords = 0 ; }
754 chunk = getNextChunk( stream, start, ok );
755 if ( !ok ) return false;
756 boundary.SetMeshName( chunk.c_str() );
758 chunk = getNextChunk( stream, start, ok );
759 if ( !ok ) return false;
760 boundary.SetMeshFile( chunk.c_str() );
763 { std::vector<double> coords;
764 coords.resize( lgcoords );
765 for ( int i = 0; i < lgcoords; i++ ) {
766 chunk = getNextChunk( stream, start, ok );
767 if ( !ok ) return false;
768 coords[i] = strtod( chunk.c_str(), 0 );
770 if ( BoundaryType == 1 )
771 { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
772 else if ( BoundaryType == 2 )
773 { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
774 else if ( BoundaryType == 3 )
775 { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
776 else if ( BoundaryType == 4 )
777 { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
778 // Remarque : la taille de coords est suffisante pour les limites
779 for ( int i = 0; i < 3; i++ ) {
780 chunk = getNextChunk( stream, start, ok );
781 if ( !ok ) return false;
782 coords[i] = strtod( chunk.c_str(), 0 );
784 boundary.SetLimit( coords[0], coords[1], coords[2]);
787 chunk = getNextChunk( stream, start, ok );
788 if ( !ok ) return false;
789 int size = atoi( chunk.c_str() );
790 for ( int i = 0; i < size; i++ ) {
791 chunk = getNextChunk( stream, start, ok );
792 if ( !ok ) return false;
793 boundary.AddGroup( chunk.c_str() );
800 // ==================================
801 // 2.6. Restauration d'un schema YACS
802 // ==================================
805 \brief Restore a schema YACS from the string
806 \param yacs yacs being restored
807 \param stream string representation of the schema yacs
808 \return \c true if yacs is correctly restored or \c false otherwise
810 bool Restore( HOMARD_YACS& yacs, const std::string& stream )
812 std::string::size_type start = 0;
816 chunk = getNextChunk( stream, start, ok );
817 if ( !ok ) return false;
818 yacs.SetName( chunk.c_str() );
820 chunk = getNextChunk( stream, start, ok );
821 if ( !ok ) return false;
822 int YACSType = atoi( chunk.c_str() ) ;
823 yacs.SetType( YACSType );
828 } // namespace HOMARD /end/