0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPTools / BOPTools.cxx
... / ...
CommitLineData
1// Created by: Peter KURNEV
2// Copyright (c) 1999-2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15
16#include <BOPCol_ListOfShape.hxx>
17#include <BOPTools.hxx>
18#include <TopExp_Explorer.hxx>
19#include <TopoDS_Shape.hxx>
20
21//=======================================================================
22//function : MapShapes
23//purpose :
24//=======================================================================
25void BOPTools::MapShapes(const TopoDS_Shape& S,
26 BOPCol_MapOfShape& M)
27{
28 M.Add(S);
29 TopoDS_Iterator It(S);
30 while (It.More()) {
31 MapShapes(It.Value(),M);
32 It.Next();
33 }
34}
35
36
37//=======================================================================
38//function : MapShapes
39//purpose :
40//=======================================================================
41void BOPTools::MapShapes(const TopoDS_Shape& S,
42 BOPCol_IndexedMapOfShape& M)
43{
44 M.Add(S);
45 TopoDS_Iterator It(S);
46 while (It.More()) {
47 MapShapes(It.Value(),M);
48 It.Next();
49 }
50}
51
52//=======================================================================
53//function : MapShapes
54//purpose :
55//=======================================================================
56void BOPTools::MapShapes(const TopoDS_Shape& S,
57 const TopAbs_ShapeEnum T,
58 BOPCol_IndexedMapOfShape& M)
59{
60 TopExp_Explorer Ex(S,T);
61 while (Ex.More()) {
62 M.Add(Ex.Current());
63 Ex.Next();
64 }
65}
66//=======================================================================
67//function : MapShapesAndAncestors
68//purpose :
69//=======================================================================
70void BOPTools::MapShapesAndAncestors
71 (const TopoDS_Shape& S,
72 const TopAbs_ShapeEnum TS,
73 const TopAbs_ShapeEnum TA,
74 BOPCol_IndexedDataMapOfShapeListOfShape& aMEF)
75{
76 TopExp_Explorer aExS, aExA;
77 //
78 // visit ancestors
79 aExA.Init(S, TA);
80 while (aExA.More()) {
81 // visit shapes
82 const TopoDS_Shape& aF = aExA.Current();
83 //
84 aExS.Init(aF, TS);
85 while (aExS.More()) {
86 const TopoDS_Shape& aE= aExS.Current();
87 if (aMEF.Contains(aE)) {
88 aMEF.ChangeFromKey(aE).Append(aF);
89 }
90 else {
91 BOPCol_ListOfShape aLS;
92 aLS.Append(aF);
93 aMEF.Add(aE, aLS);
94 }
95 aExS.Next();
96 }
97 aExA.Next();
98 }
99 //
100 // visit shapes not under ancestors
101 aExS.Init(S, TS, TA);
102 while (aExS.More()) {
103 const TopoDS_Shape& aE=aExS.Current();
104 BOPCol_ListOfShape aLS;
105 aMEF.Add(aE, aLS);
106 aExS.Next();
107 }
108}