3 \page sorting_shapes_page Sorting Shapes Algorithm
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.
9 The algorithm that provides such a possibility consists of the following steps:
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>
19 </tr><tr align=center>
21 <td>Vertex isself</td>
22 <td>Orientation value converted to double</td>
23 </tr><tr align=center>
25 <td>Center of mass</td>
26 <td>Total length of edges</td>
28 </tr><tr align=center>
30 <td>Center of mass</td>
31 <td>Total area of faces</td>
33 </tr><tr align=center>
35 <td>Center of mass</td>
36 <td>Total volume of solids</td>
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
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:
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):
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:
55 <li>Shape_1's squared diagonal of bounding box is less than the one
57 \b Otherwise if they are equal with the confusion tolerance (1.e-7):
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.
70 This algorithm is used in the following \ref geomBuilder.geomBuilder "geomBuilder" methods:
71 - \ref SubShapeAllSortedCentres
72 - \ref SubShapeAllSortedCentresIDs
73 - \ref SubShapeSortedCentres
76 and as a part of some other algorithms where sorting is required.