a5a63a5e3a5fc43f32fa51921e21b659541fe188
[occt.git] / src / ShapeFix / ShapeFix_Wire.cdl
1 -- Created on: 1998-06-03
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 class Wire from ShapeFix inherits Root from ShapeFix
18
19     ---Purpose: This class provides a set of tools for repairing a wire.
20     --
21     --          These are methods Fix...(), organised in two levels:
22     --
23     -- Level 1: Advanced - each method in this level fixes one separate problem, 
24     --          usually dealing with either single edge or connection of the
25     --          two adjacent edges. These methods should be used carefully and
26     --          called in right sequence, because some of them depend on others.
27     --
28     -- Level 2: Public (API) - methods which group several methods of level 1 
29     --          and call them in a proper sequence in order to make some 
30     --          consistent set of fixes for a whole wire. It is possible to 
31     --          control calls to methods of the advanced level from methods of 
32     --          the public level by use of flags Fix..Mode() (see below).
33     --
34     --          Fixes can be made in three ways:
35     --       1. Increasing tolerance of an edge or a vertex
36     --       2. Changing topology (adding/removing/replacing edge in the wire
37     --          and/or replacing the vertex in the edge)
38     --       3. Changing geometry (shifting vertex or adjusting ends of edge
39     --          curve to vertices, or recomputing curves of the edge)
40     --
41     --          When fix can be made in more than one way (e.g., either
42     --          by increasing tolerance or shifting a vertex), it is choosen
43     --          according to the flags:
44     --          ModifyTopologyMode - allows modification of the topology.
45     --                               This flag can be set when fixing a wire on 
46     --                               the separate (free) face, and should be
47     --                               unset for face which is part of shell.
48     --          ModifyGeometryMode - allows modification of the geometry.
49     --
50     --          The order of descriptions of Fix() methods in this CDL 
51     --          approximately corresponds to the optimal order of calls.
52     --
53     --          NOTE: most of fixing methods expect edges in the 
54     --          ShapeExtend_WireData to be ordered, so it is necessary to make
55     --          call to FixReorder() before any other fixes
56     --
57     --          ShapeFix_Wire should be initialized prior to any fix by the 
58     --          following data:
59     --          a) Wire (ether TopoDS_Wire or ShapeExtend_Wire)
60     --          b) Face or surface
61     --          c) Precision
62     --          This can be done either by calling corresponding methods
63     --          (LoadWire, SetFace or SetSurface, and SetPrecision), or
64     --          by loading already filled ShapeAnalisis_Wire with method Load
65
66 uses 
67
68     Surface   from Geom,
69     Face      from TopoDS,
70     Vertex    from TopoDS, 
71     Wire      from TopoDS, 
72     Location  from TopLoc,
73     WireData  from ShapeExtend, 
74     Status    from ShapeExtend,
75     Wire      from ShapeAnalysis,
76     WireOrder from ShapeAnalysis,
77     Edge      from ShapeFix
78
79 is
80
81     Create returns Wire from ShapeFix;
82         ---Purpose: Empty Constructor, creates clear object with default flags
83
84     Create (wire: Wire from TopoDS; face: Face from TopoDS; prec: Real)
85     returns Wire from ShapeFix;
86         ---Purpose: Create new object with default flags and prepare it for use
87         --          (Loads analyzer with all the data for the wire and face)
88
89     --- Loading and extracting the wire and other working data:
90
91     ClearModes (me: mutable);
92         ---Purpose: Sets all modes to default
93
94     ClearStatuses (me: mutable);
95         ---Purpose: Clears all statuses
96     
97     Init (me: mutable; wire: Wire from TopoDS; 
98                       face: Face from TopoDS; prec: Real);
99         ---Purpose: Load analyzer with all the data for the wire and face
100         --          and drops all fixing statuses 
101
102     Init (me: mutable; saw: Wire from ShapeAnalysis);
103         ---Purpose: Load analyzer with all the data already prepared
104         --          and drops all fixing statuses 
105         --          If analyzer contains face, there is no need to set it
106         --          by SetFace or SetSurface
107
108     Load (me: mutable; wire: Wire from TopoDS);
109         ---Purpose: Load data for the wire, and drops all fixing statuses
110         ---Note   : It is necessary to set face or surface for the wire before fixes
111     
112     Load (me: mutable; sbwd: WireData from ShapeExtend);
113         ---Purpose: Load data for the wire, and drops all fixing statuses
114         ---Note   : It is necessary to set face or surface for the wire before fixes
115     
116     SetFace (me: mutable; face: Face from TopoDS);
117         ---C++: inline
118         ---Purpose: Set working face for the wire
119     
120     SetSurface (me: mutable; surf: Surface from Geom);
121         ---C++: inline
122         ---Purpose: Set surface for the wire
123         ---Remark : This function creates new face and calls SetFace
124     
125     SetSurface (me: mutable; surf: Surface from Geom; 
126                             loc: Location from TopLoc);
127         ---C++: inline
128         ---Purpose: Set surface for the wire
129         ---Remark : This function creates new face and calls SetFace
130     
131     SetPrecision (me: mutable; prec: Real) is redefined;
132         ---Purpose: Set working precision (to root and to analyzer)
133
134     IsLoaded (me) returns Boolean;
135         ---C++: inline
136         ---Purpose: Tells if the wire is loaded 
137         ---Remark:  returns myAnalyzer.IsLoadaed()
138
139     IsReady (me) returns Boolean;
140         ---C++: inline
141         ---Purpose: Tells if the wire and face are loaded 
142         ---Remark:  returns myAnalyzer.IsReady()
143
144     NbEdges (me) returns Integer;
145         ---Purpose: returns number of edges in the working wire
146         ---Remark:  returns myAnalyzer.NbEdges()
147
148     Wire (me) returns Wire from TopoDS;
149         ---C++: inline
150         ---Purpose: Makes the resulting Wire (by basic Brep_Builder)
151         ---Remark:  returns myAnalyzer.Wire()
152
153     WireAPIMake (me) returns Wire from TopoDS;
154         ---C++: inline
155         ---Purpose: Makes the resulting Wire (by BRepAPI_MakeWire)
156         ---Remark:  returns myAnalyzer.WireAPIMake()
157
158     Analyzer (me) returns Wire from ShapeAnalysis;
159         ---Purpose: returns field Analyzer (working tool)
160
161     WireData (me) returns WireData from ShapeExtend;
162         ---C++: inline
163         ---C++: return const &
164         ---Purpose: returns working wire
165         ---Remark:  calls Analyzer.WireData()
166
167     Face (me) returns Face from TopoDS;
168         ---C++: inline
169         ---C++: return const &
170         ---Purpose: returns working face (Analyzer.Face())
171
172     --- Parameters:
173
174     ModifyTopologyMode (me: mutable) returns Boolean;
175         ---C++: inline
176         ---C++: return &
177         ---Purpose: Returns (modifiable) the flag which defines whether it is 
178         --          allowed to modify topology of the wire during fixing
179         --          (adding/removing edges etc.)
180         ---Use    : This flag can be set to True for wire on separate (free) face.
181         --          It should be set to False if the wire is on face which is a part
182         --          of a shell.
183         ---Default: False
184
185     ModifyGeometryMode (me: mutable) returns Boolean;
186         ---C++: inline
187         ---C++: return &
188         ---Purpose: Returns (modifiable) the flag which defines whether the Fix..()
189         --          methods are allowed to modify geometry of the edges and vertices
190         ---Default: True
191         ---Remark : Currently is not used
192
193     ModifyRemoveLoopMode (me: mutable) returns Integer;
194         ---C++: inline
195         ---C++: return &
196         ---Purpose: Returns (modifiable) the flag which defines whether the Fix..()
197         --          methods are allowed to modify RemoveLoop of the edges 
198         ---Default: -1
199         ---Remark : Currently is not used
200
201     ClosedWireMode (me: mutable) returns Boolean;
202         ---C++: inline
203         ---C++: return &
204         ---Purpose: Returns (modifiable) the flag which defines whether the wire
205         --          is to be closed (by calling methods like FixDegenerated() 
206         --          and FixConnected() for last and first edges). 
207         ---Use    : This flag should be set to False if wire is not a face boundary 
208         --          but is a (not closed) curve on a face.
209         ---Default: True
210
211     PreferencePCurveMode (me: mutable) returns Boolean;
212         ---C++: inline
213         ---C++: return &
214         ---Purpose: Returns (modifiable) the flag which defines whether the 2d (True)
215         --          representation of the wire is preferable over 3d one (in the 
216         --          case of ambiguity in FixEdgeCurves).
217         ---Default: True (means that 2d representation is preferable).
218         ---Remark : Currently is not used
219
220     FixGapsByRangesMode (me: mutable) returns Boolean;
221         ---C++: inline
222         ---C++: return &
223         ---Purpose: Returns (modifiable) the flag which defines whether tool
224         --          tries to fix gaps first by changing curves ranges (i.e.
225         --          using intersection, extrema, projections) or not.
226         ---Default: False (means that tool will only bend curves).
227         ---Remark : Currently is not used
228
229     --- Flags:
230
231     --- Level: Public (API)
232     --         These flags are only used in Perform()
233     FixReorderMode (me: mutable) returns Integer;
234         ---C++: inline
235         ---C++: return &
236     FixSmallMode (me: mutable) returns Integer;
237         ---C++: inline
238         ---C++: return &
239     FixConnectedMode (me: mutable) returns Integer;
240         ---C++: inline
241         ---C++: return &
242     FixEdgeCurvesMode (me: mutable) returns Integer;
243         ---C++: inline
244         ---C++: return &
245     FixDegeneratedMode (me: mutable) returns Integer;
246         ---C++: inline
247         ---C++: return &
248     FixSelfIntersectionMode (me: mutable) returns Integer;
249         ---C++: inline
250         ---C++: return &
251     FixLackingMode (me: mutable) returns Integer;
252         ---C++: inline
253         ---C++: return &
254     FixGaps3dMode (me: mutable) returns Integer;
255         ---C++: inline
256         ---C++: return &
257     FixGaps2dMode (me: mutable) returns Integer;
258         ---C++: inline
259         ---C++: return &
260         ---Purpose: Returns (modifiable) the flag for corresponding Fix..() method
261         --          which defines whether this method will be called from the
262         --          method APIFix():
263         --       -1 default
264         --        1 method will be called
265         --        0 method will not be called
266
267     --- Level: Advanced: 
268     --         These flags are only used in FixEdgeCurves() and FixSelfIntersection()
269     --         For FixEdgeCurves():
270     FixReversed2dMode (me: mutable) returns Integer;
271         ---C++: inline
272         ---C++: return &
273     FixRemovePCurveMode (me: mutable) returns Integer;
274         ---C++: inline
275         ---C++: return &
276     FixAddPCurveMode (me: mutable) returns Integer;
277         ---C++: inline
278         ---C++: return &
279     FixRemoveCurve3dMode (me: mutable) returns Integer;
280         ---C++: inline
281         ---C++: return &
282     FixAddCurve3dMode (me: mutable) returns Integer;
283         ---C++: inline
284         ---C++: return &
285     FixSeamMode (me: mutable) returns Integer;
286         ---C++: inline
287         ---C++: return &
288     FixShiftedMode (me: mutable) returns Integer;
289         ---C++: inline
290         ---C++: return &
291     FixSameParameterMode (me: mutable) returns Integer;
292         ---C++: inline
293         ---C++: return &
294     FixVertexToleranceMode (me: mutable) returns Integer;
295         ---C++: inline
296         ---C++: return &
297     --         For FixSelfIntersection():
298     FixNotchedEdgesMode (me: mutable) returns Integer;
299         ---C++: inline
300         ---C++: return &
301     FixSelfIntersectingEdgeMode (me: mutable) returns Integer;
302         ---C++: inline
303         ---C++: return &
304     FixIntersectingEdgesMode (me: mutable) returns Integer;
305         ---C++: inline
306         ---C++: return &
307     FixNonAdjacentIntersectingEdgesMode (me: mutable) returns Integer;
308         ---C++: inline
309         ---C++: return &    
310         ---Purpose: Returns (modifiable) the flag for corresponding Fix..() method
311         --          which defines whether this method will be called from the 
312         --          corresponding Fix..() method of the public level:
313         --       -1 default
314         --        1 method will be called
315         --        0 method will not be called
316
317     --- Fixing methods:
318     
319     --- Level: Public (API)
320
321     Perform (me: mutable) returns Boolean;
322         ---Purpose: This method performs all the available fixes.
323         --          If some fix is turned on or off explicitly by the Fix..Mode() flag,
324         --          this fix is either called or not depending on that flag.
325         --          Else (i.e. if flag is default) fix is called depending on the 
326         --          situation: some fixes are not called or are limited if order of 
327         --          edges in the wire is not OK, or depending on modes
328         --
329         --          The order of the fixes and default behaviour of Perform() are:
330         --          FixReorder
331         --          FixSmall (with lockvtx true if ! TopoMode or if wire is not ordered)
332         --          FixConnected (if wire is ordered)
333         --          FixEdgeCurves (without FixShifted if wire is not ordered)
334         --          FixDegenerated (if wire is ordered)
335         --          FixSelfIntersection (if wire is ordered and ClosedMode is True)
336         --          FixLacking (if wire is ordered)
337         --
338         ---Returns: False if nothing done, else True
339         --          Use methods Status...() to investigate the results of calls to the
340         --          each fixing method. All statuses are dropped at the start of Perform().
341
342     FixReorder (me: mutable) returns Boolean;
343         ---Purpose: Performs an analysis and reorders edges in the wire using 
344         --          class WireOrder 
345         ---Returns: False if nothing to do, True if some edges were reordered
346         ---Status : See StatusReorder() for details
347         --          FAIL1 - ShapeAnalysis_WireOrder has detected several loops
348         --          FAIL2 - ShapeAnalysis_WireOrder failed (result is incorrect)
349         --          DONE1 - Reorder done OK
350         --          DONE2 - in addition to DONE1 - some gaps remain
351         --          DONE3 - in addition to DONE1 - some edges were reversed
352
353     FixSmall (me: mutable; lockvtx: Boolean; precsmall: Real = 0.0) 
354     returns Integer;
355         ---Purpose: Applies FixSmall(num) to all edges in the wire
356         ---Returns: True if some edges were removed, else False
357         ---Status : See StatusSmall() for details
358         --          OK   : Edge is not null-length
359         --          DONE1: Edge is null-length and has the same vertices at begin 
360         --                 and end; removed
361         --          DONE2: (only if lockvtx is False and ModifyTopologyMode is True)
362         --                 Edge is null-length and has different vertices at begin and end; 
363         --                 edge removed, and CheckConnected called for adjacent edges
364         --          FAIL1: Edge cannot be checked (no 3d curve and no pcurve)
365         --          FAIL2: Edge is null-length and has different vertices at begin 
366         --                 and end, and lockvtx is True or ModifyTopologyMode is False; 
367         --                 edge is not removed
368         --          FAIL3: In the case of DONE2, CheckConnected has failed
369
370     FixConnected (me: mutable; prec: Real = -1.0) returns Boolean;
371         ---Purpose: Applies FixConnected(num) to all edges in the wire
372         --          Connection between first and last edges is treated only if 
373         --          flag ClosedMode is True
374         --          If <prec> is -1 then MaxTolerance() is taken.
375         ---Returns: True if some vertices were replaced, False if OK or fail
376         ---Status : See StatusConnected() for details
377         --          OK   : If they are already the same, nothing done
378         --          DONE1: Absolutely confused (gp::Resolution), set the same
379         --          DONE2: Confused with Analyzer.Precision(), set the same
380         --          DONE3: Confused with <prec> but not Analyzer.Precision(), set the same
381         --          FAIL1: Not confused neither with prec nor Analyzer.Precision()
382     
383     FixEdgeCurves (me: mutable) returns Boolean;
384         ---Purpose: Groups the fixes dealing with 3d and pcurves of the edges.
385         --          The order of the fixes and the default behaviour are:
386         --          ShapeFix_Edge::FixReversed2d
387         --          ShapeFix_Edge::FixRemovePCurve (only if forced)
388         --          ShapeFix_Edge::FixAddPCurve
389         --          ShapeFix_Edge::FixRemoveCurve3d (only if forced)
390         --          ShapeFix_Edge::FixAddCurve3d
391         --          FixSeam,
392         --          FixShifted,
393         --          ShapeFix_Edge::FixSameParameter
394         ---Returns: False if nothing done, else True
395         ---Status : See StatusEdgeCurves() for details
396         --          OK - no problem was detected, nothing fixed
397         --          DONE1, FAIL1 - FixReversed2d was fixed and/or failed
398         --          DONE2, FAIL2 - FixRemovePCurve was fixed and/or failed
399         --          DONE3, FAIL3 - FixAddPCurve was fixed and/or failed
400         --          DONE4, FAIL4 - FixRemoveCurve3d was fixed and/or failed
401         --          DONE5, FAIL5 - FixAddCurve3d was fixed and/or failed
402         --          DONE6, FAIL6 - FixSeam was fixed and/or failed
403         --          DONE7, FAIL7 - FixShifted was fixed and/or failed
404         --          DONE8, FAIL8 - FixSameParameter or FixVertexTolerance were fixed and/or failed
405
406     FixDegenerated (me: mutable) returns Boolean;
407         ---Purpose: Applies FixDegenerated(num) to all edges in the wire
408         --          Connection between first and last edges is treated only if 
409         --          flag ClosedMode is True
410         ---Returns: True if at least one degenerated edge was fixed or added
411         ---Status : See StatusDegenerated() for details
412         --          OK   : Nothing done
413         --          FAIL1: Analysis has failed
414         --          DONE1: New degenerated edge was added
415         --          DONE2: Edge <num> was made degenerated
416     
417     FixSelfIntersection ( me: mutable ) returns Boolean;
418         ---Purpose: Applies FixSelfIntersectingEdge(num) and 
419         --          FixIntersectingEdges(num) to all edges in the wire and
420         --          FixIntersectingEdges(num1, num2) for all pairs num1 and num2
421         --          such that num2 >= num1 + 2
422         --          and removes wrong edges if any
423         ---Returns: True if something was fixed, else False
424         ---Status : See StatusSelfIntersection() for details
425         --          OK   : No intersection found
426         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
427         --          FAIL2: self-intersection was found, but not fixed because of 
428         --                 limit of increasing tolerance (MaxTolerance)
429         --          FAIL3: intercestion of non adjacent edges found, but not fixed 
430         --                 because of limit of increasing tolerance (MaxTolerance) 
431         --          DONE1: tolerance of vertex was increased to fix self-intersection
432         --          DONE2: vertex was moved to fix self-intersection
433         --          DONE3: some edges were removed because of intersection
434         --          DONE4: pcurve(s) was(were) modified
435         --          DONE5: non adjacent intersection fixed by increasing tolerance of
436         --                 vertex(vertices)
437         --          DONE6: tolerance of edge was increased to hide intersection
438         --          DONE7: range of some edges was decreased to avoid intersection
439
440     FixLacking (me: mutable; force: Boolean = Standard_False) returns Boolean;
441         ---Purpose: Applies FixLacking(num) to all edges in the wire
442         --          Connection between first and last edges is treated only if 
443         --          flag ClosedMode is True
444         --          If <force> is False (default), test for connectness is done with 
445         --          precision of vertex between edges, else it is done with minimal
446         --          value of vertex tolerance and Analyzer.Precision().
447         --          Hence, <force> will lead to inserting lacking edges in replacement
448         --          of vertices which have big tolerances.
449         ---Returns: True if lacking edge was fixed, else False.
450         ---Status : See StatusLacking() for more details
451         --          OK   : No problems detected
452         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
453         --          FAIL2: lacking edge not fixed because of 
454         --                 limit of increasing tolerance (MaxTolerance)
455         --          FAIL3: failed to build lacking edge (3d curve) 
456         --          DONE1: tolerance was increased to fix lacking edge
457         --          DONE2: lacking edge was inserted
458
459     FixClosed (me: mutable; prec: Real = -1.0) returns Boolean;
460         ---Purpose: Fixes a wire to be well closed
461         --          It performs FixConnected, FixDegenerated and FixLacking between
462         --          last and first edges (independingly on flag ClosedMode and modes
463         --          for these fixings)
464         --          If <prec> is -1 then MaxTolerance() is taken.
465         ---Returns: False if nothing done, else True
466         ---Status : See StatusClosed() for details
467         --          OK - no problem was detected, nothing fixed
468         --          DONE1, FAIL1 - FixConnected was fixed and/or failed
469         --          DONE2, FAIL2 - FixDegenerated was fixed and/or failed
470         --          DONE3, FAIL3 - FixLacking was fixed and/or failed
471
472     FixGaps3d (me: mutable) returns Boolean;
473         ---Purpose: Fixes gaps between ends of 3d curves on adjacent edges
474         --          myPrecision is used to detect the gaps.
475         ---Returns: False if nothing done, else True
476         ---Status : See StatusGaps3d() for details
477         --          OK - no problem was detected, nothing fixed
478         --          DONE1 - Some gaps in 3d were found and fixed
479         --          FAIL1 - There was no 3d curve found on some edges
480         --          FAIL2 - Method failed to fix some gaps
481
482     FixGaps2d (me: mutable) returns Boolean;
483         ---Purpose: Fixes gaps between ends of pcurves on adjacent edges
484         --          myPrecision is used to detect the gaps.
485         ---Returns: False if nothing done, else True
486         ---Status : See StatusGaps2d() for details
487         --          OK - no problem was detected, nothing fixed
488         --          DONE1 - Some gaps in 2d were found and fixed
489         --          FAIL1 - There was no pcurve found on some edges
490         --          FAIL2 - Method failed to fix some gaps
491
492     --- Level: Advanced
493     
494     ---Status: For analyzing the status of the last performed method use 
495     --         LastFixStatus(status)
496     --
497     --         All the Fix.. methods below return False if the problem was not 
498     --         fixed, in this case LastFixStatus contains either FAIL or OK.
499     --         If a method returns True the LastFixStatus contains DONE,
500     --         this means that some fix was made
501     --         For detailed meaning of Status see corresponding method.
502     
503     FixReorder (me: mutable; wi: in WireOrder from ShapeAnalysis) returns Boolean;
504         ---Purpose: Reorder edges in the wire as determined by WireOrder
505         --          that should be filled and computed before
506         ---Returns: False if nothing to do, True if some edges were reordered
507         ---Status : See LastFixStatus() for details
508         --          OK    - edges are ordered well
509         --          FAIL1 - WireOrder has detected several loops
510         --          FAIL2 - WireOrder is incorrect (wrong number of edges)
511         --          FAIL3 - WireOrder is incorrect 
512         --          DONE1 - reorder was performed successfully
513
514     FixSmall (me: mutable; num: Integer; lockvtx: Boolean; precsmall: Real)
515     returns Boolean;
516         ---Purpose: Fixes Null Length Edge to be removed
517         --          If an Edge has Null Length (regarding preci, or <precsmall>
518         --          - what is smaller), it should be removed
519         --          It can be with no problem if its two vertices are the same
520         --          Else, if lockvtx is False, it is removed and its end vertex
521         --          is put on the preceeding edge
522         --          But if lockvtx is True, this edge must be kept ...
523         ---Use    : Is to be used in the case if some edges can be too short, and 
524         --          should be removed (hence, if topology of the wire can be modified). 
525         --          It is recommended to call this method before FixIntersection()
526         --
527         ---Returns: True if null edge was removed, False if nothing done
528         ---Status : See LastFixStatus() for details
529         --          OK   : Edge is not null-length
530         --          DONE1: Edge is null-length and has the same vertices at begin 
531         --                 and end; removed
532         --          DONE2: (only if lockvtx is False and ModifyTopologyMode is True)
533         --                 Edge is null-length and has different vertices at begin and end; 
534         --                 edge removed, and CheckConnected called for adjacent edges
535         --          FAIL1: Edge cannot be checked (no 3d curve and no pcurve)
536         --          FAIL2: Edge is null-length and has different vertices at begin 
537         --                 and end, and lockvtx is True or ModifyTopologyMode is False; 
538         --                 edge is not removed
539         --          FAIL3: In the case of DONE2, CheckConnected has failed
540
541     FixConnected (me: mutable; num: Integer; prec: Real)
542     returns Boolean;
543         ---Purpose: Fixes connected edges (preceeding and current)
544         --          Forces Vertices (end of preceeding-begin of current) to be
545         --          the same one
546         --          Tests with starting preci or, if given greater, <prec>
547         --          If <prec> is -1 then MaxTolerance() is taken.
548         --
549         ---Use    : It is to be used if two consequent edges in the wire have not
550         --          the same common vertex, e.g., if wire was constructed from 
551         --          not connected edges or some operations like adding/removing an
552         --          edge were done.
553         --          While it may change vertices, it should not be
554         --          called in cases when vertices may not be changed ...
555         --
556         ---Remark : Replacement of vertices in the edges is made by copying these edges
557         --
558         ---Returns: False if edges are already connected (vertices are the same) or if
559         --          it is not possible to perform fix (edges have a gap more than <prec>); 
560         --          True if disconnected situation was fixed by producing a new Vertex 
561         --          at the middle of the former ones.
562         ---Status:
563         --          OK   : If they are already the same, nothing done
564         --          DONE1: Absolutely confused (gp::Resolution), set the same
565         --          DONE2: Confused with Analyzer.Precision(), set the same
566         --          DONE3: Confused with <prec> but not Analyzer.Precision(), set the same
567         --          FAIL1: Not confused neither with prec nor Analyzer.Precision()
568
569     FixSeam (me: mutable; num: Integer) returns Boolean;
570         ---Purpose: Fixes a seam edge
571         --          A Seam edge has two pcurves, one for forward. one for reversed
572         --          The forward pcurve must be set as first
573         --
574         --          NOTE that correct order of pcurves in the seam edge depends on
575         --          its orientation (i.e., on orientation of the wire, method of 
576         --          exploration of edges etc.).
577         --          Since wire represented by the ShapeExtend_WireData is always forward
578         --          (orientation is accounted by edges), it will work correct if:
579         --       1. Wire created from ShapeExtend_WireData with methods 
580         --          ShapeExtend_WireData::Wire..() is added into the FORWARD face 
581         --          (orientation can be applied later)
582         --       2. Wire is extracted from the face with orientation not composed
583         --          with orientation of the face
584         --
585         ---Use    : This operation should be called after reversing the wire if it 
586         --          contains seam edges. 
587         --
588         ---Returns: True if edge is a seam and its curves were fixed (reordered), else False
589         ---Status : See StatusSeam() for details
590         --          OK - edge is not a seam or has pcurves OK
591         --          DONE1 - seam pcurves were fixed
592
593     FixShifted (me: mutable) returns Boolean;
594         ---Purpose: Fixes edges which have pcurves shifted by whole parameter 
595         --          range on the closed surface (the case may occur if pcurve 
596         --          of edge was computed by projecting 3d curve, which goes 
597         --          along the seam). 
598         --          It compares each two consequent edges and tries to connect them 
599         --          if distance between ends is near to range of the surface.
600         --          It also can detect and fix the case if all pcurves are connected,
601         --          but lie out of parametric bounds of the surface.
602         --          In addition to FixShifted from ShapeFix_Wire, more
603         --          sophisticated check of degenerate points is performed,
604         --          and special cases like sphere given by two meridians 
605         --          are treated.
606         ---Use    : Is to be used if some pcurves were recomputed.
607         --          It is recommended to use it before FixDegenerated.
608         ---Returns: False if nothing done, else True
609         ---Status : See StatusShifted() for details
610         --          OK: If pcurves are OK
611         --          FAIL1: some pcurves are missing
612         --          DONE1: some pcurves were shifted in order to ensure connection 
613         --                 between edges
614         --          DONE2: all pcurves were shifted in order to be in the parametric 
615         --                 range of a surface
616
617     FixDegenerated (me: mutable; num: Integer) returns Boolean;
618         ---Purpose: Fixes Degenerated Edge
619         --          Checks an <num-th> edge or a point between <num>th-1 and <num>th
620         --          edges for a singularity on a supporting surface.
621         --          If singularity is detected, either adds new degenerated edge 
622         --          (before <num>th), or makes <num>th edge to be degenerated.
623         ---Use    : It is to be called for faces which lie on surfaces with 
624         --          singularities. 
625         --          It should be called after all pcurves are correctly computed.
626         ---Returns: False if nothing done, else True
627         ---Status : See LastFixStatus() for details
628         --          OK   : Nothing done
629         --          FAIL1: Analysis has failed
630         --          DONE1: New degenerated edge was added
631         --          DONE2: Edge <num> was made degenerated
632         --          DONE3: Edge <num> was incorrectly coded as degenerated, removed
633
634     FixSelfIntersectingEdge ( me: mutable; num: Integer )
635     returns Boolean is private;
636         ---Purpose: Detect and fix self-intersecting pcurve of edge <num>.
637         --          Fix is made by one of two methods:
638         --          - cut out the self-intersection loop on pcurve (thus 
639         --            producing C0 pcurve). This also increases tolerance of edge
640         --            in order to satisfy SameParameter requirement.
641         --          - increase tolerance of the vertex of edge nearest to the 
642         --            self-intersection point so that it comprises that point.
643         --          The first method is considered only if ModifyGeometryMode 
644         --          is True. In that case, the method which requires less 
645         --          increasing of tolerance is selected. 
646         ---Returns: True if it was done, else False
647         ---Status : See LastFixStatus() for details
648         --          OK   : Edge is not self-intersecting
649         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
650         --          FAIL2: self-intersection was found, but not fixed because of 
651         --                 limit of increasing tolerance (MaxTolerance)
652         --          DONE1: tolerance was increased to fix self-intersection
653         --          DONE4: pcurve was modified (self-intersection loop cutted out)
654
655     FixIntersectingEdges ( me: mutable; num: Integer )
656     returns Boolean is private;
657         ---Purpose: Test if two consequent edges are intersecting and fix it
658         --          by increasing of tolerance of vertex between edges,
659         --          shifting this vertex to the point of intersection,
660         --          cutting edges to the intersection point.
661         --          It also can give signal to remove edge if it whole is cut by
662         --          intersection (if flag ModifyTopologyMode is set).
663         --
664         ---Returns: False if nothing done, True if something was fixed.
665         ---Status : See LastFixStatus() for details
666         --          OK   : No intersection found
667         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
668         --          FAIL2: self-intersection was found, but not fixed because of 
669         --                 limit of increasing tolerance (MaxTolerance)
670         --          DONE1: tolerance was increased to fix self-intersection
671         --          DONE2: vertex was moved to fix self-intersection
672         --          DONE3: previous or
673         --          DONE4: current edge should be removed because of intersection
674         --          DONE6: tolerance of edge was increased to hide intersection
675         --          DONE7: range of some edges was decreased to avoid intersection
676
677     FixIntersectingEdges (me: mutable; num1  : Integer;
678                                       num2  : Integer)
679     returns Boolean is private;
680         ---Purpose: Tests if two edges <num1> and <num2> are intersecting and
681         --          fix intersection by increasing of tolerance of vertex
682         --          nearest to the point of intersection.
683         --
684         ---Returns: False if nothing done, True if something was fixed.
685         ---Status : See LastFixStatus() for details
686         --          OK   : No intersection found
687         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
688         --          FAIL2: self-intersection was found, but not fixed because of 
689         --                 limit of increasing tolerance (MaxTolerance)
690         --          DONE1: tolerance was increased to fix self-intersection
691     
692     FixLacking ( me: mutable; num: Integer; force: Boolean = Standard_False )
693     returns Boolean;
694         ---Purpose: Fixes Lacking Edge 
695         --          Test if two adjucent edges are disconnected in 2d (while 
696         --          connected in 3d), and in that case either increase tolerance 
697         --          of the vertex or add a new edge (straight in 2d space), in 
698         --          order to close wire in 2d.
699         --          Returns True if edge was added or tolerance was increased.
700         ---Algorithm:
701         --       1. Compute the 2d gap between edges and calculate a tolerance
702         --          which should have vertex in order to comprise the gap
703         --          (using GeomAdaptor_Surface); computed value is inctol
704         --       2. If inctol < tol of vertex, return False (everything is OK)
705         --       3. If inctol < Precision, just increase tolerance of vertex to inctol
706         --       4. Else (if both edges are not degenerated) try to add new edge 
707         --          with straight pcurve (in order to close the gap):
708         --       a) if flag MayEdit is False
709         --          1. if inctol < MaxTolerance, increase tolerance of vertex to inctol
710         --          2. else try to add degenerated edge (check that middle point of 
711         --             that pcurve is inside the vertex)
712         --       b) if MayEdit is True
713         --          1. try to replace big vertex with two new small vertices 
714         --             connected by new edge. This is made if there is a 3d space
715         --             between ends of adjacent edges.
716         --          2. if inctol < MaxTolerance, increase tolerance of vertex to inctol
717         --          3. else add either degenerated or closed edge (if middle point
718         --             of a pcurve of a new edge is inside the vertex, then
719         --             degenerated edge is added, else new edge is closed).
720         --       5. If new edge cannot be added, but inctol < MaxTolerance,
721         --          when increase tolerance of vertex to a value of inctol
722         --
723         ---Use    : This method should be used after all pcurves in the wire are 
724         --          correctly computed. It is not recommended to use this method 
725         --          after FixDegenerated() and before FixSelfIntersection().
726         --
727         ---Returns: False if nothing done, else True.
728         ---Status : See LastFixStatus() for more details
729         --          OK   : If nothing done
730         --          FAIL1: analysis failed (edge has no pcurve, or no vertices etc.)
731         --          FAIL2: lacking edge not fixed because of 
732         --                 limit of increasing tolerance (MaxTolerance)
733         --          FAIL3: failed to build lacking edge (3d curve) 
734         --          DONE1: tolerance was increased to fix lacking edge
735         --          DONE2: lacking edge was inserted
736         --          DONE3: (in addition to DONE2) inserted edge is degenerated
737         --          DONE4: (in addition to DONE2) inserted edge is closed
738         --          DONE5: pcurves of edges were bent (only if ModifyGeometry is True)
739     
740     FixNotchedEdges(me: mutable) returns Boolean;
741     
742     FixDummySeam(me: mutable; num: Integer) is private;
743
744     FixGap3d ( me: mutable; num: Integer; convert: Boolean = Standard_False )
745     returns Boolean;
746         ---Purpose: Fixes gap between ends of 3d curves on num-1 and num-th edges.
747         --          myPrecision is used to detect the gap.
748         --          If convert is True, converts curves to bsplines to bend.
749         ---Algorithm:
750         ---Returns: False if nothing done, else True
751         ---Status : See StatusGaps3d() for details
752         --          OK - no problem was detected, nothing fixed
753         --          DONE1 - A gap in 3d were found and fixed
754         --          FAIL1 - There was no 3d curve found on some edge
755         --          FAIL2 - Method failed to fix the gap
756
757     FixGap2d ( me: mutable; num: Integer; convert: Boolean = Standard_False )
758     returns Boolean;
759         ---Purpose: Fixes gap between ends of pcurves on num-1 and num-th edges.
760         --          myPrecision is used to detect the gap.
761         --          If convert is True, converts pcurves to bsplines to bend.
762         ---Algorithm:
763         ---Returns: False if nothing done, else True
764         ---Status : See StatusGaps2d() for details
765         --          OK - no problem was detected, nothing fixed
766         --          DONE1 - A gap in 2d were found and fixed
767         --          FAIL1 - There was no pcurve found on some edge
768         --          FAIL2 - Method failed to fix the gap
769
770     --- Result of fixes: 
771
772     StatusReorder          (me; status: Status from ShapeExtend) returns Boolean;
773         ---C++: inline
774     StatusSmall            (me; status: Status from ShapeExtend) returns Boolean;
775         ---C++: inline
776     StatusConnected        (me; status: Status from ShapeExtend) returns Boolean;
777         ---C++: inline
778     StatusEdgeCurves       (me; status: Status from ShapeExtend) returns Boolean;
779         ---C++: inline
780     StatusDegenerated      (me; status: Status from ShapeExtend) returns Boolean;
781         ---C++: inline
782     StatusSelfIntersection (me; status: Status from ShapeExtend) returns Boolean;
783         ---C++: inline
784     StatusLacking          (me; status: Status from ShapeExtend) returns Boolean;
785         ---C++: inline
786     StatusClosed           (me; status: Status from ShapeExtend) returns Boolean;
787         ---C++: inline
788     StatusGaps3d           (me; status: Status from ShapeExtend) returns Boolean;
789         ---C++: inline
790     StatusGaps2d           (me; status: Status from ShapeExtend) returns Boolean;
791         ---C++: inline
792     StatusNotches          (me; status: Status from ShapeExtend) returns Boolean;
793         ---C++: inline
794     StatusRemovedSegment   (me) returns Boolean;
795         ---C++: inline
796         ---Purpose: Querying the status of perfomed API fixing procedures
797         --          Each Status..() methods gives information about the last call to
798         --          the corresponding Fix..() method of API level:
799         --          OK  : no problems detected; nothing done
800         --          DONE: some problem(s) was(were) detected and successfully fixed
801         --          FAIL: some problem(s) cannot be fixed
802         ---Level  : Public (API)
803     LastFixStatus (me; status: Status from ShapeExtend) returns Boolean;                 
804         ---C++: inline
805         ---Purpose: Queries the status of last call to methods Fix... of 
806         --          advanced level
807         --          For details see corresponding methods; universal statuses are:
808         --          OK  : problem not detected; nothing done
809         --          DONE: problem was detected and successfully fixed
810         --          FAIL: problem cannot be fixed
811         ---Level  : Advanced
812         
813     FixEdgeTool (me) returns Edge from ShapeFix;
814         ---Purpose: Returns tool for fixing wires.
815         ---C++: inline
816
817     UpdateWire (me: mutable) is protected;
818         ---Purpose: Updates WireData if some replacements are made
819         --          This is necessary for wires (unlike other shape types)
820         --          since one edge can present in wire several times
821         
822 fields
823
824     myFixEdge : Edge from ShapeFix is protected;
825     myAnalyzer: Wire from ShapeAnalysis is protected; -- working analyzer
826
827     myGeomMode:        Boolean is protected; -- may change geometry
828     myTopoMode:        Boolean is protected; -- may change topology
829     myClosedMode:      Boolean is protected; -- should wire be closed?
830     myPreference2d:    Boolean is protected; -- is 2d representation of edge preferred
831     myFixGapsByRanges: Boolean is protected; -- try to fix gaps by changing curves ranges
832
833     myFixReversed2dMode:                    Integer is protected;
834     myFixRemovePCurveMode:                  Integer is protected;
835     myFixAddPCurveMode:                     Integer is protected;
836     myFixRemoveCurve3dMode:                 Integer is protected;
837     myFixAddCurve3dMode:                    Integer is protected;
838     myFixSeamMode:                          Integer is protected;
839     myFixShiftedMode:                       Integer is protected;
840     myFixSameParameterMode:                 Integer is protected;
841     myFixVertexToleranceMode:               Integer is protected;
842     myFixNotchedEdgesMode:                  Integer is protected;
843     myFixSelfIntersectingEdgeMode:          Integer is protected;
844     myFixIntersectingEdgesMode:             Integer is protected;
845     myFixNonAdjacentIntersectingEdgesMode:  Integer is protected;
846
847     myRemoveLoopMode:                       Integer is protected;
848       -- -1 - old variant (default)
849       --  0 - try remove both 2d loop and 3d loop
850       --  1 - try insert new vertex
851
852     myFixReorderMode:          Integer is protected;
853     myFixSmallMode:            Integer is protected;
854     myFixConnectedMode:        Integer is protected;
855     myFixEdgeCurvesMode:       Integer is protected;
856     myFixDegeneratedMode:      Integer is protected;
857     myFixSelfIntersectionMode: Integer is protected;
858     myFixLackingMode:          Integer is protected;
859     myFixGaps3dMode:           Integer is protected;
860     myFixGaps2dMode:           Integer is protected;
861   
862     myLastFixStatus:          Integer is protected; -- status of last fix of advanced level
863
864     -- statuses corresponding to API methods, queried by Status..(status) methods
865     myStatusReorder:          Integer is protected;    
866     myStatusSmall:            Integer is protected;    
867     myStatusConnected:        Integer is protected;    
868     myStatusEdgeCurves:       Integer is protected;    
869     myStatusDegenerated:      Integer is protected;    
870     myStatusClosed:           Integer is protected;    
871     myStatusSelfIntersection: Integer is protected; 
872     myStatusLacking:          Integer is protected;
873     myStatusGaps3d:           Integer is protected;
874     myStatusGaps2d:           Integer is protected;
875     myStatusRemovedSegment:   Boolean is protected;
876     myStatusNotches:          Integer is protected;
877 end Wire;