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