1 -- Created on: 1995-03-23
2 -- Created by: Jing Cheng MEI
3 -- Copyright (c) 1995-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 -- Modified Thu May 7 15:20:25 1998 by David Carbonel (dcl)
18 -- Little faces management.
19 -- Add of Cutting option.
20 -- Optimisation of cutting fonction
21 -- Modified Thu Jan 21 13:00:58 MET 1999 by Jing Cheng MEI
22 -- Nonmanifold processing
24 class Sewing from BRepBuilderAPI inherits TShared from MMgt
26 ---Purpose: Provides methods to
28 -- - identify possible contigous boundaries (for control
29 -- afterwards (of continuity: C0, C1, ...))
31 -- - assemble contigous shapes into one shape.
32 -- Only manifold shapes will be found. Sewing will not
33 -- be done in case of multiple edges.
35 -- For sewing, use this function as following:
36 -- - create an empty object
37 -- - default tolerance 1.E-06
38 -- - with face analysis on
39 -- - with sewing operation on
40 -- - set the cutting option as you need (default True)
41 -- - define a tolerance
42 -- - add shapes to be sewed -> Add
43 -- - compute -> Perfom
44 -- - output the resulted shapes
45 -- - output free edges if necessary
46 -- - output multiple edges if necessary
47 -- - output the problems if any
49 -- For control, use this function as following:
50 -- - create an empty object
51 -- - default tolerance 1.E-06
52 -- - with face analysis on
53 -- - with sewing operation on
54 -- - set the cutting option as you need (default True)
55 -- - define a tolerance to capture contigous boundaries
56 -- - set if necessary face analysis off
57 -- - set sewing operation off
58 -- - add shapes to be controlled -> Add
59 -- - compute -> Perfom
60 -- - output couples of connected edges (contigous) and
61 -- their original boundary for control
62 -- - output the problems if any
69 ListOfShape from TopTools,
70 MapOfShape from TopTools,
71 DataMapOfShapeShape from TopTools,
72 DataMapOfShapeListOfShape from TopTools,
73 IndexedMapOfShape from TopTools,
74 IndexedDataMapOfShapeShape from TopTools,
75 IndexedDataMapOfShapeListOfShape from TopTools,
76 SequenceOfShape from TopTools,
77 Array1OfShape from TopTools,
79 Array1OfInteger from TColStd,
80 Array1OfPnt from TColgp,
81 Array2OfPnt2d from TColgp,
82 Array1OfBoolean from TColStd,
83 Array1OfReal from TColStd,
84 IndexedMapOfInteger from TColStd,
91 ReShape from BRepTools,
92 SequenceOfInteger from TColStd,
93 SequenceOfReal from TColStd,
94 SequenceOfPnt from TColgp,
95 ProgressIndicator from Message
99 OutOfRange from Standard,
100 NoSuchObject from Standard
104 Create(tolerance: Real = 1.0e-06; -- tolerance of connexity
105 option1 : Boolean = Standard_True; -- option for sewing
106 option2 : Boolean = Standard_True; -- option for analysis of degenerated shapes
107 option3 : Boolean = Standard_True; -- option for cutting of free edges.
108 option4 : Boolean = Standard_False) -- option for non manifold processing
109 returns Sewing from BRepBuilderAPI;
110 ---Purpose: Creates an object with
111 -- tolerance of connexity
112 -- option for sewing (if false only control)
113 -- option for analysis of degenerated shapes
114 -- option for cutting of free edges.
115 -- option for non manifold processing
117 Init(me : mutable; tolerance: Real = 1.0e-06; -- tolerance of connexity
118 option1: Boolean = Standard_True; -- option for sewing
119 option2: Boolean = Standard_True; -- option for analysis of degenerated shapes
120 option3: Boolean = Standard_True; -- option for cutting free edge after first merging
121 -- This option can be set to False if no edge need to be cut.
122 option4: Boolean = Standard_False);-- option for non manifold processing
123 ---Purpose: initialize the parameters if necessary
125 Load(me : mutable; shape : Shape from TopoDS);
126 ---Purpose: Loades the context shape.
128 Add(me : mutable; shape : Shape from TopoDS);
129 ---Purpose: Defines the shapes to be sewed or controlled
131 Perform(me : mutable;
132 thePI : ProgressIndicator from Message = 0);
133 ---Purpose: Computing
134 -- thePI - progress indicator of algorithm
136 SewedShape(me) returns Shape from TopoDS;
137 ---C++: return const &
138 ---Purpose: Gives the sewed shape
139 -- a null shape if nothing constructed
140 -- may be a face, a shell, a solid or a compound
142 SetContext(me : mutable; theContext : ReShape from BRepTools);
143 ---Purpose: set context
145 GetContext(me) returns ReShape from BRepTools;
146 ---C++: return const &
147 ---Purpose: return context
149 NbFreeEdges(me) returns Integer;
150 ---Purpose: Gives the number of free edges (edge shared by one face)
152 FreeEdge(me; index: Integer) returns Edge from TopoDS
153 raises OutOfRange from Standard; -- raised if index < 1 or > NbFreeEdges
154 ---C++: return const &
155 ---Purpose: Gives each free edge
157 NbMultipleEdges(me) returns Integer;
158 ---Purpose: Gives the number of multiple edges
159 -- (edge shared by more than two faces)
161 MultipleEdge(me; index: Integer) returns Edge from TopoDS
162 raises OutOfRange from Standard; -- raised if index < 1 or > NbMultipleEdges
163 ---C++: return const &
164 ---Purpose: Gives each multiple edge
166 NbContigousEdges(me) returns Integer;
167 ---Purpose: Gives the number of contigous edges (edge shared by two faces)
169 ContigousEdge(me; index: Integer) returns Edge from TopoDS
170 raises OutOfRange from Standard; -- raised if index < 1 or > NbContigousEdges
171 ---C++: return const &
172 ---Purpose: Gives each contigous edge
174 ContigousEdgeCouple(me; index: Integer) returns ListOfShape from TopTools
175 raises OutOfRange from Standard; -- raised if index < 1 or > NbContigousEdges
176 ---C++: return const &
177 ---Purpose: Gives the sections (edge) belonging to a contigous edge
179 IsSectionBound(me; section: Edge from TopoDS) returns Boolean;
180 ---Purpose: Indicates if a section is bound (before use SectionToBoundary)
182 SectionToBoundary(me; section: Edge from TopoDS) returns Edge from TopoDS
183 raises NoSuchObject from Standard; -- raised if section has not been bound
184 ---C++: return const &
185 ---Purpose: Gives the original edge (free boundary) which becomes the
186 -- the section. Remember that sections constitute common edges.
187 -- This imformation is important for control because with
188 -- original edge we can find the surface to which the section
191 NbDegeneratedShapes(me) returns Integer;
192 ---Purpose: Gives the number of degenerated shapes
194 DegeneratedShape(me; index: Integer) returns Shape from TopoDS
195 raises OutOfRange from Standard; -- raised if index < 1 or > NbDegeneratedShapes
196 ---C++: return const &
197 ---Purpose: Gives each degenerated shape
199 IsDegenerated(me; shape: Shape from TopoDS) returns Boolean;
200 ---Purpose: Indicates if a input shape is degenerated
202 IsModified(me; shape: Shape from TopoDS) returns Boolean;
203 ---Purpose: Indicates if a input shape has been modified
205 Modified(me ; shape: Shape from TopoDS) returns Shape from TopoDS
206 raises NoSuchObject from Standard; -- raised if shape has not been modified
207 ---C++: return const &
208 ---Purpose: Gives a modifieded shape
210 IsModifiedSubShape(me; shape: Shape from TopoDS) returns Boolean;
211 ---Purpose: Indicates if a input subshape has been modified
213 ModifiedSubShape(me ; shape: Shape from TopoDS) returns Shape from TopoDS
214 raises NoSuchObject from Standard; -- raised if shape has not been modified
215 ---Purpose: Gives a modifieded subshape
218 ---Purpose: print the informations
220 NbDeletedFaces(me) returns Integer;
221 ---Purpose: Gives the number of deleted faces (faces smallest than tolerance)
223 DeletedFace(me; index: Integer) returns Face from TopoDS
224 raises OutOfRange from Standard; -- raised if index < 1 or > NbDeletedFaces
225 ---C++: return const &
226 ---Purpose: Gives each deleted face
228 WhichFace(me; theEdg: Edge from TopoDS; index: Integer = 1) returns Face from TopoDS;
229 ---Purpose: Gives a modified shape
231 SameParameterMode(me) returns Boolean;
233 ---Purpose: Gets same parameter mode.
235 SetSameParameterMode(me: in mutable; SameParameterMode : Boolean);
237 ---Purpose: Sets same parameter mode.
239 Tolerance(me) returns Real;
241 ---Purpose: Gives set tolerance.
243 SetTolerance(me: mutable; theToler : Real);
245 ---Purpose: Sets tolerance
246 MinTolerance(me) returns Real;
248 ---Purpose: Gives set min tolerance.
250 SetMinTolerance(me: mutable; theMinToler : Real);
252 ---Purpose: Sets min tolerance
254 MaxTolerance(me) returns Real;
256 ---Purpose: Gives set max tolerance
258 SetMaxTolerance(me:mutable; theMaxToler : Real);
260 ---Purpose: Sets max tolerance.
262 FaceMode(me) returns Boolean;
264 ---Purpose: Returns mode for sewing faces By default - true.
266 SetFaceMode(me: mutable; theFaceMode : Boolean);
268 ---Purpose: Sets mode for sewing faces By default - true.
270 FloatingEdgesMode(me) returns Boolean;
272 ---Purpose: Returns mode for sewing floating edges By default - false.
274 SetFloatingEdgesMode(me: mutable; theFloatingEdgesMode : Boolean);
276 ---Purpose: Sets mode for sewing floating edges By default - false.
278 -- CuttingFloatingEdgesMode(me) returns Boolean;
280 ---Purpose: Returns mode for cutting floating edges By default - false.
282 -- SetCuttingFloatingEdgesMode(me: mutable; theCuttingFloatingEdgesMode : Boolean);
284 ---Purpose: Sets mode for cutting floating edges By default - false.
286 LocalTolerancesMode(me) returns Boolean;
288 ---Purpose: Returns mode for accounting of local tolerances
289 -- of edges and vertices during of merging.
291 SetLocalTolerancesMode(me: mutable; theLocalTolerancesMode : Boolean);
293 ---Purpose: Sets mode for accounting of local tolerances
294 -- of edges and vertices during of merging
295 -- in this case WorkTolerance = myTolerance + tolEdge1+ tolEdg2;
297 SetNonManifoldMode(me: mutable; theNonManifoldMode : Boolean);
299 ---Purpose: Sets mode for non-manifold sewing.
301 NonManifoldMode(me) returns Boolean;
303 ---Purpose: Gets mode for non-manifold sewing.
304 -------------------------
305 --- INTERNAL FUCTIONS ---
306 -------------------------
308 Cutting(me : mutable;
309 thePI : ProgressIndicator from Message = 0) is protected;
310 ---Purpose: Performs cutting of sections
311 -- thePI - progress indicator of processing
313 Merging(me : mutable; passage : Boolean;
314 thePI : ProgressIndicator from Message = 0) is protected;
317 Edge1 : Edge from TopoDS;
318 Edge2 : Edge from TopoDS;
319 fase : Face from TopoDS)
320 returns Boolean is protected;
322 FindCandidates(me : mutable;
323 seqSections : in out SequenceOfShape from TopTools;
324 mapReference : in out IndexedMapOfInteger from TColStd;
325 seqCandidates : in out SequenceOfInteger from TColStd;
326 seqOrientations : in out SequenceOfInteger from TColStd)
327 returns Boolean is protected;
329 AnalysisNearestEdges(me : mutable;
330 sequenceSec : SequenceOfShape from TopTools;
331 seqIndCandidate : in out SequenceOfInteger from TColStd;
332 seqOrientations : in out SequenceOfInteger from TColStd;
333 evalDist : Boolean = Standard_True) is protected;
337 MergedNearestEdges(me : mutable;
338 edge : Shape from TopoDS;
339 SeqMergedEdge : in out SequenceOfShape from TopTools;
340 SeqMergedOri : in out SequenceOfInteger from TColStd)
341 returns Boolean is protected;
342 ---Purpose: Merged nearest edges.
344 EdgeProcessing(me : mutable;
345 thePI : ProgressIndicator from Message = 0) is protected;
347 CreateOutputInformations(me : mutable) is protected;
349 ---------------------------------
350 --- VIRTUAL INTERNAL FUCTIONS ---
351 ---------------------------------
353 IsUClosedSurface(me; surf : Surface from Geom; theEdge : Shape from TopoDS;
354 theloc : Location from TopLoc)
355 returns Boolean is virtual protected;
356 ---Purpose: Defines if surface is U closed.
358 IsVClosedSurface(me; surf : Surface from Geom; theEdge : Shape from TopoDS;
359 theloc : Location from TopLoc)
360 returns Boolean is virtual protected;
361 ---Purpose:Defines if surface is V closed.
363 FaceAnalysis(me : mutable;
364 thePI : ProgressIndicator from Message = 0) is virtual protected;
366 -- This method is called from Perform only
367 -- thePI - progress indicator of processing
369 FindFreeBoundaries(me : mutable) is virtual protected;
371 -- This method is called from Perform only
373 VerticesAssembling(me : mutable;
374 thePI : ProgressIndicator from Message = 0) is virtual protected;
376 -- This method is called from Perform only
377 -- thePI - progress indicator of processing
379 CreateSewedShape(me : mutable) is virtual protected;
381 -- This method is called from Perform only
383 GetFreeWires(me : mutable;
384 MapFreeEdges : in out MapOfShape from TopTools;
385 seqWires : in out SequenceOfShape from TopTools) is virtual protected;
386 ---Purpose: Get wire from free edges.
387 -- This method is called from EdgeProcessing only
390 sequenceSec : in out SequenceOfShape from TopTools;
391 secForward : in out Array1OfBoolean from TColStd;
392 tabAng : in out Array1OfReal from TColStd;
393 indRef : in Integer) is virtual protected;
395 -- This method is called from MergingOfSections only
397 EvaluateDistances(me;
398 sequenceSec : in out SequenceOfShape from TopTools;
399 secForward : in out Array1OfBoolean from TColStd;
400 tabAng : in out Array1OfReal from TColStd;
401 arrLen : in out Array1OfReal from TColStd;
402 tabMinDist : in out Array1OfReal from TColStd;
403 indRef : in Integer) is virtual protected;
405 -- This method is called from MergingOfSections only
408 CurvePtr : Curve from Geom2d;
409 FirstOnCurve : Real from Standard;
410 LastOnCurve : Real from Standard;
411 RequestedFirst : Real from Standard;
412 RequestedLast : Real from Standard)
413 returns Curve from Geom2d is virtual protected;
415 -- This method is called from SameParameterEdge only
417 SameParameter(me; edge : Edge from TopoDS) is virtual protected;
419 -- This method is called from SameParameterEdge only
421 SameParameterEdge(me : mutable;
422 edge : Shape from TopoDS;
423 seqEdges : SequenceOfShape from TopTools;
424 seqForward : SequenceOfInteger from TColStd;
425 mapMerged : in out MapOfShape from TopTools;
426 locReShape : ReShape from BRepTools)
427 returns Edge from TopoDS is virtual protected;
429 -- This method is called from Merging only
431 SameParameterEdge(me : mutable;
432 edge1 : Edge from TopoDS;
433 edge2 : Edge from TopoDS;
434 listFaces1 : ListOfShape from TopTools;
435 listFaces2 : ListOfShape from TopTools;
436 secForward : Boolean ;
437 whichSec : in out Integer;
438 firstCall : Boolean = Standard_True)
439 returns Edge from TopoDS is virtual protected;
441 -- This method is called from Merging only
443 ProjectPointsOnCurve(me;
444 arrPnt : Array1OfPnt from TColgp;
445 Crv : Curve from Geom;
446 first : Real from Standard;
447 last : Real from Standard;
448 arrDist : in out Array1OfReal from TColStd;
449 arrPara : in out Array1OfReal from TColStd;
450 arrProj : in out Array1OfPnt from TColgp;
451 isConsiderEnds : in Boolean from Standard) is protected;
452 ---Purpose: Projects points on curve
453 -- This method is called from Cutting only
455 CreateCuttingNodes(me : mutable;
456 MapVert : IndexedMapOfShape from TopTools;
457 bound : Shape from TopoDS;
458 vfirst : Shape from TopoDS;
459 vlast : Shape from TopoDS;
460 arrDist : Array1OfReal from TColStd;
461 arrPara : Array1OfReal from TColStd;
462 arrPnt : Array1OfPnt from TColgp;
463 seqNode : in out SequenceOfShape from TopTools;
464 seqPara : in out SequenceOfReal from TColStd) is virtual protected;
465 ---Purpose: Creates cutting vertices on projections
466 -- This method is called from Cutting only
468 CreateSections(me : mutable;
469 bound : Shape from TopoDS;
470 seqNode : SequenceOfShape from TopTools;
471 seqPara : SequenceOfReal from TColStd;
472 listEdge : in out ListOfShape from TopTools) is virtual protected;
473 ---Purpose: Performs cutting of bound
474 -- This method is called from Cutting only
476 SameParameterShape(me : mutable) is virtual protected;
477 ---Purpose: Makes all edges from shape same parameter
478 -- if SameParameterMode is equal to Standard_True
479 -- This method is called from Perform only
484 myTolerance : Real is protected;
485 mySewing : Boolean is protected;
486 myAnalysis : Boolean is protected;
487 myCutting : Boolean is protected;
488 -- Indicates if the cutting will be done or not.
489 -- Default value is true.
490 myNonmanifold : Boolean is protected;
491 myFaceMode : Boolean; -- Mode for sewing faces by default true
492 myFloatingEdgesMode : Boolean; -- Mode for sewing floating edges by default - false
493 -- myCuttingFloatingEdgesMode : Boolean; -- Mode for cutting of floating edges by default - false
494 mySameParameterMode : Boolean;
495 myLocalToleranceMode : Boolean;
497 myOldShapes : IndexedDataMapOfShapeShape from TopTools is protected;
498 -- input shape -> input shape after analysis
499 mySewedShape : Shape from TopoDS is protected;
500 -- contains the sewed shape
501 myDegenerated : IndexedMapOfShape from TopTools is protected;
502 -- contains all degenerated shapes
503 myFreeEdges : IndexedMapOfShape from TopTools is protected;
504 -- contains all free edges
505 -- (edge shared by only one face)
506 myMultipleEdges : IndexedMapOfShape from TopTools is protected;
507 -- contains all multiple edges
508 -- (edge shared by more than two faces)
509 myContigousEdges : IndexedDataMapOfShapeListOfShape from TopTools is protected;
510 -- contains all contigous edges
511 -- (edge shared by two faces) and a list of sections
512 -- (two edges) which constitute each contigous edge
513 myContigSecBound : DataMapOfShapeShape is protected;
514 -- for each section belong to a contigous edge
515 -- indicates its the original free boundary
518 -- OldShape : input shapes
519 -- Shape : input shapes after analysis
520 -- Bound : free boundaries
521 -- Section : free boundaries after cutting
522 -- Edge : connected sections become edge
523 -- - Free edge : edge shared by one face
524 -- - Contigous edge : edge shared by two faces
525 -- - Multiple edge : edge shared by more than two faces
526 -- Vertex : vertices on free boundaries
527 -- Node : assembled vertices become node
529 myNbShapes : Integer is protected; -- number of input shapes after analysis
530 myNbVertices : Integer is protected; -- number of nodes after assembling
531 myNbEdges : Integer is protected; -- number of edges after merging
533 myBoundFaces : IndexedDataMapOfShapeListOfShape from TopTools is protected;
534 -- for EACH bound contains a list of faces (REFERENCE map)
535 myBoundSections : DataMapOfShapeListOfShape from TopTools is protected;
536 -- for bound contains a list of cutting sections if any
537 --mySectionEdge : DataMapOfShapeShape from TopTools is protected;
538 -- for section contains a merged edge for this section
539 mySectionBound : DataMapOfShapeShape from TopTools is protected;
540 -- for EACH section contains its bound
541 myVertexNode : IndexedDataMapOfShapeShape from TopTools is protected;
542 -- for EACH original vertex contains a node
543 myVertexNodeFree : IndexedDataMapOfShapeShape from TopTools is protected;
544 -- for EACH floating vertex contains a node
545 myNodeSections : DataMapOfShapeListOfShape from TopTools is protected;
546 -- for EACH node contains a list of sections
547 myCuttingNode : DataMapOfShapeListOfShape from TopTools is protected;
548 -- nodes cutting edges
549 myLittleFace : IndexedMapOfShape from TopTools is protected;
550 -- Faces to be suppress because they are too little
551 myMinTolerance : Real;
553 myMaxTolerance : Real;
555 myShape : Shape from TopoDS is protected;
557 myReShape : ReShape from BRepTools is protected;
558 myMergedEdges : MapOfShape from TopTools;