0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / ShapeFix / ShapeFix_Edge.hxx
1 // Created on: 1998-06-17
2 // Created by: data exchange team
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 _ShapeFix_Edge_HeaderFile
18 #define _ShapeFix_Edge_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <MMgt_TShared.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <ShapeExtend_Status.hxx>
28 class ShapeConstruct_ProjectCurveOnSurface;
29 class TopoDS_Edge;
30 class TopoDS_Face;
31 class Geom_Surface;
32 class TopLoc_Location;
33 class ShapeAnalysis_Surface;
34 class ShapeBuild_ReShape;
35
36 class ShapeFix_Edge;
37 DEFINE_STANDARD_HANDLE(ShapeFix_Edge, MMgt_TShared)
38
39 //! Fixing invalid edge.
40 //! Geometrical and/or topological inconsistency:
41 //! - no 3d curve or pcurve,
42 //! - mismatching orientation of 3d curve and pcurve,
43 //! - incorrect SameParameter flag (curve deviation is greater than
44 //! edge tolerance),
45 //! - not adjacent curves (3d or pcurve) to the vertices.
46 class ShapeFix_Edge : public MMgt_TShared
47 {
48
49 public:
50
51   
52   //! Empty constructor
53   Standard_EXPORT ShapeFix_Edge();
54   
55   //! Returns the projector used for recomputing missing pcurves
56   //! Can be used for adjusting parameters of projector
57   Standard_EXPORT Handle(ShapeConstruct_ProjectCurveOnSurface) Projector();
58   
59   Standard_EXPORT Standard_Boolean FixRemovePCurve (const TopoDS_Edge& edge, const TopoDS_Face& face);
60   
61   //! Removes the pcurve(s) of the edge if it does not match the
62   //! vertices
63   //! Check is done
64   //! Use    : It is to be called when pcurve of an edge can be wrong
65   //! (e.g., after import from IGES)
66   //! Returns: True, if does not match, removed (status DONE)
67   //! False, (status OK) if matches or (status FAIL) if no pcurve,
68   //! nothing done
69   Standard_EXPORT Standard_Boolean FixRemovePCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location);
70   
71   //! Removes 3d curve of the edge if it does not match the vertices
72   //! Returns: True,  if does not match, removed (status DONE)
73   //! False, (status OK) if matches or (status FAIL) if no 3d curve,
74   //! nothing done
75   Standard_EXPORT Standard_Boolean FixRemoveCurve3d (const TopoDS_Edge& edge);
76   
77   //! See method below for information
78   Standard_EXPORT Standard_Boolean FixAddPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Boolean isSeam, const Standard_Real prec = 0.0);
79   
80   //! See method below for information
81   Standard_EXPORT Standard_Boolean FixAddPCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, const Standard_Boolean isSeam, const Standard_Real prec = 0.0);
82   
83   //! See method below for information
84   Standard_EXPORT Standard_Boolean FixAddPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Boolean isSeam, const Handle(ShapeAnalysis_Surface)& surfana, const Standard_Real prec = 0.0);
85   
86   //! Adds pcurve(s) of the edge if missing (by projecting 3d curve)
87   //! Parameter isSeam indicates if the edge is a seam.
88   //! The parameter <prec> defines the precision for calculations.
89   //! If it is 0 (default), the tolerance of the edge is taken.
90   //! Remark : This method is rather for internal use since it accepts parameter
91   //! <surfana> for optimization of computations
92   //! Use    : It is to be called after FixRemovePCurve (if removed) or in any
93   //! case when edge can have no pcurve
94   //! Returns: True if pcurve was added, else False
95   //! Status :
96   //! OK   : Pcurve exists
97   //! FAIL1: No 3d curve
98   //! FAIL2: fail during projecting
99   //! DONE1: Pcurve was added
100   //! DONE2: specific case of pcurve going through degenerated point on
101   //! sphere encountered during projection (see class
102   //! ShapeConstruct_ProjectCurveOnSurface for more info)
103   Standard_EXPORT Standard_Boolean FixAddPCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location, const Standard_Boolean isSeam, const Handle(ShapeAnalysis_Surface)& surfana, const Standard_Real prec = 0.0);
104   
105   //! Tries to build 3d curve of the edge if missing
106   //! Use    : It is to be called after FixRemoveCurve3d (if removed) or in any
107   //! case when edge can have no 3d curve
108   //! Returns: True if 3d curve was added, else False
109   //! Status :
110   //! OK   : 3d curve exists
111   //! FAIL1: BRepLib::BuildCurve3d() has failed
112   //! DONE1: 3d curve was added
113   Standard_EXPORT Standard_Boolean FixAddCurve3d (const TopoDS_Edge& edge);
114   
115   Standard_EXPORT Standard_Boolean FixVertexTolerance (const TopoDS_Edge& edge, const TopoDS_Face& face);
116   
117   //! Increases the tolerances of the edge vertices to comprise
118   //! the ends of 3d curve and pcurve on the given face
119   //! (first method) or all pcurves stored in an edge (second one)
120   //! Returns: True, if tolerances have been increased, otherwise False
121   //! Status:
122   //! OK   : the original tolerances have not been changed
123   //! DONE1: the tolerance of first vertex has been increased
124   //! DONE2: the tolerance of last  vertex has been increased
125   Standard_EXPORT Standard_Boolean FixVertexTolerance (const TopoDS_Edge& edge);
126   
127   Standard_EXPORT Standard_Boolean FixReversed2d (const TopoDS_Edge& edge, const TopoDS_Face& face);
128   
129   //! Fixes edge if pcurve is directed opposite to 3d curve
130   //! Check is done by call to the function
131   //! ShapeAnalysis_Edge::CheckCurve3dWithPCurve()
132   //! Warning: For seam edge this method will check and fix the pcurve in only
133   //! one direction. Hence, it should be called twice for seam edge:
134   //! once with edge orientation FORWARD and once with REVERSED.
135   //! Returns: False if nothing done, True if reversed (status DONE)
136   //! Status:  OK    - pcurve OK, nothing done
137   //! FAIL1 - no pcurve
138   //! FAIL2 - no 3d curve
139   //! DONE1 - pcurve was reversed
140   Standard_EXPORT Standard_Boolean FixReversed2d (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location);
141   
142   //! Tries to make edge SameParameter and sets corresponding
143   //! tolerance and SameParameter flag.
144   //! First, it makes edge same range if SameRange flag is not set.
145   //!
146   //! If flag SameParameter is set, this method calls the
147   //! function ShapeAnalysis_Edge::CheckSameParameter() that
148   //! calculates the maximal deviation of pcurves of the edge from
149   //! its 3d curve. If deviation > tolerance, the tolerance of edge
150   //! is increased to a value of deviation. If deviation < tolerance
151   //! nothing happens.
152   //!
153   //! If flag SameParameter is not set, this method chooses the best
154   //! variant (one that has minimal tolerance), either
155   //! a. only after computing deviation (as above) or
156   //! b. after calling standard procedure BRepLib::SameParameter
157   //! and computing deviation (as above). If <tolerance> > 0, it is
158   //! used as parameter for BRepLib::SameParameter, otherwise,
159   //! tolerance of the edge is used.
160   //!
161   //! Use    : Is to be called after all pcurves and 3d curve of the edge are
162   //! correctly computed
163   //! Remark : SameParameter flag is always set to True after this method
164   //! Returns: True, if something done, else False
165   //! Status : OK    - edge was initially SameParameter, nothing is done
166   //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
167   //! FAIL2 - BRepLib::SameParameter() has failed
168   //! DONE1 - tolerance of the edge was increased
169   //! DONE2 - flag SameParameter was set to True (only if
170   //! BRepLib::SameParameter() did not set it)
171   //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
172   //! DONE4 - not used anymore
173   //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
174   //! (only for edges with not set SameParameter)
175   Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge, const Standard_Real tolerance = 0.0);
176
177   //! Tries to make edge SameParameter and sets corresponding
178   //! tolerance and SameParameter flag.
179   //! First, it makes edge same range if SameRange flag is not set.
180   //!
181   //! If flag SameParameter is set, this method calls the
182   //! function ShapeAnalysis_Edge::CheckSameParameter() that
183   //! calculates the maximal deviation of pcurves of the edge from
184   //! its 3d curve. If deviation > tolerance, the tolerance of edge
185   //! is increased to a value of deviation. If deviation < tolerance
186   //! nothing happens.
187   //!
188   //! If flag SameParameter is not set, this method chooses the best
189   //! variant (one that has minimal tolerance), either
190   //! a. only after computing deviation (as above) or
191   //! b. after calling standard procedure BRepLib::SameParameter
192   //! and computing deviation (as above). If <tolerance> > 0, it is
193   //! used as parameter for BRepLib::SameParameter, otherwise,
194   //! tolerance of the edge is used.
195   //!
196   //! Use    : Is to be called after all pcurves and 3d curve of the edge are
197   //! correctly computed
198   //! Remark : SameParameter flag is always set to True after this method
199   //! Returns: True, if something done, else False
200   //! Status : OK    - edge was initially SameParameter, nothing is done
201   //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
202   //! FAIL2 - BRepLib::SameParameter() has failed
203   //! DONE1 - tolerance of the edge was increased
204   //! DONE2 - flag SameParameter was set to True (only if
205   //! BRepLib::SameParameter() did not set it)
206   //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
207   //! DONE4 - not used anymore
208   //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
209   //! (only for edges with not set SameParameter)
210   Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge,
211                                                      const TopoDS_Face& face,
212                                                      const Standard_Real tolerance = 0.0);
213   
214   //! Returns the status (in the form of True/False) of last Fix
215   Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const;
216
217   //! Sets context
218   Standard_EXPORT void SetContext (const Handle(ShapeBuild_ReShape)& context);
219
220   //! Returns context
221   Standard_EXPORT Handle(ShapeBuild_ReShape) Context() const;
222
223   DEFINE_STANDARD_RTTIEXT(ShapeFix_Edge,MMgt_TShared)
224
225 protected:
226
227   Handle(ShapeBuild_ReShape) myContext;
228   Standard_Integer myStatus;
229   Handle(ShapeConstruct_ProjectCurveOnSurface) myProjector;
230
231
232 private:
233
234
235
236
237 };
238
239
240
241
242
243
244
245 #endif // _ShapeFix_Edge_HeaderFile