0031303: Different calculation of offset direction in Adaptor2d_OffsetCurve and Geom2...
[occt.git] / src / BRepFill / BRepFill_OffsetAncestors.cxx
CommitLineData
b311480e 1// Created on: 1995-09-01
2// Created by: Bruno DUMORTIER
3// Copyright (c) 1995-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 <BRepFill_OffsetAncestors.hxx>
19#include <BRepFill_OffsetWire.hxx>
20#include <StdFail_NotDone.hxx>
7fd59977 21#include <TopExp_Explorer.hxx>
42cf5bc1 22#include <TopoDS_Edge.hxx>
7fd59977 23#include <TopoDS_Face.hxx>
42cf5bc1 24#include <TopoDS_Shape.hxx>
7fd59977 25#include <TopTools_ListIteratorOfListOfShape.hxx>
26
27//=======================================================================
28//function : BRepFill_OffsetAncestors
29//purpose :
30//=======================================================================
7fd59977 31BRepFill_OffsetAncestors::BRepFill_OffsetAncestors()
32:myIsPerform(Standard_False)
33{
34}
35
36
37//=======================================================================
38//function : BRepFill_OffsetAncestors
39//purpose :
40//=======================================================================
41
42BRepFill_OffsetAncestors::BRepFill_OffsetAncestors
43(BRepFill_OffsetWire& Paral)
44{
45 Perform(Paral);
46}
47
48
49//=======================================================================
50//function : Perform
51//purpose :
52//=======================================================================
53
54void 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
85Standard_Boolean BRepFill_OffsetAncestors::IsDone() const
86{
87 return myIsPerform;
88}
89
90//=======================================================================
91//function : IsDone
92//purpose :
93//=======================================================================
94
95Standard_Boolean BRepFill_OffsetAncestors:: HasAncestor(const TopoDS_Edge& S1)
96const
97{
98 return myMap.IsBound(S1);
99}
100
101//=======================================================================
102//function : TopoDS_Shape&
103//purpose :
104//=======================================================================
105
106const TopoDS_Shape& BRepFill_OffsetAncestors::Ancestor(const TopoDS_Edge& S1)
107const
108{
2d2b3d53 109 StdFail_NotDone_Raise_if (!myIsPerform, "BRepFill_OffsetAncestors::Ancestor() - Perform() should be called before accessing results");
7fd59977 110 return myMap(S1);
111}