0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BOPTools / BOPTools.cxx
CommitLineData
4e57c75e 1// Created by: Peter KURNEV
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
4e57c75e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
4e57c75e 5//
d5f74e42 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
973c2be1 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.
4e57c75e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
4e57c75e 14
42cf5bc1 15
4e57c75e 16#include <BOPCol_ListOfShape.hxx>
42cf5bc1 17#include <BOPTools.hxx>
18#include <TopExp_Explorer.hxx>
19#include <TopoDS_Shape.hxx>
4e57c75e 20
21//=======================================================================
22//function : MapShapes
23//purpose :
24//=======================================================================
0090ae85 25void BOPTools::MapShapes(const TopoDS_Shape& S,
26 BOPCol_MapOfShape& M)
4e57c75e 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//=======================================================================
0090ae85 41void BOPTools::MapShapes(const TopoDS_Shape& S,
42 BOPCol_IndexedMapOfShape& M)
4e57c75e 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//=======================================================================
0090ae85 56void BOPTools::MapShapes(const TopoDS_Shape& S,
57 const TopAbs_ShapeEnum T,
58 BOPCol_IndexedMapOfShape& M)
4e57c75e 59{
60 TopExp_Explorer Ex(S,T);
61 while (Ex.More()) {
62 M.Add(Ex.Current());
63 Ex.Next();
64 }
65}
4e57c75e 66//=======================================================================
67//function : MapShapesAndAncestors
68//purpose :
69//=======================================================================
0090ae85 70void BOPTools::MapShapesAndAncestors
71 (const TopoDS_Shape& S,
72 const TopAbs_ShapeEnum TS,
73 const TopAbs_ShapeEnum TA,
74 BOPCol_IndexedDataMapOfShapeListOfShape& aMEF)
4e57c75e 75{
0090ae85 76 TopExp_Explorer aExS, aExA;
77 //
4e57c75e 78 // visit ancestors
0090ae85 79 aExA.Init(S, TA);
80 while (aExA.More()) {
4e57c75e 81 // visit shapes
0090ae85 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();
4e57c75e 96 }
0090ae85 97 aExA.Next();
4e57c75e 98 }
0090ae85 99 //
4e57c75e 100 // visit shapes not under ancestors
0090ae85 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();
4e57c75e 107 }
108}