0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepOffsetAPI / BRepOffsetAPI_NormalProjection.hxx
1 // Created on: 1997-10-13
2 // Created by: Roman BORISOV
3 // Copyright (c) 1997-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_NormalProjection_HeaderFile
18 #define _BRepOffsetAPI_NormalProjection_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <BRepAlgo_NormalProjection.hxx>
25 #include <BRepBuilderAPI_MakeShape.hxx>
26 #include <Standard_Real.hxx>
27 #include <GeomAbs_Shape.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Boolean.hxx>
30 #include <TopTools_ListOfShape.hxx>
31 class Standard_ConstructionError;
32 class Standard_NoSuchObject;
33 class StdFail_NotDone;
34 class TopoDS_Shape;
35 class TopoDS_Edge;
36
37
38 //! A framework to define projection onto a shape
39 //! according to the normal from each point to be projected.
40 //! The target shape is a face, and the source shape is an edge or a wire.
41 //! The target face is considered to be a 2D surface.
42 class BRepOffsetAPI_NormalProjection  : public BRepBuilderAPI_MakeShape
43 {
44 public:
45
46   DEFINE_STANDARD_ALLOC
47
48   
49   //! Constructs an empty framework to define projection on
50   //! a shape according to the normal from each point to be
51   //! projected to the shape.
52   Standard_EXPORT BRepOffsetAPI_NormalProjection();
53   
54   //! Constructs a framework to define projection onto the
55   //! basis shape S according to the normal from each point
56   //! to be projected from the shape added to this framework by Add.
57   //! Default parameters of the algorithm: Tol3D = 1.e-04, Tol2D =sqr(tol3d)
58   //! , InternalContinuity = GeomAbs_C2, MaxDegree = 14, MaxSeg = 16.
59   Standard_EXPORT BRepOffsetAPI_NormalProjection(const TopoDS_Shape& S);
60   
61   //! Initializes the empty constructor framework with the shape S.
62   Standard_EXPORT void Init (const TopoDS_Shape& S);
63   
64   //! Adds the shape ToProj to the framework for calculation
65   //! of the projection by Compute3d.
66   //! ToProj is an edge or a wire and will be projected onto the basis shape.
67   //! Exceptions
68   //! Standard_ConstructionError if ToProj is not added.
69   Standard_EXPORT void Add (const TopoDS_Shape& ToProj);
70   
71   //! Sets the parameters  used  for computation
72   //! Tol3 is the requiered  tolerance between the  3d projected
73   //! curve  and     its    2d    representation
74   //! InternalContinuity  is the order of constraints
75   //! used for  approximation
76   //! MaxDeg and MaxSeg are the maximum degree and the maximum
77   //! number of segment for BSpline resulting of an approximation.
78   Standard_EXPORT void SetParams (const Standard_Real Tol3D, const Standard_Real Tol2D, const GeomAbs_Shape InternalContinuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSeg);
79   
80   //! Sets the maximum distance between target shape and
81   //! shape to project. If this condition is not satisfied then corresponding
82   //! part of solution is discarded.
83   //! if MaxDist < 0 then this method does not affect the algorithm
84   Standard_EXPORT void SetMaxDistance (const Standard_Real MaxDist);
85   
86   //! Manage  limitation  of  projected  edges.
87   Standard_EXPORT void SetLimit (const Standard_Boolean FaceBoundaries = Standard_True);
88   
89   //! Returns true if a 3D curve is computed. If not, false is
90   //! returned and an initial 3D curve is kept to build the resulting edges.
91   Standard_EXPORT void Compute3d (const Standard_Boolean With3d = Standard_True);
92   
93   //! Builds the result of the projection as a compound of
94   //! wires. Tries to build oriented wires.
95   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
96   
97   //! Returns true if the object was correctly built by the shape
98   //! construction algorithm.
99   //! If at the construction time of the shape, the algorithm
100   //! cannot be completed, or the original data is corrupted,
101   //! IsDone returns false and therefore protects the use of
102   //! functions to access the result of the construction
103   //! (typically the Shape function).
104   Standard_EXPORT Standard_Boolean IsDone() const Standard_OVERRIDE;
105   
106   //! Performs the projection.
107   //! The construction of the result is performed by Build.
108   //! Exceptions
109   //! StdFail_NotDone if the projection was not performed.
110   Standard_EXPORT const TopoDS_Shape& Projection() const;
111   
112   //! Returns the initial face corresponding to the projected edge E.
113   //! Exceptions
114   //! StdFail_NotDone if no face was found.
115   //! Standard_NoSuchObject if if a face corresponding to
116   //! E has already been found.
117   Standard_EXPORT const TopoDS_Shape& Couple (const TopoDS_Edge& E) const;
118   
119   //! Returns the  list   of shapes generated   from the
120   //! shape <S>.
121   Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
122   
123   //! Returns the initial edge corresponding to the edge E
124   //! resulting from the computation of the projection.
125   //! Exceptions
126   //! StdFail_NotDone if no edge was found.
127   //! Standard_NoSuchObject if an edge corresponding to
128   //! E has already been found.
129   Standard_EXPORT const TopoDS_Shape& Ancestor (const TopoDS_Edge& E) const;
130   
131   //! build the result as a list of wire if possible in --
132   //! a first returns a wire only if there is only a wire.
133   Standard_EXPORT Standard_Boolean BuildWire (TopTools_ListOfShape& Liste) const;
134
135
136
137
138 protected:
139
140
141
142
143
144 private:
145
146
147
148   BRepAlgo_NormalProjection myNormalProjector;
149
150
151 };
152
153
154
155
156
157
158
159 #endif // _BRepOffsetAPI_NormalProjection_HeaderFile