Salome HOME
Merge remote branch 'origin/hydro/imps_2015'
[modules/geom.git] / doc / salome / gui / GEOM / input / tui_sorting_shapes.doc
1 /*!
2
3 \page sorting_shapes_page Sorting Shapes Algorithm
4
5 Some algorithms of GEOM module return a list of shapes sorted in accordance
6 with some criterion. The goal of this sorting is a possibility to obtain
7 stable result regardless SALOME version being used.
8
9 The algorithm that provides such a possibility consists of the following steps:
10
11 <ol>
12   <li>For each shape a pair of point and number is associated. The point and
13       number depend on the shape type:
14     <table border="1" align="center" cellpadding="3" cellspacing="0" bgcolor="#EEEEEE">
15       <tr align=center bgcolor=#999999>
16         <td>Shape Type</td>
17         <td>Point</td>
18         <td>Number</td>
19       </tr><tr align=center>
20         <td>Vertex</td>
21         <td>Vertex isself</td>
22         <td>Orientation value converted to double</td>
23       </tr><tr align=center>
24         <td>Edge, Wire</td>
25         <td>Center of mass</td>
26         <td>Total length of edges</td>
27       </tr>
28       </tr><tr align=center>
29         <td>Face, Shell</td>
30         <td>Center of mass</td>
31         <td>Total area of faces</td>
32       </tr>
33       </tr><tr align=center>
34         <td>Other</td>
35         <td>Center of mass</td>
36         <td>Total volume of solids</td>
37       </tr>
38     </table>
39   </li> 
40   <li>Each point is converted to double using the following expression:
41       \code point.X() * 999.0 + point.Y() * 99.0 + point.Z() * 0.9 \endcode
42   </li> 
43   <li>The shapes are sorted in ascending order. The shape comparison criterion
44       is the following. Shape_1 is considered less then Shape_2 if:
45     <ul>
46       <li>Shape_1's double value obtained on the step 2 is less than
47           the corresponding value of Shape_2.<br>
48           \b Otherwise if they are equal with the confusion tolerance (1.e-7):
49       </li>
50       <li>Shape_1's number obtained on the step 1 is less than the
51           corresponding number of Shape_2.<br>
52           \b Otherwise if they are equal with the confusion tolerance (1.e-7)
53           and the shapes have either Face or more complex type:
54       </li>
55       <li>Shape_1's squared diagonal of bounding box is less than the one
56           of Shape_2.<br>
57           \b Otherwise if they are equal with the confusion tolerance (1.e-7):
58       </li>
59       <li>Get the minimal and maximal values of X, Y and Z coordinates
60           of bounding boxes for Shape_1 and Shape_2. Compute the following
61           values for Shape_1 and Shape_2:
62           \code (aXmin+aXmax) * 999.0 + (aYmin+aYmax) * 99.0 + (aZmin+aZmax) * 0.9 \endcode
63           Shape_1 is less than Shape_2 if this value for Shape_1 is less
64           than the value for Shape_2.
65       </li>
66     </ul>
67   </li>
68 </ol>
69
70 This algorithm is used in the following \ref geomBuilder.geomBuilder "geomBuilder" methods:
71 - \ref SubShapeAllSortedCentres
72 - \ref SubShapeAllSortedCentresIDs
73 - \ref SubShapeSortedCentres
74 - \ref ExtractShapes
75
76 and as a part of some other algorithms where sorting is required.
77
78 */