0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / AIS / AIS_BadEdgeFilter.cxx
1 // Created on: 1998-03-04
2 // Created by: Julia Gerasimova
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //              <g_design>
18
19 #include <AIS_BadEdgeFilter.hxx>
20 #include <SelectMgr_EntityOwner.hxx>
21 #include <Standard_Type.hxx>
22 #include <StdSelect_BRepOwner.hxx>
23 #include <TopoDS_Edge.hxx>
24 #include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
25 #include <TopTools_ListIteratorOfListOfShape.hxx>
26 #include <TopTools_ListOfShape.hxx>
27
28 //=======================================================================
29 //function : AIS_BadEdgeFilter
30 //purpose  : 
31 //=======================================================================
32 AIS_BadEdgeFilter::AIS_BadEdgeFilter()
33 {
34   myContour=0;
35 }
36
37 //=======================================================================
38 //function : ActsOn
39 //purpose  : 
40 //=======================================================================
41
42 Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
43 {
44   return (aType == TopAbs_EDGE);
45 }
46
47 //=======================================================================
48 //function : IsOk
49 //purpose  : 
50 //=======================================================================
51
52 Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
53 {
54   if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
55     return Standard_True;
56
57   if (myContour==0)
58     return Standard_True;
59
60   const TopoDS_Shape& aShape = Handle(StdSelect_BRepOwner)::DownCast (EO)->Shape();
61
62   if (myBadEdges.IsBound(myContour)) {
63     TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
64     for (; it.More(); it.Next()) {
65       if (it.Value().IsSame(aShape))
66         return Standard_False;
67     }
68   }
69   return Standard_True;
70 }
71
72 //=======================================================================
73 //function : AddEdge
74 //purpose  : 
75 //=======================================================================
76
77 void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
78                                 const Standard_Integer Index)
79 {
80   if (myBadEdges.IsBound(Index)) {
81     myBadEdges.ChangeFind(Index).Append(anEdge); 
82   }
83   else {
84     TopTools_ListOfShape LS;
85     LS.Append(anEdge);
86     myBadEdges.Bind(Index,LS);
87   }
88 }
89
90 //=======================================================================
91 //function : RemoveEdges
92 //purpose  : 
93 //=======================================================================
94
95 void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
96 {
97   myBadEdges.UnBind(Index);
98 }
99
100 //=======================================================================
101 //function : RemoveEdges
102 //purpose  : 
103 //=======================================================================
104
105 void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
106 {
107   myContour = Index;
108 }