b224df2e7d7c8ef0f1470a8f546aafb43af866c4
[occt.git] / dox / user_guides / boolean_operations / boolean_operations.md
1 Boolean Operations {#occt_user_guides__boolean_operations}
2 =========================
3
4 @tableofcontents
5
6 @section occt_algorithms_1 Introduction
7
8 This document provides a comprehensive description of the Boolean Operation Algorithm (BOA) as it is  implemented in Open CASCADE Technology. The Boolean Component contains:
9
10 * General Fuse Operator (GFA), 
11 * Boolean Operator (BOA), 
12 * Section Operator (SA), 
13 * Splitter Operator (SPA). 
14
15 GFA is the base algorithm for BOA, SPA, SA.
16
17 GFA has a history-based architecture designed to allow using OCAF naming functionality. The architecture of GFA is expandable, that allows creating new algorithms basing on it.
18
19
20 @section occt_algorithms_2 Overview 
21
22 @subsection occt_algorithms_2_1 Operators
23
24 @subsubsection occt_algorithms_2_1_1 Boolean operator
25
26 The Boolean operator provides the operations (Common, Fuse, Cut) between two groups: *Objects* and *Tools*. Each group consists of an arbitrary number of arguments in terms of *TopoDS_Shape*.
27
28 The operator can be represented as:
29
30 <i>R<sub>B</sub>=B<sub>j</sub> (G<sub>1</sub>, G<sub>2</sub>),</i>      
31
32 where:
33 * *R<sub>B</sub>* -- result of the operation;
34 * *B<sub>j</sub>* -- operation of type *j* (Common, Fuse, Cut);
35 * *G<sub>1</sub>={S<sub>11</sub>, S<sub>12</sub> ... S<sub>1n1</sub>}*  group of arguments (Objects); 
36 * *G<sub>2</sub>={S<sub>21</sub>, S<sub>22</sub> ... S<sub>2n2</sub>}*  group of arguments (Tools);
37 * *n<sub>1</sub>* -- Number of arguments in *Objects* group; 
38 * *n<sub>2</sub>* -- Number of arguments in *Tools* group.
39
40
41 **Note** There is an operation *Cut21*, which is an extension for forward Cut operation, i.e <i>Cut21=Cut(G2, G1)</i>.
42
43 For more details see @ref occt_algorithms_9 "Boolean Operations Algorithm" section.
44
45 @subsubsection occt_algorithms_2_1_2 General Fuse operator
46
47 The General fuse operator can be applied to an arbitrary number of arguments in terms of *TopoDS_Shape*.
48
49 The GFA operator can be represented as:
50
51 <i>R<sub>GF</sub> = GF (S<sub>1</sub>, S<sub>2</sub> ... S<sub>n</sub>), </i>   
52
53 where
54 * *R<sub>GF</sub>* -- result of the operation,
55 * *S<sub>1</sub>, S<sub>2</sub> ... S<sub>n</sub>* -- arguments of the operation,
56 * *n* -- number of arguments.
57
58 The result of the Boolean operator, *R<sub>B</sub>*, can be obtained from *R<sub>GF</sub>*.
59
60 For example, for two arguments *S<sub>1</sub>* and *S<sub>2</sub>* the result *R<sub>GF</sub>* is
61
62 <i>R<sub>GF</sub> = GF (S<sub>1</sub>, S<sub>2</sub>) = S<sub>p1</sub> + S<sub>p2</sub> + S<sub>p12</sub></i>   
63
64 @figure{/user_guides/boolean_operations/images/operations_image001.svg,"Operators",320}
65
66 This Figure shows that 
67 * <i>B<sub>common</sub> (S<sub>1</sub>, S<sub>2</sub>) = S<sub>p12</sub>;</i>
68 * <i>B<sub>cut12</sub> (S<sub>1</sub>, S<sub>2</sub>) = S<sub>p1</sub>;</i>
69 * <i>B<sub>cut21</sub> (S<sub>1</sub>, S<sub>2</sub>) = S<sub>p2</sub>;</i>
70 * <i>B<sub>fuse</sub> (S<sub>1</sub>, S<sub>2</sub>) = S<sub>p1</sub>+S<sub>p2</sub>+S<sub>p12</sub></i>
71
72 <i>R<sub>GF</sub>=GF (S<sub>1</sub>, S<sub>2</sub>) = B<sub>fuse</sub> = B<sub>common</sub>+ B<sub>cut12</sub>+ B<sub>cut21</sub>.</i>
73
74 The fact that *R<sub>GF</sub>* contains the components of *R<sub>B</sub>* allows considering GFA as the general case of BOA. So it is possible to implement BOA as a subclass of GFA.
75
76 For more details see @ref occt_algorithms_7 "General Fuse Algorithm" section.
77
78 @subsubsection occt_algorithms_2_1_3 Splitter operator 
79
80 The Splitter operator can be applied to an arbitrary number of arguments in terms of *TopoDS_Shape*. The arguments are divided into two groups: *Objects* and *Tools*. The result of *SPA* contains all parts that belong to the *Objects* but does not contain the parts that belong to the *Tools*.
81
82 The *SPA* operator can be represented as follows:
83
84 <i>R<sub>SPA</sub>=SPA (G<sub>1</sub>, G<sub>2</sub>),</i>
85 where:
86 * <i>R<sub>SPA</sub></i> -- is the result of the operation; 
87 * *G<sub>1</sub>={S<sub>11</sub>, S<sub>12</sub> ... S<sub>1n1</sub>}*  group of arguments (*Objects*); 
88 * *G<sub>2</sub>={S<sub>21</sub>, S<sub>22</sub> ... S<sub>2n2</sub>}*  group of arguments (*Tools*);
89 * *n<sub>1</sub>* -- Number of arguments in *Objects* group; 
90 * *n<sub>2</sub>* -- Number of arguments in *Tools* group.
91
92 The result *R<sub>SPA</sub>* can be obtained from *R<sub>GF</sub>* .
93
94 For example, for two arguments *S<sub>1</sub>* and  *S<sub>2</sub>* the result *R<sub>SPA</sub>* is
95
96 <i>R<sub>SPA</sub>=SPA(S<sub>1</sub>,S<sub>2</sub>)=S<sub>p1</sub>+S<sub>p12</sub>.</i>      
97
98 In case when all arguments of the *SPA* are *Objects* and there are no *Tools*, the result of *SPA* is equivalent to the result of *GFA*. 
99
100 For example, when *G<sub>1</sub>* consists of shapes *S<sub>1</sub>* and *S<sub>2</sub>* the result of *SPA* is
101
102 <i>R<sub>SPA</sub>=SPA(S<sub>1</sub>, S<sub>2</sub>) = S<sub>p1</sub> + S<sub>p2</sub> + S<sub>p12</sub> = GF (S<sub>1</sub>, S<sub>2</sub>)</i>
103
104 The fact that the *R<sub>GF</sub>* contains the components of *R<sub>SPA</sub>* allows considering *GFA* as the general case of *SPA*. Thus, it is possible to implement *SPA* as a subclass of *GFA*.
105
106 For more details see @ref occt_algorithms_8 "Splitter Algorithm" section.
107
108 @subsubsection occt_algorithms_2_1_4 Section operator
109
110 The Section operator *SA* can be applied to arbitrary number of arguments in terms of *TopoDS_Shape*. The result of *SA* contains vertices and edges in accordance with interferences between the arguments 
111 The SA operator can be represented as follows:
112 <i>R<sub>SA</sub>=SA(S1, S2… Sn)</i>, where
113 * <i>R<sub>SA</sub></i> -- the operation result;
114 * <i>S1, S2 ... Sn</i> -- the operation arguments;
115 * *n* -- the number of arguments.
116
117 For more details see @ref occt_algorithms_10a "Section Algorithm" section.
118
119 @subsection occt_algorithms_2_2 Parts of algorithms 
120
121 GFA, BOA, SPA and SA have the same Data Structure (DS). The main goal of the Data Structure is to store all necessary information for input data and intermediate results.
122
123 The operators consist of two main parts:
124 *       Intersection Part (IP). The main goal of IP is to compute the interferences between sub-shapes of arguments. The IP uses DS to retrieve input data and store the results of intersections.
125 *       Building Part (BP). The main goal of BP is to build required result of an operation. This part also uses DS to retrieve data and store the results.
126
127 As it follows from the definition of operator results, the main differences between GFA, BOA, SPA and SA are in the Building Part. The Intersection Part is the same for the algorithms.
128
129 @section occt_algorithms_3 Terms and Definitions
130
131 This chapter provides the background terms and definitions that are necessary to understand how the algorithms work. 
132
133 @subsection occt_algorithms_3_1 Interferences
134
135 There are two groups of interferences.
136
137 At first, each shape having a boundary representation (vertex, edge, face) has an internal value of geometrical tolerance. The shapes interfere with each other in terms of their tolerances. The shapes that have a boundary representation interfere when there is a part of 3D space where the distance between the underlying geometry of shapes is less or equal to the sum of tolerances of the shapes. Three types of shapes: vertex, edge and face -- produce six types of **BRep interferences:**
138 * Vertex/Vertex,
139 * Vertex/Edge,
140 * Vertex/Face,
141 * Edge/Edge, 
142 * Edge/Face and 
143 * Face/Face.
144
145 At second, there are interferences that occur between a solid *Z1* and a shape *S2* when *Z1* and *S2* have no BRep interferences but *S2* is completely inside of *Z1*. These interferences are **Non-BRep interferences**. There are four possible cases:
146 * Vertex/Solid, 
147 * Edge/Solid, 
148 * Face/Solid and 
149 * Solid/Solid.
150
151 @subsubsection occt_algorithms_3_1_1 Vertex/Vertex interference
152
153 For two vertices *Vi* and *Vj*, the distance between their corresponding 3D points is less than the sum of their tolerances *Tol(Vi)* and *Tol(Vj)*.
154
155 @figure{/user_guides/boolean_operations/images/operations_image002.svg,"Vertex/vertex interference",420}
156
157 The result is a new vertex *Vn* with 3D point *Pn* and tolerance value <i>Tol(Vn)</i>. 
158
159 The coordinates of *Pn* and the value <i>Tol(Vn)</i> are computed as the center and the radius of the sphere enclosing the tolerance spheres of the source vertices <i>(V1, V2)</i>.
160
161 @subsubsection occt_algorithms_3_1_2    Vertex/Edge interference
162
163 For a vertex *Vi* and an edge *Ej*, the distance *D* between 3D point of the vertex and its projection on the 3D curve of edge *Ej* is less or equal than sum of tolerances of vertex *Tol(Vi)* and edge *Tol(Ej)*.
164
165 @figure{/user_guides/boolean_operations/images/operations_image003.svg,"Vertex/edge interference",420}
166
167 The result is vertex *Vi* with the corresponding tolerance value <i>Tol(Vi)=Max(Tol(Vi), D+Tol(Ej))</i>, where <i>D = distance (Pi, PPi)</i>; 
168
169 and parameter *t<sub>i</sub>* of the projected point *PPi* on 3D curve *Cj* of edge *Ej*.
170
171 @subsubsection occt_algorithms_3_1_3    Vertex/Face interference
172
173 For a vertex *Vi* and a face *Fj* the distance *D* between 3D point of the vertex and its projection on the surface of the face is less or equal than sum of tolerances of the vertex *Tol(Vi)* and the face *Tol(Fj)*. 
174
175 @figure{/user_guides/boolean_operations/images/operations_image004.svg,"Vertex/face interference",420}
176
177 The result is vertex *Vi* with the corresponding tolerance value <i>Tol(Vi)=Max(Tol(Vi), D+Tol(Fj))</i>, where <i>D = distance (Pi, PPi)</i>
178
179 and parameters <i>u<sub>i</sub>, v<sub>i</sub></i> of the projected point *PPi* on surface *Sj* of face *Fj*.
180
181 @subsubsection occt_algorithms_3_1_4    Edge/Edge interference
182
183 For two edges *Ei* and *Ej* (with the corresponding 3D curves *Ci* and *Cj*) there are some places where the distance between the curves is less than (or equal to) sum of tolerances of the edges. 
184
185 Let us examine two cases:
186
187 In  the first case two edges have one or several common parts of 3D curves in terms of tolerance.
188
189 @figure{/user_guides/boolean_operations/images/operations_image005.svg,"Edge/edge interference: common parts",420}
190
191 The results are: 
192 * Parametric range <i>[t<sub>i1</sub>, t<sub>i2</sub> ]</i> for 3D curve *Ci* of edge *Ei*.
193 * Parametric range <i>[t<sub>j1</sub>, t<sub>j2</sub> ]</i> for 3D curve *Cj* of edge *Ej*. 
194
195 In the second case two edges have one or several common points in terms of tolerance.
196
197 @figure{/user_guides/boolean_operations/images/operations_image006.svg,"Edge/edge interference: common points",420}
198
199 The result is a new vertex *Vn* with 3D point *Pn* and tolerance value *Tol(Vn)*.
200
201 The coordinates of *Pn* and the value *Tol(Vn)* are computed as the center and the radius of the sphere enclosing the tolerance spheres of the corresponding nearest points *Pi*, *Pj* of 3D curves *Ci*, *Cj* of source edges *Ei*, *Ej*. 
202
203 * Parameter *t<sub>i</sub>* of *Pi* for the 3D curve *Ci*.
204 * Parameter *t<sub>j</sub>* of *Pj* for the 3D curve *Cj*.
205
206 @subsubsection occt_algorithms_3_1_5    Edge/Face interference
207
208 For an edge *Ei* (with the corresponding 3D curve *Ci*) and a face *Fj* (with the corresponding 3D surface *Sj*) there are some places in 3D space, where the distance between *Ci* and surface *Sj* is less than (or equal to) the sum of tolerances of edge *Ei* and face *Fj*.
209
210 Let us examine two cases:
211
212 In the first case Edge *Ei* and Face *Fj* have one or several common parts in terms of tolerance. 
213
214 @figure{/user_guides/boolean_operations/images/operations_image007.svg,"Edge/face interference: common parts",420}
215
216 The result is a parametric range <i>[t<sub>i1</sub>, t<sub>i2</sub>]</i> for the 3D curve *Ci* of the edge *Ei*.
217
218 In the second case Edge *Ei* and Face *Fj* have one or several common points in terms of tolerance.
219
220 @figure{/user_guides/boolean_operations/images/operations_image008.svg,"Edge/face interference: common points",420}
221
222 The result is a new vertex *Vn* with 3D point *Pn* and tolerance value *Tol(Vn)*. 
223
224 The coordinates of *Pn* and the value *Tol(Vn)* are computed as the center and the radius of the sphere enclosing the tolerance spheres of the corresponding nearest points *Pi*, *Pj* of 3D curve *Ci* and surface *Sj* of source edges *Ei*, *Fj*.
225
226 *       Parameter *t<sub>i</sub>* of *Pi* for the 3D curve *Ci*.
227 *       Parameters *u<sub>i</sub>* and *v<sub>i</sub>* of the projected point *PPi* on the surface *Sj* of the face *Fj*.
228
229 @subsubsection occt_algorithms_3_1_6    Face/Face Interference
230
231 For a face *Fi* and a face *Fj* (with the corresponding surfaces *Si* and *Sj*) there are some places in 3D space, where the distance between the surfaces is less than (or equal to) sum of tolerances of the faces.
232
233 @figure{/user_guides/boolean_operations/images/operations_image009.svg,"Face/face interference: common curves",418}
234
235 In the first case the result contains intersection curves *C<sub>ijk</sub> (k = 0, 1, 2…k<sub>N</sub>,* where *k<sub>N</sub>* is the number of intersection curves with corresponding values of tolerances *Tol(C<sub>ijk</sub>)*.
236
237 @figure{/user_guides/boolean_operations/images/operations_image010.svg,"Face/face interference: common points",305}
238
239 In the second case Face *Fi* and face *Fj* have one or several new vertices *V<sub>ijm</sub>*, where <i>m=0,1,2, ... mN, mN </i> is the number of intersection points.
240
241 The coordinates of a 3D point *P<sub>ijm</sub>* and the value *Tol(V<sub>ijm</sub>)* are computed as the center and the radius of the sphere enclosing the tolerance spheres of the corresponding nearest points *Pi*, *Pj* of the surface *Si*, *Sj* of source shapes *Fi*, *Fj*.
242
243 * Parameters *u<sub>j</sub>*, *v<sub>j</sub>* belong to point *PPj* projected on surface *Sj* of face *Fj*.
244 * Parameters *u<sub>i</sub>* and *v<sub>i</sub>* belong to point *PPi* projected on surface *Si* of face *Fi*. 
245
246 @subsubsection occt_algorithms_3_1_7    Vertex/Solid Interference
247
248 For a vertex *Vi* and a solid *Zj* there is Vertex/Solid interference if the vertex *Vi* has no BRep interferences with any sub-shape of *Zj* and *Vi* is completely inside the solid *Zj*.
249
250 @figure{/user_guides/boolean_operations/images/operations_image060.png,"Vertex/Solid Interference",220}
251
252 @subsubsection occt_algorithms_3_1_8 Edge/Soild Interference
253
254 For an edge *Ei* and a solid *Zj* there is Edge/Solid interference if the edge *Ei* and its sub-shapes have no BRep interferences with any sub-shape of *Zj* and *Ei* is completely inside the solid *Zj*.
255
256 @figure{/user_guides/boolean_operations/images/operations_image061.png,"Edge/Solid Interference",220}
257
258 @subsubsection occt_algorithms_3_1_9 Face/Soild Interference
259
260 For a face *Fi* and a solid *Zj* there is Face/Solid interference if the face *Fi* and its sub-shapes have no BRep interferences with any sub-shape of *Zj* and *Fi* is completely inside the solid *Zj*. 
261
262 @figure{/user_guides/boolean_operations/images/operations_image062.png,"Face/Solid Interference",220}
263
264 @subsubsection occt_algorithms_3_1_10  Solid/Soild Interference
265
266 For a solid *Zi* and a solid *Zj* there is Solid/Solid interference if the solid *Zi* and its sub-shapes have no BRep interferences with any sub-shape of *Zj* and *Zi* is completely inside the solid *Zj*. 
267
268 @figure{/user_guides/boolean_operations/images/operations_image063.png,"Solid/Solid Interference",220}
269
270
271 @subsubsection occt_algorithms_3_1_11 Computation Order
272
273 The interferences between shapes are computed on the basis of increasing of the dimension value of the shape in the following order: 
274 * Vertex/Vertex, 
275 * Vertex/Edge, 
276 * Edge/Edge, 
277 * Vertex/Face, 
278 * Edge/Face, 
279 * Face/Face, 
280 * Vertex/Solid,
281 * Edge/Solid,
282 * Face/Solid,
283 * Solid/Solid.
284
285 This order allows avoiding the computation of redundant interferences between upper-level shapes *Si* and  *Sj* when there are interferences between lower sub-shapes *Sik* and *Sjm*.
286
287 @subsubsection occt_algorithms_3_1_12   Results
288
289 * The result of the interference is a shape that can be either interfered shape itself (or its part) or a new shape.
290 * The result of the interference is a shape with the dimension value that is less or equal to the minimal dimension value of interfered shapes. For example, the result of Vertex/Edge interference is a vertex, but not an edge.
291 * The result of the interference splits the source shapes on the parts each time as it can do that.
292
293 @subsection occt_algorithms_3_2 Paves
294
295 The result of interferences of the type Vertex/Edge, Edge/Edge and Edge/Face in most cases is a vertex (new or old) lying on an edge.
296
297 The result of interferences of the type Face/Face in most cases is intersection curves, which go through some vertices lying on the faces.
298
299 The position of vertex *Vi* on curve *C* can be defined by a value of parameter <i>t<sub>i</sub></i> of the 3D point of the vertex on the curve.
300 Pave *PVi* on curve *C* is a structure containing the vertex *Vi* and correspondent value of the parameter  <i>t<sub>i</sub></i> of the 3D point of the vertex on the curve. Curve *C* can be a 3D or a 2D curve.
301
302 @figure{/user_guides/boolean_operations/images/operations_image011.svg,"Paves",340}
303
304 Two paves *PV1* and *PV2* on the same curve *C* can be compared using the parameter value @code PV1 > PV2 if t1 > t2 @endcode  
305
306 The usage of paves allows binding of the vertex to the curve (or any structure that contains a curve: edge, intersection curve).
307
308
309 @subsection occt_algorithms_3_3 Pave Blocks
310
311 A set of paves *PVi (i=1, 2...nPV)*, where *nPV* is the number of paves] of curve *C* can be sorted in the increasing order using the value of parameter *t* on curve *C*.
312
313 A pave block *PBi* is a part of the object (edge, intersection curve) between neighboring paves. 
314
315 @figure{/user_guides/boolean_operations/images/operations_image012.svg,"Pave Blocks",340}
316
317 Any finite source edge *E* has at least one pave block that contains two paves *PVb* and *PVe*:
318 * Pave *PVb* corresponds to the vertex *Vb* with minimal parameter <i>t<sub>b</sub></i> on the curve of the edge.
319 * Pave *PVe* corresponds to the vertex *Ve* with maximal parameter <i>t<sub>e</sub></i> on the curve of the edge.
320
321 @subsection occt_algorithms_3_4 Shrunk Range
322
323 Pave block *PV* of curve *C* is bounded by vertices *V1* and *V2* with tolerance values *Tol(V1)* and *Tol(V2)*. Curve *C* has its own tolerance value *Tol(C)*:
324 * In case of edge, the tolerance value is the tolerance of the edge.
325 * In case of intersection curve, the tolerance value is obtained from an intersection algorithm.
326
327 @figure{/user_guides/boolean_operations/images/operations_image013.svg,"Shrunk Range",340}
328
329 The theoretical parametric range of the pave block is <i>[t1C, t2C]</i>.
330
331 The positions of the vertices *V1* and *V2* of the pave block can be different. The positions are determined by the following conditions:
332 ~~~~
333 Distance (P1, P1c) is equal or less than Tol(V1) + Tol(C)
334 Distance (P2, P2c) is equal or less than Tol(V2) + Tol(C)
335 ~~~~
336 The Figure shows that each tolerance sphere of a vertex can reduce the parametric range of the pave block to a range <i>[t1S, t2S]</i>. The range <i>[t1S, t2S]</i> is the shrunk range of the pave block. 
337
338 The shrunk range of the pave block is the part of 3D curve that can interfere with other shapes.
339
340 @subsection occt_algorithms_3_5 Common Blocks
341
342 The interferences of the type Edge/Edge, Edge/Face produce results as common parts.
343
344 In case of Edge/Edge interference the common parts are pave blocks that have different base edges. 
345
346 @figure{/user_guides/boolean_operations/images/operations_image014.svg,"Common Blocks: Edge/Edge interference",340}
347
348 If the pave blocks <i>PB<sub>1</sub>, PB<sub>2</sub>…PB<sub>NbPB</sub></i> , where *NbPB* is the number of pave blocks have the same bounding vertices and geometrically coincide, the pave blocks form common block *CB*.
349         
350
351 In case of Edge/Face interference the common parts are pave blocks lying on a face(s).
352
353 @figure{/user_guides/boolean_operations/images/operations_image015.svg,"Common Blocks: Edge/Face interference",265}
354
355 If the pave blocks *PBi* geometrically coincide with a face *Fj*, the pave blocks form common block *CB*.
356
357 In general case a common block *CB* contains:
358 * Pave blocks *PBi (i=0,1,2, 3… NbPB)*.
359 * A set of faces *Fj (j=0,1... NbF), NbF* -- number of faces.
360
361
362 @subsection occt_algorithms_3_6 FaceInfo
363
364 The structure *FaceInfo* contains the following information:
365 * Pave blocks that have state **In** for the face;
366 * Vertices that have state **In** for the face;
367 * Pave blocks that have state **On** for the face;
368 * Vertices that have state **On** for the face;
369 * Pave blocks built up from intersection curves for the face;
370 * Vertices built up from intersection points for the face.
371
372 @figure{/user_guides/boolean_operations/images/operations_image016.svg,"Face Info",420}
373
374 In the figure, for face *F1*:
375 * Pave blocks that have state **In** for the face: *PB<sub>in1</sub>*.
376 * Vertices that have state **In** for the face: *V<sub>in1</sub>*.
377 * Pave blocks that have state **On** for the face: *PB<sub>on11</sub>*,  *PB<sub>on12</sub>*, *PB<sub>on2</sub>*, *PB<sub>on31</sub>*, *PB<sub>on32</sub>*, *PB<sub>on4</sub>*.
378 * Vertices that have state **On** for the face: *V1, V2, V3, V4, V5, V6*.
379 * Pave blocks built up from intersection curves for the face: *PB<sub>sc1</sub>*.
380 * Vertices built up from intersection points for the face: none
381
382
383 @section occt_algorithms_4 Data Structure
384
385 Data Structure (DS) is used to:
386 * Store information about input data and intermediate results;
387 * Provide the access to the information;
388 * Provide the links between the chunks of information.
389
390 This information includes:
391 * Arguments;
392 * Shapes;
393 * Interferences;
394 * Pave Blocks;
395 * Common Blocks.
396
397 Data Structure is implemented in the class *BOPDS_DS*.
398
399 @subsection occt_algorithms_4_1 Arguments
400
401 The arguments are shapes (in terms of *TopoDS_Shape*):
402 * Number of arguments is unlimited.
403 * Each argument is a valid shape (in terms of *BRepCheck_Analyzer*).
404 * Each argument can be of one of the following types (see the Table):
405
406 | No    | Type  | Index of Type |
407 | :----- | :----- | :----- |
408 | 1     | COMPOUND      | 0 |
409 | 2     | COMPSOLID     | 1 |
410 | 3     | SOLID | 2 |
411 | 4     | SHELL | 3 |
412 | 5     | FACE  | 4 |
413 | 6     | WIRE  | 5 | 
414 | 7     | EDGE  | 6 | 
415 | 8     | VERTEX | 7 | 
416
417 * The argument of type *0 (COMPOUND)* can include any number of shapes of an arbitrary type (0, 1…7).
418 * The argument should not be self-interfered, i.e. all sub-shapes of the argument that have geometrical coincidence through any topological entities (vertices, edges, faces) must share these entities.
419 * There are no restrictions on the type of underlying geometry of the shapes. The faces or edges of arguments *S<sub>i</sub>* can have underlying geometry of any type supported by Open CASCADE Technology modeling algorithms (in terms of *GeomAbs_CurveType* and *GeomAbs_SurfaceType*). 
420 * The faces or edges of the arguments should have underlying geometry with continuity that is not less than C1.
421
422 @subsection occt_algorithms_4_2 Shapes
423
424 The information about  Shapes is stored in  structure *BOPDS_ShapeInfo*. The objects of type *BOPDS_ShapeInfo* are stored in the container of array type. The array allows getting the access to the information by an index (DS index).
425 The structure *BOPDS_ShapeInfo* has the following contents:
426
427
428 | Name  | Contents |
429 | :-------- | :----- |
430 | *myShape* |   Shape itself |
431 | *myType* |    Type of shape |
432 | *myBox* |     3D bounding box of the shape |
433 | *mySubShapes* | List of DS indices of sub-shapes |
434 | *myReference* | Storage for some auxiliary information |
435 | *myFlag* | Storage for some auxiliary information |
436
437 @subsection occt_algorithms_4_3 Interferences 
438
439 The information about interferences is stored in the instances of classes that are inherited from class <i>BOPDS_Interf</i>. 
440
441 | Name  | Contents |
442 | :----- | :----- | 
443 | *BOPDS_Interf* |      Root class for interference |
444 | *Index1*      | DS index of the shape 1 |
445 | *Index2*      | DS index of the shape 2 |
446 | *BOPDS_InterfVV* | Storage for Vertex/Vertex interference |
447 | *BOPDS_InterfVE* | Storage for Vertex/Edge interference |
448 | *myParam* | The value of parameter of the point of the vertex on the curve of the edge |
449 | *BOPDS_InterfVF* | Storage for Vertex/Face interference |
450 | *myU, myV* |  The value of parameters of the point of the vertex on the surface of the face |
451 | *BOPDS_InterfEE* | Storage for Edge/Edge interference |
452 | *myCommonPart* | Common part (in terms of *IntTools_CommonPart* ) |
453 | *BOPDS_InterfEF* | Storage for Edge/Face interference |
454 | *myCommonPart*        | Common part (in terms of *IntTools_CommonPart* ) | 
455 | *BOPDS_InterfFF* | Storage for Face/Face interference |
456 | *myTolR3D, myTolR2D* | The value of tolerances of curves (points) reached in 3D and 2D |
457 | *myCurves* | Intersection Curves (in terms of *BOPDS_Curve*) |
458 | *myPoints* | Intersection Points (in terms of *BOPDS_Point*) |
459 | *BOPDS_InterfVZ* | Storage for Vertex/Solid interference |
460 | *BOPDS_InterfEZ* | Storage for Edge/Solid interference |
461 | *BOPDS_InterfFZ* | Storage for Face/Solid interference |
462 | *BOPDS_InterfZZ* | Storage for Solid/Solid interference | 
463
464
465
466
467
468 The Figure shows inheritance diagram for *BOPDS_Interf* classes.
469
470 @figure{/user_guides/boolean_operations/images/operations_image017.svg,"BOPDS_Interf classes",420}
471
472
473 @subsection occt_algorithms_4_4 Pave, PaveBlock and CommonBlock
474
475 The information about the pave is stored in objects of type *BOPDS_Pave*.
476
477 | Name | Contents |
478 | :--- | :------ |
479 | *BOPDS_Pave*  | |
480 | *myIndex* |   DS index of the vertex |
481 | *myParam* |   Value of the parameter of the 3D point of vertex on curve. |
482
483 The information about pave blocks is stored in objects of type *BOPDS_PaveBlock*.
484
485 | Name  | Contents |
486 | :--- | :------ |
487 | *BOPDS_PaveBlock*     | |
488 | *myEdge* | DS index of the edge produced from the pave block |
489 | *myOriginalEdge* | DS index of the source edge |
490 | *myPave1* | Pave 1 (in terms of *BOPDS_Pave*) |
491 | *myPave2* | Pave 2 (in terms of *BOPDS_Pave*) |
492 | *myExtPaves* | The list of paves (in terms of *BOPDS_Pave*) that is used to store paves lying inside the pave block during intersection process |
493 | *myCommonBlock* | The reference to common block (in terms of *BOPDS_CommonBlock*) if  the pave block is a common block |
494 | *myShrunkData* | The shrunk range of the pave block |
495
496 * To be bound to an edge (or intersection curve) the structures of type *BOPDS_PaveBlock* are stored in one container of list type <i>(BOPDS_ListOfPaveBlock)</i>.
497 * In case of edge, all the lists of pave blocks above are stored in one container of array type. The array allows getting the access to the information by index of the list of pave blocks for the edge. This index (if exists) is stored in the field *myReference*.
498
499 The information about common block is stored in objects of type *BOPDS_CommonBlock*.
500
501 | Name  | Contents |
502 | :---- | :------ |
503 | *BOPDS_CommonBlock* | |       
504 | *myPaveBlocks* | The list of pave blocks that are common in terms of @ref occt_algorithms_3_5 "Common Blocks" |
505 | *myFaces* | The list of DS indices of the faces, on which the pave blocks lie. |
506
507
508 @subsection occt_algorithms_4_5 Points and Curves
509 The information about intersection point is stored in objects of type *BOPDS_Point*. 
510
511 | Name  | Contents |
512 | :---- | :----- |
513 | *BOPDS_Point* | |     
514 | *myPnt* |     3D point |
515 | *myPnt2D1* |  2D point on the face1 |
516 | *myPnt2D2* | 2D point on the face2 |
517
518 The information about intersection curve is stored in objects of type *BOPDS_Curve*.
519
520 | Name  | Contents |
521 | :---- | :----- | 
522 | *BOPDS_Curve* | |
523 | *myCurve* | The intersection curve (in terms of *IntTools_Curve* ) |
524 | *myPaveBlocks* | The list of pave blocks that belong to the curve | 
525 | *myBox* | The bounding box of the curve (in terms of *Bnd_Box* ) |
526
527 @subsection occt_algorithms_4_6 FaceInfo
528 The information about *FaceInfo* is stored in a structure *BOPDS_FaceInfo*. 
529 The structure *BOPDS_FaceInfo* has the following contents.
530
531 | Name  | Contents |
532 | :---- | :----- |
533 | *BOPDS_FaceInfo* | |  
534 | *myPaveBlocksIn* | Pave blocks that have state In for the face |
535 | *myVerticesIn* | Vertices that have state In for the face | 
536 | *myPaveBlocksOn* | Pave blocks that have state On for the face |
537 | *myVerticesOn* | Vertices that have state On for the face | 
538 | *myPaveBlocksSc* | Pave blocks built up from intersection curves for the face |
539 | *myVerticesSc* | Vertices built up from intersection points for the face +
540
541 The objects of type *BOPDS_FaceInfo* are stored in one container of array type. The array allows getting the access to the information by index. This index (if exists) is stored in the field *myReference*.
542
543 @section occt_algorithms_5      Intersection Part
544
545 Intersection Part (IP) is used to
546 * Initialize the Data Structure;
547 * Compute interferences between the arguments (or their sub-shapes);
548 * Compute same domain vertices, edges;
549 * Build split edges;
550 * Build section edges;
551 * Build p-curves;
552 * Store all obtained information in DS.
553
554 IP is implemented in the class *BOPAlgo_PaveFiller*.
555
556 @figure{/user_guides/boolean_operations/images/operations_image064.svg,"Diagram for Class BOPAlgo_PaveFiller",230}
557
558 @subsection occt_algorithms_5_1a Class BOPAlgo_Algo
559 The class *BOPAlgo_Algo* provides the base interface for all algorithms to provide the possibility to:
560 * Get Error status;
561 * Get Warning status;
562 * Turn on/off the parallel processing
563 * Break the operations by user request
564 * Check data;
565 * Check the result;
566 * Set the appropriate memory allocator. 
567
568 The description provided in the next paragraphs is coherent with the implementation of the method *BOPAlgo_PaveFiller::Perform()*.
569
570 @subsection occt_algorithms_5_1 Initialization
571 The input data for the step is the Arguments. The description of initialization step is shown in the Table.
572
573 | No    | Contents |    Implementation |
574 | :--- | :----- | :----- |
575 | 1     | Initialization the array of shapes (in terms of @ref occt_algorithms_4_2 "Shapes"). Filling the array of shapes. | *BOPDS_DS::Init()* |
576 | 2     | Initialization the array pave blocks (in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock, CommonBlock") | *BOPDS_DS::Init()* |
577 | 3     | Initialization of intersection Iterator. The intersection Iterator is the object that computes intersections between sub-shapes of the arguments in terms of bounding boxes. The intersection Iterator provides approximate number of the interferences for given type (in terms of @ref occt_algorithms_3_1 "Interferences") | *BOPDS_Iterator* |
578 | 4     | Initialization of intersection Context. The intersection Context is an object that contains geometrical and topological toolkit (classifiers, projectors, etc). The intersection Context is used to cache the tools to increase the algorithm performance. | *IntTools_Context* |
579
580
581 @subsection occt_algorithms_5_2 Compute Vertex/Vertex Interferences
582
583 The input data for this step is the DS after the @ref occt_algorithms_5_1 "Initialization". The description of this step is shown in the table :
584
585
586 | No | Contents | Implementation |
587 | :--- | :---- | :----- | 
588 | 1 | Initialize array of Vertex/Vertex interferences. | *BOPAlgo_PaveFiller::PerformVV()* |
589 | 2 | Access to the pairs of interfered shapes <i>(nVi, nVj)k, k=0, 1…nk,</i> where *nVi* and *nVj* are DS indices of vertices *Vi* and *Vj* and *nk* is the number of pairs. | *BOPDS_Iterator* |
590 | 3 | Compute the connexity chains of interfered vertices *nV1C, nV2C… nVnC)k, C=0, 1…nCs*, where *nCs* is the number of the connexity chains |     *BOPAlgo_Tools::MakeBlocksCnx()* |
591 | 4     | Build new vertices from the chains *VNc. C=0, 1…nCs.* |     *BOPAlgo_PaveFiller::PerformVV()* |
592 | 5     | Append new vertices in DS. |  *BOPDS_DS::Append()* |
593 | 6     | Append same domain vertices in DS. | *BOPDS_DS::AddShapeSD()* |
594 | 7 | Append Vertex/Vertex interferences  in DS. | *BOPDS_DS::AddInterf()* |
595
596 * The pairs of interfered vertices are: <i>(nV11, nV12), (nV11, nV13), (nV12, nV13), (nV13, nV15), (nV13, nV14), (nV14, nV15), (nV21, nV22), (nV21, nV23), (nV22, nV23);</i> 
597 * These pairs produce two chains: <i>(nV11, nV12, nV13, nV14, nV15)</i> and <i>(nV21, nV22, nV23);</i>
598 * Each chain is used to create a new vertex,  *VN1* and *VN2*, correspondingly.
599
600 The example of connexity chains of interfered vertices is given in the image:
601
602 @figure{/user_guides/boolean_operations/images/operations_image018.svg,"Connexity chains of interfered vertices",394}
603
604
605 @subsection occt_algorithms_5_3 Compute Vertex/Edge Interferences
606
607 The input data for this step is the DS after computing Vertex/Vertex interferences.
608
609 | No | Contents | Implementation  | 
610 | :--- | :--- | :--- |
611 | 1     | Initialize array of Vertex/Edge interferences | *BOPAlgo_PaveFiller::PerformVE()* |
612 | 2     | Access to the pairs of interfered shapes <i>(nVi, nEj)k k=0, 1…nk,</i> where *nVi* is DS index of vertex *Vi*, *nEj* is DS index of edge *Ej* and *nk* is the number of pairs. |    *BOPDS_Iterator* |
613 | 3     | Compute paves. See  @ref occt_algorithms_3_1_2 "Vertex/Edge Interference" | *BOPInt_Context::ComputeVE()* | 
614 | 4     | Initialize pave blocks for the edges *Ej* involved in the interference | *BOPDS_DS:: ChangePaveBlocks()* |
615 | 5     | Append the paves into the pave blocks in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock" | *BOPDS_PaveBlock:: AppendExtPave()* |
616 | 6     | Append Vertex/Edge interferences in DS | *BOPDS_DS::AddInterf()* |
617
618 @subsection occt_algorithms_5_4 Update Pave Blocks
619 The input data for this step is the DS after computing Vertex/Edge Interferences.
620
621 | No | Contents | Implementation | 
622 | :--- | :---- | :--- | 
623 | 1     | Each pave block PB containing internal paves is split by internal paves into new pave blocks *PBN1, PBN2… PBNn*. PB is replaced by new pave blocks *PBN1, PBN2… PBNn* in the DS. |        *BOPDS_DS:: UpdatePaveBlocks()* | 
624
625 @subsection occt_algorithms_5_5 Compute Edge/Edge Interferences
626
627 The input data for this step is the DS after updating Pave Blocks. 
628
629 | No | Contents | Implementation  | 
630 | :---- | :---- | :----- | 
631 | 1 | Initialize array of Edge/Edge interferences | *BOPAlgo_PaveFiller::PerformEE()* |
632 | 2     | Access to the pairs of interfered shapes <i>(nEi, nEj)k, k=0, 1…nk,</i> where *nEi* is DS index of the edge *Ei*, *nEj* is  DS index of the edge *Ej* and *nk* is the number of pairs. | *BOPDS_Iterator* |
633 | 3     | Initialize pave blocks for the edges involved in the interference, if it is necessary. |      *BOPDS_DS:: ChangePaveBlocks()* |
634 | 4     | Access to the pave blocks of interfered shapes: <i>(PBi1, PBi2…PBiNi)</i> for edge *Ei* and <i>(PBj1, PBj2…PBjNj)</i> for  edge *Ej* | *BOPAlgo_PaveFiller::PerformEE()* |
635 | 5     | Compute shrunk data for pave blocks in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock", if it is necessary. | *BOPAlgo_PaveFiller::FillShrunkData()* |
636 | 6     | Compute Edge/Edge interference for pave blocks *PBix* and *PBiy*. The result of the computation is a set of objects of type *IntTools_CommonPart* | *IntTools_EdgeEdge* |
637 | 7.1 | For each *CommonPart* of type *VERTEX:* Create new vertices *VNi (i =1, 2…,NbVN),* where *NbVN* is the number of new vertices. Intersect the vertices *VNi* using the steps Initialization and compute Vertex/Vertex interferences as follows: a) create a new object *PFn* of type *BOPAlgo_PaveFiller* with its own DS; b) use new vertices *VNi (i=1, 2…,NbVN), NbVN* as arguments (in terms of *TopoDs_Shape*) of *PFn*; c) invoke method *Perform()* for *PFn*. The resulting vertices *VNXi (i=1, 2…,NbVNX)*, where *NbVNX* is the number of vertices, are obtained via mapping between *VNi* and the results of *PVn*. | *BOPTools_Tools::MakeNewVertex()* |
638 | 7.2 | For each *CommonPart* of type *EDGE:*   Compute the coinciding connexity chains of  pave blocks <i>(PB1C, PB2C… PNnC)k, C=0, 1…nCs,</i> where *nCs* is the number of the connexity chains. Create common blocks <i>(CBc. C=0, 1…nCs)</i> from the chains. Attach the common blocks to the pave blocks. |  *BOPAlgo_Tools::PerformCommonBlocks()* |
639 | 8     | Post-processing. Append the paves of *VNXi* into the corresponding pave blocks in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock" | *BOPDS_PaveBlock:: AppendExtPave()* |
640 | 9     | Split common blocks CBc by the paves. | *BOPDS_DS:: UpdateCommonBlock()* |
641 | 10 | Append Edge/Edge interferences in the DS. |      *BOPDS_DS::AddInterf()* |
642
643 The example of coinciding chains of pave blocks is given in the image:
644
645 @figure{/user_guides/boolean_operations/images/operations_image019.png,"Coinciding chains of pave blocks",420}
646
647 * The pairs of coincided pave blocks are: <i>(PB11, PB12), (PB11, PB13), (PB12, PB13), (PB21, PB22), (PB21, PB23), (PB22, PB23).</i>
648 * The pairs produce  two chains: <i>(PB11, PB12, PB13)</i> and <i>(PB21, PB22, PB23).</i>
649
650 @subsection occt_algorithms_5_6 Compute Vertex/Face Interferences
651
652 The input data for this step is the DS after computing Edge/Edge interferences.
653
654 | No | Contents | Implementation  |
655 | :---- | :--- | :---- |
656 | 1     | Initialize array of Vertex/Face interferences | *BOPAlgo_PaveFiller::PerformVF()* |
657 | 2     | Access to the pairs of interfered shapes <i>(nVi, nFj)k, k=0, 1…nk,</i> where *nVi* is DS index of the vertex *Vi*, *nFj* is DS index of the edge *Fj* and *nk* is the number of  pairs. |  *BOPDS_Iterator* |
658 | 3     | Compute interference  See  @ref occt_algorithms_3_1_3 "Vertex/Face Interference" | *BOPInt_Context::ComputeVF()* |
659 | 4     | Append Vertex/Face interferences in the DS |  *BOPDS_DS::AddInterf()* |
660 | 5     | Repeat steps 2-4 for each new vertex *VNXi (i=1, 2…,NbVNX),* where *NbVNX* is the number of vertices. | *BOPAlgo_PaveFiller::TreatVerticesEE()* |
661
662 @subsection occt_algorithms_5_7 Compute Edge/Face Interferences
663 The input data for this step is the DS after computing Vertex/Face Interferences. 
664
665 | No | Contents | Implementation |
666 | :---- | :---- | :---- | 
667 | 1     | Initialize array of Edge/Face interferences | *BOPAlgo_PaveFiller::PerformEF()* |
668 | 2     | Access to the pairs of interfered shapes <i>(nEi, nFj)k, k=0, 1…nk,</i> where *nEi* is DS index of edge *Ei*, *nFj* is DS index of face *Fj* and *nk* is the number of pairs. |     *BOPDS_Iterator* |
669 | 3     | Initialize pave blocks for the edges involved in the interference, if it is necessary. | *BOPDS_DS::ChangePaveBlocks()* |
670 | 4     | Access to the pave blocks of interfered edge <i>(PBi1, PBi2…PBiNi)</i> for edge *Ei*        | *BOPAlgo_PaveFiller::PerformEF()* |
671 | 5     | Compute shrunk data for pave blocks (in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock") if it is necessary. |    *BOPAlgo_PaveFiller::FillShrunkData()* |
672 | 6     | Compute Edge/Face interference for pave block *PBix*, and face *nFj*. The result of the computation is a set of objects of type *IntTools_CommonPart* | *IntTools_EdgeFace* |
673 | 7.1 | For each *CommonPart* of type *VERTEX:* Create new vertices *VNi (i=1, 2…,NbVN),* where *NbVN* is the number of new vertices. Merge vertices *VNi* as follows: a) create new object *PFn* of type *BOPAlgo_PaveFiller* with its own DS; b) use new vertices *VNi (i=1, 2…,NbVN), NbVN* as arguments (in terms of *TopoDs_Shape*) of *PFn*; c) invoke method *Perform()* for *PFn*. The resulting vertices *VNXi (i=1, 2…,NbVNX)*, where *NbVNX* is the number of vertices, are obtained via mapping between *VNi* and the results of *PVn*. | *BOPTools_Tools::MakeNewVertex()* and *BOPAlgo_PaveFiller::PerformVertices1()* |
674 | 7.2 | For each *CommonPart* of type *EDGE:* Create common blocks <i>(CBc. C=0, 1…nCs)</i> from pave blocks that lie on the faces. Attach the common blocks to the pave blocks. | *BOPAlgo_Tools::PerformCommonBlocks()* |
675 | 8     | Post-processing. Append the paves of *VNXi* into the corresponding pave blocks in terms of @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock". | *BOPDS_PaveBlock:: AppendExtPave()* |
676 | 9     | Split pave blocks and common blocks *CBc* by the paves. |     *BOPAlgo_PaveFiller::PerformVertices1()*, *BOPDS_DS:: UpdatePaveBlock()* and *BOPDS_DS:: UpdateCommonBlock()* |
677 | 10 | Append Edge/Face interferences in the DS | *BOPDS_DS::AddInterf()* |
678 | 11 | Update *FaceInfo*  for all faces having EF common parts. | *BOPDS_DS:: UpdateFaceInfoIn()* |
679
680
681 @subsection occt_algorithms_5_8 Build Split Edges
682
683 The input data for this step is the DS after computing Edge/Face Interferences.
684
685 For each pave block *PB* take the following steps: 
686         
687 | No | Contents | Implementation |
688 | :--- | :--- | :--- | 
689 | 1     | Get the real pave block *PBR*, which is equal to *PB* if *PB* is not a common block and to *PB<sub>1</sub>* if *PB* is a common block. *PB<sub>1</sub>* is the first pave block in the pave blocks list of the common block.  See  @ref occt_algorithms_4_4 "Pave, PaveBlock and CommonBlock". | *BOPAlgo_PaveFiller::MakeSplitEdges()* | 
690 | 2     | Build the split edge *Esp* using the information from *DS* and *PBR*. | *BOPTools_Tools::MakeSplitEdge()* |
691 | 3     | Compute *BOPDS_ShapeInfo* contents for Esp | *BOPAlgo_PaveFiller::MakeSplitEdges()* |
692 | 4     | Append *BOPDS_ShapeInfo* contents to the DS | *BOPDS_DS::Append()* |
693
694 @subsection occt_algorithms_5_9 Compute Face/Face Interferences
695
696 The input data for this step is DS after building Split Edges. 
697
698 | No | Contents | Implementation |
699 | :--- | :--- | :--- | 
700 | 1 | Initialize array of Face/Face interferences | *BOPAlgo_PaveFiller::PerformFF()* |
701 | 2     | Access to the pairs of interfered shapes <i>(nFi, nFj)k, k=0, 1…nk,</i> where *nFi* is DS index of edge *Fi*, *nFj* is  DS index of face *Fj* and *nk* is the number of pairs. | *BOPDS_Iterator* |
702 | 3     | Compute Face/Face interference | *IntTools_FaceFace* |
703 | 4     | Append Face/Face interferences in the DS. | *BOPDS_DS::AddInterf()* |
704
705 @subsection occt_algorithms_5_10        Build Section Edges
706
707 The input data for this step is the DS after computing Face/Face interferences.
708
709 | No | Contents | Implementation  |
710 | :---- | :---- | :---- |
711 | 1 | For each Face/Face interference *nFi, nFj*, retrieve @ref occt_algorithms_4_6 "FaceInfo". Create draft vertices from intersection points *VPk (k=1, 2…, NbVP)*, where *NbVP* is the number of new vertices, and the draft vertex *VPk* is created from an intersection point if *VPk ≠ Vm (m = 0, 1, 2… NbVm)*, where *Vm* is an existing vertex for the faces *nFi* and *nF,j* (*On* or *In* in terms of *TopoDs_Shape*),  *NbVm* is the number of vertices existing on faces *nFi* and *nF,j* and ≠ -- means non-coincidence in terms of @ref occt_algorithms_3_1_1 "Vertex/Vertex interference". | *BOPAlgo_PaveFiller::MakeBlocks()* |
712 | 2     | For each intersection curve *Cijk* | |        
713 | 2.1 | Create paves PVc for the curve using existing vertices, i.e. vertices On or In (in terms of *FaceInfo*) for faces *nFi* and *nFj*. Append the paves *PVc* | *BOPAlgo_PaveFiller::PutPaveOnCurve()* and *BOPDS_PaveBlock::AppendExtPave()* |
714 | 2.2 | Create technological vertices *Vt*, which are the bounding points of an intersection curve (with the value of tolerance *Tol(Cijk)*). Each vertex *Vt* with parameter *Tt* on curve *Cijk* forms pave *PVt* on curve *Cijk*. Append technological paves. | *BOPAlgo_PaveFiller::PutBoundPaveOnCurve()* |
715 | 2.3 | Create pave blocks *PBk* for the curve using paves <i>(k=1, 2…, NbPB)</i>, where *NbPB* is the number of pave blocks |        *BOPAlgo_PaveFiller::MakeBlocks()* |
716 | 2.4 | Build draft section edges *ESk* using the pave blocks <i>(k=1, 2…, NbES)</i>, where *NbES* is the number of draft section edges       The draft section edge is created from a pave block *PBk* if *PBk* has state *In* or *On* for both faces *nFi* and *nF,j* and *PBk ≠ PBm (m=0, 1, 2… NbPBm)*, where *PBm* is an existing pave block for faces *nFi* and *nF,j* (*On* or *In* in terms of *FaceInfo*), *NbVm* is the number of existing pave blocks for faces *nFi* and *nF,j* and ≠ -- means non-coincidence (in terms of @ref occt_algorithms_3_1_3 "Vertex/Face interference"). | *BOPTools_Tools::MakeEdge()* |
717 | 3     | Intersect the draft vertices *VPk (k=1, 2…, NbVP)* and the draft section edges *ESk (k=1, 2…, NbES)*. For this: a) create new object *PFn* of type *BOPAlgo_PaveFiller* with its own DS; b) use vertices *VPk* and edges *ESk* as arguments (in terms of @ref occt_algorithms_4_1 "Arguments") of *PFn*; c) invoke        method *Perform()* for *PFn*. Resulting vertices *VPXk (k=1, 2… NbVPX)* and edges *ESXk (k=1, 2… NbESX)* are obtained via mapping between *VPk, ESk* and the results of *PVn*. | *BOPAlgo_PaveFiller::PostTreatFF()* |
718 | 4     | Update face info (sections about pave blocks and vertices) | *BOPAlgo_PaveFiller::PerformFF()* |
719
720 @subsection occt_algorithms_5_11 Build P-Curves
721 The input data for this step is the DS after building section edges.
722
723 | No | Contents | Implementation |
724 | :---- | :---- | :---- |
725 | 1     | For each Face/Face interference *nFi* and *nFj* build p-Curves on *nFi* and *nFj* for each section edge *ESXk*. |     *BOPAlgo_PaveFiller::MakePCurves()* |
726 | 2     | For each pave block that is common for faces *nFi* and *nFj* build p-Curves on *nFi* and *nFj*. |     *BOPAlgo_PaveFiller::MakePCurves()* |
727
728 @subsection occt_algorithms_5_12        Process Degenerated Edges
729 The input data for this step is the DS  after building P-curves.
730
731 | No | Contents | Implementation |
732 | :---- | :---- | :---- |
733 | | For each degenerated edge *ED* having vertex *VD* | BOPAlgo_PaveFiller::ProcessDE() |
734 | 1     | Find pave blocks *PBi (i=1,2… NbPB)*, where *NbPB* is the number of pave blocks, that go through vertex *VD*. | *BOPAlgo_PaveFiller::FindPaveBlocks()* |
735 | 2     | Compute paves for the degenerated edge *ED* using a 2D curve of *ED* and a 2D curve of *PBi*. Form pave blocks *PBDi (i=1,2… NbPBD)*, where *NbPBD* is the number of the pave blocks for the degenerated edge *ED* | *BOPAlgo_PaveFiller::FillPaves()* |
736 | 3     | Build split edges *ESDi (i=1,2…NbESD)*, where *ESD* is the number of split edges, using the pave blocks *PBDi* |    *BOPAlgo_PaveFiller:: MakeSplitEdge()* |
737
738 @section occt_algorithms_6      General description of the Building Part
739
740 Building Part (BP) is used to 
741 * Build the result of the operation 
742 * Provide history information (in terms of <i>\::Generated(), \::Modified()</i> and <i>\::IsDeleted()</i>)
743 BP uses the DS prepared by *BOPAlgo_PaveFiller* described at chapter 5 as input data.
744 BP is implemented in the following classes:
745 * *BOPAlgo_Builder* -- for the General Fuse operator  (GFA).
746 * *BOPAlgo_BOP* -- for the Boolean Operation operator   (BOA).
747 * *BOPAlgo_Section* -- for the Section operator  (SA).
748
749 @figure{/user_guides/boolean_operations/images/operations_image020.svg,"Diagram for BP classes",300}
750
751 The class *BOPAlgo_BuilderShape* provides the interface for algorithms that have:
752 * A Shape as the result;
753 * History information (in terms of <i>\::Generated(), \::Modified()</i> and <i>\::IsDeleted()).</i>
754
755 @section occt_algorithms_7      General Fuse Algorithm
756 @subsection occt_algorithms_7_1 Arguments
757 The arguments of the algorithm are shapes (in terms of *TopoDS_Shape*). The main requirements for the arguments are described in @ref occt_algorithms_4 "Data Structure" chapter.
758
759 @subsection occt_algorithms_7_2 Results
760
761 During the operation argument *Si* can be split into several parts *Si1, Si2… Si1NbSp*, where *NbSp* is the number of parts. The set <i>(Si1, Si2… Si1NbSp)</i> is an image of argument *Si*.
762 * The result of the General Fuse operation is a compound. Each sub-shape of the compound corresponds to the certain argument shape S1, S2…Sn and has shared sub-shapes in accordance with interferences between the arguments.
763 * For the arguments of the type EDGE, FACE, SOLID the result contains split parts of the argument.
764 * For the arguments of the type WIRE, SHELL, COMPSOLID, COMPOUND the result contains the image of the shape of the corresponding type (i.e. WIRE, SHELL, COMPSOLID or COMPOUND).
765 The types of resulting shapes depend on the type of the corresponding argument participating in the operation. See the table below:
766
767 | No | Type of argument | Type of resulting shape | Comments |
768 | :--- | :---- | :--- | :--- |
769 | 1 | COMPOUND | COMPOUND | The resulting COMPOUND is built from images of sub-shapes of type COMPOUND COMPSOLID, SHELL, WIRE and VERTEX. Sets of split sub-shapes of type SOLID, FACE, EDGE. | 
770 | 2     | COMPSOLID     | COMPSOLID     | The resulting COMPSOLID is built from split SOLIDs. |
771 | 3     | SOLID | Set of split SOLIDs | |
772 | 4     | SHELL | SHELL | The resulting SHELL is built from split FACEs |
773 | 5     | FACE  | Set of split FACEs | |
774 | 6     | WIRE | WIRE | The resulting WIRE is built from split EDGEs |
775 | 7     | EDGE  | Set of split EDGEs    | |
776 | 8     | VERTEX | VERTEX | |
777
778 @subsection occt_algorithms_7_3 Examples
779
780 Please, have a look at the examples, which can help to better understand the definitions.
781
782 @subsubsection occt_algorithms_7_3_1    Case 1: Three edges intersecting at a point 
783
784 Let us consider three edges: *E1, E2* and *E3* that intersect in one 3D point.
785
786 @figure{/user_guides/boolean_operations/images/operations_image021.svg,"Three Intersecting Edges",420}
787
788 The result of the GFA operation is a compound containing 6 new edges: *E11, E12, E21, E22, E31*, and *E32*. These edges have one shared vertex *Vn1*.
789
790 In this case:
791 * The argument edge *E1* has resulting split edges *E11* and *E12* (image of *E1*).
792 * The argument edge *E2* has resulting split edges *E21* and *E22* (image of *E2*).
793 * The argument edge *E3* has resulting split edges *E31* and *E32* (image of *E3*).
794
795 @subsubsection occt_algorithms_7_3_2 Case 2: Two wires and an edge
796
797 Let us consider two wires *W1 (Ew11, Ew12, Ew13)* and *W2 (Ew21, Ew22, Ew23)* and edge *E1*.
798
799 @figure{/user_guides/boolean_operations/images/operations_image022.svg,"Two wires and an edge",420}
800
801 The result of the GF operation is a compound consisting of 2 wires: *Wn1 (Ew11, En1, En2, En3, Ew13)* and *Wn2 (Ew21, En2, En3, En4, Ew23)* and two edges: *E11* and *E12*. 
802
803 In this case :
804 * The argument *W1* has image *Wn1*.
805 * The argument *W2* has image *Wn2*.
806 * The argument edge *E1* has split edges *E11* and *E12*. (image of *E1*).
807 The edges *En1, En2, En3, En4* and vertex *Vn1* are new shapes created during the operation. Edge *Ew12* has split edges *En1, En2* and *En3* and edge *Ew22* has split edges *En2, En3* and *En4*.
808
809 @subsubsection occt_algorithms_7_3_3 Case 3: An edge intersecting with a face
810
811 Let us consider edge *E1* and face *F2*:
812
813 @figure{/user_guides/boolean_operations/images/operations_image023.svg,"An edge intersecting with a face",420}
814
815 The result of the GF operation is a compound consisting of 3 shapes: 
816 * Split edge parts *E11* and *E12* (image of *E1*).
817 * New face *F21* with internal edge *E12* (image of *F2*).
818
819 @subsubsection occt_algorithms_7_3_4 Case 4: An edge lying on a face
820
821 Let us consider edge *E1* and face *F2*:
822
823 @figure{/user_guides/boolean_operations/images/operations_image024.svg,"An edge lying on a face",420}
824
825 The result of the GF operation is a compound consisting of 5 shapes: 
826 * Split edge parts *E11, E12* and *E13* (image of *E1*).
827 * Split face parts  *F21* and *F22* (image of *F2*).
828
829
830 @subsubsection occt_algorithms_7_3_5 Case 5: An edge and a shell
831
832 Let us consider edge *E1* and shell *Sh2* that consists of 2 faces: *F21* and *F22*
833
834 @figure{/user_guides/boolean_operations/images/operations_image025.svg,"An edge and a shell",488}
835
836 The result of the GF operation is a compound consisting of 5 shapes: 
837 * Split edge parts *E11, E12 , E13* and *E14* (image of *E1*).
838 * Image shell *Sh21* (that contains split face parts  *F211, F212, F221* and *F222*).
839
840 @subsubsection occt_algorithms_7_3_6 Case 6: A wire and a shell
841
842 Let us consider  wire *W1 (E1, E2, E3, E4)* and  shell *Sh2 (F21, F22)*. 
843 @figure{/user_guides/boolean_operations/images/operations_image026.svg,"A wire and a shell",427}
844
845 The result of the GF operation is a compound consisting of 2 shapes: 
846
847 * Image wire *W11* that consists of split edge parts from wire *W1: E11, E12, E13* and *E14*.
848 * Image shell *Sh21* that contains split face parts: *F211, F212, F213, F221, F222* and *F223*.
849
850 @subsubsection occt_algorithms_7_3_7 Case 7: Three faces
851
852 Let us consider 3 faces: *F1, F2* and *F3*. @figure{/user_guides/boolean_operations/images/operations_image027.png,"Three faces",420}
853
854 The result of the GF operation is a compound consisting of 7 shapes:
855 * Split face parts: *Fn1, Fn2, Fn3, Fn4, Fn5, Fn6* and *Fn7*.
856
857 @subsubsection occt_algorithms_7_3_8 Case 8: A face and a shell
858
859 Let us consider shell *Sh1 (F11, F12, F13)* and face *F2*.
860 @figure{/user_guides/boolean_operations/images/operations_image028.png,"A face and a shell",420}
861
862 The result of the GF operation is a compound consisting of 4 shapes:
863 * Image shell *Sh11* that consists of split face parts from shell *Sh1: Fn1, Fn2, Fn3, Fn4, Fn5* and *Fn6*.
864 * Split parts of face *F2: Fn3, Fn6* and *Fn7*.
865
866 @subsubsection occt_algorithms_7_3_9 Case 9: A shell and a solid
867
868 Let us consider shell *Sh1 (F11, F12…F16)* and solid *So2*. @figure{/user_guides/boolean_operations/images/operations_image029.png,"A shell and a solid: arguments",220}
869
870 The result of the GF operation is a compound consisting of 2 shapes:
871 * Image shell *Sh11* consisting of split face parts of *Sh1: Fn1, Fn2 ... Fn8.*
872 * Solid *So21* with internal shell. (image of *So2*).
873 @figure{/user_guides/boolean_operations/images/operations_image030.png,"A shell and a solid: results",420}
874
875 @subsubsection occt_algorithms_7_3_10 Case 10: A compound and a solid
876
877 Let us consider compound *Cm1* consisting of 2 solids *So11* and *So12*) and solid *So2*.
878 @figure{/user_guides/boolean_operations/images/operations_image031.png,"A compound and a solid: arguments",220}
879
880 The result of the GF operation is a compound consisting of 4 shapes:
881 * Image compound *Cm11* consisting of split solid parts from *So11* and *So12 (Sn1, Sn2, Sn3, Sn4)*.
882 * Split parts of solid *So2 (Sn2, Sn3, Sn5)*.
883
884 @figure{/user_guides/boolean_operations/images/operations_image032.png,"A compound and a solid: results",420}
885
886 @subsection occt_algorithms_7_4 Class BOPAlgo_Builder
887
888 GFA is implemented in the class *BOPAlgo_Builder*.
889
890 @subsubsection occt_algorithms_7_4_1 Fields
891
892 The main fields of the class are described in the Table: 
893
894 | Name | Contents |
895 | :---- | :---- |
896 | *myPaveFiller* |      Pointer to the *BOPAlgo_PaveFiller* object |
897 | *myDS* |      Pointer to the *BOPDS_DS* object |
898 | *myContext* | Pointer to the intersection Context |
899 | *myImages* | The Map between the source shape and its images | 
900 | *myShapesSD* |        The Map between the source shape (or split part of source shape) and the shape (or part of shape) that will be used in result due to same domain property. |
901
902 @subsubsection occt_algorithms_7_4_2 Initialization
903
904 The input data for this step is a *BOPAlgo_PaveFiller* object (in terms of @ref  occt_algorithms_5 "Intersection") at the state after @ref occt_algorithms_5_12 "Processing of degenerated edges"  with the corresponding DS.
905
906 | No | Contents | Implementation |
907 | :---- | :---- | :---- |
908 | 1     | Check the readiness of the DS and *BOPAlgo_PaveFiller*. | *BOPAlgo_Builder::CheckData()* | 
909 | 2     | Build an empty result of type Compound. | *BOPAlgo_Builder::Prepare()* |
910
911 @subsubsection occt_algorithms_7_4_3 Build Images for Vertices
912
913 The input data for this step is *BOPAlgo_Builder* object  after Initialization.
914
915 | No | Contents | Implementation  |
916 | :--- | :--- | :--- | 
917 | 1     | Fill *myShapesSD*  by SD vertices using the information from the DS. |        *BOPAlgo_Builder::FillImagesVertices()* |
918
919 @subsubsection occt_algorithms_7_4_4 Build Result of Type Vertex
920
921 The input data for this step is *BOPAlgo_Builder* object  after building images for vertices and *Type*, which is the shape type (*TopAbs_VERTEX*).
922
923 | No | Contents | Implementation |
924 | :--- | :--- | :----- |
925 | 1 |   For the arguments of type *Type*.       If there is an image for the argument: add the image to the result. If there is no image for the argument: add the argument to the result. | *BOPAlgo_Builder::BuildResult()* |
926
927 @subsubsection occt_algorithms_7_4_5 Build Images for Edges
928
929 The input data for this step is *BOPAlgo_Builder object* after building result of type vertex.
930
931 | No | Contents | Implementation |
932 | :---- | :---- | :----- | 
933 | 1     | For all pave blocks in the DS. Fill *myImages*  for the original edge *E* by split edges *ESPi* from pave blocks. In case of common blocks on edges, use edge *ESPSDj* that corresponds to the leading pave block and fill *myShapesSD* by the pairs *ESPi/ESPSDj*. | *BOPAlgo_Builder::FillImagesEdges()* |
934
935 @subsubsection occt_algorithms_7_4_6 Build Result of Type Edge
936
937 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex", but for the type *Edge*.
938
939 @subsubsection occt_algorithms_7_4_7 Build Images for Wires
940
941 The input data for this step is: 
942 * *BOPAlgo_Builder* object after building result of type *Edge*;
943 * Original Shape -- Wire
944 * *Type* -- the shape type <i>(TopAbs_WIRE).</i>
945
946 | No | Contents | Implementation |
947 | :---- | :---- | :----- | 
948 | 1     | For all arguments of the type *Type*. Create a container C of the type *Type*. | *BOPAlgo_Builder::FillImagesContainers()* |
949 | 2     | Add to C the images or non-split parts of the *Original Shape*, taking into account its orientation. | *BOPAlgo_Builder::FillImagesContainers()* *BOPTools_Tools::IsSplitToReverse()* |
950 | 3     | Fill *myImages*  for the *Original Shape* by the information above. | *BOPAlgo_Builder::FillImagesContainers()* | 
951
952 @subsubsection occt_algorithms_7_4_8    Build Result of Type Wire
953
954 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex" but for the type *Wire*.
955
956 @subsubsection occt_algorithms_7_4_9    Build Images for Faces
957
958 The input data for this step is *BOPAlgo_Builder* object after building result of type *Wire*.
959  
960 | No | Contents | Implementation |
961 | :--- | :--- | :--- |
962 | 1     | Build Split Faces     for all interfered DS shapes *Fi* of type *FACE*. | |   
963 | 1.1 | Collect all edges or their images of *Fi(ESPij)*. |     *BOPAlgo_Builder::BuildSplitFaces()* |
964 | 1.2 | Impart to ESPij the orientation to be coherent with the original one. | *BOPAlgo_Builder::BuildSplitFaces()* |
965 | 1.3 | Collect all section edges *SEk* for *Fi*. | *BOPAlgo_Builder::BuildSplitFaces()* |
966 | 1.4 | Build split faces for *Fi (Fi1, Fi2…FiNbSp)*, where *NbSp* is the number of split parts (see @ref occt_algorithms_7_2 "Building faces from a set of edges" for more details). | *BOPAlgo_BuilderFace* | 
967 | 1.5 | Impart to <i>(Fi1, Fi2…FiNbSp)</i> the orientation coherent with the original face *Fi*. | *BOPAlgo_Builder::BuildSplitFaces()* | 
968 | 1.6 | Fill the map mySplits with *Fi/(Fi1, Fi2…FiNbSp)* | *BOPAlgo_Builder::BuildSplitFaces()* |
969 | 2 | Fill Same Domain faces | *BOPAlgo_Builder::FillSameDomainFaces* | 
970 | 2.1 |  Find and collect in the contents of *mySplits* the pairs of same domain split faces <i>(Fij, Fkl)m</i>, where *m* is the number of pairs. | *BOPAlgo_Builder::FillSameDomainFaces* *BOPTools_Tools::AreFacesSameDomain()* |
971 | 2.2 | Compute the connexity chains 1) of same domain faces <i>(F1C, F2C… FnC)k, C=0, 1…nCs,</i> where *nCs* is the number of connexity chains. | *BOPAlgo_Builder::FillSameDomainFaces()* | 
972 | 2.3 | Fill *myShapesSD* using the chains <i>(F1C, F2C… FnC)k</i> |  *BOPAlgo_Builder::FillSameDomainFaces()* |
973 | 2.4 | Add internal vertices to split faces. | *BOPAlgo_Builder::FillSameDomainFaces()* |
974 | 2.5 | Fill *myImages* using *myShapesSD* and *mySplits*.      | *BOPAlgo_Builder::FillSameDomainFaces()* |
975
976
977 The example of chains of same domain faces is given in the image:
978
979 @figure{/user_guides/boolean_operations/images/operations_image033.svg,"Chains of same domain faces",420}
980
981 * The pairs of same domain faces are: <i>(F11, F21), (F22, F31), (F41, F51) , (F41, F6)</i> and <i>(F51, F6)</i>.
982 * The pairs produce the three chains: <i>(F11, F21), (F22, F31)</i> and <i>(F41, F51, F6)</i>.
983
984 @subsubsection occt_algorithms_7_4_10   Build Result of Type Face
985 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex" but for the type *Face*.
986
987 @subsubsection occt_algorithms_7_4_11   Build Images for Shells
988 The input data for this step is:
989 * *BOPAlgo_Builder* object  after building result of type face;
990 * *Original Shape* -- a Shell;
991 * *Type* -- the type of the shape <i>(TopAbs_SHELL)</i>.
992
993 The procedure is the same as for building images for wires. 
994
995 @subsubsection occt_algorithms_7_4_12   Build Result of Type Shell
996 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex" but for the type *Shell*.
997
998 @subsubsection occt_algorithms_7_4_13 Build Images for Solids
999
1000 The input data for this step is *BOPAlgo_Builder* object after building result of type *Shell*. 
1001
1002 The following procedure is executed for all interfered DS shapes *Si* of type *SOLID*.  
1003
1004 | No | Contents | Implementation | 
1005 | :--- | :--- | :--- | 
1006 | 1     | Collect all images or non-split parts for all faces <i>(FSPij)</i> that have 3D state *In Si*. | *BOPAlgo_Builder::FillIn3DParts ()* | 
1007 | 2     | Collect all images or non-split parts for all faces of *Si* | *BOPAlgo_Builder::BuildSplitSolids()* |
1008 | 3     | Build split solids for *Si -> (Si1, Si2…SiNbSp)*, where *NbSp* is the number of split parts (see @ref occt_algorithms_7_2 "Building faces from a set of edges" for more details) | *BOPAlgo_BuilderSolid* |
1009 | 4     | Fill the map Same Domain solids *myShapesSD* | *BOPAlgo_Builder::BuildSplitSolids()* |
1010 | 5     | Fill the map *myImages* |  *BOPAlgo_Builder::BuildSplitSolids()* |
1011 | 6     | Add internal vertices to split solids | *BOPAlgo_Builder::FillInternalShapes()* |
1012
1013 @subsubsection occt_algorithms_7_4_14 Build Result of Type Solid
1014 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex", but for the type Solid.
1015
1016 @subsubsection occt_algorithms_7_4_15 Build Images for Type CompSolid
1017
1018 The input data for this step is:
1019 * *BOPAlgo_Builder* object after building result of type solid;
1020 * *Original Shape* -- a Compsolid;
1021 * *Type* -- the type of the shape <i>(TopAbs_COMPSOLID)</i>.
1022
1023 The procedure is the same as for building images for wires. 
1024
1025 @subsubsection occt_algorithms_7_4_16 Build Result of Type Compsolid
1026 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex", but for the type Compsolid.
1027
1028 @subsubsection occt_algorithms_7_4_17 Build Images for Compounds
1029 The input data for this step is as follows:
1030 * *BOPAlgo_Builder* object after building results of type *compsolid*;
1031 * *Original Shape* -- a Compound;
1032 * *Type* -- the type of the shape <i>(TopAbs_COMPOUND)</i>.
1033
1034 The procedure is the same as for building images for wires. 
1035
1036 @subsubsection occt_algorithms_7_4_18 Build Result of Type Compound
1037
1038 This step is the same as @ref occt_algorithms_7_4_4 "Building Result of Type Vertex", but for the type Compound.
1039
1040 @subsubsection occt_algorithms_7_4_19 Post-Processing
1041 The purpose of the step is to correct tolerances of the result to provide its validity in terms of *BRepCheck_Analyzer.*
1042
1043 The input data for this step is a *BOPAlgo_Builder* object after building result of type compound.
1044
1045 | No |  Contents | Implementation  |
1046 | :---- | :---- | :----- |
1047 | 1     | Correct tolerances of vertices on curves | *BOPTools_Tools::CorrectPointOnCurve()* |
1048 | 2     | Correct tolerances of edges on faces | *BOPTools_Tools::CorrectCurveOnSurface()* |
1049
1050
1051 @section occt_algorithms_8  Splitter Algorithm
1052
1053 The Splitter algorithm allows splitting a group of arbitrary shapes by another group of arbitrary shapes.<br>
1054 It is based on the General Fuse  algorithm, thus all options of the General Fuse such as Fuzzy mode, safe processing mode, parallel mode, gluing mode and history support are also available in this algorithm.
1055
1056 @subsection occt_algorithms_8_1 Arguments
1057
1058 * The arguments of the Splitter algorithm are divided into two groups - *Objects* (shapes that will be split) and *Tools* (shapes, by which the *Objects* will be split);
1059 * The requirements for the arguments (both for *Objects* and *Tools*) are the same as for the General Fuse algorithm - there can be any number of arguments of any type in each group, but each argument should be valid and not self-interfered.
1060
1061 @subsection occt_algorithms_8_2 Results
1062
1063 * The result of Splitter algorithm contains only the split parts of the shapes included into the group of *Objects*;
1064 * The split parts of the shapes included only into the group of *Tools* are excluded from the result;
1065 * If there are no shapes in the group of *Tools* the result of the operation will be equivalent to the result of General Fuse operation;
1066 * The shapes can be split by other shapes from the same group (if these shapes are interfering).
1067
1068 @subsection occt_algorithms_8_3 Usage
1069
1070 @subsubsection occt_algorithms_8_3_1 API
1071
1072 On the low level the Splitter algorithm is implemented in class *BOPAlgo_Splitter*. The usage of this algorithm looks as follows:
1073 ~~~~~
1074 BOPAlgo_Splitter aSplitter;
1075 BOPCol_ListOfShape aLSObjects = …; // Objects
1076 BOPCol_ListOfShape aLSTools = …; // Tools
1077 Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
1078 Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
1079 Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
1080 BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
1081 // setting arguments
1082 aSplitter.SetArguments(aLSObjects);
1083 aSplitter.SetTools(aLSTools);
1084 // setting options
1085 aSplitter.SetRunParallel(bRunParallel);
1086 aSplitter.SetFuzzyValue(aTol);
1087 aSplitter.SetNonDestructive(bSafeMode);
1088 aSplitter.SetGlue(aGlue);
1089 //
1090 aSplitter.Perform(); //perform the operation
1091 if (aSplitter.ErrorStatus()) { //check error status
1092   return;
1093 }
1094 //
1095 const TopoDS_Shape& aResult = aSplitter.Shape(); // result of the operation
1096 ~~~~~
1097
1098 @subsubsection occt_algorithms_8_3_2 DRAW
1099
1100 The command *bsplit* implements the Splitter algorithm in DRAW. Similarly to the *bbuild* command for the General Fuse algorithm, the *bsplit* command should be used after the Pave Filler is filled.
1101 ~~~~~
1102 # s1 s2 s3 - objects
1103 # t1 t2 t3 - tools
1104 bclearobjects
1105 bcleartools
1106 baddobjects s1 s2 s3
1107 baddtools t1 t2 t3
1108 bfillds
1109 bsplit result
1110 ~~~~~
1111
1112 @subsection occt_algorithms_8_4 Examples
1113
1114 @subsubsection occt_algorithms_8_4_1 Example 1
1115
1116 Splitting a face by the set of edges:
1117
1118 ~~~~
1119 # draw script for reproducing
1120 bclearobjects
1121 bcleartools
1122
1123 set height 20
1124 cylinder cyl 0 0 0 0 0 1 10
1125 mkface f cyl 0 2*pi -$height $height
1126 baddobjects f
1127
1128 # create tool edges
1129 compound edges
1130
1131 set nb_uedges 10
1132 set pi2 [dval 2*pi]
1133 set ustep [expr $pi2/$nb_uedges]
1134 for {set i 0} {$i <= $pi2} {set i [expr $i + $ustep]} {
1135   uiso c cyl $i
1136   mkedge e c -25 25
1137   add e edges
1138 }
1139
1140 set nb_vedges 10
1141 set vstep [expr 2*$height/$nb_vedges]
1142 for {set i -20} {$i <= 20} {set i [expr $i + $vstep]} {
1143   viso c cyl $i
1144   mkedge e c
1145   add e edges
1146 }
1147 baddctools edges
1148
1149 bfillds
1150 bsplit result
1151 ~~~~
1152
1153 <table align="center">
1154 <tr>
1155   <td>@figure{/user_guides/boolean_operations/images/bsplit_image001.png,"Arguments",160}</td>
1156   <td>@figure{/user_guides/boolean_operations/images/bsplit_image002.png,"Result",160}</td>
1157 </tr>
1158 </table>
1159
1160 @subsubsection occt_algorithms_8_4_2 Example 2
1161
1162 Splitting a plate by the set of cylinders:
1163
1164 ~~~~
1165 # draw script for reproducing:
1166 bclearobjects
1167 bcleartools
1168
1169 box plate 100 100 1
1170 baddobjects plate
1171
1172 pcylinder p 1 11
1173 compound cylinders
1174 for {set i 0} {$i < 101} {incr i 5} {
1175   for {set j 0} {$j < 101} {incr j 5} {
1176     copy p p1;
1177     ttranslate p1 $i $j -5;
1178     add p1 cylinders
1179   }
1180 }
1181 baddtools cylinders
1182
1183 bfillds
1184 bsplit result
1185 ~~~~
1186
1187 <table align="center">
1188 <tr>
1189   <td>@figure{/user_guides/boolean_operations/images/bsplit_image003.png,"Arguments",160}</td>
1190   <td>@figure{/user_guides/boolean_operations/images/bsplit_image004.png,"Result",160}</td>
1191 </tr>
1192 </table>
1193
1194 @subsubsection occt_algorithms_8_4_3 Example 3
1195
1196 Splitting shell hull by the planes:
1197 <table align="center">
1198 <tr>
1199   <td>@figure{/user_guides/boolean_operations/images/bsplit_image005.png,"Arguments",160}</td>
1200   <td>@figure{/user_guides/boolean_operations/images/bsplit_image006.png,"Results",160}</td>
1201 </tr>
1202 </table>
1203
1204 @section occt_algorithms_9      Boolean Operations Algorithm
1205
1206 @subsection occt_algorithms_9_1 Arguments
1207
1208 * The arguments of BOA are shapes in terms of *TopoDS_Shape*. The main requirements for the arguments are described in the @ref occt_algorithms_4 "Data Structure"
1209 * There are two groups of arguments in BOA:
1210         * Objects <i>(S1=S11, S12, ...)</i>;
1211         * Tools <i>(S2=S21, S22, ...)</i>.
1212 * The following table contains the values of dimension for different types of arguments:
1213
1214 | No | Type of Argument | Index of Type | Dimension |
1215 | :---- | :---- | :----- | :---- |
1216 | 1 | COMPOUND | 0 | One of 0, 1, 2, 3 |
1217 | 2     | COMPSOLID     | 1     | 3 |
1218 | 3     | SOLID | 2     | 3 |
1219 | 4     | SHELL | 3     | 2 |
1220 | 5     | FACE | 4 | 2 |
1221 | 6     | WIRE | 5 | 1 |
1222 | 7 | EDGE | 6 | 1 |
1223 | 8 | VERTEX | 7 | 0 |
1224
1225 * For Boolean operation Fuse all arguments should have equal dimensions.
1226 * For Boolean operation Cut the minimal dimension of *S2* should not be less than the maximal dimension of *S1*.
1227 * For Boolean operation Common the arguments can have any dimension.
1228
1229 @subsection occt_algorithms_9_3 Results. General Rules
1230
1231 * The result of the Boolean operation is a compound (if defined). Each sub-shape of the compound has shared sub-shapes in accordance with interferences between the arguments. 
1232 * The content of the result depends on the type of the operation (Common, Fuse, Cut12, Cut21) and the dimensions of the arguments. 
1233 * The result of the operation Fuse is defined for arguments *S1* and *S2* that have the same dimension value : *Dim(S1)=Dim(S2)*. If the arguments have different dimension values the result of the operation Fuse is not defined. The dimension of the result is equal to the dimension of the arguments. For example, it is impossible to fuse an edge and a face.
1234 * The result of the operation Fuse for arguments *S1* and *S2* contains the parts of arguments that have states **OUT** relative to the opposite arguments.
1235 * The result of the operation Fuse for arguments *S1* and *S2* having dimension value 3 (Solids) is refined by removing all possible internal faces to provide minimal number of solids.
1236 * The result of the operation Common for arguments *S1* and *S2* is defined for all values of the dimensions of the arguments. The result can contain shapes of different dimensions, but the minimal dimension of the result will be equal to the minimal dimension of the arguments. For example, the result of the operation Common between edges cannot be a vertex. 
1237 * The result of the operation Common for the arguments *S1* and *S2* contains the parts of the argument that have states **IN** and **ON** relative to the opposite argument.
1238 * The result of the operation Cut is defined for arguments *S1* and *S2* that have values of dimensions *Dim(S2)* that should not be less than *Dim(S1)*. The result can contain shapes of different dimensions, but the minimal dimension of the result will be equal to the minimal dimension of the objects *Dim(S1)*. The result of the operation *Cut12* is not defined for other cases. For example, it is impossible to cut an edge from a solid, because a solid without an edge is not defined. 
1239 * The result of the operation *Cut12* for arguments *S1* and *S2* contains the parts of argument *S1* that have state **OUT** relative to the opposite argument *S2*.
1240 * The result of the operation *Cut21* for arguments *S1* and *S2* contains the parts of argument *S2* that have state **OUT** relative to the opposite argument *S1*.
1241 * For the arguments of collection type (WIRE, SHELL, COMPSOLID) the type will be passed in the result. For example, the result of Common operation between Shell and Wire will be a compound containing Wire.
1242 * For the arguments of collection type (WIRE, SHELL, COMPSOLID) containing overlapping parts the overlapping parts passed into result will be repeated for each container from the input shapes containing such parts. The containers completely included in other containers will be avoided in the result.
1243 * For the arguments of collection type (WIRE, SHELL, COMPSOLID) the containers included into result will have the same orientation as the original containers from arguments. In case of duplication its orientation will be defined by the orientation of the first container in arguments. Each container included into result will have coherent orientation of its sub-shapes.
1244 * The result of the operation Fuse for the arguments of collection type (WIRE, SHELL) will consist of the shapes of the same collection type. The overlapping parts (EDGES/FACES) will be shared among containers, but duplicating containers will be avoided in the result. For example, the result of Fuse operation between two fully coinciding wires will be one wire, but the result of Fuse operation between two partially coinciding wires will be two wires sharing coinciding edges.
1245 * The result of the operation Fuse for the arguments of type COMPSOLID will consist of the compound containing COMPSOLIDs created from connexity blocks of fused solids.
1246 * The result of the operation Common for the arguments of collection type (WIRE, SHELL, COMPSOLID) will consist of the unique containers containing the overlapping parts. For example, the result of Common operation between two fully overlapping wires will be one wire containing all splits of edges. The number of wires in the result of Common operation between two partially overlapping wires will be equal to the number of connexity blocks of overlapping edges.
1247
1248 @subsection occt_algorithms_9_4 Examples
1249
1250 @subsubsection occt_algorithms_9_4_1    Case 1: Two Vertices
1251
1252 Let us consider two interfering vertices *V1* and *V2*:
1253
1254 @figure{/user_guides/boolean_operations/images/boolean_image001.svg,"",160}
1255
1256 * The result of *Fuse* operation is the compound that contains new vertex *V*.
1257
1258 @figure{/user_guides/boolean_operations/images/boolean_image002.svg,"",160}
1259
1260 * The result of *Common* operation is a compound containing new vertex *V*.
1261
1262 * The result of *Cut12* operation is an empty compound.
1263 * The result of *Cut21* operation is an empty compound.
1264
1265 @subsubsection occt_algorithms_9_4_2    Case 2: A Vertex and an Edge
1266
1267 Let us consider vertex *V1* and the edge *E2*, that intersect in a 3D point:
1268
1269 @figure{/user_guides/boolean_operations/images/boolean_image004.png,"",230}
1270
1271 * The result of *Fuse* operation is result is not defined because the dimension of the vertex (0) is not equal to the dimension of the edge (1).
1272
1273 * The result of *Common* operation is a compound containing vertex *V<sub>1</sub>* as the argument *V<sub>1</sub>* has a common part with edge *E2*.
1274
1275 @figure{/user_guides/boolean_operations/images/boolean_image005.png,"",230}
1276
1277 * The result of *Cut12* operation is an empty compound.
1278 * The result of *Cut21* operation is not defined because the dimension of the vertex (0) is less than the dimension of the edge (1).
1279
1280 @subsubsection occt_algorithms_9_4_3    Case 3: A Vertex and a Face
1281
1282 Let us consider  vertex *V1* and face *F2*, that intersect in a 3D point:
1283
1284 @figure{/user_guides/boolean_operations/images/boolean_image006.png,"",230}
1285
1286 * The result of *Fuse* operation is not defined because the dimension of the vertex (0) is not equal to the dimension of the face (2).
1287
1288 * The result of *Common* operation is a compound containing vertex *V<sub>1</sub>* as the argument *V<sub>1</sub>* has a common part with face *F2*.
1289
1290 @figure{/user_guides/boolean_operations/images/boolean_image007.png,"",230}
1291
1292 * The result of *Cut12* operation is an empty compound.
1293 * The result of *Cut21* operation is not defined because the dimension of the vertex (0) is less than the dimension of the face (2).
1294
1295 @subsubsection occt_algorithms_9_4_4    Case 4: A Vertex and a Solid
1296
1297 Let us consider  vertex *V1* and solid *S2*, that intersect in a 3D point:
1298
1299 @figure{/user_guides/boolean_operations/images/boolean_image008.png,"",230}
1300
1301 * The result of *Fuse* operation is not defined because the dimension of the vertex (0) is not equal to the dimension of the solid (3).
1302
1303 * The result of *Common* operation is a compound containing vertex *V<sub>1</sub>* as the argument *V<sub>1</sub>* has a common part with solid *S2*.
1304
1305 @figure{/user_guides/boolean_operations/images/boolean_image009.png,"",230}
1306
1307 * The result of *Cut12* operation is an empty compound.
1308 * The result of *Cut21* operation is not defined because the dimension of the vertex (0) is less than the dimension of the solid (3).
1309
1310 @subsubsection occt_algorithms_9_4_5    Case 5: Two edges intersecting at one point
1311
1312 Let us consider edges *E1* and *E2* that intersect in a 3D point:
1313
1314 @figure{/user_guides/boolean_operations/images/boolean_image010.svg,"",230}
1315
1316 * The result of *Fuse* operation is a compound containing split parts of arguments i.e. 4 new edges *E11, E12, E21*, and *E22*. These edges have one shared vertex *Vn1*. 
1317 In this case: 
1318         * argument edge *E1* has resulting split edges *E11* and *E12* (image of *E1*);
1319         * argument edge *E2* has resulting split edges *E21* and *E22* (image of *E2*).
1320         
1321 @figure{/user_guides/boolean_operations/images/boolean_image011.svg,"",230}
1322
1323 * The result of *Common* operation is an empty compound because the dimension (0) of the common part between the edges (vertex) is less than the dimension of the arguments (1).
1324
1325 * The result of *Cut12* operation is a compound containing split parts of the argument  *E1*, i.e. 2 new edges *E11* and *E12*. These edges have one shared vertex *Vn1*. 
1326
1327 In this case the argument edge *E1* has resulting split edges *E11* and *E12* (image of *E1*).
1328
1329 @figure{/user_guides/boolean_operations/images/boolean_image012.svg,"",230}
1330
1331 * The result of *Cut21* operation is a compound containing split parts of the argument  *E2*, i.e. 2 new edges *E21* and *E12*. These edges have one shared vertex *Vn1*. 
1332
1333 In this case the argument edge *E2* has resulting split edges *E21* and *E22* (image of *E2*).
1334
1335 @figure{/user_guides/boolean_operations/images/boolean_image013.svg,"",70}
1336
1337 @subsubsection occt_algorithms_9_4_6    Case 6: Two edges having a common block
1338
1339 Let us consider edges *E1* and *E2* that have a common block:
1340
1341 @figure{/user_guides/boolean_operations/images/boolean_image014.svg,"",230}
1342
1343 * The result of *Fuse* operation is a compound containing split parts of arguments i.e. 3 new edges *E11*, *E12* and *E22*. These edges have two shared vertices. 
1344 In this case: 
1345         * argument edge *E1* has resulting split edges *E11* and *E12* (image of *E1*);
1346         * argument edge *E2* has resulting split edges *E21* and *E22* (image of *E2*);
1347         * edge *E12* is common for the images of *E1* and *E2*.
1348         
1349 @figure{/user_guides/boolean_operations/images/boolean_image015.svg,"",230}
1350
1351 * The result of *Common* operation is a compound containing split parts of arguments i.e. 1 new edge *E12*. In this case edge *E12* is common for the images of *E1* and *E2*. 
1352 The common part between the edges (edge) has the same dimension (1) as the dimension of the arguments (1).
1353
1354 @figure{/user_guides/boolean_operations/images/boolean_image016.svg,"",230}
1355
1356 * The result of *Cut12* operation is a compound containing a split part of argument  *E1*, i.e. new edge *E11*. 
1357
1358 @figure{/user_guides/boolean_operations/images/boolean_image017.svg,"",230}
1359
1360 * The result of *Cut21* operation is a compound containing a split part of argument  *E2*, i.e. new edge *E22*.
1361
1362 @figure{/user_guides/boolean_operations/images/boolean_image018.svg,"",230}
1363
1364
1365 @subsubsection occt_algorithms_9_4_7    Case 7: An Edge and a Face intersecting at a point
1366
1367 Let us consider edge *E1* and face *F2* that intersect at a 3D point:
1368
1369 @figure{/user_guides/boolean_operations/images/boolean_image019.png,"",230}
1370
1371 * The result of *Fuse* operation is not defined because the dimension of the edge (1) is not equal to the dimension of the face (2).
1372         
1373 * The result of *Common* operation is an empty compound because the dimension (0) of the common part between the edge and face (vertex) is less than the dimension of the arguments (1).
1374
1375 * The result of *Cut12* operation is a compound containing split parts of the argument  *E1*, i.e. 2 new edges *E11* and *E12*.  
1376
1377 In this case the argument edge *E1* has no common parts with the face *F2* so the whole image of *E1* is in the result.
1378
1379 @figure{/user_guides/boolean_operations/images/boolean_image020.png,"",230}
1380
1381 * The result of *Cut21* operation is not defined because the dimension of the edge (1) is less than the dimension of the face (2).
1382
1383 @subsubsection occt_algorithms_9_4_8    Case 8: A Face and an Edge that have a common block
1384
1385 Let us consider edge *E1* and face *F2* that have a common block:
1386
1387 @figure{/user_guides/boolean_operations/images/boolean_image021.png,"",230}
1388
1389 * The result of *Fuse* operation is not defined because the dimension of the edge (1) is not equal to the dimension of the face (2).
1390         
1391 * The result of *Common* operation is a compound containing a split part of the argument  *E1*, i.e. new edge *E12*. 
1392
1393 In this case the argument edge *E1* has a common part with face *F2* so the corresponding part of the image of *E1* is in the result. The yellow square is not a part of the result. It only shows the place of *F2*.
1394
1395 @figure{/user_guides/boolean_operations/images/boolean_image022.png,"",230}
1396
1397 * The result of *Cut12* operation is a compound containing split part of the argument  *E1*, i.e. new edge *E11*.  
1398
1399 In this case the argument edge *E1* has a common part with face *F2* so the corresponding part is not included into the result. The yellow square is not a part of the result. It only shows the place of F2.
1400
1401 @figure{/user_guides/boolean_operations/images/boolean_image023.png,"",230}
1402
1403 * The result of *Cut21* operation is not defined because the dimension of the edge (1) is less than the dimension of the face (2).
1404
1405 @subsubsection occt_algorithms_9_4_9    Case 9: An Edge and a Solid intersecting at a point 
1406
1407 Let us consider edge *E1* and solid *S2* that intersect at a point:
1408
1409 @figure{/user_guides/boolean_operations/images/boolean_image024.png,"",230}
1410
1411 * The result of *Fuse* operation is not defined because the dimension of the edge (1) is not equal to the dimension of the solid (3).
1412         
1413 * The result of *Common* operation is a compound containing a split part of the argument  *E1*, i.e. new edge *E12*. 
1414
1415 In this case the argument edge *E1* has a common part with solid *S2* so the corresponding part of the image of *E1* is in the result. The yellow square is not a part of the result. It only shows the place of *S2*.
1416
1417 @figure{/user_guides/boolean_operations/images/boolean_image025.png,"",230}
1418
1419 * The result of *Cut12* operation is a compound containing split part of the argument *E1*, i.e. new edge *E11*.  
1420
1421 In this case the argument edge *E1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow square is not a part of the result. It only shows the place of *S2*.
1422
1423 @figure{/user_guides/boolean_operations/images/boolean_image071.png,"",230}
1424
1425 * The result of *Cut21* operation is not defined because the dimension of the edge (1) is less than the dimension of the solid (3).
1426
1427 @subsubsection occt_algorithms_9_4_10 Case 10: An Edge and a Solid that have a common block 
1428
1429 Let us consider edge *E1* and solid *S2* that have a common block:
1430
1431 @figure{/user_guides/boolean_operations/images/boolean_image072.png,"",230}
1432
1433 * The result of *Fuse* operation is not defined because the dimension of the edge (1) is not equal to the dimension of the solid (3).
1434         
1435 * The result of *Common* operation is a compound containing a split part of the argument  *E1*, i.e. new edge *E12*. 
1436
1437 In this case the argument edge *E1* has a common part with solid *S2* so the corresponding part of the image of *E1* is in the result. The yellow square is not a part of the result. It only shows the place of *S2*.
1438
1439 @figure{/user_guides/boolean_operations/images/boolean_image073.png,"",230}
1440
1441 * The result of *Cut12* operation is a compound containing split part of the argument *E1*, i.e. new edge *E11*.  
1442
1443 In this case the argument edge *E1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow square is not a part of the result. It only shows the place of *S2*.
1444
1445 @figure{/user_guides/boolean_operations/images/boolean_image026.png,"",230}
1446
1447 * The result of *Cut21* operation is not defined because the dimension of the edge (1) is less than the dimension of the solid (3).
1448
1449 @subsubsection occt_algorithms_9_4_11   Case 11: Two intersecting faces 
1450
1451 Let us consider two intersecting faces *F1* and *F2*:
1452
1453 @figure{/user_guides/boolean_operations/images/boolean_image027.png,"",230}
1454
1455 * The result of *Fuse* operation is a compound containing split parts of arguments  i.e. 2 new faces *F11* and *F21*. These faces have one shared edge *En1*.
1456
1457 @figure{/user_guides/boolean_operations/images/boolean_image028.png,"",230}
1458
1459
1460 * The result of *Common* operation is an empty compound because the dimension (1) of the common part between *F1* and *F2* (edge) is less than the dimension of arguments (2).
1461
1462 * The result of *Cut12* operation is a compound containing split part of the argument *F1*, i.e. new face *F11*.  
1463
1464 @figure{/user_guides/boolean_operations/images/boolean_image029.png,"",230}
1465
1466 * The result of *Cut21* operation is a compound containing split parts of the argument  *F2*, i.e. 1 new face *F21*.
1467
1468 @figure{/user_guides/boolean_operations/images/boolean_image030.png,"",127}
1469         
1470 @subsubsection occt_algorithms_9_4_12   Case 12: Two faces that have a common part
1471
1472 Let us consider two faces *F1* and *F2* that have a common part:
1473
1474 @figure{/user_guides/boolean_operations/images/boolean_image031.png,"",230}
1475
1476 * The result of *Fuse* operation is a compound containing split parts of arguments, i.e. 3 new faces: *F11*, *F12* and *F22*. These faces are shared through edges In this case: 
1477         * the argument edge *F1* has resulting split faces *F11* and *F12* (image of *F1*)
1478         * the argument face *F2* has resulting split faces *F12* and *F22* (image of *F2*)
1479         * the face *F12* is common for the images of *F1* and *F2*.
1480         
1481 @figure{/user_guides/boolean_operations/images/boolean_image032.png,"",230}
1482
1483 * The result of *Common* operation is a compound containing split parts of arguments i.e. 1 new face *F12*. 
1484 In this case: face *F12* is common for the images of *F1* and *F2*.
1485 The common part between the faces (face) has the same dimension (2) as the dimension of the arguments (2).
1486
1487
1488 @figure{/user_guides/boolean_operations/images/boolean_image033.png,"",230}
1489
1490 * The result of *Cut12* operation is a compound containing split part of the argument *F1*, i.e. new face *F11*.  
1491         
1492 @figure{/user_guides/boolean_operations/images/boolean_image034.png,"",230}
1493         
1494 * The result of *Cut21* operation is a compound containing split parts of the argument  *F2*, i.e. 1 new face *F21*.
1495
1496 @figure{/user_guides/boolean_operations/images/boolean_image035.png,"",230}
1497
1498 @subsubsection occt_algorithms_9_4_13   Case 13: Two faces that have a common edge
1499
1500 Let us consider two faces *F1* and *F2* that have a common edge:
1501
1502 @figure{/user_guides/boolean_operations/images/boolean_image036.png,"",230}
1503
1504 * The result of *Fuse* operation is a compound containing split parts of arguments, i.e. 2 new faces: *F11* and *F21*. These faces have one shared edge *En1*.
1505         
1506 @figure{/user_guides/boolean_operations/images/boolean_image037.png,"",230}
1507
1508 * The result of *Common* operation is an empty compound because the dimension (1) of the common part between *F1* and *F2* (edge)is less than the dimension of the arguments (2)
1509
1510 * The result of *Cut12* operation is a compound containing split part of the argument *F1*, i.e. new face *F11*.  The vertices are shown just to clarify the fact that the edges are spitted.
1511         
1512 @figure{/user_guides/boolean_operations/images/boolean_image038.png,"",230}
1513         
1514 * The result of *Cut21* operation is a compound containing split parts of the argument  *F2*, i.e. 1 new face *F21*.  The vertices are shown just to clarify the fact that the edges are spitted.
1515
1516 @figure{/user_guides/boolean_operations/images/boolean_image039.png,"",230}
1517
1518 @subsubsection occt_algorithms_9_4_14   Case 14: Two faces that have a common vertex
1519
1520 Let us consider two faces *F1* and *F2* that have a common vertex:
1521
1522 @figure{/user_guides/boolean_operations/images/boolean_image040.png,"",230}
1523
1524 * The result of *Fuse* operation is a compound containing split parts of arguments, i.e. 2 new faces: *F11* and *F21*. These faces have one shared vertex *Vn1*.
1525         
1526 @figure{/user_guides/boolean_operations/images/boolean_image041.png,"",230}
1527
1528 * The result of *Common* operation is an empty compound because the dimension (0) of the common part between *F1* and *F2* (vertex) is less than the dimension of the arguments (2)
1529
1530 * The result of *Cut12* operation is a compound containing split part of the argument *F1*, i.e. new face *F11*.  
1531         
1532 @figure{/user_guides/boolean_operations/images/boolean_image042.png,"",230}
1533         
1534 * The result of *Cut21* operation is a compound containing split parts of the argument  *F2*, i.e. 1 new face *F21*. 
1535
1536 @figure{/user_guides/boolean_operations/images/boolean_image043.png,"",230}
1537
1538
1539 @subsubsection occt_algorithms_9_4_15   Case 15: A Face and a Solid that have an intersection curve.
1540
1541 Let us consider face *F1* and solid *S2* that have an intersection curve:
1542
1543 @figure{/user_guides/boolean_operations/images/boolean_image044.png,"",230}
1544
1545 * The result of *Fuse* operation is not defined because the dimension of the face (2) is not equal to the dimension of the solid (3).
1546         
1547 * The result of *Common* operation is a compound containing split part of the argument  *F1*. In this case the argument face *F1* has a common part with solid *S2*, so the corresponding part of the image of *F1* is in the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1548
1549 @figure{/user_guides/boolean_operations/images/boolean_image045.png,"",230}
1550
1551 * The result of *Cut12* operation is a compound containing split part of the argument *F1*. In this case  argument face *F1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1552         
1553 @figure{/user_guides/boolean_operations/images/boolean_image046.png,"",230}
1554         
1555 * The result of *Cut21* operation is is not defined because the dimension of the face (2) is less than the dimension of the solid (3).
1556
1557 @subsubsection occt_algorithms_9_4_16   Case 16: A Face and a Solid that have overlapping faces.
1558
1559 Let us consider face *F1* and solid *S2* that have overlapping faces:
1560
1561 @figure{/user_guides/boolean_operations/images/boolean_image047.png,"",230}
1562
1563 * The result of *Fuse* operation is not defined because the dimension of the face (2) is not equal to the dimension of the solid (3).
1564
1565 * The result of *Common* operation is a compound containing split part of the argument  *F1*. In this case the argument face *F1* has a common part with solid *S2*, so the corresponding part of the image of *F1* is included in the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1566
1567 @figure{/user_guides/boolean_operations/images/boolean_image048.png,"",230}
1568
1569 * The result of *Cut12* operation is a compound containing split part of the argument *F1*. In this case  argument face *F1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1570         
1571 @figure{/user_guides/boolean_operations/images/boolean_image049.png,"",230}
1572         
1573 * The result of *Cut21* operation is is not defined because the dimension of the face (2) is less than the dimension of the solid (3).
1574
1575
1576 @subsubsection occt_algorithms_9_4_17   Case 17: A Face and a Solid that have overlapping edges.
1577
1578 Let us consider face *F1* and solid *S2* that have overlapping edges:
1579
1580 @figure{/user_guides/boolean_operations/images/boolean_image050.png,"",230}
1581
1582 * The result of *Fuse* operation is not defined because the dimension of the face (2) is not equal to the dimension of the solid (3).
1583         
1584 * The result of *Common* operation is an empty compound because the dimension (1) of the common part between *F1* and *S2* (edge) is less than the lower dimension of the arguments (2).
1585
1586 * The result of *Cut12* operation is a compound containing split part of the argument *F1*. In this case  argument face *F1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1587         
1588 @figure{/user_guides/boolean_operations/images/boolean_image051.png,"",230}
1589         
1590 * The result of *Cut21* operation is is not defined because the dimension of the face (2) is less than the dimension of the solid (3).
1591
1592 @subsubsection occt_algorithms_9_4_18   Case 18: A Face and a Solid that have overlapping vertices.
1593
1594 Let us consider face *F1* and solid *S2* that have overlapping vertices:
1595
1596 @figure{/user_guides/boolean_operations/images/boolean_image052.png,"",230}
1597
1598 * The result of *Fuse* operation is not defined because the dimension of the face (2) is not equal to the dimension of the solid (3).
1599         
1600 * The result of *Common* operation is an empty compound because the dimension (1) of the common part between *F1* and *S2* (vertex) is less than the lower dimension of the arguments (2).
1601
1602 * The result of *Cut12* operation is a compound containing split part of the argument *F1*. In this case  argument face *F1* has a common part with solid *S2* so the corresponding part is not included into the result. The yellow contour is not a part of the result. It only shows the place of *S2*.
1603         
1604 @figure{/user_guides/boolean_operations/images/boolean_image053.png,"",230}
1605         
1606 * The result of *Cut21* operation is is not defined because the dimension of the face (2) is less than the dimension of the solid (3).
1607
1608 @subsubsection occt_algorithms_9_4_19   Case 19: Two intersecting Solids.
1609
1610 Let us consider two intersecting solids *S1* and *S2*:
1611
1612 @figure{/user_guides/boolean_operations/images/boolean_image054.png,"",230}
1613
1614 * The result of *Fuse* operation is a compound composed from the split parts of arguments *S11, S12* and *S22* <i>(Cut12, Common, Cut21)</i>. All inner webs are removed, so the result is one new solid *R*. 
1615         
1616 @figure{/user_guides/boolean_operations/images/boolean_image055.png,"",230}
1617         
1618 * The result of *Common* operation is a compound containing split parts of arguments i.e. one new solid *S12*.  In this case solid *S12* is common for the images of *S1* and *S2*. The common part between the solids (solid) has the same dimension (3) as the dimension of the arguments (3). The yellow contour is not a part of the result. It only shows the place of *S1*. 
1619
1620 @figure{/user_guides/boolean_operations/images/boolean_image056.png,"",176}
1621
1622 * The result of *Cut12* operation is a compound containing split part of the argument *S1*, i.e. 1 new solid *S11*.
1623         
1624 @figure{/user_guides/boolean_operations/images/boolean_image057.png,"",230}
1625         
1626 * The result of *Cut21* operation is a compound containing split part of the argument *S2*, i.e. 1 new solid *S21*.
1627
1628 @figure{/user_guides/boolean_operations/images/boolean_image058.png,"",230}
1629
1630 @subsubsection occt_algorithms_9_4_20   Case 20: Two Solids that have overlapping faces.
1631
1632 Let us consider two solids *S1* and *S2* that have a common part on face:
1633
1634 @figure{/user_guides/boolean_operations/images/boolean_image059.png,"",230}
1635
1636 * The result of *Fuse* operation is a compound composed from the split parts of arguments *S11, S12* and *S22* <i>(Cut12, Common, Cut21)</i>. All inner webs are removed, so the result is one new solid *R*. 
1637         
1638 @figure{/user_guides/boolean_operations/images/boolean_image060.png,"",230}
1639         
1640 * The result of *Common* operation is an  empty compound because the dimension (2) of the common part between *S1* and *S2* (face) is less than the lower dimension of the arguments (3). 
1641
1642 * The result of *Cut12* operation is a compound containing split part of the argument *S1*, i.e. 1 new solid *S11*.
1643         
1644 @figure{/user_guides/boolean_operations/images/boolean_image061.png,"",230}
1645         
1646 * The result of *Cut21* operation is a compound containing split part of the argument *S2*, i.e. 1 new solid *S21*.
1647 @figure{/user_guides/boolean_operations/images/boolean_image062.png,"",230}
1648
1649
1650 @subsubsection occt_algorithms_9_4_21   Case 21: Two Solids that have overlapping edges.
1651
1652 Let us consider two solids *S1* and *S2* that have overlapping edges:
1653
1654 @figure{/user_guides/boolean_operations/images/boolean_image063.png,"",230}
1655
1656 * The result of *Fuse* operation is a compound composed from the split parts of arguments i.e. 2 new solids *S11* and *S21*. These solids have one shared edge *En1*.
1657         
1658 @figure{/user_guides/boolean_operations/images/boolean_image064.png,"",230}
1659         
1660 * The result of *Common* operation is an  empty compound because the dimension (1) of the common part between *S1* and *S2* (edge) is less than the lower dimension of the arguments (3). 
1661
1662 * The result of *Cut12* operation is a compound containing split part of the argument *S1*. In this case 
1663 argument *S1* has a common part with solid *S2* so the corresponding part is not included into the result.
1664         
1665 @figure{/user_guides/boolean_operations/images/boolean_image065.png,"",230}
1666         
1667 * The result of *Cut21* operation is a compound containing split part of the argument *S2*. In this case 
1668 argument *S2* has a common part with solid *S1* so the corresponding part is not included into the result.
1669
1670 @figure{/user_guides/boolean_operations/images/boolean_image066.png,"",230}
1671
1672 @subsubsection occt_algorithms_9_4_22   Case 22: Two Solids that have overlapping vertices.
1673
1674 Let us consider two solids *S1* and *S2* that have overlapping vertices:
1675
1676 @figure{/user_guides/boolean_operations/images/boolean_image067.png,"",230}
1677
1678 * The result of *Fuse* operation is a compound composed from the split parts of arguments i.e. 2 new solids *S11* and *S21*. These solids share *Vn1*.
1679         
1680 @figure{/user_guides/boolean_operations/images/boolean_image068.png,"",230}
1681         
1682 * The result of *Common* operation is an  empty compound because the dimension (0) of the common part between *S1* and *S2* (vertex) is less than the lower dimension of the arguments (3). 
1683
1684 * The result of *Cut12* operation is a compound containing split part of the argument *S1*.
1685         
1686 @figure{/user_guides/boolean_operations/images/boolean_image069.png,"",230}
1687         
1688 * The result of *Cut21* operation is a  compound containing split part of the argument *S2*. 
1689
1690 @figure{/user_guides/boolean_operations/images/boolean_image070.png,"",230}
1691
1692 @subsubsection occt_algorithms_9_4_23   Case 23: A Shell and a Wire cut by a Solid.
1693
1694 Let us consider Shell *Sh* and Wire *W* as the objects and Solid *S* as the tool:
1695
1696 @figure{/user_guides/boolean_operations/images/boolean_image136.png,"",230}
1697
1698 * The result of *Fuse* operation is not defined as the dimension of the arguments is not the same.
1699         
1700 * The result of *Common* operation is a compound containing the parts of the initial Shell and Wire common for the Solid. The new Shell and Wire are created from the objects.
1701
1702 @figure{/user_guides/boolean_operations/images/boolean_image137.png,"",230}
1703
1704 * The result of *Cut12* operation is a  compound containing new Shell and Wire split from the arguments *Sh* and *W*. In this case they have a common part with solid *S* so the corresponding part is not included into the result.
1705         
1706 @figure{/user_guides/boolean_operations/images/boolean_image138.png,"",230}
1707         
1708 * The result of *Cut21* operation is not defined as the objects have a lower dimension than the tool. 
1709
1710 @subsubsection occt_algorithms_9_4_24   Case 24: Two Wires that have overlapping edges.
1711
1712 Let us consider two Wires that have overlapping edges, *W1* is the object and *W2* is the tool:
1713
1714 @figure{/user_guides/boolean_operations/images/boolean_image139.png,"",230}
1715
1716 * The result of *Fuse* operation is a compound containing two Wires, which share an overlapping edge. The new Wires are created from the objects:
1717
1718 @figure{/user_guides/boolean_operations/images/boolean_image140.png,"",230}
1719         
1720 * The result of *Common* operation is a compound containing one Wire consisting of an overlapping edge. The new Wire is created from the objects:
1721
1722 @figure{/user_guides/boolean_operations/images/boolean_image141.png,"",230}
1723
1724 * The result of *Cut12* operation is a compound containing a wire split from object *W1*. Its common part with *W2* is not included into the result.
1725         
1726 @figure{/user_guides/boolean_operations/images/boolean_image142.png,"",230}
1727         
1728 * The result of *Cut21* operation is a compound containing a wire split from *W2*. Its common part with *W1* is not included into the result.
1729         
1730 @figure{/user_guides/boolean_operations/images/boolean_image143.png,"",230}
1731
1732
1733 @subsection occt_algorithms_9_5 Class BOPAlgo_BOP
1734
1735 BOA is implemented in the class *BOPAlgo_BOP*. The main fields of this class are described in the Table:
1736
1737 | Name | Contents |
1738 | :---- | :--- |        
1739 | *myOperation* | The type of the Boolean operation (Common, Fuse, Cut) |
1740 | *myTools* |   The tools |
1741 | *myDims[2]* | The values of the dimensions of the arguments |
1742 | *myRC* | The draft result (shape) |
1743
1744 The main steps of the *BOPAlgo_BOP* are the same as of @ref occt_algorithms_7_4 "BOPAlgo_Builder" except for some aspects described in the next paragraphs.
1745
1746 @subsection occt_algorithms_9_6 Building Draft Result
1747
1748 The input data for this step is as follows:
1749 * *BOPAlgo_BOP* object after building result of type *Compound*;
1750 * *Type* of the Boolean operation.
1751
1752 | No | Contents | Implementation |
1753 | :---- | :----- | :----- | 
1754 | 1 |   For the Boolean operation *Fuse* add to *myRC* all images of arguments. | *BOPAlgo_BOP::BuildRC()* |
1755 | 2 |   For the Boolean operation *Common* or *Cut* add to *myRC* all images of argument *S1* that are *Common* for the Common operation and are *Not Common* for the Cut operation |   *BOPAlgo_BOP::BuildRC()* |
1756  
1757 @subsection occt_algorithms_9_7 Building the Result
1758
1759 The input data for this step is as follows:
1760 * *BOPAlgo_BOP* object the state after building draft result. 
1761
1762 | No | Contents | Implementation |
1763 | :---- | :---- | :------ |
1764 | 1 | For the Type of the Boolean operation Common, Cut with any dimension and operation Fuse with *myDim[0] < 3* | |
1765 | 1.1 | Find containers (WIRE, SHELL, COMPSOLID) in the arguments | *BOPAlgo_BOP:: BuildShape()* |
1766 | 1.2 | Make connexity blocks from splits of each container that are in *myRC* |        *BOPTools_Tools::MakeConnexityBlocks()* |
1767 | 1.3 | Build the result from shapes made from the connexity blocks | *BOPAlgo_BOP:: BuildShape()* |
1768 | 1.4 | Add the remaining shapes from *myRC* to the result | *BOPAlgo_BOP:: BuildShape()* |
1769 | 2     | For the Type of the Boolean operation Fuse with *myDim[0] = 3* | |    
1770 | 2.1 | Find internal faces <i>(FWi)</i> in *myRC* | *BOPAlgo_BOP::BuildSolid()* |
1771 | 2.2 | Collect all faces of *myRC* except for internal faces <i>(FWi) -> SFS</i> | *BOPAlgo_BOP::BuildSolid ()* |
1772 | 2.3 | Build solids <i>(SDi)</i> from *SFS*. | *BOPAlgo_BuilderSolid* |
1773 | 2.4 | Add the solids <i>(SDi)</i> to the result       | |
1774
1775 @section occt_algorithms_10a Section Algorithm 
1776
1777 @subsection occt_algorithms_10a_1 Arguments
1778
1779 The arguments of BOA are shapes in terms of *TopoDS_Shape*. The main requirements for the arguments are described in the Algorithms.
1780
1781 @subsection occt_algorithms_10a_2 Results and general rules
1782 * The result of Section operation is a compound. Each sub-shape of the compound has shared sub-shapes in accordance with interferences between the arguments. 
1783 * The result of Section operation contains shapes that have dimension that is  less then 2 i.e. vertices and edges. 
1784 * The result of Section operation contains standalone vertices if these vertices do not belong to the edges of the result.
1785 * The result of Section operation contains vertices and edges of the arguments (or images of the arguments) that belong to at least two arguments (or two images of the arguments).
1786 * The result of Section operation contains Section vertices and edges obtained from Face/Face interferences.
1787 * The result of Section operation contains vertices that are the result of interferences between vertices and faces.
1788 * The result of Section operation contains edges that are the result of interferences between edges and faces (Common Blocks),
1789
1790 @subsection occt_algorithms_10a_3  Examples
1791
1792 @subsubsection occt_algorithms_10a_3_1 Case 1: Two Vertices
1793
1794 Let us consider two interfering vertices: *V1* and *V2*.
1795
1796 @figure{/user_guides/boolean_operations/images/boolean_image080.png,"",131}
1797
1798 The result of *Section* operation is the compound that contains a new vertex *V*.
1799
1800 @figure{/user_guides/boolean_operations/images/boolean_image081.png,"",128}
1801
1802 @subsubsection occt_algorithms_10a_3_2 Case 1: Case 2: A Vertex and an Edge
1803
1804 Let us consider vertex *V1* and the edge *E2*, that intersect in a 3D point:
1805
1806 @figure{/user_guides/boolean_operations/images/boolean_image082.png,"",230}
1807
1808 The result of *Section* operation is the compound that contains vertex *V1*.
1809
1810 @figure{/user_guides/boolean_operations/images/boolean_image083.png,"",230}
1811
1812 @subsubsection occt_algorithms_10a_3_3 Case 1: Case 2: A Vertex and a Face
1813  
1814 Let us consider vertex *V1* and face *F2*, that intersect in a 3D point:
1815
1816 @figure{/user_guides/boolean_operations/images/boolean_image084.png,"",230}
1817
1818 The result of *Section* operation is the compound that contains vertex *V1*.
1819
1820 @figure{/user_guides/boolean_operations/images/boolean_image085.png,"",230}
1821
1822 @subsubsection occt_algorithms_10a_3_4 Case 4: A Vertex and a Solid
1823
1824 Let us consider vertex *V1* and solid *Z2*. The vertex *V1* is inside the solid *Z2*.
1825
1826 @figure{/user_guides/boolean_operations/images/boolean_image086.png,"",230}
1827  
1828 The result of *Section* operation is an empty compound.
1829
1830 @subsubsection occt_algorithms_10a_3_5 Case 5: Two edges intersecting at one point
1831
1832 Let us consider edges *E1* and *E2*, that intersect in a 3D point:
1833
1834 @figure{/user_guides/boolean_operations/images/boolean_image087.png,"",230}
1835
1836 The result of *Section* operation is the compound that contains a new vertex *Vnew*.
1837
1838 @figure{/user_guides/boolean_operations/images/boolean_image088.png,"",230}
1839
1840 @subsubsection occt_algorithms_10a_3_6 Case 6: Two edges having a common block
1841
1842 Let us consider edges *E1* and *E2*, that have a common block:
1843
1844 @figure{/user_guides/boolean_operations/images/boolean_image089.png,"",230}
1845  
1846 The result of *Section* operation is the compound that contains a new edge *Enew*.
1847
1848 @figure{/user_guides/boolean_operations/images/boolean_image090.png,"",230}
1849
1850 @subsubsection occt_algorithms_10a_3_7 Case 7: An Edge and a Face intersecting at a point
1851
1852 Let us consider edge *E1* and face *F2*, that intersect at a 3D point:
1853  
1854 @figure{/user_guides/boolean_operations/images/boolean_image091.png,"",230}
1855
1856 The result of *Section* operation is the compound that contains a new vertex *Vnew*.
1857
1858 @figure{/user_guides/boolean_operations/images/boolean_image092.png,"",230}
1859  
1860 @subsubsection occt_algorithms_10a_3_8 Case 8: A Face and an Edge that have a common block
1861
1862 Let us consider edge *E1* and face *F2*, that have a common block:
1863
1864 @figure{/user_guides/boolean_operations/images/boolean_image093.png,"",230}
1865
1866 The result of *Section* operation is the compound that contains new edge *Enew*. 
1867
1868 @figure{/user_guides/boolean_operations/images/boolean_image094.png,"",230}
1869  
1870  
1871 @subsubsection occt_algorithms_10a_3_9 Case 9: An Edge and a Solid intersecting at a point
1872
1873 Let us consider edge *E1* and solid *Z2*, that intersect at a point:
1874
1875 @figure{/user_guides/boolean_operations/images/boolean_image095.png,"",230}
1876
1877 The result of *Section* operation is the compound that contains a new vertex *Vnew*. 
1878
1879 @figure{/user_guides/boolean_operations/images/boolean_image096.png,"",230}
1880
1881 @subsubsection occt_algorithms_10a_3_10 Case 10: An Edge and a Solid that have a common block
1882
1883 Let us consider edge *E1* and solid *Z2*, that have a common block at a face:
1884
1885 @figure{/user_guides/boolean_operations/images/boolean_image097.png,"",230}
1886  
1887 The result of *Section* operation is the compound that contains a new edge *Enew*. 
1888
1889 @figure{/user_guides/boolean_operations/images/boolean_image098.png,"",230}
1890  
1891 @subsubsection occt_algorithms_10a_3_11 Case 11: Two intersecting faces
1892
1893 Let us consider two intersecting faces *F1* and *F2*:
1894  
1895 @figure{/user_guides/boolean_operations/images/boolean_image099.png,"",230}
1896
1897 The result of *Section* operation is the compound that contains a new edge *Enew*. 
1898
1899 @figure{/user_guides/boolean_operations/images/boolean_image100.png,"",230}
1900  
1901 @subsubsection occt_algorithms_10a_3_12 Case 12: Two faces that have a common part
1902
1903 Let us consider two faces *F1* and *F2* that have a common part:
1904
1905 @figure{/user_guides/boolean_operations/images/boolean_image133.png,"",230}
1906  
1907 The result of *Section* operation is the compound that contains 4 new edges.
1908
1909 @figure{/user_guides/boolean_operations/images/boolean_image134.png,"",230}
1910
1911 @subsubsection occt_algorithms_10a_3_13 Case 13: Two faces that have overlapping edges
1912
1913 Let us consider two faces *F1* and *F2* that have a overlapping edges:
1914
1915 @figure{/user_guides/boolean_operations/images/boolean_image101.png,"",230}
1916
1917 The result of *Section* operation is the compound that contains a new edge *Enew*.
1918
1919 @figure{/user_guides/boolean_operations/images/boolean_image102.png,"",230}
1920  
1921 @subsubsection occt_algorithms_10a_3_14 Case 14: Two faces that have overlapping vertices
1922
1923 Let us consider two faces *F1* and *F2* that have overlapping vertices:
1924
1925 @figure{/user_guides/boolean_operations/images/boolean_image103.png,"",230}
1926  
1927 The result of *Section* operation is the compound that contains a new vertex *Vnew*. 
1928  
1929 @figure{/user_guides/boolean_operations/images/boolean_image104.png,"",230}
1930  
1931 @subsubsection occt_algorithms_10a_3_15 Case 15: A Face and a Solid that have an intersection curve
1932
1933 Let us consider face *F1* and solid *Z2* that have an intersection curve:
1934  
1935 @figure{/user_guides/boolean_operations/images/boolean_image105.png,"",230}
1936  
1937 The result of *Section* operation is the compound that contains new edges.
1938
1939 @figure{/user_guides/boolean_operations/images/boolean_image106.png,"",230}
1940  
1941 @subsubsection occt_algorithms_10a_3_16 Case 16: A Face and a Solid that have overlapping faces.
1942
1943 Let us consider face *F1* and solid *Z2* that have overlapping faces:
1944
1945 @figure{/user_guides/boolean_operations/images/boolean_image107.png,"",230}
1946  
1947 The result of *Section* operation is the compound that contains new edges
1948  
1949 @figure{/user_guides/boolean_operations/images/boolean_image108.png,"",230}
1950  
1951 @subsubsection occt_algorithms_10a_3_17 Case 17: A Face and a Solid that have overlapping edges.
1952
1953 Let us consider face *F1* and solid *Z2* that have a common part on edge:
1954
1955 @figure{/user_guides/boolean_operations/images/boolean_image109.png,"",230}
1956
1957 The result of *Section* operation is the compound that contains a new edge *Enew*.
1958
1959 @figure{/user_guides/boolean_operations/images/boolean_image110.png,"",230}
1960  
1961 @subsubsection occt_algorithms_10a_3_18 Case 18: A Face and a Solid that have overlapping vertices.
1962
1963 Let us consider face *F1* and solid *Z2* that have overlapping vertices:
1964
1965 @figure{/user_guides/boolean_operations/images/boolean_image111.png,"",230}
1966   
1967 The result of *Section* operation is the compound that contains a new vertex *Vnew*.
1968  
1969 @figure{/user_guides/boolean_operations/images/boolean_image112.png,"",230}
1970
1971 @subsubsection occt_algorithms_10a_3_19 Case 19: Two intersecting Solids
1972
1973 Let us consider two intersecting solids *Z1* and *Z2*:
1974 @figure{/user_guides/boolean_operations/images/boolean_image113.png,"",230}
1975
1976 The result of *Section* operation is the compound that contains new edges.
1977 @figure{/user_guides/boolean_operations/images/boolean_image114.png,"",230}
1978
1979 @subsubsection occt_algorithms_10a_3_20 Case 20: Two Solids that have overlapping faces
1980
1981 Let us consider two solids *Z1* and *Z2* that have a common part on face:
1982 @figure{/user_guides/boolean_operations/images/boolean_image115.png,"",230}
1983
1984 The result of *Section* operation is the compound that contains new edges.
1985 @figure{/user_guides/boolean_operations/images/boolean_image116.png,"",230}
1986  
1987 @subsubsection occt_algorithms_10a_3_21 Case 21: Two Solids that have overlapping edges
1988
1989 Let us consider two solids *Z1* and *Z2* that have overlapping edges:
1990 @figure{/user_guides/boolean_operations/images/boolean_image117.png,"",230}
1991  
1992 The result of *Section* operation is the compound that contains a new edge *Enew*.
1993 @figure{/user_guides/boolean_operations/images/boolean_image118.png,"",230}
1994
1995 @subsubsection occt_algorithms_10a_3_22 Case 22: Two Solids that have overlapping vertices
1996
1997 Let us consider two solids *Z1* and *Z2* that have overlapping vertices: 
1998 @figure{/user_guides/boolean_operations/images/boolean_image119.png,"",230}
1999
2000 The result of *Section* operation is the compound that contains a new vertex *Vnew*.
2001 @figure{/user_guides/boolean_operations/images/boolean_image120.png,"",230}
2002
2003 @subsection occt_algorithms_10a_4 Class BOPAlgo_Section
2004
2005 SA is implemented in the class *BOPAlgo_Section*. The class has no specific fields.
2006 The main steps of the *BOPAlgo_Section*  are the same as of *BOPAlgo_Builder* except for the following steps:
2007
2008 * Build Images for Wires;
2009 * Build Result of Type Wire;
2010 * Build Images for Faces;
2011 * Build Result of Type Face;
2012 * Build Images for Shells;
2013 * Build Result of Type Shell;
2014 * Build Images for Solids;
2015 * Build Result of Type Solid;
2016 * Build Images for Type CompSolid;
2017 * Build Result of Type CompSolid;
2018 * Build Images for Compounds;
2019 Some aspects of building the result are described in the next paragraph
2020
2021 @subsection occt_algorithms_10a_5 Building the Result
2022
2023 | No | Contents | Implementation |
2024 | :---- | :---- | :------ |
2025 | 1 | Build the result of the operation using all information contained in *FaceInfo*, Common Block, Shared entities of the arguments, etc. | *BOPAlgo_Section:: BuildSection()* |
2026
2027 @section occt_algorithms_10b Volume Maker Algorithm
2028
2029 The Volume Maker algorithm has been designed for building the elementary volumes (solids) from a set of connected, intersecting, or nested shapes. The algorithm can also be useful for splitting solids into parts, or constructing new solid(s) from set of intersecting or connected faces or shells.
2030 The algorithm creates only closed solids. In general case the result solids are non-manifold: fragments of the input shapes (wires, faces) located inside the solids are added as internal sub-shapes to these solids.
2031 But the algorithm allows preventing the addition of the internal for solids parts into result. In this case the result solids will be manifold and not contain any internal parts. However, this option does not prevent from the occurrence of the internal edges or vertices in the faces.<br>
2032 Non-closed faces, free wires etc. located outside of any solid are always excluded from the result.
2033
2034 The Volume Maker algorithm is implemented in the class BOPAlgo_MakerVolume. It is based on the General Fuse (GF) algorithm. All the options of the GF algorithm such as possibility to run algorithm in parallel mode, fuzzy option, safe mode, glue options and history support are also available in this algorithm.
2035
2036 The requirements for the arguments are the same as for the arguments of GF algorithm - they could be of any type, but each argument should be valid and not self-interfered.
2037
2038 The algorithm allows disabling the calculation of intersections among the arguments. In this case the algorithm will run much faster, but the user should guarantee that the arguments do not interfere with each other, otherwise the result will be invalid (e.g. contain unexpected parts) or empty.
2039 This option is useful e.g. for building a solid from the faces of one shell or from the shapes that have already been intersected.
2040
2041 @subsection occt_algorithms_10b_1 Usage
2042
2043 #### C++ Level
2044 The usage of the algorithm on the API level:
2045 ~~~~
2046 BOPAlgo_MakerVolume aMV;
2047 BOPCol_ListOfShape aLS = …; // arguments
2048 Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
2049 Standard_Boolean bIntersect = Standard_True; /* intersect or not the arguments (the default value is TRUE)*/
2050 Standard_Real aTol = 0.0; /* fuzzy option (default value is 0)*/
2051 Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
2052 BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up intersection of the arguments*/
2053 Standard_Boolean bAvoidInternalShapes = Standard_False; /* Avoid or not the internal for solids shapes in the result*/
2054 //
2055 aMV.SetArguments(aLS);
2056 aMV.SetRunParallel(bRunParallel);
2057 aMV.SetIntersect(bIntersect);
2058 aMV.SetFuzzyValue(aTol);
2059 aMV.SetNonDestructive(bSafeMode);
2060 aMV.SetGlue(aGlue);
2061 aMV.SetAvoidInternalShapes(bAvoidInternalShapes);
2062 //
2063 aMV.Perform(); //perform the operation
2064 if (aMV.ErrorStatus()) { //check error status
2065   return;
2066 }
2067 //
2068 const TopoDS_Shape& aResult = aMV.Shape(); // result of the operation
2069 ~~~~
2070
2071 #### Tcl Level
2072 To use the algorithm in Draw the command mkvolume has been implemented. The usage of this command is following:
2073 ~~~~
2074 Usage: mkvolume r b1 b2 ... [-c] [-ni] [-ai]
2075 Options:
2076 -c - use this option to have input compounds considered as set of separate arguments (allows passing multiple arguments as one compound);
2077 -ni - use this option to disable the intersection of the arguments;
2078 -ai - use this option to avoid internal for solids shapes in the result.
2079 ~~~~
2080
2081 @subsection occt_algorithms_10b_2 Examples
2082
2083 #### Example 1
2084 Creation of 9832 solids from sphere and set of 63 planes:
2085
2086 <table align="center">
2087 <tr>
2088   <td>@figure{/user_guides/boolean_operations/images/mkvolume_image001.png,"Arguments",200}</td>
2089   <td>@figure{/user_guides/boolean_operations/images/mkvolume_image002.png,"Results",200}</td>
2090 </tr>
2091 </table>
2092
2093 #### Example 2
2094 Creating compartments on a ship defined by hull shell and a set of planes. The ship is divided on compartments by five transverse bulkheads and a deck – six compartments are created:
2095
2096 <table align="center">
2097 <tr>
2098   <td>@figure{/user_guides/boolean_operations/images/mkvolume_image003.png,"Arguments",200}</td>
2099   <td>@figure{/user_guides/boolean_operations/images/mkvolume_image004.png,"Results",200}</td>
2100 </tr>
2101 </table>
2102
2103 @section occt_algorithms_10c_Cells Cells Builder algorithm
2104
2105 The Cells Builder algorithm is an extension of the General Fuse algorithm. The result of General Fuse algorithm contains all split parts of the arguments. The Cells Builder algorithm provides means to specify if any given split part of the arguments (referred to as Cell) can be taken or avoided in the result.
2106
2107 The possibility of selecting any Cell allows combining any possible result and gives the Cells Builder algorithm a very wide sphere of application - from building the result of any Boolean operation to building the result of any application-specific operation.
2108
2109 The algorithm builds Cells only once and then just reuses them for combining the result. This gives this algorithm the performance advantage over Boolean operations, which always rebuild the splits to obtain the desirable result.
2110
2111 Thus, the Cells Builder algorithm can be especially useful for simulating Boolean expressions, i.e. a sequence of Boolean operations on the same arguments. Instead of performing many Boolean operations it allows getting the final result in a single operation. The Cells Builder will also be beneficial to obtain the results of different Boolean operations on the same arguments - Cut and Common, for example.
2112
2113 The Cells Builder algorithm also provides the possibility to remove any internal boundaries between splits of the same type, i.e. to fuse any same-dimensional parts added into the result and to keep any other parts as separate. This possibility is implemented through the Cells material approach: to remove the boundary between two Cells, both Cells should be assigned with the same material ID. However, if the same material ID has been assigned to the Cells of different dimension, the removal of the internal boundaries for that material will not be performed. Currently, such case is considered a limitation for the algorithm.
2114
2115 The algorithm can also create containers from the connected Cells added into result - WIRES from Edges, SHELLS from Faces and COMPSOLIDS from Solids.
2116
2117 @subsection occt_algorithms_10c_Cells_1 Usage
2118
2119 The algorithm has been implemented in the *BOPAlgo_CellsBuilder* class.
2120
2121 Cells Builder is based on the General Fuse algorithm. Thus all options of the General Fuse algorithm, such as parallel processing mode, fuzzy mode, safe processing mode, gluing mode and history support are also available in this algorithm.
2122
2123 The requirements for the input shapes are the same as for General Fuse - each argument should be valid in terms of *BRepCheck_Analyzer* and *BOPAlgo_ArgumentAnalyzer*.
2124
2125 The result of the algorithm is a compound containing the selected parts of the basic type (VERTEX, EDGE, FACE or SOLID). The default result is an empty compound. It is possible to add any Cell by using the methods *AddToRessult()* and *AddAllToResult()*. It is also possible to remove any part from the result by using methods *RemoveFromResult()* and *RemoveAllFromResult()*. The method *RemoveAllFromResult()* is also suitable for clearing the result.
2126
2127 The Cells that should be added/removed to/from the result are defined through the input shapes containing the parts that should be taken *(ShapesToTake)* and the ones containing parts that should be avoided (ShapesToAvoid).
2128 To be taken into the result the part must be IN all shapes from *ShapesToTake* and OUT of all shapes from *ShapesToAvoid*.
2129
2130 To remove Internal boundaries, it is necessary to set the same material to the Cells, between which the boundaries should be removed, and call the method *RemoveInternalBoundaries()*.
2131 The material should not be equal to 0, as this is the default material ID. The boundaries between Cells with this material ID will not be removed. The same Cell cannot be added with different materials.
2132 It is also possible to remove the boundaries when the result is combined. To do this, it is necessary to set the material for parts (not equal to 0) and set the flag *bUpdate* to TRUE.
2133 If the same material ID has been set for parts of different dimension, the removal of internal boundaries for this material will not be performed.
2134
2135 It is possible to create typed Containers from the parts added into result by using method *MakeContainers()*. The type of the containers will depend on the type of the input shapes: WIRES for EDGE, SHELLS for FACES and COMPSOLIDS for SOLIDS. The result will be a compound containing containers.
2136
2137 #### API usage
2138 Here is the example of the algorithm use on the API level:
2139 ~~~~
2140 BOPAlgo_CellsBuilder aCBuilder;
2141 BOPCol_ListOfShape aLS = …; // arguments
2142 Standard_Boolean bRunParallel = Standard_False; /* parallel or single mode (the default value is FALSE)*/
2143 Standard_Real aTol = 0.0; /* fuzzy option (the default value is 0)*/
2144 Standard_Boolean bSafeMode = Standard_False; /* protect or not the arguments from modification*/
2145 BOPAlgo_Glue aGlue = BOPAlgo_GlueOff; /* Glue option to speed up the intersection of arguments*/
2146 //
2147 aCBuilder.SetArguments(aLS);
2148 aCBuilder.SetRunParallel(bRunParallel);
2149 aCBuilder.SetFuzzyValue(aTol);
2150 aCBuilder.SetNonDestructive(bSafeMode);
2151 aCBuilder.SetGlue(aGlue);
2152 //
2153 aCBuilder.Perform(); // build splits of all arguments (GF)
2154 if (aCBuilder.ErrorStatus()) { // check error status
2155   return;
2156 }
2157 //
2158 // collecting of the cells into result
2159 const TopoDS_Shape& anEmptyRes = aCBuilder.Shape(); // empty result, as nothing has been added yet 
2160 const TopoDS_Shape& anAllCells = aCBuilder.GetAllParts(); //all split parts 
2161 //
2162 BOPCol_ListOfShape aLSToTake = ...; // parts of these arguments will be taken into result
2163 BOPCol_ListOfShape aLSToAvoid = ...; // parts of these arguments will not be taken into result
2164 //
2165 Standard_Integer iMaterial = 1; // defines the material for the cells
2166 Standard_Boolean bUpdate = Standard_False; // defines whether to update the result right now or not
2167 // adding to result
2168 aCBuilder.AddToResult(aLSToTake, aLSToAvoid, iMaterial, bUpdate);
2169 aCBuilder.RemoveInternalBoundaries(); // removing of the boundaries
2170 TopoDS_Shape aResult = aCBuilder.Shape(); // the result
2171 // removing from result
2172 aCBuilder.AddAllToResult();
2173 aCBuilder.RemoveFromResult(aLSToTake, aLSToAvoid);
2174 aResult = aCBuilder.Shape(); // the result
2175 ~~~~
2176
2177 #### DRAW usage
2178
2179 The following set of new commands has been implemented to run the algorithm in DRAW Test Harness:
2180 ~~~~
2181 bcbuild          : Initialization of the Cells Builder. Use: *bcbuild r*
2182 bcadd            : Add parts to result. Use: *bcadd r s1 (0,1) s2 (0,1) ... [-m material [-u]]*
2183 bcaddall         : Add all parts to result. Use: *bcaddall r [-m material [-u]]*
2184 bcremove         : Remove parts from result. Use: *bcremove r s1 (0,1) s2 (0,1) ...*
2185 bcremoveall      : Remove all parts from result. Use: *bcremoveall*
2186 bcremoveint      : Remove internal boundaries. Use: *bcremoveint r*
2187 bcmakecontainers : Make containers from the parts added to result. Use: *bcmakecontainers r*
2188 ~~~~
2189
2190 Here is the example of the algorithm use on the DRAW level:
2191 ~~~~
2192 psphere s1 15
2193 psphere s2 15
2194 psphere s3 15
2195 ttranslate s1 0 0 10
2196 ttranslate s2 20 0 10
2197 ttranslate s3 10 0 0 
2198 bclearobjects; bcleartools
2199 baddobjects s1 s2 s3
2200 bfillds
2201 # rx will contain all split parts
2202 bcbuild rx 
2203 # add to result the part that is common for all three spheres
2204 bcadd res s1 1 s2 1 s3 1 -m 1
2205 # add to result the part that is common only for first and third spheres
2206 bcadd res s1 1 s2 0 s3 1 -m 1
2207 # remove internal boundaries
2208 bcremoveint res
2209 ~~~~
2210
2211 @subsection occt_algorithms_10c_Cells_2 Examples
2212
2213 The following simple example illustrates the possibilities of the algorithm working on a cylinder and a sphere intersected by a plane:
2214 ~~~~
2215 pcylinder c 10 30 
2216 psphere s 15
2217 ttranslate s 0 0 30
2218 plane p 0 0 20 1 0 0
2219 mkface f p -25 30 -17 17
2220 ~~~~
2221
2222 @figure{/user_guides/boolean_operations/images/cells_algorithm_001.png,"Arguments",160} 
2223
2224 ~~~~
2225 bclearobjects
2226 bcleartools
2227 baddobjects c s f
2228 bfillds
2229 bcbuild r
2230 ~~~~
2231
2232 #### 1. Common for all arguments
2233
2234 ~~~~
2235 bcremoveall
2236 bcadd res c 1 s 1 f 1
2237 ~~~~
2238
2239 @figure{/user_guides/boolean_operations/images/cells_algorithm_002.png,"The result of COMMON operation",126} 
2240
2241 #### 2. Common between cylinder and face
2242
2243 ~~~~
2244 bcremoveall
2245 bcadd res f 1 c 1
2246 ~~~~
2247
2248 @figure{/user_guides/boolean_operations/images/cells_algorithm_003.png,"The result of COMMON operation between cylinder and face",90} 
2249
2250 #### 3. Common between cylinder and sphere
2251
2252 ~~~~
2253 bcremoveall
2254 bcadd res c 1 s 1
2255 ~~~~
2256
2257 @figure{/user_guides/boolean_operations/images/cells_algorithm_004.png,"The result of COMMON operation between cylinder and sphere",120} 
2258
2259 #### 4. Fuse of cylinder and sphere
2260
2261 ~~~~
2262 bcremoveall
2263 bcadd res c 1 -m 1
2264 bcadd res s 1 -m 1
2265 bcremoveint res
2266 ~~~~
2267
2268 @figure{/user_guides/boolean_operations/images/cells_algorithm_005.png,"The result of FUSE operation between cylinder and sphere",160} 
2269
2270 #### 5. Parts of the face inside solids - FUSE(COMMON(f, c), COMMON(f, s))
2271
2272 ~~~~
2273 bcremoveall
2274 bcadd res f 1 s 1 -m 1
2275 bcadd res f 1 c 1 -m 1
2276 ~~~~
2277
2278 @figure{/user_guides/boolean_operations/images/cells_algorithm_006_1.png,"Parts of the face inside solids",160} 
2279
2280 ~~~~
2281 bcremoveint res
2282 ~~~~
2283
2284 @figure{/user_guides/boolean_operations/images/cells_algorithm_006_2.png,"Unified parts of the face inside solids",160} 
2285
2286 #### 6. Part of the face outside solids
2287
2288 ~~~~
2289 bcremoveall
2290 bcadd res f 1 c 0 s 0
2291 ~~~~
2292
2293 @figure{/user_guides/boolean_operations/images/cells_algorithm_007.png,"Part of the face outside solids",160} 
2294
2295 #### 7. Fuse operation (impossible using standard Boolean Fuse operation)
2296
2297 ~~~~
2298 bcremoveall
2299 bcadd res c 1 -m 1
2300 bcadd res s 1 -m 1
2301 bcadd res f 1 c 0 s 0
2302 bcremoveint res
2303 ~~~~
2304
2305 @figure{/user_guides/boolean_operations/images/cells_algorithm_008.png,"Fuse operation",160} 
2306
2307
2308 These examples may last forever. To define any new operation, it is just necessary to define, which Cells should be taken and which should be avoided.
2309
2310
2311 @section occt_algorithms_10     Algorithm Limitations 
2312
2313 The chapter describes the problems that are considered as Algorithm limitations. In most cases an Algorithm failure is caused by a combination of various factors, such as self-interfered arguments, inappropriate or ungrounded values of the argument tolerances, adverse mutual position of the arguments, tangency, etc.
2314
2315 A lot of failures of GFA algorithm can be caused by bugs in low-level algorithms: Intersection Algorithm, Projection Algorithm, Approximation Algorithm, Classification Algorithm, etc.
2316 * The Intersection, Projection and Approximation Algorithms are mostly used at the Intersection step. Their bugs directly cause wrong section results (i.e. incorrect section edges, section points, missing section edges or micro edges). It is not possible to obtain a correct final result of the GFA if a section result is wrong.
2317 * The Projection Algorithm is used at the Intersection step. The purpose of Projection Algorithm is to compute 2D curves on surfaces. Wrong results here lead to incorrect or missing faces in the final GFA result. 
2318 * The Classification Algorithm is used at the Building step. The bugs in the Classification Algorithm lead to errors in selecting shape parts (edges, faces, solids) and ultimately to a wrong final GFA result.
2319
2320 The description below illustrates some known GFA limitations. It does not enumerate exhaustively all problems that can arise in practice. Please, address cases of Algorithm failure to the OCCT Maintenance Service.
2321
2322
2323 @subsection occt_algorithms_10_1        Arguments
2324
2325 @subsubsection occt_algorithms_10_1_1   Common requirements 
2326
2327 Each argument should be valid (in terms of *BRepCheck_Analyzer*), or conversely, if the argument is considered as non-valid (in terms of *BRepCheck_Analyzer*), it cannot be used as an argument of the algorithm.
2328
2329 The class *BRepCheck_Analyzer* is used to check the overall validity of a shape. In OCCT a Shape (or its sub-shapes) is considered valid if it meets certain criteria. If the shape is found as invalid, it can be fixed by tools from *ShapeAnalysis, ShapeUpgrade* and *ShapeFix* packages.
2330
2331 However, it is important to note that class *BRepCheck_Analyzer* is just a tool that can have its own problems; this means that due to a specific factor(s) this tool can sometimes provide a wrong result.
2332
2333 Let us consider the following example:
2334
2335 The Analyzer checks distances between couples of 3D check-points <i>(Pi, PSi)</i> of edge *E* on face *F*. Point *Pi* is obtained from the 3D curve (at the parameter *ti*) of the edge. *PSi* is obtained from 2D curve (at the parameter *ti*) of the edge on surface *S* of face *F*. To be valid the distance should be less than *Tol(E)* for all couples of check-points. The number of these check-points is a predefined value (e.g. 23). 
2336
2337 Let us consider the case when edge *E* is recognized valid (in terms of *BRepCheck_Analyzer*).
2338
2339 Further, after some operation, edge *E* is split into two edges *E1* and *E2*. Each split edge has the same 3D curve and 2D curve as the original edge *E*. 
2340
2341 Let us check *E1* (or E2). The Analyzer again checks the distances between the couples of check-points points <i>(Pi, PSi)</i>. The number of these check-points is the same constant value (23), but there is no guarantee that the distances will be less than *Tol(E)*, because the points chosen for *E1* are not the same as for *E*. 
2342
2343 Thus, if *E1* is recognized by the Analyzer as non-valid, edge *E*  should also be non-valid. However *E* has been recognized as valid. Thus the Analyzer gives a wrong result for *E*.
2344
2345 The fact that the argument is a valid shape (in terms of *BRepCheck_Analyzer*) is a necessary but insufficient requirement to produce a valid result of the Algorithms.
2346
2347 @subsubsection occt_algorithms_10_1_3   Pure self-interference
2348
2349 The argument should not be self-interfered, i.e. all sub-shapes of the argument that have geometrical coincidence through any topological entities (vertices, edges, faces) should share these entities.
2350
2351 #### Example 1: Compound of two edges
2352 The compound of two edges *E1* and *E2* is a self-interfered shape and cannot be used as the argument of the Algorithms.
2353
2354 @figure{/user_guides/boolean_operations/images/operations_image036.svg,"Compound of two edges",230}
2355
2356 #### Example 2: Self-interfered Edge
2357 The edge *E* is a self-interfered shape and cannot be used as an argument of the Algorithms.
2358
2359 @figure{/user_guides/boolean_operations/images/operations_image037.svg,"Self-interfered Edge",140}
2360  
2361 #### Example 3: Self-interfered Face
2362 The face *F* is a self-interfered shape and cannot be used as an argument of the Algorithms.
2363
2364 @figure{/user_guides/boolean_operations/images/operations_image038.svg,"Self-interfered Face",230}
2365  
2366 ####    Example 4: Face of Revolution
2367 The face *F* has been obtained by revolution of edge *E* around line *L*.
2368
2369 @figure{/user_guides/boolean_operations/images/operations_image039a.png,"Face of Revolution: Arguments",230}
2370 @figure{/user_guides/boolean_operations/images/operations_image039b.png,"Face of Revolution: Result",230}
2371
2372 In spite of the fact that face *F* is valid (in terms of *BRepCheck_Analyzer*) it is a self-interfered shape and cannot be used as the argument of the Algorithms.
2373
2374 @subsubsection occt_algorithms_10_1_4   Self-interferences due to tolerances
2375 #### Example 1: Non-closed Edge
2376
2377 Let us consider edge *E* based on a non-closed circle. @figure{/user_guides/boolean_operations/images/operations_image040.png,"Edge based on a non-closed circle",230}
2378
2379 The distance between the vertices of *E* is *D=0.69799*. The values of the tolerances *Tol(V1)=Tol(V2)=0.5*.
2380 @figure{/user_guides/boolean_operations/images/operations_image041.png,"Distance and Tolerances",230}
2381  
2382 In spite of the fact that the edge *E* is valid in terms of *BRepCheck_Analyzer*, it is a self-interfered shape because its vertices are interfered. Thus, edge *E* cannot be used as an argument of the Algorithms.
2383
2384 #### Example 2: Solid containing an interfered vertex
2385
2386 Let us consider solid *S* containing vertex V. @figure{/user_guides/boolean_operations/images/operations_image042.png,"Solid containing an interfered vertex",230}
2387
2388 The value of  tolerance Tol(V)= 50.000075982061.
2389
2390 @figure{/user_guides/boolean_operations/images/operations_image043.png,"Tolerance",230}
2391
2392 In spite of the fact that solid *S* is valid in terms of *BRepCheck_Analyzer* it is a self-interfered shape because vertex *V* is interfered with a lot of sub-shapes from *S* without any topological connection with them. Thus solid *S* cannot be used as an argument of the Algorithms.
2393
2394 @subsubsection occt_algorithms_10_1_5 Parametric representation
2395 The parameterization of some surfaces (cylinder, cone, surface of revolution) can be the cause of limitation.
2396
2397 ####    Example 1: Cylindrical surface
2398 The parameterization range for cylindrical surface is:
2399
2400 @figure{/user_guides/boolean_operations/images/boolean_image135.png,"",230}
2401
2402 The range of *U* coordinate is always restricted while the range of *V* coordinate is non-restricted.
2403
2404 Let us consider a cylinder-based *Face 1* with radii *R=3* and *H=6*. 
2405
2406 @figure{/user_guides/boolean_operations/images/operations_image044.png,"Face 1",230}
2407
2408 @figure{/user_guides/boolean_operations/images/operations_image045.png,"P-Curves for Face 1",230}
2409
2410 Let us also consider a cylinder-based *Face 2* with radii *R=3000* and *H=6000* (resulting from scaling Face 1 with scale factor *ScF=1000*). 
2411
2412 @figure{/user_guides/boolean_operations/images/operations_image046.png,"Face 2",230}
2413
2414 @figure{/user_guides/boolean_operations/images/operations_image047.png,"P-Curves for Face 2",230}
2415
2416 Please, pay attention to the Zoom value of the Figures.
2417
2418 It is obvious that starting with some value of *ScF*, e.g. *ScF>1000000*, all sloped p-Curves on *Face 2*  will be almost vertical. At least, there will be no difference between the values of angles computed by standard C Run-Time Library functions, such as *double acos(double x)*. The loss of accuracy in computation of angles can cause failure of some BP sub-algorithms, such as building faces from a set of edges or building solids from a set of faces.
2419
2420
2421 @subsubsection occt_algorithms_10_1_6 Using tolerances of vertices to fix gaps
2422
2423 It is possible to create shapes that use sub-shapes of lower order to avoid gaps in the tolerance-based data model.
2424
2425 Let us consider the following example:
2426
2427 @figure{/user_guides/boolean_operations/images/operations_image048.png,"Example",230}
2428
2429 * Face *F* has two edges *E1* and *E2* and two vertices, the base plane is <i>{0,0,0, 0,0,1}</i>;
2430 * Edge *E1* is based on line <i>{0,0,0, 1,0,0}, Tol(E1) = 1.e-7; </i>
2431 * Edge *E2* is based on line <i>{0,1,0, 1,0,0}, Tol(E2) = 1.e-7;</i>
2432 * Vertex *V1*, point <i>{0,0.5,0}, Tol(V1) = 1;</i>
2433 * Vertex *V2*, point <i>{10,0.5,0}, Tol(V2) = 1;</i>
2434 * Face *F* is valid (in terms of *BRepCheck_Analyzer*).
2435  
2436 The values of tolerances *Tol(V1)* and *Tol(V2)* are big enough to fix the gaps between the ends of the edges, but the vertices *V1* and *V2* do not contain any information about the trajectories connecting the corresponding ends of the edges. Thus, the trajectories are undefined. This will cause failure of some sub-algorithms of BP. For example, the sub-algorithms for building faces from a set of edges use the information about all edges connected in a vertex. The situation when a vertex has several pairs of edges such as above will not be solved in a right way. 
2437
2438
2439 @subsection occt_algorithms_11_1        Intersection problems
2440 @subsubsection occt_algorithms_11_1_1 Pure intersections and common zones 
2441
2442 #### Example: Intersecting Edges
2443
2444 Let us consider the intersection between two edges:
2445 * *E1* is based on a line: <i>{0,-10,0, 1,0,0}, Tol(E1)=2.</i>
2446 * *E2* is based on a circle: <i>{0,0,0, 0,0,1}, R=10, Tol(E2)=2.</i>
2447
2448 @figure{/user_guides/boolean_operations/images/operations_image049.png,"Intersecting Edges",320}
2449
2450 The result of pure intersection between *E1* and *E2* is vertex *Vx {0,-10,0}*.
2451
2452 The result of intersection taking into account tolerances is the common zone *CZ* (part of 3D-space where the distance between the curves is less than or equals to the sum of edge tolerances. 
2453
2454 The Intersection Part of Algorithms uses the result of pure intersection *Vx* instead of *CZ* for the following reasons: 
2455 * The Algorithms do not produce Common Blocks between edges based on underlying curves of explicitly different type (e.g. Line / Circle). If the curves have different types, the rule of thumb is that the produced result is of type **vertex**. This rule does not work for non-analytic curves (Bezier, B-Spline) and their combinations with analytic curves.
2456 * The algorithm of intersection between two surfaces *IntPatch_Intersection* does not compute *CZ* of the intersection between curves and points. So even if *CZ* were computed by Edge/Edge intersection algorithm, its result could not be treated by Face/Face intersection algorithm.
2457
2458 @subsubsection occt_algorithms_11_2_2 Tolerances and inaccuracies
2459
2460 The following limitations result from modeling errors or inaccuracies.
2461
2462 #### Example: Intersection of planar faces
2463
2464 Let us consider two planar rectangular faces *F1* and *F2*.
2465
2466 The intersection curve between the planes is curve *C12*. The curve produces a new intersection edge *EC12*. The edge goes through vertices *V1* and *V2* thanks to big tolerance values of vertices *Tol(V1)* and *Tol(V2)*. So, two straight edges *E12* and *EC12* go through two vertices, which is  impossible in this case.
2467
2468 @figure{/user_guides/boolean_operations/images/operations_image050.svg,"Intersecting Faces",320}
2469
2470
2471 The problem cannot be solved in general, because the length of *E12* can be infinite and the values of *Tol(V1)* and *Tol(V2)* theoretically can be infinite too.
2472
2473 In a particular case the problem can be solved in several ways:
2474 * Reduce, if possible, the values of *Tol(V1)* and *Tol(V2)* (refinement of *F1*).
2475 * Analyze the value of *Tol(EC12)* and increase *Tol(EC12)* to get a common part between the edges *EC12* and *E12*. Then the common part will be rejected as there is an already existing edge *E12* for face *F1*.
2476
2477 It is easy to see that if *C12* is slightly above the tolerance spheres of *V1* and *V2* the problem does not appear. 
2478
2479 #### Example: Intersection of two edges
2480
2481 Let us consider two edges *E1* and *E2*, which have common vertices *V1* and *V2*. The edges *E1* and *E2* have 3D-curves *C1* and *C2. Tol(E1)=1.e<sup>-7</sup>, Tol(E2)=1.e<sup>-7</sup>.*
2482
2483 *C1* practically coincides in 3D with *C2*. The value of deflection is *Dmax* (e.g. *Dmax=1.e<sup>-6</sup>*). 
2484
2485 @figure{/user_guides/boolean_operations/images/operations_image051.svg,"Intersecting Edges",420}
2486
2487 The evident and prospective result should be the Common Block between *E1* and *E2*. However, the result of intersection differs. 
2488
2489 @figure{/user_guides/boolean_operations/images/operations_image052.svg,"Result of Intersection",420}
2490
2491 The result contains three new vertices *Vx1, Vx2* and *Vx3*, 8 new edges <i>(V1, Vx1, Vx2, Vx3, V2)</i> and no Common Blocks. This is correct due to the source data: *Tol(E1)=1.e<sup>-7</sup>, Tol(E2)=1.e<sup>-7</sup>* and <i>Dmax=1.e<sup>-6</sup></i>.
2492
2493 In this particular case the problem can be solved by several ways:
2494 * Increase, if possible, the values *Tol(E1)* and *Tol(E2)* to get coincidence in 3D between *E1* and *E2* in terms of tolerance.
2495 * Replace *E1* by a more accurate model.
2496
2497 The example can be extended from 1D (edges) to 2D (faces).
2498
2499 @figure{/user_guides/boolean_operations/images/operations_image053.svg,"Intersecting Faces",420}
2500
2501 The comments and recommendations are the same as for 1D case above.
2502
2503
2504 @subsubsection occt_algorithms_11_2_3 Acquired Self-interferences
2505 ####    Example 1: Vertex and edge
2506
2507 Let us consider vertex *V1* and edge *E2*. 
2508
2509 @figure{/user_guides/boolean_operations/images/operations_image054.svg,"Vertex and Edge",171}
2510
2511 Vertex *V1* interferes with vertices *V12* and *V22*.
2512 So vertex *V21* should interfere with vertex *V22*, which is impossible because vertices *V21* and *V22* are the vertices of edge *E2*, thus *V21* is not equal to *V22*.
2513
2514 The problem cannot be solved in general, because the length can be as small as possible to provide validity of *E2* (in the extreme case: *Length (E2) = Tol(V21) + Tol(V22) + e,* where *e-> 0*).
2515
2516 In a particular case the problem can be solved by refinement of arguments, i.e. by decreasing the values of *Tol(V21)*, *Tol(V22)* and  *Tol(V1)*.
2517
2518 #### Example 2: Vertex and wire
2519   
2520 Let us consider vertex *V2* and wire consisting of edges *E11* and *E12*. 
2521
2522 @figure{/user_guides/boolean_operations/images/operations_image055.svg,"Vertex and Wire",200}
2523
2524 The arguments themselves are not self-intersected.
2525 Vertex *V2* interferes with edges *E11* and *E12*. Thus, edge *E11* should interfere with edge *E22*, but it is impossible because edges *E11* and *E12* cannot interfere by the condition.
2526  
2527 The cases when a non-self-interfered argument (or its sub-shapes) become interfered due to the intersections with other arguments (or their sub-shapes) are considered as limitations for the Algorithms.
2528
2529 @section occt_algorithms_11a Advanced Options
2530
2531 The previous chapters describe so called Basic Operations. Most of tasks can be solved using Basic Operations. Nonetheless, there are cases that can not be solved straightforwardly by Basic Operations. The tasks are considered as limitations of Basic Operations. 
2532
2533 The chapter is devoted to Advanced Options. In some cases the usage of Advanced Options allows overcoming the limitations, improving the quality of the result of operations, robustness and performance of the operators themselves.
2534
2535 @subsection occt_algorithms_11a_1  Fuzzy Boolean Operation
2536
2537 Fuzzy Boolean operation is the option of Basic Operations such as General Fuse, Splitting, Boolean, Section, Maker Volume and Cells building operations, in which additional user-specified tolerance is used. This option allows operators to handle robustly cases of touching and near-coincident, misaligned entities of the arguments.
2538
2539 The Fuzzy option is useful on the shapes with gaps or embeddings between the entities of these shapes, which are not covered by the tolerance values of these entities. Such shapes can be the result of modeling mistakes, or translating process, or import from other systems with loss of precision, or errors in some algorithms. 
2540
2541 Most likely, the Basic Operations will give unsatisfactory results on such models. The result may contain unexpected and unwanted small entities, faulty entities (in terms of *BRepCheck_Analyzer*), or there can be no result at all.
2542
2543 With the Fuzzy option it is possible to get the expected result -- it is just necessary to define the appropriate value of fuzzy tolerance for the operation. To define that value it is necessary to measure the value of the gap (or the value of embedding depth) between the entities of the models, slightly increase it (to make the shifted entities coincident in terms of their tolerance plus the additional one) and pass it to the algorithm.
2544
2545 Fuzzy option is included in interface of Intersection Part (class *BOPAlgo_PaveFiller*) and application programming interface (class  *BRepAlgoAPI_BooleanOperation*)
2546
2547 @subsubsection occt_algorithms_11a_1_1 Examples
2548 The following examples demonstrate the advantages of usage Fuzzy option operations over the Basic Operations in typical situations.
2549
2550 #### Case 1
2551
2552 In this example the cylinder (shown in yellow and transparent) is subtracted from the box (shown in red). The cylinder is shifted by  5e<sup>-5</sup> relatively to the box along its axis (the distance between rear faces of the box and cylinder is 5e<sup>-5</sup>).
2553
2554 @figure{/user_guides/boolean_operations/images/boolean_image121.png,"",240}
2555   
2556 The following results are obtained using Basic Operations and the Fuzzy ones with the fuzzy value 5e<sup>-5</sup>:
2557
2558 @figure{/user_guides/boolean_operations/images/boolean_image122.png,"Result of CUT operation obtained with Basic Operations",240}
2559
2560 @figure{/user_guides/boolean_operations/images/boolean_image123.png,"Result of CUT operation obtained with Fuzzy Option",240}
2561
2562 In this example Fuzzy option allows eliminating a very thin part of the result shape produced by Basic algorithm due to misalignment of rear faces of the box and the cylinder. 
2563
2564 #### Case 2
2565
2566 In this example two boxes are fused. One of them has dimensions 10*10*10, and the other is 10*10.000001*10.000001 and adjacent to the first one. There is no gap in this case as the surfaces of the neighboring faces coincide, but one box is slightly greater than the other. 
2567
2568 @figure{/user_guides/boolean_operations/images/boolean_image124.png,"",240}
2569
2570 The following results are obtained using Basic Operations and the Fuzzy ones with the fuzzy value 1e<sup>-6</sup>: 
2571
2572 @figure{/user_guides/boolean_operations/images/boolean_image125.png,"Result of CUT operation obtained with Basic Operations",240}
2573
2574 @figure{/user_guides/boolean_operations/images/boolean_image126.png,"Result of CUT operation obtained with Fuzzy Option",240}
2575
2576 In this example Fuzzy option allows eliminating an extremely narrow face in the result produced by Basic operation.
2577
2578 #### Case 3
2579
2580 In this example the small planar face (shown in orange) is subtracted from the big one (shown in yellow). There is a gap 1e<sup>-5</sup> between the edges of these faces.
2581
2582 @figure{/user_guides/boolean_operations/images/boolean_image127.png,"",240}
2583
2584 The following results are obtained using Basic Operations and the Fuzzy ones with the fuzzy value 1e<sup>-5</sup>: 
2585
2586 @figure{/user_guides/boolean_operations/images/boolean_image128.png,"Result of CUT operation obtained with Basic Operations",240}
2587
2588 @figure{/user_guides/boolean_operations/images/boolean_image129.png,"Result of CUT operation obtained with Fuzzy Option",240}
2589
2590 In this example Fuzzy options eliminated a pin-like protrusion resulting from the gap between edges of the argument faces.
2591
2592 #### Case 4
2593
2594 In this example the small edge is subtracted from the big one. The edges are overlapping not precisely, with max deviation between them equal to 5.28004e<sup>-5</sup>. We will use 6e<sup>-5</sup> value for Fuzzy option.
2595
2596 @figure{/user_guides/boolean_operations/images/boolean_image130.png,"",240}
2597
2598 The following results are obtained using Basic Operations and the Fuzzy ones with the fuzzy value 6e<sup>-5</sup>: 
2599
2600 @figure{/user_guides/boolean_operations/images/boolean_image131.png,"Result of CUT operation obtained with Basic Operations",240}
2601
2602 @figure{/user_guides/boolean_operations/images/boolean_image132.png,"Result of CUT operation obtained with Fuzzy Option",240}
2603
2604 This example stresses not only the validity, but also the performance issue. The usage of Fuzzy option with the appropriate value allows processing the case much faster than with the pure Basic operation. The performance gain for the case is 45 (Processor: Intel(R) Core(TM) i5-3450 CPU @ 3.10 GHz).
2605
2606 @subsection occt_algorithms_11a_2 Gluing Operation
2607
2608 The Gluing operation is the option of the Basic Operations such as General Fuse, Splitting, Boolean, Section, Maker Volume and Cells building operations.
2609 It has been designed to speed up the computation of the interferences among arguments of the operations on special cases, in which the arguments may be overlapping but do not have real intersections between their sub-shapes.
2610
2611 This option cannot be used on the shapes having real intersections, like intersection vertex between edges, or intersection vertex between edge and a face or intersection line between faces:
2612
2613 @figure{/user_guides/boolean_operations/images/glue_options_image002.png,"Intersecting faces",240}
2614
2615 There are two possibilities of overlapping shapes:
2616 * The shapes can be partially coinciding - the faces do not have intersection curves, but overlapping. The faces of such arguments will be split during the operation. The following picture illustrates such shapes:
2617
2618 @figure{/user_guides/boolean_operations/images/glue_options_image001.png,"Partially coinciding faces",240}
2619
2620 * The shapes can be fully coinciding - there should be no partial overlapping of the faces, thus no intersection of type EDGE/FACE at all. In such cases the faces will not be split during the operation.
2621
2622 @figure{/user_guides/boolean_operations/images/glue_options_image003.png,"Full coinciding faces of the boxes",240}
2623
2624 Thus, there are two possible options - for full and partial coincidence of the shapes.
2625
2626 Even though there are no real intersections on such cases without Gluing options the algorithm will still intersect the sub-shapes of the arguments with interfering bounding boxes.
2627
2628 The performance improvement in gluing mode is achieved by excluding the most time consuming computations and in some case can go up to 90%:
2629 * Exclude computation of FACE/FACE intersections for partial coincidence;
2630 * Exclude computation of VERTEX/FACE, EDGE/FACE and FACE/FACE intersections for full coincidence.
2631
2632 By setting the Gluing option for the operation user should guarantee that the arguments are really coinciding. The algorithm does not check this itself. Setting inappropriate option for the operation is likely to lead to incorrect result.
2633
2634 @subsubsection occt_algorithms_11a_2_1 Usage
2635
2636 The Gluing option is an enumeration implemented in BOPAlgo_GlueEnum.hxx:
2637 * BOPAlgo_GlueOff - default value for the algorithms, Gluing is switched off;
2638 * BOPAlgo_GlueShift - Glue option for shapes with partial coincidence;
2639 * BOPAlgo_GlueFull - Glue option for shapes with full coincidence.
2640
2641 #### API level
2642 For setting the Gluing options for the algorithm it is just necessary to call the SetGlue(const BOPAlgo_Glue) method with appropriate value:
2643 ~~~~
2644 BOPAlgo_Builder aGF;
2645 //
2646 ....
2647 // setting the gluing option to speed up intersection of the arguments
2648 aGF.SetGlue(BOPAlgo_GlueShift)
2649 //
2650 ....
2651 ~~~~
2652
2653 #### TCL level
2654 For setting the Gluing options in DRAW it is necessary to call the <i>bglue</i> command with appropriate value:
2655 * 0 - default value, Gluing is off;
2656 * 1 - for partial coincidence;
2657 * 2 - for full coincidence
2658
2659 ~~~~
2660 bglue 1
2661 ~~~~
2662
2663 @subsubsection occt_algorithms_11a_2_2 Examples
2664 #### Case1 - Fusing the 64 bspline boxes into one solid
2665
2666 @figure{/user_guides/boolean_operations/images/glue_options_image004.png,"BSpline Boxes with partial coincidence",240}
2667
2668 Performance improvement from using the GlueShift option in this case is about 70 percent.
2669
2670 #### Case2 - Sewing faces of the shape after reading from IGES
2671
2672 @figure{/user_guides/boolean_operations/images/glue_options_image005.png,"Faces with coinciding but not shared edges",240}
2673
2674 Performance improvement in this case is also about 70 percent.
2675
2676 @subsection occt_algorithms_11a_3 Safe processing mode
2677
2678 The safe processing mode is the advanced option in Boolean Operation component. This mode can be applied to all Basic operations such as General Fuse, Splitting, Boolean, Section, Maker Volume, Cells building.
2679 This option allows keeping the input arguments untouched. In other words, switching this option on prevents the input arguments from any modification such as tolerance increase, addition of the P-Curves on edges, etc.
2680
2681 The option can be very useful for implementation of the Undo/Redo mechanism in the applications and allows performing the operation many times without changing the inputs.
2682
2683 By default the safe processing option is switched off for the algorithms. Enabling this option might slightly decrease the performance of the operation, because instead of the modification of some entity it will be necessary to create the copy of this entity and modify it. However, this degradation should be very small because the copying is performed only in case of necessity.
2684
2685 The option is also available in the Intersection algorithm - *BOPAlgo_PaveFiller*. To perform several different operations on the same arguments, the safe processing mode can be enabled in PaveFiller, prepared only once and then used in operations. It is enough to set this option to PaveFiller only and all algorithms taking this PaveFiller will also work in the safe mode.
2686
2687 @subsubsection occt_algorithms_11a_3_1 Usage
2688
2689 #### API level
2690
2691 To enable/disable the safe processing mode for the algorithm, it is necessary to call *SetNonDestructive()* method with the  appropriate value:
2692 ~~~~
2693 BOPAlgo_Builder aGF;
2694 //
2695 ....
2696 // enabling the safe processing mode to prevent modification of the input shapes
2697 aGF.SetNonDestructive(Standard_True);
2698 //
2699 ....
2700 ~~~~
2701
2702 #### TCL level
2703 To enable the safe processing mode for the operation in DRAW, it is necessary to call the <i>bnondestructive</i> command with the appropriate value:
2704 * 0 - default value, the safe mode is switched off;
2705 * 1 - the safe mode will be switched on.
2706
2707 ~~~~
2708 bnondestructive 1
2709 ~~~~
2710
2711
2712 @section occt_algorithms_11b Usage 
2713
2714 The chapter contains some examples of the OCCT Boolean Component usage. The usage is possible on two levels: C++ and Tcl. 
2715
2716 @subsection occt_algorithms_11b_1 Package BRepAlgoAPI
2717
2718 The package *BRepAlgoAPI* provides the Application Programming Interface of the Boolean Component.
2719
2720 The package consists of the following classes:
2721 * *BRepAlgoAPI_Algo* -- the root class that provides the interface for algorithms. 
2722 * *BRepAlgoAPI_BuilderAlgo* -- the class API level of General Fuse algorithm.
2723 * *BRepAlgoAPI_Splitter* -- the class API level of the Splitter algorithm.
2724 * *BRepAlgoAPI_BooleanOperation* -- the root class for the classes *BRepAlgoAPI_Fuse*. *BRepAlgoAPI_Common*, *BRepAlgoAPI_Cut* and *BRepAlgoAPI_Section*.
2725 * *BRepAlgoAPI_Fuse* -- the class provides Boolean fusion operation. 
2726 * *BRepAlgoAPI_Common* -- the class provides Boolean common operation.
2727 * *BRepAlgoAPI_Cut* -- the class provides Boolean cut operation.
2728 * *BRepAlgoAPI_Section* -- the class provides Boolean section operation.
2729
2730 @figure{/user_guides/boolean_operations/images/operations_image065.png,"Diagram of BRepAlgoAPI package",420}
2731
2732 The detailed description of the classes can be found in the corresponding .hxx files. The examples are below in this chapter.
2733
2734 @subsection occt_algorithms_11b_2 Package BOPTest
2735 The package *BOPTest* provides the usage of the Boolean Component on Tcl level. The method *BOPTest::APICommands* contains corresponding Tcl commands: 
2736
2737 * *bapibuild* -- for General Fuse Operator;
2738 * *bapisplit* -- for Splitter Operator;
2739 * *bapibop* -- for Boolean Operator and Section Operator.
2740
2741 The examples of how to use the commands are below in this chapter.
2742
2743 @subsubsection occt_algorithms_11b_2_1 Case 1. General Fuse operation
2744
2745 The following example illustrates how to use General Fuse operator:
2746
2747 #### C++ Level
2748
2749 ~~~~
2750 #include <TopoDS_Shape.hxx>
2751 #include <TopTools_ListOfShape.hxx>
2752 #include <BRepAlgoAPI_BuilderAlgo.hxx>
2753  {…
2754   Standard_Boolean bRunParallel;
2755   Standard_Integer iErr;
2756   Standard_Real aFuzzyValue;
2757   BRepAlgoAPI_BuilderAlgo aBuilder;
2758   //
2759   // prepare the arguments
2760   TopTools_ListOfShape& aLS=…;
2761   //
2762   bRunParallel=Standard_True;
2763   aFuzzyValue=2.1e-5;
2764   //
2765   // set the arguments  
2766   aBuilder.SetArguments(aLS);
2767   // set parallel processing mode 
2768   // if  bRunParallel= Standard_True :  the parallel processing is switched on
2769   // if  bRunParallel= Standard_False :  the parallel processing is switched off
2770   aBuilder.SetRunParallel(bRunParallel);
2771   //
2772   // set Fuzzy value
2773   // if aFuzzyValue=0.: the Fuzzy option is off
2774   //  if aFuzzyValue>0.: the Fuzzy option is on
2775   aBuilder.SetFuzzyValue(aFuzzyValue);
2776   //
2777   // safe mode - avoid modification of the arguments
2778   Standard_Boolean bSafeMode = Standard_True;
2779   // if bSafeMode == Standard_True  - the safe mode is switched on
2780   // if bSafeMode == Standard_False - the safe mode is switched off
2781   aBuilder.SetNonDestructive(bSafeMode);
2782   //
2783   // gluing options - for coinciding arguments
2784   BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
2785   // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
2786   // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
2787   // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
2788   aBuilder.SetGlue(aGlueOpt);
2789   //
2790   // run the algorithm 
2791   aBuilder.Build(); 
2792   iErr=aBuilder.ErrorStatus();
2793   if (iErr) {
2794     // an error treatment
2795     return;
2796   }
2797   //
2798   // result of the operation aR
2799   const TopoDS_Shape& aR=aBuilder.Shape();
2800
2801 }
2802 ~~~~
2803
2804 #### Tcl Level
2805
2806 ~~~~
2807 # prepare the arguments
2808 box b1 10 10 10 
2809 box b2 3 4 5 10 10 10 
2810 box b3 5 6 7 10 10 10 
2811 #
2812 # clear inner contents
2813 bclearobjects; bcleartools;
2814 #
2815 # set the arguments
2816 baddobjects b1 b2 b3
2817 # set parallel processing mode
2818 # 1:  the parallel processing is switched on
2819 # 0:  the parallel processing is switched off
2820 brunparallel 1 
2821 #
2822 # set Fuzzy value
2823 # 0.    : the Fuzzy option is off
2824 # >0. : the Fuzzy option is on
2825 bfuzzyvalue 0.
2826 #
2827 # set safe processing mode
2828 bnondestructive 1
2829 # set safe mode
2830 # 1 - the safe processing mode is switched on
2831 # 0 - the safe processing mode is switched off
2832 #
2833 # set gluing mode
2834 bglue 1
2835 # set the gluing mode
2836 # 1 or 2 - the gluing mode is switched on
2837 # 0 - the gluing mode is switched off
2838 #
2839 # run the algorithm
2840 # r is the result of the operation
2841 bapibuild r 
2842 ~~~~
2843
2844 @subsubsection occt_algorithms_11b_2_2 Case 2. Splitting operation
2845
2846 The following example illustrates how to use the Splitter operator:
2847
2848 #### C++ Level
2849
2850 ~~~~
2851 #include <TopoDS_Shape.hxx>
2852 #include <TopTools_ListOfShape.hxx>
2853 #include <BRepAlgoAPI_Splitter.hxx>
2854 //
2855 BRepAlgoAPI_BuilderAlgo aSplitter;
2856 //
2857 // prepare the arguments
2858 // objects
2859 TopTools_ListOfShape& aLSObjects = … ;
2860 // tools
2861 TopTools_ListOfShape& aLSTools = … ;
2862 //
2863 // set the arguments
2864 aSplitter.SetArguments(aLSObjects);
2865 aSplitter.SetTools(aLSTools);
2866 //
2867 // set options
2868 // parallel processing mode 
2869 Standard_Boolean bRunParallel = Standard_True;
2870 // bRunParallel == Standard_True  - the parallel processing is switched on
2871 // bRunParallel == Standard_False - the parallel processing is switched off
2872 aSplitter.SetRunParallel();
2873 //
2874 // fuzzy value - additional tolerance for the operation
2875 Standard_Real aFuzzyValue = 1.e-5;
2876 // if aFuzzyValue == 0. - the Fuzzy option is off
2877 // if aFuzzyValue > 0.  - the Fuzzy option is on
2878 aSplitter.SetFuzzyValue(aFuzzyValue);
2879 //
2880 // safe mode - avoid modification of the arguments
2881 Standard_Boolean bSafeMode = Standard_True;
2882 // if bSafeMode == Standard_True  - the safe mode is switched on
2883 // if bSafeMode == Standard_False - the safe mode is switched off
2884 aSplitter.SetNonDestructive(bSafeMode);
2885 //
2886 // gluing options - for coinciding arguments
2887 BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
2888 // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
2889 // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
2890 // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
2891 aSplitter.SetGlue(aGlueOpt);
2892 //
2893 // run the algorithm 
2894 aSplitter.Build(); 
2895 // check error status
2896 if (aSplitter.ErrorStatus()) {
2897   return;
2898 }
2899 //
2900 // result of the operation aResult
2901 const TopoDS_Shape& aResult = aSplitter.Shape();
2902 ~~~~
2903
2904 #### Tcl Level
2905
2906 ~~~~
2907 # prepare the arguments
2908 # objects
2909 box b1 10 10 10 
2910 box b2 7 0 0 10 10 10
2911
2912 # tools
2913 plane p 10 5 5 0 1 0
2914 mkface f p -20 20 -20 20
2915 #
2916 # clear inner contents
2917 bclearobjects; bcleartools;
2918 #
2919 # set the objects
2920 baddobjects b1 b2
2921 # set the tools
2922 baddtools f
2923 #
2924 # set parallel processing mode
2925 # 1:  the parallel processing is switched on
2926 # 0:  the parallel processing is switched off
2927 brunparallel 1 
2928 #
2929 # set Fuzzy value
2930 # 0.  : the Fuzzy option is off
2931 # >0. : the Fuzzy option is on
2932 bfuzzyvalue 0.
2933 #
2934 # set safe processing mode
2935 bnondestructive 1
2936 # set safe mode
2937 # 1 - the safe processing mode is switched on
2938 # 0 - the safe processing mode is switched off
2939 #
2940 # set gluing mode
2941 bglue 1
2942 # set the gluing mode
2943 # 1 or 2 - the gluing mode is switched on
2944 # 0 - the gluing mode is switched off
2945 #
2946 # run the algorithm
2947 # r is the result of the operation
2948 bapisplit r 
2949 ~~~~
2950
2951 @subsubsection occt_algorithms_11b_2_3 Case 3. Common operation
2952
2953 The following example illustrates how to use Common operation:
2954
2955 #### C++ Level
2956
2957 ~~~~
2958 #include <TopoDS_Shape.hxx>
2959 #include <TopTools_ListOfShape.hxx>
2960 #include < BRepAlgoAPI_Common.hxx>
2961  {…
2962   Standard_Boolean bRunParallel;
2963   Standard_Integer iErr;
2964   Standard_Real aFuzzyValue;
2965   BRepAlgoAPI_Common aBuilder;
2966   
2967   // perpare the arguments
2968   TopTools_ListOfShape& aLS=…;
2969   TopTools_ListOfShape& aLT=…;
2970   //
2971   bRunParallel=Standard_True;
2972   aFuzzyValue=2.1e-5;
2973   //
2974   // set the arguments  
2975   aBuilder.SetArguments(aLS);
2976   aBuilder.SetTools(aLT);
2977   //    
2978   // set parallel processing mode 
2979   // if  bRunParallel= Standard_True :  the parallel processing is switched on
2980   // if  bRunParallel= Standard_False :  the parallel processing is switched off
2981   aBuilder.SetRunParallel(bRunParallel);
2982   //
2983   // set Fuzzy value
2984   // if aFuzzyValue=0.: the Fuzzy option is off
2985   //  if aFuzzyValue>0.: the Fuzzy option is on
2986   aBuilder.SetFuzzyValue(aFuzzyValue);
2987   //
2988   // safe mode - avoid modification of the arguments
2989   Standard_Boolean bSafeMode = Standard_True;
2990   // if bSafeMode == Standard_True  - the safe mode is switched on
2991   // if bSafeMode == Standard_False - the safe mode is switched off
2992   aBuilder.SetNonDestructive(bSafeMode);
2993   //
2994   // gluing options - for coinciding arguments
2995   BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
2996   // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
2997   // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
2998   // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
2999   aBuilder.SetGlue(aGlueOpt);
3000   //
3001   // run the algorithm 
3002   aBuilder.Build(); 
3003   iErr=aBuilder.ErrorStatus();
3004   if (iErr) {
3005     // an error treatment
3006     return;
3007   }
3008   //
3009   // result of the operation aR
3010   const TopoDS_Shape& aR=aBuilder.Shape();
3011
3012 }
3013 ~~~~
3014
3015 #### Tcl Level
3016
3017 ~~~~
3018 # prepare the arguments
3019 box b1 10 10 10 
3020 box b2 7 0 4 10 10 10 
3021 box b3 14 0 0 10 10 10 
3022 #
3023 # clear inner contents
3024 bclearobjects; bcleartools;
3025 #
3026 # set the arguments
3027 baddobjects b1 b3
3028 baddtools b2
3029 #
3030 # set parallel processing mode
3031 # 1:  the parallel processing is switched on
3032 # 0:  the parallel processing is switched off
3033 brunparallel 1
3034 #
3035 # set Fuzzy value
3036 # 0.    : the Fuzzy option is off
3037 # >0. : the Fuzzy option is on
3038 bfuzzyvalue 0.
3039 #
3040 # set safe processing mode
3041 bnondestructive 1
3042 # set safe mode
3043 # 1 - the safe processing mode is switched on
3044 # 0 - the safe processing mode is switched off
3045 #
3046 # set gluing mode
3047 bglue 1
3048 # set the gluing mode
3049 # 1 or 2 - the gluing mode is switched on
3050 # 0 - the gluing mode is switched off
3051 #
3052 # run the algorithm
3053 # r is the result of the operation
3054 # 0 means Common operation
3055 bapibop r 0
3056 ~~~~
3057
3058 @subsubsection occt_algorithms_11b_2_4 Case 4. Fuse operation
3059
3060 The following example illustrates how to use Fuse operation:
3061
3062 #### C++ Level
3063
3064 ~~~~
3065 #include <TopoDS_Shape.hxx>
3066 #include <TopTools_ListOfShape.hxx>
3067 #include < BRepAlgoAPI_Fuse.hxx>
3068  {…
3069   Standard_Boolean bRunParallel;
3070   Standard_Integer iErr;
3071   Standard_Real aFuzzyValue;
3072   BRepAlgoAPI_Fuse aBuilder;
3073   
3074   // perpare the arguments
3075   TopTools_ListOfShape& aLS=…;
3076   TopTools_ListOfShape& aLT=…;
3077   //
3078   bRunParallel=Standard_True;
3079   aFuzzyValue=2.1e-5;
3080   //
3081   // set the arguments  
3082   aBuilder.SetArguments(aLS);
3083   aBuilder.SetTools(aLT);
3084   //    
3085   // set parallel processing mode 
3086   // if  bRunParallel= Standard_True :  the parallel processing is switched on
3087   // if  bRunParallel= Standard_False :  the parallel processing is switched off
3088   aBuilder.SetRunParallel(bRunParallel);
3089   //
3090   // set Fuzzy value
3091   // if aFuzzyValue=0.: the Fuzzy option is off
3092   //  if aFuzzyValue>0.: the Fuzzy option is on
3093   aBuilder.SetFuzzyValue(aFuzzyValue);
3094   //
3095   // safe mode - avoid modification of the arguments
3096   Standard_Boolean bSafeMode = Standard_True;
3097   // if bSafeMode == Standard_True  - the safe mode is switched on
3098   // if bSafeMode == Standard_False - the safe mode is switched off
3099   aBuilder.SetNonDestructive(bSafeMode);
3100   //
3101   // gluing options - for coinciding arguments
3102   BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
3103   // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
3104   // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
3105   // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
3106   aBuilder.SetGlue(aGlueOpt);
3107   //
3108   // run the algorithm 
3109   aBuilder.Build(); 
3110   iErr=aBuilder.ErrorStatus();
3111   if (iErr) {
3112     // an error treatment
3113     return;
3114   }
3115   //
3116   // result of the operation aR
3117   const TopoDS_Shape& aR=aBuilder.Shape();
3118
3119 }
3120 ~~~~
3121
3122 #### Tcl Level
3123
3124 ~~~~
3125 # prepare the arguments
3126 box b1 10 10 10 
3127 box b2 7 0 4 10 10 10 
3128 box b3 14 0 0 10 10 10 
3129 #
3130 # clear inner contents
3131 bclearobjects; bcleartools;
3132 #
3133 # set the arguments
3134 baddobjects b1 b3
3135 baddtools b2
3136 #
3137 # set parallel processing mode
3138 # 1:  the parallel processing is switched on
3139 # 0:  the parallel processing is switched off
3140 brunparallel 1
3141 #
3142 # set Fuzzy value
3143 # 0.    : the Fuzzy option is off
3144 # >0. : the Fuzzy option is on
3145 bfuzzyvalue 0.
3146 #
3147 # set safe processing mode
3148 bnondestructive 1
3149 # set safe mode
3150 # 1 - the safe processing mode is switched on
3151 # 0 - the safe processing mode is switched off
3152 #
3153 # set gluing mode
3154 bglue 1
3155 # set the gluing mode
3156 # 1 or 2 - the gluing mode is switched on
3157 # 0 - the gluing mode is switched off
3158 #
3159 # run the algorithm
3160 # r is the result of the operation
3161 # 1 means Fuse operation
3162 bapibop r 1
3163 ~~~~
3164
3165 @subsubsection occt_algorithms_11b_2_5 Case 5. Cut operation
3166
3167 The following example illustrates how to use Cut operation:
3168
3169 #### C++ Level
3170
3171 ~~~~
3172 #include <TopoDS_Shape.hxx>
3173 #include <TopTools_ListOfShape.hxx>
3174 #include < BRepAlgoAPI_Cut.hxx>
3175  {…
3176   Standard_Boolean bRunParallel;
3177   Standard_Integer iErr;
3178   Standard_Real aFuzzyValue;
3179   BRepAlgoAPI_Cut aBuilder;
3180   
3181   // perpare the arguments
3182   TopTools_ListOfShape& aLS=…;
3183   TopTools_ListOfShape& aLT=…;
3184   //
3185   bRunParallel=Standard_True;
3186   aFuzzyValue=2.1e-5;
3187   //
3188   // set the arguments  
3189   aBuilder.SetArguments(aLS);
3190   aBuilder.SetTools(aLT);
3191   //    
3192   // set parallel processing mode 
3193   // if  bRunParallel= Standard_True :  the parallel processing is switched on
3194   // if  bRunParallel= Standard_False :  the parallel processing is switched off
3195   aBuilder.SetRunParallel(bRunParallel);
3196   //
3197   // set Fuzzy value
3198   // if aFuzzyValue=0.: the Fuzzy option is off
3199   //  if aFuzzyValue>0.: the Fuzzy option is on
3200   aBuilder.SetFuzzyValue(aFuzzyValue);
3201   //
3202   // safe mode - avoid modification of the arguments
3203   Standard_Boolean bSafeMode = Standard_True;
3204   // if bSafeMode == Standard_True  - the safe mode is switched on
3205   // if bSafeMode == Standard_False - the safe mode is switched off
3206   aBuilder.SetNonDestructive(bSafeMode);
3207   //
3208   // gluing options - for coinciding arguments
3209   BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
3210   // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
3211   // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
3212   // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
3213   aBuilder.SetGlue(aGlueOpt);
3214   //
3215   // run the algorithm 
3216   aBuilder.Build(); 
3217   iErr=aBuilder.ErrorStatus();
3218   if (iErr) {
3219     // an error treatment
3220     return;
3221   }
3222   //
3223   // result of the operation aR
3224   const TopoDS_Shape& aR=aBuilder.Shape();
3225
3226 }
3227 ~~~~
3228
3229 #### Tcl Level
3230
3231 ~~~~
3232 # prepare the arguments
3233 box b1 10 10 10 
3234 box b2 7 0 4 10 10 10 
3235 box b3 14 0 0 10 10 10 
3236 #
3237 # clear inner contents
3238 bclearobjects; bcleartools;
3239 #
3240 # set the arguments
3241 baddobjects b1 b3
3242 baddtools b2
3243 #
3244 # set parallel processing mode
3245 # 1:  the parallel processing is switched on
3246 # 0:  the parallel processing is switched off
3247 brunparallel 1
3248 #
3249 # set Fuzzy value
3250 # 0.    : the Fuzzy option is off
3251 # >0. : the Fuzzy option is on
3252 bfuzzyvalue 0.
3253 #
3254 # set safe processing mode
3255 bnondestructive 1
3256 # set safe mode
3257 # 1 - the safe processing mode is switched on
3258 # 0 - the safe processing mode is switched off
3259 # set gluing mode
3260 #
3261 bglue 1
3262 # set the gluing mode
3263 # 1 or 2 - the gluing mode is switched on
3264 # 0 - the gluing mode is switched off
3265 #
3266 # run the algorithm
3267 # r is the result of the operation
3268 # 2 means Cut operation
3269 bapibop r 2
3270 ~~~~
3271
3272
3273 @subsubsection occt_algorithms_11b_2_6 Case 6. Section operation
3274
3275 The following example illustrates how to use Section operation:
3276
3277 #### C++ Level
3278
3279 ~~~~
3280 #include <TopoDS_Shape.hxx>
3281 #include <TopTools_ListOfShape.hxx>
3282 #include < BRepAlgoAPI_Section.hxx>
3283  {…
3284   Standard_Boolean bRunParallel;
3285   Standard_Integer iErr;
3286   Standard_Real aFuzzyValue;
3287   BRepAlgoAPI_Section aBuilder;
3288   
3289   // perpare the arguments
3290   TopTools_ListOfShape& aLS=…;
3291   TopTools_ListOfShape& aLT=…;
3292   //
3293   bRunParallel=Standard_True;
3294   aFuzzyValue=2.1e-5;
3295   //
3296   // set the arguments  
3297   aBuilder.SetArguments(aLS);
3298   aBuilder.SetTools(aLT);
3299   //    
3300   // set parallel processing mode 
3301   // if  bRunParallel= Standard_True :  the parallel processing is switched on
3302   // if  bRunParallel= Standard_False :  the parallel processing is switched off
3303   aBuilder.SetRunParallel(bRunParallel);
3304   //
3305   // set Fuzzy value
3306   // if aFuzzyValue=0.: the Fuzzy option is off
3307   //  if aFuzzyValue>0.: the Fuzzy option is on
3308   aBuilder.SetFuzzyValue(aFuzzyValue);
3309   //
3310   // safe mode - avoid modification of the arguments
3311   Standard_Boolean bSafeMode = Standard_True;
3312   // if bSafeMode == Standard_True  - the safe mode is switched on
3313   // if bSafeMode == Standard_False - the safe mode is switched off
3314   aBuilder.SetNonDestructive(bSafeMode);
3315   //
3316   // gluing options - for coinciding arguments
3317   BOPAlgo_GlueEnum aGlueOpt = BOPAlgo_GlueFull;
3318   // if aGlueOpt == BOPAlgo_GlueOff   - the gluing mode is switched off
3319   // if aGlueOpt == BOPAlgo_GlueShift - the gluing mode is switched on
3320   // if aGlueOpt == BOPAlgo_GlueFull  - the gluing mode is switched on
3321   aBuilder.SetGlue(aGlueOpt);
3322   //
3323   // run the algorithm 
3324   aBuilder.Build(); 
3325   iErr=aBuilder.ErrorStatus();
3326   if (iErr) {
3327     // an error treatment
3328     return;
3329   }
3330   //
3331   // result of the operation aR
3332   const TopoDS_Shape& aR=aBuilder.Shape();
3333
3334 }
3335 ~~~~
3336
3337 #### Tcl Level
3338
3339 ~~~~
3340 # prepare the arguments
3341 box b1 10 10 10 
3342 box b2 3 4 5 10 10 10 
3343 box b3 5 6 7 10 10 10 
3344 #
3345 # clear inner contents
3346 bclearobjects; bcleartools;
3347 #
3348 # set the arguments
3349 baddobjects b1 b3
3350 baddtools b2
3351 #
3352 # set parallel processing mode
3353 # 1:  the parallel processing is switched on
3354 # 0:  the parallel processing is switched off
3355 brunparallel 1
3356 #
3357 # set Fuzzy value
3358 # 0.    : the Fuzzy option is off
3359 # >0. : the Fuzzy option is on
3360 bfuzzyvalue 0.
3361 #
3362 # set safe processing mode
3363 bnondestructive 1
3364 # set safe mode
3365 # 1 - the safe processing mode is switched on
3366 # 0 - the safe processing mode is switched off
3367 #
3368 # set gluing mode
3369 bglue 1
3370 # set the gluing mode
3371 # 1 or 2 - the gluing mode is switched on
3372 # 0 - the gluing mode is switched off
3373 #
3374 # run the algorithm
3375 # r is the result of the operation
3376 # 4 means Section operation
3377 bapibop r 4
3378 ~~~~
3379