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 Checks the type of object.
51 * \param theObject object to check
52 * \return true if object is geometry object
54 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
57 * \brief Updates the child object name.
58 * \param theOldStr old father object name
59 * \param theNewStr new father object name
60 * \param theObject object to update
62 static void UpdateChildObjectName( const QString& theOldStr,
63 const QString& theNewStr,
64 const Handle(HYDROData_Entity)& theObject );
68 * \brief Generate name for new object in python environment.
69 * \param theTreatedObjects objects which was alredy created by dump operation
70 * \param thePrefix name prefix
71 * \return generated name
73 static QString GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
74 const QString& thePrefix );
76 * Computes Point State from TopAbs (simplified & limited method).
79 static TopAbs_State ComputePointState( const gp_XY& thePnt2d,
80 const TopoDS_Face& theFace );
83 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
85 return theFirst > ( theSecond - Precision::Confusion() ) &&
86 theFirst < ( theSecond + Precision::Confusion() );
89 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
91 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
94 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
96 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );