0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / BRepFill / BRepFill_OffsetAncestors.cxx
1 // Created on: 1995-09-01
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRepFill_OffsetAncestors.hxx>
19 #include <BRepFill_OffsetWire.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <TopExp_Explorer.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopTools_ListIteratorOfListOfShape.hxx>
26
27 //=======================================================================
28 //function : BRepFill_OffsetAncestors
29 //purpose  : 
30 //=======================================================================
31 BRepFill_OffsetAncestors::BRepFill_OffsetAncestors()
32 :myIsPerform(Standard_False)
33 {
34 }
35
36
37 //=======================================================================
38 //function : BRepFill_OffsetAncestors
39 //purpose  : 
40 //=======================================================================
41
42 BRepFill_OffsetAncestors::BRepFill_OffsetAncestors
43 (BRepFill_OffsetWire& Paral)
44 {
45   Perform(Paral);
46 }
47
48
49 //=======================================================================
50 //function : Perform
51 //purpose  : 
52 //=======================================================================
53
54 void BRepFill_OffsetAncestors::Perform(BRepFill_OffsetWire& Paral)
55 {
56   TopoDS_Face Spine = Paral.Spine();
57   
58   TopExp_Explorer                    Exp;
59   TopTools_ListIteratorOfListOfShape it;
60
61   // on itere sur les edges.
62   for ( Exp.Init(Spine, TopAbs_EDGE); Exp.More(); Exp.Next()) {
63     for (it.Initialize(Paral.GeneratedShapes(Exp.Current()));
64          it.More(); it.Next()) {
65       myMap.Bind( it.Value(), Exp.Current());
66     }
67   }
68
69   // on itere sur les vertex.
70   for ( Exp.Init(Spine, TopAbs_VERTEX); Exp.More(); Exp.Next()) {
71     for (it.Initialize(Paral.GeneratedShapes(Exp.Current()));
72          it.More(); it.Next()) {
73       myMap.Bind( it.Value(), Exp.Current());
74     }
75   }
76
77   myIsPerform = Standard_True;
78 }
79
80 //=======================================================================
81 //function : IsDone
82 //purpose  : 
83 //=======================================================================
84
85 Standard_Boolean BRepFill_OffsetAncestors::IsDone() const
86 {
87   return myIsPerform;
88 }
89
90 //=======================================================================
91 //function : IsDone
92 //purpose  : 
93 //=======================================================================
94
95 Standard_Boolean BRepFill_OffsetAncestors:: HasAncestor(const TopoDS_Edge& S1)
96 const
97 {
98   return myMap.IsBound(S1);
99 }
100
101 //=======================================================================
102 //function : TopoDS_Shape&
103 //purpose  : 
104 //=======================================================================
105
106 const TopoDS_Shape& BRepFill_OffsetAncestors::Ancestor(const TopoDS_Edge& S1)
107 const
108 {
109   StdFail_NotDone_Raise_if (!myIsPerform, "BRepFill_OffsetAncestors::Ancestor() - Perform() should be called before accessing results");
110   return myMap(S1);
111 }