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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _ShapeFix_Edge_HeaderFile
18 #define _ShapeFix_Edge_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_Transient.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <ShapeExtend_Status.hxx>
28 class ShapeConstruct_ProjectCurveOnSurface;
32 class TopLoc_Location;
33 class ShapeAnalysis_Surface;
34 class ShapeBuild_ReShape;
36 // resolve name collisions with X11 headers
42 DEFINE_STANDARD_HANDLE(ShapeFix_Edge, Standard_Transient)
44 //! Fixing invalid edge.
45 //! Geometrical and/or topological inconsistency:
46 //! - no 3d curve or pcurve,
47 //! - mismatching orientation of 3d curve and pcurve,
48 //! - incorrect SameParameter flag (curve deviation is greater than
50 //! - not adjacent curves (3d or pcurve) to the vertices.
51 class ShapeFix_Edge : public Standard_Transient
58 Standard_EXPORT ShapeFix_Edge();
60 //! Returns the projector used for recomputing missing pcurves
61 //! Can be used for adjusting parameters of projector
62 Standard_EXPORT Handle(ShapeConstruct_ProjectCurveOnSurface) Projector();
64 Standard_EXPORT Standard_Boolean FixRemovePCurve (const TopoDS_Edge& edge, const TopoDS_Face& face);
66 //! Removes the pcurve(s) of the edge if it does not match the
69 //! Use : It is to be called when pcurve of an edge can be wrong
70 //! (e.g., after import from IGES)
71 //! Returns: True, if does not match, removed (status DONE)
72 //! False, (status OK) if matches or (status FAIL) if no pcurve,
74 Standard_EXPORT Standard_Boolean FixRemovePCurve (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location);
76 //! Removes 3d curve of the edge if it does not match the vertices
77 //! Returns: True, if does not match, removed (status DONE)
78 //! False, (status OK) if matches or (status FAIL) if no 3d curve,
80 Standard_EXPORT Standard_Boolean FixRemoveCurve3d (const TopoDS_Edge& edge);
82 //! See method below for information
83 Standard_EXPORT Standard_Boolean FixAddPCurve (const TopoDS_Edge& edge, const TopoDS_Face& face, const Standard_Boolean isSeam, const Standard_Real prec = 0.0);
85 //! See method below for information
86 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);
88 //! See method below for information
89 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);
91 //! Adds pcurve(s) of the edge if missing (by projecting 3d curve)
92 //! Parameter isSeam indicates if the edge is a seam.
93 //! The parameter <prec> defines the precision for calculations.
94 //! If it is 0 (default), the tolerance of the edge is taken.
95 //! Remark : This method is rather for internal use since it accepts parameter
96 //! <surfana> for optimization of computations
97 //! Use : It is to be called after FixRemovePCurve (if removed) or in any
98 //! case when edge can have no pcurve
99 //! Returns: True if pcurve was added, else False
101 //! OK : Pcurve exists
102 //! FAIL1: No 3d curve
103 //! FAIL2: fail during projecting
104 //! DONE1: Pcurve was added
105 //! DONE2: specific case of pcurve going through degenerated point on
106 //! sphere encountered during projection (see class
107 //! ShapeConstruct_ProjectCurveOnSurface for more info)
108 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);
110 //! Tries to build 3d curve of the edge if missing
111 //! Use : It is to be called after FixRemoveCurve3d (if removed) or in any
112 //! case when edge can have no 3d curve
113 //! Returns: True if 3d curve was added, else False
115 //! OK : 3d curve exists
116 //! FAIL1: BRepLib::BuildCurve3d() has failed
117 //! DONE1: 3d curve was added
118 Standard_EXPORT Standard_Boolean FixAddCurve3d (const TopoDS_Edge& edge);
120 Standard_EXPORT Standard_Boolean FixVertexTolerance (const TopoDS_Edge& edge, const TopoDS_Face& face);
122 //! Increases the tolerances of the edge vertices to comprise
123 //! the ends of 3d curve and pcurve on the given face
124 //! (first method) or all pcurves stored in an edge (second one)
125 //! Returns: True, if tolerances have been increased, otherwise False
127 //! OK : the original tolerances have not been changed
128 //! DONE1: the tolerance of first vertex has been increased
129 //! DONE2: the tolerance of last vertex has been increased
130 Standard_EXPORT Standard_Boolean FixVertexTolerance (const TopoDS_Edge& edge);
132 Standard_EXPORT Standard_Boolean FixReversed2d (const TopoDS_Edge& edge, const TopoDS_Face& face);
134 //! Fixes edge if pcurve is directed opposite to 3d curve
135 //! Check is done by call to the function
136 //! ShapeAnalysis_Edge::CheckCurve3dWithPCurve()
137 //! Warning: For seam edge this method will check and fix the pcurve in only
138 //! one direction. Hence, it should be called twice for seam edge:
139 //! once with edge orientation FORWARD and once with REVERSED.
140 //! Returns: False if nothing done, True if reversed (status DONE)
141 //! Status: OK - pcurve OK, nothing done
142 //! FAIL1 - no pcurve
143 //! FAIL2 - no 3d curve
144 //! DONE1 - pcurve was reversed
145 Standard_EXPORT Standard_Boolean FixReversed2d (const TopoDS_Edge& edge, const Handle(Geom_Surface)& surface, const TopLoc_Location& location);
147 //! Tries to make edge SameParameter and sets corresponding
148 //! tolerance and SameParameter flag.
149 //! First, it makes edge same range if SameRange flag is not set.
151 //! If flag SameParameter is set, this method calls the
152 //! function ShapeAnalysis_Edge::CheckSameParameter() that
153 //! calculates the maximal deviation of pcurves of the edge from
154 //! its 3d curve. If deviation > tolerance, the tolerance of edge
155 //! is increased to a value of deviation. If deviation < tolerance
158 //! If flag SameParameter is not set, this method chooses the best
159 //! variant (one that has minimal tolerance), either
160 //! a. only after computing deviation (as above) or
161 //! b. after calling standard procedure BRepLib::SameParameter
162 //! and computing deviation (as above). If <tolerance> > 0, it is
163 //! used as parameter for BRepLib::SameParameter, otherwise,
164 //! tolerance of the edge is used.
166 //! Use : Is to be called after all pcurves and 3d curve of the edge are
167 //! correctly computed
168 //! Remark : SameParameter flag is always set to True after this method
169 //! Returns: True, if something done, else False
170 //! Status : OK - edge was initially SameParameter, nothing is done
171 //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
172 //! FAIL2 - BRepLib::SameParameter() has failed
173 //! DONE1 - tolerance of the edge was increased
174 //! DONE2 - flag SameParameter was set to True (only if
175 //! BRepLib::SameParameter() did not set it)
176 //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
177 //! DONE4 - not used anymore
178 //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
179 //! (only for edges with not set SameParameter)
180 Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge, const Standard_Real tolerance = 0.0);
182 //! Tries to make edge SameParameter and sets corresponding
183 //! tolerance and SameParameter flag.
184 //! First, it makes edge same range if SameRange flag is not set.
186 //! If flag SameParameter is set, this method calls the
187 //! function ShapeAnalysis_Edge::CheckSameParameter() that
188 //! calculates the maximal deviation of pcurves of the edge from
189 //! its 3d curve. If deviation > tolerance, the tolerance of edge
190 //! is increased to a value of deviation. If deviation < tolerance
193 //! If flag SameParameter is not set, this method chooses the best
194 //! variant (one that has minimal tolerance), either
195 //! a. only after computing deviation (as above) or
196 //! b. after calling standard procedure BRepLib::SameParameter
197 //! and computing deviation (as above). If <tolerance> > 0, it is
198 //! used as parameter for BRepLib::SameParameter, otherwise,
199 //! tolerance of the edge is used.
201 //! Use : Is to be called after all pcurves and 3d curve of the edge are
202 //! correctly computed
203 //! Remark : SameParameter flag is always set to True after this method
204 //! Returns: True, if something done, else False
205 //! Status : OK - edge was initially SameParameter, nothing is done
206 //! FAIL1 - computation of deviation of pcurves from 3d curve has failed
207 //! FAIL2 - BRepLib::SameParameter() has failed
208 //! DONE1 - tolerance of the edge was increased
209 //! DONE2 - flag SameParameter was set to True (only if
210 //! BRepLib::SameParameter() did not set it)
211 //! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
212 //! DONE4 - not used anymore
213 //! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
214 //! (only for edges with not set SameParameter)
215 Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge,
216 const TopoDS_Face& face,
217 const Standard_Real tolerance = 0.0);
219 //! Returns the status (in the form of True/False) of last Fix
220 Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const;
223 Standard_EXPORT void SetContext (const Handle(ShapeBuild_ReShape)& context);
226 Standard_EXPORT Handle(ShapeBuild_ReShape) Context() const;
228 DEFINE_STANDARD_RTTIEXT(ShapeFix_Edge,Standard_Transient)
232 Handle(ShapeBuild_ReShape) myContext;
233 Standard_Integer myStatus;
234 Handle(ShapeConstruct_ProjectCurveOnSurface) myProjector;
250 #endif // _ShapeFix_Edge_HeaderFile