Salome HOME
test linear interpolation of a stream
[modules/hydro.git] / src / HYDROData / HYDROData_SplitToZonesTool.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_SplitToZonesTool_H
20 #define HYDROData_SplitToZonesTool_H
21
22 #ifdef WIN32
23   #pragma warning ( disable: 4251 )
24 #endif
25
26 #include <HYDROData_Object.h>
27 #include <HYDROData_Transform.h>
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Compound.hxx>
30 #include <TopoDS_Face.hxx>
31 #include <TopoDS_Wire.hxx>
32
33 #include <TopTools_ShapeMapHasher.hxx>
34 #include <NCollection_IndexedMap.hxx>
35 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
36 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
37 #include <TopTools_ListOfShape.hxx>
38 #include <QStringList>
39 #include <NCollection_DataMap.hxx>
40
41 class HYDROData_PolylineXY;
42
43 /**
44  * \class HYDROData_SplitToZonesTool
45  * \brief This class contains methods used for splitting geometry objects
46  *        into non-intersected regions.
47  */
48 class HYDRODATA_EXPORT HYDROData_SplitToZonesTool
49 {
50 public:
51   struct HYDRODATA_EXPORT SplitData
52   {
53     enum SplitObjectType
54     {
55       Data_None,
56       Data_Zone,
57       Data_Edge,
58       Data_IntEdge
59     };
60
61     TopoDS_Shape    Shape;
62     QStringList     ObjectNames;
63     SplitObjectType Type;
64
65     SplitData() :
66      Type( Data_None ) {}
67     
68     SplitData( const SplitObjectType& theType,
69                const TopoDS_Shape&    theShape,
70                const QStringList&     theObjectNames ) :
71       Type( theType ), Shape( theShape ), ObjectNames( theObjectNames ) {}
72
73     SplitData( const SplitObjectType& theType,
74                const TopoDS_Shape&    theShape,
75                const QString&         theObjectName ) :
76       Type( theType ), Shape( theShape ), ObjectNames( theObjectName ) {}
77
78     TopoDS_Face Face() const;
79   };
80
81   typedef QList        <SplitData> SplitDataList;
82   typedef QListIterator<SplitData> SplitDataListIterator;  
83   typedef NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> HYDROData_MapOfShape;
84   typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape;
85   typedef NCollection_IndexedDataMap<TopoDS_Shape, TopTools_ListOfShape, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfShape;
86   typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape;
87   typedef NCollection_IndexedDataMap<TopoDS_Shape,  QStringList, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfString;
88   typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfString;
89   #undef _NCollection_MapHasher
90
91 public:
92
93   static SplitDataList       Split( const HYDROData_SequenceOfObjects&  theObjectList,
94                                     const HYDROData_SequenceOfObjects&  theGroupsList,
95                                     const Handle(HYDROData_PolylineXY)& thePolyline,
96                                     const HYDROData_SequenceOfObjects& InterPolys );
97
98   static SplitDataList       Split( const HYDROData_SequenceOfObjects&  theObjectList );
99
100   static void AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
101                                const HYDROData_SequenceOfObjects& thePolylines,
102                                NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
103
104   static void CutFaceByEdges(const TopoDS_Face& in, 
105                              TopTools_ListOfShape& out, 
106                              const HYDROData_SequenceOfObjects& thePolylines,
107                              NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE,
108                              TopTools_IndexedDataMapOfShapeListOfShape* OutOrSh2M);
109
110   static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
111                         TopTools_ListOfShape& outShs,
112                         bool OutShapeAsRes,
113                         TopTools_IndexedDataMapOfShapeShape* OutNE2OE,
114                         TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH);
115
116   static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
117
118   static Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace);
119
120
121 private:
122
123   /**
124    * Split input faces.
125    */
126   static bool SplitFaces(const TopoDS_Compound& theComp, HYDROData_Transform& theTool);
127 };
128
129 #ifdef WIN32
130   #pragma warning ( default: 4251 )
131 #endif
132
133
134 #endif