0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_MakeEvolved.cxx
1 // Created on: 1995-09-18
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.hxx>
19 #include <BRepOffsetAPI_MakeEvolved.hxx>
20 #include <gp_Ax3.hxx>
21 #include <TopoDS_Shape.hxx>
22 #include <TopoDS_Wire.hxx>
23 #include <TopoDS_Iterator.hxx>
24 #include <TopoDS.hxx>
25
26 static const TopTools_ListOfShape anEmptyList;
27
28 //=======================================================================
29 //function : Constructor
30 //purpose  : 
31 //=======================================================================
32 BRepOffsetAPI_MakeEvolved::BRepOffsetAPI_MakeEvolved()
33 {
34 }
35
36 //=======================================================================
37 //function : Constructor
38 //purpose  : 
39 //=======================================================================
40 BRepOffsetAPI_MakeEvolved::BRepOffsetAPI_MakeEvolved(const TopoDS_Shape&    Spine,
41                                                      const TopoDS_Wire&     Profil,
42                                                      const GeomAbs_JoinType Join,
43                                                      const Standard_Boolean AxeProf,
44                                                      const Standard_Boolean Solid,
45                                                      const Standard_Boolean ProfOnSpine,
46                                                      const Standard_Real    Tol,
47                                                      const Standard_Boolean theIsVolume,
48                                                      const Standard_Boolean theRunInParallel)
49   : myIsVolume (theIsVolume)
50 {
51   if (Spine.ShapeType() != TopAbs_WIRE && Spine.ShapeType() != TopAbs_FACE)
52   {
53     Standard_TypeMismatch::Raise ("BRepOffsetAPI_MakeEvolved: face or wire is expected as a spine");
54   }
55   if (theIsVolume)
56   {
57     myVolume.SetParallelMode(theRunInParallel);
58     TopoDS_Wire aSpine;
59     if (Spine.ShapeType() == TopAbs_WIRE)
60     {
61       aSpine = TopoDS::Wire(Spine);
62     }
63     else
64     {
65       aSpine = TopoDS::Wire(TopoDS_Iterator(Spine).Value());
66     }
67     myVolume.Perform(aSpine, Profil, Tol, Solid);
68     if (!myVolume.IsDone())
69     {
70       return;
71     }
72   }
73   else
74   {
75     gp_Ax3 Axis(gp::Origin(), gp::DZ(), gp::DX());
76
77     if (!AxeProf)
78     {
79       Standard_Boolean POS;
80       BRepFill::Axe(Spine, Profil, Axis, POS, Max(Tol, Precision::Confusion()));
81       if (ProfOnSpine && !POS) return;
82     }
83     if (Spine.ShapeType() == TopAbs_WIRE)
84     {
85       myEvolved.Perform(TopoDS::Wire(Spine), Profil, Axis, Join, Solid);
86     }
87     else
88     {
89       myEvolved.Perform(TopoDS::Face(Spine), Profil, Axis, Join, Solid);
90     }
91   }
92
93   Build();
94 }
95
96 //=======================================================================
97 //function : BRepFill_Evolved&
98 //purpose  : 
99 //=======================================================================
100
101 const BRepFill_Evolved& BRepOffsetAPI_MakeEvolved::Evolved() const
102 {
103   if (myIsVolume)
104   {
105     Standard_TypeMismatch::Raise ("BRepOffsetAPI_MakeEvolved: myEvolved is accessed while in volume mode");
106   }
107   return myEvolved;
108 }
109
110 //=======================================================================
111 //function : Build
112 //purpose  : 
113 //=======================================================================
114 void BRepOffsetAPI_MakeEvolved::Build(const Message_ProgressRange& /*theRange*/)
115 {
116   if (myEvolved.IsDone())
117   {
118     myShape = myEvolved.Shape();
119   }
120   else if (myVolume.IsDone())
121   {
122     myShape = myVolume.Shape();
123   }
124   
125   Done();
126 }
127
128 //=======================================================================
129 //function : Top
130 //purpose  : 
131 //=======================================================================
132 const TopoDS_Shape&  BRepOffsetAPI_MakeEvolved::Top() const 
133 {
134   return myEvolved.Top();
135 }
136
137 //=======================================================================
138 //function : Bottom
139 //purpose  : 
140 //=======================================================================
141 const TopoDS_Shape&  BRepOffsetAPI_MakeEvolved::Bottom() const 
142 {
143   return myEvolved.Bottom();
144 }
145
146 //=======================================================================
147 //function : GeneratedShapes
148 //purpose  : 
149 //=======================================================================
150 const TopTools_ListOfShape&
151         BRepOffsetAPI_MakeEvolved::GeneratedShapes(const TopoDS_Shape& SpineShape,
152                                                    const TopoDS_Shape& ProfShape) const 
153 {
154   if (!myEvolved.IsDone())
155     return anEmptyList;
156
157   return myEvolved.GeneratedShapes(SpineShape,ProfShape);
158 }