1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_Tool_HeaderFile
24 #define HYDROData_Tool_HeaderFile
26 #include "HYDROData.h"
27 #include "HYDROData_Entity.h"
29 #include <Precision.hxx>
31 #include <TopAbs_ShapeEnum.hxx>
34 #include <QStringList>
36 #include <TopoDS_Face.hxx>
40 class TopTools_SequenceOfShape;
41 class Handle(HYDROData_Document);
43 class HYDRODATA_EXPORT HYDROData_Tool {
47 static void WriteStringsToFile( QFile& theFile,
48 const QStringList& theStrings,
49 const QString& theSep = "\n" );
52 * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects.
53 * \param theDoc document where this operation is performed
55 static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc );
58 * \brief Generate name for new object.
59 * \param theDoc document
60 * \param thePrefix name prefix
61 * \param theUsedNames list of already used names
62 * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
63 * \return generated name
65 static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
66 const QString& thePrefix,
67 const QStringList& theUsedNames = QStringList(),
68 const bool theIsTryToUsePurePrefix = false );
71 * \brief Checks the type of object.
72 * \param theObject object to check
73 * \return true if object is geometry object
75 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
78 * \brief Updates the child object name.
79 * \param theOldStr old father object name
80 * \param theNewStr new father object name
81 * \param theObject object to update
83 static void UpdateChildObjectName( const QString& theOldStr,
84 const QString& theNewStr,
85 const Handle(HYDROData_Entity)& theObject );
89 * \brief Generate name for new object in python environment.
90 * \param theTreatedObjects objects which was alredy created by dump operation
91 * \param thePrefix name prefix
92 * \return generated name
94 static QString GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
95 const QString& thePrefix );
97 * Computes Point State from TopAbs (simplified & limited method).
100 static TopAbs_State ComputePointState( const gp_XY& thePnt2d,
101 const TopoDS_Face& theFace );
104 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
106 return theFirst > ( theSecond - Precision::Confusion() ) &&
107 theFirst < ( theSecond + Precision::Confusion() );
110 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
112 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
115 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
117 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );