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