Salome HOME
refs #640: correct width for non-georeferenced profile
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineOperator.h
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_PolylineOperator_HeaderFile
20 #define HYDROData_PolylineOperator_HeaderFile
21
22 #include <HYDROData_PolylineXY.h>
23 #include <Geom2d_Curve.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <vector>
26
27 class Handle( HYDROData_Document );
28 class HYDROData_TopoCurve;
29
30 class HYDRODATA_EXPORT HYDROData_PolylineOperator
31 {
32 public:
33   bool Split( const Handle( HYDROData_Document )& theDoc,
34               const Handle( HYDROData_PolylineXY )& thePolyline,
35               const gp_Pnt2d& thePoint,
36               double theTolerance ) const;
37   bool Split( const Handle( HYDROData_Document )& theDoc,
38               const Handle( HYDROData_PolylineXY )& thePolyline,
39               const Handle( HYDROData_PolylineXY )& theTool,
40               double theTolerance,
41               bool& theIsIntersected) const;
42   bool Split( const Handle( HYDROData_Document )& theDoc,
43               const HYDROData_SequenceOfObjects& thePolylines,
44               double theTolerance );
45   bool Merge( const Handle( HYDROData_Document )& theDoc,
46               const QString& theName,
47               const HYDROData_SequenceOfObjects& thePolylines,
48               bool isConnectByNewSegment,
49               double theTolerance );
50
51   static void GetWires(
52     const Handle( HYDROData_PolylineXY )& thePolyline,
53     std::vector<TopoDS_Wire>& theWires);
54
55   //! The method is intended to approximate the B-spline edge curve
56   //! by a 'Hydro' spline section.
57   //! Inserts the knot in the middle of each such B-spline piece that
58   //! the middle deflection is more than the required deflection and
59   //! more than the half of the maximal middle deflection.
60   //! Returns the initial maximal middle deflection.
61   //! Returns a negative value in the case of any erorr.
62   static double ReduceDeflection(
63     const double theDeflection,
64     HYDROData_TopoCurve& theCurve,
65     int& thePieceCount);
66
67 protected:
68   bool split( const Handle( HYDROData_Document )& theDoc,
69               const Handle( HYDROData_PolylineXY )& thePolyline,
70               const HYDROData_SequenceOfObjects& theTools,
71               double theTolerance,
72               int theIgnoreIndex,
73               bool& theIsIntersected) const;
74
75   static void Split(
76     const TopoDS_Wire& theWire,
77     const gp_Pnt2d& thePoint,
78     double theTolerance,
79     std::vector<TopoDS_Shape>& theWires);
80
81   static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
82                                const QString& theNamePrefix,
83                                const std::vector<TopoDS_Shape>& theShape,
84                                bool isUseIndices );
85 };
86
87 #endif