summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepDS/TopOpeBRepDS_Association.cxx
blob: 3903ec7798eba09cd0f9e0082762a3df3adc7311 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// File:	TopOpeBRepDS_Association.cxx
// Created:	Thu Sep  3 09:35:36 1998
// Author:	Yves FRICAUD
//		<yfr@claquox.paris1.matra-dtv.fr>


#include <TopOpeBRepDS_Association.ixx>
#include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>


//=======================================================================
//function : Contains
//purpose  : 
//=======================================================================

static Standard_Boolean Contains (const TopOpeBRepDS_ListOfInterference& LI,
				  const Handle(TopOpeBRepDS_Interference)& I)
{
  for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
    if (I->HasSameGeometry(it.Value())) return 1;
  }
  return 0;
}


//=======================================================================
//function : TopOpeBRepDS_Association
//purpose  : 
//=======================================================================

TopOpeBRepDS_Association::TopOpeBRepDS_Association()
{
}


//=======================================================================
//function : Associate
//purpose  : 
//=======================================================================

void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
					 const Handle(TopOpeBRepDS_Interference)& K) 
{
  if (!myMap.IsBound(I)) {
    TopOpeBRepDS_ListOfInterference empty;
    myMap.Bind(I,empty);
    myMap(I).Append(K);
  }
  else if (!Contains(myMap(I),K)) {
    myMap(I).Append(K);
  }
  if (!myMap.IsBound(K)) {
    TopOpeBRepDS_ListOfInterference empty;
    myMap.Bind(K,empty);
    myMap(K).Append(I);
  }
  else if (!Contains(myMap(K),I)) {
    myMap(K).Append(I);
  }
}


//=======================================================================
//function : Associate
//purpose  : 
//=======================================================================

void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
					 const TopOpeBRepDS_ListOfInterference& LI) 
{  
  for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
    Associate(I,it.Value());
  }
}

//=======================================================================
//function : HasAssociation
//purpose  : 
//=======================================================================

Standard_Boolean TopOpeBRepDS_Association::HasAssociation(const Handle(TopOpeBRepDS_Interference)& I) const
{
  return myMap.IsBound(I);
}


//=======================================================================
//function : Associated
//purpose  : 
//=======================================================================

TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_Association::Associated
(const Handle(TopOpeBRepDS_Interference)& I)
{
  if (myMap.IsBound(I)) {
    return myMap.ChangeFind(I);
  }
  static TopOpeBRepDS_ListOfInterference empty;
  return empty;
}


//=======================================================================
//function : AreAssociated
//purpose  : 
//=======================================================================

Standard_Boolean TopOpeBRepDS_Association::AreAssociated(const Handle(TopOpeBRepDS_Interference)& I,
							 const Handle(TopOpeBRepDS_Interference)& K) const
{
  return (myMap.IsBound(I) && Contains(myMap(I),K));
}