]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_Tool.h
Salome HOME
d2260e781100c6601d95b13801a7f0f0a269781b
[modules/hydro.git] / src / HYDROData / HYDROData_Tool.h
1
2 #ifndef HYDROData_Tool_HeaderFile
3 #define HYDROData_Tool_HeaderFile
4
5 #include "HYDROData.h"
6 #include "HYDROData_Entity.h"
7
8 #include <Precision.hxx>
9
10 #include <TopAbs_ShapeEnum.hxx>
11
12 #include <QString>
13 #include <QStringList>
14 #include <gp_XY.hxx>
15 #include <TopoDS_Face.hxx>
16
17 class QFile;
18 class TopoDS_Shape;
19 class TopTools_SequenceOfShape;
20 class Handle(HYDROData_Document);
21
22 class HYDRODATA_EXPORT HYDROData_Tool {
23
24 public:
25
26   static void                           WriteStringsToFile( QFile&             theFile,
27                                                             const QStringList& theStrings,
28                                                             const QString&     theSep = "\n" );
29
30   /**
31    * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
32    * \param theDoc document where this operation is performed
33    */
34   static void                           SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
35
36   /**
37    * \brief Generate name for new object.
38    * \param theDoc document
39    * \param thePrefix name prefix
40    * \param theUsedNames list of already used names
41    * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
42    * \return generated name
43    */
44   static QString                        GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
45                                                             const QString&                    thePrefix,
46                                                             const QStringList&                theUsedNames = QStringList(),
47                                                             const bool                        theIsTryToUsePurePrefix = false );
48
49   /**
50    * \brief Find the data object with the specified name.
51    * \param theModule module
52    * \param theName name
53    * \param theObjectKind kind of object
54    * \return data object
55    */
56   static Handle(HYDROData_Entity)       FindObjectByName( const Handle(HYDROData_Document)& theDoc,
57                                                           const QString&                    theName,
58                                                           const ObjectKind                  theObjectKind = KIND_UNKNOWN );
59
60   /**
61    * \brief Find the data objects with the specified names.
62    * \param theModule module
63    * \param theNames list of names
64    * \param theObjectKind kind of object
65    * \return list of data objects
66    */
67   static HYDROData_SequenceOfObjects    FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
68                                                             const QStringList&                theNames,
69                                                             const ObjectKind                  theObjectKind = KIND_UNKNOWN );
70
71   /**
72    * \brief Checks the type of object.
73    * \param theObject object to check
74    * \return true if object is geometry object
75    */
76   static bool                           IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
77
78   /**
79    * \brief Updates the child object name.
80    * \param theOldStr old father object name
81    * \param theNewStr new father object name
82    * \param theObject object to update
83    */
84   static void                           UpdateChildObjectName( const QString&                  theOldStr,
85                                                                const QString&                  theNewStr,
86                                                                const Handle(HYDROData_Entity)& theObject );
87
88
89   /**
90    * \brief Generate name for new object in python environment.
91    * \param theTreatedObjects objects which was alredy created by dump operation
92    * \param thePrefix name prefix
93    * \return generated name
94    */
95   static QString                        GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
96                                                                const QString&             thePrefix );
97  /**
98   * Computes Point State from TopAbs (simplified & limited method).
99   */
100
101  static TopAbs_State                    ComputePointState( const gp_XY& thePnt2d, 
102                                                                const TopoDS_Face& theFace );
103 };
104
105 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
106 {
107   return theFirst > ( theSecond - Precision::Confusion() ) &&
108          theFirst < ( theSecond + Precision::Confusion() );
109 }
110
111 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
112 {
113   return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
114 }
115
116 inline  bool ValuesLessEquals( const double& theFirst, const double& theSecond )
117 {
118   return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );
119 }
120
121
122
123
124 #endif
125
126