0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_Association.cxx
CommitLineData
b311480e 1// Created on: 1998-09-03
2// Created by: Yves FRICAUD
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.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <Standard_Type.hxx>
19#include <TopOpeBRepDS_Association.hxx>
20#include <TopOpeBRepDS_Interference.hxx>
21#include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
7fd59977 22
23//=======================================================================
24//function : Contains
25//purpose :
26//=======================================================================
7fd59977 27static Standard_Boolean Contains (const TopOpeBRepDS_ListOfInterference& LI,
28 const Handle(TopOpeBRepDS_Interference)& I)
29{
30 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
31 if (I->HasSameGeometry(it.Value())) return 1;
32 }
33 return 0;
34}
35
36
37//=======================================================================
38//function : TopOpeBRepDS_Association
39//purpose :
40//=======================================================================
41
42TopOpeBRepDS_Association::TopOpeBRepDS_Association()
43{
44}
45
46
47//=======================================================================
48//function : Associate
49//purpose :
50//=======================================================================
51
52void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
53 const Handle(TopOpeBRepDS_Interference)& K)
54{
55 if (!myMap.IsBound(I)) {
56 TopOpeBRepDS_ListOfInterference empty;
57 myMap.Bind(I,empty);
58 myMap(I).Append(K);
59 }
60 else if (!Contains(myMap(I),K)) {
61 myMap(I).Append(K);
62 }
63 if (!myMap.IsBound(K)) {
64 TopOpeBRepDS_ListOfInterference empty;
65 myMap.Bind(K,empty);
66 myMap(K).Append(I);
67 }
68 else if (!Contains(myMap(K),I)) {
69 myMap(K).Append(I);
70 }
71}
72
73
74//=======================================================================
75//function : Associate
76//purpose :
77//=======================================================================
78
79void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
80 const TopOpeBRepDS_ListOfInterference& LI)
81{
82 for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
83 Associate(I,it.Value());
84 }
85}
86
87//=======================================================================
88//function : HasAssociation
89//purpose :
90//=======================================================================
91
92Standard_Boolean TopOpeBRepDS_Association::HasAssociation(const Handle(TopOpeBRepDS_Interference)& I) const
93{
94 return myMap.IsBound(I);
95}
96
97
98//=======================================================================
99//function : Associated
100//purpose :
101//=======================================================================
102
103TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_Association::Associated
104(const Handle(TopOpeBRepDS_Interference)& I)
105{
106 if (myMap.IsBound(I)) {
107 return myMap.ChangeFind(I);
108 }
109 static TopOpeBRepDS_ListOfInterference empty;
110 return empty;
111}
112
113
114//=======================================================================
115//function : AreAssociated
116//purpose :
117//=======================================================================
118
119Standard_Boolean TopOpeBRepDS_Association::AreAssociated(const Handle(TopOpeBRepDS_Interference)& I,
120 const Handle(TopOpeBRepDS_Interference)& K) const
121{
122 return (myMap.IsBound(I) && Contains(myMap(I),K));
123}
124
125