summaryrefslogtreecommitdiff
path: root/src/AIS/AIS_BadEdgeFilter.cxx
blob: 496c514ba5d7be46938735c1fc9b9b2082de97c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// File:	AIS_BadEdgeFilter.cxx
// Created:	Wed Mar  4 12:01:13 1998
// Author:	Julia Gerasimova
//		<g_design>


#include <AIS_BadEdgeFilter.ixx>

#include <StdSelect_BRepOwner.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape.hxx>



//=======================================================================
//function : AIS_BadEdgeFilter
//purpose  : 
//=======================================================================

AIS_BadEdgeFilter::AIS_BadEdgeFilter()
{
  myContour=0;
}

//=======================================================================
//function : ActsOn
//purpose  : 
//=======================================================================

Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
  return (aType == TopAbs_EDGE);
}

//=======================================================================
//function : IsOk
//purpose  : 
//=======================================================================

Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
  if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
    return Standard_True;

  if (myContour==0)
    return Standard_True;

  const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();

  if (myBadEdges.IsBound(myContour)) {
    TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
    for (; it.More(); it.Next()) {
      if (it.Value().IsSame(aShape))
	return Standard_False;
    }
  }
  return Standard_True;
}

//=======================================================================
//function : AddEdge
//purpose  : 
//=======================================================================

void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
				const Standard_Integer Index)
{
  if (myBadEdges.IsBound(Index)) {
    myBadEdges.ChangeFind(Index).Append(anEdge); 
  }
  else {
    TopTools_ListOfShape LS;
    LS.Append(anEdge);
    myBadEdges.Bind(Index,LS);
  }
}

//=======================================================================
//function : RemoveEdges
//purpose  : 
//=======================================================================

void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
{
  myBadEdges.UnBind(Index);
}

//=======================================================================
//function : RemoveEdges
//purpose  : 
//=======================================================================

void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
{
  myContour = Index;
}