]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Tool.h
Salome HOME
Merge branch 'BR_v14_rc' into BR_SINUSX_FORMAT
[modules/hydro.git] / src / HYDROData / HYDROData_Tool.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_Tool_HeaderFile
20 #define HYDROData_Tool_HeaderFile
21
22 #include "HYDROData.h"
23 #include "HYDROData_Entity.h"
24
25 #include <Precision.hxx>
26
27 #include <TopAbs_ShapeEnum.hxx>
28
29 #include <QString>
30 #include <QStringList>
31 #include <gp_XY.hxx>
32 #include <TopoDS_Face.hxx>
33
34 class QFile;
35 class TopoDS_Shape;
36 class TopTools_SequenceOfShape;
37 class Handle(HYDROData_Document);
38
39 class HYDRODATA_EXPORT HYDROData_Tool {
40
41 public:
42
43   static void                           WriteStringsToFile( QFile&             theFile,
44                                                             const QStringList& theStrings,
45                                                             const QString&     theSep = "\n" );
46
47   /**
48    * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
49    * \param theDoc document where this operation is performed
50    */
51   static void                           SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
52
53   /**
54    * \brief Generate name for new object.
55    * \param theDoc document
56    * \param thePrefix name prefix
57    * \param theUsedNames list of already used names
58    * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
59    * \return generated name
60    */
61   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
62                                                             const QString&                    thePrefix,
63                                                             const QStringList&                theUsedNames = QStringList(),
64                                                             const bool                        theIsTryToUsePurePrefix = false );
65
66   /**
67    * \brief Checks the type of object.
68    * \param theObject object to check
69    * \return true if object is geometry object
70    */
71   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
72
73   /**
74    * \brief Updates the child object name.
75    * \param theOldStr old father object name
76    * \param theNewStr new father object name
77    * \param theObject object to update
78    */
79   static void                           UpdateChildObjectName( const QString&                  theOldStr,
80                                                                const QString&                  theNewStr,
81                                                                const Handle(HYDROData_Entity)& theObject );
82
83
84   /**
85    * \brief Generate name for new object in python environment.
86    * \param theTreatedObjects objects which was alredy created by dump operation
87    * \param thePrefix name prefix
88    * \return generated name
89    */
90   static QString                        GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
91                                                                const QString&             thePrefix );
92  /**
93   * Computes Point State from TopAbs (simplified & limited method).
94   */
95
96  static TopAbs_State                    ComputePointState( const gp_XY& thePnt2d, 
97                                                                const TopoDS_Face& theFace );
98 };
99
100 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
101 {
102   return theFirst > ( theSecond - Precision::Confusion() ) &&
103          theFirst < ( theSecond + Precision::Confusion() );
104 }
105
106 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
107 {
108   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
109 }
110
111 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
112 {
113   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
114 }
115
116
117
118
119 #endif
120
121