]> SALOME platform Git repositories - modules/yacs.git/blob - src/lineconn2d/LineConn2d.h
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / lineconn2d / LineConn2d.h
1 // File:      LineConn2d.h
2 // Created:   04.08.05 22:26:39
3 // Author:    Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
5
6
7 #ifndef LineConn2d_HeaderFile
8 #define LineConn2d_HeaderFile
9
10 #include <Precision.hxx>
11
12 class LineConn2d_Object;
13 class gp_XY;
14
15 #ifdef __sparc
16 #define LineConn2d_FABS(x) ((x) < 0.? -(x) : (x))
17 #else
18 #include <math.h>
19 #define LineConn2d_FABS(x) ::fabs(x)
20 #endif
21
22 ///  Utilities
23 //
24
25 class LineConn2d
26 {
27  public:
28
29   /**
30    * One of 4 possible orientations.
31    */
32   typedef enum {
33     Indefinite  = -1,   ///< non-initialized
34     E           = 0,    ///< east
35     N           = 1,    ///< north
36     W           = 2,    ///< west
37     S           = 3,    ///< south
38     Indefinite1 = 4
39   } Orient;
40
41   // ---------- PUBLIC METHODS ----------
42
43   /**
44    * Test the value if it is small (absolute value is tested).
45    */
46   inline static Standard_Boolean IsSmall (const Standard_Real theVal)
47   { return LineConn2d_FABS (theVal) < Precision::Confusion(); }
48
49   /**
50    * Test the value for inclusion in the given interval.
51    * To ensure the inclusion the interval is extended by Confusion value.
52    * @param theVal
53    *   the given Real value
54    * @param theLow
55    *   lower bound of the interval
56    * @param theUp
57    *   upper bound of the interval
58    * @return
59    *   True if theVal is inside the interval inclusive.
60    */
61   inline static Standard_Boolean IsInside (const Standard_Real theVal,
62                                            const Standard_Real theLow,
63                                            const Standard_Real theUp)
64   { return (theVal > theLow - Precision::Confusion() &&
65             theVal < theUp  + Precision::Confusion()); }
66
67   /**
68    * Return the orientatation of the given axis.
69    * LineConn2d_Port can be used as subclass of the axis
70    */
71   Standard_EXPORT static Orient           Orientation (const gp_XY& aDir);
72
73   /**
74    * Test intersection of two Objects.
75    */
76   Standard_EXPORT static Standard_Boolean IsIntersect
77                                         (const LineConn2d_Object& anObj1,
78                                          const LineConn2d_Object& anObj2);
79
80
81  private:
82   // ---------- PRIVATE METHODS ----------
83   /// Empty constructor
84   LineConn2d () {}
85
86 };
87
88 #endif