1 // Copyright (C) 2011-2023 CEA, EDF
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 == -1 )
308 os << separator() << boundary.GetDataFile();
310 else if ( BoundaryType == 0 )
312 os << separator() << boundary.GetMeshName();
313 os << separator() << boundary.GetDataFile();
316 std::vector<double> coor = boundary.GetCoords() ;
317 for ( int i = 0; i < coor.size(); i++ )
318 os << separator() << coor[i];
319 std::vector<double> limit = boundary.GetLimit();
320 for ( int i = 0; i < limit.size(); i++ )
321 os << separator() << limit[i];
324 std::list<std::string> ListString = boundary.GetGroups();
325 std::list<std::string>::const_iterator it;
326 os << separator() << ListString.size();
327 for ( it = ListString.begin(); it != ListString.end(); ++it )
328 os << separator() << *it;
331 // MESSAGE( ". Fin avec "<<saux);
341 \brief Dump YACS to the string
342 \param yacs yacs being dumped
343 \return string representation of the zone
345 std::string Dump( const HOMARD_YACS& yacs )
347 std::stringstream os;
349 MESSAGE( ". Sauvegarde du schema YACS "<<yacs.GetName());
350 os << yacs.GetName();
351 os << separator() << yacs.GetType();
354 // MESSAGE( ". Fin avec "<<saux);
358 // 2. Restauration des objets
359 // ==========================
361 // ==========================
364 \brief Restore case from the string
365 \param cas case being restored
366 \param stream string representation of the case
367 \return \c true if case is correctly restored or \c false otherwise
369 bool Restore( HOMARD_Cas& cas, const std::string& stream )
371 MESSAGE( ". Restoration du cas ");
372 std::string::size_type start = 0;
373 std::string chunk, chunkNext;
376 chunk = getNextChunk( stream, start, ok );
377 if ( !ok ) return false;
378 cas.SetName( chunk.c_str() );
380 chunk = getNextChunk( stream, start, ok );
381 if ( !ok ) return false;
382 cas.SetDirName( chunk.c_str() );
384 chunk = getNextChunk( stream, start, ok );
385 if ( !ok ) return false;
386 cas.SetConfType( atoi( chunk.c_str() ) );
388 chunk = getNextChunk( stream, start, ok );
389 if ( !ok ) return false;
390 cas.SetExtType( atoi( chunk.c_str() ) );
392 chunk = getNextChunk( stream, start, ok );
393 if ( !ok ) return false;
395 int size = atoi( chunk.c_str() );
396 std::vector<double> boite;
397 boite.resize( size );
398 for ( int i = 0; i < size; i++ ) {
399 chunk = getNextChunk( stream, start, ok );
400 if ( !ok ) return false;
401 boite[i] = strtod( chunk.c_str(), 0 );
403 cas.SetBoundingBox( boite );
405 chunk = getNextChunk( stream, start, ok );
406 if ( !ok ) return false;
408 size = atoi( chunk.c_str() );
409 for ( int i = 0; i < size; i++ ) {
410 chunk = getNextChunk( stream, start, ok );
411 if ( !ok ) return false;
412 cas.AddIteration( chunk.c_str() );
415 chunk = getNextChunk( stream, start, ok );
416 if ( !ok ) return false;
417 size = atoi( chunk.c_str() );
418 for ( int i = 0; i < size; i++ )
420 chunk = getNextChunk( stream, start, ok );
421 if ( !ok ) return false;
422 cas.AddGroup( chunk.c_str() );
425 chunk = getNextChunk( stream, start, ok );
426 if ( !ok ) return false;
427 size = atoi( chunk.c_str() );
428 for ( int i = 0; i < size; i++ ) {
429 chunk = getNextChunk( stream, start, ok );
430 if ( !ok ) return false;
432 chunkNext = getNextChunk( stream, start, ok );
433 if ( !ok ) return false;
434 cas.AddBoundaryGroup( chunk.c_str(), chunkNext.c_str() );
437 chunk = getNextChunk( stream, start, ok );
438 if ( !ok ) return false;
439 cas.SetPyram( atoi( chunk.c_str() ) );
448 \brief Restore iteration from the string
449 \param iteration iteration being restored
450 \param stream string representation of the iteration
451 \return \c true if iteration is correctly restored or \c false otherwise
453 bool Restore( HOMARD_Iteration& iteration, const std::string& stream )
455 std::string::size_type start = 0;
458 chunk = getNextChunk( stream, start, ok );
459 if ( !ok ) return false;
461 iteration.SetName( chunk.c_str() );
462 chunk = getNextChunk( stream, start, ok );
463 if ( !ok ) return false;
464 iteration.SetState( atoi( chunk.c_str() ) );
465 chunk = getNextChunk( stream, start, ok );
466 if ( !ok ) return false;
467 iteration.SetNumber( atoi( chunk.c_str() ) );
468 chunk = getNextChunk( stream, start, ok );
469 if ( !ok ) return false;
470 iteration.SetMeshFile( chunk.c_str() );
471 chunk = getNextChunk( stream, start, ok );
472 if ( !ok ) return false;
473 iteration.SetLogFile( chunk.c_str() );
474 chunk = getNextChunk( stream, start, ok );
475 if ( !ok ) return false;
476 iteration.SetMeshName( chunk.c_str() );
477 chunk = getNextChunk( stream, start, ok );
478 if ( !ok ) return false;
479 iteration.SetFieldFile( chunk.c_str() );
482 chunk = getNextChunk( stream, start, ok );
483 if ( !ok ) return false;
484 timestep = atoi( chunk.c_str() );
485 chunk = getNextChunk( stream, start, ok );
486 if ( !ok ) return false;
487 rank = atoi( chunk.c_str() );
488 iteration.SetTimeStepRank( timestep, rank );
489 chunk = getNextChunk( stream, start, ok );
490 if ( !ok ) return false;
491 iteration.SetIterParentName( chunk.c_str() );
493 chunk = getNextChunk( stream, start, ok );
494 if ( !ok ) return false;
495 int size = atoi( chunk.c_str() );
496 for ( int i = 0; i < size; i++ ) {
497 chunk = getNextChunk( stream, start, ok );
498 if ( !ok ) return false;
499 iteration.LinkNextIteration( chunk.c_str() );
502 chunk = getNextChunk( stream, start, ok );
503 if ( !ok ) return false;
504 iteration.SetHypoName( chunk.c_str() );
505 chunk = getNextChunk( stream, start, ok );
506 if ( !ok ) return false;
507 iteration.SetCaseName( chunk.c_str() );
508 chunk = getNextChunk( stream, start, ok );
509 if ( !ok ) return false;
510 iteration.SetDirNameLoc( chunk.c_str() );
519 \brief Restore hypothesis from the string
520 \param hypothesis hypothesis being restored
521 \param stream string representation of the hypothesis
522 \return \c true if hypothesis is correctly restored or \c false otherwise
524 bool Restore( HOMARD_Hypothesis& hypothesis, const std::string& stream )
526 std::string::size_type start = 0;
527 std::string chunk, chunkNext;
530 chunk = getNextChunk( stream, start, ok );
531 if ( !ok ) return false;
532 hypothesis.SetName( chunk.c_str() );
534 chunk = getNextChunk( stream, start, ok );
535 if ( !ok ) return false;
536 hypothesis.SetCaseCreation( chunk.c_str() );
538 chunk = getNextChunk( stream, start, ok );
539 if ( !ok ) return false;
540 hypothesis.SetAdapType( atoi( chunk.c_str() ) );
542 chunk = getNextChunk( stream, start, ok );
543 if ( !ok ) return false;
544 int typeraff = atoi( chunk.c_str() );
545 chunk = getNextChunk( stream, start, ok );
546 if ( !ok ) return false;
547 int typedera = atoi( chunk.c_str() );
548 hypothesis.SetRefinTypeDera( typeraff, typedera );
550 chunk = getNextChunk( stream, start, ok );
551 if ( !ok ) return false;
552 hypothesis.SetField( chunk.c_str() );
554 chunk = getNextChunk( stream, start, ok );
555 if ( !ok ) return false;
556 int typethr = atoi( chunk.c_str() );
557 chunk = getNextChunk( stream, start, ok );
558 if ( !ok ) return false;
559 double threshr = strtod( chunk.c_str(), 0 );
560 hypothesis.SetRefinThr( typethr, threshr );
562 chunk = getNextChunk( stream, start, ok );
563 if ( !ok ) return false;
564 int typethc = atoi( chunk.c_str() );
565 chunk = getNextChunk( stream, start, ok );
566 if ( !ok ) return false;
567 double threshc = strtod( chunk.c_str(), 0 );
568 hypothesis.SetUnRefThr( typethc, threshc );
570 chunk = getNextChunk( stream, start, ok );
571 if ( !ok ) return false;
572 hypothesis.SetUseField(atoi(chunk.c_str()));
574 chunk = getNextChunk( stream, start, ok );
575 if ( !ok ) return false;
576 hypothesis.SetUseComp(atoi(chunk.c_str()));
578 chunk = getNextChunk( stream, start, ok );
579 if ( !ok ) return false;
580 hypothesis.SetTypeFieldInterp(atoi(chunk.c_str()));
582 chunk = getNextChunk( stream, start, ok );
583 if ( !ok ) return false;
584 int size = atoi( chunk.c_str() );
585 for ( int i = 0; i < size; i++ ) {
586 chunk = getNextChunk( stream, start, ok );
587 if ( !ok ) return false;
588 hypothesis.LinkIteration( chunk.c_str() );
591 chunk = getNextChunk( stream, start, ok );
592 if ( !ok ) return false;
593 size = atoi( chunk.c_str() );
594 for ( int i = 0; i < size; i++ ) {
595 chunk = getNextChunk( stream, start, ok );
596 if ( !ok ) return false;
598 chunkNext = getNextChunk( stream, start, ok );
599 int typeuse = atoi( chunkNext.c_str() );
600 if ( !ok ) return false;
601 hypothesis.AddZone( chunk.c_str(), typeuse );
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.AddComp( 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;
619 hypothesis.AddGroup( chunk.c_str() );
622 chunk = getNextChunk( stream, start, ok );
623 if ( !ok ) return false;
624 size = atoi( chunk.c_str() );
625 for ( int i = 0; i < size; i++ ) {
626 chunk = getNextChunk( stream, start, ok );
627 if ( !ok ) return false;
629 chunkNext = getNextChunk( stream, start, ok );
630 int TypeInterp = atoi( chunkNext.c_str() );
631 if ( !ok ) return false;
632 hypothesis.AddFieldInterpType( chunk.c_str(), TypeInterp );
635 chunk = getNextChunk( stream, start, ok );
636 if ( !ok ) return false;
637 hypothesis.SetNivMax( atoi( chunk.c_str() ) );
639 chunk = getNextChunk( stream, start, ok );
640 if ( !ok ) return false;
641 hypothesis.SetDiamMin( strtod( chunk.c_str(), 0 ) );
643 chunk = getNextChunk( stream, start, ok );
644 if ( !ok ) return false;
645 hypothesis.SetAdapInit( strtod( chunk.c_str(), 0 ) );
647 chunk = getNextChunk( stream, start, ok );
648 if ( !ok ) return false;
649 hypothesis.SetExtraOutput( strtod( chunk.c_str(), 0 ) );
659 \brief Restore zone from the string
660 \param zone zone being restored
661 \param stream string representation of the zone
662 \return \c true if zone is correctly restored or \c false otherwise
664 bool Restore( HOMARD_Zone& zone, const std::string& stream )
666 std::string::size_type start = 0;
670 chunk = getNextChunk( stream, start, ok );
671 if ( !ok ) return false;
672 zone.SetName( chunk.c_str() );
674 chunk = getNextChunk( stream, start, ok );
675 if ( !ok ) return false;
676 int ZoneType = atoi( chunk.c_str() ) ;
677 zone.SetType( ZoneType );
678 // Les coordonnees des zones : le nombre depend du type
679 std::vector<double> coords;
681 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) ) { lgcoords = 6 ; }
682 else if ( ZoneType == 4 ) { lgcoords = 4 ; }
683 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) ) { lgcoords = 8 ; }
684 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) ) { lgcoords = 9 ; }
686 coords.resize( lgcoords );
687 for ( int i = 0; i < lgcoords; i++ ) {
688 chunk = getNextChunk( stream, start, ok );
689 if ( !ok ) return false;
690 coords[i] = strtod( chunk.c_str(), 0 );
692 if ( ZoneType == 2 || ( ZoneType >= 11 && ZoneType <= 13 ) )
693 { zone.SetBox( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] ); }
694 else if ( ZoneType == 4 )
695 { zone.SetSphere( coords[0], coords[1], coords[2], coords[3] ); }
696 else if ( ZoneType == 5 || ( ZoneType >= 31 && ZoneType <= 33 ) )
697 { zone.SetCylinder( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7] ); }
698 else if ( ZoneType == 7 || ( ZoneType >= 61 && ZoneType <= 63 ) )
699 { zone.SetPipe( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7], coords[8] ); }
700 // Remarque : la taille de coords est suffisante pour les limites
701 for ( int i = 0; i < 3; i++ ) {
702 chunk = getNextChunk( stream, start, ok );
703 if ( !ok ) return false;
704 coords[i] = strtod( chunk.c_str(), 0 );
706 zone.SetLimit( coords[0], coords[1], coords[2]);
708 chunk = getNextChunk( stream, start, ok );
709 if ( !ok ) return false;
710 int size = atoi( chunk.c_str() );
711 for ( int i = 0; i < size; i++ ) {
712 chunk = getNextChunk( stream, start, ok );
713 if ( !ok ) return false;
714 zone.AddHypo( chunk.c_str() );
720 // =================================
721 // 2.5. Restauration d'une frontiere
722 // =================================
725 \brief Restore boundary from the string
726 \param boundary boundary being restored
727 \param stream string representation of the boundary
728 \return \c true if the boundary is correctly restored or \c false otherwise
730 bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
732 std::string::size_type start = 0;
736 chunk = getNextChunk( stream, start, ok );
737 if ( !ok ) return false;
738 boundary.SetName( chunk.c_str() );
740 chunk = getNextChunk( stream, start, ok );
741 if ( !ok ) return false;
742 int BoundaryType = atoi( chunk.c_str() ) ;
743 boundary.SetType( BoundaryType );
745 chunk = getNextChunk( stream, start, ok );
746 if ( !ok ) return false;
747 boundary.SetCaseCreation( chunk.c_str() );
749 // Si analytique, les coordonnees des frontieres : le nombre depend du type
750 // Si discret, le maillage
751 // Si CAO, la géométrie
753 if ( BoundaryType == -1 ) { lgcoords = -1 ; }
754 else if ( BoundaryType == 1 ) { lgcoords = 7 ; }
755 else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
756 else { lgcoords = 0 ; }
758 if ( lgcoords == -1 )
760 chunk = getNextChunk( stream, start, ok );
761 if ( !ok ) return false;
762 boundary.SetDataFile( chunk.c_str() );
764 else if ( lgcoords == 0 )
766 chunk = getNextChunk( stream, start, ok );
767 if ( !ok ) return false;
768 boundary.SetMeshName( chunk.c_str() );
770 chunk = getNextChunk( stream, start, ok );
771 if ( !ok ) return false;
772 boundary.SetDataFile( chunk.c_str() );
775 { std::vector<double> coords;
776 coords.resize( lgcoords );
777 for ( int i = 0; i < lgcoords; i++ ) {
778 chunk = getNextChunk( stream, start, ok );
779 if ( !ok ) return false;
780 coords[i] = strtod( chunk.c_str(), 0 );
782 if ( BoundaryType == 1 )
783 { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
784 else if ( BoundaryType == 2 )
785 { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
786 else if ( BoundaryType == 3 )
787 { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
788 else if ( BoundaryType == 4 )
789 { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
790 // Remarque : la taille de coords est suffisante pour les limites
791 for ( int i = 0; i < 3; i++ ) {
792 chunk = getNextChunk( stream, start, ok );
793 if ( !ok ) return false;
794 coords[i] = strtod( chunk.c_str(), 0 );
796 boundary.SetLimit( coords[0], coords[1], coords[2]);
799 chunk = getNextChunk( stream, start, ok );
800 if ( !ok ) return false;
801 int size = atoi( chunk.c_str() );
802 for ( int i = 0; i < size; i++ ) {
803 chunk = getNextChunk( stream, start, ok );
804 if ( !ok ) return false;
805 boundary.AddGroup( chunk.c_str() );
812 // ==================================
813 // 2.6. Restauration d'un schema YACS
814 // ==================================
817 \brief Restore a schema YACS from the string
818 \param yacs yacs being restored
819 \param stream string representation of the schema yacs
820 \return \c true if yacs is correctly restored or \c false otherwise
822 bool Restore( HOMARD_YACS& yacs, const std::string& stream )
824 std::string::size_type start = 0;
828 chunk = getNextChunk( stream, start, ok );
829 if ( !ok ) return false;
830 yacs.SetName( chunk.c_str() );
832 chunk = getNextChunk( stream, start, ok );
833 if ( !ok ) return false;
834 int YACSType = atoi( chunk.c_str() ) ;
835 yacs.SetType( YACSType );
840 } // namespace HOMARD /end/