]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_LCM_FaceClassifier.h
Salome HOME
debug of classifier
[modules/hydro.git] / src / HYDROData / HYDROData_LCM_FaceClassifier.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_LCM_FACECLASSIFIER_H
20 #define HYDRODATA_LCM_FACECLASSIFIER_H
21
22 #include <HYDROData.h>
23 #include <vector>
24 #include <set>
25 #include <QString>
26
27 #include "Bnd_Box2d.hxx" 
28 #include <NCollection_UBTree.hxx>
29 #include <NCollection_List.hxx>
30 #include <NCollection_IndexedDataMap.hxx>
31 #include <TopoDS_Face.hxx>
32 #include <NCollection_Map.hxx>
33
34 class BRepTopAdaptor_FClass2d;
35 class HYDROData_LandCoverMap;
36 class Handle(Geom_Plane);
37
38 typedef NCollection_UBTree <Standard_Integer, Bnd_Box2d> HYDROData_FaceClassifier_BndBoxTree;
39
40 class HYDROData_FaceClassifier_BndBoxTreeSelector : public HYDROData_FaceClassifier_BndBoxTree::Selector
41 {
42 public:
43   HYDROData_FaceClassifier_BndBoxTreeSelector(const NCollection_IndexedDataMap<TopoDS_Face, BRepTopAdaptor_FClass2d*>& theMapOfShape)
44     : HYDROData_FaceClassifier_BndBoxTreeSelector::Selector(), myMapF2Class2d (theMapOfShape)
45   {}
46
47   Standard_Boolean Reject (const Bnd_Box2d& theBox) const
48   {
49     return (theBox.IsOut (myP));
50   }
51
52   Standard_Boolean Accept (const Standard_Integer& theObj);
53
54   const NCollection_List<TopoDS_Face>& GetResFaces () const 
55   { 
56     return myResFaces;
57   }
58
59   const TopoDS_Face& GetFirstFace() const 
60   { 
61     if (!myResFaces.IsEmpty())
62       return myResFaces.First();
63     else
64       TopoDS_Face();
65   }
66
67   void SetCurrentPoint (const gp_Pnt2d& theP) 
68   { 
69     myP = theP;
70   }
71
72 private:
73   HYDROData_FaceClassifier_BndBoxTreeSelector(const HYDROData_FaceClassifier_BndBoxTreeSelector& );
74   HYDROData_FaceClassifier_BndBoxTreeSelector& operator=(const HYDROData_FaceClassifier_BndBoxTreeSelector& );
75
76 private:
77   const NCollection_IndexedDataMap<TopoDS_Face, BRepTopAdaptor_FClass2d*>& myMapF2Class2d;
78   gp_Pnt2d myP;
79   NCollection_List<TopoDS_Face> myResFaces;
80 };
81
82 class HYDRODATA_EXPORT HYDROData_LCM_FaceClassifier
83 {
84
85 public:
86
87   HYDROData_LCM_FaceClassifier(const HYDROData_LandCoverMap* const theLCM) : myLCM(theLCM)
88   {};
89
90   ~HYDROData_LCM_FaceClassifier()
91   {};
92
93   void Classify( const std::vector<gp_XY>& thePoints, 
94     std::vector<std::set <QString> >& theTypes, 
95     std::vector<NCollection_Map <TopoDS_Face> >* theFaces) const;
96
97   static Handle(Geom_Plane) GetPlane(const TopoDS_Face& F);
98
99
100 private:
101   const HYDROData_LandCoverMap* const myLCM;
102
103 };
104
105
106 #endif