0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- 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 IMPLEMENT_STANDARD_RTTIEXT(AIS_BadEdgeFilter,SelectMgr_Filter)
29
30 //=======================================================================
31 //function : AIS_BadEdgeFilter
32 //purpose  : 
33 //=======================================================================
34 AIS_BadEdgeFilter::AIS_BadEdgeFilter()
35 {
36   myContour=0;
37 }
38
39 //=======================================================================
40 //function : ActsOn
41 //purpose  : 
42 //=======================================================================
43
44 Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
45 {
46   return (aType == TopAbs_EDGE);
47 }
48
49 //=======================================================================
50 //function : IsOk
51 //purpose  : 
52 //=======================================================================
53
54 Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
55 {
56   if (myContour==0)
57     return Standard_True;
58
59   Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO));
60   if (aBO.IsNull())
61     return Standard_True;
62
63   const TopoDS_Shape& aShape = aBO->Shape();
64
65   if (myBadEdges.IsBound(myContour)) {
66     TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
67     for (; it.More(); it.Next()) {
68       if (it.Value().IsSame(aShape))
69         return Standard_False;
70     }
71   }
72   return Standard_True;
73 }
74
75 //=======================================================================
76 //function : AddEdge
77 //purpose  : 
78 //=======================================================================
79
80 void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
81                                 const Standard_Integer Index)
82 {
83   if (myBadEdges.IsBound(Index)) {
84     myBadEdges.ChangeFind(Index).Append(anEdge); 
85   }
86   else {
87     TopTools_ListOfShape LS;
88     LS.Append(anEdge);
89     myBadEdges.Bind(Index,LS);
90   }
91 }
92
93 //=======================================================================
94 //function : RemoveEdges
95 //purpose  : 
96 //=======================================================================
97
98 void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
99 {
100   myBadEdges.UnBind(Index);
101 }
102
103 //=======================================================================
104 //function : RemoveEdges
105 //purpose  : 
106 //=======================================================================
107
108 void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
109 {
110   myContour = Index;
111 }