Salome HOME
Merge branch 'BR_LAND_COVER' of ssh://git.salome-platform.org/modules/hydro into...
[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 #include <HYDROData_Object.h>
23 #include <HYDROData_Transform.h>
24 #include <TopoDS_Shape.hxx>
25 #include <TopoDS_Compound.hxx>
26 #include <TopoDS_Face.hxx>
27 #include <TopTools_ShapeMapHasher.hxx>
28 #include <NCollection_IndexedMap.hxx>
29 #include <NCollection_IndexedDataMap.hxx>
30 #include <TopTools_ListOfShape.hxx>
31 #include <QStringList>
32
33 class Handle(HYDROData_PolylineXY);
34
35 /**
36  * \class HYDROData_SplitToZonesTool
37  * \brief This class contains methods used for splitting geometry objects
38  *        into non-intersected regions.
39  */
40 class HYDRODATA_EXPORT HYDROData_SplitToZonesTool
41 {
42 public:
43   struct HYDRODATA_EXPORT SplitData
44   {
45     enum SplitObjectType
46     {
47       Data_None,
48       Data_Zone,
49       Data_Edge
50     };
51
52     TopoDS_Shape    Shape;
53     QStringList     ObjectNames;
54     SplitObjectType Type;
55
56     SplitData() :
57      Type( Data_None ) {}
58     
59     SplitData( const SplitObjectType& theType,
60                const TopoDS_Shape&    theShape,
61                const QStringList&     theObjectNames ) :
62       Type( theType ), Shape( theShape ), ObjectNames( theObjectNames ) {}
63
64     SplitData( const SplitObjectType& theType,
65                const TopoDS_Shape&    theShape,
66                const QString&         theObjectName ) :
67       Type( theType ), Shape( theShape ), ObjectNames( theObjectName ) {}
68
69     TopoDS_Face Face() const;
70   };
71
72   typedef QList        <SplitData> SplitDataList;
73   typedef QListIterator<SplitData> SplitDataListIterator;  
74   typedef NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> HYDROData_MapOfShape;
75   typedef HYDROData_MapOfShape::Iterator HYDROData_MapIteratorOfMapOfShape;
76   typedef NCollection_IndexedDataMap<TopoDS_Shape, TopTools_ListOfShape, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfShape;
77   typedef HYDROData_DataMapOfShapeListOfShape::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape;
78   typedef NCollection_IndexedDataMap<TopoDS_Shape,  QStringList, TopTools_ShapeMapHasher> HYDROData_DataMapOfShapeListOfString;
79   typedef HYDROData_DataMapOfShapeListOfString::Iterator HYDROData_DataMapIteratorOfDataMapOfShapeListOfString;
80   #undef _NCollection_MapHasher
81
82 public:
83
84   static SplitDataList       Split( const HYDROData_SequenceOfObjects&  theObjectList,
85                                     const HYDROData_SequenceOfObjects&  theGroupsList,
86                                     const Handle(HYDROData_PolylineXY)& thePolyline );
87
88   static SplitDataList       Split( const HYDROData_SequenceOfObjects&  theObjectList );
89
90   static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
91
92 private:
93
94   /**
95    * Split input faces.
96    */
97   static Standard_Integer SplitFaces(const TopoDS_Compound& theComp, HYDROData_Transform& theTool);
98 };
99
100 #endif