0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepPrimAPI / BRepPrimAPI_MakeRevol.cxx
1 // Created on: 1993-10-14
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-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 // Modified by skv - Fri Mar  4 15:50:09 2005
18 // Add methods for supporting history.
19
20 #include <BRep_TEdge.hxx>
21 #include <BRepLib.hxx>
22 #include <BRepPrimAPI_MakeRevol.hxx>
23 #include <BRepSweep_Revol.hxx>
24 #include <gp_Ax1.hxx>
25 #include <TopExp_Explorer.hxx>
26 #include <TopoDS_Shape.hxx>
27
28 // perform checks on the argument
29 static const TopoDS_Shape& check(const TopoDS_Shape& S)
30 {
31  BRepLib::BuildCurves3d(S);
32    return S;
33 }
34
35 //=======================================================================
36 //function : BRepPrimAPI_MakeRevol
37 //purpose  : 
38 //=======================================================================
39
40 BRepPrimAPI_MakeRevol::BRepPrimAPI_MakeRevol(const TopoDS_Shape& S, 
41                                      const gp_Ax1& A, 
42                                      const Standard_Real D, 
43                                      const Standard_Boolean Copy) :
44        myRevol(check(S),A,D,Copy)
45 {
46   Build();
47 }
48
49
50 //=======================================================================
51 //function : BRepPrimAPI_MakeRevol
52 //purpose  : 
53 //=======================================================================
54
55 BRepPrimAPI_MakeRevol::BRepPrimAPI_MakeRevol(const TopoDS_Shape& S, 
56                                      const gp_Ax1& A, 
57                                      const Standard_Boolean Copy) :
58        myRevol(check(S),A,Copy)
59 {
60   Build();
61 }
62
63
64 //=======================================================================
65 //function : Revol
66 //purpose  : 
67 //=======================================================================
68
69 const BRepSweep_Revol&  BRepPrimAPI_MakeRevol::Revol() const 
70 {
71   return myRevol;
72 }
73
74
75 //=======================================================================
76 //function : Build
77 //purpose  : 
78 //=======================================================================
79
80 void  BRepPrimAPI_MakeRevol::Build()
81 {
82   myShape = myRevol.Shape();
83   Done();
84 // Modified by skv - Fri Mar  4 15:50:09 2005 Begin
85   myDegenerated.Clear();
86
87   TopExp_Explorer anExp(myShape, TopAbs_EDGE);
88
89   for (; anExp.More(); anExp.Next()) {
90     const TopoDS_Shape &anEdge = anExp.Current();
91     Handle(BRep_TEdge)  aTEdge = Handle(BRep_TEdge)::DownCast(anEdge.TShape());
92
93     if (aTEdge->Degenerated())
94       myDegenerated.Append(anEdge);
95   }
96 // Modified by skv - Fri Mar  4 15:50:09 2005 End
97 }
98
99
100 //=======================================================================
101 //function : FirstShape
102 //purpose  : 
103 //=======================================================================
104
105 TopoDS_Shape BRepPrimAPI_MakeRevol::FirstShape()
106 {
107   return myRevol.FirstShape();
108 }
109
110
111 //=======================================================================
112 //function : LastShape
113 //purpose  : 
114 //=======================================================================
115
116 TopoDS_Shape BRepPrimAPI_MakeRevol::LastShape()
117 {
118   return myRevol.LastShape();
119 }
120
121
122 //=======================================================================
123 //function : Generated
124 //purpose  : 
125 //=======================================================================
126
127 const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Generated (const TopoDS_Shape& S)
128 {
129   myGenerated.Clear();
130   if (!myRevol.Shape (S).IsNull())
131     myGenerated.Append (myRevol.Shape (S));
132   return myGenerated;
133 }
134
135
136 // Modified by skv - Fri Mar  4 15:50:09 2005 Begin
137
138 //=======================================================================
139 //function : FirstShape
140 //purpose  : This method returns the shape of the beginning of the revolution,
141 //           generated with theShape (subShape of the generating shape).
142 //=======================================================================
143
144 TopoDS_Shape BRepPrimAPI_MakeRevol::FirstShape(const TopoDS_Shape &theShape)
145 {
146   return myRevol.FirstShape(theShape);
147 }
148
149
150 //=======================================================================
151 //function : LastShape
152 //purpose  : This method returns the shape of the end of the revolution,
153 //           generated with theShape (subShape of the generating shape).
154 //=======================================================================
155
156 TopoDS_Shape BRepPrimAPI_MakeRevol::LastShape(const TopoDS_Shape &theShape)
157 {
158   return myRevol.LastShape(theShape);
159 }
160
161 //=======================================================================
162 //function : HasDegenerated
163 //purpose  : 
164 //=======================================================================
165
166 Standard_Boolean BRepPrimAPI_MakeRevol::HasDegenerated () const
167 {
168   return (!myDegenerated.IsEmpty());
169 }
170
171
172 //=======================================================================
173 //function : Degenerated
174 //purpose  : 
175 //=======================================================================
176
177 const TopTools_ListOfShape& BRepPrimAPI_MakeRevol::Degenerated () const
178 {
179   return myDegenerated;
180 }
181 // Modified by skv - Fri Mar  4 15:50:09 2005 End