4c01e25192be77f38002e9d6eb7ed3f274ac46fb
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_MakePipeShell.hxx
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 #ifndef _BRepOffsetAPI_MakePipeShell_HeaderFile
18 #define _BRepOffsetAPI_MakePipeShell_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <BRepPrimAPI_MakeSweep.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <BRepFill_PipeShell.hxx>
27 #include <BRepFill_TypeOfContact.hxx>
28 #include <BRepBuilderAPI_PipeError.hxx>
29 #include <Standard_Real.hxx>
30 #include <Standard_Integer.hxx>
31 #include <BRepBuilderAPI_TransitionMode.hxx>
32 #include <TopTools_ListOfShape.hxx>
33 class Standard_DomainError;
34 class StdFail_NotDone;
35 class TopoDS_Wire;
36 class gp_Ax2;
37 class gp_Dir;
38 class TopoDS_Shape;
39 class TopoDS_Vertex;
40 class Law_Function;
41
42
43 //! This class provides for a framework to construct a shell
44 //! or a solid along a spine consisting in a wire.
45 //! To produce a solid, the initial wire must be closed.
46 //! Two approaches are used:
47 //! - definition by section
48 //! - by a section and a scaling law
49 //! - by addition of successive intermediary sections
50 //! - definition by sweep mode.
51 //! - pseudo-Frenet
52 //! - constant
53 //! - binormal constant
54 //! - normal defined by a surface support
55 //! - normal defined by a guiding contour.
56 //! The two global approaches can also be combined.
57 //! You can also close the surface later in order to form a solid.
58 //! Warning: some limitations exist
59 //! -- Mode with auxilary spine is incompatible with hometetic laws
60 //! -- Mode with auxilary spine and keep contact produce only CO surface.
61 class BRepOffsetAPI_MakePipeShell  : public BRepPrimAPI_MakeSweep
62 {
63 public:
64
65   DEFINE_STANDARD_ALLOC
66
67   
68   //! Constructs the shell-generating framework defined by the wire Spine.
69   //! Sets an sweep's mode
70   //! If no mode are setted, the mode use in MakePipe is used
71   Standard_EXPORT BRepOffsetAPI_MakePipeShell(const TopoDS_Wire& Spine);
72   
73   //! Sets a Frenet or a CorrectedFrenet trihedron
74   //! to  perform  the  sweeping
75   //! If IsFrenet is false, a corrected Frenet trihedron is used.
76   Standard_EXPORT void SetMode (const Standard_Boolean IsFrenet = Standard_False);
77   
78   //! Sets a Discrete trihedron
79   //! to  perform  the  sweeping
80   Standard_EXPORT void SetDiscreteMode();
81   
82   //! Sets  a  fixed  trihedron  to  perform  the  sweeping
83   //! all sections will be parallel.
84   Standard_EXPORT void SetMode (const gp_Ax2& Axe);
85   
86   //! Sets a fixed BiNormal  direction to perform the --
87   //! sweeping.   Angular   relations   beetween  the
88   //! section(s) and <BiNormal> will be constant
89   Standard_EXPORT void SetMode (const gp_Dir& BiNormal);
90   
91   //! Sets support to the spine to define the BiNormal of
92   //! the trihedron, like the normal  to the surfaces.
93   //! Warning:  To be effective, Each  edge of the <spine> must
94   //! have an representaion on one face of<SpineSupport>
95   Standard_EXPORT Standard_Boolean SetMode (const TopoDS_Shape& SpineSupport);
96   
97   //! Sets  an  auxiliary  spine  to  define  the Normal
98   //! For  each  Point  of  the  Spine  P,  an  Point  Q  is  evalued
99   //! on  <AuxiliarySpine>
100   //! If <CurvilinearEquivalence>
101   //! Q split <AuxiliarySpine> with  the  same  length ratio
102   //! than P split  <Spline>.
103   //! Else  the  plan  define  by  P  and  the  tangent  to  the  <Spine>
104   //! intersect <AuxiliarySpine> in Q.
105   //! If <KeepContact> equals BRepFill_NoContact: The Normal is defined
106   //! by the vector PQ.
107   //! If <KeepContact> equals BRepFill_Contact: The Normal is defined to
108   //! achieve that the sweeped section is in contact to the
109   //! auxiliarySpine. The width of section is constant all along the path.
110   //! In other words, the auxiliary spine lies on the swept surface,
111   //! but not necessarily is a boundary of this surface. However,
112   //! the auxiliary spine has to be close enough to the main spine
113   //! to provide intersection with any section all along the path.
114   //! If <KeepContact> equals BRepFill_ContactOnBorder: The auxiliary spine
115   //! becomes a boundary of the swept surface and the width of section varies
116   //! along the path.
117   //! Give section to sweep.
118   //! Possibilities are :
119   //! - Give one or sevral section
120   //! - Give one profile and an homotetic law.
121   //! - Automatic compute of correspondance beetween spine, and section
122   //! on the sweeped shape
123   //! - correspondance beetween spine, and section on the sweeped shape
124   //! defined by a vertex of the spine
125   Standard_EXPORT void SetMode (const TopoDS_Wire& AuxiliarySpine, const Standard_Boolean CurvilinearEquivalence, const BRepFill_TypeOfContact KeepContact = BRepFill_NoContact);
126   
127   //! Adds the section Profile to this framework. First and last
128   //! sections may be punctual, so the shape Profile may be
129   //! both wire and vertex. Correspondent point on spine is
130   //! computed automatically.
131   //! If WithContact is true, the section is translated to be in
132   //! contact with the spine.
133   //! If WithCorrection is true, the section is rotated to be
134   //! orthogonal to the spine?s tangent in the correspondent
135   //! point. This option has no sense if the section is punctual
136   //! (Profile is of type TopoDS_Vertex).
137   Standard_EXPORT void Add (const TopoDS_Shape& Profile, const Standard_Boolean WithContact = Standard_False, const Standard_Boolean WithCorrection = Standard_False);
138   
139   //! Adds the section Profile to this framework.
140   //! Correspondent point on the spine is given by Location.
141   //! Warning:
142   //! To be effective, it is not recommended to combine methods Add and SetLaw.
143   Standard_EXPORT void Add (const TopoDS_Shape& Profile, const TopoDS_Vertex& Location, const Standard_Boolean WithContact = Standard_False, const Standard_Boolean WithCorrection = Standard_False);
144   
145   //! Sets the evolution law defined by the wire Profile with
146   //! its position (Location, WithContact, WithCorrection
147   //! are the same options as in methods Add) and a
148   //! homotetic law defined by the function L.
149   //! Warning:
150   //! To be effective, it is not recommended to combine methods Add and SetLaw.
151   Standard_EXPORT void SetLaw (const TopoDS_Shape& Profile, const Handle(Law_Function)& L, const Standard_Boolean WithContact = Standard_False, const Standard_Boolean WithCorrection = Standard_False);
152   
153   //! Sets the evolution law defined by the wire Profile with
154   //! its position (Location, WithContact, WithCorrection
155   //! are the same options as in methods Add) and a
156   //! homotetic law defined by the function L.
157   //! Warning:
158   //! To be effective, it is not recommended to combine methods Add and SetLaw.
159   Standard_EXPORT void SetLaw (const TopoDS_Shape& Profile, const Handle(Law_Function)& L, const TopoDS_Vertex& Location, const Standard_Boolean WithContact = Standard_False, const Standard_Boolean WithCorrection = Standard_False);
160   
161   //! Removes the section Profile from this framework.
162   Standard_EXPORT void Delete (const TopoDS_Shape& Profile);
163   
164   //! Returns true if this tool object is ready to build the
165   //! shape, i.e. has a definition for the wire section Profile.
166   Standard_EXPORT Standard_Boolean IsReady() const;
167   
168   //! Get a status, when Simulate or Build failed.       It can be
169   //! BRepBuilderAPI_PipeDone,
170   //! BRepBuilderAPI_PipeNotDone,
171   //! BRepBuilderAPI_PlaneNotIntersectGuide,
172   //! BRepBuilderAPI_ImpossibleContact.
173   Standard_EXPORT BRepBuilderAPI_PipeError GetStatus() const;
174   
175   //! Sets the following tolerance values
176   //! - 3D tolerance Tol3d
177   //! - boundary tolerance BoundTol
178   //! - angular tolerance TolAngular.
179   Standard_EXPORT void SetTolerance (const Standard_Real Tol3d = 1.0e-4, const Standard_Real BoundTol = 1.0e-4, const Standard_Real TolAngular = 1.0e-2);
180   
181   //! Define the maximum V degree of resulting surface
182   Standard_EXPORT void SetMaxDegree (const Standard_Integer NewMaxDegree);
183   
184   //! Define the maximum number of spans in V-direction
185   //! on resulting surface
186   Standard_EXPORT void SetMaxSegments (const Standard_Integer NewMaxSegments);
187   
188   //! Set the flag that indicates attempt to approximate
189   //! a C1-continuous surface if a swept surface proved
190   //! to be C0.
191   Standard_EXPORT void SetForceApproxC1 (const Standard_Boolean ForceApproxC1);
192   
193   //! Sets the transition mode to manage discontinuities on
194   //! the swept shape caused by fractures on the spine. The
195   //! transition mode can be BRepBuilderAPI_Transformed
196   //! (default value), BRepBuilderAPI_RightCorner,
197   //! BRepBuilderAPI_RoundCorner:
198   //! -              RepBuilderAPI_Transformed:
199   //! discontinuities are treated by
200   //! modification of the sweeping mode. The
201   //! pipe is "transformed" at the fractures of
202   //! the spine. This mode assumes building a
203   //! self-intersected shell.
204   //! -              BRepBuilderAPI_RightCorner:
205   //! discontinuities are treated like right
206   //! corner. Two pieces of the pipe
207   //! corresponding to two adjacent
208   //! segments of the spine are extended
209   //! and intersected at a fracture of the spine.
210   //! -              BRepBuilderAPI_RoundCorner:
211   //! discontinuities are treated like round
212   //! corner. The corner is treated as rotation
213   //! of the profile around an axis which
214   //! passes through the point of the spine?s
215   //! fracture. This axis is based on cross
216   //! product of directions tangent to the
217   //! adjacent segments of the spine at their common point.
218   //! Warnings
219   //! The mode BRepBuilderAPI_RightCorner provides a
220   //! valid result if intersection of two pieces of the pipe
221   //! (corresponding to two adjacent segments of the spine)
222   //! in the neighborhood of the spine?s fracture is
223   //! connected and planar. This condition can be violated if
224   //! the spine is non-linear in some neighborhood of the
225   //! fracture or if the profile was set with a scaling law.
226   //! The last mode, BRepBuilderAPI_RoundCorner, will
227   //! assuredly provide a good result only if a profile was set
228   //! with option WithCorrection = True, i.e. it is strictly
229   //! orthogonal to the spine.
230   Standard_EXPORT void SetTransitionMode (const BRepBuilderAPI_TransitionMode Mode = BRepBuilderAPI_Transformed);
231   
232   //! Simulates the resulting shape by calculating its
233   //! cross-sections. The spine is devided by this
234   //! cross-sections into (NumberOfSection - 1) equal
235   //! parts, the number of cross-sections is
236   //! NumberOfSection. The cross-sections are wires and
237   //! they are returned in the list Result.
238   //! This gives a rapid preview of the resulting shape,
239   //! which will be obtained using the settings you have provided.
240   //! Raises  NotDone if  <me> it is not Ready
241   Standard_EXPORT void Simulate (const Standard_Integer NumberOfSection, TopTools_ListOfShape& Result);
242   
243   //! Builds the resulting shape (redefined from MakeShape).
244   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
245   
246   //! Transforms the sweeping Shell in Solid.
247   //! If a propfile is not closed returns False
248   Standard_EXPORT Standard_Boolean MakeSolid();
249   
250   //! Returns the  TopoDS  Shape of the bottom of the sweep.
251   Standard_EXPORT virtual TopoDS_Shape FirstShape() Standard_OVERRIDE;
252   
253   //! Returns the TopoDS Shape of the top of the sweep.
254   Standard_EXPORT virtual TopoDS_Shape LastShape() Standard_OVERRIDE;
255   
256   //! Returns a list of new shapes generated from the shape
257   //! S by the shell-generating algorithm.
258   //! This function is redefined from BRepOffsetAPI_MakeShape::Generated.
259   //! S can be an edge or a vertex of a given Profile (see methods Add).
260   Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
261   
262   Standard_EXPORT Standard_Real ErrorOnSurface() const;
263
264   //! Returns the list of original profiles
265   void Profiles(TopTools_ListOfShape& theProfiles)
266   {
267     myPipe->Profiles(theProfiles);
268   }
269
270
271
272 protected:
273
274
275
276
277
278 private:
279
280
281
282   Handle(BRepFill_PipeShell) myPipe;
283
284
285 };
286
287
288
289
290
291
292
293 #endif // _BRepOffsetAPI_MakePipeShell_HeaderFile