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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_Tool_HeaderFile
20 #define HYDROData_Tool_HeaderFile
22 #include "HYDROData.h"
23 #include "HYDROData_Entity.h"
25 #include <Precision.hxx>
27 #include <TopAbs_ShapeEnum.hxx>
30 #include <QStringList>
32 #include <TopoDS_Face.hxx>
36 class TopTools_SequenceOfShape;
37 class Handle(HYDROData_Document);
41 class HYDRODATA_EXPORT HYDROData_Tool {
45 static void WriteStringsToFile( QFile& theFile,
46 const QStringList& theStrings,
47 const QString& theSep = "\n" );
50 * \brief Generate name for new object.
51 * \param theDoc document
52 * \param thePrefix name prefix
53 * \param theUsedNames list of already used names
54 * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
55 * \return generated name
57 static QString GenerateObjectName( const Handle(HYDROData_Document)& theDoc,
58 const QString& thePrefix,
59 const QStringList& theUsedNames = QStringList(),
60 const bool theIsTryToUsePurePrefix = false );
63 * \brief Checks the type of object.
64 * \param theObject object to check
65 * \return true if object is geometry object
67 static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject );
70 * \brief Updates the child object name.
71 * \param theOldStr old father object name
72 * \param theNewStr new father object name
73 * \param theObject object to update
75 static void UpdateChildObjectName( const QString& theOldStr,
76 const QString& theNewStr,
77 const Handle(HYDROData_Entity)& theObject );
81 * \brief Generate name for new object in python environment.
82 * \param theTreatedObjects objects which was alredy created by dump operation
83 * \param thePrefix name prefix
84 * \return generated name
86 static QString GenerateNameForPython( const MapOfTreatedObjects& theTreatedObjects,
87 const QString& thePrefix );
89 * Computes Point State from TopAbs (simplified & limited method).
92 static TopAbs_State ComputePointState( const gp_XY& thePnt2d,
93 const TopoDS_Face& theFace );
95 static double GetAltitudeForEdge( const TopoDS_Edge& theEdge,
96 const gp_XY& thePoint,
97 double theParameterTolerance,
98 double theSquareDistanceTolerance,
99 double theInvalidAltitude );
100 static double GetAltitudeForWire( const TopoDS_Wire& theWire,
101 const gp_XY& thePoint,
102 double theParameterTolerance,
103 double theSquareDistanceTolerance,
104 double theInvalidAltitude );
107 * \brief Returns the first shape from the group.
108 * \param theGroups the list of groups
109 * \param theGroupId the group id
111 static TopoDS_Shape getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
112 const int theGroupId );
115 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
117 return theFirst > ( theSecond - Precision::Confusion() ) &&
118 theFirst < ( theSecond + Precision::Confusion() );
121 inline bool ValuesMoreEquals( const double& theFirst, const double& theSecond )
123 return theFirst >= theSecond || ValuesEquals( theFirst, theSecond );
126 inline bool ValuesLessEquals( const double& theFirst, const double& theSecond )
128 return theFirst <= theSecond || ValuesEquals( theFirst, theSecond );