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
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 class Wire from ShapeFix inherits Root from ShapeFix
19 ---Purpose: This class provides a set of tools for repairing a wire.
21 -- These are methods Fix...(), organised in two levels:
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.
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).
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)
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.
50 -- The order of descriptions of Fix() methods in this CDL
51 -- approximately corresponds to the optimal order of calls.
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
57 -- ShapeFix_Wire should be initialized prior to any fix by the
59 -- a) Wire (ether TopoDS_Wire or ShapeExtend_Wire)
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
73 WireData from ShapeExtend,
74 Status from ShapeExtend,
75 Wire from ShapeAnalysis,
76 WireOrder from ShapeAnalysis,
81 Create returns Wire from ShapeFix;
82 ---Purpose: Empty Constructor, creates clear object with default flags
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)
89 --- Loading and extracting the wire and other working data:
91 ClearModes (me: mutable);
92 ---Purpose: Sets all modes to default
94 ClearStatuses (me: mutable);
95 ---Purpose: Clears all statuses
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
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
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
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
116 SetFace (me: mutable; face: Face from TopoDS);
118 ---Purpose: Set working face for the wire
120 SetSurface (me: mutable; surf: Surface from Geom);
122 ---Purpose: Set surface for the wire
123 ---Remark : This function creates new face and calls SetFace
125 SetSurface (me: mutable; surf: Surface from Geom;
126 loc: Location from TopLoc);
128 ---Purpose: Set surface for the wire
129 ---Remark : This function creates new face and calls SetFace
131 SetPrecision (me: mutable; prec: Real) is redefined;
132 ---Purpose: Set working precision (to root and to analyzer)
134 IsLoaded (me) returns Boolean;
136 ---Purpose: Tells if the wire is loaded
137 ---Remark: returns myAnalyzer.IsLoadaed()
139 IsReady (me) returns Boolean;
141 ---Purpose: Tells if the wire and face are loaded
142 ---Remark: returns myAnalyzer.IsReady()
144 NbEdges (me) returns Integer;
145 ---Purpose: returns number of edges in the working wire
146 ---Remark: returns myAnalyzer.NbEdges()
148 Wire (me) returns Wire from TopoDS;
150 ---Purpose: Makes the resulting Wire (by basic Brep_Builder)
151 ---Remark: returns myAnalyzer.Wire()
153 WireAPIMake (me) returns Wire from TopoDS;
155 ---Purpose: Makes the resulting Wire (by BRepAPI_MakeWire)
156 ---Remark: returns myAnalyzer.WireAPIMake()
158 Analyzer (me) returns Wire from ShapeAnalysis;
159 ---Purpose: returns field Analyzer (working tool)
161 WireData (me) returns WireData from ShapeExtend;
163 ---C++: return const &
164 ---Purpose: returns working wire
165 ---Remark: calls Analyzer.WireData()
167 Face (me) returns Face from TopoDS;
169 ---C++: return const &
170 ---Purpose: returns working face (Analyzer.Face())
174 ModifyTopologyMode (me: mutable) returns Boolean;
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
185 ModifyGeometryMode (me: mutable) returns Boolean;
188 ---Purpose: Returns (modifiable) the flag which defines whether the Fix..()
189 -- methods are allowed to modify geometry of the edges and vertices
191 ---Remark : Currently is not used
193 ModifyRemoveLoopMode (me: mutable) returns Integer;
196 ---Purpose: Returns (modifiable) the flag which defines whether the Fix..()
197 -- methods are allowed to modify RemoveLoop of the edges
199 ---Remark : Currently is not used
201 ClosedWireMode (me: mutable) returns Boolean;
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.
211 PreferencePCurveMode (me: mutable) returns Boolean;
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
220 FixGapsByRangesMode (me: mutable) returns Boolean;
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
231 --- Level: Public (API)
232 -- These flags are only used in Perform()
233 FixReorderMode (me: mutable) returns Integer;
236 FixSmallMode (me: mutable) returns Integer;
239 FixConnectedMode (me: mutable) returns Integer;
242 FixEdgeCurvesMode (me: mutable) returns Integer;
245 FixDegeneratedMode (me: mutable) returns Integer;
248 FixSelfIntersectionMode (me: mutable) returns Integer;
251 FixLackingMode (me: mutable) returns Integer;
254 FixGaps3dMode (me: mutable) returns Integer;
257 FixGaps2dMode (me: mutable) returns Integer;
260 ---Purpose: Returns (modifiable) the flag for corresponding Fix..() method
261 -- which defines whether this method will be called from the
264 -- 1 method will be called
265 -- 0 method will not be called
268 -- These flags are only used in FixEdgeCurves() and FixSelfIntersection()
269 -- For FixEdgeCurves():
270 FixReversed2dMode (me: mutable) returns Integer;
273 FixRemovePCurveMode (me: mutable) returns Integer;
276 FixAddPCurveMode (me: mutable) returns Integer;
279 FixRemoveCurve3dMode (me: mutable) returns Integer;
282 FixAddCurve3dMode (me: mutable) returns Integer;
285 FixSeamMode (me: mutable) returns Integer;
288 FixShiftedMode (me: mutable) returns Integer;
291 FixSameParameterMode (me: mutable) returns Integer;
294 FixVertexToleranceMode (me: mutable) returns Integer;
297 -- For FixSelfIntersection():
298 FixNotchedEdgesMode (me: mutable) returns Integer;
301 FixSelfIntersectingEdgeMode (me: mutable) returns Integer;
304 FixIntersectingEdgesMode (me: mutable) returns Integer;
307 FixNonAdjacentIntersectingEdgesMode (me: mutable) returns Integer;
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:
314 -- 1 method will be called
315 -- 0 method will not be called
319 --- Level: Public (API)
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
329 -- The order of the fixes and default behaviour of Perform() are:
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)
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().
342 FixReorder (me: mutable) returns Boolean;
343 ---Purpose: Performs an analysis and reorders edges in the wire using
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
353 FixSmall (me: mutable; lockvtx: Boolean; precsmall: Real = 0.0)
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
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
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()
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
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
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
413 -- FAIL1: Analysis has failed
414 -- DONE1: New degenerated edge was added
415 -- DONE2: Edge <num> was made degenerated
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
437 -- DONE6: tolerance of edge was increased to hide intersection
438 -- DONE7: range of some edges was decreased to avoid intersection
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
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
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
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
494 ---Status: For analyzing the status of the last performed method use
495 -- LastFixStatus(status)
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.
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
514 FixSmall (me: mutable; num: Integer; lockvtx: Boolean; precsmall: Real)
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()
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
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
541 FixConnected (me: mutable; num: Integer; prec: Real)
543 ---Purpose: Fixes connected edges (preceeding and current)
544 -- Forces Vertices (end of preceeding-begin of current) to be
546 -- Tests with starting preci or, if given greater, <prec>
547 -- If <prec> is -1 then MaxTolerance() is taken.
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
553 -- While it may change vertices, it should not be
554 -- called in cases when vertices may not be changed ...
556 ---Remark : Replacement of vertices in the edges is made by copying these edges
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.
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()
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
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
585 ---Use : This operation should be called after reversing the wire if it
586 -- contains seam edges.
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
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
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
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
614 -- DONE2: all pcurves were shifted in order to be in the parametric
615 -- range of a surface
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
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
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
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)
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).
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
677 FixIntersectingEdges (me: mutable; num1 : 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.
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
692 FixLacking ( me: mutable; num: Integer; force: Boolean = Standard_False )
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.
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
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().
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)
740 FixNotchedEdges(me: mutable) returns Boolean;
742 FixDummySeam(me: mutable; num: Integer) is private;
744 FixGap3d ( me: mutable; num: Integer; convert: Boolean = Standard_False )
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.
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
757 FixGap2d ( me: mutable; num: Integer; convert: Boolean = Standard_False )
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.
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
772 StatusReorder (me; status: Status from ShapeExtend) returns Boolean;
774 StatusSmall (me; status: Status from ShapeExtend) returns Boolean;
776 StatusConnected (me; status: Status from ShapeExtend) returns Boolean;
778 StatusEdgeCurves (me; status: Status from ShapeExtend) returns Boolean;
780 StatusDegenerated (me; status: Status from ShapeExtend) returns Boolean;
782 StatusSelfIntersection (me; status: Status from ShapeExtend) returns Boolean;
784 StatusLacking (me; status: Status from ShapeExtend) returns Boolean;
786 StatusClosed (me; status: Status from ShapeExtend) returns Boolean;
788 StatusGaps3d (me; status: Status from ShapeExtend) returns Boolean;
790 StatusGaps2d (me; status: Status from ShapeExtend) returns Boolean;
792 StatusNotches (me; status: Status from ShapeExtend) returns Boolean;
794 StatusRemovedSegment (me) returns Boolean;
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;
805 ---Purpose: Queries the status of last call to methods Fix... of
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
813 FixEdgeTool (me) returns Edge from ShapeFix;
814 ---Purpose: Returns tool for fixing wires.
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
824 myFixEdge : Edge from ShapeFix is protected;
825 myAnalyzer: Wire from ShapeAnalysis is protected; -- working analyzer
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
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;
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
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;
862 myLastFixStatus: Integer is protected; -- status of last fix of advanced level
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;