Salome HOME
Merge branch 'BR_H2018_3' into BR_2018_V8_5
[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 #include <NCollection_IndexedDataMap.hxx>
27
28 class HYDROData_Document;
29 class HYDROData_TopoCurve;
30 class HYDROData_Object;
31
32 class HYDRODATA_EXPORT HYDROData_PolylineOperator
33 {
34 public:
35   bool Split( const Handle( HYDROData_Document )& theDoc,
36               const Handle( HYDROData_PolylineXY )& thePolyline,
37               const gp_Pnt2d& thePoint,
38               double theTolerance ) const;
39   bool Split( const Handle( HYDROData_Document )& theDoc,
40               const Handle( HYDROData_PolylineXY )& thePolyline,
41               const Handle( HYDROData_PolylineXY )& theTool,
42               double theTolerance,
43               bool& theIsIntersected) const;
44   bool Split( const Handle( HYDROData_Document )& theDoc,
45               const HYDROData_SequenceOfObjects& thePolylines,
46               double theTolerance );
47   bool Merge( const Handle( HYDROData_Document )& theDoc,
48               const QString& theName,
49               const HYDROData_SequenceOfObjects& thePolylines,
50               bool isConnectByNewSegment,
51               double theTolerance );
52
53   static void GetWires(
54     const Handle( HYDROData_PolylineXY )& thePolyline,
55     std::vector<TopoDS_Wire>& theWires);
56
57   //! The method is intended to approximate the B-spline edge curve
58   //! by a 'Hydro' spline section.
59   //! Inserts the knot in the middle of each such B-spline piece that
60   //! the middle deflection is more than the required deflection and
61   //! more than the half of the maximal middle deflection.
62   //! Returns the initial maximal middle deflection.
63   //! Returns a negative value in the case of any error.
64   static double ReduceDeflection(
65     const double theDeflection,
66     HYDROData_TopoCurve& theCurve,
67     int& thePieceCount);
68
69   bool Extract( const Handle(HYDROData_Document)& theDocument,
70                 const Handle(HYDROData_Object)& theObject );
71
72 protected:
73   bool split( const Handle( HYDROData_Document )& theDoc,
74               const Handle( HYDROData_PolylineXY )& thePolyline,
75               const HYDROData_SequenceOfObjects& theTools,
76               double theTolerance,
77               int theIgnoreIndex,
78               bool& theIsIntersected) const;
79
80   static void Split(
81     const TopoDS_Wire& theWire,
82     const gp_Pnt2d& thePoint,
83     double theTolerance,
84     std::vector<TopoDS_Shape>& theWires);
85
86   static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
87                                const Handle( HYDROData_PolylineXY )& theOldPolyline,
88                                const std::vector<TopoDS_Shape>& theShape,
89                                bool isUseIndices,
90                                NCollection_IndexedDataMap<Handle(HYDROData_PolylineXY), TopoDS_Shape>& outPoly2Sh);
91 };
92
93 #endif