b311480e |
1 | // Created on: 1998-03-04 |
2 | // Created by: Julia Gerasimova |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | // <g_design> |
18 | |
19 | |
20 | #include <AIS_BadEdgeFilter.ixx> |
21 | |
22 | #include <StdSelect_BRepOwner.hxx> |
23 | #include <TopTools_ListOfShape.hxx> |
24 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
25 | #include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx> |
26 | |
27 | |
28 | |
29 | //======================================================================= |
30 | //function : AIS_BadEdgeFilter |
31 | //purpose : |
32 | //======================================================================= |
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 (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) |
57 | return Standard_True; |
58 | |
59 | if (myContour==0) |
60 | return Standard_True; |
61 | |
62 | const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape(); |
63 | |
64 | if (myBadEdges.IsBound(myContour)) { |
65 | TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour)); |
66 | for (; it.More(); it.Next()) { |
67 | if (it.Value().IsSame(aShape)) |
68 | return Standard_False; |
69 | } |
70 | } |
71 | return Standard_True; |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : AddEdge |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge, |
80 | const Standard_Integer Index) |
81 | { |
82 | if (myBadEdges.IsBound(Index)) { |
83 | myBadEdges.ChangeFind(Index).Append(anEdge); |
84 | } |
85 | else { |
86 | TopTools_ListOfShape LS; |
87 | LS.Append(anEdge); |
88 | myBadEdges.Bind(Index,LS); |
89 | } |
90 | } |
91 | |
92 | //======================================================================= |
93 | //function : RemoveEdges |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index) |
98 | { |
99 | myBadEdges.UnBind(Index); |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : RemoveEdges |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index) |
108 | { |
109 | myContour = Index; |
110 | } |