0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_MakePipeShell.cxx
1 // Created on: 1998-04-08
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1998-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_PipeShell.hxx>
19 #include <BRepOffsetAPI_MakePipeShell.hxx>
20 #include <GeomFill_PipeError.hxx>
21 #include <gp_Ax2.hxx>
22 #include <gp_Dir.hxx>
23 #include <Law_Function.hxx>
24 #include <Standard_DomainError.hxx>
25 #include <Standard_NotImplemented.hxx>
26 #include <StdFail_NotDone.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopoDS_Vertex.hxx>
29 #include <TopoDS_Wire.hxx>
30
31 //=======================================================================
32 //function :
33 //purpose  : 
34 //=======================================================================
35 BRepOffsetAPI_MakePipeShell::BRepOffsetAPI_MakePipeShell(const TopoDS_Wire& Spine)
36                       
37
38 {
39   myPipe = new (BRepFill_PipeShell) (Spine);
40   SetTolerance();
41   SetTransitionMode();
42   NotDone();
43 }
44
45 //=======================================================================
46 //function : SetMode
47 //purpose  : 
48 //=======================================================================
49  void BRepOffsetAPI_MakePipeShell::SetMode(const Standard_Boolean IsFrenet) 
50 {
51   myPipe->Set(IsFrenet);
52 }
53
54 //=======================================================================
55 //function : SetDiscreteMode
56 //purpose  : 
57 //=======================================================================
58  void BRepOffsetAPI_MakePipeShell::SetDiscreteMode() 
59 {
60   myPipe->SetDiscrete();
61 }
62
63 //=======================================================================
64 //function : SetMode
65 //purpose  : 
66 //=======================================================================
67  void BRepOffsetAPI_MakePipeShell::SetMode(const gp_Ax2& Axe) 
68 {
69   myPipe->Set(Axe);
70 }
71
72 //=======================================================================
73 //function : SetMode
74 //purpose  : 
75 //=======================================================================
76  void BRepOffsetAPI_MakePipeShell::SetMode(const gp_Dir& BiNormal) 
77 {
78   myPipe->Set(BiNormal);
79 }
80
81 //=======================================================================
82 //function : SetMode
83 //purpose  : 
84 //=======================================================================
85  Standard_Boolean BRepOffsetAPI_MakePipeShell::SetMode(const TopoDS_Shape& SpineSupport) 
86 {
87   return myPipe->Set(SpineSupport);
88 }
89
90 //=======================================================================
91 //function : SetMode
92 //purpose  : 
93 //=======================================================================
94  void BRepOffsetAPI_MakePipeShell::SetMode(const TopoDS_Wire& AuxiliarySpine,
95                                            const Standard_Boolean CurvilinearEquivalence,
96                                            const BRepFill_TypeOfContact KeepContact) 
97 {
98    myPipe->Set(AuxiliarySpine, CurvilinearEquivalence, KeepContact);
99 }
100
101 //=======================================================================
102 //function :Add
103 //purpose  : 
104 //=======================================================================
105  void BRepOffsetAPI_MakePipeShell::Add(const TopoDS_Shape& Profile,
106                                        const Standard_Boolean WithContact,
107                                        const Standard_Boolean WithCorrection) 
108 {
109   myPipe->Add(Profile, WithContact, WithCorrection);
110 }
111
112 //=======================================================================
113 //function : Add
114 //purpose  : 
115 //=======================================================================
116  void BRepOffsetAPI_MakePipeShell::Add(const TopoDS_Shape& Profile,
117                                        const TopoDS_Vertex& Location,
118                                        const Standard_Boolean WithContact,
119                                        const Standard_Boolean WithCorrection) 
120 {
121   myPipe->Add(Profile, Location, WithContact, WithCorrection);
122 }
123
124 //=======================================================================
125 //function : SetLaw
126 //purpose  : 
127 //=======================================================================
128  void BRepOffsetAPI_MakePipeShell::SetLaw(const TopoDS_Shape& Profile,
129                                           const Handle(Law_Function)& L,
130                                           const Standard_Boolean WithContact,
131                                           const Standard_Boolean WithCorrection) 
132 {
133   myPipe->SetLaw(Profile, L, WithContact, WithCorrection);
134 }
135
136 //=======================================================================
137 //function : SetLaw
138 //purpose  : 
139 //=======================================================================
140  void BRepOffsetAPI_MakePipeShell::SetLaw(const TopoDS_Shape& Profile,
141                                           const Handle(Law_Function)& L,
142                                           const TopoDS_Vertex& Location,
143                                           const Standard_Boolean WithContact,
144                                           const Standard_Boolean WithCorrection) 
145 {
146   myPipe->SetLaw(Profile, L, Location, WithContact, WithCorrection);
147 }
148
149 //=======================================================================
150 //function : Delete
151 //purpose  : 
152 //=======================================================================
153
154 void BRepOffsetAPI_MakePipeShell::Delete( const TopoDS_Shape& Profile)
155 {
156   myPipe->DeleteProfile(Profile);
157 }
158
159
160 //=======================================================================
161 //function : IsReady
162 //purpose  : 
163 //=======================================================================
164  Standard_Boolean BRepOffsetAPI_MakePipeShell::IsReady() const
165 {
166   return myPipe->IsReady();
167 }
168
169 //=======================================================================
170 //function : GetStatus
171 //purpose  : 
172 //=======================================================================
173  BRepBuilderAPI_PipeError BRepOffsetAPI_MakePipeShell::GetStatus() const
174 {
175   BRepBuilderAPI_PipeError Status;
176   GeomFill_PipeError stat;
177   stat = myPipe->GetStatus();
178   switch (stat) {
179   case GeomFill_PipeOk :
180     {
181       Status = BRepBuilderAPI_PipeDone;
182       break;
183     }
184   case  GeomFill_PlaneNotIntersectGuide :
185     {
186       Status = BRepBuilderAPI_PlaneNotIntersectGuide;
187       break;
188     }
189   case  GeomFill_ImpossibleContact :
190     {
191       Status = BRepBuilderAPI_ImpossibleContact;
192       break;
193     }
194     default :
195       Status = BRepBuilderAPI_PipeNotDone; 
196   }
197   return Status;
198 }
199
200 //=======================================================================
201 //function : SetTolerance
202 //purpose  : 
203 //=======================================================================
204  void BRepOffsetAPI_MakePipeShell::SetTolerance(const Standard_Real Tol3d,
205                                          const Standard_Real BoundTol,
206                                          const Standard_Real TolAngular)
207 {
208  myPipe->SetTolerance(Tol3d, BoundTol, TolAngular);
209 }
210
211 //=======================================================================
212 //function : SetMaxDegree
213 //purpose  : 
214 //=======================================================================
215 void BRepOffsetAPI_MakePipeShell::SetMaxDegree(const Standard_Integer NewMaxDegree)
216 {
217   myPipe->SetMaxDegree(NewMaxDegree);
218 }
219
220 //=======================================================================
221 //function : SetMaxSegments
222 //purpose  : 
223 //=======================================================================
224 void BRepOffsetAPI_MakePipeShell::SetMaxSegments(const Standard_Integer NewMaxSegments)
225 {
226   myPipe->SetMaxSegments(NewMaxSegments);
227 }
228
229 //=======================================================================
230 //function : SetForceApproxC1
231 //purpose  : Set the flag that indicates attempt to approximate
232 //           a C1-continuous surface if a swept surface proved
233 //           to be C0.
234 //=======================================================================
235  void BRepOffsetAPI_MakePipeShell::SetForceApproxC1(const Standard_Boolean ForceApproxC1)
236 {
237   myPipe->SetForceApproxC1(ForceApproxC1);
238 }
239
240 //=======================================================================
241 //function : SetTransitionMode
242 //purpose  : 
243 //=======================================================================
244  void BRepOffsetAPI_MakePipeShell::SetTransitionMode(const BRepBuilderAPI_TransitionMode Mode)
245 {
246   myPipe->SetTransition( (BRepFill_TransitionStyle)Mode );
247 }
248
249 //=======================================================================
250 //function :Simulate
251 //purpose  : 
252 //=======================================================================
253  void BRepOffsetAPI_MakePipeShell::Simulate(const Standard_Integer N,
254                                      TopTools_ListOfShape& R) 
255 {
256  myPipe->Simulate(N, R); 
257 }
258
259 //=======================================================================
260 //function :Build() 
261 //purpose  : 
262 //=======================================================================
263  void BRepOffsetAPI_MakePipeShell::Build() 
264 {
265   Standard_Boolean Ok;
266   Ok = myPipe->Build();
267   if (Ok) {
268     myShape = myPipe->Shape();
269     Done();
270   }
271   else NotDone(); 
272 }
273
274 //=======================================================================
275 //function : MakeSolid
276 //purpose  : 
277 //=======================================================================
278  Standard_Boolean BRepOffsetAPI_MakePipeShell::MakeSolid() 
279 {
280   if (!IsDone()) throw StdFail_NotDone("BRepOffsetAPI_MakePipeShell::MakeSolid");
281   Standard_Boolean Ok;
282   Ok = myPipe->MakeSolid();
283   if (Ok) myShape = myPipe->Shape();
284   return Ok;
285 }
286
287 //=======================================================================
288 //function :FirstShape()
289 //purpose  : 
290 //=======================================================================
291  TopoDS_Shape BRepOffsetAPI_MakePipeShell::FirstShape() 
292 {
293   return myPipe->FirstShape();
294 }
295
296 //=======================================================================
297 //function : LastShape()
298 //purpose  : 
299 //=======================================================================
300  TopoDS_Shape BRepOffsetAPI_MakePipeShell::LastShape() 
301 {
302   return myPipe->LastShape();
303 }
304
305 //=======================================================================
306 //function : Generated
307 //purpose  : 
308 //=======================================================================
309 const TopTools_ListOfShape& 
310 BRepOffsetAPI_MakePipeShell::Generated(const TopoDS_Shape& S) 
311 {
312   myPipe->Generated(S, myGenerated);
313   return myGenerated;
314 }
315
316 //=======================================================================
317 //function : ErrorOnSurface
318 //purpose  : 
319 //=======================================================================
320
321 Standard_Real BRepOffsetAPI_MakePipeShell::ErrorOnSurface() const
322 {
323   return myPipe->ErrorOnSurface();
324 }