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