1 // SMESH HOMARD : implementation of SMESHHOMARD idl descriptions
3 // Copyright (C) 2011-2021 CEA/DEN, EDF R&D
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "SMESH_Homard.hxx"
24 #include <Utils_SALOME_Exception.hxx>
25 #include <utilities.h>
41 #include <MEDCouplingMemArray.hxx>
42 #include <MEDFileMesh.hxx>
44 #include <XAO_Xao.hxx>
45 #include <XAO_BrepGeometry.hxx>
46 #include <XAO_Group.hxx>
55 #include <boost/filesystem.hpp>
57 #include <OSD_Parallel.hxx>
58 #include <BRepAdaptor_Curve.hxx>
59 #include <BRepBndLib.hxx>
60 #include <BRepTopAdaptor_FClass2d.hxx>
61 #include <BRep_Tool.hxx>
62 #include <Bnd_Box.hxx>
64 #include <TopExp_Explorer.hxx>
65 #include <TopTools_IndexedMapOfShape.hxx>
67 #include <TopoDS_Edge.hxx>
68 #include <TopoDS_Face.hxx>
69 #include <TopoDS_Vertex.hxx>
70 #include <TopoDS_Shape.hxx>
73 #include <GCPnts_UniformDeflection.hxx>
74 #include <GeomAdaptor_Curve.hxx>
75 #include <GeomLib_IsPlanarSurface.hxx>
76 #include <ShapeAnalysis_Curve.hxx>
77 #include <ShapeAnalysis_Surface.hxx>
78 #include <gp_Circ.hxx>
79 #include <gp_Cylinder.hxx>
83 #include <gp_Sphere.hxx>
86 namespace boofs = boost::filesystem;
90 namespace SMESHHOMARDImpl
93 std::string SEPARATOR = "|" ;
96 \brief Read next chunk of data from the string
99 The function tries to read next chunk of the data from the input string \a str.
100 The parameter \a start specifies the start position of next chunk. If the operation
101 read the chunk successfully, after its completion this parameter will refer to the
102 start position of the next chunk. The function returns resulting chunk as a string.
103 The status of the operation is returned via \a ok parameter.
105 \param str source data stream string
106 \param start start position to get next chunk
107 \param ok in this variable the status of the chunk reading operation is returned
108 \return next chunk read from the string
110 static std::string getNextChunk( const std::string& str, std::string::size_type& start, bool& ok )
112 std::string chunk = "";
114 if ( start <= str.size() ) {
115 std::string::size_type end = str.find( separator(), start );
116 chunk = str.substr( start, end == std::string::npos ? std::string::npos : end-start );
117 start = end == std::string::npos ? str.size()+1 : end + separator().size();
124 \brief Get persistence signature
125 \param type persistence entity type
126 \return persistence signature
128 std::string GetSignature( SignatureType type )
130 std::string signature = "";
132 case Case: signature = "CASE"; break;
133 case Zone: signature = "ZONE"; break;
134 case Hypothesis: signature = "HYPO"; break;
135 case Iteration: signature = "ITER"; break;
136 case Boundary: signature = "BOUNDARY"; break;
139 signature += separator();
144 \brief Get data separator
145 \return string that is used to separate data entities in the stream
147 std::string separator()
152 // =======================
154 // =======================
156 \brief Dump case to the string
157 \param cas case being dumped
158 \return string representation of the case
160 std::string Dump( const HOMARD_Cas& cas )
162 std::stringstream os;
165 MESSAGE( ". Sauvegarde du cas "<<cas.GetName());
167 os << separator() << cas.GetDirName();
168 os << separator() << cas.GetConfType();
170 std::vector<double> coor = cas.GetBoundingBox();
171 os << separator() << coor.size();
172 for ( unsigned int i = 0; i < coor.size(); i++ )
173 os << separator() << coor[i];
175 std::list<std::string> ListString = cas.GetIterations();
176 os << separator() << ListString.size();
177 std::list<std::string>::const_iterator it;
178 for ( it = ListString.begin(); it != ListString.end(); ++it )
179 os << separator() << *it;
181 ListString = cas.GetGroups();
182 os << separator() << ListString.size();
183 for ( it = ListString.begin(); it != ListString.end(); ++it )
184 os << separator() << *it;
185 ListString = cas.GetBoundaryGroup();
186 os << separator() << ListString.size();
187 for ( it = ListString.begin(); it != ListString.end(); ++it )
188 os << separator() << *it;
190 os << separator() << 0; //cas.GetPyram()
193 // MESSAGE( ". Fin avec "<<saux);
202 \brief Dump iteration to the string
203 \param iteration iteration being dumped
204 \return string representation of the iteration
206 std::string Dump( const HOMARD_Iteration& iteration )
208 std::stringstream os;
211 MESSAGE( ". Sauvegarde de l'iteration "<<iteration.GetName());
212 os << iteration.GetName();
213 os << separator() << iteration.GetState();
214 os << separator() << iteration.GetNumber();
215 os << separator() << iteration.GetMeshFile();
216 os << separator() << iteration.GetLogFile();
217 os << separator() << iteration.GetMeshName();
218 os << separator() << iteration.GetFieldFile();
219 os << separator() << iteration.GetTimeStep();
220 os << separator() << iteration.GetRank();
221 os << separator() << iteration.GetIterParentName();
223 std::list<std::string> ListString = iteration.GetIterations();
224 os << separator() << ListString.size();
225 std::list<std::string>::const_iterator it;
226 for ( it = ListString.begin(); it != ListString.end(); ++it )
227 os << separator() << *it;
229 os << separator() << iteration.GetHypoName();
230 os << separator() << iteration.GetCaseName();
231 os << separator() << iteration.GetDirNameLoc();
234 // MESSAGE( ". Fin avec "<<saux);
242 \brief Dump hypothesis to the string
243 \param hypothesis hypothesis being dumped
244 \return string representation of the hypothesis
246 std::string Dump( const HOMARD_Hypothesis& hypothesis )
248 std::stringstream os;
251 MESSAGE( ". Sauvegarde de l'hypothese "<<hypothesis.GetName());
252 os << hypothesis.GetName();
253 os << separator() << hypothesis.GetCaseCreation();
254 os << separator() << hypothesis.GetAdapType();
255 os << separator() << hypothesis.GetRefinType();
256 os << separator() << hypothesis.GetUnRefType();
257 os << separator() << hypothesis.GetFieldName();
258 os << separator() << hypothesis.GetRefinThrType();
259 os << separator() << hypothesis.GetThreshR();
260 os << separator() << hypothesis.GetUnRefThrType();
261 os << separator() << hypothesis.GetThreshC();
262 os << separator() << hypothesis.GetUseField();
263 os << separator() << hypothesis.GetUseComp();
264 os << separator() << hypothesis.GetTypeFieldInterp();
266 std::list<std::string> ListString = hypothesis.GetIterations();
267 std::list<std::string>::const_iterator it;
268 os << separator() << ListString.size();
269 for ( it = ListString.begin(); it != ListString.end(); ++it )
270 os << separator() << *it;
272 ListString = hypothesis.GetZones();
273 os << separator() << ListString.size();
274 for ( it = ListString.begin(); it != ListString.end(); ++it )
275 os << separator() << *it;
277 ListString = hypothesis.GetComps();
278 os << separator() << ListString.size();
279 for ( it = ListString.begin(); it != ListString.end(); ++it )
280 os << separator() << *it;
282 ListString = hypothesis.GetGroups();
283 os << separator() << ListString.size();
284 for ( it = ListString.begin(); it != ListString.end(); ++it )
285 os << separator() << *it;
287 ListString = hypothesis.GetFieldInterps();
288 os << separator() << ListString.size();
289 for ( it = ListString.begin(); it != ListString.end(); ++it )
290 os << separator() << *it;
292 os << separator() << hypothesis.GetNivMax();
293 os << separator() << hypothesis.GetDiamMin();
294 os << separator() << hypothesis.GetAdapInit();
295 os << separator() << hypothesis.GetExtraOutput();
298 // MESSAGE( ". Fin avec "<<saux);
302 // ==============================
303 // 1.5. Archivage d'une frontiere
304 // ==============================
307 \brief Dump boundary to the string
308 \param boundary boundary being dumped
309 \return string representation of the boundary
311 std::string Dump( const HOMARD_Boundary& boundary )
313 std::stringstream os;
315 MESSAGE( ". Sauvegarde de la frontiere "<<boundary.GetName());
317 int BoundaryType = boundary.GetType() ;
319 os << boundary.GetName() ;
320 os << separator() << BoundaryType ;
321 os << separator() << boundary.GetCaseCreation() ;
323 if ( BoundaryType == -1 )
325 os << separator() << boundary.GetDataFile();
327 else if ( BoundaryType == 0 )
329 os << separator() << boundary.GetMeshName();
330 os << separator() << boundary.GetDataFile();
333 std::vector<double> coor = boundary.GetCoords() ;
334 for ( unsigned int i = 0; i < coor.size(); i++ )
335 os << separator() << coor[i];
336 std::vector<double> limit = boundary.GetLimit();
337 for ( unsigned int i = 0; i < limit.size(); i++ )
338 os << separator() << limit[i];
341 std::list<std::string> ListString = boundary.GetGroups();
342 std::list<std::string>::const_iterator it;
343 os << separator() << ListString.size();
344 for ( it = ListString.begin(); it != ListString.end(); ++it )
345 os << separator() << *it;
348 // 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.SetExtraOutput( strtod( chunk.c_str(), 0 ) );
646 // =================================
647 // 2.5. Restauration d'une frontiere
648 // =================================
651 \brief Restore boundary from the string
652 \param boundary boundary being restored
653 \param stream string representation of the boundary
654 \return \c true if the boundary is correctly restored or \c false otherwise
656 bool Restore( HOMARD_Boundary& boundary, const std::string& stream )
658 std::string::size_type start = 0;
662 chunk = getNextChunk( stream, start, ok );
663 if ( !ok ) return false;
664 boundary.SetName( chunk.c_str() );
666 chunk = getNextChunk( stream, start, ok );
667 if ( !ok ) return false;
668 int BoundaryType = atoi( chunk.c_str() ) ;
669 boundary.SetType( BoundaryType );
671 chunk = getNextChunk( stream, start, ok );
672 if ( !ok ) return false;
673 boundary.SetCaseCreation( chunk.c_str() );
675 // Si analytique, les coordonnees des frontieres : le nombre depend du type
676 // Si discret, le maillage
677 // Si CAO, la géométrie
679 if ( BoundaryType == -1 ) { lgcoords = -1 ; }
680 else if ( BoundaryType == 1 ) { lgcoords = 7 ; }
681 else if ( BoundaryType == 2 ) { lgcoords = 4 ; }
682 else { lgcoords = 0 ; }
684 if ( lgcoords == -1 )
686 chunk = getNextChunk( stream, start, ok );
687 if ( !ok ) return false;
688 boundary.SetDataFile( chunk.c_str() );
690 else if ( lgcoords == 0 )
692 chunk = getNextChunk( stream, start, ok );
693 if ( !ok ) return false;
694 boundary.SetMeshName( chunk.c_str() );
696 chunk = getNextChunk( stream, start, ok );
697 if ( !ok ) return false;
698 boundary.SetDataFile( chunk.c_str() );
701 { std::vector<double> coords;
702 coords.resize( lgcoords );
703 for ( int i = 0; i < lgcoords; i++ ) {
704 chunk = getNextChunk( stream, start, ok );
705 if ( !ok ) return false;
706 coords[i] = strtod( chunk.c_str(), 0 );
708 if ( BoundaryType == 1 )
709 { boundary.SetCylinder(coords[0],coords[1],coords[2],coords[3],coords[4],coords[5],coords[6]); }
710 else if ( BoundaryType == 2 )
711 { boundary.SetSphere( coords[0], coords[1], coords[2], coords[3]); }
712 else if ( BoundaryType == 3 )
713 { boundary.SetConeA( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6]); }
714 else if ( BoundaryType == 4 )
715 { boundary.SetConeR( coords[0], coords[1], coords[2], coords[3], coords[4], coords[5], coords[6], coords[7]); }
716 // Remarque : la taille de coords est suffisante pour les limites
717 for ( int i = 0; i < 3; i++ ) {
718 chunk = getNextChunk( stream, start, ok );
719 if ( !ok ) return false;
720 coords[i] = strtod( chunk.c_str(), 0 );
722 boundary.SetLimit( coords[0], coords[1], coords[2]);
725 chunk = getNextChunk( stream, start, ok );
726 if ( !ok ) return false;
727 int size = atoi( chunk.c_str() );
728 for ( int i = 0; i < size; i++ ) {
729 chunk = getNextChunk( stream, start, ok );
730 if ( !ok ) return false;
731 boundary.AddGroup( chunk.c_str() );
737 //=============================================================================
739 * default constructor:
741 //=============================================================================
742 HOMARD_Boundary::HOMARD_Boundary():
743 _Name( "" ),_Type( 1 ),
744 _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
745 _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
746 _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
747 _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
749 MESSAGE("HOMARD_Boundary");
752 //=============================================================================
753 HOMARD_Boundary::~HOMARD_Boundary()
755 MESSAGE("~HOMARD_Boundary");
757 //=============================================================================
758 //=============================================================================
760 //=============================================================================
761 //=============================================================================
762 void HOMARD_Boundary::SetName( const char* Name )
764 _Name = std::string( Name );
766 //=============================================================================
767 std::string HOMARD_Boundary::GetName() const
771 //=============================================================================
772 std::string HOMARD_Boundary::GetDumpPython() const
774 std::ostringstream aScript;
778 aScript << _Name << " = smeshhomard.CreateBoundaryCAO(\"" << _Name << "\", ";
779 aScript << "\"" << _DataFile << "\")\n";
784 aScript << _Name << " = smeshhomard.CreateBoundaryDi(\"" << _Name << "\", ";
785 aScript << "\"" << _MeshName << "\", ";
786 aScript << "\"" << _DataFile << "\")\n";
791 aScript << _Name << " = smeshhomard.CreateBoundaryCylinder(\"" << _Name << "\", ";
792 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
797 aScript << _Name << " = smeshhomard.CreateBoundarySphere(\"" << _Name << "\", ";
798 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
803 aScript << _Name << " = smeshhomard.CreateBoundaryConeA(\"" << _Name << "\", ";
804 aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
809 aScript << _Name << " = smeshhomard.CreateBoundaryConeR(\"" << _Name << "\", ";
810 aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
815 aScript << _Name << " = smeshhomard.CreateBoundaryTorus(\"" << _Name << "\", ";
816 aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n";
821 return aScript.str();
823 //=============================================================================
824 //=============================================================================
826 //=============================================================================
827 //=============================================================================
828 void HOMARD_Boundary::SetType( int Type )
832 //=============================================================================
833 int HOMARD_Boundary::GetType() const
837 //=============================================================================
838 void HOMARD_Boundary::SetMeshName( const char* MeshName )
840 _MeshName = std::string( MeshName );
842 //=============================================================================
843 std::string HOMARD_Boundary::GetMeshName() const
847 //=============================================================================
848 void HOMARD_Boundary::SetDataFile( const char* DataFile )
850 _DataFile = std::string( DataFile );
852 //=============================================================================
853 std::string HOMARD_Boundary::GetDataFile() const
857 //=======================================================================================
858 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
859 double X3, double X4, double X5, double X6 )
861 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
862 _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
865 //======================================================================
866 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
868 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
871 //======================================================================
872 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
873 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
875 _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
877 _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
880 //======================================================================
881 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
882 double Xcentre, double Ycentre, double Zcentre)
884 _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
886 _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
888 //=======================================================================================
889 void HOMARD_Boundary::SetTorus( double X0, double X1, double X2,
890 double X3, double X4, double X5, double X6, double X7 )
892 _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
893 _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
897 //=======================================================================================
898 std::vector<double> HOMARD_Boundary::GetCoords() const
900 std::vector<double> mesCoor;
907 mesCoor.push_back( _Xcentre );
908 mesCoor.push_back( _Ycentre );
909 mesCoor.push_back( _Zcentre );
910 mesCoor.push_back( _Xaxe );
911 mesCoor.push_back( _Yaxe );
912 mesCoor.push_back( _Zaxe );
913 mesCoor.push_back( _rayon );
919 mesCoor.push_back( _Xcentre );
920 mesCoor.push_back( _Ycentre );
921 mesCoor.push_back( _Zcentre );
922 mesCoor.push_back( _rayon );
925 // Cone defini par un axe et un angle
928 mesCoor.push_back( _Xaxe );
929 mesCoor.push_back( _Yaxe );
930 mesCoor.push_back( _Zaxe );
931 mesCoor.push_back( _Angle );
932 mesCoor.push_back( _Xcentre );
933 mesCoor.push_back( _Ycentre );
934 mesCoor.push_back( _Zcentre );
937 // Cone defini par les 2 rayons
940 mesCoor.push_back( _Xcentre1 );
941 mesCoor.push_back( _Ycentre1 );
942 mesCoor.push_back( _Zcentre1 );
943 mesCoor.push_back( _Rayon1 );
944 mesCoor.push_back( _Xcentre2 );
945 mesCoor.push_back( _Ycentre2 );
946 mesCoor.push_back( _Zcentre2 );
947 mesCoor.push_back( _Rayon2 );
953 mesCoor.push_back( _Xcentre );
954 mesCoor.push_back( _Ycentre );
955 mesCoor.push_back( _Zcentre );
956 mesCoor.push_back( _Xaxe );
957 mesCoor.push_back( _Yaxe );
958 mesCoor.push_back( _Zaxe );
959 mesCoor.push_back( _Rayon1 );
960 mesCoor.push_back( _Rayon2 );
963 VERIFICATION( (_Type>=1) && (_Type<=5) ) ;
967 //======================================================================
968 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
970 _Xincr = X0; _Yincr = X1; _Zincr = X2;
972 //=======================================================================================
973 std::vector<double> HOMARD_Boundary::GetLimit() const
975 std::vector<double> mesLimit;
976 mesLimit.push_back( _Xincr );
977 mesLimit.push_back( _Yincr );
978 mesLimit.push_back( _Zincr );
981 //=============================================================================
982 void HOMARD_Boundary::AddGroup( const char* Group)
984 _ListGroupSelected.push_back(Group);
986 //=============================================================================
987 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
989 _ListGroupSelected.clear();
990 std::list<std::string>::const_iterator it = ListGroup.begin();
991 while(it != ListGroup.end())
992 _ListGroupSelected.push_back((*it++));
994 //=============================================================================
995 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
997 return _ListGroupSelected;
999 //=============================================================================
1000 //=============================================================================
1001 // Liens avec les autres structures
1002 //=============================================================================
1003 //=============================================================================
1004 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
1006 _NomCasCreation = std::string( NomCasCreation );
1008 //=============================================================================
1009 std::string HOMARD_Boundary::GetCaseCreation() const
1011 return _NomCasCreation;
1013 //=============================================================================
1015 //=============================================================================
1017 * default constructor:
1018 * Par defaut, l'adaptation est conforme, sans suivi de frontiere
1020 //=============================================================================
1021 HOMARD_Cas::HOMARD_Cas():
1022 _Name(""), _NomDir("/tmp"), _ConfType(0)
1024 MESSAGE("HOMARD_Cas");
1026 //=============================================================================
1027 HOMARD_Cas::~HOMARD_Cas()
1028 //=============================================================================
1030 MESSAGE("~HOMARD_Cas");
1032 //=============================================================================
1033 //=============================================================================
1035 //=============================================================================
1036 //=============================================================================
1037 void HOMARD_Cas::SetName( const char* Name )
1039 _Name = std::string( Name );
1041 //=============================================================================
1042 std::string HOMARD_Cas::GetName() const
1046 //=============================================================================
1047 std::string HOMARD_Cas::GetDumpPython() const
1049 std::ostringstream aScript;
1050 //aScript << _Name << ".SetDirName(\"" << _NomDir << "\")\n";
1051 aScript << _Name << ".SetConfType(" << _ConfType << ")\n";
1052 // Suivi de frontieres
1053 std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
1054 while (it != _ListBoundaryGroup.end()) {
1055 aScript << _Name << ".AddBoundaryGroup(\"" << *it << "\", \"";
1057 aScript << *it << "\")\n";
1061 return aScript.str();
1063 //=============================================================================
1064 //=============================================================================
1066 //=============================================================================
1067 //=============================================================================
1068 int HOMARD_Cas::SetDirName( const char* NomDir )
1070 // MESSAGE("SetDirName, NomDir : "<<NomDir);
1071 // MESSAGE("SetDirName, _NomDir : "<<_NomDir);
1073 // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
1074 // MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
1075 if ( _ListIter.size() > 1 ) { erreur = 1 ; }
1077 if ( CHDIR(NomDir) == 0 )
1078 { _NomDir = std::string( NomDir ); }
1083 if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
1085 if ( _mkdir(NomDir) == 0 )
1088 if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
1089 else { erreur = 2 ; }
1091 else { erreur = 2 ; }
1095 //=============================================================================
1096 std::string HOMARD_Cas::GetDirName() const
1100 //=============================================================================
1101 int HOMARD_Cas::GetNumberofIter()
1103 return _ListIter.size();
1106 // Le type de conformite ou non conformite
1108 //=============================================================================
1109 void HOMARD_Cas::SetConfType( int Conftype )
1111 // VERIFICATION( (Conftype>=-2) && (Conftype<=3) );
1112 _ConfType = Conftype;
1114 //=============================================================================
1115 const int HOMARD_Cas::GetConfType() const
1120 // La boite englobante
1122 //=============================================================================
1123 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
1126 _Boite.resize( extremas.size() );
1127 for ( unsigned int i = 0; i < extremas.size(); i++ )
1128 _Boite[i] = extremas[i];
1130 //=============================================================================
1131 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
1138 //=============================================================================
1139 void HOMARD_Cas::AddGroup( const char* Group )
1141 _ListGroup.push_back(Group);
1143 //=============================================================================
1144 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
1147 std::list<std::string>::const_iterator it = ListGroup.begin();
1148 while(it != ListGroup.end())
1150 _ListGroup.push_back((*it++));
1153 //=============================================================================
1154 const std::list<std::string>& HOMARD_Cas::GetGroups() const
1158 //=============================================================================
1159 void HOMARD_Cas::SupprGroups()
1166 //=============================================================================
1167 void HOMARD_Cas::AddBoundary( const char* Boundary )
1169 // MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
1170 const char* Group = "";
1171 AddBoundaryGroup( Boundary, Group );
1173 //=============================================================================
1174 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
1176 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
1177 // MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
1178 _ListBoundaryGroup.push_back( Boundary );
1179 _ListBoundaryGroup.push_back( Group );
1181 //=============================================================================
1182 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
1184 return _ListBoundaryGroup;
1186 //=============================================================================
1187 void HOMARD_Cas::SupprBoundaryGroup()
1189 _ListBoundaryGroup.clear();
1191 //=============================================================================
1192 //=============================================================================
1193 // Liens avec les autres structures
1194 //=============================================================================
1195 //=============================================================================
1196 std::string HOMARD_Cas::GetIter0Name() const
1198 // Par construction de la liste, l'iteration a ete mise en tete.
1199 return (*(_ListIter.begin()));
1201 //=============================================================================
1202 void HOMARD_Cas::AddIteration( const char* NomIteration )
1204 _ListIter.push_back( std::string( NomIteration ) );
1206 //=============================================================================
1207 const std::list<std::string>& HOMARD_Cas::GetIterations() const
1211 //=============================================================================
1212 void HOMARD_Cas::SupprIterations()
1217 //=============================================================================
1218 //=============================================================================
1219 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
1220 _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
1221 _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
1222 _Texte( "" ), _bLu( false )
1224 MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
1225 // Le repertoire ou se trouve l'executable HOMARD
1228 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
1229 dir += "/bin/salome";
1230 MESSAGE("dir ="<<dir);
1231 // L'executable HOMARD
1232 std::string executable = "homard";
1233 MESSAGE("executable ="<<executable);
1234 // Memorisation du nom complet de l'executable HOMARD
1235 _HOMARD_Exec = dir + "/" + executable ;
1236 MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
1239 _siterp1 = siterp1 ;
1241 //=============================================================================
1242 //=============================================================================
1243 HomardDriver::~HomardDriver()
1246 //===============================================================================
1248 //===============================================================================
1249 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
1251 MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
1253 _Texte = "ListeStd \"" + LogFile + "\"\n" ;
1254 _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
1255 _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
1256 _Texte += "Langue \"" + Langue + "\"\n" ;
1259 //===============================================================================
1260 void HomardDriver::TexteAdap()
1262 MESSAGE("TexteAdap");
1264 _Texte += "Action homa\n";
1265 _Texte += "CCAssoci med\n";
1266 _Texte += "ModeHOMA 1\n";
1267 _Texte += "NumeIter " + _siter + "\n";
1270 //===============================================================================
1271 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
1273 MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
1275 _Texte += "ModeHOMA 2\n" ;
1276 std::stringstream saux1 ;
1278 std::string saux2 = saux1.str() ;
1279 _Texte += "TypeBila " + saux2 + "\n" ;
1280 if ( NumeIter == 0 )
1282 _Texte += "NumeIter 0\n" ;
1283 _Texte += "Action info_av\n" ;
1284 _Texte += "CCAssoci med\n" ;
1288 _Texte += "NumeIter " + _siter + "\n" ;
1289 _Texte += "Action info_ap\n" ;
1290 _Texte += "CCAssoci homard\n" ;
1295 //===============================================================================
1296 void HomardDriver::TexteMajCoords( int NumeIter )
1298 MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
1300 _Texte += "ModeHOMA 5\n" ;
1301 _Texte += "NumeIter " + _siterp1 + "\n" ;
1302 _Texte += "Action homa\n" ;
1303 _Texte += "CCAssoci med\n" ;
1304 _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
1308 //===============================================================================
1309 // B. Les maillages en entree et en sortie
1310 //===============================================================================
1311 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
1313 MESSAGE("TexteMaillage, NomMesh = "<<NomMesh);
1314 MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
1315 MESSAGE("TexteMaillage, apres = "<<apres);
1318 if ( apres < 1 ) { saux = "__" ; }
1320 _Texte += "# Maillages Med " + saux + "\n" ;
1321 _Texte += "CCNoMN" + saux + " \"" + NomMesh + "\"\n" ;
1322 _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
1325 //===============================================================================
1326 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
1328 MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
1330 if ( apres < 1 ) { saux = "__" ; }
1331 else { saux = "P1" ; }
1333 _Texte += "# Maillage HOMARD " + liter + "\n" ;
1334 _Texte += "HOMaiN" + saux + " Mai" + liter + " \"" + Dir + "/maill." + liter + ".hom.med\"\n" ;
1337 //===============================================================================
1338 // C. Le pilotage de l'adaptation
1339 //===============================================================================
1340 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
1342 MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
1343 MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
1345 // Type de conformite
1352 saux = "NON_CONFORME_1_ARETE" ;
1357 saux = "CONFORME_BOITES" ;
1367 saux = "NON_CONFORME" ;
1372 saux = "NON_CONFORME_1_NOEUD" ;
1377 saux = "NON_CONFORME_INDICATEUR" ;
1381 _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
1383 // Type de raffinement/deraffinement
1385 if ( TypeAdap == -1 )
1387 if ( TypeRaff == 1 )
1389 saux = "TypeRaff uniforme\n" ;
1393 saux = "TypeRaff non\n" ;
1395 if ( TypeDera == 1 )
1397 saux += "TypeDera uniforme" ;
1401 saux += "TypeDera non" ;
1406 if ( TypeRaff == 1 )
1408 saux = "TypeRaff libre\n" ;
1412 saux = "TypeRaff non\n" ;
1414 if ( TypeDera == 1 )
1416 saux += "TypeDera libre" ;
1420 saux += "TypeDera non" ;
1423 _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
1425 // MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
1427 //===============================================================================
1428 void HomardDriver::TexteCompo( int NumeComp, const std::string NomCompo)
1430 MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NomCompo = "<<NomCompo);
1431 _Texte +="CCCoChaI \"" + NomCompo + "\"\n" ;
1433 //===============================================================================
1434 void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8 )
1436 MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
1437 MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
1439 std::string saux, saux2 ;
1442 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
1443 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
1444 // Attention a mettre le bon signe a ZoneTypeHOMARD :
1445 // >0 signifie que l'on raffinera les mailles contenues dans la zone,
1446 // <0 signifie que l'on deraffinera
1448 int ZoneTypeHOMARD ;
1449 if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
1450 else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
1451 else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
1452 else { ZoneTypeHOMARD = ZoneType ; }
1454 if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
1456 std::stringstream saux1 ;
1458 saux = "#\n# Zone numero " + saux1.str() + "\n" ;
1460 { std::stringstream saux1 ;
1461 saux1 << NumeZone << " " << ZoneTypeHOMARD ;
1462 saux += "ZoRaType " + saux1.str() + "\n" ;
1467 if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
1468 // Y Homard <=> Y Salome
1470 saux += "#Rectangle\n" ;
1471 { std::stringstream saux1 ;
1472 saux1 << NumeZone << " " << x0 ;
1473 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1475 { std::stringstream saux1 ;
1476 saux1 << NumeZone << " " << x1 ;
1477 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1479 { std::stringstream saux1 ;
1480 saux1 << NumeZone << " " << x2 ;
1481 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1483 { std::stringstream saux1 ;
1484 saux1 << NumeZone << " " << x3 ;
1485 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1489 else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
1490 // Y Homard <=> Z Salome
1492 saux += "#Rectangle\n" ;
1493 { std::stringstream saux1 ;
1494 saux1 << NumeZone << " " << x2 ;
1495 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1497 { std::stringstream saux1 ;
1498 saux1 << NumeZone << " " << x3 ;
1499 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1501 { std::stringstream saux1 ;
1502 saux1 << NumeZone << " " << x4 ;
1503 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1505 { std::stringstream saux1 ;
1506 saux1 << NumeZone << " " << x5 ;
1507 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1511 else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
1512 // Y Homard <=> Z Salome
1514 saux += "#Rectangle\n" ;
1515 { std::stringstream saux1 ;
1516 saux1 << NumeZone << " " << x0 ;
1517 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1519 { std::stringstream saux1 ;
1520 saux1 << NumeZone << " " << x1 ;
1521 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1523 { std::stringstream saux1 ;
1524 saux1 << NumeZone << " " << x4 ;
1525 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1527 { std::stringstream saux1 ;
1528 saux1 << NumeZone << " " << x5 ;
1529 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1533 // Cas du parallelepipede
1535 else if ( ZoneType == 2 )
1537 saux += "# Boite\n" ;
1538 { std::stringstream saux1 ;
1539 saux1 << NumeZone << " " << x0 ;
1540 saux += "ZoRaXmin " + saux1.str() + "\n" ;
1542 { std::stringstream saux1 ;
1543 saux1 << NumeZone << " " << x1 ;
1544 saux += "ZoRaXmax " + saux1.str() + "\n" ;
1546 { std::stringstream saux1 ;
1547 saux1 << NumeZone << " " << x2 ;
1548 saux += "ZoRaYmin " + saux1.str() + "\n" ;
1550 { std::stringstream saux1 ;
1551 saux1 << NumeZone << " " << x3 ;
1552 saux += "ZoRaYmax " + saux1.str() + "\n" ;
1554 { std::stringstream saux1 ;
1555 saux1 << NumeZone << " " << x4 ;
1556 saux += "ZoRaZmin " + saux1.str() + "\n" ;
1558 { std::stringstream saux1 ;
1559 saux1 << NumeZone << " " << x5 ;
1560 saux += "ZoRaZmax " + saux1.str() + "\n" ;
1566 else if ( ZoneType == 31 || ZoneType == 61 )
1568 saux += "# Sphere\n" ;
1569 { std::stringstream saux1 ;
1570 saux1 << NumeZone << " " << x0 ;
1571 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1573 { std::stringstream saux1 ;
1574 saux1 << NumeZone << " " << x1 ;
1575 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1577 { std::stringstream saux1 ;
1578 saux1 << NumeZone << " " << x6 ;
1579 saux2 = saux1.str() ;
1580 if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1581 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1583 if ( ZoneType == 61 )
1584 { std::stringstream saux1 ;
1585 saux1 << NumeZone << " " << x8 ;
1586 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1589 else if ( ZoneType == 32 || ZoneType == 62 )
1591 saux += "# Sphere\n" ;
1592 { std::stringstream saux1 ;
1593 saux1 << NumeZone << " " << x1 ;
1594 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1596 { std::stringstream saux1 ;
1597 saux1 << NumeZone << " " << x2 ;
1598 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1600 { std::stringstream saux1 ;
1601 saux1 << NumeZone << " " << x6 ;
1602 saux2 = saux1.str() ;
1603 if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1604 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1606 if ( ZoneType == 62 )
1607 { std::stringstream saux1 ;
1608 saux1 << NumeZone << " " << x8 ;
1609 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1612 else if ( ZoneType == 33 || ZoneType == 63 )
1614 saux += "# Sphere\n" ;
1615 { std::stringstream saux1 ;
1616 saux1 << NumeZone << " " << x0 ;
1617 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1619 { std::stringstream saux1 ;
1620 saux1 << NumeZone << " " << x2 ;
1621 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1623 { std::stringstream saux1 ;
1624 saux1 << NumeZone << " " << x6 ;
1625 saux2 = saux1.str() ;
1626 if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
1627 else { saux += "ZoRaRayo " + saux2 + "\n" ; }
1629 if ( ZoneType == 63 )
1630 { std::stringstream saux1 ;
1631 saux1 << NumeZone << " " << x8 ;
1632 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1638 else if ( ZoneType == 4 )
1640 saux += "# Sphere\n" ;
1641 { std::stringstream saux1 ;
1642 saux1 << NumeZone << " " << x0 ;
1643 saux += "ZoRaXCen " + saux1.str() + "\n" ;
1645 { std::stringstream saux1 ;
1646 saux1 << NumeZone << " " << x1 ;
1647 saux += "ZoRaYCen " + saux1.str() + "\n" ;
1649 { std::stringstream saux1 ;
1650 saux1 << NumeZone << " " << x2 ;
1651 saux += "ZoRaZCen " + saux1.str() + "\n" ;
1653 { std::stringstream saux1 ;
1654 saux1 << NumeZone << " " << x3 ;
1655 saux += "ZoRaRayo " + saux1.str() + "\n" ;
1659 // Cas du cylindre ou du tuyau
1661 else if ( ZoneType == 5 || ZoneType == 7 )
1663 if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
1664 else { saux += "# Tuyau\n" ; }
1665 { std::stringstream saux1 ;
1666 saux1 << NumeZone << " " << x0 ;
1667 saux += "ZoRaXBas " + saux1.str() + "\n" ;
1669 { std::stringstream saux1 ;
1670 saux1 << NumeZone << " " << x1 ;
1671 saux += "ZoRaYBas " + saux1.str() + "\n" ;
1673 { std::stringstream saux1 ;
1674 saux1 << NumeZone << " " << x2 ;
1675 saux += "ZoRaZBas " + saux1.str() + "\n" ;
1677 { std::stringstream saux1 ;
1678 saux1 << NumeZone << " " << x3 ;
1679 saux += "ZoRaXAxe " + saux1.str() + "\n" ;
1681 { std::stringstream saux1 ;
1682 saux1 << NumeZone << " " << x4 ;
1683 saux += "ZoRaYAxe " + saux1.str() + "\n" ;
1685 { std::stringstream saux1 ;
1686 saux1 << NumeZone << " " << x5 ;
1687 saux += "ZoRaZAxe " + saux1.str() + "\n" ;
1689 { std::stringstream saux1 ;
1690 saux1 << NumeZone << " " << x6 ;
1691 saux2 = saux1.str() ;
1692 if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
1693 else { saux += "ZoRaRayE " + saux2 + "\n" ; }
1695 { std::stringstream saux1 ;
1696 saux1 << NumeZone << " " << x7 ;
1697 saux += "ZoRaHaut " + saux1.str() + "\n" ;
1699 if ( ZoneType == 7 )
1700 { std::stringstream saux1 ;
1701 saux1 << NumeZone << " " << x8 ;
1702 saux += "ZoRaRayI " + saux1.str() + "\n" ;
1706 _Texte += saux + "#\n" ;
1708 // MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
1710 //===============================================================================
1711 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
1712 int TypeThR, double ThreshR, int TypeThC, double ThreshC,
1713 int UsField, int UsCmpI )
1715 MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
1716 MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
1718 std::string saux, saux2 ;
1721 _Texte += "# Champ d'indicateurs\n" ;
1722 _Texte += "CCIndica \"" + FieldFile + "\"\n" ;
1723 _Texte += "CCNoChaI \"" + FieldName + "\"\n" ;
1725 // Cas ou on prend le dernier pas de temps
1726 if ( TimeStep == -2 )
1727 { _Texte += "CCNumPTI Last\n" ; }
1728 // Cas avec pas de temps
1729 else if ( TimeStep >= 0 )
1732 std::stringstream saux1 ;
1734 saux2 = saux1.str() ;
1735 _Texte += "CCNumPTI " + saux2 + "\n" ;
1739 std::stringstream saux1 ;
1741 saux2 = saux1.str() ;
1742 _Texte += "CCNumOrI " + saux2 + "\n" ;
1757 std::stringstream saux1 ;
1759 _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ;
1773 std::stringstream saux1 ;
1775 _Texte += "Seuil" + saux + " " + saux1.str() + "\n" ;
1780 { saux = "MAILLE" ; }
1785 _Texte += "CCModeFI " + saux + "\n" ;
1792 { saux = "INFINI" ; }
1794 { saux = "RELATIF" ; }
1797 _Texte += "CCUsCmpI " + saux + "\n" ;
1800 //===============================================================================
1801 void HomardDriver::TexteGroup( const std::string GroupName )
1803 MESSAGE("TexteGroup, GroupName = "<<GroupName);
1805 _Texte += "CCGroAda \"" + GroupName + "\"\n" ;
1808 //===============================================================================
1809 // D. Les frontieres
1810 //===============================================================================
1811 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
1813 MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
1815 // Type de suivi de frontiere
1817 std::stringstream saux1 ;
1818 saux1 << BoundaryOption ;
1819 std::string saux = saux1.str() ;
1820 _Texte += "SuivFron " + saux + "\n" ;
1822 }//===============================================================================
1823 void HomardDriver::TexteBoundaryCAOGr( const std::string GroupName )
1825 MESSAGE("TexteBoundaryCAOGr, GroupName = "<<GroupName);
1827 _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
1831 //===============================================================================
1832 void HomardDriver::TexteBoundaryDi( const std::string MeshName, const std::string MeshFile )
1834 MESSAGE("TexteBoundaryDi, MeshName = "<<MeshName);
1835 MESSAGE("TexteBoundaryDi, MeshFile = "<<MeshFile);
1837 _Texte += "#\n# Frontiere discrete\n" ;
1838 _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
1839 _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
1842 //===============================================================================
1843 void HomardDriver::TexteBoundaryDiGr( const std::string GroupName )
1845 MESSAGE("TexteBoundaryDiGr, GroupName = "<<GroupName);
1847 _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
1850 //===============================================================================
1851 void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7 )
1853 MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
1854 // MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
1855 MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
1856 // MESSAGE("TexteBoundaryAn, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
1858 std::string saux, saux2 ;
1862 std::stringstream saux1 ;
1863 saux1 << NumeBoundary ;
1864 saux2 = saux1.str() ;
1865 saux = "#\n# Frontiere numero " + saux2 + "\n" ;
1866 if ( BoundaryType == 1 )
1867 { saux += "# Cylindre\n" ; }
1868 if ( BoundaryType == 2 )
1869 { saux += "# Sphere\n" ; }
1870 if ( BoundaryType == 3 || BoundaryType == 4 )
1871 { saux += "# Cone\n" ; }
1872 if ( BoundaryType == 5 )
1873 { saux += "# Tore\n" ; }
1875 // Le nom de la frontiere
1877 { std::stringstream saux1 ;
1878 saux1 << NumeBoundary ;
1879 saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
1882 // Type de frontiere
1884 { std::stringstream saux1 ;
1885 saux1 << NumeBoundary << " " << BoundaryType ;
1886 saux += "FAType " + saux1.str() + "\n" ;
1891 if ( BoundaryType == 1 )
1893 { std::stringstream saux1 ;
1894 saux1 << NumeBoundary << " " << x0 ;
1895 saux2 = saux1.str() ;
1896 saux += "FAXCen " + saux1.str() + "\n" ;
1898 { std::stringstream saux1 ;
1899 saux1 << NumeBoundary << " " << x1 ;
1900 saux += "FAYCen " + saux1.str() + "\n" ;
1902 { std::stringstream saux1 ;
1903 saux1 << NumeBoundary << " " << x2 ;
1904 saux += "FAZCen " + saux1.str() + "\n" ;
1906 { std::stringstream saux1 ;
1907 saux1 << NumeBoundary << " " << x3 ;
1908 saux += "FAXAxe " + saux1.str() + "\n" ;
1910 { std::stringstream saux1 ;
1911 saux1 << NumeBoundary << " " << x4 ;
1912 saux += "FAYAxe " + saux1.str() + "\n" ;
1914 { std::stringstream saux1 ;
1915 saux1 << NumeBoundary << " " << x5 ;
1916 saux += "FAZAxe " + saux1.str() + "\n" ;
1918 { std::stringstream saux1 ;
1919 saux1 << NumeBoundary << " " << x6 ;
1920 saux += "FARayon " + saux1.str() + "\n" ;
1926 else if ( BoundaryType == 2 )
1928 { std::stringstream saux1 ;
1929 saux1 << NumeBoundary << " " << x0 ;
1930 saux += "FAXCen " + saux1.str() + "\n" ;
1932 { std::stringstream saux1 ;
1933 saux1 << NumeBoundary << " " << x1 ;
1934 saux += "FAYCen " + saux1.str() + "\n" ;
1936 { std::stringstream saux1 ;
1937 saux1 << NumeBoundary << " " << x2 ;
1938 saux += "FAZCen " + saux1.str() + "\n" ;
1940 { std::stringstream saux1 ;
1941 saux1 << NumeBoundary << " " << x3 ;
1942 saux += "FARayon " + saux1.str() + "\n" ;
1946 // Cas du cone defini par un axe et un angle
1948 if ( BoundaryType == 3 )
1950 { std::stringstream saux1 ;
1951 saux1 << NumeBoundary << " " << x0 ;
1952 saux += "FAXAxe " + saux1.str() + "\n" ;
1954 { std::stringstream saux1 ;
1955 saux1 << NumeBoundary << " " << x1 ;
1956 saux += "FAYAxe " + saux1.str() + "\n" ;
1958 { std::stringstream saux1 ;
1959 saux1 << NumeBoundary << " " << x2 ;
1960 saux += "FAZAxe " + saux1.str() + "\n" ;
1962 { std::stringstream saux1 ;
1963 saux1 << NumeBoundary << " " << x3 ;
1964 saux += "FAAngle " + saux1.str() + "\n" ;
1966 { std::stringstream saux1 ;
1967 saux1 << NumeBoundary << " " << x4 ;
1968 saux += "FAXCen " + saux1.str() + "\n" ;
1970 { std::stringstream saux1 ;
1971 saux1 << NumeBoundary << " " << x5 ;
1972 saux += "FAYCen " + saux1.str() + "\n" ;
1974 { std::stringstream saux1 ;
1975 saux1 << NumeBoundary << " " << x6 ;
1976 saux += "FAZCen " + saux1.str() + "\n" ;
1980 // Cas du cone defini par les 2 rayons
1982 if ( BoundaryType == 4 )
1984 { std::stringstream saux1 ;
1985 saux1 << NumeBoundary << " " << x0 ;
1986 saux += "FAXCen " + saux1.str() + "\n" ;
1988 { std::stringstream saux1 ;
1989 saux1 << NumeBoundary << " " << x1 ;
1990 saux += "FAYCen " + saux1.str() + "\n" ;
1992 { std::stringstream saux1 ;
1993 saux1 << NumeBoundary << " " << x2 ;
1994 saux += "FAZCen " + saux1.str() + "\n" ;
1996 { std::stringstream saux1 ;
1997 saux1 << NumeBoundary << " " << x3 ;
1998 saux += "FARayon " + saux1.str() + "\n" ;
2000 { std::stringstream saux1 ;
2001 saux1 << NumeBoundary << " " << x4 ;
2002 saux += "FAXCen2 " + saux1.str() + "\n" ;
2004 { std::stringstream saux1 ;
2005 saux1 << NumeBoundary << " " << x5 ;
2006 saux += "FAYCen2 " + saux1.str() + "\n" ;
2008 { std::stringstream saux1 ;
2009 saux1 << NumeBoundary << " " << x6 ;
2010 saux += "FAZCen2 " + saux1.str() + "\n" ;
2012 { std::stringstream saux1 ;
2013 saux1 << NumeBoundary << " " << x7 ;
2014 saux += "FARayon2 " + saux1.str() + "\n" ;
2020 if ( BoundaryType == 5 )
2022 { std::stringstream saux1 ;
2023 saux1 << NumeBoundary << " " << x0 ;
2024 saux2 = saux1.str() ;
2025 saux += "FAXCen " + saux1.str() + "\n" ;
2027 { std::stringstream saux1 ;
2028 saux1 << NumeBoundary << " " << x1 ;
2029 saux += "FAYCen " + saux1.str() + "\n" ;
2031 { std::stringstream saux1 ;
2032 saux1 << NumeBoundary << " " << x2 ;
2033 saux += "FAZCen " + saux1.str() + "\n" ;
2035 { std::stringstream saux1 ;
2036 saux1 << NumeBoundary << " " << x3 ;
2037 saux += "FAXAxe " + saux1.str() + "\n" ;
2039 { std::stringstream saux1 ;
2040 saux1 << NumeBoundary << " " << x4 ;
2041 saux += "FAYAxe " + saux1.str() + "\n" ;
2043 { std::stringstream saux1 ;
2044 saux1 << NumeBoundary << " " << x5 ;
2045 saux += "FAZAxe " + saux1.str() + "\n" ;
2047 { std::stringstream saux1 ;
2048 saux1 << NumeBoundary << " " << x6 ;
2049 saux += "FARayon " + saux1.str() + "\n" ;
2051 { std::stringstream saux1 ;
2052 saux1 << NumeBoundary << " " << x7 ;
2053 saux += "FARayon2 " + saux1.str() + "\n" ;
2057 _Texte += saux + "#\n" ;
2060 //===============================================================================
2061 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
2063 MESSAGE("TexteBoundaryAnGr, NameBoundary = "<<NameBoundary);
2064 // MESSAGE("TexteBoundaryAnGr, NumeBoundary = "<<NumeBoundary);
2065 // MESSAGE("TexteBoundaryAnGr, GroupName = "<<GroupName);
2069 std::string saux, saux2 ;
2070 std::stringstream saux1 ;
2071 saux1 << NumeBoundary ;
2072 saux2 = saux1.str() ;
2073 saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
2075 saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
2076 saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
2078 _Texte += saux + "#\n" ;
2081 //===============================================================================
2082 // E. Les interpolations
2083 //===============================================================================
2084 // Les fichiers d'entree et de sortie des champs a interpoler
2085 void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
2087 MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
2089 _Texte += "#\n# Interpolations des champs\n" ;
2091 // Fichier en entree
2092 _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
2093 // Fichier en sortie
2094 _Texte += "CCSolNP1 \"" + MeshFile + "\"\n" ;
2096 // std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
2098 //===============================================================================
2099 // Tous les champs sont a interpoler
2100 void HomardDriver::TexteFieldInterpAll( )
2102 MESSAGE("TexteFieldInterpAll");
2104 _Texte += "CCChaTou oui\n" ;
2106 //===============================================================================
2107 // Ecrit les caracteristiques de chaque interpolation sous la forme :
2108 // CCChaNom 1 "DEPL" ! Nom du 1er champ a interpoler
2109 // CCChaTIn 1 0 ! Mode d'interpolation : automatique
2110 // CCChaNom 2 "VOLUME" ! Nom du 2nd champ a interpoler
2111 // CCChaTIn 2 1 ! Mode d'interpolation : une variable extensive
2112 // CCChaPdT 2 14 ! Pas de temps 14
2113 // CCChaNuO 2 14 ! Numero d'ordre 14
2116 // NumeChamp : numero d'ordre du champ a interpoler
2117 // FieldName : nom du champ
2118 // TypeInterp : type d'interpolation
2119 // TimeStep : pas de temps retenu (>0 si pas de precision)
2120 // Rank : numero d'ordre retenu
2122 void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
2124 MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
2125 MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
2126 // Numero d'ordre du champ a interpoler
2127 std::stringstream saux1 ;
2128 saux1 << NumeChamp ;
2129 std::string saux = saux1.str() ;
2131 _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
2132 // Type d'interpolation pour le champ
2133 _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
2135 if ( TimeStep >= 0 )
2138 std::stringstream saux1 ;
2140 _Texte += "CCChaPdT " + saux + " " + saux1.str() + "\n" ;
2143 std::stringstream saux1 ;
2145 _Texte += "CCChaNuO " + saux + " " + saux1.str() + "\n" ;
2149 //===============================================================================
2150 // F. Les options avancees
2151 //===============================================================================
2152 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
2154 MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
2158 _Texte += "# Niveaux extremes\n" ;
2159 { std::stringstream saux1 ;
2161 _Texte += "NiveauMa " + saux1.str() + "\n" ;
2166 _Texte += "# Diametre minimal\n" ;
2167 { std::stringstream saux1 ;
2169 _Texte += "DiametMi " + saux1.str() + "\n" ;
2172 if ( AdapInit != 0 )
2175 { _Texte += "# Raffinement" ; }
2177 { _Texte += "# Deraffinement" ; }
2178 _Texte += " des regions sans indicateur\n" ;
2179 { std::stringstream saux1 ;
2181 _Texte += "AdapInit " + saux1.str() + "\n" ;
2184 if ( ExtraOutput % 2 == 0 )
2186 _Texte += "# Sortie des niveaux de raffinement\n" ;
2187 _Texte += "NCNiveau NIVEAU\n" ;
2189 if ( ExtraOutput % 3 == 0 )
2191 _Texte += "# Sortie des qualités des mailles\n" ;
2192 _Texte += "NCQualit QUAL\n" ;
2194 if ( ExtraOutput % 5 == 0 )
2196 _Texte += "# Sortie des diamètres des mailles\n" ;
2197 _Texte += "NCDiamet DIAM\n" ;
2199 if ( ExtraOutput % 7 == 0 )
2201 _Texte += "# Sortie des parents des mailles\n" ;
2202 _Texte += "NCParent PARENT\n" ;
2204 if ( ExtraOutput % 11 == 0 )
2206 _Texte += "# Volumes voisins par recollement\n" ;
2207 _Texte += "NCVoisRc Voisin-Recollement\n" ;
2210 //===============================================================================
2212 //===============================================================================
2213 void HomardDriver::TexteInfoCompute( int MessInfo )
2215 MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
2217 if ( MessInfo != 0 )
2219 _Texte += "# Messages d'informations\n" ;
2220 { std::stringstream saux1 ;
2222 _Texte += "MessInfo " + saux1.str() + "\n" ;
2226 //===============================================================================
2227 void HomardDriver::CreeFichier( )
2230 if ( _modeHOMARD == 1 )
2231 { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
2232 else if ( _modeHOMARD == 2 )
2233 { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
2234 else if ( _modeHOMARD == 5 )
2235 { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
2237 std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
2238 if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
2242 //===============================================================================
2243 // Creation du fichier de donnees pour l'information
2244 //===============================================================================
2245 void HomardDriver::CreeFichierDonn( )
2248 MESSAGE("CreeFichierDonn");
2249 _NomFichierDonn = "info.donn" ;
2255 std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
2256 if (Fic.is_open() == true) { Fic << data << std::endl ; }
2260 //===============================================================================
2261 int HomardDriver::ExecuteHomard()
2263 MESSAGE("ExecuteHomard");
2264 std::string commande ;
2266 // Copie des Fichiers HOMARD
2267 commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
2268 codret = system(commande.c_str()) ;
2270 // Execution de HOMARD
2273 commande = _HOMARD_Exec.c_str() ;
2274 if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
2275 codret = system(commande.c_str());
2276 if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
2277 _NomFichierDonn = "" ;
2282 //=============================================================================
2283 //=============================================================================
2284 HOMARD_Gen::HOMARD_Gen()
2286 MESSAGE("HOMARD_Gen");
2289 //=============================================================================
2290 //=============================================================================
2291 HOMARD_Gen::~HOMARD_Gen()
2293 MESSAGE("~HOMARD_Gen");
2295 //=============================================================================
2297 //=============================================================================
2299 * default constructor:
2301 //=============================================================================
2302 HOMARD_Hypothesis::HOMARD_Hypothesis():
2303 _Name(""), _NomCasCreation(""),
2304 _TypeAdap(-1), _TypeRaff(0), _TypeDera(0),
2306 _TypeThR(0), _TypeThC(0),
2307 _ThreshR(0), _ThreshC(0),
2308 _UsField(0), _UsCmpI(0), _TypeFieldInterp(0),
2310 _NivMax(-1), _DiamMin(-1.0), _AdapInit(0), _ExtraOutput(1)
2312 MESSAGE("HOMARD_Hypothesis");
2315 //=============================================================================
2318 //=============================================================================
2319 HOMARD_Hypothesis::~HOMARD_Hypothesis()
2321 MESSAGE("~HOMARD_Hypothesis");
2323 //=============================================================================
2324 //=============================================================================
2326 //=============================================================================
2327 //=============================================================================
2328 void HOMARD_Hypothesis::SetName( const char* Name )
2330 _Name = std::string( Name );
2332 //=============================================================================
2333 std::string HOMARD_Hypothesis::GetName() const
2337 //=============================================================================
2338 //=============================================================================
2340 //=============================================================================
2341 //=============================================================================
2342 void HOMARD_Hypothesis::SetAdapType( int TypeAdap )
2344 VERIFICATION( (TypeAdap>=-1) && (TypeAdap<=1) );
2345 _TypeAdap = TypeAdap;
2347 //=============================================================================
2348 int HOMARD_Hypothesis::GetAdapType() const
2352 //=============================================================================
2353 void HOMARD_Hypothesis::SetRefinTypeDera( int TypeRaff, int TypeDera )
2355 VERIFICATION( (TypeRaff>=-1) && (TypeRaff<=1) );
2356 _TypeRaff = TypeRaff;
2357 VERIFICATION( (TypeDera>=-1) && (TypeDera<=1) );
2358 _TypeDera = TypeDera;
2360 //=============================================================================
2361 int HOMARD_Hypothesis::GetRefinType() const
2365 //=============================================================================
2366 int HOMARD_Hypothesis::GetUnRefType() const
2370 //=============================================================================
2371 void HOMARD_Hypothesis::SetField( const char* FieldName )
2373 _Field = std::string( FieldName );
2374 MESSAGE( "SetField : FieldName = " << FieldName );
2376 //=============================================================================
2377 std::string HOMARD_Hypothesis::GetFieldName() const
2381 //=============================================================================
2382 void HOMARD_Hypothesis::SetUseField( int UsField )
2384 VERIFICATION( (UsField>=0) && (UsField<=1) );
2387 //=============================================================================
2388 int HOMARD_Hypothesis::GetUseField() const
2392 //=============================================================================
2393 void HOMARD_Hypothesis::SetUseComp( int UsCmpI )
2395 MESSAGE ("SetUseComp pour UsCmpI = "<<UsCmpI) ;
2396 VERIFICATION( (UsCmpI>=0) && (UsCmpI<=2) );
2399 //=============================================================================
2400 int HOMARD_Hypothesis::GetUseComp() const
2404 //=============================================================================
2405 void HOMARD_Hypothesis::AddComp( const char* NomComp )
2407 // On commence par supprimer la composante au cas ou elle aurait deja ete inseree
2408 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2409 // definition de l'hypothese
2410 SupprComp( NomComp ) ;
2411 // Insertion veritable
2412 _ListComp.push_back( std::string( NomComp ) );
2414 //=============================================================================
2415 void HOMARD_Hypothesis::SupprComp( const char* NomComp )
2417 MESSAGE ("SupprComp pour "<<NomComp) ;
2418 std::list<std::string>::iterator it = find( _ListComp.begin(), _ListComp.end(), NomComp );
2419 if ( it != _ListComp.end() ) { it = _ListComp.erase( it ); }
2421 //=============================================================================
2422 void HOMARD_Hypothesis::SupprComps()
2426 //=============================================================================
2427 const std::list<std::string>& HOMARD_Hypothesis::GetComps() const
2431 //=============================================================================
2432 void HOMARD_Hypothesis::SetRefinThr( int TypeThR, double ThreshR )
2434 MESSAGE( "SetRefinThr : TypeThR = " << TypeThR << ", ThreshR = " << ThreshR );
2435 VERIFICATION( (TypeThR>=0) && (TypeThR<=4) );
2439 //=============================================================================
2440 int HOMARD_Hypothesis::GetRefinThrType() const
2444 //=============================================================================
2445 double HOMARD_Hypothesis::GetThreshR() const
2449 //=============================================================================
2450 void HOMARD_Hypothesis::SetUnRefThr( int TypeThC, double ThreshC )
2452 VERIFICATION( (TypeThC>=0) && (TypeThC<=4) );
2456 //=============================================================================
2457 int HOMARD_Hypothesis::GetUnRefThrType() const
2461 //=============================================================================
2462 double HOMARD_Hypothesis::GetThreshC() const
2466 //=============================================================================
2467 void HOMARD_Hypothesis::SetNivMax( int NivMax )
2468 //=============================================================================
2472 //=============================================================================
2473 const int HOMARD_Hypothesis::GetNivMax() const
2474 //=============================================================================
2478 //=============================================================================
2479 void HOMARD_Hypothesis::SetDiamMin( double DiamMin )
2480 //=============================================================================
2484 //=============================================================================
2485 const double HOMARD_Hypothesis::GetDiamMin() const
2486 //=============================================================================
2490 //=============================================================================
2491 void HOMARD_Hypothesis::SetAdapInit( int AdapInit )
2492 //=============================================================================
2494 _AdapInit = AdapInit;
2496 //=============================================================================
2497 const int HOMARD_Hypothesis::GetAdapInit() const
2498 //=============================================================================
2502 //=============================================================================
2503 void HOMARD_Hypothesis::SetExtraOutput( int ExtraOutput )
2504 //=============================================================================
2506 _ExtraOutput = ExtraOutput;
2508 //=============================================================================
2509 const int HOMARD_Hypothesis::GetExtraOutput() const
2510 //=============================================================================
2512 return _ExtraOutput;
2514 //=============================================================================
2515 void HOMARD_Hypothesis::AddGroup( const char* Group)
2517 // On commence par supprimer le groupe au cas ou il aurait deja ete insere
2518 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2519 // definition de l'hypothese
2520 SupprGroup( Group ) ;
2521 // Insertion veritable
2522 _ListGroupSelected.push_back(Group);
2524 //=============================================================================
2525 void HOMARD_Hypothesis::SupprGroup( const char* Group )
2527 MESSAGE ("SupprGroup pour "<<Group) ;
2528 std::list<std::string>::iterator it = find( _ListGroupSelected.begin(), _ListGroupSelected.end(), Group );
2529 if ( it != _ListGroupSelected.end() ) { it = _ListGroupSelected.erase( it ); }
2531 //=============================================================================
2532 void HOMARD_Hypothesis::SupprGroups()
2534 _ListGroupSelected.clear();
2536 //=============================================================================
2537 void HOMARD_Hypothesis::SetGroups( const std::list<std::string>& ListGroup )
2539 _ListGroupSelected.clear();
2540 std::list<std::string>::const_iterator it = ListGroup.begin();
2541 while(it != ListGroup.end())
2542 _ListGroupSelected.push_back((*it++));
2544 //=============================================================================
2545 const std::list<std::string>& HOMARD_Hypothesis::GetGroups() const
2547 return _ListGroupSelected;
2549 //=============================================================================
2550 // Type d'interpolation des champs :
2551 // 0 : aucun champ n'est interpole
2552 // 1 : tous les champs sont interpoles
2553 // 2 : certains champs sont interpoles
2554 void HOMARD_Hypothesis::SetTypeFieldInterp( int TypeFieldInterp )
2556 VERIFICATION( (TypeFieldInterp>=0) && (TypeFieldInterp<=2) );
2557 _TypeFieldInterp = TypeFieldInterp;
2559 //=============================================================================
2560 int HOMARD_Hypothesis::GetTypeFieldInterp() const
2562 return _TypeFieldInterp;
2564 //=============================================================================
2565 void HOMARD_Hypothesis::AddFieldInterpType( const char* FieldInterp, int TypeInterp )
2567 MESSAGE ("Dans AddFieldInterpType pour " << FieldInterp << " et TypeInterp = " << TypeInterp) ;
2568 // On commence par supprimer le champ au cas ou il aurait deja ete insere
2569 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2570 // definition de l'hypothese
2571 SupprFieldInterp( FieldInterp ) ;
2572 // Insertion veritable
2574 _ListFieldInterp.push_back( std::string( FieldInterp ) );
2576 std::stringstream saux1 ;
2577 saux1 << TypeInterp ;
2578 _ListFieldInterp.push_back( saux1.str() );
2579 // . Indication generale : certains champs sont a interpoler
2580 SetTypeFieldInterp ( 2 ) ;
2582 //=============================================================================
2583 void HOMARD_Hypothesis::SupprFieldInterp( const char* FieldInterp )
2585 MESSAGE ("Dans SupprFieldInterp pour " << FieldInterp) ;
2586 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp ) ;
2587 // Attention a supprimer le nom du champ et le type d'usage
2588 if ( it != _ListFieldInterp.end() )
2590 it = _ListFieldInterp.erase( it ) ;
2591 it = _ListFieldInterp.erase( it ) ;
2593 // Decompte du nombre de champs restant a interpoler
2594 it = _ListFieldInterp.begin() ;
2596 while(it != _ListFieldInterp.end())
2601 MESSAGE("Nombre de champ restants = "<<cpt/2);
2602 // . Indication generale : aucun champ ne reste a interpoler
2605 SetTypeFieldInterp ( 0 ) ;
2608 //=============================================================================
2609 void HOMARD_Hypothesis::SupprFieldInterps()
2611 MESSAGE ("SupprFieldInterps") ;
2612 _ListFieldInterp.clear();
2613 // . Indication generale : aucun champ ne reste a interpoler
2614 SetTypeFieldInterp ( 0 ) ;
2616 //=============================================================================
2617 const std::list<std::string>& HOMARD_Hypothesis::GetFieldInterps() const
2619 return _ListFieldInterp;
2621 //=============================================================================
2622 //=============================================================================
2623 // Liens avec les autres structures
2624 //=============================================================================
2625 //=============================================================================
2626 void HOMARD_Hypothesis::SetCaseCreation( const char* NomCasCreation )
2628 _NomCasCreation = std::string( NomCasCreation );
2630 //=============================================================================
2631 std::string HOMARD_Hypothesis::GetCaseCreation() const
2633 return _NomCasCreation;
2635 //=============================================================================
2636 void HOMARD_Hypothesis::LinkIteration( const char* NomIteration )
2638 _ListIter.push_back( std::string( NomIteration ) );
2640 //=============================================================================
2641 void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
2643 std::list<std::string>::iterator it = find( _ListIter.begin(), _ListIter.end(), NomIteration ) ;
2644 if ( it != _ListIter.end() )
2646 MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
2647 it = _ListIter.erase( it ) ;
2650 //=============================================================================
2651 void HOMARD_Hypothesis::UnLinkIterations()
2655 //=============================================================================
2656 const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
2660 //=============================================================================
2661 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
2663 MESSAGE ("Dans AddZone pour " << NomZone << " et TypeUse = " << TypeUse) ;
2664 // On commence par supprimer la zone au cas ou elle aurait deja ete inseree
2665 // Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
2666 // definition de l'hypothese
2667 SupprZone( NomZone ) ;
2668 // Insertion veritable
2670 _ListZone.push_back( std::string( NomZone ) );
2671 // . Usage de la zone
2672 std::stringstream saux1 ;
2674 _ListZone.push_back( saux1.str() );
2676 //=============================================================================
2677 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
2679 MESSAGE ("Dans SupprZone pour " << NomZone) ;
2680 std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
2681 // Attention a supprimer le nom de zone et le type d'usage
2682 if ( it != _ListZone.end() )
2684 it = _ListZone.erase( it );
2685 it = _ListZone.erase( it );
2688 //=============================================================================
2689 void HOMARD_Hypothesis::SupprZones()
2693 //=============================================================================
2694 const std::list<std::string>& HOMARD_Hypothesis::GetZones() const
2699 //=============================================================================
2701 * default constructor:
2703 //=============================================================================
2704 HOMARD_Iteration::HOMARD_Iteration():
2705 _Name( "" ), _Etat( 0 ),
2707 _NomMesh( "" ), _MeshFile( "" ),
2708 _FieldFile( "" ), _TimeStep( -1 ), _Rank( -1 ),
2711 _NomHypo( "" ), _NomCas( "" ), _NomDir( "" ),
2715 MESSAGE("HOMARD_Iteration");
2717 //=============================================================================
2721 //=============================================================================
2722 HOMARD_Iteration::~HOMARD_Iteration()
2724 MESSAGE("~HOMARD_Iteration");
2726 //=============================================================================
2727 //=============================================================================
2729 //=============================================================================
2730 //=============================================================================
2731 void HOMARD_Iteration::SetName( const char* Name )
2733 _Name = std::string( Name );
2735 //=============================================================================
2736 std::string HOMARD_Iteration::GetName() const
2740 //=============================================================================
2741 //=============================================================================
2743 //=============================================================================
2744 //=============================================================================
2745 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
2747 _NomDir = std::string( NomDir );
2749 //=============================================================================
2750 std::string HOMARD_Iteration::GetDirNameLoc() const
2754 //=============================================================================
2755 void HOMARD_Iteration::SetNumber( int NumIter )
2759 //=============================================================================
2760 int HOMARD_Iteration::GetNumber() const
2764 //=============================================================================
2765 void HOMARD_Iteration::SetState( int etat )
2769 //=============================================================================
2770 int HOMARD_Iteration::GetState() const
2774 //=============================================================================
2775 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
2777 _NomMesh = std::string( NomMesh );
2779 //=============================================================================
2780 std::string HOMARD_Iteration::GetMeshName() const
2784 //=============================================================================
2785 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
2787 _MeshFile = std::string( MeshFile );
2789 //=============================================================================
2790 std::string HOMARD_Iteration::GetMeshFile() const
2794 //=============================================================================
2795 void HOMARD_Iteration::SetFieldFile( const char* FieldFile )
2797 _FieldFile = std::string( FieldFile );
2799 //=============================================================================
2800 std::string HOMARD_Iteration::GetFieldFile() const
2804 //=============================================================================
2805 // Instants pour le champ de pilotage
2806 //=============================================================================
2807 void HOMARD_Iteration::SetTimeStep( int TimeStep )
2809 _TimeStep = TimeStep;
2811 //=============================================================================
2812 void HOMARD_Iteration::SetTimeStepRank( int TimeStep, int Rank )
2814 _TimeStep = TimeStep;
2817 //=============================================================================
2818 void HOMARD_Iteration::SetTimeStepRankLast()
2822 //=============================================================================
2823 int HOMARD_Iteration::GetTimeStep() const
2827 //=============================================================================
2828 int HOMARD_Iteration::GetRank() const
2832 //=============================================================================
2833 // Instants pour un champ a interpoler
2834 //=============================================================================
2835 void HOMARD_Iteration::SetFieldInterpTimeStep( const char* FieldInterp, int TimeStep )
2837 SetFieldInterpTimeStepRank( FieldInterp, TimeStep, TimeStep ) ;
2839 //=============================================================================
2840 void HOMARD_Iteration::SetFieldInterpTimeStepRank( const char* FieldInterp, int TimeStep, int Rank )
2842 MESSAGE("Champ " << FieldInterp << ", hypothese " << _NomHypo )
2843 // Verification de la presence du champ dans l'hypothese
2844 std::list<std::string>::iterator it = find( _ListFieldInterp.begin(), _ListFieldInterp.end(), FieldInterp );
2845 if ( it == _ListFieldInterp.end() )
2847 INFOS("Champ " << FieldInterp << " ; hypothese " << _NomHypo )
2848 VERIFICATION("Le champ est inconnu dans l'hypothese associee a cette iteration." == 0);
2852 _ListFieldInterpTSR.push_back( std::string( FieldInterp ) );
2854 std::stringstream saux1 ;
2856 _ListFieldInterpTSR.push_back( saux1.str() );
2858 std::stringstream saux2 ;
2860 _ListFieldInterpTSR.push_back( saux2.str() );
2862 //=============================================================================
2863 const std::list<std::string>& HOMARD_Iteration::GetFieldInterpsTimeStepRank() const
2865 return _ListFieldInterpTSR;
2867 //=============================================================================
2868 void HOMARD_Iteration::SetFieldInterp( const char* FieldInterp )
2870 _ListFieldInterp.push_back( std::string( FieldInterp ) );
2872 //=============================================================================
2873 const std::list<std::string>& HOMARD_Iteration::GetFieldInterps() const
2875 return _ListFieldInterp;
2877 //=============================================================================
2878 void HOMARD_Iteration::SupprFieldInterps()
2880 _ListFieldInterp.clear();
2882 //=============================================================================
2883 void HOMARD_Iteration::SetLogFile( const char* LogFile )
2885 _LogFile = std::string( LogFile );
2887 //=============================================================================
2888 std::string HOMARD_Iteration::GetLogFile() const
2892 //=============================================================================
2893 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
2895 _FileInfo = std::string( FileInfo );
2897 //=============================================================================
2898 std::string HOMARD_Iteration::GetFileInfo() const
2902 //=============================================================================
2903 //=============================================================================
2904 // Liens avec les autres iterations
2905 //=============================================================================
2906 //=============================================================================
2907 void HOMARD_Iteration::LinkNextIteration( const char* NomIteration )
2909 _mesIterFilles.push_back( std::string( NomIteration ) );
2911 //=============================================================================
2912 void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
2914 std::list<std::string>::iterator it = find( _mesIterFilles.begin(), _mesIterFilles.end(), NomIteration ) ;
2915 if ( it != _mesIterFilles.end() )
2917 MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
2918 it = _mesIterFilles.erase( it ) ;
2921 //=============================================================================
2922 void HOMARD_Iteration::UnLinkNextIterations()
2924 _mesIterFilles.clear();
2926 //=============================================================================
2927 const std::list<std::string>& HOMARD_Iteration::GetIterations() const
2929 return _mesIterFilles;
2931 //=============================================================================
2932 void HOMARD_Iteration::SetIterParentName( const char* IterParent )
2934 _IterParent = IterParent;
2936 //=============================================================================
2937 std::string HOMARD_Iteration::GetIterParentName() const
2941 //=============================================================================
2942 //=============================================================================
2943 // Liens avec les autres structures
2944 //=============================================================================
2945 //=============================================================================
2946 void HOMARD_Iteration::SetCaseName( const char* NomCas )
2948 _NomCas = std::string( NomCas );
2950 //=============================================================================
2951 std::string HOMARD_Iteration::GetCaseName() const
2955 //=============================================================================
2956 void HOMARD_Iteration::SetHypoName( const char* NomHypo )
2958 _NomHypo = std::string( NomHypo );
2960 //=============================================================================
2961 std::string HOMARD_Iteration::GetHypoName() const
2965 //=============================================================================
2966 //=============================================================================
2968 //=============================================================================
2969 //=============================================================================
2970 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
2972 _MessInfo = MessInfo;
2974 //=============================================================================
2975 int HOMARD_Iteration::GetInfoCompute() const
2982 * \brief Relocate nodes to lie on geometry
2983 * \param [in] theInputMedFile - a MED file holding a mesh including nodes that will be
2984 * moved onto the geometry
2985 * \param [in] theOutputMedFile - a MED file to create, that will hold a modified mesh
2986 * \param [in] theInputNodeFiles - an array of names of files describing groups of nodes that
2987 * will be moved onto the geometry
2988 * \param [in] theXaoFileName - a path to a file in XAO format holding the geometry and
2989 * the geometrical groups.
2990 * \param [in] theIsParallel - if \c true, all processors are used to treat boundary shapes
2993 void FrontTrack::track( const std::string& theInputMedFile,
2994 const std::string& theOutputMedFile,
2995 const std::vector< std::string > & theInputNodeFiles,
2996 const std::string& theXaoFileName,
2997 bool theIsParallel )
3001 std::cout << "FrontTrack::track" << std::endl;
3004 if ( theInputNodeFiles.empty() )
3008 std::cout << "Input MED file: " << theInputMedFile << std::endl;
3010 if ( !FT_Utils::fileExists( theInputMedFile ))
3011 throw std::invalid_argument( "Input MED file does not exist: " + theInputMedFile );
3014 std::cout << "Output MED file: " << theOutputMedFile << std::endl;
3016 if ( !FT_Utils::canWrite( theOutputMedFile ))
3017 throw std::invalid_argument( "Can't create the output MED file: " + theOutputMedFile );
3019 std::vector< std::string > theNodeFiles ;
3020 for ( size_t i = 0; i < theInputNodeFiles.size(); ++i )
3023 std::cout << "Initial input node file #"<<i<<": " << theInputNodeFiles[i] << std::endl;
3025 if ( !FT_Utils::fileExists( theInputNodeFiles[i] ))
3026 throw std::invalid_argument( "Input node file does not exist: " + theInputNodeFiles[i] );
3027 // the name of the groupe on line #1, then the numbers of nodes on line #>1
3028 // keep only files with more than 1 line:
3029 std::ifstream fichier(theInputNodeFiles[i].c_str());
3031 unsigned int nb_lines = 0;
3032 while(std::getline(fichier,s)) ++nb_lines;
3033 // std::cout << ". nb_lines: " << nb_lines << std::endl;
3034 if ( nb_lines >= 2 ) { theNodeFiles.push_back( theInputNodeFiles[i] ); }
3037 for ( size_t i = 0; i < theNodeFiles.size(); ++i )
3038 { std::cout << "Valid input node file #"<<i<<": " << theNodeFiles[i] << std::endl; }
3042 std::cout << "XAO file: " << theXaoFileName << std::endl;
3044 if ( !FT_Utils::fileExists( theXaoFileName ))
3045 throw std::invalid_argument( "Input XAO file does not exist: " + theXaoFileName );
3050 std::cout << "Lecture du maillage" << std::endl;
3052 MEDCoupling::MCAuto< MEDCoupling::MEDFileUMesh >
3053 mfMesh( MEDCoupling::MEDFileUMesh::New( theInputMedFile ));
3054 if ( mfMesh.isNull() )
3055 throw std::invalid_argument( "Failed to read the input MED file: " + theInputMedFile );
3057 MEDCoupling::DataArrayDouble * nodeCoords = mfMesh->getCoords();
3058 if ( !nodeCoords || nodeCoords->empty() )
3059 throw std::invalid_argument( "No nodes in the input mesh" );
3065 std::cout << "Lecture de la geometrie" << std::endl;
3068 if ( !xao.importXAO( theXaoFileName ) || !xao.getGeometry() )
3069 throw std::invalid_argument( "Failed to read the XAO input file: " + theXaoFileName );
3072 std::cout << "Conversion en BREP" << std::endl;
3074 XAO::BrepGeometry* xaoGeom = dynamic_cast<XAO::BrepGeometry*>( xao.getGeometry() );
3075 if ( !xaoGeom || xaoGeom->getTopoDS_Shape().IsNull() )
3076 throw std::invalid_argument( "Failed to get a BREP shape from the XAO input file" );
3079 // read groups of nodes and associate them with boundary shapes using names (no projection so far)
3082 std::cout << "Lecture des groupes" << std::endl;
3084 FT_NodeGroups nodeGroups;
3085 nodeGroups.read( theNodeFiles, &xao, nodeCoords );
3087 std::cout << "Nombre de groupes : " << nodeGroups.nbOfGroups() << std::endl;
3090 // project nodes to the boundary shapes and change their coordinates
3093 std::cout << "Projection des noeuds, theIsParallel=" << theIsParallel << std::endl;
3095 OSD_Parallel::For( 0, nodeGroups.nbOfGroups(), nodeGroups, !theIsParallel );
3097 // save the modified mesh
3100 std::cout << "Ecriture du maillage" << std::endl;
3102 const int erase = 2;
3103 mfMesh->write( theOutputMedFile, /*mode=*/erase );
3105 if ( !nodeGroups.isOK() )
3106 throw std::runtime_error("Unable to project some nodes");
3109 //================================================================================
3111 * \brief Initialize FT_Projector's with all sub-shapes of given type
3112 * \param [in] theMainShape - the shape to explore
3113 * \param [in] theSubType - the type of sub-shapes
3114 * \param [out] theProjectors - the projectors
3116 //================================================================================
3118 void getProjectors( const TopoDS_Shape& theMainShape,
3119 const TopAbs_ShapeEnum theSubType,
3120 std::vector< FT_Projector > & theProjectors )
3122 TopTools_IndexedMapOfShape subShapes;
3123 TopExp::MapShapes( theMainShape, theSubType, subShapes );
3125 std::cout << ". Nombre de subShapes : " << subShapes.Size() << std::endl;
3128 theProjectors.resize( subShapes.Size() );
3129 for ( int i = 1; i <= subShapes.Size(); ++i )
3130 theProjectors[ i-1 ].setBoundaryShape( subShapes( i ));
3133 //================================================================================
3135 * \brief Load node groups from files
3136 * \param [in] theNodeFiles - an array of names of files describing groups of nodes that
3137 * will be moved onto geometry
3138 * \param [in] theXaoGeom - the whole geometry to project on
3139 * \param [inout] theNodeCoords - array of node coordinates
3141 //================================================================================
3143 void FT_NodeGroups::read( const std::vector< std::string >& theNodeFiles,
3144 const XAO::Xao* theXao,
3145 MEDCoupling::DataArrayDouble* theNodeCoords )
3147 // get projectors for all boundary sub-shapes;
3148 // index of a projector in the vector corresponds to a XAO index of a sub-shape
3149 XAO::BrepGeometry* xaoGeom = dynamic_cast<XAO::BrepGeometry*>( theXao->getGeometry() );
3150 getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_EDGE, _projectors[0] );
3151 getProjectors( xaoGeom->getTopoDS_Shape(), TopAbs_FACE, _projectors[1] );
3153 _nodesOnGeom.resize( theNodeFiles.size() );
3155 // read node IDs and look for projectors to boundary sub-shapes by group name
3156 FT_Utils::XaoGroups xaoGroups( theXao );
3157 for ( size_t i = 0; i < theNodeFiles.size(); ++i )
3159 _nodesOnGeom[i].read( theNodeFiles[i], xaoGroups, theNodeCoords, _projectors );
3163 //================================================================================
3165 * \brief Project and move nodes of a given group of nodes
3167 //================================================================================
3169 void FT_NodeGroups::projectAndMove( const int groupIndex )
3171 _nodesOnGeom[ groupIndex ].projectAndMove();
3174 //================================================================================
3176 * \brief Return true if all nodes were successfully relocated
3178 //================================================================================
3180 bool FT_NodeGroups::isOK() const
3182 for ( size_t i = 0; i < _nodesOnGeom.size(); ++i )
3183 if ( ! _nodesOnGeom[ i ].isOK() )
3189 //================================================================================
3191 * \brief Print some statistics on node groups
3193 //================================================================================
3195 void FT_NodeGroups::dumpStat() const
3197 for ( size_t i = 0; i < _nodesOnGeom.size(); ++i )
3199 std::cout << _nodesOnGeom[i].getShapeDim() << "D "
3200 << _nodesOnGeom[i].nbNodes() << " nodes" << std::endl;
3205 * \brief Close a file at destruction
3211 FileCloser( FILE * file ): _file( file ) {}
3212 ~FileCloser() { if ( _file ) ::fclose( _file ); }
3215 //================================================================================
3217 * \brief Read node ids from a file and find shapes for projection
3218 * \param [in] theNodeFile - a name of file holding IDs of nodes that
3219 * will be moved onto geometry
3220 * \param [in] theXaoGroups - a tool returning FT_Projector's by XAO group name
3221 * \param [inout] theNodeCoords - array of node coordinates
3222 * \param [in] theAllProjectorsByDim - all projectors of 2 dimensions, ordered so that
3223 * a vector index corresponds to a XAO sub-shape ID
3225 //================================================================================
3227 void FT_NodesOnGeom::read( const std::string& theNodeFile,
3228 const FT_Utils::XaoGroups& theXaoGroups,
3229 MEDCoupling::DataArrayDouble* theNodeCoords,
3230 std::vector< FT_Projector > * theAllProjectorsByDim )
3232 _nodeCoords = theNodeCoords;
3234 FILE * file = ::fopen( theNodeFile.c_str(), "r" );
3236 throw std::invalid_argument( "Can't open an input node file: " + theNodeFile );
3238 FileCloser fileCloser( file );
3240 // -------------------------------------
3241 // get shape dimension by the file name
3242 // -------------------------------------
3244 // hope the file name is something like "frnD.**" with n in (1,2)
3245 int dimPos = theNodeFile.size() - 5;
3246 if ( theNodeFile[ dimPos ] == '2' )
3248 else if ( theNodeFile[ dimPos ] == '1' )
3251 throw std::invalid_argument( "Can't define dimension by node file name " + theNodeFile );
3253 std::cout << ". Dimension of the file " << theNodeFile << ": " << _shapeDim << std::endl;
3256 // -------------------------------------
3257 // read geom group names; several lines
3258 // -------------------------------------
3260 std::vector< std::string > geomNames;
3262 const int maxLineLen = 256;
3263 char line[ maxLineLen ];
3265 long int pos = ::ftell( file );
3266 while ( ::fgets( line, maxLineLen, file )) // read a line
3268 if ( ::feof( file ))
3270 return; // no nodes in the file
3273 // check if the line describes node ids in format 3I10 (e.g. " 120 1 43\n")
3274 size_t lineLen = strlen( line );
3275 if ( lineLen >= 31 &&
3276 ::isdigit( line[9] ) &&
3278 ::isdigit( line[19] ) &&
3280 ::isdigit( line[29] ) &&
3281 ::isspace( line[30] ))
3284 geomNames.push_back( line + 1 ); // skip the 1st white space
3286 pos = ::ftell( file ); // remember the position to return if the next line holds node ids
3289 ::fseek( file, pos, SEEK_SET ); // return to the 1st line holding nodes ids
3296 FT_NodeToMove nodeIds;
3297 std::vector< int > ids;
3299 const int nbNodes = theNodeCoords->getNumberOfTuples(); // to check validity of node IDs
3301 while ( ::fgets( line, maxLineLen, file )) // read a line
3303 // find node ids in the line
3305 char *beg = line, *end = 0;
3309 while (( id = ::strtol( beg, &end, 10 )) &&
3312 ids.push_back( id );
3314 throw std::invalid_argument( "Too large node ID: " + FT_Utils::toStr( id ));
3318 if ( ids.size() >= 3 )
3320 std::vector< int >::iterator i = ids.begin();
3321 nodeIds._nodeToMove = *i;
3322 nodeIds._neighborNodes.assign( ++i, ids.end() );
3324 _nodes.push_back( nodeIds );
3327 if ( ::feof( file ))
3331 // -----------------------------------------------------------------
3332 // try to find FT_Projector's to boundary sub-shapes by group names
3333 // -----------------------------------------------------------------
3335 _allProjectors = & theAllProjectorsByDim[ _shapeDim - 1 ];
3337 _projectors.reserve( geomNames.size() );
3338 std::vector< const FT_Projector* > projectors;
3340 for ( size_t i = 0; i < geomNames.size(); ++i )
3342 std::string & groupName = geomNames[i];
3344 std::cout << ". Group name: " << groupName << std::endl;
3347 // remove trailing white spaces
3348 for ( int iC = groupName.size() - 1; iC >= 0; --iC )
3350 if ( ::isspace( groupName[iC] ) )
3351 groupName.resize( iC );
3355 if ( groupName.empty() )
3358 _groupNames.push_back( groupName ); // keep _groupNames for easier debug :)
3360 // get projectors by group name
3361 theXaoGroups.getProjectors( groupName, _shapeDim,
3362 theAllProjectorsByDim[ _shapeDim-1 ], projectors );
3365 // ------------------------------
3366 // check the found FT_Projector's
3367 // ------------------------------
3369 if ( projectors.size() == 1 )
3371 _projectors.push_back( *projectors[ 0 ]);
3376 for ( size_t i = 0; i < _nodes.size(); ++i )
3377 nodesBox.Add( getPoint( _nodes[i]._nodeToMove ));
3379 if ( projectors.size() > 1 )
3381 // more than one boundary shape;
3382 // try to filter off unnecessary projectors using a bounding box of nodes
3383 for ( size_t i = 0; i < projectors.size(); ++i )
3384 if ( !nodesBox.IsOut( projectors[ i ]->getBoundingBox() ))
3385 _projectors.push_back( *projectors[ i ]);
3388 if ( _projectors.empty() )
3390 // select projectors using a bounding box of nodes
3391 std::vector< FT_Projector > & allProjectors = *_allProjectors;
3392 for ( size_t i = 0; i < allProjectors.size(); ++i )
3393 if ( !nodesBox.IsOut( allProjectors[ i ].getBoundingBox() ))
3394 _projectors.push_back( allProjectors[ i ]);
3396 if ( _projectors.empty() && !_nodes.empty() )
3397 throw std::runtime_error("No boundary shape found for nodes in file " + theNodeFile );
3401 // prepare for projection - create real projectors
3402 for ( size_t i = 0; i < _projectors.size(); ++i )
3403 _projectors[ i ].prepareForProjection();
3407 //================================================================================
3409 * \brief Project nodes to the shapes and move them to new positions
3411 //================================================================================
3413 void FT_NodesOnGeom::projectAndMove()
3419 // check if all the shapes are planar
3420 bool isAllPlanar = true;
3421 for ( size_t i = 0; i < _projectors.size() && isAllPlanar; ++i )
3422 isAllPlanar = _projectors[i].isPlanarBoundary();
3426 // set nodes in the order suitable for optimal projection
3429 // project and move nodes
3431 std::vector< FT_NodeToMove* > notProjectedNodes;
3432 size_t iP, iProjector;
3436 std::cout << ".. _projectors.size() = " << _projectors.size() << std::endl;
3437 std::cout << ".. _nodesOrder.size() = " << _nodesOrder.size() << std::endl;
3441 // 2.1. Avec plusieurs shapes
3443 if ( _projectors.size() > 1 )
3445 // the nodes are to be projected onto several boundary shapes;
3446 // in addition to the projecting, classification on a shape is necessary
3447 // in order to find out on which of the shapes a node is to be projected
3450 for ( size_t i = 0; i < _nodesOrder.size(); ++i )
3452 FT_NodeToMove& nn = _nodes[ _nodesOrder[ i ]];
3453 gp_Pnt xyz = getPoint( nn._nodeToMove );
3454 gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] );
3455 gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] );
3456 double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.;
3457 if ( _projectors[ iProjector ].projectAndClassify( xyz, maxDist2, newXyz,
3458 nn._params, nn._nearParams ))
3460 moveNode( nn._nodeToMove, newXyz );
3462 else // a node is not on iProjector-th shape, find the shape it is on
3464 for ( iP = 1; iP < _projectors.size(); ++iP ) // check _projectors other than iProjector
3466 iProjector = ( iProjector + 1 ) % _projectors.size();
3467 if ( _projectors[ iProjector ].projectAndClassify( xyz, maxDist2, newXyz,
3468 nn._params, nn._nearParams ))
3470 moveNode( nn._nodeToMove, newXyz );
3474 if ( iP == _projectors.size() )
3476 notProjectedNodes.push_back( &nn );
3479 std::cerr << "Warning: no shape found for node " << nn._nodeToMove << std::endl;
3480 if ( !_groupNames.empty() )
3481 std::cerr << "Warning: group -- " << _groupNames[0] << std::endl;
3488 // 2.2. Avec une seule shape
3492 for ( size_t i = 0; i < _nodesOrder.size(); ++i )
3494 FT_NodeToMove& nn = _nodes[ _nodesOrder[ i ]];
3495 gp_Pnt xyz = getPoint( nn._nodeToMove );
3496 gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] );
3497 gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] );
3499 // maxDist2 : le quart du carré de la distance entre les deux voisins du noeud à bouger
3500 double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.;
3502 std::cout << "\n.. maxDist2 = " << maxDist2 << " entre " << nn._neighborNodes[0] << " et " << nn._neighborNodes[1] << " - milieu " << nn._nodeToMove << " - d/2 = " << sqrt(maxDist2) << " - d = " << sqrt(xyz1.SquareDistance( xyz2 )) << std::endl;
3504 if ( _projectors[ 0 ].project( xyz, maxDist2, newXyz,
3505 nn._params, nn._nearParams ))
3506 moveNode( nn._nodeToMove, newXyz );
3508 notProjectedNodes.push_back( &nn );
3514 if ( !notProjectedNodes.empty() )
3516 // project nodes that are not projected by any of _projectors;
3517 // a proper projector is selected by evaluation of a distance between neighbor nodes
3520 std::vector< FT_Projector > & projectors = *_allProjectors;
3523 for ( size_t i = 0; i < notProjectedNodes.size(); ++i )
3525 FT_NodeToMove& nn = *notProjectedNodes[ i ];
3526 gp_Pnt xyz = getPoint( nn._nodeToMove );
3527 gp_Pnt xyz1 = getPoint( nn._neighborNodes[0] );
3528 gp_Pnt xyz2 = getPoint( nn._neighborNodes[1] );
3529 double maxDist2 = xyz1.SquareDistance( xyz2 ) / 4.;
3530 double tol2 = 1e-6 * maxDist2;
3533 for ( iP = 0; iP < projectors.size(); ++iP )
3535 projectors[ iProjector ].prepareForProjection();
3536 projectors[ iProjector ].tryWithoutPrevSolution( true );
3538 if (( ok = projectors[ iProjector ].isOnShape( xyz1, tol2, nn._params, nn._nearParams )) &&
3539 ( ok = projectors[ iProjector ].isOnShape( xyz2, tol2, nn._params, nn._params )))
3541 if ( nn._neighborNodes.size() == 4 )
3543 gp_Pnt xyz1 = getPoint( nn._neighborNodes[2] );
3544 gp_Pnt xyz2 = getPoint( nn._neighborNodes[3] );
3545 if (( ok = projectors[ iProjector ].isOnShape( xyz1, tol2, nn._params, nn._params )))
3546 ok = projectors[ iProjector ].isOnShape( xyz2, tol2, nn._params, nn._params );
3550 if ( ok && projectors[iProjector].project( xyz, maxDist2, newXyz, nn._params, nn._params ))
3552 moveNode( nn._nodeToMove, newXyz );
3555 iProjector = ( iProjector + 1 ) % projectors.size();
3557 if ( iP == projectors.size() )
3561 std::cerr << "Error: not projected node " << nn._nodeToMove << std::endl;
3567 //================================================================================
3569 * \brief Put nodes in the order for optimal projection and set FT_NodeToMove::_nearParams
3570 * to point to a FT_NodeToMove::_params of a node that will be projected earlier
3572 //================================================================================
3574 void FT_NodesOnGeom::putNodesInOrder()
3576 if ( !_nodesOrder.empty() )
3579 // check if any of projectors can use parameters of a previously projected node on a shape
3580 // to speed up projection
3582 bool isPrevSolutionUsed = false;
3583 for ( size_t i = 0; i < _projectors.size() && !isPrevSolutionUsed; ++i )
3584 isPrevSolutionUsed = _projectors[i].canUsePrevSolution();
3586 if ( !isPrevSolutionUsed )
3588 _nodesOrder.resize( _nodes.size() );
3589 for ( size_t i = 0; i < _nodesOrder.size(); ++i )
3590 _nodesOrder[ i ] = i;
3594 // make a map to find a neighbor projected node
3596 // map of { FT_NodeToMove::_neighborNodes[i] } to { FT_NodeToMove* };
3597 // here we call FT_NodeToMove a 'link' as this data links a _neighborNodes[i] node to other nodes
3598 typedef NCollection_DataMap< int, std::vector< FT_NodeToMove* > > TNodeIDToLinksMap;
3599 TNodeIDToLinksMap neigborsMap;
3601 int mapSize = ( _shapeDim == 1 ) ? _nodes.size() + 1 : _nodes.size() * 3;
3602 neigborsMap.Clear();
3603 neigborsMap.ReSize( mapSize );
3605 std::vector< FT_NodeToMove* > linkVec, *linkVecPtr;
3606 const int maxNbLinks = ( _shapeDim == 1 ) ? 2 : 6; // usual nb of links
3608 for ( size_t i = 0; i < _nodes.size(); ++i )
3610 FT_NodeToMove& nn = _nodes[i];
3611 for ( size_t iN = 0; iN < nn._neighborNodes.size(); ++iN )
3613 if ( !( linkVecPtr = neigborsMap.ChangeSeek( nn._neighborNodes[ iN ] )))
3615 linkVecPtr = neigborsMap.Bound( nn._neighborNodes[ iN ], linkVec );
3616 linkVecPtr->reserve( maxNbLinks );
3618 linkVecPtr->push_back( & nn );
3622 // fill in _nodesOrder
3624 _nodesOrder.reserve( _nodes.size() );
3626 std::list< FT_NodeToMove* > queue;
3627 queue.push_back( &_nodes[0] );
3628 _nodes[0]._nearParams = _nodes[0]._params; // to avoid re-adding to the queue
3630 while ( !queue.empty() )
3632 FT_NodeToMove* nn = queue.front();
3635 _nodesOrder.push_back( nn - & _nodes[0] );
3637 // add neighbors to the queue and set their _nearParams = nn->_params
3638 for ( size_t iN = 0; iN < nn->_neighborNodes.size(); ++iN )
3640 std::vector< FT_NodeToMove* >& linkVec = neigborsMap( nn->_neighborNodes[ iN ]);
3641 for ( size_t iL = 0; iL < linkVec.size(); ++iL )
3643 FT_NodeToMove* nnn = linkVec[ iL ];
3644 if ( nnn != nn && nnn->_nearParams == 0 )
3646 nnn->_nearParams = nn->_params;
3647 queue.push_back( nnn );
3652 _nodes[0]._nearParams = 0; // reset
3655 //================================================================================
3657 * \brief Get node coordinates. Node IDs count from a unit
3659 //================================================================================
3661 gp_Pnt FT_NodesOnGeom::getPoint( const int nodeID )
3663 const size_t dim = _nodeCoords->getNumberOfComponents();
3664 const double * xyz = _nodeCoords->getConstPointer() + ( dim * ( nodeID - 1 ));
3665 return gp_Pnt( xyz[0], xyz[1], dim == 2 ? 0 : xyz[2] );
3668 //================================================================================
3670 * \brief change node coordinates
3672 //================================================================================
3674 void FT_NodesOnGeom::moveNode( const int nodeID, const gp_Pnt& newXyz )
3676 const size_t dim = _nodeCoords->getNumberOfComponents();
3677 double z, *xyz = _nodeCoords->getPointer() + ( dim * ( nodeID - 1 ));
3678 newXyz.Coord( xyz[0], xyz[1], dim == 2 ? z : xyz[2] );
3681 //-----------------------------------------------------------------------------
3683 * \brief Root class of a projector of a point to a boundary shape
3685 struct FT_RealProjector
3687 virtual ~FT_RealProjector() {}
3690 * \brief Project a point to a boundary shape
3691 * \param [in] point - the point to project
3692 * \param [out] newSolution - position on the shape (U or UV) found during the projection
3693 * \param [in] prevSolution - position already found during the projection of a neighbor point
3694 * \return gp_Pnt - the projection point
3696 virtual gp_Pnt project( const gp_Pnt& point,
3697 double* newSolution,
3698 const double* prevSolution = 0) = 0;
3701 * \brief Project a point to a boundary shape and check if the projection is within
3702 * the shape boundary
3703 * \param [in] point - the point to project
3704 * \param [in] maxDist2 - the maximal allowed square distance between point and projection
3705 * \param [out] projection - the projection point
3706 * \param [out] newSolution - position on the shape (U or UV) found during the projection
3707 * \param [in] prevSolution - position already found during the projection of a neighbor point
3708 * \return bool - false if the projection point lies out of the shape boundary or
3709 the distance the point and the projection is more than sqrt(maxDist2)
3711 virtual bool projectAndClassify( const gp_Pnt& point,
3712 const double maxDist2,
3714 double* newSolution,
3715 const double* prevSolution = 0) = 0;
3717 // return true if a previously found solution can be used to speed up the projection
3719 virtual bool canUsePrevSolution() const { return false; }
3722 double _dist; // distance between the point being projected and its projection
3725 namespace // actual projection algorithms
3727 const double theEPS = 1e-12;
3729 //================================================================================
3731 * \brief Projector to any curve
3733 //================================================================================
3735 struct CurveProjector : public FT_RealProjector
3737 BRepAdaptor_Curve _curve;
3739 ShapeAnalysis_Curve _projector;
3742 //-----------------------------------------------------------------------------
3743 CurveProjector( const TopoDS_Edge& e, const double tol ):
3744 _curve( e ), _tol( tol )
3746 BRep_Tool::Range( e, _uRange[0], _uRange[1] );
3749 //-----------------------------------------------------------------------------
3750 // project a point to the curve
3751 virtual gp_Pnt project( const gp_Pnt& P,
3752 double* newSolution,
3753 const double* prevSolution = 0)
3756 std::cout << ".. project a point to the curve prevSolution = " << prevSolution << std::endl;
3759 Standard_Real param;
3763 _dist = _projector.NextProject( prevSolution[0], _curve, P, _tol, proj, param );
3767 _dist = _projector.Project( _curve, P, _tol, proj, param, false );
3770 std::cout << ".. _dist : " << _dist << std::endl;
3772 proj = _curve.Value( param );
3774 newSolution[0] = param;
3779 //-----------------------------------------------------------------------------
3780 // project a point to a curve and check if the projection is within the curve boundary
3781 virtual bool projectAndClassify( const gp_Pnt& point,
3782 const double maxDist2,
3784 double* newSolution,
3785 const double* prevSolution = 0)
3788 std::cout << ".. project a point to a curve and check " << std::endl;
3790 projection = project( point, newSolution, prevSolution );
3791 return ( _uRange[0] < newSolution[0] && newSolution[0] < _uRange[1] &&
3792 _dist * _dist < maxDist2 );
3795 //-----------------------------------------------------------------------------
3796 // return true if a previously found solution can be used to speed up the projection
3797 virtual bool canUsePrevSolution() const { return true; }
3800 //================================================================================
3802 * \brief Projector to a straight curve. Don't project, classify only
3804 //================================================================================
3806 struct LineProjector : public FT_RealProjector
3810 //-----------------------------------------------------------------------------
3811 LineProjector( TopoDS_Edge e )
3813 e.Orientation( TopAbs_FORWARD );
3814 _p0 = BRep_Tool::Pnt( TopExp::FirstVertex( e ));
3815 _p1 = BRep_Tool::Pnt( TopExp::LastVertex ( e ));
3818 //-----------------------------------------------------------------------------
3820 virtual gp_Pnt project( const gp_Pnt& P,
3821 double* newSolution,
3822 const double* prevSolution = 0)
3826 //-----------------------------------------------------------------------------
3827 // check if a point lies within the line segment
3828 virtual bool projectAndClassify( const gp_Pnt& point,
3829 const double maxDist2,
3831 double* newSolution,
3832 const double* prevSolution = 0)
3834 gp_Vec edge( _p0, _p1 );
3835 gp_Vec p0p ( _p0, point );
3836 double u = ( edge * p0p ) / edge.SquareMagnitude(); // param [0,1] on the edge
3837 projection = ( 1. - u ) * _p0.XYZ() + u * _p1.XYZ(); // projection of the point on the edge
3838 if ( u < 0 || 1 < u )
3842 return point.SquareDistance( projection ) < theEPS * theEPS;
3846 //================================================================================
3848 * \brief Projector to a circular edge
3850 //================================================================================
3852 struct CircleProjector : public FT_RealProjector
3857 //-----------------------------------------------------------------------------
3858 CircleProjector( const gp_Circ& c, const double f, const double l ):
3865 //-----------------------------------------------------------------------------
3866 // project a point to the circle
3867 virtual gp_Pnt project( const gp_Pnt& P,
3868 double* newSolution,
3869 const double* prevSolution = 0)
3871 // assume that P is already on the the plane of circle, since
3872 // it is in the middle of two points lying on the circle
3874 // move P to the circle
3875 const gp_Pnt& O = _circle.Location();
3876 gp_Vec radiusVec( O, P );
3877 double radius = radiusVec.Magnitude();
3878 if ( radius < std::numeric_limits<double>::min() )
3879 return P; // P in on the axe
3881 gp_Pnt proj = O.Translated( radiusVec.Multiplied( _circle.Radius() / radius ));
3883 _dist = _circle.Radius() - radius;
3888 //-----------------------------------------------------------------------------
3889 // project and check if a projection lies within the circular edge
3890 virtual bool projectAndClassify( const gp_Pnt& point,
3891 const double maxDist2,
3893 double* newSolution,
3894 const double* prevSolution = 0)
3897 projection = project( point, newSolution );
3898 if ( _dist < 0 || // ?
3899 _dist * _dist > maxDist2 )
3902 newSolution[0] = ElCLib::Parameter( _circle, projection );
3903 return ( _uRange[0] < newSolution[0] && newSolution[0] < _uRange[1] );
3907 //================================================================================
3909 * \brief Projector to any surface
3911 //================================================================================
3913 struct SurfaceProjector : public FT_RealProjector
3915 ShapeAnalysis_Surface _projector;
3917 BRepTopAdaptor_FClass2d* _classifier;
3919 //-----------------------------------------------------------------------------
3920 SurfaceProjector( const TopoDS_Face& face, const double tol, BRepTopAdaptor_FClass2d* cls ):
3921 _projector( BRep_Tool::Surface( face )),
3926 //-----------------------------------------------------------------------------
3927 // delete _classifier
3933 //-----------------------------------------------------------------------------
3934 // project a point to a surface
3935 virtual gp_Pnt project( const gp_Pnt& P,
3936 double* newSolution,
3937 const double* prevSolution = 0)
3943 gp_Pnt2d prevUV( prevSolution[0], prevSolution[1] );
3944 uv = _projector.NextValueOfUV( prevUV, P, _tol );
3948 uv = _projector.ValueOfUV( P, _tol );
3951 uv.Coord( newSolution[0], newSolution[1] );
3953 gp_Pnt proj = _projector.Value( uv );
3955 _dist = _projector.Gap();
3960 //-----------------------------------------------------------------------------
3961 // project a point to a surface and check if the projection is within the surface boundary
3962 virtual bool projectAndClassify( const gp_Pnt& point,
3963 const double maxDist2,
3965 double* newSolution,
3966 const double* prevSolution = 0)
3968 projection = project( point, newSolution, prevSolution );
3969 return ( _dist * _dist < maxDist2 ) && classify( newSolution );
3972 //-----------------------------------------------------------------------------
3973 // check if the projection is within the shape boundary
3974 bool classify( const double* newSolution )
3976 TopAbs_State state = _classifier->Perform( gp_Pnt2d( newSolution[0], newSolution[1]) );
3977 return ( state != TopAbs_OUT );
3980 //-----------------------------------------------------------------------------
3981 // return true if a previously found solution can be used to speed up the projection
3982 virtual bool canUsePrevSolution() const { return true; }
3985 //================================================================================
3987 * \brief Projector to a plane. Don't project, classify only
3989 //================================================================================
3991 struct PlaneProjector : public SurfaceProjector
3994 bool _isRealPlane; // false means that a surface is planar but parametrization is different
3996 //-----------------------------------------------------------------------------
3997 PlaneProjector( const gp_Pln& pln,
3998 const TopoDS_Face& face,
3999 BRepTopAdaptor_FClass2d* cls,
4000 bool isRealPlane=true):
4001 SurfaceProjector( face, 0, cls ),
4003 _isRealPlane( isRealPlane )
4006 //-----------------------------------------------------------------------------
4008 virtual gp_Pnt project( const gp_Pnt& P,
4009 double* newSolution,
4010 const double* prevSolution = 0)
4014 //-----------------------------------------------------------------------------
4015 // check if a point lies within the boundry of the planar face
4016 virtual bool projectAndClassify( const gp_Pnt& point,
4017 const double maxDist2,
4019 double* newSolution,
4020 const double* prevSolution = 0)
4024 ElSLib::PlaneParameters( _plane.Position(), point, newSolution[0], newSolution[1]);
4025 projection = ElSLib::PlaneValue ( newSolution[0], newSolution[1], _plane.Position() );
4026 if ( projection.SquareDistance( point ) > theEPS * theEPS )
4029 return SurfaceProjector::classify( newSolution );
4033 return SurfaceProjector::projectAndClassify( point, maxDist2, projection,
4034 newSolution, prevSolution );
4037 //-----------------------------------------------------------------------------
4038 // return true if a previously found solution can be used to speed up the projection
4039 virtual bool canUsePrevSolution() const { return false; }
4042 //================================================================================
4044 * \brief Projector to a cylinder
4046 //================================================================================
4048 struct CylinderProjector : public SurfaceProjector
4050 gp_Cylinder _cylinder;
4052 //-----------------------------------------------------------------------------
4053 CylinderProjector( const gp_Cylinder& c,
4054 const TopoDS_Face& face,
4055 BRepTopAdaptor_FClass2d* cls ):
4056 SurfaceProjector( face, 0, cls ),
4060 //-----------------------------------------------------------------------------
4061 // project a point to the cylinder
4062 virtual gp_Pnt project( const gp_Pnt& P,
4063 double* newSolution,
4064 const double* prevSolution = 0)
4066 // project the point P to the cylinder axis -> Pp
4067 const gp_Pnt& O = _cylinder.Position().Location();
4068 const gp_Dir& axe = _cylinder.Position().Direction();
4069 gp_Vec trsl = gp_Vec( axe ).Multiplied( gp_Vec( O, P ).Dot( axe ));
4070 gp_Pnt Pp = O.Translated( trsl );
4072 // move Pp to the cylinder
4073 gp_Vec radiusVec( Pp, P );
4074 double radius = radiusVec.Magnitude();
4075 if ( radius < std::numeric_limits<double>::min() )
4076 return P; // P in on the axe
4078 gp_Pnt proj = Pp.Translated( radiusVec.Multiplied( _cylinder.Radius() / radius ));
4080 _dist = _cylinder.Radius() - radius;
4084 //-----------------------------------------------------------------------------
4085 // project a point to the cylinder and check if the projection is within the surface boundary
4086 virtual bool projectAndClassify( const gp_Pnt& point,
4087 const double maxDist2,
4089 double* newSolution,
4090 const double* prevSolution = 0)
4092 ElSLib::CylinderParameters( _cylinder.Position(), _cylinder.Radius(), point,
4093 newSolution[0], newSolution[1]);
4094 projection = ElSLib::CylinderValue( newSolution[0], newSolution[1],
4095 _cylinder.Position(), _cylinder.Radius() );
4096 _dist = point.Distance( projection );
4098 return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution );
4100 //-----------------------------------------------------------------------------
4101 // return true if a previously found solution can be used to speed up the projection
4102 virtual bool canUsePrevSolution() const { return false; }
4105 //================================================================================
4107 * \brief Projector to a cone
4109 //================================================================================
4111 struct ConeProjector : public SurfaceProjector
4115 //-----------------------------------------------------------------------------
4116 ConeProjector( const gp_Cone& c,
4117 const TopoDS_Face& face,
4118 BRepTopAdaptor_FClass2d* cls ):
4119 SurfaceProjector( face, 0, cls ),
4123 //-----------------------------------------------------------------------------
4124 // project a point to the cone
4125 virtual gp_Pnt project( const gp_Pnt& point,
4126 double* newSolution,
4127 const double* prevSolution = 0)
4129 ElSLib::ConeParameters( _cone.Position(), _cone.RefRadius(), _cone.SemiAngle(),
4130 point, newSolution[0], newSolution[1]);
4131 gp_Pnt proj = ElSLib::ConeValue( newSolution[0], newSolution[1],
4132 _cone.Position(), _cone.RefRadius(), _cone.SemiAngle() );
4133 _dist = point.Distance( proj );
4138 //-----------------------------------------------------------------------------
4139 // project a point to the cone and check if the projection is within the surface boundary
4140 virtual bool projectAndClassify( const gp_Pnt& point,
4141 const double maxDist2,
4143 double* newSolution,
4144 const double* prevSolution = 0)
4146 projection = project( point, newSolution, prevSolution );
4148 return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution );
4150 //-----------------------------------------------------------------------------
4151 // return true if a previously found solution can be used to speed up the projection
4152 virtual bool canUsePrevSolution() const { return false; }
4155 //================================================================================
4157 * \brief Projector to a sphere
4159 //================================================================================
4161 struct SphereProjector : public SurfaceProjector
4165 //-----------------------------------------------------------------------------
4166 SphereProjector( const gp_Sphere& s,
4167 const TopoDS_Face& face,
4168 BRepTopAdaptor_FClass2d* cls ):
4169 SurfaceProjector( face, 0, cls ),
4173 //-----------------------------------------------------------------------------
4174 // project a point to the sphere
4175 virtual gp_Pnt project( const gp_Pnt& P,
4176 double* newSolution,
4177 const double* prevSolution = 0)
4179 // move Pp to the Sphere
4180 const gp_Pnt& O = _sphere.Location();
4181 gp_Vec radiusVec( O, P );
4182 double radius = radiusVec.Magnitude();
4183 if ( radius < std::numeric_limits<double>::min() )
4184 return P; // P is on O
4186 gp_Pnt proj = O.Translated( radiusVec.Multiplied( _sphere.Radius() / radius ));
4188 _dist = _sphere.Radius() - radius;
4193 //-----------------------------------------------------------------------------
4194 // project a point to the sphere and check if the projection is within the surface boundary
4195 virtual bool projectAndClassify( const gp_Pnt& point,
4196 const double maxDist2,
4198 double* newSolution,
4199 const double* prevSolution = 0)
4201 ElSLib::SphereParameters( _sphere.Position(), _sphere.Radius(), point,
4202 newSolution[0], newSolution[1]);
4203 projection = ElSLib::SphereValue( newSolution[0], newSolution[1],
4204 _sphere.Position(), _sphere.Radius() );
4206 return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution );
4208 //-----------------------------------------------------------------------------
4209 // return true if a previously found solution can be used to speed up the projection
4210 virtual bool canUsePrevSolution() const { return false; }
4213 //================================================================================
4215 * \brief Projector to a torus
4217 //================================================================================
4219 struct TorusProjector : public SurfaceProjector
4223 //-----------------------------------------------------------------------------
4224 TorusProjector( const gp_Torus& t,
4225 const TopoDS_Face& face,
4226 BRepTopAdaptor_FClass2d* cls ):
4227 SurfaceProjector( face, 0, cls ),
4231 //-----------------------------------------------------------------------------
4232 // project a point to the torus
4233 virtual gp_Pnt project( const gp_Pnt& point,
4234 double* newSolution,
4235 const double* prevSolution = 0)
4237 ElSLib::TorusParameters( _torus.Position(), _torus.MajorRadius(), _torus.MinorRadius(),
4238 point, newSolution[0], newSolution[1]);
4239 gp_Pnt proj = ElSLib::TorusValue( newSolution[0], newSolution[1],
4240 _torus.Position(), _torus.MajorRadius(), _torus.MinorRadius() );
4241 _dist = point.Distance( proj );
4246 //-----------------------------------------------------------------------------
4247 // project a point to the torus and check if the projection is within the surface boundary
4248 virtual bool projectAndClassify( const gp_Pnt& point,
4249 const double maxDist2,
4251 double* newSolution,
4252 const double* prevSolution = 0)
4254 projection = project( point, newSolution, prevSolution );
4256 return ( _dist * _dist < maxDist2 ) && SurfaceProjector::classify( newSolution );
4258 //-----------------------------------------------------------------------------
4259 // return true if a previously found solution can be used to speed up the projection
4260 virtual bool canUsePrevSolution() const { return false; }
4263 //================================================================================
4265 * \brief Check if a curve can be considered straight
4267 //================================================================================
4269 bool isStraight( const GeomAdaptor_Curve& curve, const double tol )
4271 // rough check: evaluate how far from a straight line connecting the curve ends
4272 // stand several internal points of the curve
4274 const double f = curve.FirstParameter();
4275 const double l = curve.LastParameter();
4276 const gp_Pnt pf = curve.Value( f );
4277 const gp_Pnt pl = curve.Value( l );
4278 const gp_Vec lineVec( pf, pl );
4279 const double lineLen2 = lineVec.SquareMagnitude();
4280 if ( lineLen2 < std::numeric_limits< double >::min() )
4281 return false; // E seems closed
4283 const double nbSamples = 7;
4284 for ( int i = 0; i < nbSamples; ++i )
4286 const double r = ( i + 1 ) / nbSamples;
4287 const gp_Pnt pi = curve.Value( f * r + l * ( 1 - r ));
4288 const gp_Vec vi( pf, pi );
4289 const double h2 = lineVec.Crossed( vi ).SquareMagnitude() / lineLen2;
4290 if ( h2 > tol * tol )
4295 GCPnts_UniformDeflection divider( curve, tol );
4296 return ( divider.IsDone() && divider.NbPoints() < 3 );
4300 //================================================================================
4302 * \brief Initialize with a boundary shape
4304 //================================================================================
4306 FT_Projector::FT_Projector(const TopoDS_Shape& shape)
4309 setBoundaryShape( shape );
4310 _tryWOPrevSolution = false;
4313 //================================================================================
4315 * \brief Copy another projector
4317 //================================================================================
4319 FT_Projector::FT_Projector(const FT_Projector& other)
4322 _shape = other._shape;
4323 _bndBox = other._bndBox;
4324 _tryWOPrevSolution = false;
4327 //================================================================================
4329 * \brief Destructor. Delete _realProjector
4331 //================================================================================
4333 FT_Projector::~FT_Projector()
4335 delete _realProjector;
4338 //================================================================================
4340 * \brief Initialize with a boundary shape. Compute the bounding box
4342 //================================================================================
4344 void FT_Projector::setBoundaryShape(const TopoDS_Shape& shape)
4346 delete _realProjector; _realProjector = 0;
4348 if ( shape.IsNull() )
4351 BRepBndLib::Add( shape, _bndBox );
4352 _bndBox.Enlarge( 1e-5 * sqrt( _bndBox.SquareExtent() ));
4355 //================================================================================
4357 * \brief Create a real projector
4359 //================================================================================
4361 void FT_Projector::prepareForProjection()
4363 if ( _shape.IsNull() || _realProjector )
4366 if ( _shape.ShapeType() == TopAbs_EDGE )
4368 const TopoDS_Edge& edge = TopoDS::Edge( _shape );
4370 double tol = 1e-6 * sqrt( _bndBox.SquareExtent() );
4373 Handle(Geom_Curve) curve = BRep_Tool::Curve( edge, f,l );
4374 if ( curve.IsNull() )
4375 return; // degenerated edge
4377 GeomAdaptor_Curve acurve( curve, f, l );
4378 switch ( acurve.GetType() )
4381 _realProjector = new LineProjector( edge );
4383 case GeomAbs_Circle:
4384 _realProjector = new CircleProjector( acurve.Circle(), f, l );
4386 case GeomAbs_BezierCurve:
4387 case GeomAbs_BSplineCurve:
4388 case GeomAbs_OffsetCurve:
4389 case GeomAbs_OtherCurve:
4390 if ( isStraight( acurve, tol ))
4392 _realProjector = new LineProjector( edge );
4395 case GeomAbs_Ellipse:
4396 case GeomAbs_Hyperbola:
4397 case GeomAbs_Parabola:
4398 _realProjector = new CurveProjector( edge, tol );
4401 else if ( _shape.ShapeType() == TopAbs_FACE )
4403 TopoDS_Face face = TopoDS::Face( _shape );
4405 Handle(Geom_Surface) surface = BRep_Tool::Surface( face );
4406 if ( surface.IsNull() )
4409 GeomAdaptor_Surface asurface( surface );
4410 Standard_Real tol = BRep_Tool::Tolerance( face );
4411 Standard_Real toluv = Min( asurface.UResolution( tol ), asurface.VResolution( tol ));
4412 BRepTopAdaptor_FClass2d* classifier = new BRepTopAdaptor_FClass2d( face, toluv );
4414 switch ( asurface.GetType() )
4417 _realProjector = new PlaneProjector( asurface.Plane(), face, classifier );
4419 case GeomAbs_Cylinder:
4420 _realProjector = new CylinderProjector( asurface.Cylinder(), face, classifier );
4422 case GeomAbs_Sphere:
4423 _realProjector = new SphereProjector( asurface.Sphere(), face, classifier );
4426 _realProjector = new ConeProjector( asurface.Cone(), face, classifier );
4429 _realProjector = new TorusProjector( asurface.Torus(), face, classifier );
4431 case GeomAbs_BezierSurface:
4432 case GeomAbs_BSplineSurface:
4433 case GeomAbs_SurfaceOfRevolution:
4434 case GeomAbs_SurfaceOfExtrusion:
4435 case GeomAbs_OffsetSurface:
4436 case GeomAbs_OtherSurface:
4437 GeomLib_IsPlanarSurface isPlaneCheck( surface, tol );
4438 if ( isPlaneCheck.IsPlanar() )
4440 _realProjector = new PlaneProjector( isPlaneCheck.Plan(), face, classifier,
4441 /*isRealPlane=*/false);
4445 _realProjector = new SurfaceProjector( face, tol, classifier );
4450 if ( !_realProjector )
4455 //================================================================================
4457 * \brief Return true if projection is not needed
4459 //================================================================================
4461 bool FT_Projector::isPlanarBoundary() const
4463 return ( dynamic_cast< LineProjector* >( _realProjector ) ||
4464 dynamic_cast< PlaneProjector* >( _realProjector ) );
4467 //================================================================================
4469 * \brief Check if a point lies on the boundary shape
4470 * \param [in] point - the point to check
4471 * \param [in] tol2 - a square tolerance allowing to decide whether a point is on the shape
4472 * \param [in] newSolution - position on the shape (U or UV) of the point found
4474 * \param [in] prevSolution - position on the shape (U or UV) of a neighbor point
4475 * \return bool - \c true if the point lies on the boundary shape
4477 * This method is used to select a shape by checking if all neighbor nodes of a node to move
4480 //================================================================================
4482 bool FT_Projector::isOnShape( const gp_Pnt& point,
4484 double* newSolution,
4485 const double* prevSolution)
4487 if ( _bndBox.IsOut( point ) || !_realProjector )
4491 if ( isPlanarBoundary() )
4492 return projectAndClassify( point, tol2, proj, newSolution, prevSolution );
4494 return project( point, tol2, proj, newSolution, prevSolution );
4497 //================================================================================
4499 * \brief Project a point to the boundary shape
4500 * \param [in] point - the point to project
4501 * \param [in] maxDist2 - the maximal square distance between the point and the projection
4502 * \param [out] projection - the projection
4503 * \param [out] newSolution - position on the shape (U or UV) of the point found
4505 * \param [in] prevSolution - already found position on the shape (U or UV) of a neighbor point
4506 * \return bool - false if the distance between the point and the projection
4507 * is more than sqrt(maxDist2)
4509 * This method is used to project a node in the case where only one shape is found by name
4511 //================================================================================
4513 bool FT_Projector::project( const gp_Pnt& point,
4514 const double maxDist2,
4516 double* newSolution,
4517 const double* prevSolution)
4519 if ( !_realProjector )
4522 _realProjector->_dist = 1e100;
4523 projection = _realProjector->project( point, newSolution, prevSolution );
4525 bool ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 );
4526 if ( !ok && _tryWOPrevSolution && prevSolution )
4528 projection = _realProjector->project( point, newSolution );
4529 ok = ( _realProjector->_dist * _realProjector->_dist < maxDist2 );
4534 //================================================================================
4536 * \brief Project a point to the boundary shape and check if the projection lies within
4537 * the shape boundary
4538 * \param [in] point - the point to project
4539 * \param [in] maxDist2 - the maximal square distance between the point and the projection
4540 * \param [out] projection - the projection
4541 * \param [out] newSolution - position on the shape (U or UV) of the point found
4543 * \param [in] prevSolution - already found position on the shape (U or UV) of a neighbor point
4544 * \return bool - false if the projection point lies out of the shape boundary or
4545 * the distance between the point and the projection is more than sqrt(maxDist2)
4547 * This method is used to project a node in the case where several shapes are selected for
4548 * projection of a node group
4550 //================================================================================
4552 bool FT_Projector::projectAndClassify( const gp_Pnt& point,
4553 const double maxDist2,
4555 double* newSolution,
4556 const double* prevSolution)
4558 if ( _bndBox.IsOut( point ) || !_realProjector )
4561 bool ok = _realProjector->projectAndClassify( point, maxDist2, projection,
4562 newSolution, prevSolution );
4563 if ( !ok && _tryWOPrevSolution && prevSolution )
4564 ok = _realProjector->projectAndClassify( point, maxDist2, projection, newSolution );
4569 //================================================================================
4571 * \brief Return true if a previously found solution can be used to speed up the projection
4573 //================================================================================
4575 bool FT_Projector::canUsePrevSolution() const
4577 return ( _realProjector && _realProjector->canUsePrevSolution() );
4580 //================================================================================
4582 * \brief Check if a file exists
4584 //================================================================================
4586 bool FT_Utils::fileExists( const std::string& path )
4591 boost::system::error_code err;
4592 bool res = boofs::exists( path, err );
4594 return err ? false : res;
4597 //================================================================================
4599 * \brief Check if a file can be created/overwritten
4601 //================================================================================
4603 bool FT_Utils::canWrite( const std::string& path )
4611 HANDLE file = CreateFile( path.c_str(), // name of the write
4612 GENERIC_WRITE, // open for writing
4614 NULL, // default security
4615 OPEN_ALWAYS, // CREATE NEW or OPEN EXISTING
4616 FILE_ATTRIBUTE_NORMAL, // normal file
4617 NULL); // no attr. template
4618 can = ( file != INVALID_HANDLE_VALUE );
4619 CloseHandle( file );
4623 int file = ::open( path.c_str(),
4625 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); // rw-r--r--
4626 can = ( file >= 0 );
4633 //================================================================================
4635 * \brief Make a map of XAO groups
4637 //================================================================================
4639 FT_Utils::XaoGroups::XaoGroups( const XAO::Xao* theXao )
4641 XAO::Xao* xao = const_cast< XAO::Xao* >( theXao );
4643 for ( int iG = 0; iG < theXao->countGroups(); ++iG )
4645 XAO::Group* group = xao->getGroup( iG );
4647 if ( group->getDimension() == 1 )
4649 _xaoGroups[ 0 ].insert( std::make_pair( group->getName(), group ));
4651 else if ( group->getDimension() == 2 )
4653 _xaoGroups[ 1 ].insert( std::make_pair( group->getName(), group ));
4657 //================================================================================
4659 * \brief Return FT_Projector's by a group name
4660 * \param [in] groupName - the group name
4661 * \param [in] dim - the group dimension
4662 * \param [in] allProjectors - the projector of all shapes of \a dim dimension
4663 * \param [out] groupProjectors - projectors to shapes of the group
4664 * \return int - number of found shapes
4666 //================================================================================
4668 int FT_Utils::XaoGroups::getProjectors( const std::string& groupName,
4670 const std::vector< FT_Projector > & allProjectors,
4671 std::vector< const FT_Projector* > & groupProjectors) const
4673 // get namesake groups
4675 const TGroupByNameMap* groupMap = 0;
4677 groupMap = &_xaoGroups[ 0 ];
4678 else if ( dim == 2 )
4679 groupMap = &_xaoGroups[ 1 ];
4683 TGroupByNameMap::const_iterator name2gr = groupMap->find( groupName );
4684 if ( name2gr == groupMap->end() )
4687 std::vector< XAO::Group* > groups;
4688 groups.push_back( name2gr->second );
4690 for ( ++name2gr; name2gr != groupMap->end(); ++name2gr )
4692 if ( name2gr->second->getName() == groupName )
4693 groups.push_back( name2gr->second );
4701 for ( size_t i = 0; i < groups.size(); ++i )
4703 // IDs in XAO correspond to indices of allProjectors
4704 std::set<int>::iterator id = groups[i]->begin(), end = groups[i]->end();
4705 for ( ; id != end; ++id, ++nbFound )
4706 if ( *id < (int) allProjectors.size() )
4707 groupProjectors.push_back ( & allProjectors[ *id ]);
4713 } // namespace SMESHHOMARDImpl /end/