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