Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / lineconn2d / LineConn2d_Object.h
1 // File:      LineConn2d_Object.h
2 // Created:   03.08.05 20:34:45
3 // Author:    Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
5
6
7 #ifndef LineConn2d_Object_HeaderFile
8 #define LineConn2d_Object_HeaderFile
9
10 #include <LineConn2d_Box.h>
11 #include <NCollection_List.hxx>
12
13 /**
14  * Data Object is represented by:
15  *  - Polyline (a list of points) for one closed contour defioning the shape
16  *  - Bounding box of the polyline.
17  * The Objects should be allocated/destroyed exclusively from the Model class.
18  */
19
20 class LineConn2d_Object 
21 {
22  public:
23
24   /// Iterator type, to retrieve the contour points
25   typedef NCollection_List<gp_XY>::Iterator PointIterator;
26
27   // ---------- PUBLIC METHODS ----------
28
29   /// Empty constructor.
30   inline LineConn2d_Object () {}
31
32   /**
33    * Add a next point to the polyline of the given Object.
34    * You should be careful to provide a correct index value.
35    */
36   inline void                       AddPoint  (const gp_XY& thePnt)
37   {
38     myPoints.Append (thePnt);
39     myIsModified = 1;
40   }
41
42   /**
43    * Update the Object internal data after its initialisation. This method
44    * builds the bounding box and performs other preparations.
45    */
46   Standard_EXPORT void              Update    ();
47
48   /**
49    * Query the bounding box.
50    */
51   inline const LineConn2d_Box&      Box       () const
52   { return myBox; }
53
54   /**
55    * Query the number of points in the contour.
56    */
57   inline Standard_Integer           NbPoints  () const
58   { return myPoints.Extent(); }
59
60   /**
61    * Get Iterator on points.
62    */
63   inline PointIterator              PointsIterator () const
64   { return myPoints; }
65
66   /**
67    * Query the last point in the contour.
68    */
69   inline const gp_XY&               LastPoint () const
70   { return myPoints.Last(); }
71
72   /**
73    * Classify a point towards the polygon defined by the object
74    * @param thePoint
75    *   The given point to be classified
76    * @param theTol
77    *   Tolerance for ON condition: if thePoint is nearer to any contour segment
78    *   than the value theTol, the method returns False.
79    * @return
80    *   True if the given point is outside the Object contour.
81    */
82   Standard_EXPORT Standard_Boolean  IsOut     (const gp_XY&        thePoint,
83                                                const Standard_Real theTol)const;
84
85  protected:
86   // ---------- PROTECTED METHODS ----------
87
88   /// Constructor.
89   inline LineConn2d_Object (const Handle(NCollection_BaseAllocator)& theAlloc)
90     : myPoints (theAlloc)  {}
91
92  private:
93   // ---------- PRIVATE FIELDS ----------
94
95   NCollection_List<gp_XY>       myPoints;
96   LineConn2d_Box                myBox;
97   Standard_Boolean              myIsModified : 1;
98
99   friend class LineConn2d_Model;
100 };
101
102 #endif