2 #ifndef HYDROData_Tool_HeaderFile
3 #define HYDROData_Tool_HeaderFile
6 #include "HYDROData_Entity.h"
8 #include <Precision.hxx>
10 #include <TopAbs_ShapeEnum.hxx>
13 #include <QStringList>
15 #include <TopoDS_Face.hxx>
19 class TopTools_SequenceOfShape;
20 class Handle(HYDROData_Document);
22 class HYDRODATA_EXPORT HYDROData_Tool {
26 static void WriteStringsToFile( QFile& theFile,
27 const QStringList& theStrings,
28 const QString& theSep = "\n" );
31 * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
32 * \param theDoc document where this operation is performed
34 static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
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
44 static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
45 const QString& thePrefix,
46 const QStringList& theUsedNames = QStringList(),
47 const bool theIsTryToUsePurePrefix = false );
50 * \brief Find the data object with the specified name.
51 * \param theModule module
53 * \param theObjectKind kind of object
56 static Handle(HYDROData_Entity) FindObjectByName( const Handle(HYDROData_Document)& theDoc,
57 const QString& theName,
58 const ObjectKind theObjectKind = KIND_UNKNOWN );
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
67 static HYDROData_SequenceOfObjects FindObjectsByNames( const Handle(HYDROData_Document)& theDoc,
68 const QStringList& theNames,
69 const ObjectKind theObjectKind = KIND_UNKNOWN );
72 * \brief Checks the type of object.
73 * \param theObject object to check
74 * \return true if object is geometry object
76 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
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
84 static void UpdateChildObjectName( const QString& theOldStr,
85 const QString& theNewStr,
86 const Handle(HYDROData_Entity)& theObject );
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
95 static QString GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
96 const QString& thePrefix );
98 * Computes Point State from TopAbs (simplified & limited method).
101 static TopAbs_State ComputePointState( const gp_XY& thePnt2d,
102 const TopoDS_Face& theFace );
105 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
107 return theFirst > ( theSecond - Precision::Confusion() ) &&
108 theFirst < ( theSecond + Precision::Confusion() );
111 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
113 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
116 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
118 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );