0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / AIS / AIS_BadEdgeFilter.cxx
CommitLineData
b311480e 1// Created on: 1998-03-04
2// Created by: Julia Gerasimova
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21// <g_design>
22
23
24#include <AIS_BadEdgeFilter.ixx>
25
26#include <StdSelect_BRepOwner.hxx>
27#include <TopTools_ListOfShape.hxx>
28#include <TopTools_ListIteratorOfListOfShape.hxx>
29#include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>
30
31
32
33//=======================================================================
34//function : AIS_BadEdgeFilter
35//purpose :
36//=======================================================================
37
38AIS_BadEdgeFilter::AIS_BadEdgeFilter()
39{
40 myContour=0;
41}
42
43//=======================================================================
44//function : ActsOn
45//purpose :
46//=======================================================================
47
48Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
49{
50 return (aType == TopAbs_EDGE);
51}
52
53//=======================================================================
54//function : IsOk
55//purpose :
56//=======================================================================
57
58Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
59{
60 if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
61 return Standard_True;
62
63 if (myContour==0)
64 return Standard_True;
65
66 const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
67
68 if (myBadEdges.IsBound(myContour)) {
69 TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
70 for (; it.More(); it.Next()) {
71 if (it.Value().IsSame(aShape))
72 return Standard_False;
73 }
74 }
75 return Standard_True;
76}
77
78//=======================================================================
79//function : AddEdge
80//purpose :
81//=======================================================================
82
83void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
84 const Standard_Integer Index)
85{
86 if (myBadEdges.IsBound(Index)) {
87 myBadEdges.ChangeFind(Index).Append(anEdge);
88 }
89 else {
90 TopTools_ListOfShape LS;
91 LS.Append(anEdge);
92 myBadEdges.Bind(Index,LS);
93 }
94}
95
96//=======================================================================
97//function : RemoveEdges
98//purpose :
99//=======================================================================
100
101void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
102{
103 myBadEdges.UnBind(Index);
104}
105
106//=======================================================================
107//function : RemoveEdges
108//purpose :
109//=======================================================================
110
111void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
112{
113 myContour = Index;
114}